1 /* ioctl() (mostly Linux Wireless Extensions) routines for Host AP driver */
3 #include <linux/types.h>
4 #include <linux/sched.h>
5 #include <linux/ethtool.h>
6 #include <linux/if_arp.h>
7 #include <net/lib80211.h>
9 #include "hostap_wlan.h"
11 #include "hostap_ap.h"
13 static struct iw_statistics
*hostap_get_wireless_stats(struct net_device
*dev
)
15 struct hostap_interface
*iface
;
17 struct iw_statistics
*wstats
;
19 iface
= netdev_priv(dev
);
22 /* Why are we doing that ? Jean II */
23 if (iface
->type
!= HOSTAP_INTERFACE_MAIN
)
26 wstats
= &local
->wstats
;
29 wstats
->discard
.code
=
30 local
->comm_tallies
.rx_discards_wep_undecryptable
;
31 wstats
->discard
.misc
=
32 local
->comm_tallies
.rx_fcs_errors
+
33 local
->comm_tallies
.rx_discards_no_buffer
+
34 local
->comm_tallies
.tx_discards_wrong_sa
;
36 wstats
->discard
.retries
=
37 local
->comm_tallies
.tx_retry_limit_exceeded
;
38 wstats
->discard
.fragment
=
39 local
->comm_tallies
.rx_message_in_bad_msg_fragments
;
41 if (local
->iw_mode
!= IW_MODE_MASTER
&&
42 local
->iw_mode
!= IW_MODE_REPEAT
) {
45 /* RID reading might sleep and it must not be called in
46 * interrupt context or while atomic. However, this
47 * function seems to be called while atomic (at least in Linux
48 * 2.5.59). Update signal quality values only if in suitable
49 * context. Otherwise, previous values read from tick timer
53 #endif /* in_atomic */
55 if (update
&& prism2_update_comms_qual(dev
) == 0)
56 wstats
->qual
.updated
= IW_QUAL_ALL_UPDATED
|
59 wstats
->qual
.qual
= local
->comms_qual
;
60 wstats
->qual
.level
= local
->avg_signal
;
61 wstats
->qual
.noise
= local
->avg_noise
;
63 wstats
->qual
.qual
= 0;
64 wstats
->qual
.level
= 0;
65 wstats
->qual
.noise
= 0;
66 wstats
->qual
.updated
= IW_QUAL_ALL_INVALID
;
73 static int prism2_get_datarates(struct net_device
*dev
, u8
*rates
)
75 struct hostap_interface
*iface
;
81 iface
= netdev_priv(dev
);
84 len
= local
->func
->get_rid(dev
, HFA384X_RID_SUPPORTEDDATARATES
, buf
,
89 val
= le16_to_cpu(*(__le16
*) buf
); /* string length */
91 if (len
- 2 < val
|| val
> 10)
94 memcpy(rates
, buf
+ 2, val
);
99 static int prism2_get_name(struct net_device
*dev
,
100 struct iw_request_info
*info
,
101 char *name
, char *extra
)
104 int len
, i
, over2
= 0;
106 len
= prism2_get_datarates(dev
, rates
);
108 for (i
= 0; i
< len
; i
++) {
109 if (rates
[i
] == 0x0b || rates
[i
] == 0x16) {
115 strcpy(name
, over2
? "IEEE 802.11b" : "IEEE 802.11-DS");
121 static int prism2_ioctl_siwencode(struct net_device
*dev
,
122 struct iw_request_info
*info
,
123 struct iw_point
*erq
, char *keybuf
)
125 struct hostap_interface
*iface
;
128 struct lib80211_crypt_data
**crypt
;
130 iface
= netdev_priv(dev
);
131 local
= iface
->local
;
133 i
= erq
->flags
& IW_ENCODE_INDEX
;
135 i
= local
->crypt_info
.tx_keyidx
;
138 if (i
< 0 || i
>= WEP_KEYS
)
141 crypt
= &local
->crypt_info
.crypt
[i
];
143 if (erq
->flags
& IW_ENCODE_DISABLED
) {
145 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
149 if (*crypt
!= NULL
&& (*crypt
)->ops
!= NULL
&&
150 strcmp((*crypt
)->ops
->name
, "WEP") != 0) {
151 /* changing to use WEP; deinit previously used algorithm */
152 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
155 if (*crypt
== NULL
) {
156 struct lib80211_crypt_data
*new_crypt
;
158 /* take WEP into use */
159 new_crypt
= kzalloc(sizeof(struct lib80211_crypt_data
),
161 if (new_crypt
== NULL
)
163 new_crypt
->ops
= lib80211_get_crypto_ops("WEP");
164 if (!new_crypt
->ops
) {
165 request_module("lib80211_crypt_wep");
166 new_crypt
->ops
= lib80211_get_crypto_ops("WEP");
168 if (new_crypt
->ops
&& try_module_get(new_crypt
->ops
->owner
))
169 new_crypt
->priv
= new_crypt
->ops
->init(i
);
170 if (!new_crypt
->ops
|| !new_crypt
->priv
) {
174 printk(KERN_WARNING
"%s: could not initialize WEP: "
175 "load module hostap_crypt_wep.o\n",
182 if (erq
->length
> 0) {
183 int len
= erq
->length
<= 5 ? 5 : 13;
185 if (len
> erq
->length
)
186 memset(keybuf
+ erq
->length
, 0, len
- erq
->length
);
187 (*crypt
)->ops
->set_key(keybuf
, len
, NULL
, (*crypt
)->priv
);
188 for (j
= 0; j
< WEP_KEYS
; j
++) {
189 if (j
!= i
&& local
->crypt_info
.crypt
[j
]) {
195 local
->crypt_info
.tx_keyidx
= i
;
197 /* No key data - just set the default TX key index */
198 local
->crypt_info
.tx_keyidx
= i
;
202 local
->open_wep
= erq
->flags
& IW_ENCODE_OPEN
;
204 if (hostap_set_encryption(local
)) {
205 printk(KERN_DEBUG
"%s: set_encryption failed\n", dev
->name
);
209 /* Do not reset port0 if card is in Managed mode since resetting will
210 * generate new IEEE 802.11 authentication which may end up in looping
211 * with IEEE 802.1X. Prism2 documentation seem to require port reset
212 * after WEP configuration. However, keys are apparently changed at
213 * least in Managed mode. */
214 if (local
->iw_mode
!= IW_MODE_INFRA
&& local
->func
->reset_port(dev
)) {
215 printk(KERN_DEBUG
"%s: reset_port failed\n", dev
->name
);
223 static int prism2_ioctl_giwencode(struct net_device
*dev
,
224 struct iw_request_info
*info
,
225 struct iw_point
*erq
, char *key
)
227 struct hostap_interface
*iface
;
231 struct lib80211_crypt_data
*crypt
;
233 iface
= netdev_priv(dev
);
234 local
= iface
->local
;
236 i
= erq
->flags
& IW_ENCODE_INDEX
;
238 i
= local
->crypt_info
.tx_keyidx
;
241 if (i
< 0 || i
>= WEP_KEYS
)
244 crypt
= local
->crypt_info
.crypt
[i
];
247 if (crypt
== NULL
|| crypt
->ops
== NULL
) {
249 erq
->flags
|= IW_ENCODE_DISABLED
;
253 if (strcmp(crypt
->ops
->name
, "WEP") != 0) {
254 /* only WEP is supported with wireless extensions, so just
255 * report that encryption is used */
257 erq
->flags
|= IW_ENCODE_ENABLED
;
261 /* Reads from HFA384X_RID_CNFDEFAULTKEY* return bogus values, so show
262 * the keys from driver buffer */
263 len
= crypt
->ops
->get_key(key
, WEP_KEY_LEN
, NULL
, crypt
->priv
);
264 erq
->length
= (len
>= 0 ? len
: 0);
266 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFWEPFLAGS
, &val
, 2, 1) < 0)
268 printk("CNFWEPFLAGS reading failed\n");
272 if (val
& HFA384X_WEPFLAGS_PRIVACYINVOKED
)
273 erq
->flags
|= IW_ENCODE_ENABLED
;
275 erq
->flags
|= IW_ENCODE_DISABLED
;
276 if (val
& HFA384X_WEPFLAGS_EXCLUDEUNENCRYPTED
)
277 erq
->flags
|= IW_ENCODE_RESTRICTED
;
279 erq
->flags
|= IW_ENCODE_OPEN
;
285 static int hostap_set_rate(struct net_device
*dev
)
287 struct hostap_interface
*iface
;
289 int ret
, basic_rates
;
291 iface
= netdev_priv(dev
);
292 local
= iface
->local
;
294 basic_rates
= local
->basic_rates
& local
->tx_rate_control
;
295 if (!basic_rates
|| basic_rates
!= local
->basic_rates
) {
296 printk(KERN_INFO
"%s: updating basic rate set automatically "
297 "to match with the new supported rate set\n",
300 basic_rates
= local
->tx_rate_control
;
302 local
->basic_rates
= basic_rates
;
303 if (hostap_set_word(dev
, HFA384X_RID_CNFBASICRATES
,
305 printk(KERN_WARNING
"%s: failed to set "
306 "cnfBasicRates\n", dev
->name
);
309 ret
= (hostap_set_word(dev
, HFA384X_RID_TXRATECONTROL
,
310 local
->tx_rate_control
) ||
311 hostap_set_word(dev
, HFA384X_RID_CNFSUPPORTEDRATES
,
312 local
->tx_rate_control
) ||
313 local
->func
->reset_port(dev
));
316 printk(KERN_WARNING
"%s: TXRateControl/cnfSupportedRates "
317 "setting to 0x%x failed\n",
318 dev
->name
, local
->tx_rate_control
);
321 /* Update TX rate configuration for all STAs based on new operational
323 hostap_update_rates(local
);
329 static int prism2_ioctl_siwrate(struct net_device
*dev
,
330 struct iw_request_info
*info
,
331 struct iw_param
*rrq
, char *extra
)
333 struct hostap_interface
*iface
;
336 iface
= netdev_priv(dev
);
337 local
= iface
->local
;
340 switch (rrq
->value
) {
342 local
->tx_rate_control
= HFA384X_RATES_11MBPS
;
345 local
->tx_rate_control
= HFA384X_RATES_5MBPS
;
348 local
->tx_rate_control
= HFA384X_RATES_2MBPS
;
351 local
->tx_rate_control
= HFA384X_RATES_1MBPS
;
354 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
355 HFA384X_RATES_2MBPS
| HFA384X_RATES_5MBPS
|
356 HFA384X_RATES_11MBPS
;
360 switch (rrq
->value
) {
362 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
363 HFA384X_RATES_2MBPS
| HFA384X_RATES_5MBPS
|
364 HFA384X_RATES_11MBPS
;
367 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
368 HFA384X_RATES_2MBPS
| HFA384X_RATES_5MBPS
;
371 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
375 local
->tx_rate_control
= HFA384X_RATES_1MBPS
;
378 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
379 HFA384X_RATES_2MBPS
| HFA384X_RATES_5MBPS
|
380 HFA384X_RATES_11MBPS
;
385 return hostap_set_rate(dev
);
389 static int prism2_ioctl_giwrate(struct net_device
*dev
,
390 struct iw_request_info
*info
,
391 struct iw_param
*rrq
, char *extra
)
394 struct hostap_interface
*iface
;
398 iface
= netdev_priv(dev
);
399 local
= iface
->local
;
401 if (local
->func
->get_rid(dev
, HFA384X_RID_TXRATECONTROL
, &val
, 2, 1) <
405 if ((val
& 0x1) && (val
> 1))
410 if (local
->iw_mode
== IW_MODE_MASTER
&& local
->ap
!= NULL
&&
411 !local
->fw_tx_rate_control
) {
412 /* HFA384X_RID_CURRENTTXRATE seems to always be 2 Mbps in
413 * Host AP mode, so use the recorded TX rate of the last sent
415 rrq
->value
= local
->ap
->last_tx_rate
> 0 ?
416 local
->ap
->last_tx_rate
* 100000 : 11000000;
420 if (local
->func
->get_rid(dev
, HFA384X_RID_CURRENTTXRATE
, &val
, 2, 1) <
425 case HFA384X_RATES_1MBPS
:
426 rrq
->value
= 1000000;
428 case HFA384X_RATES_2MBPS
:
429 rrq
->value
= 2000000;
431 case HFA384X_RATES_5MBPS
:
432 rrq
->value
= 5500000;
434 case HFA384X_RATES_11MBPS
:
435 rrq
->value
= 11000000;
438 /* should not happen */
439 rrq
->value
= 11000000;
448 static int prism2_ioctl_siwsens(struct net_device
*dev
,
449 struct iw_request_info
*info
,
450 struct iw_param
*sens
, char *extra
)
452 struct hostap_interface
*iface
;
455 iface
= netdev_priv(dev
);
456 local
= iface
->local
;
458 /* Set the desired AP density */
459 if (sens
->value
< 1 || sens
->value
> 3)
462 if (hostap_set_word(dev
, HFA384X_RID_CNFSYSTEMSCALE
, sens
->value
) ||
463 local
->func
->reset_port(dev
))
469 static int prism2_ioctl_giwsens(struct net_device
*dev
,
470 struct iw_request_info
*info
,
471 struct iw_param
*sens
, char *extra
)
473 struct hostap_interface
*iface
;
477 iface
= netdev_priv(dev
);
478 local
= iface
->local
;
480 /* Get the current AP density */
481 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFSYSTEMSCALE
, &val
, 2, 1) <
485 sens
->value
= le16_to_cpu(val
);
492 /* Deprecated in new wireless extension API */
493 static int prism2_ioctl_giwaplist(struct net_device
*dev
,
494 struct iw_request_info
*info
,
495 struct iw_point
*data
, char *extra
)
497 struct hostap_interface
*iface
;
499 struct sockaddr
*addr
;
500 struct iw_quality
*qual
;
502 iface
= netdev_priv(dev
);
503 local
= iface
->local
;
505 if (local
->iw_mode
!= IW_MODE_MASTER
) {
506 printk(KERN_DEBUG
"SIOCGIWAPLIST is currently only supported "
507 "in Host AP mode\n");
512 addr
= kmalloc(sizeof(struct sockaddr
) * IW_MAX_AP
, GFP_KERNEL
);
513 qual
= kmalloc(sizeof(struct iw_quality
) * IW_MAX_AP
, GFP_KERNEL
);
514 if (addr
== NULL
|| qual
== NULL
) {
521 data
->length
= prism2_ap_get_sta_qual(local
, addr
, qual
, IW_MAX_AP
, 1);
523 memcpy(extra
, &addr
, sizeof(struct sockaddr
) * data
->length
);
524 data
->flags
= 1; /* has quality information */
525 memcpy(extra
+ sizeof(struct sockaddr
) * data
->length
, &qual
,
526 sizeof(struct iw_quality
) * data
->length
);
534 static int prism2_ioctl_siwrts(struct net_device
*dev
,
535 struct iw_request_info
*info
,
536 struct iw_param
*rts
, char *extra
)
538 struct hostap_interface
*iface
;
542 iface
= netdev_priv(dev
);
543 local
= iface
->local
;
546 val
= cpu_to_le16(2347);
547 else if (rts
->value
< 0 || rts
->value
> 2347)
550 val
= cpu_to_le16(rts
->value
);
552 if (local
->func
->set_rid(dev
, HFA384X_RID_RTSTHRESHOLD
, &val
, 2) ||
553 local
->func
->reset_port(dev
))
556 local
->rts_threshold
= rts
->value
;
561 static int prism2_ioctl_giwrts(struct net_device
*dev
,
562 struct iw_request_info
*info
,
563 struct iw_param
*rts
, char *extra
)
565 struct hostap_interface
*iface
;
569 iface
= netdev_priv(dev
);
570 local
= iface
->local
;
572 if (local
->func
->get_rid(dev
, HFA384X_RID_RTSTHRESHOLD
, &val
, 2, 1) <
576 rts
->value
= le16_to_cpu(val
);
577 rts
->disabled
= (rts
->value
== 2347);
584 static int prism2_ioctl_siwfrag(struct net_device
*dev
,
585 struct iw_request_info
*info
,
586 struct iw_param
*rts
, char *extra
)
588 struct hostap_interface
*iface
;
592 iface
= netdev_priv(dev
);
593 local
= iface
->local
;
596 val
= cpu_to_le16(2346);
597 else if (rts
->value
< 256 || rts
->value
> 2346)
600 val
= cpu_to_le16(rts
->value
& ~0x1); /* even numbers only */
602 local
->fragm_threshold
= rts
->value
& ~0x1;
603 if (local
->func
->set_rid(dev
, HFA384X_RID_FRAGMENTATIONTHRESHOLD
, &val
,
605 || local
->func
->reset_port(dev
))
611 static int prism2_ioctl_giwfrag(struct net_device
*dev
,
612 struct iw_request_info
*info
,
613 struct iw_param
*rts
, char *extra
)
615 struct hostap_interface
*iface
;
619 iface
= netdev_priv(dev
);
620 local
= iface
->local
;
622 if (local
->func
->get_rid(dev
, HFA384X_RID_FRAGMENTATIONTHRESHOLD
,
626 rts
->value
= le16_to_cpu(val
);
627 rts
->disabled
= (rts
->value
== 2346);
634 #ifndef PRISM2_NO_STATION_MODES
635 static int hostap_join_ap(struct net_device
*dev
)
637 struct hostap_interface
*iface
;
639 struct hfa384x_join_request req
;
642 struct hfa384x_hostscan_result
*entry
;
644 iface
= netdev_priv(dev
);
645 local
= iface
->local
;
647 memcpy(req
.bssid
, local
->preferred_ap
, ETH_ALEN
);
650 spin_lock_irqsave(&local
->lock
, flags
);
651 for (i
= 0; i
< local
->last_scan_results_count
; i
++) {
652 if (!local
->last_scan_results
)
654 entry
= &local
->last_scan_results
[i
];
655 if (memcmp(local
->preferred_ap
, entry
->bssid
, ETH_ALEN
) == 0) {
656 req
.channel
= entry
->chid
;
660 spin_unlock_irqrestore(&local
->lock
, flags
);
662 if (local
->func
->set_rid(dev
, HFA384X_RID_JOINREQUEST
, &req
,
664 printk(KERN_DEBUG
"%s: JoinRequest %pM failed\n",
665 dev
->name
, local
->preferred_ap
);
669 printk(KERN_DEBUG
"%s: Trying to join BSSID %pM\n",
670 dev
->name
, local
->preferred_ap
);
674 #endif /* PRISM2_NO_STATION_MODES */
677 static int prism2_ioctl_siwap(struct net_device
*dev
,
678 struct iw_request_info
*info
,
679 struct sockaddr
*ap_addr
, char *extra
)
681 #ifdef PRISM2_NO_STATION_MODES
683 #else /* PRISM2_NO_STATION_MODES */
684 struct hostap_interface
*iface
;
687 iface
= netdev_priv(dev
);
688 local
= iface
->local
;
690 memcpy(local
->preferred_ap
, &ap_addr
->sa_data
, ETH_ALEN
);
692 if (local
->host_roaming
== 1 && local
->iw_mode
== IW_MODE_INFRA
) {
693 struct hfa384x_scan_request scan_req
;
694 memset(&scan_req
, 0, sizeof(scan_req
));
695 scan_req
.channel_list
= cpu_to_le16(0x3fff);
696 scan_req
.txrate
= cpu_to_le16(HFA384X_RATES_1MBPS
);
697 if (local
->func
->set_rid(dev
, HFA384X_RID_SCANREQUEST
,
698 &scan_req
, sizeof(scan_req
))) {
699 printk(KERN_DEBUG
"%s: ScanResults request failed - "
700 "preferred AP delayed to next unsolicited "
701 "scan\n", dev
->name
);
703 } else if (local
->host_roaming
== 2 &&
704 local
->iw_mode
== IW_MODE_INFRA
) {
705 if (hostap_join_ap(dev
))
708 printk(KERN_DEBUG
"%s: Preferred AP (SIOCSIWAP) is used only "
709 "in Managed mode when host_roaming is enabled\n",
714 #endif /* PRISM2_NO_STATION_MODES */
717 static int prism2_ioctl_giwap(struct net_device
*dev
,
718 struct iw_request_info
*info
,
719 struct sockaddr
*ap_addr
, char *extra
)
721 struct hostap_interface
*iface
;
724 iface
= netdev_priv(dev
);
725 local
= iface
->local
;
727 ap_addr
->sa_family
= ARPHRD_ETHER
;
728 switch (iface
->type
) {
729 case HOSTAP_INTERFACE_AP
:
730 memcpy(&ap_addr
->sa_data
, dev
->dev_addr
, ETH_ALEN
);
732 case HOSTAP_INTERFACE_STA
:
733 memcpy(&ap_addr
->sa_data
, local
->assoc_ap_addr
, ETH_ALEN
);
735 case HOSTAP_INTERFACE_WDS
:
736 memcpy(&ap_addr
->sa_data
, iface
->u
.wds
.remote_addr
, ETH_ALEN
);
739 if (local
->func
->get_rid(dev
, HFA384X_RID_CURRENTBSSID
,
740 &ap_addr
->sa_data
, ETH_ALEN
, 1) < 0)
743 /* local->bssid is also updated in LinkStatus handler when in
745 memcpy(local
->bssid
, &ap_addr
->sa_data
, ETH_ALEN
);
753 static int prism2_ioctl_siwnickn(struct net_device
*dev
,
754 struct iw_request_info
*info
,
755 struct iw_point
*data
, char *nickname
)
757 struct hostap_interface
*iface
;
760 iface
= netdev_priv(dev
);
761 local
= iface
->local
;
763 memset(local
->name
, 0, sizeof(local
->name
));
764 memcpy(local
->name
, nickname
, data
->length
);
767 if (hostap_set_string(dev
, HFA384X_RID_CNFOWNNAME
, local
->name
) ||
768 local
->func
->reset_port(dev
))
774 static int prism2_ioctl_giwnickn(struct net_device
*dev
,
775 struct iw_request_info
*info
,
776 struct iw_point
*data
, char *nickname
)
778 struct hostap_interface
*iface
;
781 char name
[MAX_NAME_LEN
+ 3];
784 iface
= netdev_priv(dev
);
785 local
= iface
->local
;
787 len
= local
->func
->get_rid(dev
, HFA384X_RID_CNFOWNNAME
,
788 &name
, MAX_NAME_LEN
+ 2, 0);
789 val
= le16_to_cpu(*(__le16
*) name
);
790 if (len
> MAX_NAME_LEN
+ 2 || len
< 0 || val
> MAX_NAME_LEN
)
793 name
[val
+ 2] = '\0';
794 data
->length
= val
+ 1;
795 memcpy(nickname
, name
+ 2, val
+ 1);
801 static int prism2_ioctl_siwfreq(struct net_device
*dev
,
802 struct iw_request_info
*info
,
803 struct iw_freq
*freq
, char *extra
)
805 struct hostap_interface
*iface
;
808 iface
= netdev_priv(dev
);
809 local
= iface
->local
;
813 freq
->m
/ 100000 >= freq_list
[0] &&
814 freq
->m
/ 100000 <= freq_list
[FREQ_COUNT
- 1]) {
816 int fr
= freq
->m
/ 100000;
817 for (ch
= 0; ch
< FREQ_COUNT
; ch
++) {
818 if (fr
== freq_list
[ch
]) {
826 if (freq
->e
!= 0 || freq
->m
< 1 || freq
->m
> FREQ_COUNT
||
827 !(local
->channel_mask
& (1 << (freq
->m
- 1))))
830 local
->channel
= freq
->m
; /* channel is used in prism2_setup_rids() */
831 if (hostap_set_word(dev
, HFA384X_RID_CNFOWNCHANNEL
, local
->channel
) ||
832 local
->func
->reset_port(dev
))
838 static int prism2_ioctl_giwfreq(struct net_device
*dev
,
839 struct iw_request_info
*info
,
840 struct iw_freq
*freq
, char *extra
)
842 struct hostap_interface
*iface
;
846 iface
= netdev_priv(dev
);
847 local
= iface
->local
;
849 if (local
->func
->get_rid(dev
, HFA384X_RID_CURRENTCHANNEL
, &val
, 2, 1) <
854 if (val
< 1 || val
> FREQ_COUNT
)
857 freq
->m
= freq_list
[val
- 1] * 100000;
864 static void hostap_monitor_set_type(local_info_t
*local
)
866 struct net_device
*dev
= local
->ddev
;
871 if (local
->monitor_type
== PRISM2_MONITOR_PRISM
||
872 local
->monitor_type
== PRISM2_MONITOR_CAPHDR
) {
873 dev
->type
= ARPHRD_IEEE80211_PRISM
;
874 } else if (local
->monitor_type
== PRISM2_MONITOR_RADIOTAP
) {
875 dev
->type
= ARPHRD_IEEE80211_RADIOTAP
;
877 dev
->type
= ARPHRD_IEEE80211
;
882 static int prism2_ioctl_siwessid(struct net_device
*dev
,
883 struct iw_request_info
*info
,
884 struct iw_point
*data
, char *ssid
)
886 struct hostap_interface
*iface
;
889 iface
= netdev_priv(dev
);
890 local
= iface
->local
;
892 if (iface
->type
== HOSTAP_INTERFACE_WDS
)
895 if (data
->flags
== 0)
896 ssid
[0] = '\0'; /* ANY */
898 if (local
->iw_mode
== IW_MODE_MASTER
&& ssid
[0] == '\0') {
899 /* Setting SSID to empty string seems to kill the card in
901 printk(KERN_DEBUG
"%s: Host AP mode does not support "
902 "'Any' essid\n", dev
->name
);
906 memcpy(local
->essid
, ssid
, data
->length
);
907 local
->essid
[data
->length
] = '\0';
909 if ((!local
->fw_ap
&&
910 hostap_set_string(dev
, HFA384X_RID_CNFDESIREDSSID
, local
->essid
))
911 || hostap_set_string(dev
, HFA384X_RID_CNFOWNSSID
, local
->essid
) ||
912 local
->func
->reset_port(dev
))
918 static int prism2_ioctl_giwessid(struct net_device
*dev
,
919 struct iw_request_info
*info
,
920 struct iw_point
*data
, char *essid
)
922 struct hostap_interface
*iface
;
926 iface
= netdev_priv(dev
);
927 local
= iface
->local
;
929 if (iface
->type
== HOSTAP_INTERFACE_WDS
)
932 data
->flags
= 1; /* active */
933 if (local
->iw_mode
== IW_MODE_MASTER
) {
934 data
->length
= strlen(local
->essid
);
935 memcpy(essid
, local
->essid
, IW_ESSID_MAX_SIZE
);
938 char ssid
[MAX_SSID_LEN
+ 2];
939 memset(ssid
, 0, sizeof(ssid
));
940 len
= local
->func
->get_rid(dev
, HFA384X_RID_CURRENTSSID
,
941 &ssid
, MAX_SSID_LEN
+ 2, 0);
942 val
= le16_to_cpu(*(__le16
*) ssid
);
943 if (len
> MAX_SSID_LEN
+ 2 || len
< 0 || val
> MAX_SSID_LEN
) {
947 memcpy(essid
, ssid
+ 2, IW_ESSID_MAX_SIZE
);
954 static int prism2_ioctl_giwrange(struct net_device
*dev
,
955 struct iw_request_info
*info
,
956 struct iw_point
*data
, char *extra
)
958 struct hostap_interface
*iface
;
960 struct iw_range
*range
= (struct iw_range
*) extra
;
965 iface
= netdev_priv(dev
);
966 local
= iface
->local
;
968 data
->length
= sizeof(struct iw_range
);
969 memset(range
, 0, sizeof(struct iw_range
));
971 /* TODO: could fill num_txpower and txpower array with
972 * something; however, there are 128 different values.. */
974 range
->txpower_capa
= IW_TXPOW_DBM
;
976 if (local
->iw_mode
== IW_MODE_INFRA
|| local
->iw_mode
== IW_MODE_ADHOC
)
978 range
->min_pmp
= 1 * 1024;
979 range
->max_pmp
= 65535 * 1024;
980 range
->min_pmt
= 1 * 1024;
981 range
->max_pmt
= 1000 * 1024;
982 range
->pmp_flags
= IW_POWER_PERIOD
;
983 range
->pmt_flags
= IW_POWER_TIMEOUT
;
984 range
->pm_capa
= IW_POWER_PERIOD
| IW_POWER_TIMEOUT
|
985 IW_POWER_UNICAST_R
| IW_POWER_ALL_R
;
988 range
->we_version_compiled
= WIRELESS_EXT
;
989 range
->we_version_source
= 18;
991 range
->retry_capa
= IW_RETRY_LIMIT
;
992 range
->retry_flags
= IW_RETRY_LIMIT
;
993 range
->min_retry
= 0;
994 range
->max_retry
= 255;
996 range
->num_channels
= FREQ_COUNT
;
999 for (i
= 0; i
< FREQ_COUNT
; i
++) {
1000 if (local
->channel_mask
& (1 << i
)) {
1001 range
->freq
[val
].i
= i
+ 1;
1002 range
->freq
[val
].m
= freq_list
[i
] * 100000;
1003 range
->freq
[val
].e
= 1;
1006 if (val
== IW_MAX_FREQUENCIES
)
1009 range
->num_frequency
= val
;
1011 if (local
->sta_fw_ver
>= PRISM2_FW_VER(1,3,1)) {
1012 range
->max_qual
.qual
= 70; /* what is correct max? This was not
1013 * documented exactly. At least
1014 * 69 has been observed. */
1015 range
->max_qual
.level
= 0; /* dB */
1016 range
->max_qual
.noise
= 0; /* dB */
1018 /* What would be suitable values for "average/typical" qual? */
1019 range
->avg_qual
.qual
= 20;
1020 range
->avg_qual
.level
= -60;
1021 range
->avg_qual
.noise
= -95;
1023 range
->max_qual
.qual
= 92; /* 0 .. 92 */
1024 range
->max_qual
.level
= 154; /* 27 .. 154 */
1025 range
->max_qual
.noise
= 154; /* 27 .. 154 */
1027 range
->sensitivity
= 3;
1029 range
->max_encoding_tokens
= WEP_KEYS
;
1030 range
->num_encoding_sizes
= 2;
1031 range
->encoding_size
[0] = 5;
1032 range
->encoding_size
[1] = 13;
1035 len
= prism2_get_datarates(dev
, rates
);
1036 range
->num_bitrates
= 0;
1037 for (i
= 0; i
< len
; i
++) {
1038 if (range
->num_bitrates
< IW_MAX_BITRATES
) {
1039 range
->bitrate
[range
->num_bitrates
] =
1041 range
->num_bitrates
++;
1043 if (rates
[i
] == 0x0b || rates
[i
] == 0x16)
1046 /* estimated maximum TCP throughput values (bps) */
1047 range
->throughput
= over2
? 5500000 : 1500000;
1050 range
->max_rts
= 2347;
1051 range
->min_frag
= 256;
1052 range
->max_frag
= 2346;
1054 /* Event capability (kernel + driver) */
1055 range
->event_capa
[0] = (IW_EVENT_CAPA_K_0
|
1056 IW_EVENT_CAPA_MASK(SIOCGIWTHRSPY
) |
1057 IW_EVENT_CAPA_MASK(SIOCGIWAP
) |
1058 IW_EVENT_CAPA_MASK(SIOCGIWSCAN
));
1059 range
->event_capa
[1] = IW_EVENT_CAPA_K_1
;
1060 range
->event_capa
[4] = (IW_EVENT_CAPA_MASK(IWEVTXDROP
) |
1061 IW_EVENT_CAPA_MASK(IWEVCUSTOM
) |
1062 IW_EVENT_CAPA_MASK(IWEVREGISTERED
) |
1063 IW_EVENT_CAPA_MASK(IWEVEXPIRED
));
1065 range
->enc_capa
= IW_ENC_CAPA_WPA
| IW_ENC_CAPA_WPA2
|
1066 IW_ENC_CAPA_CIPHER_TKIP
| IW_ENC_CAPA_CIPHER_CCMP
;
1068 if (local
->sta_fw_ver
>= PRISM2_FW_VER(1,3,1))
1069 range
->scan_capa
= IW_SCAN_CAPA_ESSID
;
1075 static int hostap_monitor_mode_enable(local_info_t
*local
)
1077 struct net_device
*dev
= local
->dev
;
1079 printk(KERN_DEBUG
"Enabling monitor mode\n");
1080 hostap_monitor_set_type(local
);
1082 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
1083 HFA384X_PORTTYPE_PSEUDO_IBSS
)) {
1084 printk(KERN_DEBUG
"Port type setting for monitor mode "
1089 /* Host decrypt is needed to get the IV and ICV fields;
1090 * however, monitor mode seems to remove WEP flag from frame
1092 if (hostap_set_word(dev
, HFA384X_RID_CNFWEPFLAGS
,
1093 HFA384X_WEPFLAGS_HOSTENCRYPT
|
1094 HFA384X_WEPFLAGS_HOSTDECRYPT
)) {
1095 printk(KERN_DEBUG
"WEP flags setting failed\n");
1099 if (local
->func
->reset_port(dev
) ||
1100 local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
1101 (HFA384X_TEST_MONITOR
<< 8),
1103 printk(KERN_DEBUG
"Setting monitor mode failed\n");
1111 static int hostap_monitor_mode_disable(local_info_t
*local
)
1113 struct net_device
*dev
= local
->ddev
;
1118 printk(KERN_DEBUG
"%s: Disabling monitor mode\n", dev
->name
);
1119 dev
->type
= ARPHRD_ETHER
;
1121 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
1122 (HFA384X_TEST_STOP
<< 8),
1125 return hostap_set_encryption(local
);
1129 static int prism2_ioctl_siwmode(struct net_device
*dev
,
1130 struct iw_request_info
*info
,
1131 __u32
*mode
, char *extra
)
1133 struct hostap_interface
*iface
;
1134 local_info_t
*local
;
1135 int double_reset
= 0;
1137 iface
= netdev_priv(dev
);
1138 local
= iface
->local
;
1140 if (*mode
!= IW_MODE_ADHOC
&& *mode
!= IW_MODE_INFRA
&&
1141 *mode
!= IW_MODE_MASTER
&& *mode
!= IW_MODE_REPEAT
&&
1142 *mode
!= IW_MODE_MONITOR
)
1145 #ifdef PRISM2_NO_STATION_MODES
1146 if (*mode
== IW_MODE_ADHOC
|| *mode
== IW_MODE_INFRA
)
1148 #endif /* PRISM2_NO_STATION_MODES */
1150 if (*mode
== local
->iw_mode
)
1153 if (*mode
== IW_MODE_MASTER
&& local
->essid
[0] == '\0') {
1154 printk(KERN_WARNING
"%s: empty SSID not allowed in Master "
1155 "mode\n", dev
->name
);
1159 if (local
->iw_mode
== IW_MODE_MONITOR
)
1160 hostap_monitor_mode_disable(local
);
1162 if ((local
->iw_mode
== IW_MODE_ADHOC
||
1163 local
->iw_mode
== IW_MODE_MONITOR
) && *mode
== IW_MODE_MASTER
) {
1164 /* There seems to be a firmware bug in at least STA f/w v1.5.6
1165 * that leaves beacon frames to use IBSS type when moving from
1166 * IBSS to Host AP mode. Doing double Port0 reset seems to be
1167 * enough to workaround this. */
1171 printk(KERN_DEBUG
"prism2: %s: operating mode changed "
1172 "%d -> %d\n", dev
->name
, local
->iw_mode
, *mode
);
1173 local
->iw_mode
= *mode
;
1175 if (local
->iw_mode
== IW_MODE_MONITOR
)
1176 hostap_monitor_mode_enable(local
);
1177 else if (local
->iw_mode
== IW_MODE_MASTER
&& !local
->host_encrypt
&&
1178 !local
->fw_encrypt_ok
) {
1179 printk(KERN_DEBUG
"%s: defaulting to host-based encryption as "
1180 "a workaround for firmware bug in Host AP mode WEP\n",
1182 local
->host_encrypt
= 1;
1185 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
1186 hostap_get_porttype(local
)))
1189 if (local
->func
->reset_port(dev
))
1191 if (double_reset
&& local
->func
->reset_port(dev
))
1194 if (local
->iw_mode
!= IW_MODE_INFRA
&& local
->iw_mode
!= IW_MODE_ADHOC
)
1196 /* netif_carrier is used only in client modes for now, so make
1197 * sure carrier is on when moving to non-client modes. */
1198 netif_carrier_on(local
->dev
);
1199 netif_carrier_on(local
->ddev
);
1205 static int prism2_ioctl_giwmode(struct net_device
*dev
,
1206 struct iw_request_info
*info
,
1207 __u32
*mode
, char *extra
)
1209 struct hostap_interface
*iface
;
1210 local_info_t
*local
;
1212 iface
= netdev_priv(dev
);
1213 local
= iface
->local
;
1215 switch (iface
->type
) {
1216 case HOSTAP_INTERFACE_STA
:
1217 *mode
= IW_MODE_INFRA
;
1219 case HOSTAP_INTERFACE_WDS
:
1220 *mode
= IW_MODE_REPEAT
;
1223 *mode
= local
->iw_mode
;
1230 static int prism2_ioctl_siwpower(struct net_device
*dev
,
1231 struct iw_request_info
*info
,
1232 struct iw_param
*wrq
, char *extra
)
1234 #ifdef PRISM2_NO_STATION_MODES
1236 #else /* PRISM2_NO_STATION_MODES */
1240 return hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 0);
1242 switch (wrq
->flags
& IW_POWER_MODE
) {
1243 case IW_POWER_UNICAST_R
:
1244 ret
= hostap_set_word(dev
, HFA384X_RID_CNFMULTICASTRECEIVE
, 0);
1247 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 1);
1251 case IW_POWER_ALL_R
:
1252 ret
= hostap_set_word(dev
, HFA384X_RID_CNFMULTICASTRECEIVE
, 1);
1255 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 1);
1265 if (wrq
->flags
& IW_POWER_TIMEOUT
) {
1266 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 1);
1269 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMHOLDOVERDURATION
,
1274 if (wrq
->flags
& IW_POWER_PERIOD
) {
1275 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 1);
1278 ret
= hostap_set_word(dev
, HFA384X_RID_CNFMAXSLEEPDURATION
,
1285 #endif /* PRISM2_NO_STATION_MODES */
1289 static int prism2_ioctl_giwpower(struct net_device
*dev
,
1290 struct iw_request_info
*info
,
1291 struct iw_param
*rrq
, char *extra
)
1293 #ifdef PRISM2_NO_STATION_MODES
1295 #else /* PRISM2_NO_STATION_MODES */
1296 struct hostap_interface
*iface
;
1297 local_info_t
*local
;
1298 __le16 enable
, mcast
;
1300 iface
= netdev_priv(dev
);
1301 local
= iface
->local
;
1303 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFPMENABLED
, &enable
, 2, 1)
1307 if (!le16_to_cpu(enable
)) {
1314 if ((rrq
->flags
& IW_POWER_TYPE
) == IW_POWER_TIMEOUT
) {
1316 if (local
->func
->get_rid(dev
,
1317 HFA384X_RID_CNFPMHOLDOVERDURATION
,
1318 &timeout
, 2, 1) < 0)
1321 rrq
->flags
= IW_POWER_TIMEOUT
;
1322 rrq
->value
= le16_to_cpu(timeout
) * 1024;
1325 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFMAXSLEEPDURATION
,
1329 rrq
->flags
= IW_POWER_PERIOD
;
1330 rrq
->value
= le16_to_cpu(period
) * 1024;
1333 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFMULTICASTRECEIVE
, &mcast
,
1337 if (le16_to_cpu(mcast
))
1338 rrq
->flags
|= IW_POWER_ALL_R
;
1340 rrq
->flags
|= IW_POWER_UNICAST_R
;
1343 #endif /* PRISM2_NO_STATION_MODES */
1347 static int prism2_ioctl_siwretry(struct net_device
*dev
,
1348 struct iw_request_info
*info
,
1349 struct iw_param
*rrq
, char *extra
)
1351 struct hostap_interface
*iface
;
1352 local_info_t
*local
;
1354 iface
= netdev_priv(dev
);
1355 local
= iface
->local
;
1360 /* setting retry limits is not supported with the current station
1361 * firmware code; simulate this with alternative retry count for now */
1362 if (rrq
->flags
== IW_RETRY_LIMIT
) {
1363 if (rrq
->value
< 0) {
1364 /* disable manual retry count setting and use firmware
1366 local
->manual_retry_count
= -1;
1367 local
->tx_control
&= ~HFA384X_TX_CTRL_ALT_RTRY
;
1369 if (hostap_set_word(dev
, HFA384X_RID_CNFALTRETRYCOUNT
,
1371 printk(KERN_DEBUG
"%s: Alternate retry count "
1372 "setting to %d failed\n",
1373 dev
->name
, rrq
->value
);
1377 local
->manual_retry_count
= rrq
->value
;
1378 local
->tx_control
|= HFA384X_TX_CTRL_ALT_RTRY
;
1386 /* what could be done, if firmware would support this.. */
1388 if (rrq
->flags
& IW_RETRY_LIMIT
) {
1389 if (rrq
->flags
& IW_RETRY_LONG
)
1390 HFA384X_RID_LONGRETRYLIMIT
= rrq
->value
;
1391 else if (rrq
->flags
& IW_RETRY_SHORT
)
1392 HFA384X_RID_SHORTRETRYLIMIT
= rrq
->value
;
1394 HFA384X_RID_LONGRETRYLIMIT
= rrq
->value
;
1395 HFA384X_RID_SHORTRETRYLIMIT
= rrq
->value
;
1400 if (rrq
->flags
& IW_RETRY_LIFETIME
) {
1401 HFA384X_RID_MAXTRANSMITLIFETIME
= rrq
->value
/ 1024;
1408 static int prism2_ioctl_giwretry(struct net_device
*dev
,
1409 struct iw_request_info
*info
,
1410 struct iw_param
*rrq
, char *extra
)
1412 struct hostap_interface
*iface
;
1413 local_info_t
*local
;
1414 __le16 shortretry
, longretry
, lifetime
, altretry
;
1416 iface
= netdev_priv(dev
);
1417 local
= iface
->local
;
1419 if (local
->func
->get_rid(dev
, HFA384X_RID_SHORTRETRYLIMIT
, &shortretry
,
1421 local
->func
->get_rid(dev
, HFA384X_RID_LONGRETRYLIMIT
, &longretry
,
1423 local
->func
->get_rid(dev
, HFA384X_RID_MAXTRANSMITLIFETIME
,
1424 &lifetime
, 2, 1) < 0)
1429 if ((rrq
->flags
& IW_RETRY_TYPE
) == IW_RETRY_LIFETIME
) {
1430 rrq
->flags
= IW_RETRY_LIFETIME
;
1431 rrq
->value
= le16_to_cpu(lifetime
) * 1024;
1433 if (local
->manual_retry_count
>= 0) {
1434 rrq
->flags
= IW_RETRY_LIMIT
;
1435 if (local
->func
->get_rid(dev
,
1436 HFA384X_RID_CNFALTRETRYCOUNT
,
1437 &altretry
, 2, 1) >= 0)
1438 rrq
->value
= le16_to_cpu(altretry
);
1440 rrq
->value
= local
->manual_retry_count
;
1441 } else if ((rrq
->flags
& IW_RETRY_LONG
)) {
1442 rrq
->flags
= IW_RETRY_LIMIT
| IW_RETRY_LONG
;
1443 rrq
->value
= le16_to_cpu(longretry
);
1445 rrq
->flags
= IW_RETRY_LIMIT
;
1446 rrq
->value
= le16_to_cpu(shortretry
);
1447 if (shortretry
!= longretry
)
1448 rrq
->flags
|= IW_RETRY_SHORT
;
1455 /* Note! This TX power controlling is experimental and should not be used in
1456 * production use. It just sets raw power register and does not use any kind of
1457 * feedback information from the measured TX power (CR58). This is now
1458 * commented out to make sure that it is not used by accident. TX power
1459 * configuration will be enabled again after proper algorithm using feedback
1460 * has been implemented. */
1462 #ifdef RAW_TXPOWER_SETTING
1463 /* Map HFA386x's CR31 to and from dBm with some sort of ad hoc mapping..
1464 * This version assumes following mapping:
1465 * CR31 is 7-bit value with -64 to +63 range.
1466 * -64 is mapped into +20dBm and +63 into -43dBm.
1467 * This is certainly not an exact mapping for every card, but at least
1468 * increasing dBm value should correspond to increasing TX power.
1471 static int prism2_txpower_hfa386x_to_dBm(u16 val
)
1484 static u16
prism2_txpower_dBm_to_hfa386x(int val
)
1497 return (unsigned char) tmp
;
1499 #endif /* RAW_TXPOWER_SETTING */
1502 static int prism2_ioctl_siwtxpow(struct net_device
*dev
,
1503 struct iw_request_info
*info
,
1504 struct iw_param
*rrq
, char *extra
)
1506 struct hostap_interface
*iface
;
1507 local_info_t
*local
;
1508 #ifdef RAW_TXPOWER_SETTING
1514 iface
= netdev_priv(dev
);
1515 local
= iface
->local
;
1517 if (rrq
->disabled
) {
1518 if (local
->txpower_type
!= PRISM2_TXPOWER_OFF
) {
1519 val
= 0xff; /* use all standby and sleep modes */
1520 ret
= local
->func
->cmd(dev
, HFA384X_CMDCODE_WRITEMIF
,
1521 HFA386X_CR_A_D_TEST_MODES2
,
1523 printk(KERN_DEBUG
"%s: Turning radio off: %s\n",
1524 dev
->name
, ret
? "failed" : "OK");
1525 local
->txpower_type
= PRISM2_TXPOWER_OFF
;
1527 return (ret
? -EOPNOTSUPP
: 0);
1530 if (local
->txpower_type
== PRISM2_TXPOWER_OFF
) {
1531 val
= 0; /* disable all standby and sleep modes */
1532 ret
= local
->func
->cmd(dev
, HFA384X_CMDCODE_WRITEMIF
,
1533 HFA386X_CR_A_D_TEST_MODES2
, &val
, NULL
);
1534 printk(KERN_DEBUG
"%s: Turning radio on: %s\n",
1535 dev
->name
, ret
? "failed" : "OK");
1536 local
->txpower_type
= PRISM2_TXPOWER_UNKNOWN
;
1539 #ifdef RAW_TXPOWER_SETTING
1540 if (!rrq
->fixed
&& local
->txpower_type
!= PRISM2_TXPOWER_AUTO
) {
1541 printk(KERN_DEBUG
"Setting ALC on\n");
1542 val
= HFA384X_TEST_CFG_BIT_ALC
;
1543 local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
1544 (HFA384X_TEST_CFG_BITS
<< 8), 1, &val
, NULL
);
1545 local
->txpower_type
= PRISM2_TXPOWER_AUTO
;
1549 if (local
->txpower_type
!= PRISM2_TXPOWER_FIXED
) {
1550 printk(KERN_DEBUG
"Setting ALC off\n");
1551 val
= HFA384X_TEST_CFG_BIT_ALC
;
1552 local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
1553 (HFA384X_TEST_CFG_BITS
<< 8), 0, &val
, NULL
);
1554 local
->txpower_type
= PRISM2_TXPOWER_FIXED
;
1557 if (rrq
->flags
== IW_TXPOW_DBM
)
1559 else if (rrq
->flags
== IW_TXPOW_MWATT
)
1563 printk(KERN_DEBUG
"Setting TX power to %d %s\n", rrq
->value
, tmp
);
1565 if (rrq
->flags
!= IW_TXPOW_DBM
) {
1566 printk("SIOCSIWTXPOW with mW is not supported; use dBm\n");
1570 local
->txpower
= rrq
->value
;
1571 val
= prism2_txpower_dBm_to_hfa386x(local
->txpower
);
1572 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_WRITEMIF
,
1573 HFA386X_CR_MANUAL_TX_POWER
, &val
, NULL
))
1575 #else /* RAW_TXPOWER_SETTING */
1578 #endif /* RAW_TXPOWER_SETTING */
1583 static int prism2_ioctl_giwtxpow(struct net_device
*dev
,
1584 struct iw_request_info
*info
,
1585 struct iw_param
*rrq
, char *extra
)
1587 #ifdef RAW_TXPOWER_SETTING
1588 struct hostap_interface
*iface
;
1589 local_info_t
*local
;
1592 iface
= netdev_priv(dev
);
1593 local
= iface
->local
;
1595 rrq
->flags
= IW_TXPOW_DBM
;
1599 if (local
->txpower_type
== PRISM2_TXPOWER_AUTO
) {
1600 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_READMIF
,
1601 HFA386X_CR_MANUAL_TX_POWER
,
1602 NULL
, &resp0
) == 0) {
1603 rrq
->value
= prism2_txpower_hfa386x_to_dBm(resp0
);
1605 /* Could not get real txpower; guess 15 dBm */
1608 } else if (local
->txpower_type
== PRISM2_TXPOWER_OFF
) {
1611 } else if (local
->txpower_type
== PRISM2_TXPOWER_FIXED
) {
1612 rrq
->value
= local
->txpower
;
1615 printk("SIOCGIWTXPOW - unknown txpower_type=%d\n",
1616 local
->txpower_type
);
1619 #else /* RAW_TXPOWER_SETTING */
1621 #endif /* RAW_TXPOWER_SETTING */
1625 #ifndef PRISM2_NO_STATION_MODES
1627 /* HostScan request works with and without host_roaming mode. In addition, it
1628 * does not break current association. However, it requires newer station
1629 * firmware version (>= 1.3.1) than scan request. */
1630 static int prism2_request_hostscan(struct net_device
*dev
,
1631 u8
*ssid
, u8 ssid_len
)
1633 struct hostap_interface
*iface
;
1634 local_info_t
*local
;
1635 struct hfa384x_hostscan_request scan_req
;
1637 iface
= netdev_priv(dev
);
1638 local
= iface
->local
;
1640 memset(&scan_req
, 0, sizeof(scan_req
));
1641 scan_req
.channel_list
= cpu_to_le16(local
->channel_mask
&
1642 local
->scan_channel_mask
);
1643 scan_req
.txrate
= cpu_to_le16(HFA384X_RATES_1MBPS
);
1647 scan_req
.target_ssid_len
= cpu_to_le16(ssid_len
);
1648 memcpy(scan_req
.target_ssid
, ssid
, ssid_len
);
1651 if (local
->func
->set_rid(dev
, HFA384X_RID_HOSTSCAN
, &scan_req
,
1652 sizeof(scan_req
))) {
1653 printk(KERN_DEBUG
"%s: HOSTSCAN failed\n", dev
->name
);
1660 static int prism2_request_scan(struct net_device
*dev
)
1662 struct hostap_interface
*iface
;
1663 local_info_t
*local
;
1664 struct hfa384x_scan_request scan_req
;
1667 iface
= netdev_priv(dev
);
1668 local
= iface
->local
;
1670 memset(&scan_req
, 0, sizeof(scan_req
));
1671 scan_req
.channel_list
= cpu_to_le16(local
->channel_mask
&
1672 local
->scan_channel_mask
);
1673 scan_req
.txrate
= cpu_to_le16(HFA384X_RATES_1MBPS
);
1676 * It seems to be enough to set roaming mode for a short moment to
1677 * host-based and then setup scanrequest data and return the mode to
1680 * Master mode would need to drop to Managed mode for a short while
1681 * to make scanning work.. Or sweep through the different channels and
1682 * use passive scan based on beacons. */
1684 if (!local
->host_roaming
)
1685 hostap_set_word(dev
, HFA384X_RID_CNFROAMINGMODE
,
1686 HFA384X_ROAMING_HOST
);
1688 if (local
->func
->set_rid(dev
, HFA384X_RID_SCANREQUEST
, &scan_req
,
1689 sizeof(scan_req
))) {
1690 printk(KERN_DEBUG
"SCANREQUEST failed\n");
1694 if (!local
->host_roaming
)
1695 hostap_set_word(dev
, HFA384X_RID_CNFROAMINGMODE
,
1696 HFA384X_ROAMING_FIRMWARE
);
1701 #else /* !PRISM2_NO_STATION_MODES */
1703 static inline int prism2_request_hostscan(struct net_device
*dev
,
1704 u8
*ssid
, u8 ssid_len
)
1710 static inline int prism2_request_scan(struct net_device
*dev
)
1715 #endif /* !PRISM2_NO_STATION_MODES */
1718 static int prism2_ioctl_siwscan(struct net_device
*dev
,
1719 struct iw_request_info
*info
,
1720 struct iw_point
*data
, char *extra
)
1722 struct hostap_interface
*iface
;
1723 local_info_t
*local
;
1725 u8
*ssid
= NULL
, ssid_len
= 0;
1726 struct iw_scan_req
*req
= (struct iw_scan_req
*) extra
;
1728 iface
= netdev_priv(dev
);
1729 local
= iface
->local
;
1731 if (data
->length
< sizeof(struct iw_scan_req
))
1734 if (local
->iw_mode
== IW_MODE_MASTER
) {
1735 /* In master mode, we just return the results of our local
1736 * tables, so we don't need to start anything...
1742 if (!local
->dev_enabled
)
1745 if (req
&& data
->flags
& IW_SCAN_THIS_ESSID
) {
1747 ssid_len
= req
->essid_len
;
1750 ((local
->iw_mode
!= IW_MODE_INFRA
&&
1751 local
->iw_mode
!= IW_MODE_ADHOC
) ||
1752 (local
->sta_fw_ver
< PRISM2_FW_VER(1,3,1))))
1756 if (local
->sta_fw_ver
>= PRISM2_FW_VER(1,3,1))
1757 ret
= prism2_request_hostscan(dev
, ssid
, ssid_len
);
1759 ret
= prism2_request_scan(dev
);
1762 local
->scan_timestamp
= jiffies
;
1764 /* Could inquire F101, F103 or wait for SIOCGIWSCAN and read RID */
1770 #ifndef PRISM2_NO_STATION_MODES
1771 static char * __prism2_translate_scan(local_info_t
*local
,
1772 struct iw_request_info
*info
,
1773 struct hfa384x_hostscan_result
*scan
,
1774 struct hostap_bss_info
*bss
,
1775 char *current_ev
, char *end_buf
)
1778 struct iw_event iwe
;
1788 ssid_len
= bss
->ssid_len
;
1792 ssid_len
= le16_to_cpu(scan
->ssid_len
);
1793 bssid
= scan
->bssid
;
1798 /* First entry *MUST* be the AP MAC address */
1799 memset(&iwe
, 0, sizeof(iwe
));
1800 iwe
.cmd
= SIOCGIWAP
;
1801 iwe
.u
.ap_addr
.sa_family
= ARPHRD_ETHER
;
1802 memcpy(iwe
.u
.ap_addr
.sa_data
, bssid
, ETH_ALEN
);
1803 current_ev
= iwe_stream_add_event(info
, current_ev
, end_buf
, &iwe
,
1806 /* Other entries will be displayed in the order we give them */
1808 memset(&iwe
, 0, sizeof(iwe
));
1809 iwe
.cmd
= SIOCGIWESSID
;
1810 iwe
.u
.data
.length
= ssid_len
;
1811 iwe
.u
.data
.flags
= 1;
1812 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1815 memset(&iwe
, 0, sizeof(iwe
));
1816 iwe
.cmd
= SIOCGIWMODE
;
1818 capabilities
= bss
->capab_info
;
1820 capabilities
= le16_to_cpu(scan
->capability
);
1822 if (capabilities
& (WLAN_CAPABILITY_ESS
|
1823 WLAN_CAPABILITY_IBSS
)) {
1824 if (capabilities
& WLAN_CAPABILITY_ESS
)
1825 iwe
.u
.mode
= IW_MODE_MASTER
;
1827 iwe
.u
.mode
= IW_MODE_ADHOC
;
1828 current_ev
= iwe_stream_add_event(info
, current_ev
, end_buf
,
1829 &iwe
, IW_EV_UINT_LEN
);
1832 memset(&iwe
, 0, sizeof(iwe
));
1833 iwe
.cmd
= SIOCGIWFREQ
;
1835 chan
= le16_to_cpu(scan
->chid
);
1843 iwe
.u
.freq
.m
= freq_list
[chan
- 1] * 100000;
1845 current_ev
= iwe_stream_add_event(info
, current_ev
, end_buf
,
1846 &iwe
, IW_EV_FREQ_LEN
);
1850 memset(&iwe
, 0, sizeof(iwe
));
1852 if (local
->last_scan_type
== PRISM2_HOSTSCAN
) {
1853 iwe
.u
.qual
.level
= le16_to_cpu(scan
->sl
);
1854 iwe
.u
.qual
.noise
= le16_to_cpu(scan
->anl
);
1857 HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan
->sl
));
1859 HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan
->anl
));
1861 iwe
.u
.qual
.updated
= IW_QUAL_LEVEL_UPDATED
1862 | IW_QUAL_NOISE_UPDATED
1863 | IW_QUAL_QUAL_INVALID
1865 current_ev
= iwe_stream_add_event(info
, current_ev
, end_buf
,
1866 &iwe
, IW_EV_QUAL_LEN
);
1869 memset(&iwe
, 0, sizeof(iwe
));
1870 iwe
.cmd
= SIOCGIWENCODE
;
1871 if (capabilities
& WLAN_CAPABILITY_PRIVACY
)
1872 iwe
.u
.data
.flags
= IW_ENCODE_ENABLED
| IW_ENCODE_NOKEY
;
1874 iwe
.u
.data
.flags
= IW_ENCODE_DISABLED
;
1875 iwe
.u
.data
.length
= 0;
1876 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
, &iwe
, "");
1878 /* TODO: add SuppRates into BSS table */
1880 memset(&iwe
, 0, sizeof(iwe
));
1881 iwe
.cmd
= SIOCGIWRATE
;
1882 current_val
= current_ev
+ iwe_stream_lcp_len(info
);
1883 pos
= scan
->sup_rates
;
1884 for (i
= 0; i
< sizeof(scan
->sup_rates
); i
++) {
1887 /* Bit rate given in 500 kb/s units (+ 0x80) */
1888 iwe
.u
.bitrate
.value
= ((pos
[i
] & 0x7f) * 500000);
1889 current_val
= iwe_stream_add_value(
1890 info
, current_ev
, current_val
, end_buf
, &iwe
,
1893 /* Check if we added any event */
1894 if ((current_val
- current_ev
) > iwe_stream_lcp_len(info
))
1895 current_ev
= current_val
;
1898 /* TODO: add BeaconInt,resp_rate,atim into BSS table */
1899 buf
= kmalloc(MAX_WPA_IE_LEN
* 2 + 30, GFP_ATOMIC
);
1901 memset(&iwe
, 0, sizeof(iwe
));
1902 iwe
.cmd
= IWEVCUSTOM
;
1903 sprintf(buf
, "bcn_int=%d", le16_to_cpu(scan
->beacon_interval
));
1904 iwe
.u
.data
.length
= strlen(buf
);
1905 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1908 memset(&iwe
, 0, sizeof(iwe
));
1909 iwe
.cmd
= IWEVCUSTOM
;
1910 sprintf(buf
, "resp_rate=%d", le16_to_cpu(scan
->rate
));
1911 iwe
.u
.data
.length
= strlen(buf
);
1912 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1915 if (local
->last_scan_type
== PRISM2_HOSTSCAN
&&
1916 (capabilities
& WLAN_CAPABILITY_IBSS
)) {
1917 memset(&iwe
, 0, sizeof(iwe
));
1918 iwe
.cmd
= IWEVCUSTOM
;
1919 sprintf(buf
, "atim=%d", le16_to_cpu(scan
->atim
));
1920 iwe
.u
.data
.length
= strlen(buf
);
1921 current_ev
= iwe_stream_add_point(info
, current_ev
,
1922 end_buf
, &iwe
, buf
);
1927 if (bss
&& bss
->wpa_ie_len
> 0 && bss
->wpa_ie_len
<= MAX_WPA_IE_LEN
) {
1928 memset(&iwe
, 0, sizeof(iwe
));
1929 iwe
.cmd
= IWEVGENIE
;
1930 iwe
.u
.data
.length
= bss
->wpa_ie_len
;
1931 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1935 if (bss
&& bss
->rsn_ie_len
> 0 && bss
->rsn_ie_len
<= MAX_WPA_IE_LEN
) {
1936 memset(&iwe
, 0, sizeof(iwe
));
1937 iwe
.cmd
= IWEVGENIE
;
1938 iwe
.u
.data
.length
= bss
->rsn_ie_len
;
1939 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1947 /* Translate scan data returned from the card to a card independant
1948 * format that the Wireless Tools will understand - Jean II */
1949 static inline int prism2_translate_scan(local_info_t
*local
,
1950 struct iw_request_info
*info
,
1951 char *buffer
, int buflen
)
1953 struct hfa384x_hostscan_result
*scan
;
1954 int entry
, hostscan
;
1955 char *current_ev
= buffer
;
1956 char *end_buf
= buffer
+ buflen
;
1957 struct list_head
*ptr
;
1959 spin_lock_bh(&local
->lock
);
1961 list_for_each(ptr
, &local
->bss_list
) {
1962 struct hostap_bss_info
*bss
;
1963 bss
= list_entry(ptr
, struct hostap_bss_info
, list
);
1967 hostscan
= local
->last_scan_type
== PRISM2_HOSTSCAN
;
1968 for (entry
= 0; entry
< local
->last_scan_results_count
; entry
++) {
1970 scan
= &local
->last_scan_results
[entry
];
1972 /* Report every SSID if the AP is using multiple SSIDs. If no
1973 * BSS record is found (e.g., when WPA mode is disabled),
1974 * report the AP once. */
1975 list_for_each(ptr
, &local
->bss_list
) {
1976 struct hostap_bss_info
*bss
;
1977 bss
= list_entry(ptr
, struct hostap_bss_info
, list
);
1978 if (memcmp(bss
->bssid
, scan
->bssid
, ETH_ALEN
) == 0) {
1980 current_ev
= __prism2_translate_scan(
1981 local
, info
, scan
, bss
, current_ev
,
1987 current_ev
= __prism2_translate_scan(
1988 local
, info
, scan
, NULL
, current_ev
, end_buf
);
1990 /* Check if there is space for one more entry */
1991 if ((end_buf
- current_ev
) <= IW_EV_ADDR_LEN
) {
1992 /* Ask user space to try again with a bigger buffer */
1993 spin_unlock_bh(&local
->lock
);
1998 /* Prism2 firmware has limits (32 at least in some versions) for number
1999 * of BSSes in scan results. Extend this limit by using local BSS list.
2001 list_for_each(ptr
, &local
->bss_list
) {
2002 struct hostap_bss_info
*bss
;
2003 bss
= list_entry(ptr
, struct hostap_bss_info
, list
);
2006 current_ev
= __prism2_translate_scan(local
, info
, NULL
, bss
,
2007 current_ev
, end_buf
);
2008 /* Check if there is space for one more entry */
2009 if ((end_buf
- current_ev
) <= IW_EV_ADDR_LEN
) {
2010 /* Ask user space to try again with a bigger buffer */
2011 spin_unlock_bh(&local
->lock
);
2016 spin_unlock_bh(&local
->lock
);
2018 return current_ev
- buffer
;
2020 #endif /* PRISM2_NO_STATION_MODES */
2023 static inline int prism2_ioctl_giwscan_sta(struct net_device
*dev
,
2024 struct iw_request_info
*info
,
2025 struct iw_point
*data
, char *extra
)
2027 #ifdef PRISM2_NO_STATION_MODES
2029 #else /* PRISM2_NO_STATION_MODES */
2030 struct hostap_interface
*iface
;
2031 local_info_t
*local
;
2034 iface
= netdev_priv(dev
);
2035 local
= iface
->local
;
2037 /* Wait until the scan is finished. We can probably do better
2038 * than that - Jean II */
2039 if (local
->scan_timestamp
&&
2040 time_before(jiffies
, local
->scan_timestamp
+ 3 * HZ
)) {
2041 /* Important note : we don't want to block the caller
2042 * until results are ready for various reasons.
2043 * First, managing wait queues is complex and racy
2044 * (there may be multiple simultaneous callers).
2045 * Second, we grab some rtnetlink lock before comming
2046 * here (in dev_ioctl()).
2047 * Third, the caller can wait on the Wireless Event
2051 local
->scan_timestamp
= 0;
2053 res
= prism2_translate_scan(local
, info
, extra
, data
->length
);
2062 #endif /* PRISM2_NO_STATION_MODES */
2066 static int prism2_ioctl_giwscan(struct net_device
*dev
,
2067 struct iw_request_info
*info
,
2068 struct iw_point
*data
, char *extra
)
2070 struct hostap_interface
*iface
;
2071 local_info_t
*local
;
2074 iface
= netdev_priv(dev
);
2075 local
= iface
->local
;
2077 if (local
->iw_mode
== IW_MODE_MASTER
) {
2078 /* In MASTER mode, it doesn't make sense to go around
2079 * scanning the frequencies and make the stations we serve
2080 * wait when what the user is really interested about is the
2081 * list of stations and access points we are talking to.
2082 * So, just extract results from our cache...
2085 /* Translate to WE format */
2086 res
= prism2_ap_translate_scan(dev
, info
, extra
);
2088 printk(KERN_DEBUG
"Scan result translation succeeded "
2089 "(length=%d)\n", res
);
2094 "Scan result translation failed (res=%d)\n",
2101 return prism2_ioctl_giwscan_sta(dev
, info
, data
, extra
);
2106 static const struct iw_priv_args prism2_priv
[] = {
2107 { PRISM2_IOCTL_MONITOR
,
2108 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "monitor" },
2109 { PRISM2_IOCTL_READMIF
,
2110 IW_PRIV_TYPE_BYTE
| IW_PRIV_SIZE_FIXED
| 1,
2111 IW_PRIV_TYPE_BYTE
| IW_PRIV_SIZE_FIXED
| 1, "readmif" },
2112 { PRISM2_IOCTL_WRITEMIF
,
2113 IW_PRIV_TYPE_BYTE
| IW_PRIV_SIZE_FIXED
| 2, 0, "writemif" },
2114 { PRISM2_IOCTL_RESET
,
2115 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "reset" },
2116 { PRISM2_IOCTL_INQUIRE
,
2117 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "inquire" },
2118 { PRISM2_IOCTL_SET_RID_WORD
,
2119 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 2, 0, "set_rid_word" },
2120 { PRISM2_IOCTL_MACCMD
,
2121 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "maccmd" },
2122 { PRISM2_IOCTL_WDS_ADD
,
2123 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "wds_add" },
2124 { PRISM2_IOCTL_WDS_DEL
,
2125 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "wds_del" },
2126 { PRISM2_IOCTL_ADDMAC
,
2127 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "addmac" },
2128 { PRISM2_IOCTL_DELMAC
,
2129 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "delmac" },
2130 { PRISM2_IOCTL_KICKMAC
,
2131 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "kickmac" },
2132 /* --- raw access to sub-ioctls --- */
2133 { PRISM2_IOCTL_PRISM2_PARAM
,
2134 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 2, 0, "prism2_param" },
2135 { PRISM2_IOCTL_GET_PRISM2_PARAM
,
2136 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1,
2137 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getprism2_param" },
2138 /* --- sub-ioctls handlers --- */
2139 { PRISM2_IOCTL_PRISM2_PARAM
,
2140 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "" },
2141 { PRISM2_IOCTL_GET_PRISM2_PARAM
,
2142 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "" },
2143 /* --- sub-ioctls definitions --- */
2144 { PRISM2_PARAM_TXRATECTRL
,
2145 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "txratectrl" },
2146 { PRISM2_PARAM_TXRATECTRL
,
2147 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gettxratectrl" },
2148 { PRISM2_PARAM_BEACON_INT
,
2149 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "beacon_int" },
2150 { PRISM2_PARAM_BEACON_INT
,
2151 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getbeacon_int" },
2152 #ifndef PRISM2_NO_STATION_MODES
2153 { PRISM2_PARAM_PSEUDO_IBSS
,
2154 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "pseudo_ibss" },
2155 { PRISM2_PARAM_PSEUDO_IBSS
,
2156 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getpseudo_ibss" },
2157 #endif /* PRISM2_NO_STATION_MODES */
2159 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "alc" },
2161 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getalc" },
2162 { PRISM2_PARAM_DUMP
,
2163 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "dump" },
2164 { PRISM2_PARAM_DUMP
,
2165 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getdump" },
2166 { PRISM2_PARAM_OTHER_AP_POLICY
,
2167 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "other_ap_policy" },
2168 { PRISM2_PARAM_OTHER_AP_POLICY
,
2169 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getother_ap_pol" },
2170 { PRISM2_PARAM_AP_MAX_INACTIVITY
,
2171 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "max_inactivity" },
2172 { PRISM2_PARAM_AP_MAX_INACTIVITY
,
2173 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getmax_inactivi" },
2174 { PRISM2_PARAM_AP_BRIDGE_PACKETS
,
2175 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "bridge_packets" },
2176 { PRISM2_PARAM_AP_BRIDGE_PACKETS
,
2177 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getbridge_packe" },
2178 { PRISM2_PARAM_DTIM_PERIOD
,
2179 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "dtim_period" },
2180 { PRISM2_PARAM_DTIM_PERIOD
,
2181 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getdtim_period" },
2182 { PRISM2_PARAM_AP_NULLFUNC_ACK
,
2183 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "nullfunc_ack" },
2184 { PRISM2_PARAM_AP_NULLFUNC_ACK
,
2185 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getnullfunc_ack" },
2186 { PRISM2_PARAM_MAX_WDS
,
2187 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "max_wds" },
2188 { PRISM2_PARAM_MAX_WDS
,
2189 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getmax_wds" },
2190 { PRISM2_PARAM_AP_AUTOM_AP_WDS
,
2191 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "autom_ap_wds" },
2192 { PRISM2_PARAM_AP_AUTOM_AP_WDS
,
2193 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getautom_ap_wds" },
2194 { PRISM2_PARAM_AP_AUTH_ALGS
,
2195 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "ap_auth_algs" },
2196 { PRISM2_PARAM_AP_AUTH_ALGS
,
2197 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getap_auth_algs" },
2198 { PRISM2_PARAM_MONITOR_ALLOW_FCSERR
,
2199 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "allow_fcserr" },
2200 { PRISM2_PARAM_MONITOR_ALLOW_FCSERR
,
2201 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getallow_fcserr" },
2202 { PRISM2_PARAM_HOST_ENCRYPT
,
2203 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "host_encrypt" },
2204 { PRISM2_PARAM_HOST_ENCRYPT
,
2205 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethost_encrypt" },
2206 { PRISM2_PARAM_HOST_DECRYPT
,
2207 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "host_decrypt" },
2208 { PRISM2_PARAM_HOST_DECRYPT
,
2209 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethost_decrypt" },
2210 #ifndef PRISM2_NO_STATION_MODES
2211 { PRISM2_PARAM_HOST_ROAMING
,
2212 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "host_roaming" },
2213 { PRISM2_PARAM_HOST_ROAMING
,
2214 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethost_roaming" },
2215 #endif /* PRISM2_NO_STATION_MODES */
2216 { PRISM2_PARAM_BCRX_STA_KEY
,
2217 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "bcrx_sta_key" },
2218 { PRISM2_PARAM_BCRX_STA_KEY
,
2219 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getbcrx_sta_key" },
2220 { PRISM2_PARAM_IEEE_802_1X
,
2221 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "ieee_802_1x" },
2222 { PRISM2_PARAM_IEEE_802_1X
,
2223 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getieee_802_1x" },
2224 { PRISM2_PARAM_ANTSEL_TX
,
2225 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "antsel_tx" },
2226 { PRISM2_PARAM_ANTSEL_TX
,
2227 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getantsel_tx" },
2228 { PRISM2_PARAM_ANTSEL_RX
,
2229 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "antsel_rx" },
2230 { PRISM2_PARAM_ANTSEL_RX
,
2231 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getantsel_rx" },
2232 { PRISM2_PARAM_MONITOR_TYPE
,
2233 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "monitor_type" },
2234 { PRISM2_PARAM_MONITOR_TYPE
,
2235 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getmonitor_type" },
2236 { PRISM2_PARAM_WDS_TYPE
,
2237 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "wds_type" },
2238 { PRISM2_PARAM_WDS_TYPE
,
2239 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getwds_type" },
2240 { PRISM2_PARAM_HOSTSCAN
,
2241 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "hostscan" },
2242 { PRISM2_PARAM_HOSTSCAN
,
2243 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethostscan" },
2244 { PRISM2_PARAM_AP_SCAN
,
2245 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "ap_scan" },
2246 { PRISM2_PARAM_AP_SCAN
,
2247 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getap_scan" },
2248 { PRISM2_PARAM_ENH_SEC
,
2249 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "enh_sec" },
2250 { PRISM2_PARAM_ENH_SEC
,
2251 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getenh_sec" },
2252 #ifdef PRISM2_IO_DEBUG
2253 { PRISM2_PARAM_IO_DEBUG
,
2254 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "io_debug" },
2255 { PRISM2_PARAM_IO_DEBUG
,
2256 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getio_debug" },
2257 #endif /* PRISM2_IO_DEBUG */
2258 { PRISM2_PARAM_BASIC_RATES
,
2259 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "basic_rates" },
2260 { PRISM2_PARAM_BASIC_RATES
,
2261 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getbasic_rates" },
2262 { PRISM2_PARAM_OPER_RATES
,
2263 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "oper_rates" },
2264 { PRISM2_PARAM_OPER_RATES
,
2265 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getoper_rates" },
2266 { PRISM2_PARAM_HOSTAPD
,
2267 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "hostapd" },
2268 { PRISM2_PARAM_HOSTAPD
,
2269 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethostapd" },
2270 { PRISM2_PARAM_HOSTAPD_STA
,
2271 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "hostapd_sta" },
2272 { PRISM2_PARAM_HOSTAPD_STA
,
2273 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethostapd_sta" },
2275 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "wpa" },
2277 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getwpa" },
2278 { PRISM2_PARAM_PRIVACY_INVOKED
,
2279 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "privacy_invoked" },
2280 { PRISM2_PARAM_PRIVACY_INVOKED
,
2281 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getprivacy_invo" },
2282 { PRISM2_PARAM_TKIP_COUNTERMEASURES
,
2283 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "tkip_countermea" },
2284 { PRISM2_PARAM_TKIP_COUNTERMEASURES
,
2285 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gettkip_counter" },
2286 { PRISM2_PARAM_DROP_UNENCRYPTED
,
2287 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "drop_unencrypte" },
2288 { PRISM2_PARAM_DROP_UNENCRYPTED
,
2289 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getdrop_unencry" },
2290 { PRISM2_PARAM_SCAN_CHANNEL_MASK
,
2291 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "scan_channels" },
2292 { PRISM2_PARAM_SCAN_CHANNEL_MASK
,
2293 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getscan_channel" },
2297 static int prism2_ioctl_priv_inquire(struct net_device
*dev
, int *i
)
2299 struct hostap_interface
*iface
;
2300 local_info_t
*local
;
2302 iface
= netdev_priv(dev
);
2303 local
= iface
->local
;
2305 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_INQUIRE
, *i
, NULL
, NULL
))
2312 static int prism2_ioctl_priv_prism2_param(struct net_device
*dev
,
2313 struct iw_request_info
*info
,
2314 void *wrqu
, char *extra
)
2316 struct hostap_interface
*iface
;
2317 local_info_t
*local
;
2318 int *i
= (int *) extra
;
2320 int value
= *(i
+ 1);
2324 iface
= netdev_priv(dev
);
2325 local
= iface
->local
;
2328 case PRISM2_PARAM_TXRATECTRL
:
2329 local
->fw_tx_rate_control
= value
;
2332 case PRISM2_PARAM_BEACON_INT
:
2333 if (hostap_set_word(dev
, HFA384X_RID_CNFBEACONINT
, value
) ||
2334 local
->func
->reset_port(dev
))
2337 local
->beacon_int
= value
;
2340 #ifndef PRISM2_NO_STATION_MODES
2341 case PRISM2_PARAM_PSEUDO_IBSS
:
2342 if (value
== local
->pseudo_adhoc
)
2345 if (value
!= 0 && value
!= 1) {
2350 printk(KERN_DEBUG
"prism2: %s: pseudo IBSS change %d -> %d\n",
2351 dev
->name
, local
->pseudo_adhoc
, value
);
2352 local
->pseudo_adhoc
= value
;
2353 if (local
->iw_mode
!= IW_MODE_ADHOC
)
2356 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
2357 hostap_get_porttype(local
))) {
2362 if (local
->func
->reset_port(dev
))
2365 #endif /* PRISM2_NO_STATION_MODES */
2367 case PRISM2_PARAM_ALC
:
2368 printk(KERN_DEBUG
"%s: %s ALC\n", dev
->name
,
2369 value
== 0 ? "Disabling" : "Enabling");
2370 val
= HFA384X_TEST_CFG_BIT_ALC
;
2371 local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
2372 (HFA384X_TEST_CFG_BITS
<< 8),
2373 value
== 0 ? 0 : 1, &val
, NULL
);
2376 case PRISM2_PARAM_DUMP
:
2377 local
->frame_dump
= value
;
2380 case PRISM2_PARAM_OTHER_AP_POLICY
:
2381 if (value
< 0 || value
> 3) {
2385 if (local
->ap
!= NULL
)
2386 local
->ap
->ap_policy
= value
;
2389 case PRISM2_PARAM_AP_MAX_INACTIVITY
:
2390 if (value
< 0 || value
> 7 * 24 * 60 * 60) {
2394 if (local
->ap
!= NULL
)
2395 local
->ap
->max_inactivity
= value
* HZ
;
2398 case PRISM2_PARAM_AP_BRIDGE_PACKETS
:
2399 if (local
->ap
!= NULL
)
2400 local
->ap
->bridge_packets
= value
;
2403 case PRISM2_PARAM_DTIM_PERIOD
:
2404 if (value
< 0 || value
> 65535) {
2408 if (hostap_set_word(dev
, HFA384X_RID_CNFOWNDTIMPERIOD
, value
)
2409 || local
->func
->reset_port(dev
))
2412 local
->dtim_period
= value
;
2415 case PRISM2_PARAM_AP_NULLFUNC_ACK
:
2416 if (local
->ap
!= NULL
)
2417 local
->ap
->nullfunc_ack
= value
;
2420 case PRISM2_PARAM_MAX_WDS
:
2421 local
->wds_max_connections
= value
;
2424 case PRISM2_PARAM_AP_AUTOM_AP_WDS
:
2425 if (local
->ap
!= NULL
) {
2426 if (!local
->ap
->autom_ap_wds
&& value
) {
2427 /* add WDS link to all APs in STA table */
2428 hostap_add_wds_links(local
);
2430 local
->ap
->autom_ap_wds
= value
;
2434 case PRISM2_PARAM_AP_AUTH_ALGS
:
2435 local
->auth_algs
= value
;
2436 if (hostap_set_auth_algs(local
))
2440 case PRISM2_PARAM_MONITOR_ALLOW_FCSERR
:
2441 local
->monitor_allow_fcserr
= value
;
2444 case PRISM2_PARAM_HOST_ENCRYPT
:
2445 local
->host_encrypt
= value
;
2446 if (hostap_set_encryption(local
) ||
2447 local
->func
->reset_port(dev
))
2451 case PRISM2_PARAM_HOST_DECRYPT
:
2452 local
->host_decrypt
= value
;
2453 if (hostap_set_encryption(local
) ||
2454 local
->func
->reset_port(dev
))
2458 #ifndef PRISM2_NO_STATION_MODES
2459 case PRISM2_PARAM_HOST_ROAMING
:
2460 if (value
< 0 || value
> 2) {
2464 local
->host_roaming
= value
;
2465 if (hostap_set_roaming(local
) || local
->func
->reset_port(dev
))
2468 #endif /* PRISM2_NO_STATION_MODES */
2470 case PRISM2_PARAM_BCRX_STA_KEY
:
2471 local
->bcrx_sta_key
= value
;
2474 case PRISM2_PARAM_IEEE_802_1X
:
2475 local
->ieee_802_1x
= value
;
2478 case PRISM2_PARAM_ANTSEL_TX
:
2479 if (value
< 0 || value
> HOSTAP_ANTSEL_HIGH
) {
2483 local
->antsel_tx
= value
;
2484 hostap_set_antsel(local
);
2487 case PRISM2_PARAM_ANTSEL_RX
:
2488 if (value
< 0 || value
> HOSTAP_ANTSEL_HIGH
) {
2492 local
->antsel_rx
= value
;
2493 hostap_set_antsel(local
);
2496 case PRISM2_PARAM_MONITOR_TYPE
:
2497 if (value
!= PRISM2_MONITOR_80211
&&
2498 value
!= PRISM2_MONITOR_CAPHDR
&&
2499 value
!= PRISM2_MONITOR_PRISM
&&
2500 value
!= PRISM2_MONITOR_RADIOTAP
) {
2504 local
->monitor_type
= value
;
2505 if (local
->iw_mode
== IW_MODE_MONITOR
)
2506 hostap_monitor_set_type(local
);
2509 case PRISM2_PARAM_WDS_TYPE
:
2510 local
->wds_type
= value
;
2513 case PRISM2_PARAM_HOSTSCAN
:
2515 struct hfa384x_hostscan_request scan_req
;
2518 memset(&scan_req
, 0, sizeof(scan_req
));
2519 scan_req
.channel_list
= cpu_to_le16(0x3fff);
2521 case 1: rate
= HFA384X_RATES_1MBPS
; break;
2522 case 2: rate
= HFA384X_RATES_2MBPS
; break;
2523 case 3: rate
= HFA384X_RATES_5MBPS
; break;
2524 case 4: rate
= HFA384X_RATES_11MBPS
; break;
2525 default: rate
= HFA384X_RATES_1MBPS
; break;
2527 scan_req
.txrate
= cpu_to_le16(rate
);
2528 /* leave SSID empty to accept all SSIDs */
2530 if (local
->iw_mode
== IW_MODE_MASTER
) {
2531 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
2532 HFA384X_PORTTYPE_BSS
) ||
2533 local
->func
->reset_port(dev
))
2534 printk(KERN_DEBUG
"Leaving Host AP mode "
2535 "for HostScan failed\n");
2538 if (local
->func
->set_rid(dev
, HFA384X_RID_HOSTSCAN
, &scan_req
,
2539 sizeof(scan_req
))) {
2540 printk(KERN_DEBUG
"HOSTSCAN failed\n");
2543 if (local
->iw_mode
== IW_MODE_MASTER
) {
2544 wait_queue_t __wait
;
2545 init_waitqueue_entry(&__wait
, current
);
2546 add_wait_queue(&local
->hostscan_wq
, &__wait
);
2547 set_current_state(TASK_INTERRUPTIBLE
);
2548 schedule_timeout(HZ
);
2549 if (signal_pending(current
))
2551 set_current_state(TASK_RUNNING
);
2552 remove_wait_queue(&local
->hostscan_wq
, &__wait
);
2554 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
2555 HFA384X_PORTTYPE_HOSTAP
) ||
2556 local
->func
->reset_port(dev
))
2557 printk(KERN_DEBUG
"Returning to Host AP mode "
2558 "after HostScan failed\n");
2563 case PRISM2_PARAM_AP_SCAN
:
2564 local
->passive_scan_interval
= value
;
2565 if (timer_pending(&local
->passive_scan_timer
))
2566 del_timer(&local
->passive_scan_timer
);
2568 local
->passive_scan_timer
.expires
= jiffies
+
2569 local
->passive_scan_interval
* HZ
;
2570 add_timer(&local
->passive_scan_timer
);
2574 case PRISM2_PARAM_ENH_SEC
:
2575 if (value
< 0 || value
> 3) {
2579 local
->enh_sec
= value
;
2580 if (hostap_set_word(dev
, HFA384X_RID_CNFENHSECURITY
,
2582 local
->func
->reset_port(dev
)) {
2583 printk(KERN_INFO
"%s: cnfEnhSecurity requires STA f/w "
2584 "1.6.3 or newer\n", dev
->name
);
2589 #ifdef PRISM2_IO_DEBUG
2590 case PRISM2_PARAM_IO_DEBUG
:
2591 local
->io_debug_enabled
= value
;
2593 #endif /* PRISM2_IO_DEBUG */
2595 case PRISM2_PARAM_BASIC_RATES
:
2596 if ((value
& local
->tx_rate_control
) != value
|| value
== 0) {
2597 printk(KERN_INFO
"%s: invalid basic rate set - basic "
2598 "rates must be in supported rate set\n",
2603 local
->basic_rates
= value
;
2604 if (hostap_set_word(dev
, HFA384X_RID_CNFBASICRATES
,
2605 local
->basic_rates
) ||
2606 local
->func
->reset_port(dev
))
2610 case PRISM2_PARAM_OPER_RATES
:
2611 local
->tx_rate_control
= value
;
2612 if (hostap_set_rate(dev
))
2616 case PRISM2_PARAM_HOSTAPD
:
2617 ret
= hostap_set_hostapd(local
, value
, 1);
2620 case PRISM2_PARAM_HOSTAPD_STA
:
2621 ret
= hostap_set_hostapd_sta(local
, value
, 1);
2624 case PRISM2_PARAM_WPA
:
2626 if (local
->sta_fw_ver
< PRISM2_FW_VER(1,7,0))
2628 else if (hostap_set_word(dev
, HFA384X_RID_SSNHANDLINGMODE
,
2633 case PRISM2_PARAM_PRIVACY_INVOKED
:
2634 local
->privacy_invoked
= value
;
2635 if (hostap_set_encryption(local
) ||
2636 local
->func
->reset_port(dev
))
2640 case PRISM2_PARAM_TKIP_COUNTERMEASURES
:
2641 local
->tkip_countermeasures
= value
;
2644 case PRISM2_PARAM_DROP_UNENCRYPTED
:
2645 local
->drop_unencrypted
= value
;
2648 case PRISM2_PARAM_SCAN_CHANNEL_MASK
:
2649 local
->scan_channel_mask
= value
;
2653 printk(KERN_DEBUG
"%s: prism2_param: unknown param %d\n",
2663 static int prism2_ioctl_priv_get_prism2_param(struct net_device
*dev
,
2664 struct iw_request_info
*info
,
2665 void *wrqu
, char *extra
)
2667 struct hostap_interface
*iface
;
2668 local_info_t
*local
;
2669 int *param
= (int *) extra
;
2672 iface
= netdev_priv(dev
);
2673 local
= iface
->local
;
2676 case PRISM2_PARAM_TXRATECTRL
:
2677 *param
= local
->fw_tx_rate_control
;
2680 case PRISM2_PARAM_BEACON_INT
:
2681 *param
= local
->beacon_int
;
2684 case PRISM2_PARAM_PSEUDO_IBSS
:
2685 *param
= local
->pseudo_adhoc
;
2688 case PRISM2_PARAM_ALC
:
2689 ret
= -EOPNOTSUPP
; /* FIX */
2692 case PRISM2_PARAM_DUMP
:
2693 *param
= local
->frame_dump
;
2696 case PRISM2_PARAM_OTHER_AP_POLICY
:
2697 if (local
->ap
!= NULL
)
2698 *param
= local
->ap
->ap_policy
;
2703 case PRISM2_PARAM_AP_MAX_INACTIVITY
:
2704 if (local
->ap
!= NULL
)
2705 *param
= local
->ap
->max_inactivity
/ HZ
;
2710 case PRISM2_PARAM_AP_BRIDGE_PACKETS
:
2711 if (local
->ap
!= NULL
)
2712 *param
= local
->ap
->bridge_packets
;
2717 case PRISM2_PARAM_DTIM_PERIOD
:
2718 *param
= local
->dtim_period
;
2721 case PRISM2_PARAM_AP_NULLFUNC_ACK
:
2722 if (local
->ap
!= NULL
)
2723 *param
= local
->ap
->nullfunc_ack
;
2728 case PRISM2_PARAM_MAX_WDS
:
2729 *param
= local
->wds_max_connections
;
2732 case PRISM2_PARAM_AP_AUTOM_AP_WDS
:
2733 if (local
->ap
!= NULL
)
2734 *param
= local
->ap
->autom_ap_wds
;
2739 case PRISM2_PARAM_AP_AUTH_ALGS
:
2740 *param
= local
->auth_algs
;
2743 case PRISM2_PARAM_MONITOR_ALLOW_FCSERR
:
2744 *param
= local
->monitor_allow_fcserr
;
2747 case PRISM2_PARAM_HOST_ENCRYPT
:
2748 *param
= local
->host_encrypt
;
2751 case PRISM2_PARAM_HOST_DECRYPT
:
2752 *param
= local
->host_decrypt
;
2755 case PRISM2_PARAM_HOST_ROAMING
:
2756 *param
= local
->host_roaming
;
2759 case PRISM2_PARAM_BCRX_STA_KEY
:
2760 *param
= local
->bcrx_sta_key
;
2763 case PRISM2_PARAM_IEEE_802_1X
:
2764 *param
= local
->ieee_802_1x
;
2767 case PRISM2_PARAM_ANTSEL_TX
:
2768 *param
= local
->antsel_tx
;
2771 case PRISM2_PARAM_ANTSEL_RX
:
2772 *param
= local
->antsel_rx
;
2775 case PRISM2_PARAM_MONITOR_TYPE
:
2776 *param
= local
->monitor_type
;
2779 case PRISM2_PARAM_WDS_TYPE
:
2780 *param
= local
->wds_type
;
2783 case PRISM2_PARAM_HOSTSCAN
:
2787 case PRISM2_PARAM_AP_SCAN
:
2788 *param
= local
->passive_scan_interval
;
2791 case PRISM2_PARAM_ENH_SEC
:
2792 *param
= local
->enh_sec
;
2795 #ifdef PRISM2_IO_DEBUG
2796 case PRISM2_PARAM_IO_DEBUG
:
2797 *param
= local
->io_debug_enabled
;
2799 #endif /* PRISM2_IO_DEBUG */
2801 case PRISM2_PARAM_BASIC_RATES
:
2802 *param
= local
->basic_rates
;
2805 case PRISM2_PARAM_OPER_RATES
:
2806 *param
= local
->tx_rate_control
;
2809 case PRISM2_PARAM_HOSTAPD
:
2810 *param
= local
->hostapd
;
2813 case PRISM2_PARAM_HOSTAPD_STA
:
2814 *param
= local
->hostapd_sta
;
2817 case PRISM2_PARAM_WPA
:
2818 if (local
->sta_fw_ver
< PRISM2_FW_VER(1,7,0))
2820 *param
= local
->wpa
;
2823 case PRISM2_PARAM_PRIVACY_INVOKED
:
2824 *param
= local
->privacy_invoked
;
2827 case PRISM2_PARAM_TKIP_COUNTERMEASURES
:
2828 *param
= local
->tkip_countermeasures
;
2831 case PRISM2_PARAM_DROP_UNENCRYPTED
:
2832 *param
= local
->drop_unencrypted
;
2835 case PRISM2_PARAM_SCAN_CHANNEL_MASK
:
2836 *param
= local
->scan_channel_mask
;
2840 printk(KERN_DEBUG
"%s: get_prism2_param: unknown param %d\n",
2850 static int prism2_ioctl_priv_readmif(struct net_device
*dev
,
2851 struct iw_request_info
*info
,
2852 void *wrqu
, char *extra
)
2854 struct hostap_interface
*iface
;
2855 local_info_t
*local
;
2858 iface
= netdev_priv(dev
);
2859 local
= iface
->local
;
2861 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_READMIF
, *extra
, NULL
,
2871 static int prism2_ioctl_priv_writemif(struct net_device
*dev
,
2872 struct iw_request_info
*info
,
2873 void *wrqu
, char *extra
)
2875 struct hostap_interface
*iface
;
2876 local_info_t
*local
;
2879 iface
= netdev_priv(dev
);
2880 local
= iface
->local
;
2884 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_WRITEMIF
, cr
, &val
, NULL
))
2891 static int prism2_ioctl_priv_monitor(struct net_device
*dev
, int *i
)
2893 struct hostap_interface
*iface
;
2894 local_info_t
*local
;
2898 iface
= netdev_priv(dev
);
2899 local
= iface
->local
;
2901 printk(KERN_DEBUG
"%s: process %d (%s) used deprecated iwpriv monitor "
2902 "- update software to use iwconfig mode monitor\n",
2903 dev
->name
, task_pid_nr(current
), current
->comm
);
2905 /* Backward compatibility code - this can be removed at some point */
2908 /* Disable monitor mode - old mode was not saved, so go to
2910 mode
= IW_MODE_MASTER
;
2911 ret
= prism2_ioctl_siwmode(dev
, NULL
, &mode
, NULL
);
2912 } else if (*i
== 1) {
2913 /* netlink socket mode is not supported anymore since it did
2914 * not separate different devices from each other and was not
2915 * best method for delivering large amount of packets to
2918 } else if (*i
== 2 || *i
== 3) {
2921 local
->monitor_type
= PRISM2_MONITOR_80211
;
2924 local
->monitor_type
= PRISM2_MONITOR_PRISM
;
2927 mode
= IW_MODE_MONITOR
;
2928 ret
= prism2_ioctl_siwmode(dev
, NULL
, &mode
, NULL
);
2929 hostap_monitor_mode_enable(local
);
2937 static int prism2_ioctl_priv_reset(struct net_device
*dev
, int *i
)
2939 struct hostap_interface
*iface
;
2940 local_info_t
*local
;
2942 iface
= netdev_priv(dev
);
2943 local
= iface
->local
;
2945 printk(KERN_DEBUG
"%s: manual reset request(%d)\n", dev
->name
, *i
);
2948 /* Disable and enable card */
2949 local
->func
->hw_shutdown(dev
, 1);
2950 local
->func
->hw_config(dev
, 0);
2955 local
->func
->hw_reset(dev
);
2959 /* Disable and enable port 0 */
2960 local
->func
->reset_port(dev
);
2964 prism2_sta_deauth(local
, WLAN_REASON_DEAUTH_LEAVING
);
2965 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_DISABLE
, 0, NULL
,
2971 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_ENABLE
, 0, NULL
,
2977 printk(KERN_DEBUG
"Unknown reset request %d\n", *i
);
2985 static int prism2_ioctl_priv_set_rid_word(struct net_device
*dev
, int *i
)
2988 int value
= *(i
+ 1);
2990 printk(KERN_DEBUG
"%s: Set RID[0x%X] = %d\n", dev
->name
, rid
, value
);
2992 if (hostap_set_word(dev
, rid
, value
))
2999 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
3000 static int ap_mac_cmd_ioctl(local_info_t
*local
, int *cmd
)
3005 case AP_MAC_CMD_POLICY_OPEN
:
3006 local
->ap
->mac_restrictions
.policy
= MAC_POLICY_OPEN
;
3008 case AP_MAC_CMD_POLICY_ALLOW
:
3009 local
->ap
->mac_restrictions
.policy
= MAC_POLICY_ALLOW
;
3011 case AP_MAC_CMD_POLICY_DENY
:
3012 local
->ap
->mac_restrictions
.policy
= MAC_POLICY_DENY
;
3014 case AP_MAC_CMD_FLUSH
:
3015 ap_control_flush_macs(&local
->ap
->mac_restrictions
);
3017 case AP_MAC_CMD_KICKALL
:
3018 ap_control_kickall(local
->ap
);
3019 hostap_deauth_all_stas(local
->dev
, local
->ap
, 0);
3028 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
3031 #ifdef PRISM2_DOWNLOAD_SUPPORT
3032 static int prism2_ioctl_priv_download(local_info_t
*local
, struct iw_point
*p
)
3034 struct prism2_download_param
*param
;
3037 if (p
->length
< sizeof(struct prism2_download_param
) ||
3038 p
->length
> 1024 || !p
->pointer
)
3041 param
= (struct prism2_download_param
*)
3042 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
);