1 /* ioctl() (mostly Linux Wireless Extensions) routines for Host AP driver */
3 #include <linux/types.h>
4 #include <linux/ethtool.h>
5 #include <net/lib80211.h>
7 #include "hostap_wlan.h"
11 static struct iw_statistics
*hostap_get_wireless_stats(struct net_device
*dev
)
13 struct hostap_interface
*iface
;
15 struct iw_statistics
*wstats
;
17 iface
= netdev_priv(dev
);
20 /* Why are we doing that ? Jean II */
21 if (iface
->type
!= HOSTAP_INTERFACE_MAIN
)
24 wstats
= &local
->wstats
;
27 wstats
->discard
.code
=
28 local
->comm_tallies
.rx_discards_wep_undecryptable
;
29 wstats
->discard
.misc
=
30 local
->comm_tallies
.rx_fcs_errors
+
31 local
->comm_tallies
.rx_discards_no_buffer
+
32 local
->comm_tallies
.tx_discards_wrong_sa
;
34 wstats
->discard
.retries
=
35 local
->comm_tallies
.tx_retry_limit_exceeded
;
36 wstats
->discard
.fragment
=
37 local
->comm_tallies
.rx_message_in_bad_msg_fragments
;
39 if (local
->iw_mode
!= IW_MODE_MASTER
&&
40 local
->iw_mode
!= IW_MODE_REPEAT
) {
43 /* RID reading might sleep and it must not be called in
44 * interrupt context or while atomic. However, this
45 * function seems to be called while atomic (at least in Linux
46 * 2.5.59). Update signal quality values only if in suitable
47 * context. Otherwise, previous values read from tick timer
51 #endif /* in_atomic */
53 if (update
&& prism2_update_comms_qual(dev
) == 0)
54 wstats
->qual
.updated
= IW_QUAL_ALL_UPDATED
|
57 wstats
->qual
.qual
= local
->comms_qual
;
58 wstats
->qual
.level
= local
->avg_signal
;
59 wstats
->qual
.noise
= local
->avg_noise
;
61 wstats
->qual
.qual
= 0;
62 wstats
->qual
.level
= 0;
63 wstats
->qual
.noise
= 0;
64 wstats
->qual
.updated
= IW_QUAL_ALL_INVALID
;
71 static int prism2_get_datarates(struct net_device
*dev
, u8
*rates
)
73 struct hostap_interface
*iface
;
79 iface
= netdev_priv(dev
);
82 len
= local
->func
->get_rid(dev
, HFA384X_RID_SUPPORTEDDATARATES
, buf
,
87 val
= le16_to_cpu(*(__le16
*) buf
); /* string length */
89 if (len
- 2 < val
|| val
> 10)
92 memcpy(rates
, buf
+ 2, val
);
97 static int prism2_get_name(struct net_device
*dev
,
98 struct iw_request_info
*info
,
99 char *name
, char *extra
)
102 int len
, i
, over2
= 0;
104 len
= prism2_get_datarates(dev
, rates
);
106 for (i
= 0; i
< len
; i
++) {
107 if (rates
[i
] == 0x0b || rates
[i
] == 0x16) {
113 strcpy(name
, over2
? "IEEE 802.11b" : "IEEE 802.11-DS");
119 static void prism2_crypt_delayed_deinit(local_info_t
*local
,
120 struct lib80211_crypt_data
**crypt
)
122 struct lib80211_crypt_data
*tmp
;
131 /* must not run ops->deinit() while there may be pending encrypt or
132 * decrypt operations. Use a list of delayed deinits to avoid needing
135 spin_lock_irqsave(&local
->lock
, flags
);
136 list_add(&tmp
->list
, &local
->crypt_info
.crypt_deinit_list
);
137 if (!timer_pending(&local
->crypt_info
.crypt_deinit_timer
)) {
138 local
->crypt_info
.crypt_deinit_timer
.expires
= jiffies
+ HZ
;
139 add_timer(&local
->crypt_info
.crypt_deinit_timer
);
141 spin_unlock_irqrestore(&local
->lock
, flags
);
145 static int prism2_ioctl_siwencode(struct net_device
*dev
,
146 struct iw_request_info
*info
,
147 struct iw_point
*erq
, char *keybuf
)
149 struct hostap_interface
*iface
;
152 struct lib80211_crypt_data
**crypt
;
154 iface
= netdev_priv(dev
);
155 local
= iface
->local
;
157 i
= erq
->flags
& IW_ENCODE_INDEX
;
159 i
= local
->crypt_info
.tx_keyidx
;
162 if (i
< 0 || i
>= WEP_KEYS
)
165 crypt
= &local
->crypt_info
.crypt
[i
];
167 if (erq
->flags
& IW_ENCODE_DISABLED
) {
169 prism2_crypt_delayed_deinit(local
, crypt
);
173 if (*crypt
!= NULL
&& (*crypt
)->ops
!= NULL
&&
174 strcmp((*crypt
)->ops
->name
, "WEP") != 0) {
175 /* changing to use WEP; deinit previously used algorithm */
176 prism2_crypt_delayed_deinit(local
, crypt
);
179 if (*crypt
== NULL
) {
180 struct lib80211_crypt_data
*new_crypt
;
182 /* take WEP into use */
183 new_crypt
= kzalloc(sizeof(struct lib80211_crypt_data
),
185 if (new_crypt
== NULL
)
187 new_crypt
->ops
= lib80211_get_crypto_ops("WEP");
188 if (!new_crypt
->ops
) {
189 request_module("lib80211_crypt_wep");
190 new_crypt
->ops
= lib80211_get_crypto_ops("WEP");
193 new_crypt
->priv
= new_crypt
->ops
->init(i
);
194 if (!new_crypt
->ops
|| !new_crypt
->priv
) {
198 printk(KERN_WARNING
"%s: could not initialize WEP: "
199 "load module hostap_crypt_wep.o\n",
206 if (erq
->length
> 0) {
207 int len
= erq
->length
<= 5 ? 5 : 13;
209 if (len
> erq
->length
)
210 memset(keybuf
+ erq
->length
, 0, len
- erq
->length
);
211 (*crypt
)->ops
->set_key(keybuf
, len
, NULL
, (*crypt
)->priv
);
212 for (j
= 0; j
< WEP_KEYS
; j
++) {
213 if (j
!= i
&& local
->crypt_info
.crypt
[j
]) {
219 local
->crypt_info
.tx_keyidx
= i
;
221 /* No key data - just set the default TX key index */
222 local
->crypt_info
.tx_keyidx
= i
;
226 local
->open_wep
= erq
->flags
& IW_ENCODE_OPEN
;
228 if (hostap_set_encryption(local
)) {
229 printk(KERN_DEBUG
"%s: set_encryption failed\n", dev
->name
);
233 /* Do not reset port0 if card is in Managed mode since resetting will
234 * generate new IEEE 802.11 authentication which may end up in looping
235 * with IEEE 802.1X. Prism2 documentation seem to require port reset
236 * after WEP configuration. However, keys are apparently changed at
237 * least in Managed mode. */
238 if (local
->iw_mode
!= IW_MODE_INFRA
&& local
->func
->reset_port(dev
)) {
239 printk(KERN_DEBUG
"%s: reset_port failed\n", dev
->name
);
247 static int prism2_ioctl_giwencode(struct net_device
*dev
,
248 struct iw_request_info
*info
,
249 struct iw_point
*erq
, char *key
)
251 struct hostap_interface
*iface
;
255 struct lib80211_crypt_data
*crypt
;
257 iface
= netdev_priv(dev
);
258 local
= iface
->local
;
260 i
= erq
->flags
& IW_ENCODE_INDEX
;
262 i
= local
->crypt_info
.tx_keyidx
;
265 if (i
< 0 || i
>= WEP_KEYS
)
268 crypt
= local
->crypt_info
.crypt
[i
];
271 if (crypt
== NULL
|| crypt
->ops
== NULL
) {
273 erq
->flags
|= IW_ENCODE_DISABLED
;
277 if (strcmp(crypt
->ops
->name
, "WEP") != 0) {
278 /* only WEP is supported with wireless extensions, so just
279 * report that encryption is used */
281 erq
->flags
|= IW_ENCODE_ENABLED
;
285 /* Reads from HFA384X_RID_CNFDEFAULTKEY* return bogus values, so show
286 * the keys from driver buffer */
287 len
= crypt
->ops
->get_key(key
, WEP_KEY_LEN
, NULL
, crypt
->priv
);
288 erq
->length
= (len
>= 0 ? len
: 0);
290 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFWEPFLAGS
, &val
, 2, 1) < 0)
292 printk("CNFWEPFLAGS reading failed\n");
296 if (val
& HFA384X_WEPFLAGS_PRIVACYINVOKED
)
297 erq
->flags
|= IW_ENCODE_ENABLED
;
299 erq
->flags
|= IW_ENCODE_DISABLED
;
300 if (val
& HFA384X_WEPFLAGS_EXCLUDEUNENCRYPTED
)
301 erq
->flags
|= IW_ENCODE_RESTRICTED
;
303 erq
->flags
|= IW_ENCODE_OPEN
;
309 static int hostap_set_rate(struct net_device
*dev
)
311 struct hostap_interface
*iface
;
313 int ret
, basic_rates
;
315 iface
= netdev_priv(dev
);
316 local
= iface
->local
;
318 basic_rates
= local
->basic_rates
& local
->tx_rate_control
;
319 if (!basic_rates
|| basic_rates
!= local
->basic_rates
) {
320 printk(KERN_INFO
"%s: updating basic rate set automatically "
321 "to match with the new supported rate set\n",
324 basic_rates
= local
->tx_rate_control
;
326 local
->basic_rates
= basic_rates
;
327 if (hostap_set_word(dev
, HFA384X_RID_CNFBASICRATES
,
329 printk(KERN_WARNING
"%s: failed to set "
330 "cnfBasicRates\n", dev
->name
);
333 ret
= (hostap_set_word(dev
, HFA384X_RID_TXRATECONTROL
,
334 local
->tx_rate_control
) ||
335 hostap_set_word(dev
, HFA384X_RID_CNFSUPPORTEDRATES
,
336 local
->tx_rate_control
) ||
337 local
->func
->reset_port(dev
));
340 printk(KERN_WARNING
"%s: TXRateControl/cnfSupportedRates "
341 "setting to 0x%x failed\n",
342 dev
->name
, local
->tx_rate_control
);
345 /* Update TX rate configuration for all STAs based on new operational
347 hostap_update_rates(local
);
353 static int prism2_ioctl_siwrate(struct net_device
*dev
,
354 struct iw_request_info
*info
,
355 struct iw_param
*rrq
, char *extra
)
357 struct hostap_interface
*iface
;
360 iface
= netdev_priv(dev
);
361 local
= iface
->local
;
364 switch (rrq
->value
) {
366 local
->tx_rate_control
= HFA384X_RATES_11MBPS
;
369 local
->tx_rate_control
= HFA384X_RATES_5MBPS
;
372 local
->tx_rate_control
= HFA384X_RATES_2MBPS
;
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
;
384 switch (rrq
->value
) {
386 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
387 HFA384X_RATES_2MBPS
| HFA384X_RATES_5MBPS
|
388 HFA384X_RATES_11MBPS
;
391 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
392 HFA384X_RATES_2MBPS
| HFA384X_RATES_5MBPS
;
395 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
399 local
->tx_rate_control
= HFA384X_RATES_1MBPS
;
402 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
403 HFA384X_RATES_2MBPS
| HFA384X_RATES_5MBPS
|
404 HFA384X_RATES_11MBPS
;
409 return hostap_set_rate(dev
);
413 static int prism2_ioctl_giwrate(struct net_device
*dev
,
414 struct iw_request_info
*info
,
415 struct iw_param
*rrq
, char *extra
)
418 struct hostap_interface
*iface
;
422 iface
= netdev_priv(dev
);
423 local
= iface
->local
;
425 if (local
->func
->get_rid(dev
, HFA384X_RID_TXRATECONTROL
, &val
, 2, 1) <
429 if ((val
& 0x1) && (val
> 1))
434 if (local
->iw_mode
== IW_MODE_MASTER
&& local
->ap
!= NULL
&&
435 !local
->fw_tx_rate_control
) {
436 /* HFA384X_RID_CURRENTTXRATE seems to always be 2 Mbps in
437 * Host AP mode, so use the recorded TX rate of the last sent
439 rrq
->value
= local
->ap
->last_tx_rate
> 0 ?
440 local
->ap
->last_tx_rate
* 100000 : 11000000;
444 if (local
->func
->get_rid(dev
, HFA384X_RID_CURRENTTXRATE
, &val
, 2, 1) <
449 case HFA384X_RATES_1MBPS
:
450 rrq
->value
= 1000000;
452 case HFA384X_RATES_2MBPS
:
453 rrq
->value
= 2000000;
455 case HFA384X_RATES_5MBPS
:
456 rrq
->value
= 5500000;
458 case HFA384X_RATES_11MBPS
:
459 rrq
->value
= 11000000;
462 /* should not happen */
463 rrq
->value
= 11000000;
472 static int prism2_ioctl_siwsens(struct net_device
*dev
,
473 struct iw_request_info
*info
,
474 struct iw_param
*sens
, char *extra
)
476 struct hostap_interface
*iface
;
479 iface
= netdev_priv(dev
);
480 local
= iface
->local
;
482 /* Set the desired AP density */
483 if (sens
->value
< 1 || sens
->value
> 3)
486 if (hostap_set_word(dev
, HFA384X_RID_CNFSYSTEMSCALE
, sens
->value
) ||
487 local
->func
->reset_port(dev
))
493 static int prism2_ioctl_giwsens(struct net_device
*dev
,
494 struct iw_request_info
*info
,
495 struct iw_param
*sens
, char *extra
)
497 struct hostap_interface
*iface
;
501 iface
= netdev_priv(dev
);
502 local
= iface
->local
;
504 /* Get the current AP density */
505 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFSYSTEMSCALE
, &val
, 2, 1) <
509 sens
->value
= le16_to_cpu(val
);
516 /* Deprecated in new wireless extension API */
517 static int prism2_ioctl_giwaplist(struct net_device
*dev
,
518 struct iw_request_info
*info
,
519 struct iw_point
*data
, char *extra
)
521 struct hostap_interface
*iface
;
523 struct sockaddr
*addr
;
524 struct iw_quality
*qual
;
526 iface
= netdev_priv(dev
);
527 local
= iface
->local
;
529 if (local
->iw_mode
!= IW_MODE_MASTER
) {
530 printk(KERN_DEBUG
"SIOCGIWAPLIST is currently only supported "
531 "in Host AP mode\n");
536 addr
= kmalloc(sizeof(struct sockaddr
) * IW_MAX_AP
, GFP_KERNEL
);
537 qual
= kmalloc(sizeof(struct iw_quality
) * IW_MAX_AP
, GFP_KERNEL
);
538 if (addr
== NULL
|| qual
== NULL
) {
545 data
->length
= prism2_ap_get_sta_qual(local
, addr
, qual
, IW_MAX_AP
, 1);
547 memcpy(extra
, &addr
, sizeof(struct sockaddr
) * data
->length
);
548 data
->flags
= 1; /* has quality information */
549 memcpy(extra
+ sizeof(struct sockaddr
) * data
->length
, &qual
,
550 sizeof(struct iw_quality
) * data
->length
);
558 static int prism2_ioctl_siwrts(struct net_device
*dev
,
559 struct iw_request_info
*info
,
560 struct iw_param
*rts
, char *extra
)
562 struct hostap_interface
*iface
;
566 iface
= netdev_priv(dev
);
567 local
= iface
->local
;
570 val
= cpu_to_le16(2347);
571 else if (rts
->value
< 0 || rts
->value
> 2347)
574 val
= cpu_to_le16(rts
->value
);
576 if (local
->func
->set_rid(dev
, HFA384X_RID_RTSTHRESHOLD
, &val
, 2) ||
577 local
->func
->reset_port(dev
))
580 local
->rts_threshold
= rts
->value
;
585 static int prism2_ioctl_giwrts(struct net_device
*dev
,
586 struct iw_request_info
*info
,
587 struct iw_param
*rts
, char *extra
)
589 struct hostap_interface
*iface
;
593 iface
= netdev_priv(dev
);
594 local
= iface
->local
;
596 if (local
->func
->get_rid(dev
, HFA384X_RID_RTSTHRESHOLD
, &val
, 2, 1) <
600 rts
->value
= le16_to_cpu(val
);
601 rts
->disabled
= (rts
->value
== 2347);
608 static int prism2_ioctl_siwfrag(struct net_device
*dev
,
609 struct iw_request_info
*info
,
610 struct iw_param
*rts
, char *extra
)
612 struct hostap_interface
*iface
;
616 iface
= netdev_priv(dev
);
617 local
= iface
->local
;
620 val
= cpu_to_le16(2346);
621 else if (rts
->value
< 256 || rts
->value
> 2346)
624 val
= cpu_to_le16(rts
->value
& ~0x1); /* even numbers only */
626 local
->fragm_threshold
= rts
->value
& ~0x1;
627 if (local
->func
->set_rid(dev
, HFA384X_RID_FRAGMENTATIONTHRESHOLD
, &val
,
629 || local
->func
->reset_port(dev
))
635 static int prism2_ioctl_giwfrag(struct net_device
*dev
,
636 struct iw_request_info
*info
,
637 struct iw_param
*rts
, char *extra
)
639 struct hostap_interface
*iface
;
643 iface
= netdev_priv(dev
);
644 local
= iface
->local
;
646 if (local
->func
->get_rid(dev
, HFA384X_RID_FRAGMENTATIONTHRESHOLD
,
650 rts
->value
= le16_to_cpu(val
);
651 rts
->disabled
= (rts
->value
== 2346);
658 #ifndef PRISM2_NO_STATION_MODES
659 static int hostap_join_ap(struct net_device
*dev
)
661 struct hostap_interface
*iface
;
663 struct hfa384x_join_request req
;
666 struct hfa384x_hostscan_result
*entry
;
668 iface
= netdev_priv(dev
);
669 local
= iface
->local
;
671 memcpy(req
.bssid
, local
->preferred_ap
, ETH_ALEN
);
674 spin_lock_irqsave(&local
->lock
, flags
);
675 for (i
= 0; i
< local
->last_scan_results_count
; i
++) {
676 if (!local
->last_scan_results
)
678 entry
= &local
->last_scan_results
[i
];
679 if (memcmp(local
->preferred_ap
, entry
->bssid
, ETH_ALEN
) == 0) {
680 req
.channel
= entry
->chid
;
684 spin_unlock_irqrestore(&local
->lock
, flags
);
686 if (local
->func
->set_rid(dev
, HFA384X_RID_JOINREQUEST
, &req
,
688 printk(KERN_DEBUG
"%s: JoinRequest %pM failed\n",
689 dev
->name
, local
->preferred_ap
);
693 printk(KERN_DEBUG
"%s: Trying to join BSSID %pM\n",
694 dev
->name
, local
->preferred_ap
);
698 #endif /* PRISM2_NO_STATION_MODES */
701 static int prism2_ioctl_siwap(struct net_device
*dev
,
702 struct iw_request_info
*info
,
703 struct sockaddr
*ap_addr
, char *extra
)
705 #ifdef PRISM2_NO_STATION_MODES
707 #else /* PRISM2_NO_STATION_MODES */
708 struct hostap_interface
*iface
;
711 iface
= netdev_priv(dev
);
712 local
= iface
->local
;
714 memcpy(local
->preferred_ap
, &ap_addr
->sa_data
, ETH_ALEN
);
716 if (local
->host_roaming
== 1 && local
->iw_mode
== IW_MODE_INFRA
) {
717 struct hfa384x_scan_request scan_req
;
718 memset(&scan_req
, 0, sizeof(scan_req
));
719 scan_req
.channel_list
= cpu_to_le16(0x3fff);
720 scan_req
.txrate
= cpu_to_le16(HFA384X_RATES_1MBPS
);
721 if (local
->func
->set_rid(dev
, HFA384X_RID_SCANREQUEST
,
722 &scan_req
, sizeof(scan_req
))) {
723 printk(KERN_DEBUG
"%s: ScanResults request failed - "
724 "preferred AP delayed to next unsolicited "
725 "scan\n", dev
->name
);
727 } else if (local
->host_roaming
== 2 &&
728 local
->iw_mode
== IW_MODE_INFRA
) {
729 if (hostap_join_ap(dev
))
732 printk(KERN_DEBUG
"%s: Preferred AP (SIOCSIWAP) is used only "
733 "in Managed mode when host_roaming is enabled\n",
738 #endif /* PRISM2_NO_STATION_MODES */
741 static int prism2_ioctl_giwap(struct net_device
*dev
,
742 struct iw_request_info
*info
,
743 struct sockaddr
*ap_addr
, char *extra
)
745 struct hostap_interface
*iface
;
748 iface
= netdev_priv(dev
);
749 local
= iface
->local
;
751 ap_addr
->sa_family
= ARPHRD_ETHER
;
752 switch (iface
->type
) {
753 case HOSTAP_INTERFACE_AP
:
754 memcpy(&ap_addr
->sa_data
, dev
->dev_addr
, ETH_ALEN
);
756 case HOSTAP_INTERFACE_STA
:
757 memcpy(&ap_addr
->sa_data
, local
->assoc_ap_addr
, ETH_ALEN
);
759 case HOSTAP_INTERFACE_WDS
:
760 memcpy(&ap_addr
->sa_data
, iface
->u
.wds
.remote_addr
, ETH_ALEN
);
763 if (local
->func
->get_rid(dev
, HFA384X_RID_CURRENTBSSID
,
764 &ap_addr
->sa_data
, ETH_ALEN
, 1) < 0)
767 /* local->bssid is also updated in LinkStatus handler when in
769 memcpy(local
->bssid
, &ap_addr
->sa_data
, ETH_ALEN
);
777 static int prism2_ioctl_siwnickn(struct net_device
*dev
,
778 struct iw_request_info
*info
,
779 struct iw_point
*data
, char *nickname
)
781 struct hostap_interface
*iface
;
784 iface
= netdev_priv(dev
);
785 local
= iface
->local
;
787 memset(local
->name
, 0, sizeof(local
->name
));
788 memcpy(local
->name
, nickname
, data
->length
);
791 if (hostap_set_string(dev
, HFA384X_RID_CNFOWNNAME
, local
->name
) ||
792 local
->func
->reset_port(dev
))
798 static int prism2_ioctl_giwnickn(struct net_device
*dev
,
799 struct iw_request_info
*info
,
800 struct iw_point
*data
, char *nickname
)
802 struct hostap_interface
*iface
;
805 char name
[MAX_NAME_LEN
+ 3];
808 iface
= netdev_priv(dev
);
809 local
= iface
->local
;
811 len
= local
->func
->get_rid(dev
, HFA384X_RID_CNFOWNNAME
,
812 &name
, MAX_NAME_LEN
+ 2, 0);
813 val
= le16_to_cpu(*(__le16
*) name
);
814 if (len
> MAX_NAME_LEN
+ 2 || len
< 0 || val
> MAX_NAME_LEN
)
817 name
[val
+ 2] = '\0';
818 data
->length
= val
+ 1;
819 memcpy(nickname
, name
+ 2, val
+ 1);
825 static int prism2_ioctl_siwfreq(struct net_device
*dev
,
826 struct iw_request_info
*info
,
827 struct iw_freq
*freq
, char *extra
)
829 struct hostap_interface
*iface
;
832 iface
= netdev_priv(dev
);
833 local
= iface
->local
;
837 freq
->m
/ 100000 >= freq_list
[0] &&
838 freq
->m
/ 100000 <= freq_list
[FREQ_COUNT
- 1]) {
840 int fr
= freq
->m
/ 100000;
841 for (ch
= 0; ch
< FREQ_COUNT
; ch
++) {
842 if (fr
== freq_list
[ch
]) {
850 if (freq
->e
!= 0 || freq
->m
< 1 || freq
->m
> FREQ_COUNT
||
851 !(local
->channel_mask
& (1 << (freq
->m
- 1))))
854 local
->channel
= freq
->m
; /* channel is used in prism2_setup_rids() */
855 if (hostap_set_word(dev
, HFA384X_RID_CNFOWNCHANNEL
, local
->channel
) ||
856 local
->func
->reset_port(dev
))
862 static int prism2_ioctl_giwfreq(struct net_device
*dev
,
863 struct iw_request_info
*info
,
864 struct iw_freq
*freq
, char *extra
)
866 struct hostap_interface
*iface
;
870 iface
= netdev_priv(dev
);
871 local
= iface
->local
;
873 if (local
->func
->get_rid(dev
, HFA384X_RID_CURRENTCHANNEL
, &val
, 2, 1) <
878 if (val
< 1 || val
> FREQ_COUNT
)
881 freq
->m
= freq_list
[val
- 1] * 100000;
888 static void hostap_monitor_set_type(local_info_t
*local
)
890 struct net_device
*dev
= local
->ddev
;
895 if (local
->monitor_type
== PRISM2_MONITOR_PRISM
||
896 local
->monitor_type
== PRISM2_MONITOR_CAPHDR
) {
897 dev
->type
= ARPHRD_IEEE80211_PRISM
;
898 } else if (local
->monitor_type
== PRISM2_MONITOR_RADIOTAP
) {
899 dev
->type
= ARPHRD_IEEE80211_RADIOTAP
;
901 dev
->type
= ARPHRD_IEEE80211
;
906 static int prism2_ioctl_siwessid(struct net_device
*dev
,
907 struct iw_request_info
*info
,
908 struct iw_point
*data
, char *ssid
)
910 struct hostap_interface
*iface
;
913 iface
= netdev_priv(dev
);
914 local
= iface
->local
;
916 if (iface
->type
== HOSTAP_INTERFACE_WDS
)
919 if (data
->flags
== 0)
920 ssid
[0] = '\0'; /* ANY */
922 if (local
->iw_mode
== IW_MODE_MASTER
&& ssid
[0] == '\0') {
923 /* Setting SSID to empty string seems to kill the card in
925 printk(KERN_DEBUG
"%s: Host AP mode does not support "
926 "'Any' essid\n", dev
->name
);
930 memcpy(local
->essid
, ssid
, data
->length
);
931 local
->essid
[data
->length
] = '\0';
933 if ((!local
->fw_ap
&&
934 hostap_set_string(dev
, HFA384X_RID_CNFDESIREDSSID
, local
->essid
))
935 || hostap_set_string(dev
, HFA384X_RID_CNFOWNSSID
, local
->essid
) ||
936 local
->func
->reset_port(dev
))
942 static int prism2_ioctl_giwessid(struct net_device
*dev
,
943 struct iw_request_info
*info
,
944 struct iw_point
*data
, char *essid
)
946 struct hostap_interface
*iface
;
950 iface
= netdev_priv(dev
);
951 local
= iface
->local
;
953 if (iface
->type
== HOSTAP_INTERFACE_WDS
)
956 data
->flags
= 1; /* active */
957 if (local
->iw_mode
== IW_MODE_MASTER
) {
958 data
->length
= strlen(local
->essid
);
959 memcpy(essid
, local
->essid
, IW_ESSID_MAX_SIZE
);
962 char ssid
[MAX_SSID_LEN
+ 2];
963 memset(ssid
, 0, sizeof(ssid
));
964 len
= local
->func
->get_rid(dev
, HFA384X_RID_CURRENTSSID
,
965 &ssid
, MAX_SSID_LEN
+ 2, 0);
966 val
= le16_to_cpu(*(__le16
*) ssid
);
967 if (len
> MAX_SSID_LEN
+ 2 || len
< 0 || val
> MAX_SSID_LEN
) {
971 memcpy(essid
, ssid
+ 2, IW_ESSID_MAX_SIZE
);
978 static int prism2_ioctl_giwrange(struct net_device
*dev
,
979 struct iw_request_info
*info
,
980 struct iw_point
*data
, char *extra
)
982 struct hostap_interface
*iface
;
984 struct iw_range
*range
= (struct iw_range
*) extra
;
989 iface
= netdev_priv(dev
);
990 local
= iface
->local
;
992 data
->length
= sizeof(struct iw_range
);
993 memset(range
, 0, sizeof(struct iw_range
));
995 /* TODO: could fill num_txpower and txpower array with
996 * something; however, there are 128 different values.. */
998 range
->txpower_capa
= IW_TXPOW_DBM
;
1000 if (local
->iw_mode
== IW_MODE_INFRA
|| local
->iw_mode
== IW_MODE_ADHOC
)
1002 range
->min_pmp
= 1 * 1024;
1003 range
->max_pmp
= 65535 * 1024;
1004 range
->min_pmt
= 1 * 1024;
1005 range
->max_pmt
= 1000 * 1024;
1006 range
->pmp_flags
= IW_POWER_PERIOD
;
1007 range
->pmt_flags
= IW_POWER_TIMEOUT
;
1008 range
->pm_capa
= IW_POWER_PERIOD
| IW_POWER_TIMEOUT
|
1009 IW_POWER_UNICAST_R
| IW_POWER_ALL_R
;
1012 range
->we_version_compiled
= WIRELESS_EXT
;
1013 range
->we_version_source
= 18;
1015 range
->retry_capa
= IW_RETRY_LIMIT
;
1016 range
->retry_flags
= IW_RETRY_LIMIT
;
1017 range
->min_retry
= 0;
1018 range
->max_retry
= 255;
1020 range
->num_channels
= FREQ_COUNT
;
1023 for (i
= 0; i
< FREQ_COUNT
; i
++) {
1024 if (local
->channel_mask
& (1 << i
)) {
1025 range
->freq
[val
].i
= i
+ 1;
1026 range
->freq
[val
].m
= freq_list
[i
] * 100000;
1027 range
->freq
[val
].e
= 1;
1030 if (val
== IW_MAX_FREQUENCIES
)
1033 range
->num_frequency
= val
;
1035 if (local
->sta_fw_ver
>= PRISM2_FW_VER(1,3,1)) {
1036 range
->max_qual
.qual
= 70; /* what is correct max? This was not
1037 * documented exactly. At least
1038 * 69 has been observed. */
1039 range
->max_qual
.level
= 0; /* dB */
1040 range
->max_qual
.noise
= 0; /* dB */
1042 /* What would be suitable values for "average/typical" qual? */
1043 range
->avg_qual
.qual
= 20;
1044 range
->avg_qual
.level
= -60;
1045 range
->avg_qual
.noise
= -95;
1047 range
->max_qual
.qual
= 92; /* 0 .. 92 */
1048 range
->max_qual
.level
= 154; /* 27 .. 154 */
1049 range
->max_qual
.noise
= 154; /* 27 .. 154 */
1051 range
->sensitivity
= 3;
1053 range
->max_encoding_tokens
= WEP_KEYS
;
1054 range
->num_encoding_sizes
= 2;
1055 range
->encoding_size
[0] = 5;
1056 range
->encoding_size
[1] = 13;
1059 len
= prism2_get_datarates(dev
, rates
);
1060 range
->num_bitrates
= 0;
1061 for (i
= 0; i
< len
; i
++) {
1062 if (range
->num_bitrates
< IW_MAX_BITRATES
) {
1063 range
->bitrate
[range
->num_bitrates
] =
1065 range
->num_bitrates
++;
1067 if (rates
[i
] == 0x0b || rates
[i
] == 0x16)
1070 /* estimated maximum TCP throughput values (bps) */
1071 range
->throughput
= over2
? 5500000 : 1500000;
1074 range
->max_rts
= 2347;
1075 range
->min_frag
= 256;
1076 range
->max_frag
= 2346;
1078 /* Event capability (kernel + driver) */
1079 range
->event_capa
[0] = (IW_EVENT_CAPA_K_0
|
1080 IW_EVENT_CAPA_MASK(SIOCGIWTHRSPY
) |
1081 IW_EVENT_CAPA_MASK(SIOCGIWAP
) |
1082 IW_EVENT_CAPA_MASK(SIOCGIWSCAN
));
1083 range
->event_capa
[1] = IW_EVENT_CAPA_K_1
;
1084 range
->event_capa
[4] = (IW_EVENT_CAPA_MASK(IWEVTXDROP
) |
1085 IW_EVENT_CAPA_MASK(IWEVCUSTOM
) |
1086 IW_EVENT_CAPA_MASK(IWEVREGISTERED
) |
1087 IW_EVENT_CAPA_MASK(IWEVEXPIRED
));
1089 range
->enc_capa
= IW_ENC_CAPA_WPA
| IW_ENC_CAPA_WPA2
|
1090 IW_ENC_CAPA_CIPHER_TKIP
| IW_ENC_CAPA_CIPHER_CCMP
;
1092 if (local
->sta_fw_ver
>= PRISM2_FW_VER(1,3,1))
1093 range
->scan_capa
= IW_SCAN_CAPA_ESSID
;
1099 static int hostap_monitor_mode_enable(local_info_t
*local
)
1101 struct net_device
*dev
= local
->dev
;
1103 printk(KERN_DEBUG
"Enabling monitor mode\n");
1104 hostap_monitor_set_type(local
);
1106 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
1107 HFA384X_PORTTYPE_PSEUDO_IBSS
)) {
1108 printk(KERN_DEBUG
"Port type setting for monitor mode "
1113 /* Host decrypt is needed to get the IV and ICV fields;
1114 * however, monitor mode seems to remove WEP flag from frame
1116 if (hostap_set_word(dev
, HFA384X_RID_CNFWEPFLAGS
,
1117 HFA384X_WEPFLAGS_HOSTENCRYPT
|
1118 HFA384X_WEPFLAGS_HOSTDECRYPT
)) {
1119 printk(KERN_DEBUG
"WEP flags setting failed\n");
1123 if (local
->func
->reset_port(dev
) ||
1124 local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
1125 (HFA384X_TEST_MONITOR
<< 8),
1127 printk(KERN_DEBUG
"Setting monitor mode failed\n");
1135 static int hostap_monitor_mode_disable(local_info_t
*local
)
1137 struct net_device
*dev
= local
->ddev
;
1142 printk(KERN_DEBUG
"%s: Disabling monitor mode\n", dev
->name
);
1143 dev
->type
= ARPHRD_ETHER
;
1145 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
1146 (HFA384X_TEST_STOP
<< 8),
1149 return hostap_set_encryption(local
);
1153 static int prism2_ioctl_siwmode(struct net_device
*dev
,
1154 struct iw_request_info
*info
,
1155 __u32
*mode
, char *extra
)
1157 struct hostap_interface
*iface
;
1158 local_info_t
*local
;
1159 int double_reset
= 0;
1161 iface
= netdev_priv(dev
);
1162 local
= iface
->local
;
1164 if (*mode
!= IW_MODE_ADHOC
&& *mode
!= IW_MODE_INFRA
&&
1165 *mode
!= IW_MODE_MASTER
&& *mode
!= IW_MODE_REPEAT
&&
1166 *mode
!= IW_MODE_MONITOR
)
1169 #ifdef PRISM2_NO_STATION_MODES
1170 if (*mode
== IW_MODE_ADHOC
|| *mode
== IW_MODE_INFRA
)
1172 #endif /* PRISM2_NO_STATION_MODES */
1174 if (*mode
== local
->iw_mode
)
1177 if (*mode
== IW_MODE_MASTER
&& local
->essid
[0] == '\0') {
1178 printk(KERN_WARNING
"%s: empty SSID not allowed in Master "
1179 "mode\n", dev
->name
);
1183 if (local
->iw_mode
== IW_MODE_MONITOR
)
1184 hostap_monitor_mode_disable(local
);
1186 if ((local
->iw_mode
== IW_MODE_ADHOC
||
1187 local
->iw_mode
== IW_MODE_MONITOR
) && *mode
== IW_MODE_MASTER
) {
1188 /* There seems to be a firmware bug in at least STA f/w v1.5.6
1189 * that leaves beacon frames to use IBSS type when moving from
1190 * IBSS to Host AP mode. Doing double Port0 reset seems to be
1191 * enough to workaround this. */
1195 printk(KERN_DEBUG
"prism2: %s: operating mode changed "
1196 "%d -> %d\n", dev
->name
, local
->iw_mode
, *mode
);
1197 local
->iw_mode
= *mode
;
1199 if (local
->iw_mode
== IW_MODE_MONITOR
)
1200 hostap_monitor_mode_enable(local
);
1201 else if (local
->iw_mode
== IW_MODE_MASTER
&& !local
->host_encrypt
&&
1202 !local
->fw_encrypt_ok
) {
1203 printk(KERN_DEBUG
"%s: defaulting to host-based encryption as "
1204 "a workaround for firmware bug in Host AP mode WEP\n",
1206 local
->host_encrypt
= 1;
1209 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
1210 hostap_get_porttype(local
)))
1213 if (local
->func
->reset_port(dev
))
1215 if (double_reset
&& local
->func
->reset_port(dev
))
1218 if (local
->iw_mode
!= IW_MODE_INFRA
&& local
->iw_mode
!= IW_MODE_ADHOC
)
1220 /* netif_carrier is used only in client modes for now, so make
1221 * sure carrier is on when moving to non-client modes. */
1222 netif_carrier_on(local
->dev
);
1223 netif_carrier_on(local
->ddev
);
1229 static int prism2_ioctl_giwmode(struct net_device
*dev
,
1230 struct iw_request_info
*info
,
1231 __u32
*mode
, char *extra
)
1233 struct hostap_interface
*iface
;
1234 local_info_t
*local
;
1236 iface
= netdev_priv(dev
);
1237 local
= iface
->local
;
1239 switch (iface
->type
) {
1240 case HOSTAP_INTERFACE_STA
:
1241 *mode
= IW_MODE_INFRA
;
1243 case HOSTAP_INTERFACE_WDS
:
1244 *mode
= IW_MODE_REPEAT
;
1247 *mode
= local
->iw_mode
;
1254 static int prism2_ioctl_siwpower(struct net_device
*dev
,
1255 struct iw_request_info
*info
,
1256 struct iw_param
*wrq
, char *extra
)
1258 #ifdef PRISM2_NO_STATION_MODES
1260 #else /* PRISM2_NO_STATION_MODES */
1264 return hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 0);
1266 switch (wrq
->flags
& IW_POWER_MODE
) {
1267 case IW_POWER_UNICAST_R
:
1268 ret
= hostap_set_word(dev
, HFA384X_RID_CNFMULTICASTRECEIVE
, 0);
1271 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 1);
1275 case IW_POWER_ALL_R
:
1276 ret
= hostap_set_word(dev
, HFA384X_RID_CNFMULTICASTRECEIVE
, 1);
1279 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 1);
1289 if (wrq
->flags
& IW_POWER_TIMEOUT
) {
1290 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 1);
1293 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMHOLDOVERDURATION
,
1298 if (wrq
->flags
& IW_POWER_PERIOD
) {
1299 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 1);
1302 ret
= hostap_set_word(dev
, HFA384X_RID_CNFMAXSLEEPDURATION
,
1309 #endif /* PRISM2_NO_STATION_MODES */
1313 static int prism2_ioctl_giwpower(struct net_device
*dev
,
1314 struct iw_request_info
*info
,
1315 struct iw_param
*rrq
, char *extra
)
1317 #ifdef PRISM2_NO_STATION_MODES
1319 #else /* PRISM2_NO_STATION_MODES */
1320 struct hostap_interface
*iface
;
1321 local_info_t
*local
;
1322 __le16 enable
, mcast
;
1324 iface
= netdev_priv(dev
);
1325 local
= iface
->local
;
1327 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFPMENABLED
, &enable
, 2, 1)
1331 if (!le16_to_cpu(enable
)) {
1338 if ((rrq
->flags
& IW_POWER_TYPE
) == IW_POWER_TIMEOUT
) {
1340 if (local
->func
->get_rid(dev
,
1341 HFA384X_RID_CNFPMHOLDOVERDURATION
,
1342 &timeout
, 2, 1) < 0)
1345 rrq
->flags
= IW_POWER_TIMEOUT
;
1346 rrq
->value
= le16_to_cpu(timeout
) * 1024;
1349 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFMAXSLEEPDURATION
,
1353 rrq
->flags
= IW_POWER_PERIOD
;
1354 rrq
->value
= le16_to_cpu(period
) * 1024;
1357 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFMULTICASTRECEIVE
, &mcast
,
1361 if (le16_to_cpu(mcast
))
1362 rrq
->flags
|= IW_POWER_ALL_R
;
1364 rrq
->flags
|= IW_POWER_UNICAST_R
;
1367 #endif /* PRISM2_NO_STATION_MODES */
1371 static int prism2_ioctl_siwretry(struct net_device
*dev
,
1372 struct iw_request_info
*info
,
1373 struct iw_param
*rrq
, char *extra
)
1375 struct hostap_interface
*iface
;
1376 local_info_t
*local
;
1378 iface
= netdev_priv(dev
);
1379 local
= iface
->local
;
1384 /* setting retry limits is not supported with the current station
1385 * firmware code; simulate this with alternative retry count for now */
1386 if (rrq
->flags
== IW_RETRY_LIMIT
) {
1387 if (rrq
->value
< 0) {
1388 /* disable manual retry count setting and use firmware
1390 local
->manual_retry_count
= -1;
1391 local
->tx_control
&= ~HFA384X_TX_CTRL_ALT_RTRY
;
1393 if (hostap_set_word(dev
, HFA384X_RID_CNFALTRETRYCOUNT
,
1395 printk(KERN_DEBUG
"%s: Alternate retry count "
1396 "setting to %d failed\n",
1397 dev
->name
, rrq
->value
);
1401 local
->manual_retry_count
= rrq
->value
;
1402 local
->tx_control
|= HFA384X_TX_CTRL_ALT_RTRY
;
1410 /* what could be done, if firmware would support this.. */
1412 if (rrq
->flags
& IW_RETRY_LIMIT
) {
1413 if (rrq
->flags
& IW_RETRY_LONG
)
1414 HFA384X_RID_LONGRETRYLIMIT
= rrq
->value
;
1415 else if (rrq
->flags
& IW_RETRY_SHORT
)
1416 HFA384X_RID_SHORTRETRYLIMIT
= rrq
->value
;
1418 HFA384X_RID_LONGRETRYLIMIT
= rrq
->value
;
1419 HFA384X_RID_SHORTRETRYLIMIT
= rrq
->value
;
1424 if (rrq
->flags
& IW_RETRY_LIFETIME
) {
1425 HFA384X_RID_MAXTRANSMITLIFETIME
= rrq
->value
/ 1024;
1432 static int prism2_ioctl_giwretry(struct net_device
*dev
,
1433 struct iw_request_info
*info
,
1434 struct iw_param
*rrq
, char *extra
)
1436 struct hostap_interface
*iface
;
1437 local_info_t
*local
;
1438 __le16 shortretry
, longretry
, lifetime
, altretry
;
1440 iface
= netdev_priv(dev
);
1441 local
= iface
->local
;
1443 if (local
->func
->get_rid(dev
, HFA384X_RID_SHORTRETRYLIMIT
, &shortretry
,
1445 local
->func
->get_rid(dev
, HFA384X_RID_LONGRETRYLIMIT
, &longretry
,
1447 local
->func
->get_rid(dev
, HFA384X_RID_MAXTRANSMITLIFETIME
,
1448 &lifetime
, 2, 1) < 0)
1453 if ((rrq
->flags
& IW_RETRY_TYPE
) == IW_RETRY_LIFETIME
) {
1454 rrq
->flags
= IW_RETRY_LIFETIME
;
1455 rrq
->value
= le16_to_cpu(lifetime
) * 1024;
1457 if (local
->manual_retry_count
>= 0) {
1458 rrq
->flags
= IW_RETRY_LIMIT
;
1459 if (local
->func
->get_rid(dev
,
1460 HFA384X_RID_CNFALTRETRYCOUNT
,
1461 &altretry
, 2, 1) >= 0)
1462 rrq
->value
= le16_to_cpu(altretry
);
1464 rrq
->value
= local
->manual_retry_count
;
1465 } else if ((rrq
->flags
& IW_RETRY_LONG
)) {
1466 rrq
->flags
= IW_RETRY_LIMIT
| IW_RETRY_LONG
;
1467 rrq
->value
= le16_to_cpu(longretry
);
1469 rrq
->flags
= IW_RETRY_LIMIT
;
1470 rrq
->value
= le16_to_cpu(shortretry
);
1471 if (shortretry
!= longretry
)
1472 rrq
->flags
|= IW_RETRY_SHORT
;
1479 /* Note! This TX power controlling is experimental and should not be used in
1480 * production use. It just sets raw power register and does not use any kind of
1481 * feedback information from the measured TX power (CR58). This is now
1482 * commented out to make sure that it is not used by accident. TX power
1483 * configuration will be enabled again after proper algorithm using feedback
1484 * has been implemented. */
1486 #ifdef RAW_TXPOWER_SETTING
1487 /* Map HFA386x's CR31 to and from dBm with some sort of ad hoc mapping..
1488 * This version assumes following mapping:
1489 * CR31 is 7-bit value with -64 to +63 range.
1490 * -64 is mapped into +20dBm and +63 into -43dBm.
1491 * This is certainly not an exact mapping for every card, but at least
1492 * increasing dBm value should correspond to increasing TX power.
1495 static int prism2_txpower_hfa386x_to_dBm(u16 val
)
1508 static u16
prism2_txpower_dBm_to_hfa386x(int val
)
1521 return (unsigned char) tmp
;
1523 #endif /* RAW_TXPOWER_SETTING */
1526 static int prism2_ioctl_siwtxpow(struct net_device
*dev
,
1527 struct iw_request_info
*info
,
1528 struct iw_param
*rrq
, char *extra
)
1530 struct hostap_interface
*iface
;
1531 local_info_t
*local
;
1532 #ifdef RAW_TXPOWER_SETTING
1538 iface
= netdev_priv(dev
);
1539 local
= iface
->local
;
1541 if (rrq
->disabled
) {
1542 if (local
->txpower_type
!= PRISM2_TXPOWER_OFF
) {
1543 val
= 0xff; /* use all standby and sleep modes */
1544 ret
= local
->func
->cmd(dev
, HFA384X_CMDCODE_WRITEMIF
,
1545 HFA386X_CR_A_D_TEST_MODES2
,
1547 printk(KERN_DEBUG
"%s: Turning radio off: %s\n",
1548 dev
->name
, ret
? "failed" : "OK");
1549 local
->txpower_type
= PRISM2_TXPOWER_OFF
;
1551 return (ret
? -EOPNOTSUPP
: 0);
1554 if (local
->txpower_type
== PRISM2_TXPOWER_OFF
) {
1555 val
= 0; /* disable all standby and sleep modes */
1556 ret
= local
->func
->cmd(dev
, HFA384X_CMDCODE_WRITEMIF
,
1557 HFA386X_CR_A_D_TEST_MODES2
, &val
, NULL
);
1558 printk(KERN_DEBUG
"%s: Turning radio on: %s\n",
1559 dev
->name
, ret
? "failed" : "OK");
1560 local
->txpower_type
= PRISM2_TXPOWER_UNKNOWN
;
1563 #ifdef RAW_TXPOWER_SETTING
1564 if (!rrq
->fixed
&& local
->txpower_type
!= PRISM2_TXPOWER_AUTO
) {
1565 printk(KERN_DEBUG
"Setting ALC on\n");
1566 val
= HFA384X_TEST_CFG_BIT_ALC
;
1567 local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
1568 (HFA384X_TEST_CFG_BITS
<< 8), 1, &val
, NULL
);
1569 local
->txpower_type
= PRISM2_TXPOWER_AUTO
;
1573 if (local
->txpower_type
!= PRISM2_TXPOWER_FIXED
) {
1574 printk(KERN_DEBUG
"Setting ALC off\n");
1575 val
= HFA384X_TEST_CFG_BIT_ALC
;
1576 local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
1577 (HFA384X_TEST_CFG_BITS
<< 8), 0, &val
, NULL
);
1578 local
->txpower_type
= PRISM2_TXPOWER_FIXED
;
1581 if (rrq
->flags
== IW_TXPOW_DBM
)
1583 else if (rrq
->flags
== IW_TXPOW_MWATT
)
1587 printk(KERN_DEBUG
"Setting TX power to %d %s\n", rrq
->value
, tmp
);
1589 if (rrq
->flags
!= IW_TXPOW_DBM
) {
1590 printk("SIOCSIWTXPOW with mW is not supported; use dBm\n");
1594 local
->txpower
= rrq
->value
;
1595 val
= prism2_txpower_dBm_to_hfa386x(local
->txpower
);
1596 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_WRITEMIF
,
1597 HFA386X_CR_MANUAL_TX_POWER
, &val
, NULL
))
1599 #else /* RAW_TXPOWER_SETTING */
1602 #endif /* RAW_TXPOWER_SETTING */
1607 static int prism2_ioctl_giwtxpow(struct net_device
*dev
,
1608 struct iw_request_info
*info
,
1609 struct iw_param
*rrq
, char *extra
)
1611 #ifdef RAW_TXPOWER_SETTING
1612 struct hostap_interface
*iface
;
1613 local_info_t
*local
;
1616 iface
= netdev_priv(dev
);
1617 local
= iface
->local
;
1619 rrq
->flags
= IW_TXPOW_DBM
;
1623 if (local
->txpower_type
== PRISM2_TXPOWER_AUTO
) {
1624 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_READMIF
,
1625 HFA386X_CR_MANUAL_TX_POWER
,
1626 NULL
, &resp0
) == 0) {
1627 rrq
->value
= prism2_txpower_hfa386x_to_dBm(resp0
);
1629 /* Could not get real txpower; guess 15 dBm */
1632 } else if (local
->txpower_type
== PRISM2_TXPOWER_OFF
) {
1635 } else if (local
->txpower_type
== PRISM2_TXPOWER_FIXED
) {
1636 rrq
->value
= local
->txpower
;
1639 printk("SIOCGIWTXPOW - unknown txpower_type=%d\n",
1640 local
->txpower_type
);
1643 #else /* RAW_TXPOWER_SETTING */
1645 #endif /* RAW_TXPOWER_SETTING */
1649 #ifndef PRISM2_NO_STATION_MODES
1651 /* HostScan request works with and without host_roaming mode. In addition, it
1652 * does not break current association. However, it requires newer station
1653 * firmware version (>= 1.3.1) than scan request. */
1654 static int prism2_request_hostscan(struct net_device
*dev
,
1655 u8
*ssid
, u8 ssid_len
)
1657 struct hostap_interface
*iface
;
1658 local_info_t
*local
;
1659 struct hfa384x_hostscan_request scan_req
;
1661 iface
= netdev_priv(dev
);
1662 local
= iface
->local
;
1664 memset(&scan_req
, 0, sizeof(scan_req
));
1665 scan_req
.channel_list
= cpu_to_le16(local
->channel_mask
&
1666 local
->scan_channel_mask
);
1667 scan_req
.txrate
= __constant_cpu_to_le16(HFA384X_RATES_1MBPS
);
1671 scan_req
.target_ssid_len
= cpu_to_le16(ssid_len
);
1672 memcpy(scan_req
.target_ssid
, ssid
, ssid_len
);
1675 if (local
->func
->set_rid(dev
, HFA384X_RID_HOSTSCAN
, &scan_req
,
1676 sizeof(scan_req
))) {
1677 printk(KERN_DEBUG
"%s: HOSTSCAN failed\n", dev
->name
);
1684 static int prism2_request_scan(struct net_device
*dev
)
1686 struct hostap_interface
*iface
;
1687 local_info_t
*local
;
1688 struct hfa384x_scan_request scan_req
;
1691 iface
= netdev_priv(dev
);
1692 local
= iface
->local
;
1694 memset(&scan_req
, 0, sizeof(scan_req
));
1695 scan_req
.channel_list
= cpu_to_le16(local
->channel_mask
&
1696 local
->scan_channel_mask
);
1697 scan_req
.txrate
= __constant_cpu_to_le16(HFA384X_RATES_1MBPS
);
1700 * It seems to be enough to set roaming mode for a short moment to
1701 * host-based and then setup scanrequest data and return the mode to
1704 * Master mode would need to drop to Managed mode for a short while
1705 * to make scanning work.. Or sweep through the different channels and
1706 * use passive scan based on beacons. */
1708 if (!local
->host_roaming
)
1709 hostap_set_word(dev
, HFA384X_RID_CNFROAMINGMODE
,
1710 HFA384X_ROAMING_HOST
);
1712 if (local
->func
->set_rid(dev
, HFA384X_RID_SCANREQUEST
, &scan_req
,
1713 sizeof(scan_req
))) {
1714 printk(KERN_DEBUG
"SCANREQUEST failed\n");
1718 if (!local
->host_roaming
)
1719 hostap_set_word(dev
, HFA384X_RID_CNFROAMINGMODE
,
1720 HFA384X_ROAMING_FIRMWARE
);
1725 #else /* !PRISM2_NO_STATION_MODES */
1727 static inline int prism2_request_hostscan(struct net_device
*dev
,
1728 u8
*ssid
, u8 ssid_len
)
1734 static inline int prism2_request_scan(struct net_device
*dev
)
1739 #endif /* !PRISM2_NO_STATION_MODES */
1742 static int prism2_ioctl_siwscan(struct net_device
*dev
,
1743 struct iw_request_info
*info
,
1744 struct iw_point
*data
, char *extra
)
1746 struct hostap_interface
*iface
;
1747 local_info_t
*local
;
1749 u8
*ssid
= NULL
, ssid_len
= 0;
1750 struct iw_scan_req
*req
= (struct iw_scan_req
*) extra
;
1752 iface
= netdev_priv(dev
);
1753 local
= iface
->local
;
1755 if (data
->length
< sizeof(struct iw_scan_req
))
1758 if (local
->iw_mode
== IW_MODE_MASTER
) {
1759 /* In master mode, we just return the results of our local
1760 * tables, so we don't need to start anything...
1766 if (!local
->dev_enabled
)
1769 if (req
&& data
->flags
& IW_SCAN_THIS_ESSID
) {
1771 ssid_len
= req
->essid_len
;
1774 ((local
->iw_mode
!= IW_MODE_INFRA
&&
1775 local
->iw_mode
!= IW_MODE_ADHOC
) ||
1776 (local
->sta_fw_ver
< PRISM2_FW_VER(1,3,1))))
1780 if (local
->sta_fw_ver
>= PRISM2_FW_VER(1,3,1))
1781 ret
= prism2_request_hostscan(dev
, ssid
, ssid_len
);
1783 ret
= prism2_request_scan(dev
);
1786 local
->scan_timestamp
= jiffies
;
1788 /* Could inquire F101, F103 or wait for SIOCGIWSCAN and read RID */
1794 #ifndef PRISM2_NO_STATION_MODES
1795 static char * __prism2_translate_scan(local_info_t
*local
,
1796 struct iw_request_info
*info
,
1797 struct hfa384x_hostscan_result
*scan
,
1798 struct hostap_bss_info
*bss
,
1799 char *current_ev
, char *end_buf
)
1802 struct iw_event iwe
;
1812 ssid_len
= bss
->ssid_len
;
1816 ssid_len
= le16_to_cpu(scan
->ssid_len
);
1817 bssid
= scan
->bssid
;
1822 /* First entry *MUST* be the AP MAC address */
1823 memset(&iwe
, 0, sizeof(iwe
));
1824 iwe
.cmd
= SIOCGIWAP
;
1825 iwe
.u
.ap_addr
.sa_family
= ARPHRD_ETHER
;
1826 memcpy(iwe
.u
.ap_addr
.sa_data
, bssid
, ETH_ALEN
);
1827 current_ev
= iwe_stream_add_event(info
, current_ev
, end_buf
, &iwe
,
1830 /* Other entries will be displayed in the order we give them */
1832 memset(&iwe
, 0, sizeof(iwe
));
1833 iwe
.cmd
= SIOCGIWESSID
;
1834 iwe
.u
.data
.length
= ssid_len
;
1835 iwe
.u
.data
.flags
= 1;
1836 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1839 memset(&iwe
, 0, sizeof(iwe
));
1840 iwe
.cmd
= SIOCGIWMODE
;
1842 capabilities
= bss
->capab_info
;
1844 capabilities
= le16_to_cpu(scan
->capability
);
1846 if (capabilities
& (WLAN_CAPABILITY_ESS
|
1847 WLAN_CAPABILITY_IBSS
)) {
1848 if (capabilities
& WLAN_CAPABILITY_ESS
)
1849 iwe
.u
.mode
= IW_MODE_MASTER
;
1851 iwe
.u
.mode
= IW_MODE_ADHOC
;
1852 current_ev
= iwe_stream_add_event(info
, current_ev
, end_buf
,
1853 &iwe
, IW_EV_UINT_LEN
);
1856 memset(&iwe
, 0, sizeof(iwe
));
1857 iwe
.cmd
= SIOCGIWFREQ
;
1859 chan
= le16_to_cpu(scan
->chid
);
1867 iwe
.u
.freq
.m
= freq_list
[chan
- 1] * 100000;
1869 current_ev
= iwe_stream_add_event(info
, current_ev
, end_buf
,
1870 &iwe
, IW_EV_FREQ_LEN
);
1874 memset(&iwe
, 0, sizeof(iwe
));
1876 if (local
->last_scan_type
== PRISM2_HOSTSCAN
) {
1877 iwe
.u
.qual
.level
= le16_to_cpu(scan
->sl
);
1878 iwe
.u
.qual
.noise
= le16_to_cpu(scan
->anl
);
1881 HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan
->sl
));
1883 HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan
->anl
));
1885 iwe
.u
.qual
.updated
= IW_QUAL_LEVEL_UPDATED
1886 | IW_QUAL_NOISE_UPDATED
1887 | IW_QUAL_QUAL_INVALID
1889 current_ev
= iwe_stream_add_event(info
, current_ev
, end_buf
,
1890 &iwe
, IW_EV_QUAL_LEN
);
1893 memset(&iwe
, 0, sizeof(iwe
));
1894 iwe
.cmd
= SIOCGIWENCODE
;
1895 if (capabilities
& WLAN_CAPABILITY_PRIVACY
)
1896 iwe
.u
.data
.flags
= IW_ENCODE_ENABLED
| IW_ENCODE_NOKEY
;
1898 iwe
.u
.data
.flags
= IW_ENCODE_DISABLED
;
1899 iwe
.u
.data
.length
= 0;
1900 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
, &iwe
, "");
1902 /* TODO: add SuppRates into BSS table */
1904 memset(&iwe
, 0, sizeof(iwe
));
1905 iwe
.cmd
= SIOCGIWRATE
;
1906 current_val
= current_ev
+ iwe_stream_lcp_len(info
);
1907 pos
= scan
->sup_rates
;
1908 for (i
= 0; i
< sizeof(scan
->sup_rates
); i
++) {
1911 /* Bit rate given in 500 kb/s units (+ 0x80) */
1912 iwe
.u
.bitrate
.value
= ((pos
[i
] & 0x7f) * 500000);
1913 current_val
= iwe_stream_add_value(
1914 info
, current_ev
, current_val
, end_buf
, &iwe
,
1917 /* Check if we added any event */
1918 if ((current_val
- current_ev
) > iwe_stream_lcp_len(info
))
1919 current_ev
= current_val
;
1922 /* TODO: add BeaconInt,resp_rate,atim into BSS table */
1923 buf
= kmalloc(MAX_WPA_IE_LEN
* 2 + 30, GFP_ATOMIC
);
1925 memset(&iwe
, 0, sizeof(iwe
));
1926 iwe
.cmd
= IWEVCUSTOM
;
1927 sprintf(buf
, "bcn_int=%d", le16_to_cpu(scan
->beacon_interval
));
1928 iwe
.u
.data
.length
= strlen(buf
);
1929 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1932 memset(&iwe
, 0, sizeof(iwe
));
1933 iwe
.cmd
= IWEVCUSTOM
;
1934 sprintf(buf
, "resp_rate=%d", le16_to_cpu(scan
->rate
));
1935 iwe
.u
.data
.length
= strlen(buf
);
1936 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1939 if (local
->last_scan_type
== PRISM2_HOSTSCAN
&&
1940 (capabilities
& WLAN_CAPABILITY_IBSS
)) {
1941 memset(&iwe
, 0, sizeof(iwe
));
1942 iwe
.cmd
= IWEVCUSTOM
;
1943 sprintf(buf
, "atim=%d", le16_to_cpu(scan
->atim
));
1944 iwe
.u
.data
.length
= strlen(buf
);
1945 current_ev
= iwe_stream_add_point(info
, current_ev
,
1946 end_buf
, &iwe
, buf
);
1951 if (bss
&& bss
->wpa_ie_len
> 0 && bss
->wpa_ie_len
<= MAX_WPA_IE_LEN
) {
1952 memset(&iwe
, 0, sizeof(iwe
));
1953 iwe
.cmd
= IWEVGENIE
;
1954 iwe
.u
.data
.length
= bss
->wpa_ie_len
;
1955 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1959 if (bss
&& bss
->rsn_ie_len
> 0 && bss
->rsn_ie_len
<= MAX_WPA_IE_LEN
) {
1960 memset(&iwe
, 0, sizeof(iwe
));
1961 iwe
.cmd
= IWEVGENIE
;
1962 iwe
.u
.data
.length
= bss
->rsn_ie_len
;
1963 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1971 /* Translate scan data returned from the card to a card independant
1972 * format that the Wireless Tools will understand - Jean II */
1973 static inline int prism2_translate_scan(local_info_t
*local
,
1974 struct iw_request_info
*info
,
1975 char *buffer
, int buflen
)
1977 struct hfa384x_hostscan_result
*scan
;
1978 int entry
, hostscan
;
1979 char *current_ev
= buffer
;
1980 char *end_buf
= buffer
+ buflen
;
1981 struct list_head
*ptr
;
1983 spin_lock_bh(&local
->lock
);
1985 list_for_each(ptr
, &local
->bss_list
) {
1986 struct hostap_bss_info
*bss
;
1987 bss
= list_entry(ptr
, struct hostap_bss_info
, list
);
1991 hostscan
= local
->last_scan_type
== PRISM2_HOSTSCAN
;
1992 for (entry
= 0; entry
< local
->last_scan_results_count
; entry
++) {
1994 scan
= &local
->last_scan_results
[entry
];
1996 /* Report every SSID if the AP is using multiple SSIDs. If no
1997 * BSS record is found (e.g., when WPA mode is disabled),
1998 * report the AP once. */
1999 list_for_each(ptr
, &local
->bss_list
) {
2000 struct hostap_bss_info
*bss
;
2001 bss
= list_entry(ptr
, struct hostap_bss_info
, list
);
2002 if (memcmp(bss
->bssid
, scan
->bssid
, ETH_ALEN
) == 0) {
2004 current_ev
= __prism2_translate_scan(
2005 local
, info
, scan
, bss
, current_ev
,
2011 current_ev
= __prism2_translate_scan(
2012 local
, info
, scan
, NULL
, current_ev
, end_buf
);
2014 /* Check if there is space for one more entry */
2015 if ((end_buf
- current_ev
) <= IW_EV_ADDR_LEN
) {
2016 /* Ask user space to try again with a bigger buffer */
2017 spin_unlock_bh(&local
->lock
);
2022 /* Prism2 firmware has limits (32 at least in some versions) for number
2023 * of BSSes in scan results. Extend this limit by using local BSS list.
2025 list_for_each(ptr
, &local
->bss_list
) {
2026 struct hostap_bss_info
*bss
;
2027 bss
= list_entry(ptr
, struct hostap_bss_info
, list
);
2030 current_ev
= __prism2_translate_scan(local
, info
, NULL
, bss
,
2031 current_ev
, end_buf
);
2032 /* Check if there is space for one more entry */
2033 if ((end_buf
- current_ev
) <= IW_EV_ADDR_LEN
) {
2034 /* Ask user space to try again with a bigger buffer */
2035 spin_unlock_bh(&local
->lock
);
2040 spin_unlock_bh(&local
->lock
);
2042 return current_ev
- buffer
;
2044 #endif /* PRISM2_NO_STATION_MODES */
2047 static inline int prism2_ioctl_giwscan_sta(struct net_device
*dev
,
2048 struct iw_request_info
*info
,
2049 struct iw_point
*data
, char *extra
)
2051 #ifdef PRISM2_NO_STATION_MODES
2053 #else /* PRISM2_NO_STATION_MODES */
2054 struct hostap_interface
*iface
;
2055 local_info_t
*local
;
2058 iface
= netdev_priv(dev
);
2059 local
= iface
->local
;
2061 /* Wait until the scan is finished. We can probably do better
2062 * than that - Jean II */
2063 if (local
->scan_timestamp
&&
2064 time_before(jiffies
, local
->scan_timestamp
+ 3 * HZ
)) {
2065 /* Important note : we don't want to block the caller
2066 * until results are ready for various reasons.
2067 * First, managing wait queues is complex and racy
2068 * (there may be multiple simultaneous callers).
2069 * Second, we grab some rtnetlink lock before comming
2070 * here (in dev_ioctl()).
2071 * Third, the caller can wait on the Wireless Event
2075 local
->scan_timestamp
= 0;
2077 res
= prism2_translate_scan(local
, info
, extra
, data
->length
);
2086 #endif /* PRISM2_NO_STATION_MODES */
2090 static int prism2_ioctl_giwscan(struct net_device
*dev
,
2091 struct iw_request_info
*info
,
2092 struct iw_point
*data
, char *extra
)
2094 struct hostap_interface
*iface
;
2095 local_info_t
*local
;
2098 iface
= netdev_priv(dev
);
2099 local
= iface
->local
;
2101 if (local
->iw_mode
== IW_MODE_MASTER
) {
2102 /* In MASTER mode, it doesn't make sense to go around
2103 * scanning the frequencies and make the stations we serve
2104 * wait when what the user is really interested about is the
2105 * list of stations and access points we are talking to.
2106 * So, just extract results from our cache...
2109 /* Translate to WE format */
2110 res
= prism2_ap_translate_scan(dev
, info
, extra
);
2112 printk(KERN_DEBUG
"Scan result translation succeeded "
2113 "(length=%d)\n", res
);
2118 "Scan result translation failed (res=%d)\n",
2125 return prism2_ioctl_giwscan_sta(dev
, info
, data
, extra
);
2130 static const struct iw_priv_args prism2_priv
[] = {
2131 { PRISM2_IOCTL_MONITOR
,
2132 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "monitor" },
2133 { PRISM2_IOCTL_READMIF
,
2134 IW_PRIV_TYPE_BYTE
| IW_PRIV_SIZE_FIXED
| 1,
2135 IW_PRIV_TYPE_BYTE
| IW_PRIV_SIZE_FIXED
| 1, "readmif" },
2136 { PRISM2_IOCTL_WRITEMIF
,
2137 IW_PRIV_TYPE_BYTE
| IW_PRIV_SIZE_FIXED
| 2, 0, "writemif" },
2138 { PRISM2_IOCTL_RESET
,
2139 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "reset" },
2140 { PRISM2_IOCTL_INQUIRE
,
2141 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "inquire" },
2142 { PRISM2_IOCTL_SET_RID_WORD
,
2143 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 2, 0, "set_rid_word" },
2144 { PRISM2_IOCTL_MACCMD
,
2145 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "maccmd" },
2146 { PRISM2_IOCTL_WDS_ADD
,
2147 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "wds_add" },
2148 { PRISM2_IOCTL_WDS_DEL
,
2149 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "wds_del" },
2150 { PRISM2_IOCTL_ADDMAC
,
2151 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "addmac" },
2152 { PRISM2_IOCTL_DELMAC
,
2153 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "delmac" },
2154 { PRISM2_IOCTL_KICKMAC
,
2155 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "kickmac" },
2156 /* --- raw access to sub-ioctls --- */
2157 { PRISM2_IOCTL_PRISM2_PARAM
,
2158 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 2, 0, "prism2_param" },
2159 { PRISM2_IOCTL_GET_PRISM2_PARAM
,
2160 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1,
2161 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getprism2_param" },
2162 /* --- sub-ioctls handlers --- */
2163 { PRISM2_IOCTL_PRISM2_PARAM
,
2164 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "" },
2165 { PRISM2_IOCTL_GET_PRISM2_PARAM
,
2166 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "" },
2167 /* --- sub-ioctls definitions --- */
2168 { PRISM2_PARAM_TXRATECTRL
,
2169 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "txratectrl" },
2170 { PRISM2_PARAM_TXRATECTRL
,
2171 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gettxratectrl" },
2172 { PRISM2_PARAM_BEACON_INT
,
2173 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "beacon_int" },
2174 { PRISM2_PARAM_BEACON_INT
,
2175 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getbeacon_int" },
2176 #ifndef PRISM2_NO_STATION_MODES
2177 { PRISM2_PARAM_PSEUDO_IBSS
,
2178 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "pseudo_ibss" },
2179 { PRISM2_PARAM_PSEUDO_IBSS
,
2180 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getpseudo_ibss" },
2181 #endif /* PRISM2_NO_STATION_MODES */
2183 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "alc" },
2185 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getalc" },
2186 { PRISM2_PARAM_DUMP
,
2187 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "dump" },
2188 { PRISM2_PARAM_DUMP
,
2189 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getdump" },
2190 { PRISM2_PARAM_OTHER_AP_POLICY
,
2191 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "other_ap_policy" },
2192 { PRISM2_PARAM_OTHER_AP_POLICY
,
2193 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getother_ap_pol" },
2194 { PRISM2_PARAM_AP_MAX_INACTIVITY
,
2195 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "max_inactivity" },
2196 { PRISM2_PARAM_AP_MAX_INACTIVITY
,
2197 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getmax_inactivi" },
2198 { PRISM2_PARAM_AP_BRIDGE_PACKETS
,
2199 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "bridge_packets" },
2200 { PRISM2_PARAM_AP_BRIDGE_PACKETS
,
2201 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getbridge_packe" },
2202 { PRISM2_PARAM_DTIM_PERIOD
,
2203 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "dtim_period" },
2204 { PRISM2_PARAM_DTIM_PERIOD
,
2205 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getdtim_period" },
2206 { PRISM2_PARAM_AP_NULLFUNC_ACK
,
2207 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "nullfunc_ack" },
2208 { PRISM2_PARAM_AP_NULLFUNC_ACK
,
2209 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getnullfunc_ack" },
2210 { PRISM2_PARAM_MAX_WDS
,
2211 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "max_wds" },
2212 { PRISM2_PARAM_MAX_WDS
,
2213 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getmax_wds" },
2214 { PRISM2_PARAM_AP_AUTOM_AP_WDS
,
2215 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "autom_ap_wds" },
2216 { PRISM2_PARAM_AP_AUTOM_AP_WDS
,
2217 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getautom_ap_wds" },
2218 { PRISM2_PARAM_AP_AUTH_ALGS
,
2219 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "ap_auth_algs" },
2220 { PRISM2_PARAM_AP_AUTH_ALGS
,
2221 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getap_auth_algs" },
2222 { PRISM2_PARAM_MONITOR_ALLOW_FCSERR
,
2223 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "allow_fcserr" },
2224 { PRISM2_PARAM_MONITOR_ALLOW_FCSERR
,
2225 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getallow_fcserr" },
2226 { PRISM2_PARAM_HOST_ENCRYPT
,
2227 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "host_encrypt" },
2228 { PRISM2_PARAM_HOST_ENCRYPT
,
2229 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethost_encrypt" },
2230 { PRISM2_PARAM_HOST_DECRYPT
,
2231 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "host_decrypt" },
2232 { PRISM2_PARAM_HOST_DECRYPT
,
2233 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethost_decrypt" },
2234 #ifndef PRISM2_NO_STATION_MODES
2235 { PRISM2_PARAM_HOST_ROAMING
,
2236 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "host_roaming" },
2237 { PRISM2_PARAM_HOST_ROAMING
,
2238 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethost_roaming" },
2239 #endif /* PRISM2_NO_STATION_MODES */
2240 { PRISM2_PARAM_BCRX_STA_KEY
,
2241 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "bcrx_sta_key" },
2242 { PRISM2_PARAM_BCRX_STA_KEY
,
2243 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getbcrx_sta_key" },
2244 { PRISM2_PARAM_IEEE_802_1X
,
2245 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "ieee_802_1x" },
2246 { PRISM2_PARAM_IEEE_802_1X
,
2247 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getieee_802_1x" },
2248 { PRISM2_PARAM_ANTSEL_TX
,
2249 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "antsel_tx" },
2250 { PRISM2_PARAM_ANTSEL_TX
,
2251 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getantsel_tx" },
2252 { PRISM2_PARAM_ANTSEL_RX
,
2253 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "antsel_rx" },
2254 { PRISM2_PARAM_ANTSEL_RX
,
2255 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getantsel_rx" },
2256 { PRISM2_PARAM_MONITOR_TYPE
,
2257 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "monitor_type" },
2258 { PRISM2_PARAM_MONITOR_TYPE
,
2259 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getmonitor_type" },
2260 { PRISM2_PARAM_WDS_TYPE
,
2261 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "wds_type" },
2262 { PRISM2_PARAM_WDS_TYPE
,
2263 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getwds_type" },
2264 { PRISM2_PARAM_HOSTSCAN
,
2265 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "hostscan" },
2266 { PRISM2_PARAM_HOSTSCAN
,
2267 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethostscan" },
2268 { PRISM2_PARAM_AP_SCAN
,
2269 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "ap_scan" },
2270 { PRISM2_PARAM_AP_SCAN
,
2271 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getap_scan" },
2272 { PRISM2_PARAM_ENH_SEC
,
2273 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "enh_sec" },
2274 { PRISM2_PARAM_ENH_SEC
,
2275 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getenh_sec" },
2276 #ifdef PRISM2_IO_DEBUG
2277 { PRISM2_PARAM_IO_DEBUG
,
2278 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "io_debug" },
2279 { PRISM2_PARAM_IO_DEBUG
,
2280 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getio_debug" },
2281 #endif /* PRISM2_IO_DEBUG */
2282 { PRISM2_PARAM_BASIC_RATES
,
2283 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "basic_rates" },
2284 { PRISM2_PARAM_BASIC_RATES
,
2285 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getbasic_rates" },
2286 { PRISM2_PARAM_OPER_RATES
,
2287 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "oper_rates" },
2288 { PRISM2_PARAM_OPER_RATES
,
2289 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getoper_rates" },
2290 { PRISM2_PARAM_HOSTAPD
,
2291 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "hostapd" },
2292 { PRISM2_PARAM_HOSTAPD
,
2293 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethostapd" },
2294 { PRISM2_PARAM_HOSTAPD_STA
,
2295 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "hostapd_sta" },
2296 { PRISM2_PARAM_HOSTAPD_STA
,
2297 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethostapd_sta" },
2299 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "wpa" },
2301 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getwpa" },
2302 { PRISM2_PARAM_PRIVACY_INVOKED
,
2303 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "privacy_invoked" },
2304 { PRISM2_PARAM_PRIVACY_INVOKED
,
2305 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getprivacy_invo" },
2306 { PRISM2_PARAM_TKIP_COUNTERMEASURES
,
2307 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "tkip_countermea" },
2308 { PRISM2_PARAM_TKIP_COUNTERMEASURES
,
2309 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gettkip_counter" },
2310 { PRISM2_PARAM_DROP_UNENCRYPTED
,
2311 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "drop_unencrypte" },
2312 { PRISM2_PARAM_DROP_UNENCRYPTED
,
2313 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getdrop_unencry" },
2314 { PRISM2_PARAM_SCAN_CHANNEL_MASK
,
2315 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "scan_channels" },
2316 { PRISM2_PARAM_SCAN_CHANNEL_MASK
,
2317 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getscan_channel" },
2321 static int prism2_ioctl_priv_inquire(struct net_device
*dev
, int *i
)
2323 struct hostap_interface
*iface
;
2324 local_info_t
*local
;
2326 iface
= netdev_priv(dev
);
2327 local
= iface
->local
;
2329 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_INQUIRE
, *i
, NULL
, NULL
))
2336 static int prism2_ioctl_priv_prism2_param(struct net_device
*dev
,
2337 struct iw_request_info
*info
,
2338 void *wrqu
, char *extra
)
2340 struct hostap_interface
*iface
;
2341 local_info_t
*local
;
2342 int *i
= (int *) extra
;
2344 int value
= *(i
+ 1);
2348 iface
= netdev_priv(dev
);
2349 local
= iface
->local
;
2352 case PRISM2_PARAM_TXRATECTRL
:
2353 local
->fw_tx_rate_control
= value
;
2356 case PRISM2_PARAM_BEACON_INT
:
2357 if (hostap_set_word(dev
, HFA384X_RID_CNFBEACONINT
, value
) ||
2358 local
->func
->reset_port(dev
))
2361 local
->beacon_int
= value
;
2364 #ifndef PRISM2_NO_STATION_MODES
2365 case PRISM2_PARAM_PSEUDO_IBSS
:
2366 if (value
== local
->pseudo_adhoc
)
2369 if (value
!= 0 && value
!= 1) {
2374 printk(KERN_DEBUG
"prism2: %s: pseudo IBSS change %d -> %d\n",
2375 dev
->name
, local
->pseudo_adhoc
, value
);
2376 local
->pseudo_adhoc
= value
;
2377 if (local
->iw_mode
!= IW_MODE_ADHOC
)
2380 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
2381 hostap_get_porttype(local
))) {
2386 if (local
->func
->reset_port(dev
))
2389 #endif /* PRISM2_NO_STATION_MODES */
2391 case PRISM2_PARAM_ALC
:
2392 printk(KERN_DEBUG
"%s: %s ALC\n", dev
->name
,
2393 value
== 0 ? "Disabling" : "Enabling");
2394 val
= HFA384X_TEST_CFG_BIT_ALC
;
2395 local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
2396 (HFA384X_TEST_CFG_BITS
<< 8),
2397 value
== 0 ? 0 : 1, &val
, NULL
);
2400 case PRISM2_PARAM_DUMP
:
2401 local
->frame_dump
= value
;
2404 case PRISM2_PARAM_OTHER_AP_POLICY
:
2405 if (value
< 0 || value
> 3) {
2409 if (local
->ap
!= NULL
)
2410 local
->ap
->ap_policy
= value
;
2413 case PRISM2_PARAM_AP_MAX_INACTIVITY
:
2414 if (value
< 0 || value
> 7 * 24 * 60 * 60) {
2418 if (local
->ap
!= NULL
)
2419 local
->ap
->max_inactivity
= value
* HZ
;
2422 case PRISM2_PARAM_AP_BRIDGE_PACKETS
:
2423 if (local
->ap
!= NULL
)
2424 local
->ap
->bridge_packets
= value
;
2427 case PRISM2_PARAM_DTIM_PERIOD
:
2428 if (value
< 0 || value
> 65535) {
2432 if (hostap_set_word(dev
, HFA384X_RID_CNFOWNDTIMPERIOD
, value
)
2433 || local
->func
->reset_port(dev
))
2436 local
->dtim_period
= value
;
2439 case PRISM2_PARAM_AP_NULLFUNC_ACK
:
2440 if (local
->ap
!= NULL
)
2441 local
->ap
->nullfunc_ack
= value
;
2444 case PRISM2_PARAM_MAX_WDS
:
2445 local
->wds_max_connections
= value
;
2448 case PRISM2_PARAM_AP_AUTOM_AP_WDS
:
2449 if (local
->ap
!= NULL
) {
2450 if (!local
->ap
->autom_ap_wds
&& value
) {
2451 /* add WDS link to all APs in STA table */
2452 hostap_add_wds_links(local
);
2454 local
->ap
->autom_ap_wds
= value
;
2458 case PRISM2_PARAM_AP_AUTH_ALGS
:
2459 local
->auth_algs
= value
;
2460 if (hostap_set_auth_algs(local
))
2464 case PRISM2_PARAM_MONITOR_ALLOW_FCSERR
:
2465 local
->monitor_allow_fcserr
= value
;
2468 case PRISM2_PARAM_HOST_ENCRYPT
:
2469 local
->host_encrypt
= value
;
2470 if (hostap_set_encryption(local
) ||
2471 local
->func
->reset_port(dev
))
2475 case PRISM2_PARAM_HOST_DECRYPT
:
2476 local
->host_decrypt
= value
;
2477 if (hostap_set_encryption(local
) ||
2478 local
->func
->reset_port(dev
))
2482 #ifndef PRISM2_NO_STATION_MODES
2483 case PRISM2_PARAM_HOST_ROAMING
:
2484 if (value
< 0 || value
> 2) {
2488 local
->host_roaming
= value
;
2489 if (hostap_set_roaming(local
) || local
->func
->reset_port(dev
))
2492 #endif /* PRISM2_NO_STATION_MODES */
2494 case PRISM2_PARAM_BCRX_STA_KEY
:
2495 local
->bcrx_sta_key
= value
;
2498 case PRISM2_PARAM_IEEE_802_1X
:
2499 local
->ieee_802_1x
= value
;
2502 case PRISM2_PARAM_ANTSEL_TX
:
2503 if (value
< 0 || value
> HOSTAP_ANTSEL_HIGH
) {
2507 local
->antsel_tx
= value
;
2508 hostap_set_antsel(local
);
2511 case PRISM2_PARAM_ANTSEL_RX
:
2512 if (value
< 0 || value
> HOSTAP_ANTSEL_HIGH
) {
2516 local
->antsel_rx
= value
;
2517 hostap_set_antsel(local
);
2520 case PRISM2_PARAM_MONITOR_TYPE
:
2521 if (value
!= PRISM2_MONITOR_80211
&&
2522 value
!= PRISM2_MONITOR_CAPHDR
&&
2523 value
!= PRISM2_MONITOR_PRISM
&&
2524 value
!= PRISM2_MONITOR_RADIOTAP
) {
2528 local
->monitor_type
= value
;
2529 if (local
->iw_mode
== IW_MODE_MONITOR
)
2530 hostap_monitor_set_type(local
);
2533 case PRISM2_PARAM_WDS_TYPE
:
2534 local
->wds_type
= value
;
2537 case PRISM2_PARAM_HOSTSCAN
:
2539 struct hfa384x_hostscan_request scan_req
;
2542 memset(&scan_req
, 0, sizeof(scan_req
));
2543 scan_req
.channel_list
= __constant_cpu_to_le16(0x3fff);
2545 case 1: rate
= HFA384X_RATES_1MBPS
; break;
2546 case 2: rate
= HFA384X_RATES_2MBPS
; break;
2547 case 3: rate
= HFA384X_RATES_5MBPS
; break;
2548 case 4: rate
= HFA384X_RATES_11MBPS
; break;
2549 default: rate
= HFA384X_RATES_1MBPS
; break;
2551 scan_req
.txrate
= cpu_to_le16(rate
);
2552 /* leave SSID empty to accept all SSIDs */
2554 if (local
->iw_mode
== IW_MODE_MASTER
) {
2555 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
2556 HFA384X_PORTTYPE_BSS
) ||
2557 local
->func
->reset_port(dev
))
2558 printk(KERN_DEBUG
"Leaving Host AP mode "
2559 "for HostScan failed\n");
2562 if (local
->func
->set_rid(dev
, HFA384X_RID_HOSTSCAN
, &scan_req
,
2563 sizeof(scan_req
))) {
2564 printk(KERN_DEBUG
"HOSTSCAN failed\n");
2567 if (local
->iw_mode
== IW_MODE_MASTER
) {
2568 wait_queue_t __wait
;
2569 init_waitqueue_entry(&__wait
, current
);
2570 add_wait_queue(&local
->hostscan_wq
, &__wait
);
2571 set_current_state(TASK_INTERRUPTIBLE
);
2572 schedule_timeout(HZ
);
2573 if (signal_pending(current
))
2575 set_current_state(TASK_RUNNING
);
2576 remove_wait_queue(&local
->hostscan_wq
, &__wait
);
2578 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
2579 HFA384X_PORTTYPE_HOSTAP
) ||
2580 local
->func
->reset_port(dev
))
2581 printk(KERN_DEBUG
"Returning to Host AP mode "
2582 "after HostScan failed\n");
2587 case PRISM2_PARAM_AP_SCAN
:
2588 local
->passive_scan_interval
= value
;
2589 if (timer_pending(&local
->passive_scan_timer
))
2590 del_timer(&local
->passive_scan_timer
);
2592 local
->passive_scan_timer
.expires
= jiffies
+
2593 local
->passive_scan_interval
* HZ
;
2594 add_timer(&local
->passive_scan_timer
);
2598 case PRISM2_PARAM_ENH_SEC
:
2599 if (value
< 0 || value
> 3) {
2603 local
->enh_sec
= value
;
2604 if (hostap_set_word(dev
, HFA384X_RID_CNFENHSECURITY
,
2606 local
->func
->reset_port(dev
)) {
2607 printk(KERN_INFO
"%s: cnfEnhSecurity requires STA f/w "
2608 "1.6.3 or newer\n", dev
->name
);
2613 #ifdef PRISM2_IO_DEBUG
2614 case PRISM2_PARAM_IO_DEBUG
:
2615 local
->io_debug_enabled
= value
;
2617 #endif /* PRISM2_IO_DEBUG */
2619 case PRISM2_PARAM_BASIC_RATES
:
2620 if ((value
& local
->tx_rate_control
) != value
|| value
== 0) {
2621 printk(KERN_INFO
"%s: invalid basic rate set - basic "
2622 "rates must be in supported rate set\n",
2627 local
->basic_rates
= value
;
2628 if (hostap_set_word(dev
, HFA384X_RID_CNFBASICRATES
,
2629 local
->basic_rates
) ||
2630 local
->func
->reset_port(dev
))
2634 case PRISM2_PARAM_OPER_RATES
:
2635 local
->tx_rate_control
= value
;
2636 if (hostap_set_rate(dev
))
2640 case PRISM2_PARAM_HOSTAPD
:
2641 ret
= hostap_set_hostapd(local
, value
, 1);
2644 case PRISM2_PARAM_HOSTAPD_STA
:
2645 ret
= hostap_set_hostapd_sta(local
, value
, 1);
2648 case PRISM2_PARAM_WPA
:
2650 if (local
->sta_fw_ver
< PRISM2_FW_VER(1,7,0))
2652 else if (hostap_set_word(dev
, HFA384X_RID_SSNHANDLINGMODE
,
2657 case PRISM2_PARAM_PRIVACY_INVOKED
:
2658 local
->privacy_invoked
= value
;
2659 if (hostap_set_encryption(local
) ||
2660 local
->func
->reset_port(dev
))
2664 case PRISM2_PARAM_TKIP_COUNTERMEASURES
:
2665 local
->tkip_countermeasures
= value
;
2668 case PRISM2_PARAM_DROP_UNENCRYPTED
:
2669 local
->drop_unencrypted
= value
;
2672 case PRISM2_PARAM_SCAN_CHANNEL_MASK
:
2673 local
->scan_channel_mask
= value
;
2677 printk(KERN_DEBUG
"%s: prism2_param: unknown param %d\n",
2687 static int prism2_ioctl_priv_get_prism2_param(struct net_device
*dev
,
2688 struct iw_request_info
*info
,
2689 void *wrqu
, char *extra
)
2691 struct hostap_interface
*iface
;
2692 local_info_t
*local
;
2693 int *param
= (int *) extra
;
2696 iface
= netdev_priv(dev
);
2697 local
= iface
->local
;
2700 case PRISM2_PARAM_TXRATECTRL
:
2701 *param
= local
->fw_tx_rate_control
;
2704 case PRISM2_PARAM_BEACON_INT
:
2705 *param
= local
->beacon_int
;
2708 case PRISM2_PARAM_PSEUDO_IBSS
:
2709 *param
= local
->pseudo_adhoc
;
2712 case PRISM2_PARAM_ALC
:
2713 ret
= -EOPNOTSUPP
; /* FIX */
2716 case PRISM2_PARAM_DUMP
:
2717 *param
= local
->frame_dump
;
2720 case PRISM2_PARAM_OTHER_AP_POLICY
:
2721 if (local
->ap
!= NULL
)
2722 *param
= local
->ap
->ap_policy
;
2727 case PRISM2_PARAM_AP_MAX_INACTIVITY
:
2728 if (local
->ap
!= NULL
)
2729 *param
= local
->ap
->max_inactivity
/ HZ
;
2734 case PRISM2_PARAM_AP_BRIDGE_PACKETS
:
2735 if (local
->ap
!= NULL
)
2736 *param
= local
->ap
->bridge_packets
;
2741 case PRISM2_PARAM_DTIM_PERIOD
:
2742 *param
= local
->dtim_period
;
2745 case PRISM2_PARAM_AP_NULLFUNC_ACK
:
2746 if (local
->ap
!= NULL
)
2747 *param
= local
->ap
->nullfunc_ack
;
2752 case PRISM2_PARAM_MAX_WDS
:
2753 *param
= local
->wds_max_connections
;
2756 case PRISM2_PARAM_AP_AUTOM_AP_WDS
:
2757 if (local
->ap
!= NULL
)
2758 *param
= local
->ap
->autom_ap_wds
;
2763 case PRISM2_PARAM_AP_AUTH_ALGS
:
2764 *param
= local
->auth_algs
;
2767 case PRISM2_PARAM_MONITOR_ALLOW_FCSERR
:
2768 *param
= local
->monitor_allow_fcserr
;
2771 case PRISM2_PARAM_HOST_ENCRYPT
:
2772 *param
= local
->host_encrypt
;
2775 case PRISM2_PARAM_HOST_DECRYPT
:
2776 *param
= local
->host_decrypt
;
2779 case PRISM2_PARAM_HOST_ROAMING
:
2780 *param
= local
->host_roaming
;
2783 case PRISM2_PARAM_BCRX_STA_KEY
:
2784 *param
= local
->bcrx_sta_key
;
2787 case PRISM2_PARAM_IEEE_802_1X
:
2788 *param
= local
->ieee_802_1x
;
2791 case PRISM2_PARAM_ANTSEL_TX
:
2792 *param
= local
->antsel_tx
;
2795 case PRISM2_PARAM_ANTSEL_RX
:
2796 *param
= local
->antsel_rx
;
2799 case PRISM2_PARAM_MONITOR_TYPE
:
2800 *param
= local
->monitor_type
;
2803 case PRISM2_PARAM_WDS_TYPE
:
2804 *param
= local
->wds_type
;
2807 case PRISM2_PARAM_HOSTSCAN
:
2811 case PRISM2_PARAM_AP_SCAN
:
2812 *param
= local
->passive_scan_interval
;
2815 case PRISM2_PARAM_ENH_SEC
:
2816 *param
= local
->enh_sec
;
2819 #ifdef PRISM2_IO_DEBUG
2820 case PRISM2_PARAM_IO_DEBUG
:
2821 *param
= local
->io_debug_enabled
;
2823 #endif /* PRISM2_IO_DEBUG */
2825 case PRISM2_PARAM_BASIC_RATES
:
2826 *param
= local
->basic_rates
;
2829 case PRISM2_PARAM_OPER_RATES
:
2830 *param
= local
->tx_rate_control
;
2833 case PRISM2_PARAM_HOSTAPD
:
2834 *param
= local
->hostapd
;
2837 case PRISM2_PARAM_HOSTAPD_STA
:
2838 *param
= local
->hostapd_sta
;
2841 case PRISM2_PARAM_WPA
:
2842 if (local
->sta_fw_ver
< PRISM2_FW_VER(1,7,0))
2844 *param
= local
->wpa
;
2847 case PRISM2_PARAM_PRIVACY_INVOKED
:
2848 *param
= local
->privacy_invoked
;
2851 case PRISM2_PARAM_TKIP_COUNTERMEASURES
:
2852 *param
= local
->tkip_countermeasures
;
2855 case PRISM2_PARAM_DROP_UNENCRYPTED
:
2856 *param
= local
->drop_unencrypted
;
2859 case PRISM2_PARAM_SCAN_CHANNEL_MASK
:
2860 *param
= local
->scan_channel_mask
;
2864 printk(KERN_DEBUG
"%s: get_prism2_param: unknown param %d\n",
2874 static int prism2_ioctl_priv_readmif(struct net_device
*dev
,
2875 struct iw_request_info
*info
,
2876 void *wrqu
, char *extra
)
2878 struct hostap_interface
*iface
;
2879 local_info_t
*local
;
2882 iface
= netdev_priv(dev
);
2883 local
= iface
->local
;
2885 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_READMIF
, *extra
, NULL
,
2895 static int prism2_ioctl_priv_writemif(struct net_device
*dev
,
2896 struct iw_request_info
*info
,
2897 void *wrqu
, char *extra
)
2899 struct hostap_interface
*iface
;
2900 local_info_t
*local
;
2903 iface
= netdev_priv(dev
);
2904 local
= iface
->local
;
2908 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_WRITEMIF
, cr
, &val
, NULL
))
2915 static int prism2_ioctl_priv_monitor(struct net_device
*dev
, int *i
)
2917 struct hostap_interface
*iface
;
2918 local_info_t
*local
;
2922 iface
= netdev_priv(dev
);
2923 local
= iface
->local
;
2925 printk(KERN_DEBUG
"%s: process %d (%s) used deprecated iwpriv monitor "
2926 "- update software to use iwconfig mode monitor\n",
2927 dev
->name
, task_pid_nr(current
), current
->comm
);
2929 /* Backward compatibility code - this can be removed at some point */
2932 /* Disable monitor mode - old mode was not saved, so go to
2934 mode
= IW_MODE_MASTER
;
2935 ret
= prism2_ioctl_siwmode(dev
, NULL
, &mode
, NULL
);
2936 } else if (*i
== 1) {
2937 /* netlink socket mode is not supported anymore since it did
2938 * not separate different devices from each other and was not
2939 * best method for delivering large amount of packets to
2942 } else if (*i
== 2 || *i
== 3) {
2945 local
->monitor_type
= PRISM2_MONITOR_80211
;
2948 local
->monitor_type
= PRISM2_MONITOR_PRISM
;
2951 mode
= IW_MODE_MONITOR
;
2952 ret
= prism2_ioctl_siwmode(dev
, NULL
, &mode
, NULL
);
2953 hostap_monitor_mode_enable(local
);
2961 static int prism2_ioctl_priv_reset(struct net_device
*dev
, int *i
)
2963 struct hostap_interface
*iface
;
2964 local_info_t
*local
;
2966 iface
= netdev_priv(dev
);
2967 local
= iface
->local
;
2969 printk(KERN_DEBUG
"%s: manual reset request(%d)\n", dev
->name
, *i
);
2972 /* Disable and enable card */
2973 local
->func
->hw_shutdown(dev
, 1);
2974 local
->func
->hw_config(dev
, 0);
2979 local
->func
->hw_reset(dev
);
2983 /* Disable and enable port 0 */
2984 local
->func
->reset_port(dev
);
2988 prism2_sta_deauth(local
, WLAN_REASON_DEAUTH_LEAVING
);
2989 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_DISABLE
, 0, NULL
,
2995 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_ENABLE
, 0, NULL
,
3001 printk(KERN_DEBUG
"Unknown reset request %d\n", *i
);
3009 static int prism2_ioctl_priv_set_rid_word(struct net_device
*dev
, int *i
)
3012 int value
= *(i
+ 1);
3014 printk(KERN_DEBUG
"%s: Set RID[0x%X] = %d\n", dev
->name
, rid
, value
);
3016 if (hostap_set_word(dev
, rid
, value
))
3023 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
3024 static int ap_mac_cmd_ioctl(local_info_t
*local
, int *cmd
)
3029 case AP_MAC_CMD_POLICY_OPEN
:
3030 local
->ap
->mac_restrictions
.policy
= MAC_POLICY_OPEN
;
3032 case AP_MAC_CMD_POLICY_ALLOW
:
3033 local
->ap
->mac_restrictions
.policy
= MAC_POLICY_ALLOW
;
3035 case AP_MAC_CMD_POLICY_DENY
:
3036 local
->ap
->mac_restrictions
.policy
= MAC_POLICY_DENY
;
3038 case AP_MAC_CMD_FLUSH
:
3039 ap_control_flush_macs(&local
->ap
->mac_restrictions
);
3041 case AP_MAC_CMD_KICKALL
:
3042 ap_control_kickall(local
->ap
);
3043 hostap_deauth_all_stas(local
->dev
, local
->ap
, 0);
3052 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
3055 #ifdef PRISM2_DOWNLOAD_SUPPORT
3056 static int prism2_ioctl_priv_download(local_info_t
*local
, struct iw_point
*p
)
3058 struct prism2_download_param
*param
;
3061 if (p
->length
< sizeof(struct prism2_download_param
) ||
3062 p
->length
> 1024 || !p
->pointer
)
3065 param
= (struct prism2_download_param
*)
3066 kmalloc(p
->length
, GFP_KERNEL
);
3070 if (copy_from_user(param
, p
->pointer
, p
->length
)) {
3075 if (p
->length
< sizeof(struct prism2_download_param
) +
3076 param
->num_areas
* sizeof(struct prism2_download_area
)) {
3081 ret
= local
->func
->download(local
, param
);
3087 #endif /* PRISM2_DOWNLOAD_SUPPORT */
3090 static int prism2_set_genericelement(struct net_device
*dev
, u8
*elem
,
3093 struct hostap_interface
*iface
= netdev_priv(dev
);
3094 local_info_t
*local
= iface
->local
;
3098 * Add 16-bit length in the beginning of the buffer because Prism2 RID
3101 buf
= kmalloc(len
+ 2, GFP_KERNEL
);
3105 *((__le16
*) buf
) = cpu_to_le16(len
);
3106 memcpy(buf
+ 2, elem
, len
);
3108 kfree(local
->generic_elem
);
3109 local
->generic_elem
= buf
;
3110 local
->generic_elem_len
= len
+ 2;
3112 return local
->func
->set_rid(local
->dev
, HFA384X_RID_GENERICELEMENT
,
3117 static int prism2_ioctl_siwauth(struct net_device
*dev
,
3118 struct iw_request_info
*info
,
3119 struct iw_param
*data
, char *extra
)
3121 struct hostap_interface
*iface
= netdev_priv(dev
);
3122 local_info_t
*local
= iface
->local
;
3124 switch (data
->flags
& IW_AUTH_INDEX
) {
3125 case IW_AUTH_WPA_VERSION
:
3126 case IW_AUTH_CIPHER_PAIRWISE
:
3127 case IW_AUTH_CIPHER_GROUP
:
3128 case IW_AUTH_KEY_MGMT
:
3130 * Host AP driver does not use these parameters and allows
3131 * wpa_supplicant to control them internally.
3134 case IW_AUTH_TKIP_COUNTERMEASURES
:
3135 local
->tkip_countermeasures
= data
->value
;
3137 case IW_AUTH_DROP_UNENCRYPTED
:
3138 local
->drop_unencrypted
= data
->value
;
3140 case IW_AUTH_80211_AUTH_ALG
:
3141 local
->auth_algs
= data
->value
;
3143 case IW_AUTH_WPA_ENABLED
:
3144 if (data
->value
== 0) {
3146 if (local
->sta_fw_ver
< PRISM2_FW_VER(1,7,0))
3148 prism2_set_genericelement(dev
, "", 0);
3149 local
->host_roaming
= 0;
3150 local
->privacy_invoked
= 0;
3151 if (hostap_set_word(dev
, HFA384X_RID_SSNHANDLINGMODE
,
3153 hostap_set_roaming(local
) ||
3154 hostap_set_encryption(local
) ||
3155 local
->func
->reset_port(dev
))
3159 if (local
->sta_fw_ver
< PRISM2_FW_VER(1,7,0))
3161 local
->host_roaming
= 2;
3162 local
->privacy_invoked
= 1;
3164 if (hostap_set_word(dev
, HFA384X_RID_SSNHANDLINGMODE
, 1) ||
3165 hostap_set_roaming(local
) ||
3166 hostap_set_encryption(local
) ||
3167 local
->func
->reset_port(dev
))
3170 case IW_AUTH_RX_UNENCRYPTED_EAPOL
:
3171 local
->ieee_802_1x
= data
->value
;
3173 case IW_AUTH_PRIVACY_INVOKED
:
3174 local
->privacy_invoked
= data
->value
;
3183 static int prism2_ioctl_giwauth(struct net_device
*dev
,
3184 struct iw_request_info
*info
,
3185 struct iw_param
*data
, char *extra
)
3187 struct hostap_interface
*iface
= netdev_priv(dev
);
3188 local_info_t
*local
= iface
->local
;
3190 switch (data
->flags
& IW_AUTH_INDEX
) {
3191 case IW_AUTH_WPA_VERSION
:
3192 case IW_AUTH_CIPHER_PAIRWISE
:
3193 case IW_AUTH_CIPHER_GROUP
:
3194 case IW_AUTH_KEY_MGMT
:
3196 * Host AP driver does not use these parameters and allows
3197 * wpa_supplicant to control them internally.
3200 case IW_AUTH_TKIP_COUNTERMEASURES
:
3201 data
->value
= local
->tkip_countermeasures
;
3203 case IW_AUTH_DROP_UNENCRYPTED
:
3204 data
->value
= local
->drop_unencrypted
;
3206 case IW_AUTH_80211_AUTH_ALG
:
3207 data
->value
= local
->auth_algs
;
3209 case IW_AUTH_WPA_ENABLED
:
3210 data
->value
= local
->wpa
;
3212 case IW_AUTH_RX_UNENCRYPTED_EAPOL
:
3213 data
->value
= local
->ieee_802_1x
;
3222 static int prism2_ioctl_siwencodeext(struct net_device
*dev
,
3223 struct iw_request_info
*info
,
3224 struct iw_point
*erq
, char *extra
)
3226 struct hostap_interface
*iface
= netdev_priv(dev
);
3227 local_info_t
*local
= iface
->local
;
3228 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*) extra
;
3230 struct lib80211_crypto_ops
*ops
;
3231 struct lib80211_crypt_data
**crypt
;
3234 const char *alg
, *module
;
3236 i
= erq
->flags
& IW_ENCODE_INDEX
;
3239 if (i
< 1 || i
> WEP_KEYS
)
3240 i
= local
->crypt_info
.tx_keyidx
;
3243 if (i
< 0 || i
>= WEP_KEYS
)
3246 addr
= ext
->addr
.sa_data
;
3247 if (addr
[0] == 0xff && addr
[1] == 0xff && addr
[2] == 0xff &&
3248 addr
[3] == 0xff && addr
[4] == 0xff && addr
[5] == 0xff) {
3250 crypt
= &local
->crypt_info
.crypt
[i
];
3254 sta_ptr
= ap_crypt_get_ptrs(local
->ap
, addr
, 0, &crypt
);
3255 if (sta_ptr
== NULL
) {
3256 if (local
->iw_mode
== IW_MODE_INFRA
) {
3258 * TODO: add STA entry for the current AP so
3259 * that unicast key can be used. For now, this
3260 * is emulated by using default key idx 0.
3263 crypt
= &local
->crypt_info
.crypt
[i
];
3269 if ((erq
->flags
& IW_ENCODE_DISABLED
) ||
3270 ext
->alg
== IW_ENCODE_ALG_NONE
) {
3272 prism2_crypt_delayed_deinit(local
, crypt
);
3277 case IW_ENCODE_ALG_WEP
:
3279 module
= "lib80211_crypt_wep";
3281 case IW_ENCODE_ALG_TKIP
:
3283 module
= "lib80211_crypt_tkip";
3285 case IW_ENCODE_ALG_CCMP
:
3287 module
= "lib80211_crypt_ccmp";
3290 printk(KERN_DEBUG
"%s: unsupported algorithm %d\n",
3291 local
->dev
->name
, ext
->alg
);
3296 ops
= lib80211_get_crypto_ops(alg
);
3298 request_module(module
);
3299 ops
= lib80211_get_crypto_ops(alg
);
3302 printk(KERN_DEBUG
"%s: unknown crypto alg '%s'\n",
3303 local
->dev
->name
, alg
);
3308 if (sta_ptr
|| ext
->alg
!= IW_ENCODE_ALG_WEP
) {
3310 * Per station encryption and other than WEP algorithms
3311 * require host-based encryption, so force them on
3314 local
->host_decrypt
= local
->host_encrypt
= 1;
3317 if (*crypt
== NULL
|| (*crypt
)->ops
!= ops
) {
3318 struct lib80211_crypt_data
*new_crypt
;
3320 prism2_crypt_delayed_deinit(local
, crypt
);
3322 new_crypt
= kzalloc(sizeof(struct lib80211_crypt_data
),
3324 if (new_crypt
== NULL
) {
3328 new_crypt
->ops
= ops
;
3329 new_crypt
->priv
= new_crypt
->ops
->init(i
);
3330 if (new_crypt
->priv
== NULL
) {
3340 * TODO: if ext_flags does not have IW_ENCODE_EXT_RX_SEQ_VALID, the
3341 * existing seq# should not be changed.
3342 * TODO: if ext_flags has IW_ENCODE_EXT_TX_SEQ_VALID, next TX seq#
3343 * should be changed to something else than zero.
3345 if ((!(ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
) || ext
->key_len
> 0)
3346 && (*crypt
)->ops
->set_key
&&
3347 (*crypt
)->ops
->set_key(ext
->key
, ext
->key_len
, ext
->rx_seq
,
3348 (*crypt
)->priv
) < 0) {
3349 printk(KERN_DEBUG
"%s: key setting failed\n",
3355 if (ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
) {
3357 local
->crypt_info
.tx_keyidx
= i
;
3361 if (sta_ptr
== NULL
&& ext
->key_len
> 0) {
3363 for (j
= 0; j
< WEP_KEYS
; j
++) {
3364 if (j
!= i
&& local
->crypt_info
.crypt
[j
]) {
3370 local
->crypt_info
.tx_keyidx
= i
;
3375 hostap_handle_sta_release(sta_ptr
);
3377 local
->open_wep
= erq
->flags
& IW_ENCODE_OPEN
;
3380 * Do not reset port0 if card is in Managed mode since resetting will
3381 * generate new IEEE 802.11 authentication which may end up in looping
3382 * with IEEE 802.1X. Prism2 documentation seem to require port reset
3383 * after WEP configuration. However, keys are apparently changed at
3384 * least in Managed mode.
3387 (hostap_set_encryption(local
) ||
3388 (local
->iw_mode
!= IW_MODE_INFRA
&&
3389 local
->func
->reset_port(local
->dev
))))
3396 static int prism2_ioctl_giwencodeext(struct net_device
*dev
,
3397 struct iw_request_info
*info
,
3398 struct iw_point
*erq
, char *extra
)
3400 struct hostap_interface
*iface
= netdev_priv(dev
);
3401 local_info_t
*local
= iface
->local
;
3402 struct lib80211_crypt_data
**crypt
;
3405 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*) extra
;
3408 max_key_len
= erq
->length
- sizeof(*ext
);
3409 if (max_key_len
< 0)
3412 i
= erq
->flags
& IW_ENCODE_INDEX
;
3413 if (i
< 1 || i
> WEP_KEYS
)
3414 i
= local
->crypt_info
.tx_keyidx
;
3418 addr
= ext
->addr
.sa_data
;
3419 if (addr
[0] == 0xff && addr
[1] == 0xff && addr
[2] == 0xff &&
3420 addr
[3] == 0xff && addr
[4] == 0xff && addr
[5] == 0xff) {
3422 crypt
= &local
->crypt_info
.crypt
[i
];
3425 sta_ptr
= ap_crypt_get_ptrs(local
->ap
, addr
, 0, &crypt
);
3426 if (sta_ptr
== NULL
)
3430 memset(ext
, 0, sizeof(*ext
));
3432 if (*crypt
== NULL
|| (*crypt
)->ops
== NULL
) {
3433 ext
->alg
= IW_ENCODE_ALG_NONE
;
3435 erq
->flags
|= IW_ENCODE_DISABLED
;
3437 if (strcmp((*crypt
)->ops
->name
, "WEP") == 0)
3438 ext
->alg
= IW_ENCODE_ALG_WEP
;
3439 else if (strcmp((*crypt
)->ops
->name
, "TKIP") == 0)
3440 ext
->alg
= IW_ENCODE_ALG_TKIP
;
3441 else if (strcmp((*crypt
)->ops
->name
, "CCMP") == 0)
3442 ext
->alg
= IW_ENCODE_ALG_CCMP
;
3446 if ((*crypt
)->ops
->get_key
) {
3448 (*crypt
)->ops
->get_key(ext
->key
,
3453 (ext
->alg
== IW_ENCODE_ALG_TKIP
||
3454 ext
->alg
== IW_ENCODE_ALG_CCMP
))
3455 ext
->ext_flags
|= IW_ENCODE_EXT_TX_SEQ_VALID
;
3460 hostap_handle_sta_release(sta_ptr
);
3466 static int prism2_ioctl_set_encryption(local_info_t
*local
,
3467 struct prism2_hostapd_param
*param
,
3471 struct lib80211_crypto_ops
*ops
;
3472 struct lib80211_crypt_data
**crypt
;
3475 param
->u
.crypt
.err
= 0;
3476 param
->u
.crypt
.alg
[HOSTAP_CRYPT_ALG_NAME_LEN
- 1] = '\0';
3479 (int) ((char *) param
->u
.crypt
.key
- (char *) param
) +
3480 param
->u
.crypt
.key_len
)
3483 if (param
->sta_addr
[0] == 0xff && param
->sta_addr
[1] == 0xff &&
3484 param
->sta_addr
[2] == 0xff && param
->sta_addr
[3] == 0xff &&
3485 param
->sta_addr
[4] == 0xff && param
->sta_addr
[5] == 0xff) {
3486 if (param
->u
.crypt
.idx
>= WEP_KEYS
)
3489 crypt
= &local
->crypt_info
.crypt
[param
->u
.crypt
.idx
];
3491 if (param
->u
.crypt
.idx
)
3493 sta_ptr
= ap_crypt_get_ptrs(
3494 local
->ap
, param
->sta_addr
,
3495 (param
->u
.crypt
.flags
& HOSTAP_CRYPT_FLAG_PERMANENT
),
3498 if (sta_ptr
== NULL
) {
3499 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_UNKNOWN_ADDR
;
3504 if (strcmp(param
->u
.crypt
.alg
, "none") == 0) {
3506 prism2_crypt_delayed_deinit(local
, crypt
);
3510 ops
= lib80211_get_crypto_ops(param
->u
.crypt
.alg
);
3511 if (ops
== NULL
&& strcmp(param
->u
.crypt
.alg
, "WEP") == 0) {
3512 request_module("lib80211_crypt_wep");
3513 ops
= lib80211_get_crypto_ops(param
->u
.crypt
.alg
);
3514 } else if (ops
== NULL
&& strcmp(param
->u
.crypt
.alg
, "TKIP") == 0) {
3515 request_module("lib80211_crypt_tkip");
3516 ops
= lib80211_get_crypto_ops(param
->u
.crypt
.alg
);
3517 } else if (ops
== NULL
&& strcmp(param
->u
.crypt
.alg
, "CCMP") == 0) {
3518 request_module("lib80211_crypt_ccmp");
3519 ops
= lib80211_get_crypto_ops(param
->u
.crypt
.alg
);
3522 printk(KERN_DEBUG
"%s: unknown crypto alg '%s'\n",
3523 local
->dev
->name
, param
->u
.crypt
.alg
);
3524 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_UNKNOWN_ALG
;
3529 /* station based encryption and other than WEP algorithms require
3530 * host-based encryption, so force them on automatically */
3531 local
->host_decrypt
= local
->host_encrypt
= 1;
3533 if (*crypt
== NULL
|| (*crypt
)->ops
!= ops
) {
3534 struct lib80211_crypt_data
*new_crypt
;
3536 prism2_crypt_delayed_deinit(local
, crypt
);
3538 new_crypt
= kzalloc(sizeof(struct lib80211_crypt_data
),
3540 if (new_crypt
== NULL
) {
3544 new_crypt
->ops
= ops
;
3545 new_crypt
->priv
= new_crypt
->ops
->init(param
->u
.crypt
.idx
);
3546 if (new_crypt
->priv
== NULL
) {
3548 param
->u
.crypt
.err
=
3549 HOSTAP_CRYPT_ERR_CRYPT_INIT_FAILED
;
3557 if ((!(param
->u
.crypt
.flags
& HOSTAP_CRYPT_FLAG_SET_TX_KEY
) ||
3558 param
->u
.crypt
.key_len
> 0) && (*crypt
)->ops
->set_key
&&
3559 (*crypt
)->ops
->set_key(param
->u
.crypt
.key
,
3560 param
->u
.crypt
.key_len
, param
->u
.crypt
.seq
,
3561 (*crypt
)->priv
) < 0) {
3562 printk(KERN_DEBUG
"%s: key setting failed\n",
3564 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_KEY_SET_FAILED
;
3569 if (param
->u
.crypt
.flags
& HOSTAP_CRYPT_FLAG_SET_TX_KEY
) {
3571 local
->crypt_info
.tx_keyidx
= param
->u
.crypt
.idx
;
3572 else if (param
->u
.crypt
.idx
) {
3573 printk(KERN_DEBUG
"%s: TX key idx setting failed\n",
3575 param
->u
.crypt
.err
=
3576 HOSTAP_CRYPT_ERR_TX_KEY_SET_FAILED
;
3584 hostap_handle_sta_release(sta_ptr
);
3586 /* Do not reset port0 if card is in Managed mode since resetting will
3587 * generate new IEEE 802.11 authentication which may end up in looping
3588 * with IEEE 802.1X. Prism2 documentation seem to require port reset
3589 * after WEP configuration. However, keys are apparently changed at
3590 * least in Managed mode. */
3592 (hostap_set_encryption(local
) ||
3593 (local
->iw_mode
!= IW_MODE_INFRA
&&
3594 local
->func
->reset_port(local
->dev
)))) {
3595 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_CARD_CONF_FAILED
;
3603 static int prism2_ioctl_get_encryption(local_info_t
*local
,
3604 struct prism2_hostapd_param
*param
,
3607 struct lib80211_crypt_data
**crypt
;
3611 param
->u
.crypt
.err
= 0;
3613 max_key_len
= param_len
-
3614 (int) ((char *) param
->u
.crypt
.key
- (char *) param
);
3615 if (max_key_len
< 0)
3618 if (param
->sta_addr
[0] == 0xff && param
->sta_addr
[1] == 0xff &&
3619 param
->sta_addr
[2] == 0xff && param
->sta_addr
[3] == 0xff &&
3620 param
->sta_addr
[4] == 0xff && param
->sta_addr
[5] == 0xff) {
3622 if (param
->u
.crypt
.idx
>= WEP_KEYS
)
3623 param
->u
.crypt
.idx
= local
->crypt_info
.tx_keyidx
;
3624 crypt
= &local
->crypt_info
.crypt
[param
->u
.crypt
.idx
];
3626 param
->u
.crypt
.idx
= 0;
3627 sta_ptr
= ap_crypt_get_ptrs(local
->ap
, param
->sta_addr
, 0,
3630 if (sta_ptr
== NULL
) {
3631 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_UNKNOWN_ADDR
;
3636 if (*crypt
== NULL
|| (*crypt
)->ops
== NULL
) {
3637 memcpy(param
->u
.crypt
.alg
, "none", 5);
3638 param
->u
.crypt
.key_len
= 0;
3639 param
->u
.crypt
.idx
= 0xff;
3641 strncpy(param
->u
.crypt
.alg
, (*crypt
)->ops
->name
,
3642 HOSTAP_CRYPT_ALG_NAME_LEN
);
3643 param
->u
.crypt
.key_len
= 0;
3645 memset(param
->u
.crypt
.seq
, 0, 8);
3646 if ((*crypt
)->ops
->get_key
) {
3647 param
->u
.crypt
.key_len
=
3648 (*crypt
)->ops
->get_key(param
->u
.crypt
.key
,
3656 hostap_handle_sta_release(sta_ptr
);
3662 static int prism2_ioctl_get_rid(local_info_t
*local
,
3663 struct prism2_hostapd_param
*param
,
3668 max_len
= param_len
- PRISM2_HOSTAPD_RID_HDR_LEN
;
3672 res
= local
->func
->get_rid(local
->dev
, param
->u
.rid
.rid
,
3673 param
->u
.rid
.data
, param
->u
.rid
.len
, 0);
3675 param
->u
.rid
.len
= res
;
3683 static int prism2_ioctl_set_rid(local_info_t
*local
,
3684 struct prism2_hostapd_param
*param
,
3689 max_len
= param_len
- PRISM2_HOSTAPD_RID_HDR_LEN
;
3690 if (max_len
< 0 || max_len
< param
->u
.rid
.len
)
3693 return local
->func
->set_rid(local
->dev
, param
->u
.rid
.rid
,
3694 param
->u
.rid
.data
, param
->u
.rid
.len
);
3698 static int prism2_ioctl_set_assoc_ap_addr(local_info_t
*local
,
3699 struct prism2_hostapd_param
*param
,
3702 printk(KERN_DEBUG
"%ssta: associated as client with AP %pM\n",
3703 local
->dev
->name
, param
->sta_addr
);
3704 memcpy(local
->assoc_ap_addr
, param
->sta_addr
, ETH_ALEN
);
3709 static int prism2_ioctl_siwgenie(struct net_device
*dev
,
3710 struct iw_request_info
*info
,
3711 struct iw_point
*data
, char *extra
)
3713 return prism2_set_genericelement(dev
, extra
, data
->length
);
3717 static int prism2_ioctl_giwgenie(struct net_device
*dev
,
3718 struct iw_request_info
*info
,
3719 struct iw_point
*data
, char *extra
)
3721 struct hostap_interface
*iface
= netdev_priv(dev
);
3722 local_info_t
*local
= iface
->local
;
3723 int len
= local
->generic_elem_len
- 2;
3725 if (len
<= 0 || local
->generic_elem
== NULL
) {
3730 if (data
->length
< len
)
3734 memcpy(extra
, local
->generic_elem
+ 2, len
);
3740 static int prism2_ioctl_set_generic_element(local_info_t
*local
,
3741 struct prism2_hostapd_param
*param
,
3746 len
= param
->u
.generic_elem
.len
;
3747 max_len
= param_len
- PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN
;
3748 if (max_len
< 0 || max_len
< len
)
3751 return prism2_set_genericelement(local
->dev
,
3752 param
->u
.generic_elem
.data
, len
);
3756 static int prism2_ioctl_siwmlme(struct net_device
*dev
,
3757 struct iw_request_info
*info
,
3758 struct iw_point
*data
, char *extra
)
3760 struct hostap_interface
*iface
= netdev_priv(dev
);
3761 local_info_t
*local
= iface
->local
;
3762 struct iw_mlme
*mlme
= (struct iw_mlme
*) extra
;
3765 reason
= cpu_to_le16(mlme
->reason_code
);
3767 switch (mlme
->cmd
) {
3768 case IW_MLME_DEAUTH
:
3769 return prism2_sta_send_mgmt(local
, mlme
->addr
.sa_data
,
3770 IEEE80211_STYPE_DEAUTH
,
3772 case IW_MLME_DISASSOC
:
3773 return prism2_sta_send_mgmt(local
, mlme
->addr
.sa_data
,
3774 IEEE80211_STYPE_DISASSOC
,
3782 static int prism2_ioctl_mlme(local_info_t
*local
,
3783 struct prism2_hostapd_param
*param
)
3787 reason
= cpu_to_le16(param
->u
.mlme
.reason_code
);
3788 switch (param
->u
.mlme
.cmd
) {
3789 case MLME_STA_DEAUTH
:
3790 return prism2_sta_send_mgmt(local
, param
->sta_addr
,
3791 IEEE80211_STYPE_DEAUTH
,
3793 case MLME_STA_DISASSOC
:
3794 return prism2_sta_send_mgmt(local
, param
->sta_addr
,
3795 IEEE80211_STYPE_DISASSOC
,
3803 static int prism2_ioctl_scan_req(local_info_t
*local
,
3804 struct prism2_hostapd_param
*param
)
3806 #ifndef PRISM2_NO_STATION_MODES
3807 if ((local
->iw_mode
!= IW_MODE_INFRA
&&
3808 local
->iw_mode
!= IW_MODE_ADHOC
) ||
3809 (local
->sta_fw_ver
< PRISM2_FW_VER(1,3,1)))
3812 if (!local
->dev_enabled
)
3815 return prism2_request_hostscan(local
->dev
, param
->u
.scan_req
.ssid
,
3816 param
->u
.scan_req
.ssid_len
);
3817 #else /* PRISM2_NO_STATION_MODES */
3819 #endif /* PRISM2_NO_STATION_MODES */
3823 static int prism2_ioctl_priv_hostapd(local_info_t
*local
, struct iw_point
*p
)
3825 struct prism2_hostapd_param
*param
;
3829 if (p
->length
< sizeof(struct prism2_hostapd_param
) ||
3830 p
->length
> PRISM2_HOSTAPD_MAX_BUF_SIZE
|| !p
->pointer
)
3833 param
= kmalloc(p
->length
, GFP_KERNEL
);
3837 if (copy_from_user(param
, p
->pointer
, p
->length
)) {
3842 switch (param
->cmd
) {
3843 case PRISM2_SET_ENCRYPTION
:
3844 ret
= prism2_ioctl_set_encryption(local
, param
, p
->length
);
3846 case PRISM2_GET_ENCRYPTION
:
3847 ret
= prism2_ioctl_get_encryption(local
, param
, p
->length
);
3849 case PRISM2_HOSTAPD_GET_RID
:
3850 ret
= prism2_ioctl_get_rid(local
, param
, p
->length
);
3852 case PRISM2_HOSTAPD_SET_RID
:
3853 ret
= prism2_ioctl_set_rid(local
, param
, p
->length
);
3855 case PRISM2_HOSTAPD_SET_ASSOC_AP_ADDR
:
3856 ret
= prism2_ioctl_set_assoc_ap_addr(local
, param
, p
->length
);
3858 case PRISM2_HOSTAPD_SET_GENERIC_ELEMENT
:
3859 ret
= prism2_ioctl_set_generic_element(local
, param
,
3862 case PRISM2_HOSTAPD_MLME
:
3863 ret
= prism2_ioctl_mlme(local
, param
);
3865 case PRISM2_HOSTAPD_SCAN_REQ
:
3866 ret
= prism2_ioctl_scan_req(local
, param
);
3869 ret
= prism2_hostapd(local
->ap
, param
);
3874 if (ret
== 1 || !ap_ioctl
) {
3875 if (copy_to_user(p
->pointer
, param
, p
->length
)) {
3878 } else if (ap_ioctl
)
3888 static void prism2_get_drvinfo(struct net_device
*dev
,
3889 struct ethtool_drvinfo
*info
)
3891 struct hostap_interface
*iface
;
3892 local_info_t
*local
;
3894 iface
= netdev_priv(dev
);
3895 local
= iface
->local
;
3897 strncpy(info
->driver
, "hostap", sizeof(info
->driver
) - 1);
3898 snprintf(info
->fw_version
, sizeof(info
->fw_version
) - 1,
3899 "%d.%d.%d", (local
->sta_fw_ver
>> 16) & 0xff,
3900 (local
->sta_fw_ver
>> 8) & 0xff,
3901 local
->sta_fw_ver
& 0xff);
3904 const struct ethtool_ops prism2_ethtool_ops
= {
3905 .get_drvinfo
= prism2_get_drvinfo
3909 /* Structures to export the Wireless Handlers */
3911 static const iw_handler prism2_handler
[] =
3913 (iw_handler
) NULL
, /* SIOCSIWCOMMIT */
3914 (iw_handler
) prism2_get_name
, /* SIOCGIWNAME */
3915 (iw_handler
) NULL
, /* SIOCSIWNWID */
3916 (iw_handler
) NULL
, /* SIOCGIWNWID */
3917 (iw_handler
) prism2_ioctl_siwfreq
, /* SIOCSIWFREQ */
3918 (iw_handler
) prism2_ioctl_giwfreq
, /* SIOCGIWFREQ */
3919 (iw_handler
) prism2_ioctl_siwmode
, /* SIOCSIWMODE */
3920 (iw_handler
) prism2_ioctl_giwmode
, /* SIOCGIWMODE */
3921 (iw_handler
) prism2_ioctl_siwsens
, /* SIOCSIWSENS */
3922 (iw_handler
) prism2_ioctl_giwsens
, /* SIOCGIWSENS */
3923 (iw_handler
) NULL
/* not used */, /* SIOCSIWRANGE */
3924 (iw_handler
) prism2_ioctl_giwrange
, /* SIOCGIWRANGE */
3925 (iw_handler
) NULL
/* not used */, /* SIOCSIWPRIV */
3926 (iw_handler
) NULL
/* kernel code */, /* SIOCGIWPRIV */
3927 (iw_handler
) NULL
/* not used */, /* SIOCSIWSTATS */
3928 (iw_handler
) NULL
/* kernel code */, /* SIOCGIWSTATS */
3929 iw_handler_set_spy
, /* SIOCSIWSPY */
3930 iw_handler_get_spy
, /* SIOCGIWSPY */
3931 iw_handler_set_thrspy
, /* SIOCSIWTHRSPY */
3932 iw_handler_get_thrspy
, /* SIOCGIWTHRSPY */
3933 (iw_handler
) prism2_ioctl_siwap
, /* SIOCSIWAP */
3934 (iw_handler
) prism2_ioctl_giwap
, /* SIOCGIWAP */
3935 (iw_handler
) prism2_ioctl_siwmlme
, /* SIOCSIWMLME */
3936 (iw_handler
) prism2_ioctl_giwaplist
, /* SIOCGIWAPLIST */
3937 (iw_handler
) prism2_ioctl_siwscan
, /* SIOCSIWSCAN */
3938 (iw_handler
) prism2_ioctl_giwscan
, /* SIOCGIWSCAN */
3939 (iw_handler
) prism2_ioctl_siwessid
, /* SIOCSIWESSID */
3940 (iw_handler
) prism2_ioctl_giwessid
, /* SIOCGIWESSID */
3941 (iw_handler
) prism2_ioctl_siwnickn
, /* SIOCSIWNICKN */
3942 (iw_handler
) prism2_ioctl_giwnickn
, /* SIOCGIWNICKN */
3943 (iw_handler
) NULL
, /* -- hole -- */
3944 (iw_handler
) NULL
, /* -- hole -- */
3945 (iw_handler
) prism2_ioctl_siwrate
, /* SIOCSIWRATE */
3946 (iw_handler
) prism2_ioctl_giwrate
, /* SIOCGIWRATE */
3947 (iw_handler
) prism2_ioctl_siwrts
, /* SIOCSIWRTS */
3948 (iw_handler
) prism2_ioctl_giwrts
, /* SIOCGIWRTS */
3949 (iw_handler
) prism2_ioctl_siwfrag
, /* SIOCSIWFRAG */
3950 (iw_handler
) prism2_ioctl_giwfrag
, /* SIOCGIWFRAG */
3951 (iw_handler
) prism2_ioctl_siwtxpow
, /* SIOCSIWTXPOW */
3952 (iw_handler
) prism2_ioctl_giwtxpow
, /* SIOCGIWTXPOW */
3953 (iw_handler
) prism2_ioctl_siwretry
, /* SIOCSIWRETRY */
3954 (iw_handler
) prism2_ioctl_giwretry
, /* SIOCGIWRETRY */
3955 (iw_handler
) prism2_ioctl_siwencode
, /* SIOCSIWENCODE */
3956 (iw_handler
) prism2_ioctl_giwencode
, /* SIOCGIWENCODE */
3957 (iw_handler
) prism2_ioctl_siwpower
, /* SIOCSIWPOWER */
3958 (iw_handler
) prism2_ioctl_giwpower
, /* SIOCGIWPOWER */
3959 (iw_handler
) NULL
, /* -- hole -- */
3960 (iw_handler
) NULL
, /* -- hole -- */
3961 (iw_handler
) prism2_ioctl_siwgenie
, /* SIOCSIWGENIE */
3962 (iw_handler
) prism2_ioctl_giwgenie
, /* SIOCGIWGENIE */
3963 (iw_handler
) prism2_ioctl_siwauth
, /* SIOCSIWAUTH */
3964 (iw_handler
) prism2_ioctl_giwauth
, /* SIOCGIWAUTH */
3965 (iw_handler
) prism2_ioctl_siwencodeext
, /* SIOCSIWENCODEEXT */
3966 (iw_handler
) prism2_ioctl_giwencodeext
, /* SIOCGIWENCODEEXT */
3967 (iw_handler
) NULL
, /* SIOCSIWPMKSA */
3968 (iw_handler
) NULL
, /* -- hole -- */
3971 static const iw_handler prism2_private_handler
[] =
3972 { /* SIOCIWFIRSTPRIV + */
3973 (iw_handler
) prism2_ioctl_priv_prism2_param
, /* 0 */
3974 (iw_handler
) prism2_ioctl_priv_get_prism2_param
, /* 1 */
3975 (iw_handler
) prism2_ioctl_priv_writemif
, /* 2 */
3976 (iw_handler
) prism2_ioctl_priv_readmif
, /* 3 */
3979 const struct iw_handler_def hostap_iw_handler_def
=
3981 .num_standard
= ARRAY_SIZE(prism2_handler
),
3982 .num_private
= ARRAY_SIZE(prism2_private_handler
),
3983 .num_private_args
= ARRAY_SIZE(prism2_priv
),
3984 .standard
= (iw_handler
*) prism2_handler
,
3985 .private = (iw_handler
*) prism2_private_handler
,
3986 .private_args
= (struct iw_priv_args
*) prism2_priv
,
3987 .get_wireless_stats
= hostap_get_wireless_stats
,
3991 int hostap_ioctl(struct net_device
*dev
, struct ifreq
*ifr
, int cmd
)
3993 struct iwreq
*wrq
= (struct iwreq
*) ifr
;
3994 struct hostap_interface
*iface
;
3995 local_info_t
*local
;
3998 iface
= netdev_priv(dev
);
3999 local
= iface
->local
;
4002 /* Private ioctls (iwpriv) that have not yet been converted
4003 * into new wireless extensions API */
4005 case PRISM2_IOCTL_INQUIRE
:
4006 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4007 else ret
= prism2_ioctl_priv_inquire(dev
, (int *) wrq
->u
.name
);
4010 case PRISM2_IOCTL_MONITOR
:
4011 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4012 else ret
= prism2_ioctl_priv_monitor(dev
, (int *) wrq
->u
.name
);
4015 case PRISM2_IOCTL_RESET
:
4016 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4017 else ret
= prism2_ioctl_priv_reset(dev
, (int *) wrq
->u
.name
);
4020 case PRISM2_IOCTL_WDS_ADD
:
4021 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4022 else ret
= prism2_wds_add(local
, wrq
->u
.ap_addr
.sa_data
, 1);
4025 case PRISM2_IOCTL_WDS_DEL
:
4026 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4027 else ret
= prism2_wds_del(local
, wrq
->u
.ap_addr
.sa_data
, 1, 0);
4030 case PRISM2_IOCTL_SET_RID_WORD
:
4031 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4032 else ret
= prism2_ioctl_priv_set_rid_word(dev
,
4033 (int *) wrq
->u
.name
);
4036 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
4037 case PRISM2_IOCTL_MACCMD
:
4038 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4039 else ret
= ap_mac_cmd_ioctl(local
, (int *) wrq
->u
.name
);
4042 case PRISM2_IOCTL_ADDMAC
:
4043 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4044 else ret
= ap_control_add_mac(&local
->ap
->mac_restrictions
,
4045 wrq
->u
.ap_addr
.sa_data
);
4047 case PRISM2_IOCTL_DELMAC
:
4048 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4049 else ret
= ap_control_del_mac(&local
->ap
->mac_restrictions
,
4050 wrq
->u
.ap_addr
.sa_data
);
4052 case PRISM2_IOCTL_KICKMAC
:
4053 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4054 else ret
= ap_control_kick_mac(local
->ap
, local
->dev
,
4055 wrq
->u
.ap_addr
.sa_data
);
4057 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
4060 /* Private ioctls that are not used with iwpriv;
4061 * in SIOCDEVPRIVATE range */
4063 #ifdef PRISM2_DOWNLOAD_SUPPORT
4064 case PRISM2_IOCTL_DOWNLOAD
:
4065 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4066 else ret
= prism2_ioctl_priv_download(local
, &wrq
->u
.data
);
4068 #endif /* PRISM2_DOWNLOAD_SUPPORT */
4070 case PRISM2_IOCTL_HOSTAPD
:
4071 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4072 else ret
= prism2_ioctl_priv_hostapd(local
, &wrq
->u
.data
);