1 /* ioctl() (mostly Linux Wireless Extensions) routines for Host AP driver */
3 #include <linux/slab.h>
4 #include <linux/types.h>
5 #include <linux/sched.h>
6 #include <linux/ethtool.h>
7 #include <linux/if_arp.h>
8 #include <net/lib80211.h>
10 #include "hostap_wlan.h"
12 #include "hostap_ap.h"
14 static struct iw_statistics
*hostap_get_wireless_stats(struct net_device
*dev
)
16 struct hostap_interface
*iface
;
18 struct iw_statistics
*wstats
;
20 iface
= netdev_priv(dev
);
23 /* Why are we doing that ? Jean II */
24 if (iface
->type
!= HOSTAP_INTERFACE_MAIN
)
27 wstats
= &local
->wstats
;
30 wstats
->discard
.code
=
31 local
->comm_tallies
.rx_discards_wep_undecryptable
;
32 wstats
->discard
.misc
=
33 local
->comm_tallies
.rx_fcs_errors
+
34 local
->comm_tallies
.rx_discards_no_buffer
+
35 local
->comm_tallies
.tx_discards_wrong_sa
;
37 wstats
->discard
.retries
=
38 local
->comm_tallies
.tx_retry_limit_exceeded
;
39 wstats
->discard
.fragment
=
40 local
->comm_tallies
.rx_message_in_bad_msg_fragments
;
42 if (local
->iw_mode
!= IW_MODE_MASTER
&&
43 local
->iw_mode
!= IW_MODE_REPEAT
) {
46 /* RID reading might sleep and it must not be called in
47 * interrupt context or while atomic. However, this
48 * function seems to be called while atomic (at least in Linux
49 * 2.5.59). Update signal quality values only if in suitable
50 * context. Otherwise, previous values read from tick timer
54 #endif /* in_atomic */
56 if (update
&& prism2_update_comms_qual(dev
) == 0)
57 wstats
->qual
.updated
= IW_QUAL_ALL_UPDATED
|
60 wstats
->qual
.qual
= local
->comms_qual
;
61 wstats
->qual
.level
= local
->avg_signal
;
62 wstats
->qual
.noise
= local
->avg_noise
;
64 wstats
->qual
.qual
= 0;
65 wstats
->qual
.level
= 0;
66 wstats
->qual
.noise
= 0;
67 wstats
->qual
.updated
= IW_QUAL_ALL_INVALID
;
74 static int prism2_get_datarates(struct net_device
*dev
, u8
*rates
)
76 struct hostap_interface
*iface
;
82 iface
= netdev_priv(dev
);
85 len
= local
->func
->get_rid(dev
, HFA384X_RID_SUPPORTEDDATARATES
, buf
,
90 val
= le16_to_cpu(*(__le16
*) buf
); /* string length */
92 if (len
- 2 < val
|| val
> 10)
95 memcpy(rates
, buf
+ 2, val
);
100 static int prism2_get_name(struct net_device
*dev
,
101 struct iw_request_info
*info
,
102 char *name
, char *extra
)
105 int len
, i
, over2
= 0;
107 len
= prism2_get_datarates(dev
, rates
);
109 for (i
= 0; i
< len
; i
++) {
110 if (rates
[i
] == 0x0b || rates
[i
] == 0x16) {
116 strcpy(name
, over2
? "IEEE 802.11b" : "IEEE 802.11-DS");
122 static int prism2_ioctl_siwencode(struct net_device
*dev
,
123 struct iw_request_info
*info
,
124 struct iw_point
*erq
, char *keybuf
)
126 struct hostap_interface
*iface
;
129 struct lib80211_crypt_data
**crypt
;
131 iface
= netdev_priv(dev
);
132 local
= iface
->local
;
134 i
= erq
->flags
& IW_ENCODE_INDEX
;
136 i
= local
->crypt_info
.tx_keyidx
;
139 if (i
< 0 || i
>= WEP_KEYS
)
142 crypt
= &local
->crypt_info
.crypt
[i
];
144 if (erq
->flags
& IW_ENCODE_DISABLED
) {
146 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
150 if (*crypt
!= NULL
&& (*crypt
)->ops
!= NULL
&&
151 strcmp((*crypt
)->ops
->name
, "WEP") != 0) {
152 /* changing to use WEP; deinit previously used algorithm */
153 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
156 if (*crypt
== NULL
) {
157 struct lib80211_crypt_data
*new_crypt
;
159 /* take WEP into use */
160 new_crypt
= kzalloc(sizeof(struct lib80211_crypt_data
),
162 if (new_crypt
== NULL
)
164 new_crypt
->ops
= lib80211_get_crypto_ops("WEP");
165 if (!new_crypt
->ops
) {
166 request_module("lib80211_crypt_wep");
167 new_crypt
->ops
= lib80211_get_crypto_ops("WEP");
169 if (new_crypt
->ops
&& try_module_get(new_crypt
->ops
->owner
))
170 new_crypt
->priv
= new_crypt
->ops
->init(i
);
171 if (!new_crypt
->ops
|| !new_crypt
->priv
) {
175 printk(KERN_WARNING
"%s: could not initialize WEP: "
176 "load module hostap_crypt_wep.o\n",
183 if (erq
->length
> 0) {
184 int len
= erq
->length
<= 5 ? 5 : 13;
186 if (len
> erq
->length
)
187 memset(keybuf
+ erq
->length
, 0, len
- erq
->length
);
188 (*crypt
)->ops
->set_key(keybuf
, len
, NULL
, (*crypt
)->priv
);
189 for (j
= 0; j
< WEP_KEYS
; j
++) {
190 if (j
!= i
&& local
->crypt_info
.crypt
[j
]) {
196 local
->crypt_info
.tx_keyidx
= i
;
198 /* No key data - just set the default TX key index */
199 local
->crypt_info
.tx_keyidx
= i
;
203 local
->open_wep
= erq
->flags
& IW_ENCODE_OPEN
;
205 if (hostap_set_encryption(local
)) {
206 printk(KERN_DEBUG
"%s: set_encryption failed\n", dev
->name
);
210 /* Do not reset port0 if card is in Managed mode since resetting will
211 * generate new IEEE 802.11 authentication which may end up in looping
212 * with IEEE 802.1X. Prism2 documentation seem to require port reset
213 * after WEP configuration. However, keys are apparently changed at
214 * least in Managed mode. */
215 if (local
->iw_mode
!= IW_MODE_INFRA
&& local
->func
->reset_port(dev
)) {
216 printk(KERN_DEBUG
"%s: reset_port failed\n", dev
->name
);
224 static int prism2_ioctl_giwencode(struct net_device
*dev
,
225 struct iw_request_info
*info
,
226 struct iw_point
*erq
, char *key
)
228 struct hostap_interface
*iface
;
232 struct lib80211_crypt_data
*crypt
;
234 iface
= netdev_priv(dev
);
235 local
= iface
->local
;
237 i
= erq
->flags
& IW_ENCODE_INDEX
;
239 i
= local
->crypt_info
.tx_keyidx
;
242 if (i
< 0 || i
>= WEP_KEYS
)
245 crypt
= local
->crypt_info
.crypt
[i
];
248 if (crypt
== NULL
|| crypt
->ops
== NULL
) {
250 erq
->flags
|= IW_ENCODE_DISABLED
;
254 if (strcmp(crypt
->ops
->name
, "WEP") != 0) {
255 /* only WEP is supported with wireless extensions, so just
256 * report that encryption is used */
258 erq
->flags
|= IW_ENCODE_ENABLED
;
262 /* Reads from HFA384X_RID_CNFDEFAULTKEY* return bogus values, so show
263 * the keys from driver buffer */
264 len
= crypt
->ops
->get_key(key
, WEP_KEY_LEN
, NULL
, crypt
->priv
);
265 erq
->length
= (len
>= 0 ? len
: 0);
267 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFWEPFLAGS
, &val
, 2, 1) < 0)
269 printk("CNFWEPFLAGS reading failed\n");
273 if (val
& HFA384X_WEPFLAGS_PRIVACYINVOKED
)
274 erq
->flags
|= IW_ENCODE_ENABLED
;
276 erq
->flags
|= IW_ENCODE_DISABLED
;
277 if (val
& HFA384X_WEPFLAGS_EXCLUDEUNENCRYPTED
)
278 erq
->flags
|= IW_ENCODE_RESTRICTED
;
280 erq
->flags
|= IW_ENCODE_OPEN
;
286 static int hostap_set_rate(struct net_device
*dev
)
288 struct hostap_interface
*iface
;
290 int ret
, basic_rates
;
292 iface
= netdev_priv(dev
);
293 local
= iface
->local
;
295 basic_rates
= local
->basic_rates
& local
->tx_rate_control
;
296 if (!basic_rates
|| basic_rates
!= local
->basic_rates
) {
297 printk(KERN_INFO
"%s: updating basic rate set automatically "
298 "to match with the new supported rate set\n",
301 basic_rates
= local
->tx_rate_control
;
303 local
->basic_rates
= basic_rates
;
304 if (hostap_set_word(dev
, HFA384X_RID_CNFBASICRATES
,
306 printk(KERN_WARNING
"%s: failed to set "
307 "cnfBasicRates\n", dev
->name
);
310 ret
= (hostap_set_word(dev
, HFA384X_RID_TXRATECONTROL
,
311 local
->tx_rate_control
) ||
312 hostap_set_word(dev
, HFA384X_RID_CNFSUPPORTEDRATES
,
313 local
->tx_rate_control
) ||
314 local
->func
->reset_port(dev
));
317 printk(KERN_WARNING
"%s: TXRateControl/cnfSupportedRates "
318 "setting to 0x%x failed\n",
319 dev
->name
, local
->tx_rate_control
);
322 /* Update TX rate configuration for all STAs based on new operational
324 hostap_update_rates(local
);
330 static int prism2_ioctl_siwrate(struct net_device
*dev
,
331 struct iw_request_info
*info
,
332 struct iw_param
*rrq
, char *extra
)
334 struct hostap_interface
*iface
;
337 iface
= netdev_priv(dev
);
338 local
= iface
->local
;
341 switch (rrq
->value
) {
343 local
->tx_rate_control
= HFA384X_RATES_11MBPS
;
346 local
->tx_rate_control
= HFA384X_RATES_5MBPS
;
349 local
->tx_rate_control
= HFA384X_RATES_2MBPS
;
352 local
->tx_rate_control
= HFA384X_RATES_1MBPS
;
355 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
356 HFA384X_RATES_2MBPS
| HFA384X_RATES_5MBPS
|
357 HFA384X_RATES_11MBPS
;
361 switch (rrq
->value
) {
363 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
364 HFA384X_RATES_2MBPS
| HFA384X_RATES_5MBPS
|
365 HFA384X_RATES_11MBPS
;
368 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
369 HFA384X_RATES_2MBPS
| HFA384X_RATES_5MBPS
;
372 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
376 local
->tx_rate_control
= HFA384X_RATES_1MBPS
;
379 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
380 HFA384X_RATES_2MBPS
| HFA384X_RATES_5MBPS
|
381 HFA384X_RATES_11MBPS
;
386 return hostap_set_rate(dev
);
390 static int prism2_ioctl_giwrate(struct net_device
*dev
,
391 struct iw_request_info
*info
,
392 struct iw_param
*rrq
, char *extra
)
395 struct hostap_interface
*iface
;
399 iface
= netdev_priv(dev
);
400 local
= iface
->local
;
402 if (local
->func
->get_rid(dev
, HFA384X_RID_TXRATECONTROL
, &val
, 2, 1) <
406 if ((val
& 0x1) && (val
> 1))
411 if (local
->iw_mode
== IW_MODE_MASTER
&& local
->ap
!= NULL
&&
412 !local
->fw_tx_rate_control
) {
413 /* HFA384X_RID_CURRENTTXRATE seems to always be 2 Mbps in
414 * Host AP mode, so use the recorded TX rate of the last sent
416 rrq
->value
= local
->ap
->last_tx_rate
> 0 ?
417 local
->ap
->last_tx_rate
* 100000 : 11000000;
421 if (local
->func
->get_rid(dev
, HFA384X_RID_CURRENTTXRATE
, &val
, 2, 1) <
426 case HFA384X_RATES_1MBPS
:
427 rrq
->value
= 1000000;
429 case HFA384X_RATES_2MBPS
:
430 rrq
->value
= 2000000;
432 case HFA384X_RATES_5MBPS
:
433 rrq
->value
= 5500000;
435 case HFA384X_RATES_11MBPS
:
436 rrq
->value
= 11000000;
439 /* should not happen */
440 rrq
->value
= 11000000;
449 static int prism2_ioctl_siwsens(struct net_device
*dev
,
450 struct iw_request_info
*info
,
451 struct iw_param
*sens
, char *extra
)
453 struct hostap_interface
*iface
;
456 iface
= netdev_priv(dev
);
457 local
= iface
->local
;
459 /* Set the desired AP density */
460 if (sens
->value
< 1 || sens
->value
> 3)
463 if (hostap_set_word(dev
, HFA384X_RID_CNFSYSTEMSCALE
, sens
->value
) ||
464 local
->func
->reset_port(dev
))
470 static int prism2_ioctl_giwsens(struct net_device
*dev
,
471 struct iw_request_info
*info
,
472 struct iw_param
*sens
, char *extra
)
474 struct hostap_interface
*iface
;
478 iface
= netdev_priv(dev
);
479 local
= iface
->local
;
481 /* Get the current AP density */
482 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFSYSTEMSCALE
, &val
, 2, 1) <
486 sens
->value
= le16_to_cpu(val
);
493 /* Deprecated in new wireless extension API */
494 static int prism2_ioctl_giwaplist(struct net_device
*dev
,
495 struct iw_request_info
*info
,
496 struct iw_point
*data
, char *extra
)
498 struct hostap_interface
*iface
;
500 struct sockaddr
*addr
;
501 struct iw_quality
*qual
;
503 iface
= netdev_priv(dev
);
504 local
= iface
->local
;
506 if (local
->iw_mode
!= IW_MODE_MASTER
) {
507 printk(KERN_DEBUG
"SIOCGIWAPLIST is currently only supported "
508 "in Host AP mode\n");
513 addr
= kmalloc(sizeof(struct sockaddr
) * IW_MAX_AP
, GFP_KERNEL
);
514 qual
= kmalloc(sizeof(struct iw_quality
) * IW_MAX_AP
, GFP_KERNEL
);
515 if (addr
== NULL
|| qual
== NULL
) {
522 data
->length
= prism2_ap_get_sta_qual(local
, addr
, qual
, IW_MAX_AP
, 1);
524 memcpy(extra
, &addr
, sizeof(struct sockaddr
) * data
->length
);
525 data
->flags
= 1; /* has quality information */
526 memcpy(extra
+ sizeof(struct sockaddr
) * data
->length
, &qual
,
527 sizeof(struct iw_quality
) * data
->length
);
535 static int prism2_ioctl_siwrts(struct net_device
*dev
,
536 struct iw_request_info
*info
,
537 struct iw_param
*rts
, char *extra
)
539 struct hostap_interface
*iface
;
543 iface
= netdev_priv(dev
);
544 local
= iface
->local
;
547 val
= cpu_to_le16(2347);
548 else if (rts
->value
< 0 || rts
->value
> 2347)
551 val
= cpu_to_le16(rts
->value
);
553 if (local
->func
->set_rid(dev
, HFA384X_RID_RTSTHRESHOLD
, &val
, 2) ||
554 local
->func
->reset_port(dev
))
557 local
->rts_threshold
= rts
->value
;
562 static int prism2_ioctl_giwrts(struct net_device
*dev
,
563 struct iw_request_info
*info
,
564 struct iw_param
*rts
, char *extra
)
566 struct hostap_interface
*iface
;
570 iface
= netdev_priv(dev
);
571 local
= iface
->local
;
573 if (local
->func
->get_rid(dev
, HFA384X_RID_RTSTHRESHOLD
, &val
, 2, 1) <
577 rts
->value
= le16_to_cpu(val
);
578 rts
->disabled
= (rts
->value
== 2347);
585 static int prism2_ioctl_siwfrag(struct net_device
*dev
,
586 struct iw_request_info
*info
,
587 struct iw_param
*rts
, char *extra
)
589 struct hostap_interface
*iface
;
593 iface
= netdev_priv(dev
);
594 local
= iface
->local
;
597 val
= cpu_to_le16(2346);
598 else if (rts
->value
< 256 || rts
->value
> 2346)
601 val
= cpu_to_le16(rts
->value
& ~0x1); /* even numbers only */
603 local
->fragm_threshold
= rts
->value
& ~0x1;
604 if (local
->func
->set_rid(dev
, HFA384X_RID_FRAGMENTATIONTHRESHOLD
, &val
,
606 || local
->func
->reset_port(dev
))
612 static int prism2_ioctl_giwfrag(struct net_device
*dev
,
613 struct iw_request_info
*info
,
614 struct iw_param
*rts
, char *extra
)
616 struct hostap_interface
*iface
;
620 iface
= netdev_priv(dev
);
621 local
= iface
->local
;
623 if (local
->func
->get_rid(dev
, HFA384X_RID_FRAGMENTATIONTHRESHOLD
,
627 rts
->value
= le16_to_cpu(val
);
628 rts
->disabled
= (rts
->value
== 2346);
635 #ifndef PRISM2_NO_STATION_MODES
636 static int hostap_join_ap(struct net_device
*dev
)
638 struct hostap_interface
*iface
;
640 struct hfa384x_join_request req
;
643 struct hfa384x_hostscan_result
*entry
;
645 iface
= netdev_priv(dev
);
646 local
= iface
->local
;
648 memcpy(req
.bssid
, local
->preferred_ap
, ETH_ALEN
);
651 spin_lock_irqsave(&local
->lock
, flags
);
652 for (i
= 0; i
< local
->last_scan_results_count
; i
++) {
653 if (!local
->last_scan_results
)
655 entry
= &local
->last_scan_results
[i
];
656 if (memcmp(local
->preferred_ap
, entry
->bssid
, ETH_ALEN
) == 0) {
657 req
.channel
= entry
->chid
;
661 spin_unlock_irqrestore(&local
->lock
, flags
);
663 if (local
->func
->set_rid(dev
, HFA384X_RID_JOINREQUEST
, &req
,
665 printk(KERN_DEBUG
"%s: JoinRequest %pM failed\n",
666 dev
->name
, local
->preferred_ap
);
670 printk(KERN_DEBUG
"%s: Trying to join BSSID %pM\n",
671 dev
->name
, local
->preferred_ap
);
675 #endif /* PRISM2_NO_STATION_MODES */
678 static int prism2_ioctl_siwap(struct net_device
*dev
,
679 struct iw_request_info
*info
,
680 struct sockaddr
*ap_addr
, char *extra
)
682 #ifdef PRISM2_NO_STATION_MODES
684 #else /* PRISM2_NO_STATION_MODES */
685 struct hostap_interface
*iface
;
688 iface
= netdev_priv(dev
);
689 local
= iface
->local
;
691 memcpy(local
->preferred_ap
, &ap_addr
->sa_data
, ETH_ALEN
);
693 if (local
->host_roaming
== 1 && local
->iw_mode
== IW_MODE_INFRA
) {
694 struct hfa384x_scan_request scan_req
;
695 memset(&scan_req
, 0, sizeof(scan_req
));
696 scan_req
.channel_list
= cpu_to_le16(0x3fff);
697 scan_req
.txrate
= cpu_to_le16(HFA384X_RATES_1MBPS
);
698 if (local
->func
->set_rid(dev
, HFA384X_RID_SCANREQUEST
,
699 &scan_req
, sizeof(scan_req
))) {
700 printk(KERN_DEBUG
"%s: ScanResults request failed - "
701 "preferred AP delayed to next unsolicited "
702 "scan\n", dev
->name
);
704 } else if (local
->host_roaming
== 2 &&
705 local
->iw_mode
== IW_MODE_INFRA
) {
706 if (hostap_join_ap(dev
))
709 printk(KERN_DEBUG
"%s: Preferred AP (SIOCSIWAP) is used only "
710 "in Managed mode when host_roaming is enabled\n",
715 #endif /* PRISM2_NO_STATION_MODES */
718 static int prism2_ioctl_giwap(struct net_device
*dev
,
719 struct iw_request_info
*info
,
720 struct sockaddr
*ap_addr
, char *extra
)
722 struct hostap_interface
*iface
;
725 iface
= netdev_priv(dev
);
726 local
= iface
->local
;
728 ap_addr
->sa_family
= ARPHRD_ETHER
;
729 switch (iface
->type
) {
730 case HOSTAP_INTERFACE_AP
:
731 memcpy(&ap_addr
->sa_data
, dev
->dev_addr
, ETH_ALEN
);
733 case HOSTAP_INTERFACE_STA
:
734 memcpy(&ap_addr
->sa_data
, local
->assoc_ap_addr
, ETH_ALEN
);
736 case HOSTAP_INTERFACE_WDS
:
737 memcpy(&ap_addr
->sa_data
, iface
->u
.wds
.remote_addr
, ETH_ALEN
);
740 if (local
->func
->get_rid(dev
, HFA384X_RID_CURRENTBSSID
,
741 &ap_addr
->sa_data
, ETH_ALEN
, 1) < 0)
744 /* local->bssid is also updated in LinkStatus handler when in
746 memcpy(local
->bssid
, &ap_addr
->sa_data
, ETH_ALEN
);
754 static int prism2_ioctl_siwnickn(struct net_device
*dev
,
755 struct iw_request_info
*info
,
756 struct iw_point
*data
, char *nickname
)
758 struct hostap_interface
*iface
;
761 iface
= netdev_priv(dev
);
762 local
= iface
->local
;
764 memset(local
->name
, 0, sizeof(local
->name
));
765 memcpy(local
->name
, nickname
, data
->length
);
768 if (hostap_set_string(dev
, HFA384X_RID_CNFOWNNAME
, local
->name
) ||
769 local
->func
->reset_port(dev
))
775 static int prism2_ioctl_giwnickn(struct net_device
*dev
,
776 struct iw_request_info
*info
,
777 struct iw_point
*data
, char *nickname
)
779 struct hostap_interface
*iface
;
782 char name
[MAX_NAME_LEN
+ 3];
785 iface
= netdev_priv(dev
);
786 local
= iface
->local
;
788 len
= local
->func
->get_rid(dev
, HFA384X_RID_CNFOWNNAME
,
789 &name
, MAX_NAME_LEN
+ 2, 0);
790 val
= le16_to_cpu(*(__le16
*) name
);
791 if (len
> MAX_NAME_LEN
+ 2 || len
< 0 || val
> MAX_NAME_LEN
)
794 name
[val
+ 2] = '\0';
795 data
->length
= val
+ 1;
796 memcpy(nickname
, name
+ 2, val
+ 1);
802 static int prism2_ioctl_siwfreq(struct net_device
*dev
,
803 struct iw_request_info
*info
,
804 struct iw_freq
*freq
, char *extra
)
806 struct hostap_interface
*iface
;
809 iface
= netdev_priv(dev
);
810 local
= iface
->local
;
814 freq
->m
/ 100000 >= freq_list
[0] &&
815 freq
->m
/ 100000 <= freq_list
[FREQ_COUNT
- 1]) {
817 int fr
= freq
->m
/ 100000;
818 for (ch
= 0; ch
< FREQ_COUNT
; ch
++) {
819 if (fr
== freq_list
[ch
]) {
827 if (freq
->e
!= 0 || freq
->m
< 1 || freq
->m
> FREQ_COUNT
||
828 !(local
->channel_mask
& (1 << (freq
->m
- 1))))
831 local
->channel
= freq
->m
; /* channel is used in prism2_setup_rids() */
832 if (hostap_set_word(dev
, HFA384X_RID_CNFOWNCHANNEL
, local
->channel
) ||
833 local
->func
->reset_port(dev
))
839 static int prism2_ioctl_giwfreq(struct net_device
*dev
,
840 struct iw_request_info
*info
,
841 struct iw_freq
*freq
, char *extra
)
843 struct hostap_interface
*iface
;
847 iface
= netdev_priv(dev
);
848 local
= iface
->local
;
850 if (local
->func
->get_rid(dev
, HFA384X_RID_CURRENTCHANNEL
, &val
, 2, 1) <
855 if (val
< 1 || val
> FREQ_COUNT
)
858 freq
->m
= freq_list
[val
- 1] * 100000;
865 static void hostap_monitor_set_type(local_info_t
*local
)
867 struct net_device
*dev
= local
->ddev
;
872 if (local
->monitor_type
== PRISM2_MONITOR_PRISM
||
873 local
->monitor_type
== PRISM2_MONITOR_CAPHDR
) {
874 dev
->type
= ARPHRD_IEEE80211_PRISM
;
875 } else if (local
->monitor_type
== PRISM2_MONITOR_RADIOTAP
) {
876 dev
->type
= ARPHRD_IEEE80211_RADIOTAP
;
878 dev
->type
= ARPHRD_IEEE80211
;
883 static int prism2_ioctl_siwessid(struct net_device
*dev
,
884 struct iw_request_info
*info
,
885 struct iw_point
*data
, char *ssid
)
887 struct hostap_interface
*iface
;
890 iface
= netdev_priv(dev
);
891 local
= iface
->local
;
893 if (iface
->type
== HOSTAP_INTERFACE_WDS
)
896 if (data
->flags
== 0)
897 ssid
[0] = '\0'; /* ANY */
899 if (local
->iw_mode
== IW_MODE_MASTER
&& ssid
[0] == '\0') {
900 /* Setting SSID to empty string seems to kill the card in
902 printk(KERN_DEBUG
"%s: Host AP mode does not support "
903 "'Any' essid\n", dev
->name
);
907 memcpy(local
->essid
, ssid
, data
->length
);
908 local
->essid
[data
->length
] = '\0';
910 if ((!local
->fw_ap
&&
911 hostap_set_string(dev
, HFA384X_RID_CNFDESIREDSSID
, local
->essid
))
912 || hostap_set_string(dev
, HFA384X_RID_CNFOWNSSID
, local
->essid
) ||
913 local
->func
->reset_port(dev
))
919 static int prism2_ioctl_giwessid(struct net_device
*dev
,
920 struct iw_request_info
*info
,
921 struct iw_point
*data
, char *essid
)
923 struct hostap_interface
*iface
;
927 iface
= netdev_priv(dev
);
928 local
= iface
->local
;
930 if (iface
->type
== HOSTAP_INTERFACE_WDS
)
933 data
->flags
= 1; /* active */
934 if (local
->iw_mode
== IW_MODE_MASTER
) {
935 data
->length
= strlen(local
->essid
);
936 memcpy(essid
, local
->essid
, IW_ESSID_MAX_SIZE
);
939 char ssid
[MAX_SSID_LEN
+ 2];
940 memset(ssid
, 0, sizeof(ssid
));
941 len
= local
->func
->get_rid(dev
, HFA384X_RID_CURRENTSSID
,
942 &ssid
, MAX_SSID_LEN
+ 2, 0);
943 val
= le16_to_cpu(*(__le16
*) ssid
);
944 if (len
> MAX_SSID_LEN
+ 2 || len
< 0 || val
> MAX_SSID_LEN
) {
948 memcpy(essid
, ssid
+ 2, IW_ESSID_MAX_SIZE
);
955 static int prism2_ioctl_giwrange(struct net_device
*dev
,
956 struct iw_request_info
*info
,
957 struct iw_point
*data
, char *extra
)
959 struct hostap_interface
*iface
;
961 struct iw_range
*range
= (struct iw_range
*) extra
;
966 iface
= netdev_priv(dev
);
967 local
= iface
->local
;
969 data
->length
= sizeof(struct iw_range
);
970 memset(range
, 0, sizeof(struct iw_range
));
972 /* TODO: could fill num_txpower and txpower array with
973 * something; however, there are 128 different values.. */
975 range
->txpower_capa
= IW_TXPOW_DBM
;
977 if (local
->iw_mode
== IW_MODE_INFRA
|| local
->iw_mode
== IW_MODE_ADHOC
)
979 range
->min_pmp
= 1 * 1024;
980 range
->max_pmp
= 65535 * 1024;
981 range
->min_pmt
= 1 * 1024;
982 range
->max_pmt
= 1000 * 1024;
983 range
->pmp_flags
= IW_POWER_PERIOD
;
984 range
->pmt_flags
= IW_POWER_TIMEOUT
;
985 range
->pm_capa
= IW_POWER_PERIOD
| IW_POWER_TIMEOUT
|
986 IW_POWER_UNICAST_R
| IW_POWER_ALL_R
;
989 range
->we_version_compiled
= WIRELESS_EXT
;
990 range
->we_version_source
= 18;
992 range
->retry_capa
= IW_RETRY_LIMIT
;
993 range
->retry_flags
= IW_RETRY_LIMIT
;
994 range
->min_retry
= 0;
995 range
->max_retry
= 255;
997 range
->num_channels
= FREQ_COUNT
;
1000 for (i
= 0; i
< FREQ_COUNT
; i
++) {
1001 if (local
->channel_mask
& (1 << i
)) {
1002 range
->freq
[val
].i
= i
+ 1;
1003 range
->freq
[val
].m
= freq_list
[i
] * 100000;
1004 range
->freq
[val
].e
= 1;
1007 if (val
== IW_MAX_FREQUENCIES
)
1010 range
->num_frequency
= val
;
1012 if (local
->sta_fw_ver
>= PRISM2_FW_VER(1,3,1)) {
1013 range
->max_qual
.qual
= 70; /* what is correct max? This was not
1014 * documented exactly. At least
1015 * 69 has been observed. */
1016 range
->max_qual
.level
= 0; /* dB */
1017 range
->max_qual
.noise
= 0; /* dB */
1019 /* What would be suitable values for "average/typical" qual? */
1020 range
->avg_qual
.qual
= 20;
1021 range
->avg_qual
.level
= -60;
1022 range
->avg_qual
.noise
= -95;
1024 range
->max_qual
.qual
= 92; /* 0 .. 92 */
1025 range
->max_qual
.level
= 154; /* 27 .. 154 */
1026 range
->max_qual
.noise
= 154; /* 27 .. 154 */
1028 range
->sensitivity
= 3;
1030 range
->max_encoding_tokens
= WEP_KEYS
;
1031 range
->num_encoding_sizes
= 2;
1032 range
->encoding_size
[0] = 5;
1033 range
->encoding_size
[1] = 13;
1036 len
= prism2_get_datarates(dev
, rates
);
1037 range
->num_bitrates
= 0;
1038 for (i
= 0; i
< len
; i
++) {
1039 if (range
->num_bitrates
< IW_MAX_BITRATES
) {
1040 range
->bitrate
[range
->num_bitrates
] =
1042 range
->num_bitrates
++;
1044 if (rates
[i
] == 0x0b || rates
[i
] == 0x16)
1047 /* estimated maximum TCP throughput values (bps) */
1048 range
->throughput
= over2
? 5500000 : 1500000;
1051 range
->max_rts
= 2347;
1052 range
->min_frag
= 256;
1053 range
->max_frag
= 2346;
1055 /* Event capability (kernel + driver) */
1056 range
->event_capa
[0] = (IW_EVENT_CAPA_K_0
|
1057 IW_EVENT_CAPA_MASK(SIOCGIWTHRSPY
) |
1058 IW_EVENT_CAPA_MASK(SIOCGIWAP
) |
1059 IW_EVENT_CAPA_MASK(SIOCGIWSCAN
));
1060 range
->event_capa
[1] = IW_EVENT_CAPA_K_1
;
1061 range
->event_capa
[4] = (IW_EVENT_CAPA_MASK(IWEVTXDROP
) |
1062 IW_EVENT_CAPA_MASK(IWEVCUSTOM
) |
1063 IW_EVENT_CAPA_MASK(IWEVREGISTERED
) |
1064 IW_EVENT_CAPA_MASK(IWEVEXPIRED
));
1066 range
->enc_capa
= IW_ENC_CAPA_WPA
| IW_ENC_CAPA_WPA2
|
1067 IW_ENC_CAPA_CIPHER_TKIP
| IW_ENC_CAPA_CIPHER_CCMP
;
1069 if (local
->sta_fw_ver
>= PRISM2_FW_VER(1,3,1))
1070 range
->scan_capa
= IW_SCAN_CAPA_ESSID
;
1076 static int hostap_monitor_mode_enable(local_info_t
*local
)
1078 struct net_device
*dev
= local
->dev
;
1080 printk(KERN_DEBUG
"Enabling monitor mode\n");
1081 hostap_monitor_set_type(local
);
1083 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
1084 HFA384X_PORTTYPE_PSEUDO_IBSS
)) {
1085 printk(KERN_DEBUG
"Port type setting for monitor mode "
1090 /* Host decrypt is needed to get the IV and ICV fields;
1091 * however, monitor mode seems to remove WEP flag from frame
1093 if (hostap_set_word(dev
, HFA384X_RID_CNFWEPFLAGS
,
1094 HFA384X_WEPFLAGS_HOSTENCRYPT
|
1095 HFA384X_WEPFLAGS_HOSTDECRYPT
)) {
1096 printk(KERN_DEBUG
"WEP flags setting failed\n");
1100 if (local
->func
->reset_port(dev
) ||
1101 local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
1102 (HFA384X_TEST_MONITOR
<< 8),
1104 printk(KERN_DEBUG
"Setting monitor mode failed\n");
1112 static int hostap_monitor_mode_disable(local_info_t
*local
)
1114 struct net_device
*dev
= local
->ddev
;
1119 printk(KERN_DEBUG
"%s: Disabling monitor mode\n", dev
->name
);
1120 dev
->type
= ARPHRD_ETHER
;
1122 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
1123 (HFA384X_TEST_STOP
<< 8),
1126 return hostap_set_encryption(local
);
1130 static int prism2_ioctl_siwmode(struct net_device
*dev
,
1131 struct iw_request_info
*info
,
1132 __u32
*mode
, char *extra
)
1134 struct hostap_interface
*iface
;
1135 local_info_t
*local
;
1136 int double_reset
= 0;
1138 iface
= netdev_priv(dev
);
1139 local
= iface
->local
;
1141 if (*mode
!= IW_MODE_ADHOC
&& *mode
!= IW_MODE_INFRA
&&
1142 *mode
!= IW_MODE_MASTER
&& *mode
!= IW_MODE_REPEAT
&&
1143 *mode
!= IW_MODE_MONITOR
)
1146 #ifdef PRISM2_NO_STATION_MODES
1147 if (*mode
== IW_MODE_ADHOC
|| *mode
== IW_MODE_INFRA
)
1149 #endif /* PRISM2_NO_STATION_MODES */
1151 if (*mode
== local
->iw_mode
)
1154 if (*mode
== IW_MODE_MASTER
&& local
->essid
[0] == '\0') {
1155 printk(KERN_WARNING
"%s: empty SSID not allowed in Master "
1156 "mode\n", dev
->name
);
1160 if (local
->iw_mode
== IW_MODE_MONITOR
)
1161 hostap_monitor_mode_disable(local
);
1163 if ((local
->iw_mode
== IW_MODE_ADHOC
||
1164 local
->iw_mode
== IW_MODE_MONITOR
) && *mode
== IW_MODE_MASTER
) {
1165 /* There seems to be a firmware bug in at least STA f/w v1.5.6
1166 * that leaves beacon frames to use IBSS type when moving from
1167 * IBSS to Host AP mode. Doing double Port0 reset seems to be
1168 * enough to workaround this. */
1172 printk(KERN_DEBUG
"prism2: %s: operating mode changed "
1173 "%d -> %d\n", dev
->name
, local
->iw_mode
, *mode
);
1174 local
->iw_mode
= *mode
;
1176 if (local
->iw_mode
== IW_MODE_MONITOR
)
1177 hostap_monitor_mode_enable(local
);
1178 else if (local
->iw_mode
== IW_MODE_MASTER
&& !local
->host_encrypt
&&
1179 !local
->fw_encrypt_ok
) {
1180 printk(KERN_DEBUG
"%s: defaulting to host-based encryption as "
1181 "a workaround for firmware bug in Host AP mode WEP\n",
1183 local
->host_encrypt
= 1;
1186 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
1187 hostap_get_porttype(local
)))
1190 if (local
->func
->reset_port(dev
))
1192 if (double_reset
&& local
->func
->reset_port(dev
))
1195 if (local
->iw_mode
!= IW_MODE_INFRA
&& local
->iw_mode
!= IW_MODE_ADHOC
)
1197 /* netif_carrier is used only in client modes for now, so make
1198 * sure carrier is on when moving to non-client modes. */
1199 netif_carrier_on(local
->dev
);
1200 netif_carrier_on(local
->ddev
);
1206 static int prism2_ioctl_giwmode(struct net_device
*dev
,
1207 struct iw_request_info
*info
,
1208 __u32
*mode
, char *extra
)
1210 struct hostap_interface
*iface
;
1211 local_info_t
*local
;
1213 iface
= netdev_priv(dev
);
1214 local
= iface
->local
;
1216 switch (iface
->type
) {
1217 case HOSTAP_INTERFACE_STA
:
1218 *mode
= IW_MODE_INFRA
;
1220 case HOSTAP_INTERFACE_WDS
:
1221 *mode
= IW_MODE_REPEAT
;
1224 *mode
= local
->iw_mode
;
1231 static int prism2_ioctl_siwpower(struct net_device
*dev
,
1232 struct iw_request_info
*info
,
1233 struct iw_param
*wrq
, char *extra
)
1235 #ifdef PRISM2_NO_STATION_MODES
1237 #else /* PRISM2_NO_STATION_MODES */
1241 return hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 0);
1243 switch (wrq
->flags
& IW_POWER_MODE
) {
1244 case IW_POWER_UNICAST_R
:
1245 ret
= hostap_set_word(dev
, HFA384X_RID_CNFMULTICASTRECEIVE
, 0);
1248 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 1);
1252 case IW_POWER_ALL_R
:
1253 ret
= hostap_set_word(dev
, HFA384X_RID_CNFMULTICASTRECEIVE
, 1);
1256 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 1);
1266 if (wrq
->flags
& IW_POWER_TIMEOUT
) {
1267 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 1);
1270 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMHOLDOVERDURATION
,
1275 if (wrq
->flags
& IW_POWER_PERIOD
) {
1276 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 1);
1279 ret
= hostap_set_word(dev
, HFA384X_RID_CNFMAXSLEEPDURATION
,
1286 #endif /* PRISM2_NO_STATION_MODES */
1290 static int prism2_ioctl_giwpower(struct net_device
*dev
,
1291 struct iw_request_info
*info
,
1292 struct iw_param
*rrq
, char *extra
)
1294 #ifdef PRISM2_NO_STATION_MODES
1296 #else /* PRISM2_NO_STATION_MODES */
1297 struct hostap_interface
*iface
;
1298 local_info_t
*local
;
1299 __le16 enable
, mcast
;
1301 iface
= netdev_priv(dev
);
1302 local
= iface
->local
;
1304 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFPMENABLED
, &enable
, 2, 1)
1308 if (!le16_to_cpu(enable
)) {
1315 if ((rrq
->flags
& IW_POWER_TYPE
) == IW_POWER_TIMEOUT
) {
1317 if (local
->func
->get_rid(dev
,
1318 HFA384X_RID_CNFPMHOLDOVERDURATION
,
1319 &timeout
, 2, 1) < 0)
1322 rrq
->flags
= IW_POWER_TIMEOUT
;
1323 rrq
->value
= le16_to_cpu(timeout
) * 1024;
1326 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFMAXSLEEPDURATION
,
1330 rrq
->flags
= IW_POWER_PERIOD
;
1331 rrq
->value
= le16_to_cpu(period
) * 1024;
1334 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFMULTICASTRECEIVE
, &mcast
,
1338 if (le16_to_cpu(mcast
))
1339 rrq
->flags
|= IW_POWER_ALL_R
;
1341 rrq
->flags
|= IW_POWER_UNICAST_R
;
1344 #endif /* PRISM2_NO_STATION_MODES */
1348 static int prism2_ioctl_siwretry(struct net_device
*dev
,
1349 struct iw_request_info
*info
,
1350 struct iw_param
*rrq
, char *extra
)
1352 struct hostap_interface
*iface
;
1353 local_info_t
*local
;
1355 iface
= netdev_priv(dev
);
1356 local
= iface
->local
;
1361 /* setting retry limits is not supported with the current station
1362 * firmware code; simulate this with alternative retry count for now */
1363 if (rrq
->flags
== IW_RETRY_LIMIT
) {
1364 if (rrq
->value
< 0) {
1365 /* disable manual retry count setting and use firmware
1367 local
->manual_retry_count
= -1;
1368 local
->tx_control
&= ~HFA384X_TX_CTRL_ALT_RTRY
;
1370 if (hostap_set_word(dev
, HFA384X_RID_CNFALTRETRYCOUNT
,
1372 printk(KERN_DEBUG
"%s: Alternate retry count "
1373 "setting to %d failed\n",
1374 dev
->name
, rrq
->value
);
1378 local
->manual_retry_count
= rrq
->value
;
1379 local
->tx_control
|= HFA384X_TX_CTRL_ALT_RTRY
;
1387 /* what could be done, if firmware would support this.. */
1389 if (rrq
->flags
& IW_RETRY_LIMIT
) {
1390 if (rrq
->flags
& IW_RETRY_LONG
)
1391 HFA384X_RID_LONGRETRYLIMIT
= rrq
->value
;
1392 else if (rrq
->flags
& IW_RETRY_SHORT
)
1393 HFA384X_RID_SHORTRETRYLIMIT
= rrq
->value
;
1395 HFA384X_RID_LONGRETRYLIMIT
= rrq
->value
;
1396 HFA384X_RID_SHORTRETRYLIMIT
= rrq
->value
;
1401 if (rrq
->flags
& IW_RETRY_LIFETIME
) {
1402 HFA384X_RID_MAXTRANSMITLIFETIME
= rrq
->value
/ 1024;
1409 static int prism2_ioctl_giwretry(struct net_device
*dev
,
1410 struct iw_request_info
*info
,
1411 struct iw_param
*rrq
, char *extra
)
1413 struct hostap_interface
*iface
;
1414 local_info_t
*local
;
1415 __le16 shortretry
, longretry
, lifetime
, altretry
;
1417 iface
= netdev_priv(dev
);
1418 local
= iface
->local
;
1420 if (local
->func
->get_rid(dev
, HFA384X_RID_SHORTRETRYLIMIT
, &shortretry
,
1422 local
->func
->get_rid(dev
, HFA384X_RID_LONGRETRYLIMIT
, &longretry
,
1424 local
->func
->get_rid(dev
, HFA384X_RID_MAXTRANSMITLIFETIME
,
1425 &lifetime
, 2, 1) < 0)
1430 if ((rrq
->flags
& IW_RETRY_TYPE
) == IW_RETRY_LIFETIME
) {
1431 rrq
->flags
= IW_RETRY_LIFETIME
;
1432 rrq
->value
= le16_to_cpu(lifetime
) * 1024;
1434 if (local
->manual_retry_count
>= 0) {
1435 rrq
->flags
= IW_RETRY_LIMIT
;
1436 if (local
->func
->get_rid(dev
,
1437 HFA384X_RID_CNFALTRETRYCOUNT
,
1438 &altretry
, 2, 1) >= 0)
1439 rrq
->value
= le16_to_cpu(altretry
);
1441 rrq
->value
= local
->manual_retry_count
;
1442 } else if ((rrq
->flags
& IW_RETRY_LONG
)) {
1443 rrq
->flags
= IW_RETRY_LIMIT
| IW_RETRY_LONG
;
1444 rrq
->value
= le16_to_cpu(longretry
);
1446 rrq
->flags
= IW_RETRY_LIMIT
;
1447 rrq
->value
= le16_to_cpu(shortretry
);
1448 if (shortretry
!= longretry
)
1449 rrq
->flags
|= IW_RETRY_SHORT
;
1456 /* Note! This TX power controlling is experimental and should not be used in
1457 * production use. It just sets raw power register and does not use any kind of
1458 * feedback information from the measured TX power (CR58). This is now
1459 * commented out to make sure that it is not used by accident. TX power
1460 * configuration will be enabled again after proper algorithm using feedback
1461 * has been implemented. */
1463 #ifdef RAW_TXPOWER_SETTING
1464 /* Map HFA386x's CR31 to and from dBm with some sort of ad hoc mapping..
1465 * This version assumes following mapping:
1466 * CR31 is 7-bit value with -64 to +63 range.
1467 * -64 is mapped into +20dBm and +63 into -43dBm.
1468 * This is certainly not an exact mapping for every card, but at least
1469 * increasing dBm value should correspond to increasing TX power.
1472 static int prism2_txpower_hfa386x_to_dBm(u16 val
)
1485 static u16
prism2_txpower_dBm_to_hfa386x(int val
)
1498 return (unsigned char) tmp
;
1500 #endif /* RAW_TXPOWER_SETTING */
1503 static int prism2_ioctl_siwtxpow(struct net_device
*dev
,
1504 struct iw_request_info
*info
,
1505 struct iw_param
*rrq
, char *extra
)
1507 struct hostap_interface
*iface
;
1508 local_info_t
*local
;
1509 #ifdef RAW_TXPOWER_SETTING
1515 iface
= netdev_priv(dev
);
1516 local
= iface
->local
;
1518 if (rrq
->disabled
) {
1519 if (local
->txpower_type
!= PRISM2_TXPOWER_OFF
) {
1520 val
= 0xff; /* use all standby and sleep modes */
1521 ret
= local
->func
->cmd(dev
, HFA384X_CMDCODE_WRITEMIF
,
1522 HFA386X_CR_A_D_TEST_MODES2
,
1524 printk(KERN_DEBUG
"%s: Turning radio off: %s\n",
1525 dev
->name
, ret
? "failed" : "OK");
1526 local
->txpower_type
= PRISM2_TXPOWER_OFF
;
1528 return (ret
? -EOPNOTSUPP
: 0);
1531 if (local
->txpower_type
== PRISM2_TXPOWER_OFF
) {
1532 val
= 0; /* disable all standby and sleep modes */
1533 ret
= local
->func
->cmd(dev
, HFA384X_CMDCODE_WRITEMIF
,
1534 HFA386X_CR_A_D_TEST_MODES2
, &val
, NULL
);
1535 printk(KERN_DEBUG
"%s: Turning radio on: %s\n",
1536 dev
->name
, ret
? "failed" : "OK");
1537 local
->txpower_type
= PRISM2_TXPOWER_UNKNOWN
;
1540 #ifdef RAW_TXPOWER_SETTING
1541 if (!rrq
->fixed
&& local
->txpower_type
!= PRISM2_TXPOWER_AUTO
) {
1542 printk(KERN_DEBUG
"Setting ALC on\n");
1543 val
= HFA384X_TEST_CFG_BIT_ALC
;
1544 local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
1545 (HFA384X_TEST_CFG_BITS
<< 8), 1, &val
, NULL
);
1546 local
->txpower_type
= PRISM2_TXPOWER_AUTO
;
1550 if (local
->txpower_type
!= PRISM2_TXPOWER_FIXED
) {
1551 printk(KERN_DEBUG
"Setting ALC off\n");
1552 val
= HFA384X_TEST_CFG_BIT_ALC
;
1553 local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
1554 (HFA384X_TEST_CFG_BITS
<< 8), 0, &val
, NULL
);
1555 local
->txpower_type
= PRISM2_TXPOWER_FIXED
;
1558 if (rrq
->flags
== IW_TXPOW_DBM
)
1560 else if (rrq
->flags
== IW_TXPOW_MWATT
)
1564 printk(KERN_DEBUG
"Setting TX power to %d %s\n", rrq
->value
, tmp
);
1566 if (rrq
->flags
!= IW_TXPOW_DBM
) {
1567 printk("SIOCSIWTXPOW with mW is not supported; use dBm\n");
1571 local
->txpower
= rrq
->value
;
1572 val
= prism2_txpower_dBm_to_hfa386x(local
->txpower
);
1573 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_WRITEMIF
,
1574 HFA386X_CR_MANUAL_TX_POWER
, &val
, NULL
))
1576 #else /* RAW_TXPOWER_SETTING */
1579 #endif /* RAW_TXPOWER_SETTING */
1584 static int prism2_ioctl_giwtxpow(struct net_device
*dev
,
1585 struct iw_request_info
*info
,
1586 struct iw_param
*rrq
, char *extra
)
1588 #ifdef RAW_TXPOWER_SETTING
1589 struct hostap_interface
*iface
;
1590 local_info_t
*local
;
1593 iface
= netdev_priv(dev
);
1594 local
= iface
->local
;
1596 rrq
->flags
= IW_TXPOW_DBM
;
1600 if (local
->txpower_type
== PRISM2_TXPOWER_AUTO
) {
1601 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_READMIF
,
1602 HFA386X_CR_MANUAL_TX_POWER
,
1603 NULL
, &resp0
) == 0) {
1604 rrq
->value
= prism2_txpower_hfa386x_to_dBm(resp0
);
1606 /* Could not get real txpower; guess 15 dBm */
1609 } else if (local
->txpower_type
== PRISM2_TXPOWER_OFF
) {
1612 } else if (local
->txpower_type
== PRISM2_TXPOWER_FIXED
) {
1613 rrq
->value
= local
->txpower
;
1616 printk("SIOCGIWTXPOW - unknown txpower_type=%d\n",
1617 local
->txpower_type
);
1620 #else /* RAW_TXPOWER_SETTING */
1622 #endif /* RAW_TXPOWER_SETTING */
1626 #ifndef PRISM2_NO_STATION_MODES
1628 /* HostScan request works with and without host_roaming mode. In addition, it
1629 * does not break current association. However, it requires newer station
1630 * firmware version (>= 1.3.1) than scan request. */
1631 static int prism2_request_hostscan(struct net_device
*dev
,
1632 u8
*ssid
, u8 ssid_len
)
1634 struct hostap_interface
*iface
;
1635 local_info_t
*local
;
1636 struct hfa384x_hostscan_request scan_req
;
1638 iface
= netdev_priv(dev
);
1639 local
= iface
->local
;
1641 memset(&scan_req
, 0, sizeof(scan_req
));
1642 scan_req
.channel_list
= cpu_to_le16(local
->channel_mask
&
1643 local
->scan_channel_mask
);
1644 scan_req
.txrate
= cpu_to_le16(HFA384X_RATES_1MBPS
);
1648 scan_req
.target_ssid_len
= cpu_to_le16(ssid_len
);
1649 memcpy(scan_req
.target_ssid
, ssid
, ssid_len
);
1652 if (local
->func
->set_rid(dev
, HFA384X_RID_HOSTSCAN
, &scan_req
,
1653 sizeof(scan_req
))) {
1654 printk(KERN_DEBUG
"%s: HOSTSCAN failed\n", dev
->name
);
1661 static int prism2_request_scan(struct net_device
*dev
)
1663 struct hostap_interface
*iface
;
1664 local_info_t
*local
;
1665 struct hfa384x_scan_request scan_req
;
1668 iface
= netdev_priv(dev
);
1669 local
= iface
->local
;
1671 memset(&scan_req
, 0, sizeof(scan_req
));
1672 scan_req
.channel_list
= cpu_to_le16(local
->channel_mask
&
1673 local
->scan_channel_mask
);
1674 scan_req
.txrate
= cpu_to_le16(HFA384X_RATES_1MBPS
);
1677 * It seems to be enough to set roaming mode for a short moment to
1678 * host-based and then setup scanrequest data and return the mode to
1681 * Master mode would need to drop to Managed mode for a short while
1682 * to make scanning work.. Or sweep through the different channels and
1683 * use passive scan based on beacons. */
1685 if (!local
->host_roaming
)
1686 hostap_set_word(dev
, HFA384X_RID_CNFROAMINGMODE
,
1687 HFA384X_ROAMING_HOST
);
1689 if (local
->func
->set_rid(dev
, HFA384X_RID_SCANREQUEST
, &scan_req
,
1690 sizeof(scan_req
))) {
1691 printk(KERN_DEBUG
"SCANREQUEST failed\n");
1695 if (!local
->host_roaming
)
1696 hostap_set_word(dev
, HFA384X_RID_CNFROAMINGMODE
,
1697 HFA384X_ROAMING_FIRMWARE
);
1702 #else /* !PRISM2_NO_STATION_MODES */
1704 static inline int prism2_request_hostscan(struct net_device
*dev
,
1705 u8
*ssid
, u8 ssid_len
)
1711 static inline int prism2_request_scan(struct net_device
*dev
)
1716 #endif /* !PRISM2_NO_STATION_MODES */
1719 static int prism2_ioctl_siwscan(struct net_device
*dev
,
1720 struct iw_request_info
*info
,
1721 struct iw_point
*data
, char *extra
)
1723 struct hostap_interface
*iface
;
1724 local_info_t
*local
;
1726 u8
*ssid
= NULL
, ssid_len
= 0;
1727 struct iw_scan_req
*req
= (struct iw_scan_req
*) extra
;
1729 iface
= netdev_priv(dev
);
1730 local
= iface
->local
;
1732 if (data
->length
< sizeof(struct iw_scan_req
))
1735 if (local
->iw_mode
== IW_MODE_MASTER
) {
1736 /* In master mode, we just return the results of our local
1737 * tables, so we don't need to start anything...
1743 if (!local
->dev_enabled
)
1746 if (req
&& data
->flags
& IW_SCAN_THIS_ESSID
) {
1748 ssid_len
= req
->essid_len
;
1751 ((local
->iw_mode
!= IW_MODE_INFRA
&&
1752 local
->iw_mode
!= IW_MODE_ADHOC
) ||
1753 (local
->sta_fw_ver
< PRISM2_FW_VER(1,3,1))))
1757 if (local
->sta_fw_ver
>= PRISM2_FW_VER(1,3,1))
1758 ret
= prism2_request_hostscan(dev
, ssid
, ssid_len
);
1760 ret
= prism2_request_scan(dev
);
1763 local
->scan_timestamp
= jiffies
;
1765 /* Could inquire F101, F103 or wait for SIOCGIWSCAN and read RID */
1771 #ifndef PRISM2_NO_STATION_MODES
1772 static char * __prism2_translate_scan(local_info_t
*local
,
1773 struct iw_request_info
*info
,
1774 struct hfa384x_hostscan_result
*scan
,
1775 struct hostap_bss_info
*bss
,
1776 char *current_ev
, char *end_buf
)
1779 struct iw_event iwe
;
1789 ssid_len
= bss
->ssid_len
;
1793 ssid_len
= le16_to_cpu(scan
->ssid_len
);
1794 bssid
= scan
->bssid
;
1799 /* First entry *MUST* be the AP MAC address */
1800 memset(&iwe
, 0, sizeof(iwe
));
1801 iwe
.cmd
= SIOCGIWAP
;
1802 iwe
.u
.ap_addr
.sa_family
= ARPHRD_ETHER
;
1803 memcpy(iwe
.u
.ap_addr
.sa_data
, bssid
, ETH_ALEN
);
1804 current_ev
= iwe_stream_add_event(info
, current_ev
, end_buf
, &iwe
,
1807 /* Other entries will be displayed in the order we give them */
1809 memset(&iwe
, 0, sizeof(iwe
));
1810 iwe
.cmd
= SIOCGIWESSID
;
1811 iwe
.u
.data
.length
= ssid_len
;
1812 iwe
.u
.data
.flags
= 1;
1813 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1816 memset(&iwe
, 0, sizeof(iwe
));
1817 iwe
.cmd
= SIOCGIWMODE
;
1819 capabilities
= bss
->capab_info
;
1821 capabilities
= le16_to_cpu(scan
->capability
);
1823 if (capabilities
& (WLAN_CAPABILITY_ESS
|
1824 WLAN_CAPABILITY_IBSS
)) {
1825 if (capabilities
& WLAN_CAPABILITY_ESS
)
1826 iwe
.u
.mode
= IW_MODE_MASTER
;
1828 iwe
.u
.mode
= IW_MODE_ADHOC
;
1829 current_ev
= iwe_stream_add_event(info
, current_ev
, end_buf
,
1830 &iwe
, IW_EV_UINT_LEN
);
1833 memset(&iwe
, 0, sizeof(iwe
));
1834 iwe
.cmd
= SIOCGIWFREQ
;
1836 chan
= le16_to_cpu(scan
->chid
);
1844 iwe
.u
.freq
.m
= freq_list
[chan
- 1] * 100000;
1846 current_ev
= iwe_stream_add_event(info
, current_ev
, end_buf
,
1847 &iwe
, IW_EV_FREQ_LEN
);
1851 memset(&iwe
, 0, sizeof(iwe
));
1853 if (local
->last_scan_type
== PRISM2_HOSTSCAN
) {
1854 iwe
.u
.qual
.level
= le16_to_cpu(scan
->sl
);
1855 iwe
.u
.qual
.noise
= le16_to_cpu(scan
->anl
);
1858 HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan
->sl
));
1860 HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan
->anl
));
1862 iwe
.u
.qual
.updated
= IW_QUAL_LEVEL_UPDATED
1863 | IW_QUAL_NOISE_UPDATED
1864 | IW_QUAL_QUAL_INVALID
1866 current_ev
= iwe_stream_add_event(info
, current_ev
, end_buf
,
1867 &iwe
, IW_EV_QUAL_LEN
);
1870 memset(&iwe
, 0, sizeof(iwe
));
1871 iwe
.cmd
= SIOCGIWENCODE
;
1872 if (capabilities
& WLAN_CAPABILITY_PRIVACY
)
1873 iwe
.u
.data
.flags
= IW_ENCODE_ENABLED
| IW_ENCODE_NOKEY
;
1875 iwe
.u
.data
.flags
= IW_ENCODE_DISABLED
;
1876 iwe
.u
.data
.length
= 0;
1877 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
, &iwe
, "");
1879 /* TODO: add SuppRates into BSS table */
1881 memset(&iwe
, 0, sizeof(iwe
));
1882 iwe
.cmd
= SIOCGIWRATE
;
1883 current_val
= current_ev
+ iwe_stream_lcp_len(info
);
1884 pos
= scan
->sup_rates
;
1885 for (i
= 0; i
< sizeof(scan
->sup_rates
); i
++) {
1888 /* Bit rate given in 500 kb/s units (+ 0x80) */
1889 iwe
.u
.bitrate
.value
= ((pos
[i
] & 0x7f) * 500000);
1890 current_val
= iwe_stream_add_value(
1891 info
, current_ev
, current_val
, end_buf
, &iwe
,
1894 /* Check if we added any event */
1895 if ((current_val
- current_ev
) > iwe_stream_lcp_len(info
))
1896 current_ev
= current_val
;
1899 /* TODO: add BeaconInt,resp_rate,atim into BSS table */
1900 buf
= kmalloc(MAX_WPA_IE_LEN
* 2 + 30, GFP_ATOMIC
);
1902 memset(&iwe
, 0, sizeof(iwe
));
1903 iwe
.cmd
= IWEVCUSTOM
;
1904 sprintf(buf
, "bcn_int=%d", le16_to_cpu(scan
->beacon_interval
));
1905 iwe
.u
.data
.length
= strlen(buf
);
1906 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1909 memset(&iwe
, 0, sizeof(iwe
));
1910 iwe
.cmd
= IWEVCUSTOM
;
1911 sprintf(buf
, "resp_rate=%d", le16_to_cpu(scan
->rate
));
1912 iwe
.u
.data
.length
= strlen(buf
);
1913 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1916 if (local
->last_scan_type
== PRISM2_HOSTSCAN
&&
1917 (capabilities
& WLAN_CAPABILITY_IBSS
)) {
1918 memset(&iwe
, 0, sizeof(iwe
));
1919 iwe
.cmd
= IWEVCUSTOM
;
1920 sprintf(buf
, "atim=%d", le16_to_cpu(scan
->atim
));
1921 iwe
.u
.data
.length
= strlen(buf
);
1922 current_ev
= iwe_stream_add_point(info
, current_ev
,
1923 end_buf
, &iwe
, buf
);
1928 if (bss
&& bss
->wpa_ie_len
> 0 && bss
->wpa_ie_len
<= MAX_WPA_IE_LEN
) {
1929 memset(&iwe
, 0, sizeof(iwe
));
1930 iwe
.cmd
= IWEVGENIE
;
1931 iwe
.u
.data
.length
= bss
->wpa_ie_len
;
1932 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1936 if (bss
&& bss
->rsn_ie_len
> 0 && bss
->rsn_ie_len
<= MAX_WPA_IE_LEN
) {
1937 memset(&iwe
, 0, sizeof(iwe
));
1938 iwe
.cmd
= IWEVGENIE
;
1939 iwe
.u
.data
.length
= bss
->rsn_ie_len
;
1940 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1948 /* Translate scan data returned from the card to a card independent
1949 * format that the Wireless Tools will understand - Jean II */
1950 static inline int prism2_translate_scan(local_info_t
*local
,
1951 struct iw_request_info
*info
,
1952 char *buffer
, int buflen
)
1954 struct hfa384x_hostscan_result
*scan
;
1955 int entry
, hostscan
;
1956 char *current_ev
= buffer
;
1957 char *end_buf
= buffer
+ buflen
;
1958 struct list_head
*ptr
;
1960 spin_lock_bh(&local
->lock
);
1962 list_for_each(ptr
, &local
->bss_list
) {
1963 struct hostap_bss_info
*bss
;
1964 bss
= list_entry(ptr
, struct hostap_bss_info
, list
);
1968 hostscan
= local
->last_scan_type
== PRISM2_HOSTSCAN
;
1969 for (entry
= 0; entry
< local
->last_scan_results_count
; entry
++) {
1971 scan
= &local
->last_scan_results
[entry
];
1973 /* Report every SSID if the AP is using multiple SSIDs. If no
1974 * BSS record is found (e.g., when WPA mode is disabled),
1975 * report the AP once. */
1976 list_for_each(ptr
, &local
->bss_list
) {
1977 struct hostap_bss_info
*bss
;
1978 bss
= list_entry(ptr
, struct hostap_bss_info
, list
);
1979 if (memcmp(bss
->bssid
, scan
->bssid
, ETH_ALEN
) == 0) {
1981 current_ev
= __prism2_translate_scan(
1982 local
, info
, scan
, bss
, current_ev
,
1988 current_ev
= __prism2_translate_scan(
1989 local
, info
, scan
, NULL
, current_ev
, end_buf
);
1991 /* Check if there is space for one more entry */
1992 if ((end_buf
- current_ev
) <= IW_EV_ADDR_LEN
) {
1993 /* Ask user space to try again with a bigger buffer */
1994 spin_unlock_bh(&local
->lock
);
1999 /* Prism2 firmware has limits (32 at least in some versions) for number
2000 * of BSSes in scan results. Extend this limit by using local BSS list.
2002 list_for_each(ptr
, &local
->bss_list
) {
2003 struct hostap_bss_info
*bss
;
2004 bss
= list_entry(ptr
, struct hostap_bss_info
, list
);
2007 current_ev
= __prism2_translate_scan(local
, info
, NULL
, bss
,
2008 current_ev
, end_buf
);
2009 /* Check if there is space for one more entry */
2010 if ((end_buf
- current_ev
) <= IW_EV_ADDR_LEN
) {
2011 /* Ask user space to try again with a bigger buffer */
2012 spin_unlock_bh(&local
->lock
);
2017 spin_unlock_bh(&local
->lock
);
2019 return current_ev
- buffer
;
2021 #endif /* PRISM2_NO_STATION_MODES */
2024 static inline int prism2_ioctl_giwscan_sta(struct net_device
*dev
,
2025 struct iw_request_info
*info
,
2026 struct iw_point
*data
, char *extra
)
2028 #ifdef PRISM2_NO_STATION_MODES
2030 #else /* PRISM2_NO_STATION_MODES */
2031 struct hostap_interface
*iface
;
2032 local_info_t
*local
;
2035 iface
= netdev_priv(dev
);
2036 local
= iface
->local
;
2038 /* Wait until the scan is finished. We can probably do better
2039 * than that - Jean II */
2040 if (local
->scan_timestamp
&&
2041 time_before(jiffies
, local
->scan_timestamp
+ 3 * HZ
)) {
2042 /* Important note : we don't want to block the caller
2043 * until results are ready for various reasons.
2044 * First, managing wait queues is complex and racy
2045 * (there may be multiple simultaneous callers).
2046 * Second, we grab some rtnetlink lock before coming
2047 * here (in dev_ioctl()).
2048 * Third, the caller can wait on the Wireless Event
2052 local
->scan_timestamp
= 0;
2054 res
= prism2_translate_scan(local
, info
, extra
, data
->length
);
2063 #endif /* PRISM2_NO_STATION_MODES */
2067 static int prism2_ioctl_giwscan(struct net_device
*dev
,
2068 struct iw_request_info
*info
,
2069 struct iw_point
*data
, char *extra
)
2071 struct hostap_interface
*iface
;
2072 local_info_t
*local
;
2075 iface
= netdev_priv(dev
);
2076 local
= iface
->local
;
2078 if (local
->iw_mode
== IW_MODE_MASTER
) {
2079 /* In MASTER mode, it doesn't make sense to go around
2080 * scanning the frequencies and make the stations we serve
2081 * wait when what the user is really interested about is the
2082 * list of stations and access points we are talking to.
2083 * So, just extract results from our cache...
2086 /* Translate to WE format */
2087 res
= prism2_ap_translate_scan(dev
, info
, extra
);
2089 printk(KERN_DEBUG
"Scan result translation succeeded "
2090 "(length=%d)\n", res
);
2095 "Scan result translation failed (res=%d)\n",
2102 return prism2_ioctl_giwscan_sta(dev
, info
, data
, extra
);
2107 static const struct iw_priv_args prism2_priv
[] = {
2108 { PRISM2_IOCTL_MONITOR
,
2109 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "monitor" },
2110 { PRISM2_IOCTL_READMIF
,
2111 IW_PRIV_TYPE_BYTE
| IW_PRIV_SIZE_FIXED
| 1,
2112 IW_PRIV_TYPE_BYTE
| IW_PRIV_SIZE_FIXED
| 1, "readmif" },
2113 { PRISM2_IOCTL_WRITEMIF
,
2114 IW_PRIV_TYPE_BYTE
| IW_PRIV_SIZE_FIXED
| 2, 0, "writemif" },
2115 { PRISM2_IOCTL_RESET
,
2116 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "reset" },
2117 { PRISM2_IOCTL_INQUIRE
,
2118 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "inquire" },
2119 { PRISM2_IOCTL_SET_RID_WORD
,
2120 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 2, 0, "set_rid_word" },
2121 { PRISM2_IOCTL_MACCMD
,
2122 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "maccmd" },
2123 { PRISM2_IOCTL_WDS_ADD
,
2124 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "wds_add" },
2125 { PRISM2_IOCTL_WDS_DEL
,
2126 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "wds_del" },
2127 { PRISM2_IOCTL_ADDMAC
,
2128 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "addmac" },
2129 { PRISM2_IOCTL_DELMAC
,
2130 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "delmac" },
2131 { PRISM2_IOCTL_KICKMAC
,
2132 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "kickmac" },
2133 /* --- raw access to sub-ioctls --- */
2134 { PRISM2_IOCTL_PRISM2_PARAM
,
2135 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 2, 0, "prism2_param" },
2136 { PRISM2_IOCTL_GET_PRISM2_PARAM
,
2137 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1,
2138 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getprism2_param" },
2139 /* --- sub-ioctls handlers --- */
2140 { PRISM2_IOCTL_PRISM2_PARAM
,
2141 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "" },
2142 { PRISM2_IOCTL_GET_PRISM2_PARAM
,
2143 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "" },
2144 /* --- sub-ioctls definitions --- */
2145 { PRISM2_PARAM_TXRATECTRL
,
2146 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "txratectrl" },
2147 { PRISM2_PARAM_TXRATECTRL
,
2148 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gettxratectrl" },
2149 { PRISM2_PARAM_BEACON_INT
,
2150 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "beacon_int" },
2151 { PRISM2_PARAM_BEACON_INT
,
2152 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getbeacon_int" },
2153 #ifndef PRISM2_NO_STATION_MODES
2154 { PRISM2_PARAM_PSEUDO_IBSS
,
2155 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "pseudo_ibss" },
2156 { PRISM2_PARAM_PSEUDO_IBSS
,
2157 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getpseudo_ibss" },
2158 #endif /* PRISM2_NO_STATION_MODES */
2160 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "alc" },
2162 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getalc" },
2163 { PRISM2_PARAM_DUMP
,
2164 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "dump" },
2165 { PRISM2_PARAM_DUMP
,
2166 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getdump" },
2167 { PRISM2_PARAM_OTHER_AP_POLICY
,
2168 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "other_ap_policy" },
2169 { PRISM2_PARAM_OTHER_AP_POLICY
,
2170 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getother_ap_pol" },
2171 { PRISM2_PARAM_AP_MAX_INACTIVITY
,
2172 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "max_inactivity" },
2173 { PRISM2_PARAM_AP_MAX_INACTIVITY
,
2174 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getmax_inactivi" },
2175 { PRISM2_PARAM_AP_BRIDGE_PACKETS
,
2176 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "bridge_packets" },
2177 { PRISM2_PARAM_AP_BRIDGE_PACKETS
,
2178 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getbridge_packe" },
2179 { PRISM2_PARAM_DTIM_PERIOD
,
2180 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "dtim_period" },
2181 { PRISM2_PARAM_DTIM_PERIOD
,
2182 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getdtim_period" },
2183 { PRISM2_PARAM_AP_NULLFUNC_ACK
,
2184 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "nullfunc_ack" },
2185 { PRISM2_PARAM_AP_NULLFUNC_ACK
,
2186 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getnullfunc_ack" },
2187 { PRISM2_PARAM_MAX_WDS
,
2188 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "max_wds" },
2189 { PRISM2_PARAM_MAX_WDS
,
2190 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getmax_wds" },
2191 { PRISM2_PARAM_AP_AUTOM_AP_WDS
,
2192 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "autom_ap_wds" },
2193 { PRISM2_PARAM_AP_AUTOM_AP_WDS
,
2194 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getautom_ap_wds" },
2195 { PRISM2_PARAM_AP_AUTH_ALGS
,
2196 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "ap_auth_algs" },
2197 { PRISM2_PARAM_AP_AUTH_ALGS
,
2198 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getap_auth_algs" },
2199 { PRISM2_PARAM_MONITOR_ALLOW_FCSERR
,
2200 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "allow_fcserr" },
2201 { PRISM2_PARAM_MONITOR_ALLOW_FCSERR
,
2202 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getallow_fcserr" },
2203 { PRISM2_PARAM_HOST_ENCRYPT
,
2204 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "host_encrypt" },
2205 { PRISM2_PARAM_HOST_ENCRYPT
,
2206 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethost_encrypt" },
2207 { PRISM2_PARAM_HOST_DECRYPT
,
2208 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "host_decrypt" },
2209 { PRISM2_PARAM_HOST_DECRYPT
,
2210 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethost_decrypt" },
2211 #ifndef PRISM2_NO_STATION_MODES
2212 { PRISM2_PARAM_HOST_ROAMING
,
2213 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "host_roaming" },
2214 { PRISM2_PARAM_HOST_ROAMING
,
2215 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethost_roaming" },
2216 #endif /* PRISM2_NO_STATION_MODES */
2217 { PRISM2_PARAM_BCRX_STA_KEY
,
2218 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "bcrx_sta_key" },
2219 { PRISM2_PARAM_BCRX_STA_KEY
,
2220 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getbcrx_sta_key" },
2221 { PRISM2_PARAM_IEEE_802_1X
,
2222 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "ieee_802_1x" },
2223 { PRISM2_PARAM_IEEE_802_1X
,
2224 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getieee_802_1x" },
2225 { PRISM2_PARAM_ANTSEL_TX
,
2226 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "antsel_tx" },
2227 { PRISM2_PARAM_ANTSEL_TX
,
2228 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getantsel_tx" },
2229 { PRISM2_PARAM_ANTSEL_RX
,
2230 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "antsel_rx" },
2231 { PRISM2_PARAM_ANTSEL_RX
,
2232 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getantsel_rx" },
2233 { PRISM2_PARAM_MONITOR_TYPE
,
2234 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "monitor_type" },
2235 { PRISM2_PARAM_MONITOR_TYPE
,
2236 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getmonitor_type" },
2237 { PRISM2_PARAM_WDS_TYPE
,
2238 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "wds_type" },
2239 { PRISM2_PARAM_WDS_TYPE
,
2240 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getwds_type" },
2241 { PRISM2_PARAM_HOSTSCAN
,
2242 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "hostscan" },
2243 { PRISM2_PARAM_HOSTSCAN
,
2244 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethostscan" },
2245 { PRISM2_PARAM_AP_SCAN
,
2246 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "ap_scan" },
2247 { PRISM2_PARAM_AP_SCAN
,
2248 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getap_scan" },
2249 { PRISM2_PARAM_ENH_SEC
,
2250 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "enh_sec" },
2251 { PRISM2_PARAM_ENH_SEC
,
2252 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getenh_sec" },
2253 #ifdef PRISM2_IO_DEBUG
2254 { PRISM2_PARAM_IO_DEBUG
,
2255 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "io_debug" },
2256 { PRISM2_PARAM_IO_DEBUG
,
2257 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getio_debug" },
2258 #endif /* PRISM2_IO_DEBUG */
2259 { PRISM2_PARAM_BASIC_RATES
,
2260 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "basic_rates" },
2261 { PRISM2_PARAM_BASIC_RATES
,
2262 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getbasic_rates" },
2263 { PRISM2_PARAM_OPER_RATES
,
2264 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "oper_rates" },
2265 { PRISM2_PARAM_OPER_RATES
,
2266 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getoper_rates" },
2267 { PRISM2_PARAM_HOSTAPD
,
2268 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "hostapd" },
2269 { PRISM2_PARAM_HOSTAPD
,
2270 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethostapd" },
2271 { PRISM2_PARAM_HOSTAPD_STA
,
2272 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "hostapd_sta" },
2273 { PRISM2_PARAM_HOSTAPD_STA
,
2274 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethostapd_sta" },
2276 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "wpa" },
2278 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getwpa" },
2279 { PRISM2_PARAM_PRIVACY_INVOKED
,
2280 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "privacy_invoked" },
2281 { PRISM2_PARAM_PRIVACY_INVOKED
,
2282 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getprivacy_invo" },
2283 { PRISM2_PARAM_TKIP_COUNTERMEASURES
,
2284 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "tkip_countermea" },
2285 { PRISM2_PARAM_TKIP_COUNTERMEASURES
,
2286 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gettkip_counter" },
2287 { PRISM2_PARAM_DROP_UNENCRYPTED
,
2288 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "drop_unencrypte" },
2289 { PRISM2_PARAM_DROP_UNENCRYPTED
,
2290 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getdrop_unencry" },
2291 { PRISM2_PARAM_SCAN_CHANNEL_MASK
,
2292 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "scan_channels" },
2293 { PRISM2_PARAM_SCAN_CHANNEL_MASK
,
2294 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getscan_channel" },
2298 static int prism2_ioctl_priv_inquire(struct net_device
*dev
, int *i
)
2300 struct hostap_interface
*iface
;
2301 local_info_t
*local
;
2303 iface
= netdev_priv(dev
);
2304 local
= iface
->local
;
2306 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_INQUIRE
, *i
, NULL
, NULL
))
2313 static int prism2_ioctl_priv_prism2_param(struct net_device
*dev
,
2314 struct iw_request_info
*info
,
2315 void *wrqu
, char *extra
)
2317 struct hostap_interface
*iface
;
2318 local_info_t
*local
;
2319 int *i
= (int *) extra
;
2321 int value
= *(i
+ 1);
2325 iface
= netdev_priv(dev
);
2326 local
= iface
->local
;
2329 case PRISM2_PARAM_TXRATECTRL
:
2330 local
->fw_tx_rate_control
= value
;
2333 case PRISM2_PARAM_BEACON_INT
:
2334 if (hostap_set_word(dev
, HFA384X_RID_CNFBEACONINT
, value
) ||
2335 local
->func
->reset_port(dev
))
2338 local
->beacon_int
= value
;
2341 #ifndef PRISM2_NO_STATION_MODES
2342 case PRISM2_PARAM_PSEUDO_IBSS
:
2343 if (value
== local
->pseudo_adhoc
)
2346 if (value
!= 0 && value
!= 1) {
2351 printk(KERN_DEBUG
"prism2: %s: pseudo IBSS change %d -> %d\n",
2352 dev
->name
, local
->pseudo_adhoc
, value
);
2353 local
->pseudo_adhoc
= value
;
2354 if (local
->iw_mode
!= IW_MODE_ADHOC
)
2357 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
2358 hostap_get_porttype(local
))) {
2363 if (local
->func
->reset_port(dev
))
2366 #endif /* PRISM2_NO_STATION_MODES */
2368 case PRISM2_PARAM_ALC
:
2369 printk(KERN_DEBUG
"%s: %s ALC\n", dev
->name
,
2370 value
== 0 ? "Disabling" : "Enabling");
2371 val
= HFA384X_TEST_CFG_BIT_ALC
;
2372 local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
2373 (HFA384X_TEST_CFG_BITS
<< 8),
2374 value
== 0 ? 0 : 1, &val
, NULL
);
2377 case PRISM2_PARAM_DUMP
:
2378 local
->frame_dump
= value
;
2381 case PRISM2_PARAM_OTHER_AP_POLICY
:
2382 if (value
< 0 || value
> 3) {
2386 if (local
->ap
!= NULL
)
2387 local
->ap
->ap_policy
= value
;
2390 case PRISM2_PARAM_AP_MAX_INACTIVITY
:
2391 if (value
< 0 || value
> 7 * 24 * 60 * 60) {
2395 if (local
->ap
!= NULL
)
2396 local
->ap
->max_inactivity
= value
* HZ
;
2399 case PRISM2_PARAM_AP_BRIDGE_PACKETS
:
2400 if (local
->ap
!= NULL
)
2401 local
->ap
->bridge_packets
= value
;
2404 case PRISM2_PARAM_DTIM_PERIOD
:
2405 if (value
< 0 || value
> 65535) {
2409 if (hostap_set_word(dev
, HFA384X_RID_CNFOWNDTIMPERIOD
, value
)
2410 || local
->func
->reset_port(dev
))
2413 local
->dtim_period
= value
;
2416 case PRISM2_PARAM_AP_NULLFUNC_ACK
:
2417 if (local
->ap
!= NULL
)
2418 local
->ap
->nullfunc_ack
= value
;
2421 case PRISM2_PARAM_MAX_WDS
:
2422 local
->wds_max_connections
= value
;
2425 case PRISM2_PARAM_AP_AUTOM_AP_WDS
:
2426 if (local
->ap
!= NULL
) {
2427 if (!local
->ap
->autom_ap_wds
&& value
) {
2428 /* add WDS link to all APs in STA table */
2429 hostap_add_wds_links(local
);
2431 local
->ap
->autom_ap_wds
= value
;
2435 case PRISM2_PARAM_AP_AUTH_ALGS
:
2436 local
->auth_algs
= value
;
2437 if (hostap_set_auth_algs(local
))
2441 case PRISM2_PARAM_MONITOR_ALLOW_FCSERR
:
2442 local
->monitor_allow_fcserr
= value
;
2445 case PRISM2_PARAM_HOST_ENCRYPT
:
2446 local
->host_encrypt
= value
;
2447 if (hostap_set_encryption(local
) ||
2448 local
->func
->reset_port(dev
))
2452 case PRISM2_PARAM_HOST_DECRYPT
:
2453 local
->host_decrypt
= value
;
2454 if (hostap_set_encryption(local
) ||
2455 local
->func
->reset_port(dev
))
2459 #ifndef PRISM2_NO_STATION_MODES
2460 case PRISM2_PARAM_HOST_ROAMING
:
2461 if (value
< 0 || value
> 2) {
2465 local
->host_roaming
= value
;
2466 if (hostap_set_roaming(local
) || local
->func
->reset_port(dev
))
2469 #endif /* PRISM2_NO_STATION_MODES */
2471 case PRISM2_PARAM_BCRX_STA_KEY
:
2472 local
->bcrx_sta_key
= value
;
2475 case PRISM2_PARAM_IEEE_802_1X
:
2476 local
->ieee_802_1x
= value
;
2479 case PRISM2_PARAM_ANTSEL_TX
:
2480 if (value
< 0 || value
> HOSTAP_ANTSEL_HIGH
) {
2484 local
->antsel_tx
= value
;
2485 hostap_set_antsel(local
);
2488 case PRISM2_PARAM_ANTSEL_RX
:
2489 if (value
< 0 || value
> HOSTAP_ANTSEL_HIGH
) {
2493 local
->antsel_rx
= value
;
2494 hostap_set_antsel(local
);
2497 case PRISM2_PARAM_MONITOR_TYPE
:
2498 if (value
!= PRISM2_MONITOR_80211
&&
2499 value
!= PRISM2_MONITOR_CAPHDR
&&
2500 value
!= PRISM2_MONITOR_PRISM
&&
2501 value
!= PRISM2_MONITOR_RADIOTAP
) {
2505 local
->monitor_type
= value
;
2506 if (local
->iw_mode
== IW_MODE_MONITOR
)
2507 hostap_monitor_set_type(local
);
2510 case PRISM2_PARAM_WDS_TYPE
:
2511 local
->wds_type
= value
;
2514 case PRISM2_PARAM_HOSTSCAN
:
2516 struct hfa384x_hostscan_request scan_req
;
2519 memset(&scan_req
, 0, sizeof(scan_req
));
2520 scan_req
.channel_list
= cpu_to_le16(0x3fff);
2522 case 1: rate
= HFA384X_RATES_1MBPS
; break;
2523 case 2: rate
= HFA384X_RATES_2MBPS
; break;
2524 case 3: rate
= HFA384X_RATES_5MBPS
; break;
2525 case 4: rate
= HFA384X_RATES_11MBPS
; break;
2526 default: rate
= HFA384X_RATES_1MBPS
; break;
2528 scan_req
.txrate
= cpu_to_le16(rate
);
2529 /* leave SSID empty to accept all SSIDs */
2531 if (local
->iw_mode
== IW_MODE_MASTER
) {
2532 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
2533 HFA384X_PORTTYPE_BSS
) ||
2534 local
->func
->reset_port(dev
))
2535 printk(KERN_DEBUG
"Leaving Host AP mode "
2536 "for HostScan failed\n");
2539 if (local
->func
->set_rid(dev
, HFA384X_RID_HOSTSCAN
, &scan_req
,
2540 sizeof(scan_req
))) {
2541 printk(KERN_DEBUG
"HOSTSCAN failed\n");
2544 if (local
->iw_mode
== IW_MODE_MASTER
) {
2545 wait_queue_t __wait
;
2546 init_waitqueue_entry(&__wait
, current
);
2547 add_wait_queue(&local
->hostscan_wq
, &__wait
);
2548 set_current_state(TASK_INTERRUPTIBLE
);
2549 schedule_timeout(HZ
);
2550 if (signal_pending(current
))
2552 set_current_state(TASK_RUNNING
);
2553 remove_wait_queue(&local
->hostscan_wq
, &__wait
);
2555 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
2556 HFA384X_PORTTYPE_HOSTAP
) ||
2557 local
->func
->reset_port(dev
))
2558 printk(KERN_DEBUG
"Returning to Host AP mode "
2559 "after HostScan failed\n");
2564 case PRISM2_PARAM_AP_SCAN
:
2565 local
->passive_scan_interval
= value
;
2566 if (timer_pending(&local
->passive_scan_timer
))
2567 del_timer(&local
->passive_scan_timer
);
2569 local
->passive_scan_timer
.expires
= jiffies
+
2570 local
->passive_scan_interval
* HZ
;
2571 add_timer(&local
->passive_scan_timer
);
2575 case PRISM2_PARAM_ENH_SEC
:
2576 if (value
< 0 || value
> 3) {
2580 local
->enh_sec
= value
;
2581 if (hostap_set_word(dev
, HFA384X_RID_CNFENHSECURITY
,
2583 local
->func
->reset_port(dev
)) {
2584 printk(KERN_INFO
"%s: cnfEnhSecurity requires STA f/w "
2585 "1.6.3 or newer\n", dev
->name
);
2590 #ifdef PRISM2_IO_DEBUG
2591 case PRISM2_PARAM_IO_DEBUG
:
2592 local
->io_debug_enabled
= value
;
2594 #endif /* PRISM2_IO_DEBUG */
2596 case PRISM2_PARAM_BASIC_RATES
:
2597 if ((value
& local
->tx_rate_control
) != value
|| value
== 0) {
2598 printk(KERN_INFO
"%s: invalid basic rate set - basic "
2599 "rates must be in supported rate set\n",
2604 local
->basic_rates
= value
;
2605 if (hostap_set_word(dev
, HFA384X_RID_CNFBASICRATES
,
2606 local
->basic_rates
) ||
2607 local
->func
->reset_port(dev
))
2611 case PRISM2_PARAM_OPER_RATES
:
2612 local
->tx_rate_control
= value
;
2613 if (hostap_set_rate(dev
))
2617 case PRISM2_PARAM_HOSTAPD
:
2618 ret
= hostap_set_hostapd(local
, value
, 1);
2621 case PRISM2_PARAM_HOSTAPD_STA
:
2622 ret
= hostap_set_hostapd_sta(local
, value
, 1);
2625 case PRISM2_PARAM_WPA
:
2627 if (local
->sta_fw_ver
< PRISM2_FW_VER(1,7,0))
2629 else if (hostap_set_word(dev
, HFA384X_RID_SSNHANDLINGMODE
,
2634 case PRISM2_PARAM_PRIVACY_INVOKED
:
2635 local
->privacy_invoked
= value
;
2636 if (hostap_set_encryption(local
) ||
2637 local
->func
->reset_port(dev
))
2641 case PRISM2_PARAM_TKIP_COUNTERMEASURES
:
2642 local
->tkip_countermeasures
= value
;
2645 case PRISM2_PARAM_DROP_UNENCRYPTED
:
2646 local
->drop_unencrypted
= value
;
2649 case PRISM2_PARAM_SCAN_CHANNEL_MASK
:
2650 local
->scan_channel_mask
= value
;
2654 printk(KERN_DEBUG
"%s: prism2_param: unknown param %d\n",
2664 static int prism2_ioctl_priv_get_prism2_param(struct net_device
*dev
,
2665 struct iw_request_info
*info
,
2666 void *wrqu
, char *extra
)
2668 struct hostap_interface
*iface
;
2669 local_info_t
*local
;
2670 int *param
= (int *) extra
;
2673 iface
= netdev_priv(dev
);
2674 local
= iface
->local
;
2677 case PRISM2_PARAM_TXRATECTRL
:
2678 *param
= local
->fw_tx_rate_control
;
2681 case PRISM2_PARAM_BEACON_INT
:
2682 *param
= local
->beacon_int
;
2685 case PRISM2_PARAM_PSEUDO_IBSS
:
2686 *param
= local
->pseudo_adhoc
;
2689 case PRISM2_PARAM_ALC
:
2690 ret
= -EOPNOTSUPP
; /* FIX */
2693 case PRISM2_PARAM_DUMP
:
2694 *param
= local
->frame_dump
;
2697 case PRISM2_PARAM_OTHER_AP_POLICY
:
2698 if (local
->ap
!= NULL
)
2699 *param
= local
->ap
->ap_policy
;
2704 case PRISM2_PARAM_AP_MAX_INACTIVITY
:
2705 if (local
->ap
!= NULL
)
2706 *param
= local
->ap
->max_inactivity
/ HZ
;
2711 case PRISM2_PARAM_AP_BRIDGE_PACKETS
:
2712 if (local
->ap
!= NULL
)
2713 *param
= local
->ap
->bridge_packets
;
2718 case PRISM2_PARAM_DTIM_PERIOD
:
2719 *param
= local
->dtim_period
;
2722 case PRISM2_PARAM_AP_NULLFUNC_ACK
:
2723 if (local
->ap
!= NULL
)
2724 *param
= local
->ap
->nullfunc_ack
;
2729 case PRISM2_PARAM_MAX_WDS
:
2730 *param
= local
->wds_max_connections
;
2733 case PRISM2_PARAM_AP_AUTOM_AP_WDS
:
2734 if (local
->ap
!= NULL
)
2735 *param
= local
->ap
->autom_ap_wds
;
2740 case PRISM2_PARAM_AP_AUTH_ALGS
:
2741 *param
= local
->auth_algs
;
2744 case PRISM2_PARAM_MONITOR_ALLOW_FCSERR
:
2745 *param
= local
->monitor_allow_fcserr
;
2748 case PRISM2_PARAM_HOST_ENCRYPT
:
2749 *param
= local
->host_encrypt
;
2752 case PRISM2_PARAM_HOST_DECRYPT
:
2753 *param
= local
->host_decrypt
;
2756 case PRISM2_PARAM_HOST_ROAMING
:
2757 *param
= local
->host_roaming
;
2760 case PRISM2_PARAM_BCRX_STA_KEY
:
2761 *param
= local
->bcrx_sta_key
;
2764 case PRISM2_PARAM_IEEE_802_1X
:
2765 *param
= local
->ieee_802_1x
;
2768 case PRISM2_PARAM_ANTSEL_TX
:
2769 *param
= local
->antsel_tx
;
2772 case PRISM2_PARAM_ANTSEL_RX
:
2773 *param
= local
->antsel_rx
;
2776 case PRISM2_PARAM_MONITOR_TYPE
:
2777 *param
= local
->monitor_type
;
2780 case PRISM2_PARAM_WDS_TYPE
:
2781 *param
= local
->wds_type
;
2784 case PRISM2_PARAM_HOSTSCAN
:
2788 case PRISM2_PARAM_AP_SCAN
:
2789 *param
= local
->passive_scan_interval
;
2792 case PRISM2_PARAM_ENH_SEC
:
2793 *param
= local
->enh_sec
;
2796 #ifdef PRISM2_IO_DEBUG
2797 case PRISM2_PARAM_IO_DEBUG
:
2798 *param
= local
->io_debug_enabled
;
2800 #endif /* PRISM2_IO_DEBUG */
2802 case PRISM2_PARAM_BASIC_RATES
:
2803 *param
= local
->basic_rates
;
2806 case PRISM2_PARAM_OPER_RATES
:
2807 *param
= local
->tx_rate_control
;
2810 case PRISM2_PARAM_HOSTAPD
:
2811 *param
= local
->hostapd
;
2814 case PRISM2_PARAM_HOSTAPD_STA
:
2815 *param
= local
->hostapd_sta
;
2818 case PRISM2_PARAM_WPA
:
2819 if (local
->sta_fw_ver
< PRISM2_FW_VER(1,7,0))
2821 *param
= local
->wpa
;
2824 case PRISM2_PARAM_PRIVACY_INVOKED
:
2825 *param
= local
->privacy_invoked
;
2828 case PRISM2_PARAM_TKIP_COUNTERMEASURES
:
2829 *param
= local
->tkip_countermeasures
;
2832 case PRISM2_PARAM_DROP_UNENCRYPTED
:
2833 *param
= local
->drop_unencrypted
;
2836 case PRISM2_PARAM_SCAN_CHANNEL_MASK
:
2837 *param
= local
->scan_channel_mask
;
2841 printk(KERN_DEBUG
"%s: get_prism2_param: unknown param %d\n",
2851 static int prism2_ioctl_priv_readmif(struct net_device
*dev
,
2852 struct iw_request_info
*info
,
2853 void *wrqu
, char *extra
)
2855 struct hostap_interface
*iface
;
2856 local_info_t
*local
;
2859 iface
= netdev_priv(dev
);
2860 local
= iface
->local
;
2862 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_READMIF
, *extra
, NULL
,
2872 static int prism2_ioctl_priv_writemif(struct net_device
*dev
,
2873 struct iw_request_info
*info
,
2874 void *wrqu
, char *extra
)
2876 struct hostap_interface
*iface
;
2877 local_info_t
*local
;
2880 iface
= netdev_priv(dev
);
2881 local
= iface
->local
;
2885 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_WRITEMIF
, cr
, &val
, NULL
))
2892 static int prism2_ioctl_priv_monitor(struct net_device
*dev
, int *i
)
2894 struct hostap_interface
*iface
;
2895 local_info_t
*local
;
2899 iface
= netdev_priv(dev
);
2900 local
= iface
->local
;
2902 printk(KERN_DEBUG
"%s: process %d (%s) used deprecated iwpriv monitor "
2903 "- update software to use iwconfig mode monitor\n",
2904 dev
->name
, task_pid_nr(current
), current
->comm
);
2906 /* Backward compatibility code - this can be removed at some point */
2909 /* Disable monitor mode - old mode was not saved, so go to
2911 mode
= IW_MODE_MASTER
;
2912 ret
= prism2_ioctl_siwmode(dev
, NULL
, &mode
, NULL
);
2913 } else if (*i
== 1) {
2914 /* netlink socket mode is not supported anymore since it did
2915 * not separate different devices from each other and was not
2916 * best method for delivering large amount of packets to
2919 } else if (*i
== 2 || *i
== 3) {
2922 local
->monitor_type
= PRISM2_MONITOR_80211
;
2925 local
->monitor_type
= PRISM2_MONITOR_PRISM
;
2928 mode
= IW_MODE_MONITOR
;
2929 ret
= prism2_ioctl_siwmode(dev
, NULL
, &mode
, NULL
);
2930 hostap_monitor_mode_enable(local
);
2938 static int prism2_ioctl_priv_reset(struct net_device
*dev
, int *i
)
2940 struct hostap_interface
*iface
;
2941 local_info_t
*local
;
2943 iface
= netdev_priv(dev
);
2944 local
= iface
->local
;
2946 printk(KERN_DEBUG
"%s: manual reset request(%d)\n", dev
->name
, *i
);
2949 /* Disable and enable card */
2950 local
->func
->hw_shutdown(dev
, 1);
2951 local
->func
->hw_config(dev
, 0);
2956 local
->func
->hw_reset(dev
);
2960 /* Disable and enable port 0 */
2961 local
->func
->reset_port(dev
);
2965 prism2_sta_deauth(local
, WLAN_REASON_DEAUTH_LEAVING
);
2966 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_DISABLE
, 0, NULL
,
2972 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_ENABLE
, 0, NULL
,
2978 printk(KERN_DEBUG
"Unknown reset request %d\n", *i
);
2986 static int prism2_ioctl_priv_set_rid_word(struct net_device
*dev
, int *i
)
2989 int value
= *(i
+ 1);
2991 printk(KERN_DEBUG
"%s: Set RID[0x%X] = %d\n", dev
->name
, rid
, value
);
2993 if (hostap_set_word(dev
, rid
, value
))
3000 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
3001 static int ap_mac_cmd_ioctl(local_info_t
*local
, int *cmd
)
3006 case AP_MAC_CMD_POLICY_OPEN
:
3007 local
->ap
->mac_restrictions
.policy
= MAC_POLICY_OPEN
;
3009 case AP_MAC_CMD_POLICY_ALLOW
:
3010 local
->ap
->mac_restrictions
.policy
= MAC_POLICY_ALLOW
;
3012 case AP_MAC_CMD_POLICY_DENY
:
3013 local
->ap
->mac_restrictions
.policy
= MAC_POLICY_DENY
;
3015 case AP_MAC_CMD_FLUSH
:
3016 ap_control_flush_macs(&local
->ap
->mac_restrictions
);
3018 case AP_MAC_CMD_KICKALL
:
3019 ap_control_kickall(local
->ap
);
3020 hostap_deauth_all_stas(local
->dev
, local
->ap
, 0);
3029 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
3032 #ifdef PRISM2_DOWNLOAD_SUPPORT
3033 static int prism2_ioctl_priv_download(local_info_t
*local
, struct iw_point
*p
)
3035 struct prism2_download_param
*param
;
3038 if (p
->length
< sizeof(struct prism2_download_param
) ||
3039 p
->length
> 1024 || !p
->pointer
)
3042 param
= kmalloc(p
->length
, GFP_KERNEL
);
3046 if (copy_from_user(param
, p
->pointer
, p
->length
)) {
3051 if (p
->length
< sizeof(struct prism2_download_param
) +
3052 param
->num_areas
* sizeof(struct prism2_download_area
)) {
3057 ret
= local
->func
->download(local
, param
);
3063 #endif /* PRISM2_DOWNLOAD_SUPPORT */
3066 static int prism2_set_genericelement(struct net_device
*dev
, u8
*elem
,
3069 struct hostap_interface
*iface
= netdev_priv(dev
);
3070 local_info_t
*local
= iface
->local
;
3074 * Add 16-bit length in the beginning of the buffer because Prism2 RID
3077 buf
= kmalloc(len
+ 2, GFP_KERNEL
);
3081 *((__le16
*) buf
) = cpu_to_le16(len
);
3082 memcpy(buf
+ 2, elem
, len
);
3084 kfree(local
->generic_elem
);
3085 local
->generic_elem
= buf
;
3086 local
->generic_elem_len
= len
+ 2;
3088 return local
->func
->set_rid(local
->dev
, HFA384X_RID_GENERICELEMENT
,
3093 static int prism2_ioctl_siwauth(struct net_device
*dev
,
3094 struct iw_request_info
*info
,
3095 struct iw_param
*data
, char *extra
)
3097 struct hostap_interface
*iface
= netdev_priv(dev
);
3098 local_info_t
*local
= iface
->local
;
3100 switch (data
->flags
& IW_AUTH_INDEX
) {
3101 case IW_AUTH_WPA_VERSION
:
3102 case IW_AUTH_CIPHER_PAIRWISE
:
3103 case IW_AUTH_CIPHER_GROUP
:
3104 case IW_AUTH_KEY_MGMT
:
3106 * Host AP driver does not use these parameters and allows
3107 * wpa_supplicant to control them internally.
3110 case IW_AUTH_TKIP_COUNTERMEASURES
:
3111 local
->tkip_countermeasures
= data
->value
;
3113 case IW_AUTH_DROP_UNENCRYPTED
:
3114 local
->drop_unencrypted
= data
->value
;
3116 case IW_AUTH_80211_AUTH_ALG
:
3117 local
->auth_algs
= data
->value
;
3119 case IW_AUTH_WPA_ENABLED
:
3120 if (data
->value
== 0) {
3122 if (local
->sta_fw_ver
< PRISM2_FW_VER(1,7,0))
3124 prism2_set_genericelement(dev
, "", 0);
3125 local
->host_roaming
= 0;
3126 local
->privacy_invoked
= 0;
3127 if (hostap_set_word(dev
, HFA384X_RID_SSNHANDLINGMODE
,
3129 hostap_set_roaming(local
) ||
3130 hostap_set_encryption(local
) ||
3131 local
->func
->reset_port(dev
))
3135 if (local
->sta_fw_ver
< PRISM2_FW_VER(1,7,0))
3137 local
->host_roaming
= 2;
3138 local
->privacy_invoked
= 1;
3140 if (hostap_set_word(dev
, HFA384X_RID_SSNHANDLINGMODE
, 1) ||
3141 hostap_set_roaming(local
) ||
3142 hostap_set_encryption(local
) ||
3143 local
->func
->reset_port(dev
))
3146 case IW_AUTH_RX_UNENCRYPTED_EAPOL
:
3147 local
->ieee_802_1x
= data
->value
;
3149 case IW_AUTH_PRIVACY_INVOKED
:
3150 local
->privacy_invoked
= data
->value
;
3159 static int prism2_ioctl_giwauth(struct net_device
*dev
,
3160 struct iw_request_info
*info
,
3161 struct iw_param
*data
, char *extra
)
3163 struct hostap_interface
*iface
= netdev_priv(dev
);
3164 local_info_t
*local
= iface
->local
;
3166 switch (data
->flags
& IW_AUTH_INDEX
) {
3167 case IW_AUTH_WPA_VERSION
:
3168 case IW_AUTH_CIPHER_PAIRWISE
:
3169 case IW_AUTH_CIPHER_GROUP
:
3170 case IW_AUTH_KEY_MGMT
:
3172 * Host AP driver does not use these parameters and allows
3173 * wpa_supplicant to control them internally.
3176 case IW_AUTH_TKIP_COUNTERMEASURES
:
3177 data
->value
= local
->tkip_countermeasures
;
3179 case IW_AUTH_DROP_UNENCRYPTED
:
3180 data
->value
= local
->drop_unencrypted
;
3182 case IW_AUTH_80211_AUTH_ALG
:
3183 data
->value
= local
->auth_algs
;
3185 case IW_AUTH_WPA_ENABLED
:
3186 data
->value
= local
->wpa
;
3188 case IW_AUTH_RX_UNENCRYPTED_EAPOL
:
3189 data
->value
= local
->ieee_802_1x
;
3198 static int prism2_ioctl_siwencodeext(struct net_device
*dev
,
3199 struct iw_request_info
*info
,
3200 struct iw_point
*erq
, char *extra
)
3202 struct hostap_interface
*iface
= netdev_priv(dev
);
3203 local_info_t
*local
= iface
->local
;
3204 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*) extra
;
3206 struct lib80211_crypto_ops
*ops
;
3207 struct lib80211_crypt_data
**crypt
;
3210 const char *alg
, *module
;
3212 i
= erq
->flags
& IW_ENCODE_INDEX
;
3215 if (i
< 1 || i
> WEP_KEYS
)
3216 i
= local
->crypt_info
.tx_keyidx
;
3219 if (i
< 0 || i
>= WEP_KEYS
)
3222 addr
= ext
->addr
.sa_data
;
3223 if (addr
[0] == 0xff && addr
[1] == 0xff && addr
[2] == 0xff &&
3224 addr
[3] == 0xff && addr
[4] == 0xff && addr
[5] == 0xff) {
3226 crypt
= &local
->crypt_info
.crypt
[i
];
3230 sta_ptr
= ap_crypt_get_ptrs(local
->ap
, addr
, 0, &crypt
);
3231 if (sta_ptr
== NULL
) {
3232 if (local
->iw_mode
== IW_MODE_INFRA
) {
3234 * TODO: add STA entry for the current AP so
3235 * that unicast key can be used. For now, this
3236 * is emulated by using default key idx 0.
3239 crypt
= &local
->crypt_info
.crypt
[i
];
3245 if ((erq
->flags
& IW_ENCODE_DISABLED
) ||
3246 ext
->alg
== IW_ENCODE_ALG_NONE
) {
3248 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
3253 case IW_ENCODE_ALG_WEP
:
3255 module
= "lib80211_crypt_wep";
3257 case IW_ENCODE_ALG_TKIP
:
3259 module
= "lib80211_crypt_tkip";
3261 case IW_ENCODE_ALG_CCMP
:
3263 module
= "lib80211_crypt_ccmp";
3266 printk(KERN_DEBUG
"%s: unsupported algorithm %d\n",
3267 local
->dev
->name
, ext
->alg
);
3272 ops
= lib80211_get_crypto_ops(alg
);
3274 request_module(module
);
3275 ops
= lib80211_get_crypto_ops(alg
);
3278 printk(KERN_DEBUG
"%s: unknown crypto alg '%s'\n",
3279 local
->dev
->name
, alg
);
3284 if (sta_ptr
|| ext
->alg
!= IW_ENCODE_ALG_WEP
) {
3286 * Per station encryption and other than WEP algorithms
3287 * require host-based encryption, so force them on
3290 local
->host_decrypt
= local
->host_encrypt
= 1;
3293 if (*crypt
== NULL
|| (*crypt
)->ops
!= ops
) {
3294 struct lib80211_crypt_data
*new_crypt
;
3296 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
3298 new_crypt
= kzalloc(sizeof(struct lib80211_crypt_data
),
3300 if (new_crypt
== NULL
) {
3304 new_crypt
->ops
= ops
;
3305 if (new_crypt
->ops
&& try_module_get(new_crypt
->ops
->owner
))
3306 new_crypt
->priv
= new_crypt
->ops
->init(i
);
3307 if (new_crypt
->priv
== NULL
) {
3317 * TODO: if ext_flags does not have IW_ENCODE_EXT_RX_SEQ_VALID, the
3318 * existing seq# should not be changed.
3319 * TODO: if ext_flags has IW_ENCODE_EXT_TX_SEQ_VALID, next TX seq#
3320 * should be changed to something else than zero.
3322 if ((!(ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
) || ext
->key_len
> 0)
3323 && (*crypt
)->ops
->set_key
&&
3324 (*crypt
)->ops
->set_key(ext
->key
, ext
->key_len
, ext
->rx_seq
,
3325 (*crypt
)->priv
) < 0) {
3326 printk(KERN_DEBUG
"%s: key setting failed\n",
3332 if (ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
) {
3334 local
->crypt_info
.tx_keyidx
= i
;
3338 if (sta_ptr
== NULL
&& ext
->key_len
> 0) {
3340 for (j
= 0; j
< WEP_KEYS
; j
++) {
3341 if (j
!= i
&& local
->crypt_info
.crypt
[j
]) {
3347 local
->crypt_info
.tx_keyidx
= i
;
3352 hostap_handle_sta_release(sta_ptr
);
3354 local
->open_wep
= erq
->flags
& IW_ENCODE_OPEN
;
3357 * Do not reset port0 if card is in Managed mode since resetting will
3358 * generate new IEEE 802.11 authentication which may end up in looping
3359 * with IEEE 802.1X. Prism2 documentation seem to require port reset
3360 * after WEP configuration. However, keys are apparently changed at
3361 * least in Managed mode.
3364 (hostap_set_encryption(local
) ||
3365 (local
->iw_mode
!= IW_MODE_INFRA
&&
3366 local
->func
->reset_port(local
->dev
))))
3373 static int prism2_ioctl_giwencodeext(struct net_device
*dev
,
3374 struct iw_request_info
*info
,
3375 struct iw_point
*erq
, char *extra
)
3377 struct hostap_interface
*iface
= netdev_priv(dev
);
3378 local_info_t
*local
= iface
->local
;
3379 struct lib80211_crypt_data
**crypt
;
3382 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*) extra
;
3385 max_key_len
= erq
->length
- sizeof(*ext
);
3386 if (max_key_len
< 0)
3389 i
= erq
->flags
& IW_ENCODE_INDEX
;
3390 if (i
< 1 || i
> WEP_KEYS
)
3391 i
= local
->crypt_info
.tx_keyidx
;
3395 addr
= ext
->addr
.sa_data
;
3396 if (addr
[0] == 0xff && addr
[1] == 0xff && addr
[2] == 0xff &&
3397 addr
[3] == 0xff && addr
[4] == 0xff && addr
[5] == 0xff) {
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 (param
->sta_addr
[0] == 0xff && param
->sta_addr
[1] == 0xff &&
3461 param
->sta_addr
[2] == 0xff && param
->sta_addr
[3] == 0xff &&
3462 param
->sta_addr
[4] == 0xff && param
->sta_addr
[5] == 0xff) {
3463 if (param
->u
.crypt
.idx
>= WEP_KEYS
)
3466 crypt
= &local
->crypt_info
.crypt
[param
->u
.crypt
.idx
];
3468 if (param
->u
.crypt
.idx
)
3470 sta_ptr
= ap_crypt_get_ptrs(
3471 local
->ap
, param
->sta_addr
,
3472 (param
->u
.crypt
.flags
& HOSTAP_CRYPT_FLAG_PERMANENT
),
3475 if (sta_ptr
== NULL
) {
3476 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_UNKNOWN_ADDR
;
3481 if (strcmp(param
->u
.crypt
.alg
, "none") == 0) {
3483 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
3487 ops
= lib80211_get_crypto_ops(param
->u
.crypt
.alg
);
3488 if (ops
== NULL
&& strcmp(param
->u
.crypt
.alg
, "WEP") == 0) {
3489 request_module("lib80211_crypt_wep");
3490 ops
= lib80211_get_crypto_ops(param
->u
.crypt
.alg
);
3491 } else if (ops
== NULL
&& strcmp(param
->u
.crypt
.alg
, "TKIP") == 0) {
3492 request_module("lib80211_crypt_tkip");
3493 ops
= lib80211_get_crypto_ops(param
->u
.crypt
.alg
);
3494 } else if (ops
== NULL
&& strcmp(param
->u
.crypt
.alg
, "CCMP") == 0) {
3495 request_module("lib80211_crypt_ccmp");
3496 ops
= lib80211_get_crypto_ops(param
->u
.crypt
.alg
);
3499 printk(KERN_DEBUG
"%s: unknown crypto alg '%s'\n",
3500 local
->dev
->name
, param
->u
.crypt
.alg
);
3501 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_UNKNOWN_ALG
;
3506 /* station based encryption and other than WEP algorithms require
3507 * host-based encryption, so force them on automatically */
3508 local
->host_decrypt
= local
->host_encrypt
= 1;
3510 if (*crypt
== NULL
|| (*crypt
)->ops
!= ops
) {
3511 struct lib80211_crypt_data
*new_crypt
;
3513 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
3515 new_crypt
= kzalloc(sizeof(struct lib80211_crypt_data
),
3517 if (new_crypt
== NULL
) {
3521 new_crypt
->ops
= ops
;
3522 new_crypt
->priv
= new_crypt
->ops
->init(param
->u
.crypt
.idx
);
3523 if (new_crypt
->priv
== NULL
) {
3525 param
->u
.crypt
.err
=
3526 HOSTAP_CRYPT_ERR_CRYPT_INIT_FAILED
;
3534 if ((!(param
->u
.crypt
.flags
& HOSTAP_CRYPT_FLAG_SET_TX_KEY
) ||
3535 param
->u
.crypt
.key_len
> 0) && (*crypt
)->ops
->set_key
&&
3536 (*crypt
)->ops
->set_key(param
->u
.crypt
.key
,
3537 param
->u
.crypt
.key_len
, param
->u
.crypt
.seq
,
3538 (*crypt
)->priv
) < 0) {
3539 printk(KERN_DEBUG
"%s: key setting failed\n",
3541 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_KEY_SET_FAILED
;
3546 if (param
->u
.crypt
.flags
& HOSTAP_CRYPT_FLAG_SET_TX_KEY
) {
3548 local
->crypt_info
.tx_keyidx
= param
->u
.crypt
.idx
;
3549 else if (param
->u
.crypt
.idx
) {
3550 printk(KERN_DEBUG
"%s: TX key idx setting failed\n",
3552 param
->u
.crypt
.err
=
3553 HOSTAP_CRYPT_ERR_TX_KEY_SET_FAILED
;
3561 hostap_handle_sta_release(sta_ptr
);
3563 /* Do not reset port0 if card is in Managed mode since resetting will
3564 * generate new IEEE 802.11 authentication which may end up in looping
3565 * with IEEE 802.1X. Prism2 documentation seem to require port reset
3566 * after WEP configuration. However, keys are apparently changed at
3567 * least in Managed mode. */
3569 (hostap_set_encryption(local
) ||
3570 (local
->iw_mode
!= IW_MODE_INFRA
&&
3571 local
->func
->reset_port(local
->dev
)))) {
3572 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_CARD_CONF_FAILED
;
3580 static int prism2_ioctl_get_encryption(local_info_t
*local
,
3581 struct prism2_hostapd_param
*param
,
3584 struct lib80211_crypt_data
**crypt
;
3588 param
->u
.crypt
.err
= 0;
3590 max_key_len
= param_len
-
3591 (int) ((char *) param
->u
.crypt
.key
- (char *) param
);
3592 if (max_key_len
< 0)
3595 if (param
->sta_addr
[0] == 0xff && param
->sta_addr
[1] == 0xff &&
3596 param
->sta_addr
[2] == 0xff && param
->sta_addr
[3] == 0xff &&
3597 param
->sta_addr
[4] == 0xff && param
->sta_addr
[5] == 0xff) {
3599 if (param
->u
.crypt
.idx
>= WEP_KEYS
)
3600 param
->u
.crypt
.idx
= local
->crypt_info
.tx_keyidx
;
3601 crypt
= &local
->crypt_info
.crypt
[param
->u
.crypt
.idx
];
3603 param
->u
.crypt
.idx
= 0;
3604 sta_ptr
= ap_crypt_get_ptrs(local
->ap
, param
->sta_addr
, 0,
3607 if (sta_ptr
== NULL
) {
3608 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_UNKNOWN_ADDR
;
3613 if (*crypt
== NULL
|| (*crypt
)->ops
== NULL
) {
3614 memcpy(param
->u
.crypt
.alg
, "none", 5);
3615 param
->u
.crypt
.key_len
= 0;
3616 param
->u
.crypt
.idx
= 0xff;
3618 strncpy(param
->u
.crypt
.alg
, (*crypt
)->ops
->name
,
3619 HOSTAP_CRYPT_ALG_NAME_LEN
);
3620 param
->u
.crypt
.key_len
= 0;
3622 memset(param
->u
.crypt
.seq
, 0, 8);
3623 if ((*crypt
)->ops
->get_key
) {
3624 param
->u
.crypt
.key_len
=
3625 (*crypt
)->ops
->get_key(param
->u
.crypt
.key
,
3633 hostap_handle_sta_release(sta_ptr
);
3639 static int prism2_ioctl_get_rid(local_info_t
*local
,
3640 struct prism2_hostapd_param
*param
,
3645 max_len
= param_len
- PRISM2_HOSTAPD_RID_HDR_LEN
;
3649 res
= local
->func
->get_rid(local
->dev
, param
->u
.rid
.rid
,
3650 param
->u
.rid
.data
, param
->u
.rid
.len
, 0);
3652 param
->u
.rid
.len
= res
;
3660 static int prism2_ioctl_set_rid(local_info_t
*local
,
3661 struct prism2_hostapd_param
*param
,
3666 max_len
= param_len
- PRISM2_HOSTAPD_RID_HDR_LEN
;
3667 if (max_len
< 0 || max_len
< param
->u
.rid
.len
)
3670 return local
->func
->set_rid(local
->dev
, param
->u
.rid
.rid
,
3671 param
->u
.rid
.data
, param
->u
.rid
.len
);
3675 static int prism2_ioctl_set_assoc_ap_addr(local_info_t
*local
,
3676 struct prism2_hostapd_param
*param
,
3679 printk(KERN_DEBUG
"%ssta: associated as client with AP %pM\n",
3680 local
->dev
->name
, param
->sta_addr
);
3681 memcpy(local
->assoc_ap_addr
, param
->sta_addr
, ETH_ALEN
);
3686 static int prism2_ioctl_siwgenie(struct net_device
*dev
,
3687 struct iw_request_info
*info
,
3688 struct iw_point
*data
, char *extra
)
3690 return prism2_set_genericelement(dev
, extra
, data
->length
);
3694 static int prism2_ioctl_giwgenie(struct net_device
*dev
,
3695 struct iw_request_info
*info
,
3696 struct iw_point
*data
, char *extra
)
3698 struct hostap_interface
*iface
= netdev_priv(dev
);
3699 local_info_t
*local
= iface
->local
;
3700 int len
= local
->generic_elem_len
- 2;
3702 if (len
<= 0 || local
->generic_elem
== NULL
) {
3707 if (data
->length
< len
)
3711 memcpy(extra
, local
->generic_elem
+ 2, len
);
3717 static int prism2_ioctl_set_generic_element(local_info_t
*local
,
3718 struct prism2_hostapd_param
*param
,
3723 len
= param
->u
.generic_elem
.len
;
3724 max_len
= param_len
- PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN
;
3725 if (max_len
< 0 || max_len
< len
)
3728 return prism2_set_genericelement(local
->dev
,
3729 param
->u
.generic_elem
.data
, len
);
3733 static int prism2_ioctl_siwmlme(struct net_device
*dev
,
3734 struct iw_request_info
*info
,
3735 struct iw_point
*data
, char *extra
)
3737 struct hostap_interface
*iface
= netdev_priv(dev
);
3738 local_info_t
*local
= iface
->local
;
3739 struct iw_mlme
*mlme
= (struct iw_mlme
*) extra
;
3742 reason
= cpu_to_le16(mlme
->reason_code
);
3744 switch (mlme
->cmd
) {
3745 case IW_MLME_DEAUTH
:
3746 return prism2_sta_send_mgmt(local
, mlme
->addr
.sa_data
,
3747 IEEE80211_STYPE_DEAUTH
,
3749 case IW_MLME_DISASSOC
:
3750 return prism2_sta_send_mgmt(local
, mlme
->addr
.sa_data
,
3751 IEEE80211_STYPE_DISASSOC
,
3759 static int prism2_ioctl_mlme(local_info_t
*local
,
3760 struct prism2_hostapd_param
*param
)
3764 reason
= cpu_to_le16(param
->u
.mlme
.reason_code
);
3765 switch (param
->u
.mlme
.cmd
) {
3766 case MLME_STA_DEAUTH
:
3767 return prism2_sta_send_mgmt(local
, param
->sta_addr
,
3768 IEEE80211_STYPE_DEAUTH
,
3770 case MLME_STA_DISASSOC
:
3771 return prism2_sta_send_mgmt(local
, param
->sta_addr
,
3772 IEEE80211_STYPE_DISASSOC
,
3780 static int prism2_ioctl_scan_req(local_info_t
*local
,
3781 struct prism2_hostapd_param
*param
)
3783 #ifndef PRISM2_NO_STATION_MODES
3784 if ((local
->iw_mode
!= IW_MODE_INFRA
&&
3785 local
->iw_mode
!= IW_MODE_ADHOC
) ||
3786 (local
->sta_fw_ver
< PRISM2_FW_VER(1,3,1)))
3789 if (!local
->dev_enabled
)
3792 return prism2_request_hostscan(local
->dev
, param
->u
.scan_req
.ssid
,
3793 param
->u
.scan_req
.ssid_len
);
3794 #else /* PRISM2_NO_STATION_MODES */
3796 #endif /* PRISM2_NO_STATION_MODES */
3800 static int prism2_ioctl_priv_hostapd(local_info_t
*local
, struct iw_point
*p
)
3802 struct prism2_hostapd_param
*param
;
3806 if (p
->length
< sizeof(struct prism2_hostapd_param
) ||
3807 p
->length
> PRISM2_HOSTAPD_MAX_BUF_SIZE
|| !p
->pointer
)
3810 param
= kmalloc(p
->length
, GFP_KERNEL
);
3814 if (copy_from_user(param
, p
->pointer
, p
->length
)) {
3819 switch (param
->cmd
) {
3820 case PRISM2_SET_ENCRYPTION
:
3821 ret
= prism2_ioctl_set_encryption(local
, param
, p
->length
);
3823 case PRISM2_GET_ENCRYPTION
:
3824 ret
= prism2_ioctl_get_encryption(local
, param
, p
->length
);
3826 case PRISM2_HOSTAPD_GET_RID
:
3827 ret
= prism2_ioctl_get_rid(local
, param
, p
->length
);
3829 case PRISM2_HOSTAPD_SET_RID
:
3830 ret
= prism2_ioctl_set_rid(local
, param
, p
->length
);
3832 case PRISM2_HOSTAPD_SET_ASSOC_AP_ADDR
:
3833 ret
= prism2_ioctl_set_assoc_ap_addr(local
, param
, p
->length
);
3835 case PRISM2_HOSTAPD_SET_GENERIC_ELEMENT
:
3836 ret
= prism2_ioctl_set_generic_element(local
, param
,
3839 case PRISM2_HOSTAPD_MLME
:
3840 ret
= prism2_ioctl_mlme(local
, param
);
3842 case PRISM2_HOSTAPD_SCAN_REQ
:
3843 ret
= prism2_ioctl_scan_req(local
, param
);
3846 ret
= prism2_hostapd(local
->ap
, param
);
3851 if (ret
== 1 || !ap_ioctl
) {
3852 if (copy_to_user(p
->pointer
, param
, p
->length
)) {
3855 } else if (ap_ioctl
)
3865 static void prism2_get_drvinfo(struct net_device
*dev
,
3866 struct ethtool_drvinfo
*info
)
3868 struct hostap_interface
*iface
;
3869 local_info_t
*local
;
3871 iface
= netdev_priv(dev
);
3872 local
= iface
->local
;
3874 strncpy(info
->driver
, "hostap", sizeof(info
->driver
) - 1);
3875 snprintf(info
->fw_version
, sizeof(info
->fw_version
) - 1,
3876 "%d.%d.%d", (local
->sta_fw_ver
>> 16) & 0xff,
3877 (local
->sta_fw_ver
>> 8) & 0xff,
3878 local
->sta_fw_ver
& 0xff);
3881 const struct ethtool_ops prism2_ethtool_ops
= {
3882 .get_drvinfo
= prism2_get_drvinfo
3886 /* Structures to export the Wireless Handlers */
3888 static const iw_handler prism2_handler
[] =
3890 (iw_handler
) NULL
, /* SIOCSIWCOMMIT */
3891 (iw_handler
) prism2_get_name
, /* SIOCGIWNAME */
3892 (iw_handler
) NULL
, /* SIOCSIWNWID */
3893 (iw_handler
) NULL
, /* SIOCGIWNWID */
3894 (iw_handler
) prism2_ioctl_siwfreq
, /* SIOCSIWFREQ */
3895 (iw_handler
) prism2_ioctl_giwfreq
, /* SIOCGIWFREQ */
3896 (iw_handler
) prism2_ioctl_siwmode
, /* SIOCSIWMODE */
3897 (iw_handler
) prism2_ioctl_giwmode
, /* SIOCGIWMODE */
3898 (iw_handler
) prism2_ioctl_siwsens
, /* SIOCSIWSENS */
3899 (iw_handler
) prism2_ioctl_giwsens
, /* SIOCGIWSENS */
3900 (iw_handler
) NULL
/* not used */, /* SIOCSIWRANGE */
3901 (iw_handler
) prism2_ioctl_giwrange
, /* SIOCGIWRANGE */
3902 (iw_handler
) NULL
/* not used */, /* SIOCSIWPRIV */
3903 (iw_handler
) NULL
/* kernel code */, /* SIOCGIWPRIV */
3904 (iw_handler
) NULL
/* not used */, /* SIOCSIWSTATS */
3905 (iw_handler
) NULL
/* kernel code */, /* SIOCGIWSTATS */
3906 iw_handler_set_spy
, /* SIOCSIWSPY */
3907 iw_handler_get_spy
, /* SIOCGIWSPY */
3908 iw_handler_set_thrspy
, /* SIOCSIWTHRSPY */
3909 iw_handler_get_thrspy
, /* SIOCGIWTHRSPY */
3910 (iw_handler
) prism2_ioctl_siwap
, /* SIOCSIWAP */
3911 (iw_handler
) prism2_ioctl_giwap
, /* SIOCGIWAP */
3912 (iw_handler
) prism2_ioctl_siwmlme
, /* SIOCSIWMLME */
3913 (iw_handler
) prism2_ioctl_giwaplist
, /* SIOCGIWAPLIST */
3914 (iw_handler
) prism2_ioctl_siwscan
, /* SIOCSIWSCAN */
3915 (iw_handler
) prism2_ioctl_giwscan
, /* SIOCGIWSCAN */
3916 (iw_handler
) prism2_ioctl_siwessid
, /* SIOCSIWESSID */
3917 (iw_handler
) prism2_ioctl_giwessid
, /* SIOCGIWESSID */
3918 (iw_handler
) prism2_ioctl_siwnickn
, /* SIOCSIWNICKN */
3919 (iw_handler
) prism2_ioctl_giwnickn
, /* SIOCGIWNICKN */
3920 (iw_handler
) NULL
, /* -- hole -- */
3921 (iw_handler
) NULL
, /* -- hole -- */
3922 (iw_handler
) prism2_ioctl_siwrate
, /* SIOCSIWRATE */
3923 (iw_handler
) prism2_ioctl_giwrate
, /* SIOCGIWRATE */
3924 (iw_handler
) prism2_ioctl_siwrts
, /* SIOCSIWRTS */
3925 (iw_handler
) prism2_ioctl_giwrts
, /* SIOCGIWRTS */
3926 (iw_handler
) prism2_ioctl_siwfrag
, /* SIOCSIWFRAG */
3927 (iw_handler
) prism2_ioctl_giwfrag
, /* SIOCGIWFRAG */
3928 (iw_handler
) prism2_ioctl_siwtxpow
, /* SIOCSIWTXPOW */
3929 (iw_handler
) prism2_ioctl_giwtxpow
, /* SIOCGIWTXPOW */
3930 (iw_handler
) prism2_ioctl_siwretry
, /* SIOCSIWRETRY */
3931 (iw_handler
) prism2_ioctl_giwretry
, /* SIOCGIWRETRY */
3932 (iw_handler
) prism2_ioctl_siwencode
, /* SIOCSIWENCODE */
3933 (iw_handler
) prism2_ioctl_giwencode
, /* SIOCGIWENCODE */
3934 (iw_handler
) prism2_ioctl_siwpower
, /* SIOCSIWPOWER */
3935 (iw_handler
) prism2_ioctl_giwpower
, /* SIOCGIWPOWER */
3936 (iw_handler
) NULL
, /* -- hole -- */
3937 (iw_handler
) NULL
, /* -- hole -- */
3938 (iw_handler
) prism2_ioctl_siwgenie
, /* SIOCSIWGENIE */
3939 (iw_handler
) prism2_ioctl_giwgenie
, /* SIOCGIWGENIE */
3940 (iw_handler
) prism2_ioctl_siwauth
, /* SIOCSIWAUTH */
3941 (iw_handler
) prism2_ioctl_giwauth
, /* SIOCGIWAUTH */
3942 (iw_handler
) prism2_ioctl_siwencodeext
, /* SIOCSIWENCODEEXT */
3943 (iw_handler
) prism2_ioctl_giwencodeext
, /* SIOCGIWENCODEEXT */
3944 (iw_handler
) NULL
, /* SIOCSIWPMKSA */
3945 (iw_handler
) NULL
, /* -- hole -- */
3948 static const iw_handler prism2_private_handler
[] =
3949 { /* SIOCIWFIRSTPRIV + */
3950 (iw_handler
) prism2_ioctl_priv_prism2_param
, /* 0 */
3951 (iw_handler
) prism2_ioctl_priv_get_prism2_param
, /* 1 */
3952 (iw_handler
) prism2_ioctl_priv_writemif
, /* 2 */
3953 (iw_handler
) prism2_ioctl_priv_readmif
, /* 3 */
3956 const struct iw_handler_def hostap_iw_handler_def
=
3958 .num_standard
= ARRAY_SIZE(prism2_handler
),
3959 .num_private
= ARRAY_SIZE(prism2_private_handler
),
3960 .num_private_args
= ARRAY_SIZE(prism2_priv
),
3961 .standard
= (iw_handler
*) prism2_handler
,
3962 .private = (iw_handler
*) prism2_private_handler
,
3963 .private_args
= (struct iw_priv_args
*) prism2_priv
,
3964 .get_wireless_stats
= hostap_get_wireless_stats
,
3968 int hostap_ioctl(struct net_device
*dev
, struct ifreq
*ifr
, int cmd
)
3970 struct iwreq
*wrq
= (struct iwreq
*) ifr
;
3971 struct hostap_interface
*iface
;
3972 local_info_t
*local
;
3975 iface
= netdev_priv(dev
);
3976 local
= iface
->local
;
3979 /* Private ioctls (iwpriv) that have not yet been converted
3980 * into new wireless extensions API */
3982 case PRISM2_IOCTL_INQUIRE
:
3983 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
3984 else ret
= prism2_ioctl_priv_inquire(dev
, (int *) wrq
->u
.name
);
3987 case PRISM2_IOCTL_MONITOR
:
3988 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
3989 else ret
= prism2_ioctl_priv_monitor(dev
, (int *) wrq
->u
.name
);
3992 case PRISM2_IOCTL_RESET
:
3993 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
3994 else ret
= prism2_ioctl_priv_reset(dev
, (int *) wrq
->u
.name
);
3997 case PRISM2_IOCTL_WDS_ADD
:
3998 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
3999 else ret
= prism2_wds_add(local
, wrq
->u
.ap_addr
.sa_data
, 1);
4002 case PRISM2_IOCTL_WDS_DEL
:
4003 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4004 else ret
= prism2_wds_del(local
, wrq
->u
.ap_addr
.sa_data
, 1, 0);
4007 case PRISM2_IOCTL_SET_RID_WORD
:
4008 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4009 else ret
= prism2_ioctl_priv_set_rid_word(dev
,
4010 (int *) wrq
->u
.name
);
4013 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
4014 case PRISM2_IOCTL_MACCMD
:
4015 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4016 else ret
= ap_mac_cmd_ioctl(local
, (int *) wrq
->u
.name
);
4019 case PRISM2_IOCTL_ADDMAC
:
4020 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4021 else ret
= ap_control_add_mac(&local
->ap
->mac_restrictions
,
4022 wrq
->u
.ap_addr
.sa_data
);
4024 case PRISM2_IOCTL_DELMAC
:
4025 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4026 else ret
= ap_control_del_mac(&local
->ap
->mac_restrictions
,
4027 wrq
->u
.ap_addr
.sa_data
);
4029 case PRISM2_IOCTL_KICKMAC
:
4030 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4031 else ret
= ap_control_kick_mac(local
->ap
, local
->dev
,
4032 wrq
->u
.ap_addr
.sa_data
);
4034 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
4037 /* Private ioctls that are not used with iwpriv;
4038 * in SIOCDEVPRIVATE range */
4040 #ifdef PRISM2_DOWNLOAD_SUPPORT
4041 case PRISM2_IOCTL_DOWNLOAD
:
4042 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4043 else ret
= prism2_ioctl_priv_download(local
, &wrq
->u
.data
);
4045 #endif /* PRISM2_DOWNLOAD_SUPPORT */
4047 case PRISM2_IOCTL_HOSTAPD
:
4048 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4049 else ret
= prism2_ioctl_priv_hostapd(local
, &wrq
->u
.data
);