1 /* ioctl() (mostly Linux Wireless Extensions) routines for Host AP driver */
3 #include <linux/slab.h>
4 #include <linux/types.h>
5 #include <linux/sched.h>
6 #include <linux/ethtool.h>
7 #include <linux/if_arp.h>
8 #include <linux/module.h>
9 #include <net/lib80211.h>
11 #include "hostap_wlan.h"
13 #include "hostap_ap.h"
15 static struct iw_statistics
*hostap_get_wireless_stats(struct net_device
*dev
)
17 struct hostap_interface
*iface
;
19 struct iw_statistics
*wstats
;
21 iface
= netdev_priv(dev
);
24 /* Why are we doing that ? Jean II */
25 if (iface
->type
!= HOSTAP_INTERFACE_MAIN
)
28 wstats
= &local
->wstats
;
31 wstats
->discard
.code
=
32 local
->comm_tallies
.rx_discards_wep_undecryptable
;
33 wstats
->discard
.misc
=
34 local
->comm_tallies
.rx_fcs_errors
+
35 local
->comm_tallies
.rx_discards_no_buffer
+
36 local
->comm_tallies
.tx_discards_wrong_sa
;
38 wstats
->discard
.retries
=
39 local
->comm_tallies
.tx_retry_limit_exceeded
;
40 wstats
->discard
.fragment
=
41 local
->comm_tallies
.rx_message_in_bad_msg_fragments
;
43 if (local
->iw_mode
!= IW_MODE_MASTER
&&
44 local
->iw_mode
!= IW_MODE_REPEAT
) {
47 /* RID reading might sleep and it must not be called in
48 * interrupt context or while atomic. However, this
49 * function seems to be called while atomic (at least in Linux
50 * 2.5.59). Update signal quality values only if in suitable
51 * context. Otherwise, previous values read from tick timer
55 #endif /* in_atomic */
57 if (update
&& prism2_update_comms_qual(dev
) == 0)
58 wstats
->qual
.updated
= IW_QUAL_ALL_UPDATED
|
61 wstats
->qual
.qual
= local
->comms_qual
;
62 wstats
->qual
.level
= local
->avg_signal
;
63 wstats
->qual
.noise
= local
->avg_noise
;
65 wstats
->qual
.qual
= 0;
66 wstats
->qual
.level
= 0;
67 wstats
->qual
.noise
= 0;
68 wstats
->qual
.updated
= IW_QUAL_ALL_INVALID
;
75 static int prism2_get_datarates(struct net_device
*dev
, u8
*rates
)
77 struct hostap_interface
*iface
;
83 iface
= netdev_priv(dev
);
86 len
= local
->func
->get_rid(dev
, HFA384X_RID_SUPPORTEDDATARATES
, buf
,
91 val
= le16_to_cpu(*(__le16
*) buf
); /* string length */
93 if (len
- 2 < val
|| val
> 10)
96 memcpy(rates
, buf
+ 2, val
);
101 static int prism2_get_name(struct net_device
*dev
,
102 struct iw_request_info
*info
,
103 char *name
, char *extra
)
106 int len
, i
, over2
= 0;
108 len
= prism2_get_datarates(dev
, rates
);
110 for (i
= 0; i
< len
; i
++) {
111 if (rates
[i
] == 0x0b || rates
[i
] == 0x16) {
117 strcpy(name
, over2
? "IEEE 802.11b" : "IEEE 802.11-DS");
123 static int prism2_ioctl_siwencode(struct net_device
*dev
,
124 struct iw_request_info
*info
,
125 struct iw_point
*erq
, char *keybuf
)
127 struct hostap_interface
*iface
;
130 struct lib80211_crypt_data
**crypt
;
132 iface
= netdev_priv(dev
);
133 local
= iface
->local
;
135 i
= erq
->flags
& IW_ENCODE_INDEX
;
137 i
= local
->crypt_info
.tx_keyidx
;
140 if (i
< 0 || i
>= WEP_KEYS
)
143 crypt
= &local
->crypt_info
.crypt
[i
];
145 if (erq
->flags
& IW_ENCODE_DISABLED
) {
147 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
151 if (*crypt
!= NULL
&& (*crypt
)->ops
!= NULL
&&
152 strcmp((*crypt
)->ops
->name
, "WEP") != 0) {
153 /* changing to use WEP; deinit previously used algorithm */
154 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
157 if (*crypt
== NULL
) {
158 struct lib80211_crypt_data
*new_crypt
;
160 /* take WEP into use */
161 new_crypt
= kzalloc(sizeof(struct lib80211_crypt_data
),
163 if (new_crypt
== NULL
)
165 new_crypt
->ops
= lib80211_get_crypto_ops("WEP");
166 if (!new_crypt
->ops
) {
167 request_module("lib80211_crypt_wep");
168 new_crypt
->ops
= lib80211_get_crypto_ops("WEP");
170 if (new_crypt
->ops
&& try_module_get(new_crypt
->ops
->owner
))
171 new_crypt
->priv
= new_crypt
->ops
->init(i
);
172 if (!new_crypt
->ops
|| !new_crypt
->priv
) {
176 printk(KERN_WARNING
"%s: could not initialize WEP: "
177 "load module hostap_crypt_wep.o\n",
184 if (erq
->length
> 0) {
185 int len
= erq
->length
<= 5 ? 5 : 13;
187 if (len
> erq
->length
)
188 memset(keybuf
+ erq
->length
, 0, len
- erq
->length
);
189 (*crypt
)->ops
->set_key(keybuf
, len
, NULL
, (*crypt
)->priv
);
190 for (j
= 0; j
< WEP_KEYS
; j
++) {
191 if (j
!= i
&& local
->crypt_info
.crypt
[j
]) {
197 local
->crypt_info
.tx_keyidx
= i
;
199 /* No key data - just set the default TX key index */
200 local
->crypt_info
.tx_keyidx
= i
;
204 local
->open_wep
= erq
->flags
& IW_ENCODE_OPEN
;
206 if (hostap_set_encryption(local
)) {
207 printk(KERN_DEBUG
"%s: set_encryption failed\n", dev
->name
);
211 /* Do not reset port0 if card is in Managed mode since resetting will
212 * generate new IEEE 802.11 authentication which may end up in looping
213 * with IEEE 802.1X. Prism2 documentation seem to require port reset
214 * after WEP configuration. However, keys are apparently changed at
215 * least in Managed mode. */
216 if (local
->iw_mode
!= IW_MODE_INFRA
&& local
->func
->reset_port(dev
)) {
217 printk(KERN_DEBUG
"%s: reset_port failed\n", dev
->name
);
225 static int prism2_ioctl_giwencode(struct net_device
*dev
,
226 struct iw_request_info
*info
,
227 struct iw_point
*erq
, char *key
)
229 struct hostap_interface
*iface
;
233 struct lib80211_crypt_data
*crypt
;
235 iface
= netdev_priv(dev
);
236 local
= iface
->local
;
238 i
= erq
->flags
& IW_ENCODE_INDEX
;
240 i
= local
->crypt_info
.tx_keyidx
;
243 if (i
< 0 || i
>= WEP_KEYS
)
246 crypt
= local
->crypt_info
.crypt
[i
];
249 if (crypt
== NULL
|| crypt
->ops
== NULL
) {
251 erq
->flags
|= IW_ENCODE_DISABLED
;
255 if (strcmp(crypt
->ops
->name
, "WEP") != 0) {
256 /* only WEP is supported with wireless extensions, so just
257 * report that encryption is used */
259 erq
->flags
|= IW_ENCODE_ENABLED
;
263 /* Reads from HFA384X_RID_CNFDEFAULTKEY* return bogus values, so show
264 * the keys from driver buffer */
265 len
= crypt
->ops
->get_key(key
, WEP_KEY_LEN
, NULL
, crypt
->priv
);
266 erq
->length
= (len
>= 0 ? len
: 0);
268 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFWEPFLAGS
, &val
, 2, 1) < 0)
270 printk("CNFWEPFLAGS reading failed\n");
274 if (val
& HFA384X_WEPFLAGS_PRIVACYINVOKED
)
275 erq
->flags
|= IW_ENCODE_ENABLED
;
277 erq
->flags
|= IW_ENCODE_DISABLED
;
278 if (val
& HFA384X_WEPFLAGS_EXCLUDEUNENCRYPTED
)
279 erq
->flags
|= IW_ENCODE_RESTRICTED
;
281 erq
->flags
|= IW_ENCODE_OPEN
;
287 static int hostap_set_rate(struct net_device
*dev
)
289 struct hostap_interface
*iface
;
291 int ret
, basic_rates
;
293 iface
= netdev_priv(dev
);
294 local
= iface
->local
;
296 basic_rates
= local
->basic_rates
& local
->tx_rate_control
;
297 if (!basic_rates
|| basic_rates
!= local
->basic_rates
) {
298 printk(KERN_INFO
"%s: updating basic rate set automatically "
299 "to match with the new supported rate set\n",
302 basic_rates
= local
->tx_rate_control
;
304 local
->basic_rates
= basic_rates
;
305 if (hostap_set_word(dev
, HFA384X_RID_CNFBASICRATES
,
307 printk(KERN_WARNING
"%s: failed to set "
308 "cnfBasicRates\n", dev
->name
);
311 ret
= (hostap_set_word(dev
, HFA384X_RID_TXRATECONTROL
,
312 local
->tx_rate_control
) ||
313 hostap_set_word(dev
, HFA384X_RID_CNFSUPPORTEDRATES
,
314 local
->tx_rate_control
) ||
315 local
->func
->reset_port(dev
));
318 printk(KERN_WARNING
"%s: TXRateControl/cnfSupportedRates "
319 "setting to 0x%x failed\n",
320 dev
->name
, local
->tx_rate_control
);
323 /* Update TX rate configuration for all STAs based on new operational
325 hostap_update_rates(local
);
331 static int prism2_ioctl_siwrate(struct net_device
*dev
,
332 struct iw_request_info
*info
,
333 struct iw_param
*rrq
, char *extra
)
335 struct hostap_interface
*iface
;
338 iface
= netdev_priv(dev
);
339 local
= iface
->local
;
342 switch (rrq
->value
) {
344 local
->tx_rate_control
= HFA384X_RATES_11MBPS
;
347 local
->tx_rate_control
= HFA384X_RATES_5MBPS
;
350 local
->tx_rate_control
= HFA384X_RATES_2MBPS
;
353 local
->tx_rate_control
= HFA384X_RATES_1MBPS
;
356 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
357 HFA384X_RATES_2MBPS
| HFA384X_RATES_5MBPS
|
358 HFA384X_RATES_11MBPS
;
362 switch (rrq
->value
) {
364 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
365 HFA384X_RATES_2MBPS
| HFA384X_RATES_5MBPS
|
366 HFA384X_RATES_11MBPS
;
369 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
370 HFA384X_RATES_2MBPS
| HFA384X_RATES_5MBPS
;
373 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
377 local
->tx_rate_control
= HFA384X_RATES_1MBPS
;
380 local
->tx_rate_control
= HFA384X_RATES_1MBPS
|
381 HFA384X_RATES_2MBPS
| HFA384X_RATES_5MBPS
|
382 HFA384X_RATES_11MBPS
;
387 return hostap_set_rate(dev
);
391 static int prism2_ioctl_giwrate(struct net_device
*dev
,
392 struct iw_request_info
*info
,
393 struct iw_param
*rrq
, char *extra
)
396 struct hostap_interface
*iface
;
400 iface
= netdev_priv(dev
);
401 local
= iface
->local
;
403 if (local
->func
->get_rid(dev
, HFA384X_RID_TXRATECONTROL
, &val
, 2, 1) <
407 if ((val
& 0x1) && (val
> 1))
412 if (local
->iw_mode
== IW_MODE_MASTER
&& local
->ap
!= NULL
&&
413 !local
->fw_tx_rate_control
) {
414 /* HFA384X_RID_CURRENTTXRATE seems to always be 2 Mbps in
415 * Host AP mode, so use the recorded TX rate of the last sent
417 rrq
->value
= local
->ap
->last_tx_rate
> 0 ?
418 local
->ap
->last_tx_rate
* 100000 : 11000000;
422 if (local
->func
->get_rid(dev
, HFA384X_RID_CURRENTTXRATE
, &val
, 2, 1) <
427 case HFA384X_RATES_1MBPS
:
428 rrq
->value
= 1000000;
430 case HFA384X_RATES_2MBPS
:
431 rrq
->value
= 2000000;
433 case HFA384X_RATES_5MBPS
:
434 rrq
->value
= 5500000;
436 case HFA384X_RATES_11MBPS
:
437 rrq
->value
= 11000000;
440 /* should not happen */
441 rrq
->value
= 11000000;
450 static int prism2_ioctl_siwsens(struct net_device
*dev
,
451 struct iw_request_info
*info
,
452 struct iw_param
*sens
, char *extra
)
454 struct hostap_interface
*iface
;
457 iface
= netdev_priv(dev
);
458 local
= iface
->local
;
460 /* Set the desired AP density */
461 if (sens
->value
< 1 || sens
->value
> 3)
464 if (hostap_set_word(dev
, HFA384X_RID_CNFSYSTEMSCALE
, sens
->value
) ||
465 local
->func
->reset_port(dev
))
471 static int prism2_ioctl_giwsens(struct net_device
*dev
,
472 struct iw_request_info
*info
,
473 struct iw_param
*sens
, char *extra
)
475 struct hostap_interface
*iface
;
479 iface
= netdev_priv(dev
);
480 local
= iface
->local
;
482 /* Get the current AP density */
483 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFSYSTEMSCALE
, &val
, 2, 1) <
487 sens
->value
= le16_to_cpu(val
);
494 /* Deprecated in new wireless extension API */
495 static int prism2_ioctl_giwaplist(struct net_device
*dev
,
496 struct iw_request_info
*info
,
497 struct iw_point
*data
, char *extra
)
499 struct hostap_interface
*iface
;
501 struct sockaddr
*addr
;
502 struct iw_quality
*qual
;
504 iface
= netdev_priv(dev
);
505 local
= iface
->local
;
507 if (local
->iw_mode
!= IW_MODE_MASTER
) {
508 printk(KERN_DEBUG
"SIOCGIWAPLIST is currently only supported "
509 "in Host AP mode\n");
514 addr
= kmalloc(sizeof(struct sockaddr
) * IW_MAX_AP
, GFP_KERNEL
);
515 qual
= kmalloc(sizeof(struct iw_quality
) * IW_MAX_AP
, GFP_KERNEL
);
516 if (addr
== NULL
|| qual
== NULL
) {
523 data
->length
= prism2_ap_get_sta_qual(local
, addr
, qual
, IW_MAX_AP
, 1);
525 memcpy(extra
, &addr
, sizeof(struct sockaddr
) * data
->length
);
526 data
->flags
= 1; /* has quality information */
527 memcpy(extra
+ sizeof(struct sockaddr
) * data
->length
, &qual
,
528 sizeof(struct iw_quality
) * data
->length
);
536 static int prism2_ioctl_siwrts(struct net_device
*dev
,
537 struct iw_request_info
*info
,
538 struct iw_param
*rts
, char *extra
)
540 struct hostap_interface
*iface
;
544 iface
= netdev_priv(dev
);
545 local
= iface
->local
;
548 val
= cpu_to_le16(2347);
549 else if (rts
->value
< 0 || rts
->value
> 2347)
552 val
= cpu_to_le16(rts
->value
);
554 if (local
->func
->set_rid(dev
, HFA384X_RID_RTSTHRESHOLD
, &val
, 2) ||
555 local
->func
->reset_port(dev
))
558 local
->rts_threshold
= rts
->value
;
563 static int prism2_ioctl_giwrts(struct net_device
*dev
,
564 struct iw_request_info
*info
,
565 struct iw_param
*rts
, char *extra
)
567 struct hostap_interface
*iface
;
571 iface
= netdev_priv(dev
);
572 local
= iface
->local
;
574 if (local
->func
->get_rid(dev
, HFA384X_RID_RTSTHRESHOLD
, &val
, 2, 1) <
578 rts
->value
= le16_to_cpu(val
);
579 rts
->disabled
= (rts
->value
== 2347);
586 static int prism2_ioctl_siwfrag(struct net_device
*dev
,
587 struct iw_request_info
*info
,
588 struct iw_param
*rts
, char *extra
)
590 struct hostap_interface
*iface
;
594 iface
= netdev_priv(dev
);
595 local
= iface
->local
;
598 val
= cpu_to_le16(2346);
599 else if (rts
->value
< 256 || rts
->value
> 2346)
602 val
= cpu_to_le16(rts
->value
& ~0x1); /* even numbers only */
604 local
->fragm_threshold
= rts
->value
& ~0x1;
605 if (local
->func
->set_rid(dev
, HFA384X_RID_FRAGMENTATIONTHRESHOLD
, &val
,
607 || local
->func
->reset_port(dev
))
613 static int prism2_ioctl_giwfrag(struct net_device
*dev
,
614 struct iw_request_info
*info
,
615 struct iw_param
*rts
, char *extra
)
617 struct hostap_interface
*iface
;
621 iface
= netdev_priv(dev
);
622 local
= iface
->local
;
624 if (local
->func
->get_rid(dev
, HFA384X_RID_FRAGMENTATIONTHRESHOLD
,
628 rts
->value
= le16_to_cpu(val
);
629 rts
->disabled
= (rts
->value
== 2346);
636 #ifndef PRISM2_NO_STATION_MODES
637 static int hostap_join_ap(struct net_device
*dev
)
639 struct hostap_interface
*iface
;
641 struct hfa384x_join_request req
;
644 struct hfa384x_hostscan_result
*entry
;
646 iface
= netdev_priv(dev
);
647 local
= iface
->local
;
649 memcpy(req
.bssid
, local
->preferred_ap
, ETH_ALEN
);
652 spin_lock_irqsave(&local
->lock
, flags
);
653 for (i
= 0; i
< local
->last_scan_results_count
; i
++) {
654 if (!local
->last_scan_results
)
656 entry
= &local
->last_scan_results
[i
];
657 if (memcmp(local
->preferred_ap
, entry
->bssid
, ETH_ALEN
) == 0) {
658 req
.channel
= entry
->chid
;
662 spin_unlock_irqrestore(&local
->lock
, flags
);
664 if (local
->func
->set_rid(dev
, HFA384X_RID_JOINREQUEST
, &req
,
666 printk(KERN_DEBUG
"%s: JoinRequest %pM failed\n",
667 dev
->name
, local
->preferred_ap
);
671 printk(KERN_DEBUG
"%s: Trying to join BSSID %pM\n",
672 dev
->name
, local
->preferred_ap
);
676 #endif /* PRISM2_NO_STATION_MODES */
679 static int prism2_ioctl_siwap(struct net_device
*dev
,
680 struct iw_request_info
*info
,
681 struct sockaddr
*ap_addr
, char *extra
)
683 #ifdef PRISM2_NO_STATION_MODES
685 #else /* PRISM2_NO_STATION_MODES */
686 struct hostap_interface
*iface
;
689 iface
= netdev_priv(dev
);
690 local
= iface
->local
;
692 memcpy(local
->preferred_ap
, &ap_addr
->sa_data
, ETH_ALEN
);
694 if (local
->host_roaming
== 1 && local
->iw_mode
== IW_MODE_INFRA
) {
695 struct hfa384x_scan_request scan_req
;
696 memset(&scan_req
, 0, sizeof(scan_req
));
697 scan_req
.channel_list
= cpu_to_le16(0x3fff);
698 scan_req
.txrate
= cpu_to_le16(HFA384X_RATES_1MBPS
);
699 if (local
->func
->set_rid(dev
, HFA384X_RID_SCANREQUEST
,
700 &scan_req
, sizeof(scan_req
))) {
701 printk(KERN_DEBUG
"%s: ScanResults request failed - "
702 "preferred AP delayed to next unsolicited "
703 "scan\n", dev
->name
);
705 } else if (local
->host_roaming
== 2 &&
706 local
->iw_mode
== IW_MODE_INFRA
) {
707 if (hostap_join_ap(dev
))
710 printk(KERN_DEBUG
"%s: Preferred AP (SIOCSIWAP) is used only "
711 "in Managed mode when host_roaming is enabled\n",
716 #endif /* PRISM2_NO_STATION_MODES */
719 static int prism2_ioctl_giwap(struct net_device
*dev
,
720 struct iw_request_info
*info
,
721 struct sockaddr
*ap_addr
, char *extra
)
723 struct hostap_interface
*iface
;
726 iface
= netdev_priv(dev
);
727 local
= iface
->local
;
729 ap_addr
->sa_family
= ARPHRD_ETHER
;
730 switch (iface
->type
) {
731 case HOSTAP_INTERFACE_AP
:
732 memcpy(&ap_addr
->sa_data
, dev
->dev_addr
, ETH_ALEN
);
734 case HOSTAP_INTERFACE_STA
:
735 memcpy(&ap_addr
->sa_data
, local
->assoc_ap_addr
, ETH_ALEN
);
737 case HOSTAP_INTERFACE_WDS
:
738 memcpy(&ap_addr
->sa_data
, iface
->u
.wds
.remote_addr
, ETH_ALEN
);
741 if (local
->func
->get_rid(dev
, HFA384X_RID_CURRENTBSSID
,
742 &ap_addr
->sa_data
, ETH_ALEN
, 1) < 0)
745 /* local->bssid is also updated in LinkStatus handler when in
747 memcpy(local
->bssid
, &ap_addr
->sa_data
, ETH_ALEN
);
755 static int prism2_ioctl_siwnickn(struct net_device
*dev
,
756 struct iw_request_info
*info
,
757 struct iw_point
*data
, char *nickname
)
759 struct hostap_interface
*iface
;
762 iface
= netdev_priv(dev
);
763 local
= iface
->local
;
765 memset(local
->name
, 0, sizeof(local
->name
));
766 memcpy(local
->name
, nickname
, data
->length
);
769 if (hostap_set_string(dev
, HFA384X_RID_CNFOWNNAME
, local
->name
) ||
770 local
->func
->reset_port(dev
))
776 static int prism2_ioctl_giwnickn(struct net_device
*dev
,
777 struct iw_request_info
*info
,
778 struct iw_point
*data
, char *nickname
)
780 struct hostap_interface
*iface
;
783 char name
[MAX_NAME_LEN
+ 3];
786 iface
= netdev_priv(dev
);
787 local
= iface
->local
;
789 len
= local
->func
->get_rid(dev
, HFA384X_RID_CNFOWNNAME
,
790 &name
, MAX_NAME_LEN
+ 2, 0);
791 val
= le16_to_cpu(*(__le16
*) name
);
792 if (len
> MAX_NAME_LEN
+ 2 || len
< 0 || val
> MAX_NAME_LEN
)
795 name
[val
+ 2] = '\0';
796 data
->length
= val
+ 1;
797 memcpy(nickname
, name
+ 2, val
+ 1);
803 static int prism2_ioctl_siwfreq(struct net_device
*dev
,
804 struct iw_request_info
*info
,
805 struct iw_freq
*freq
, char *extra
)
807 struct hostap_interface
*iface
;
810 iface
= netdev_priv(dev
);
811 local
= iface
->local
;
815 freq
->m
/ 100000 >= freq_list
[0] &&
816 freq
->m
/ 100000 <= freq_list
[FREQ_COUNT
- 1]) {
818 int fr
= freq
->m
/ 100000;
819 for (ch
= 0; ch
< FREQ_COUNT
; ch
++) {
820 if (fr
== freq_list
[ch
]) {
828 if (freq
->e
!= 0 || freq
->m
< 1 || freq
->m
> FREQ_COUNT
||
829 !(local
->channel_mask
& (1 << (freq
->m
- 1))))
832 local
->channel
= freq
->m
; /* channel is used in prism2_setup_rids() */
833 if (hostap_set_word(dev
, HFA384X_RID_CNFOWNCHANNEL
, local
->channel
) ||
834 local
->func
->reset_port(dev
))
840 static int prism2_ioctl_giwfreq(struct net_device
*dev
,
841 struct iw_request_info
*info
,
842 struct iw_freq
*freq
, char *extra
)
844 struct hostap_interface
*iface
;
848 iface
= netdev_priv(dev
);
849 local
= iface
->local
;
851 if (local
->func
->get_rid(dev
, HFA384X_RID_CURRENTCHANNEL
, &val
, 2, 1) <
856 if (val
< 1 || val
> FREQ_COUNT
)
859 freq
->m
= freq_list
[val
- 1] * 100000;
866 static void hostap_monitor_set_type(local_info_t
*local
)
868 struct net_device
*dev
= local
->ddev
;
873 if (local
->monitor_type
== PRISM2_MONITOR_PRISM
||
874 local
->monitor_type
== PRISM2_MONITOR_CAPHDR
) {
875 dev
->type
= ARPHRD_IEEE80211_PRISM
;
876 } else if (local
->monitor_type
== PRISM2_MONITOR_RADIOTAP
) {
877 dev
->type
= ARPHRD_IEEE80211_RADIOTAP
;
879 dev
->type
= ARPHRD_IEEE80211
;
884 static int prism2_ioctl_siwessid(struct net_device
*dev
,
885 struct iw_request_info
*info
,
886 struct iw_point
*data
, char *ssid
)
888 struct hostap_interface
*iface
;
891 iface
= netdev_priv(dev
);
892 local
= iface
->local
;
894 if (iface
->type
== HOSTAP_INTERFACE_WDS
)
897 if (data
->flags
== 0)
898 ssid
[0] = '\0'; /* ANY */
900 if (local
->iw_mode
== IW_MODE_MASTER
&& ssid
[0] == '\0') {
901 /* Setting SSID to empty string seems to kill the card in
903 printk(KERN_DEBUG
"%s: Host AP mode does not support "
904 "'Any' essid\n", dev
->name
);
908 memcpy(local
->essid
, ssid
, data
->length
);
909 local
->essid
[data
->length
] = '\0';
911 if ((!local
->fw_ap
&&
912 hostap_set_string(dev
, HFA384X_RID_CNFDESIREDSSID
, local
->essid
))
913 || hostap_set_string(dev
, HFA384X_RID_CNFOWNSSID
, local
->essid
) ||
914 local
->func
->reset_port(dev
))
920 static int prism2_ioctl_giwessid(struct net_device
*dev
,
921 struct iw_request_info
*info
,
922 struct iw_point
*data
, char *essid
)
924 struct hostap_interface
*iface
;
928 iface
= netdev_priv(dev
);
929 local
= iface
->local
;
931 if (iface
->type
== HOSTAP_INTERFACE_WDS
)
934 data
->flags
= 1; /* active */
935 if (local
->iw_mode
== IW_MODE_MASTER
) {
936 data
->length
= strlen(local
->essid
);
937 memcpy(essid
, local
->essid
, IW_ESSID_MAX_SIZE
);
940 char ssid
[MAX_SSID_LEN
+ 2];
941 memset(ssid
, 0, sizeof(ssid
));
942 len
= local
->func
->get_rid(dev
, HFA384X_RID_CURRENTSSID
,
943 &ssid
, MAX_SSID_LEN
+ 2, 0);
944 val
= le16_to_cpu(*(__le16
*) ssid
);
945 if (len
> MAX_SSID_LEN
+ 2 || len
< 0 || val
> MAX_SSID_LEN
) {
949 memcpy(essid
, ssid
+ 2, IW_ESSID_MAX_SIZE
);
956 static int prism2_ioctl_giwrange(struct net_device
*dev
,
957 struct iw_request_info
*info
,
958 struct iw_point
*data
, char *extra
)
960 struct hostap_interface
*iface
;
962 struct iw_range
*range
= (struct iw_range
*) extra
;
967 iface
= netdev_priv(dev
);
968 local
= iface
->local
;
970 data
->length
= sizeof(struct iw_range
);
971 memset(range
, 0, sizeof(struct iw_range
));
973 /* TODO: could fill num_txpower and txpower array with
974 * something; however, there are 128 different values.. */
976 range
->txpower_capa
= IW_TXPOW_DBM
;
978 if (local
->iw_mode
== IW_MODE_INFRA
|| local
->iw_mode
== IW_MODE_ADHOC
)
980 range
->min_pmp
= 1 * 1024;
981 range
->max_pmp
= 65535 * 1024;
982 range
->min_pmt
= 1 * 1024;
983 range
->max_pmt
= 1000 * 1024;
984 range
->pmp_flags
= IW_POWER_PERIOD
;
985 range
->pmt_flags
= IW_POWER_TIMEOUT
;
986 range
->pm_capa
= IW_POWER_PERIOD
| IW_POWER_TIMEOUT
|
987 IW_POWER_UNICAST_R
| IW_POWER_ALL_R
;
990 range
->we_version_compiled
= WIRELESS_EXT
;
991 range
->we_version_source
= 18;
993 range
->retry_capa
= IW_RETRY_LIMIT
;
994 range
->retry_flags
= IW_RETRY_LIMIT
;
995 range
->min_retry
= 0;
996 range
->max_retry
= 255;
998 range
->num_channels
= FREQ_COUNT
;
1001 for (i
= 0; i
< FREQ_COUNT
; i
++) {
1002 if (local
->channel_mask
& (1 << i
)) {
1003 range
->freq
[val
].i
= i
+ 1;
1004 range
->freq
[val
].m
= freq_list
[i
] * 100000;
1005 range
->freq
[val
].e
= 1;
1008 if (val
== IW_MAX_FREQUENCIES
)
1011 range
->num_frequency
= val
;
1013 if (local
->sta_fw_ver
>= PRISM2_FW_VER(1,3,1)) {
1014 range
->max_qual
.qual
= 70; /* what is correct max? This was not
1015 * documented exactly. At least
1016 * 69 has been observed. */
1017 range
->max_qual
.level
= 0; /* dB */
1018 range
->max_qual
.noise
= 0; /* dB */
1020 /* What would be suitable values for "average/typical" qual? */
1021 range
->avg_qual
.qual
= 20;
1022 range
->avg_qual
.level
= -60;
1023 range
->avg_qual
.noise
= -95;
1025 range
->max_qual
.qual
= 92; /* 0 .. 92 */
1026 range
->max_qual
.level
= 154; /* 27 .. 154 */
1027 range
->max_qual
.noise
= 154; /* 27 .. 154 */
1029 range
->sensitivity
= 3;
1031 range
->max_encoding_tokens
= WEP_KEYS
;
1032 range
->num_encoding_sizes
= 2;
1033 range
->encoding_size
[0] = 5;
1034 range
->encoding_size
[1] = 13;
1037 len
= prism2_get_datarates(dev
, rates
);
1038 range
->num_bitrates
= 0;
1039 for (i
= 0; i
< len
; i
++) {
1040 if (range
->num_bitrates
< IW_MAX_BITRATES
) {
1041 range
->bitrate
[range
->num_bitrates
] =
1043 range
->num_bitrates
++;
1045 if (rates
[i
] == 0x0b || rates
[i
] == 0x16)
1048 /* estimated maximum TCP throughput values (bps) */
1049 range
->throughput
= over2
? 5500000 : 1500000;
1052 range
->max_rts
= 2347;
1053 range
->min_frag
= 256;
1054 range
->max_frag
= 2346;
1056 /* Event capability (kernel + driver) */
1057 range
->event_capa
[0] = (IW_EVENT_CAPA_K_0
|
1058 IW_EVENT_CAPA_MASK(SIOCGIWTHRSPY
) |
1059 IW_EVENT_CAPA_MASK(SIOCGIWAP
) |
1060 IW_EVENT_CAPA_MASK(SIOCGIWSCAN
));
1061 range
->event_capa
[1] = IW_EVENT_CAPA_K_1
;
1062 range
->event_capa
[4] = (IW_EVENT_CAPA_MASK(IWEVTXDROP
) |
1063 IW_EVENT_CAPA_MASK(IWEVCUSTOM
) |
1064 IW_EVENT_CAPA_MASK(IWEVREGISTERED
) |
1065 IW_EVENT_CAPA_MASK(IWEVEXPIRED
));
1067 range
->enc_capa
= IW_ENC_CAPA_WPA
| IW_ENC_CAPA_WPA2
|
1068 IW_ENC_CAPA_CIPHER_TKIP
| IW_ENC_CAPA_CIPHER_CCMP
;
1070 if (local
->sta_fw_ver
>= PRISM2_FW_VER(1,3,1))
1071 range
->scan_capa
= IW_SCAN_CAPA_ESSID
;
1077 static int hostap_monitor_mode_enable(local_info_t
*local
)
1079 struct net_device
*dev
= local
->dev
;
1081 printk(KERN_DEBUG
"Enabling monitor mode\n");
1082 hostap_monitor_set_type(local
);
1084 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
1085 HFA384X_PORTTYPE_PSEUDO_IBSS
)) {
1086 printk(KERN_DEBUG
"Port type setting for monitor mode "
1091 /* Host decrypt is needed to get the IV and ICV fields;
1092 * however, monitor mode seems to remove WEP flag from frame
1094 if (hostap_set_word(dev
, HFA384X_RID_CNFWEPFLAGS
,
1095 HFA384X_WEPFLAGS_HOSTENCRYPT
|
1096 HFA384X_WEPFLAGS_HOSTDECRYPT
)) {
1097 printk(KERN_DEBUG
"WEP flags setting failed\n");
1101 if (local
->func
->reset_port(dev
) ||
1102 local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
1103 (HFA384X_TEST_MONITOR
<< 8),
1105 printk(KERN_DEBUG
"Setting monitor mode failed\n");
1113 static int hostap_monitor_mode_disable(local_info_t
*local
)
1115 struct net_device
*dev
= local
->ddev
;
1120 printk(KERN_DEBUG
"%s: Disabling monitor mode\n", dev
->name
);
1121 dev
->type
= ARPHRD_ETHER
;
1123 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
1124 (HFA384X_TEST_STOP
<< 8),
1127 return hostap_set_encryption(local
);
1131 static int prism2_ioctl_siwmode(struct net_device
*dev
,
1132 struct iw_request_info
*info
,
1133 __u32
*mode
, char *extra
)
1135 struct hostap_interface
*iface
;
1136 local_info_t
*local
;
1137 int double_reset
= 0;
1139 iface
= netdev_priv(dev
);
1140 local
= iface
->local
;
1142 if (*mode
!= IW_MODE_ADHOC
&& *mode
!= IW_MODE_INFRA
&&
1143 *mode
!= IW_MODE_MASTER
&& *mode
!= IW_MODE_REPEAT
&&
1144 *mode
!= IW_MODE_MONITOR
)
1147 #ifdef PRISM2_NO_STATION_MODES
1148 if (*mode
== IW_MODE_ADHOC
|| *mode
== IW_MODE_INFRA
)
1150 #endif /* PRISM2_NO_STATION_MODES */
1152 if (*mode
== local
->iw_mode
)
1155 if (*mode
== IW_MODE_MASTER
&& local
->essid
[0] == '\0') {
1156 printk(KERN_WARNING
"%s: empty SSID not allowed in Master "
1157 "mode\n", dev
->name
);
1161 if (local
->iw_mode
== IW_MODE_MONITOR
)
1162 hostap_monitor_mode_disable(local
);
1164 if ((local
->iw_mode
== IW_MODE_ADHOC
||
1165 local
->iw_mode
== IW_MODE_MONITOR
) && *mode
== IW_MODE_MASTER
) {
1166 /* There seems to be a firmware bug in at least STA f/w v1.5.6
1167 * that leaves beacon frames to use IBSS type when moving from
1168 * IBSS to Host AP mode. Doing double Port0 reset seems to be
1169 * enough to workaround this. */
1173 printk(KERN_DEBUG
"prism2: %s: operating mode changed "
1174 "%d -> %d\n", dev
->name
, local
->iw_mode
, *mode
);
1175 local
->iw_mode
= *mode
;
1177 if (local
->iw_mode
== IW_MODE_MONITOR
)
1178 hostap_monitor_mode_enable(local
);
1179 else if (local
->iw_mode
== IW_MODE_MASTER
&& !local
->host_encrypt
&&
1180 !local
->fw_encrypt_ok
) {
1181 printk(KERN_DEBUG
"%s: defaulting to host-based encryption as "
1182 "a workaround for firmware bug in Host AP mode WEP\n",
1184 local
->host_encrypt
= 1;
1187 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
1188 hostap_get_porttype(local
)))
1191 if (local
->func
->reset_port(dev
))
1193 if (double_reset
&& local
->func
->reset_port(dev
))
1196 if (local
->iw_mode
!= IW_MODE_INFRA
&& local
->iw_mode
!= IW_MODE_ADHOC
)
1198 /* netif_carrier is used only in client modes for now, so make
1199 * sure carrier is on when moving to non-client modes. */
1200 netif_carrier_on(local
->dev
);
1201 netif_carrier_on(local
->ddev
);
1207 static int prism2_ioctl_giwmode(struct net_device
*dev
,
1208 struct iw_request_info
*info
,
1209 __u32
*mode
, char *extra
)
1211 struct hostap_interface
*iface
;
1212 local_info_t
*local
;
1214 iface
= netdev_priv(dev
);
1215 local
= iface
->local
;
1217 switch (iface
->type
) {
1218 case HOSTAP_INTERFACE_STA
:
1219 *mode
= IW_MODE_INFRA
;
1221 case HOSTAP_INTERFACE_WDS
:
1222 *mode
= IW_MODE_REPEAT
;
1225 *mode
= local
->iw_mode
;
1232 static int prism2_ioctl_siwpower(struct net_device
*dev
,
1233 struct iw_request_info
*info
,
1234 struct iw_param
*wrq
, char *extra
)
1236 #ifdef PRISM2_NO_STATION_MODES
1238 #else /* PRISM2_NO_STATION_MODES */
1242 return hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 0);
1244 switch (wrq
->flags
& IW_POWER_MODE
) {
1245 case IW_POWER_UNICAST_R
:
1246 ret
= hostap_set_word(dev
, HFA384X_RID_CNFMULTICASTRECEIVE
, 0);
1249 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 1);
1253 case IW_POWER_ALL_R
:
1254 ret
= hostap_set_word(dev
, HFA384X_RID_CNFMULTICASTRECEIVE
, 1);
1257 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 1);
1267 if (wrq
->flags
& IW_POWER_TIMEOUT
) {
1268 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 1);
1271 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMHOLDOVERDURATION
,
1276 if (wrq
->flags
& IW_POWER_PERIOD
) {
1277 ret
= hostap_set_word(dev
, HFA384X_RID_CNFPMENABLED
, 1);
1280 ret
= hostap_set_word(dev
, HFA384X_RID_CNFMAXSLEEPDURATION
,
1287 #endif /* PRISM2_NO_STATION_MODES */
1291 static int prism2_ioctl_giwpower(struct net_device
*dev
,
1292 struct iw_request_info
*info
,
1293 struct iw_param
*rrq
, char *extra
)
1295 #ifdef PRISM2_NO_STATION_MODES
1297 #else /* PRISM2_NO_STATION_MODES */
1298 struct hostap_interface
*iface
;
1299 local_info_t
*local
;
1300 __le16 enable
, mcast
;
1302 iface
= netdev_priv(dev
);
1303 local
= iface
->local
;
1305 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFPMENABLED
, &enable
, 2, 1)
1309 if (!le16_to_cpu(enable
)) {
1316 if ((rrq
->flags
& IW_POWER_TYPE
) == IW_POWER_TIMEOUT
) {
1318 if (local
->func
->get_rid(dev
,
1319 HFA384X_RID_CNFPMHOLDOVERDURATION
,
1320 &timeout
, 2, 1) < 0)
1323 rrq
->flags
= IW_POWER_TIMEOUT
;
1324 rrq
->value
= le16_to_cpu(timeout
) * 1024;
1327 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFMAXSLEEPDURATION
,
1331 rrq
->flags
= IW_POWER_PERIOD
;
1332 rrq
->value
= le16_to_cpu(period
) * 1024;
1335 if (local
->func
->get_rid(dev
, HFA384X_RID_CNFMULTICASTRECEIVE
, &mcast
,
1339 if (le16_to_cpu(mcast
))
1340 rrq
->flags
|= IW_POWER_ALL_R
;
1342 rrq
->flags
|= IW_POWER_UNICAST_R
;
1345 #endif /* PRISM2_NO_STATION_MODES */
1349 static int prism2_ioctl_siwretry(struct net_device
*dev
,
1350 struct iw_request_info
*info
,
1351 struct iw_param
*rrq
, char *extra
)
1353 struct hostap_interface
*iface
;
1354 local_info_t
*local
;
1356 iface
= netdev_priv(dev
);
1357 local
= iface
->local
;
1362 /* setting retry limits is not supported with the current station
1363 * firmware code; simulate this with alternative retry count for now */
1364 if (rrq
->flags
== IW_RETRY_LIMIT
) {
1365 if (rrq
->value
< 0) {
1366 /* disable manual retry count setting and use firmware
1368 local
->manual_retry_count
= -1;
1369 local
->tx_control
&= ~HFA384X_TX_CTRL_ALT_RTRY
;
1371 if (hostap_set_word(dev
, HFA384X_RID_CNFALTRETRYCOUNT
,
1373 printk(KERN_DEBUG
"%s: Alternate retry count "
1374 "setting to %d failed\n",
1375 dev
->name
, rrq
->value
);
1379 local
->manual_retry_count
= rrq
->value
;
1380 local
->tx_control
|= HFA384X_TX_CTRL_ALT_RTRY
;
1388 /* what could be done, if firmware would support this.. */
1390 if (rrq
->flags
& IW_RETRY_LIMIT
) {
1391 if (rrq
->flags
& IW_RETRY_LONG
)
1392 HFA384X_RID_LONGRETRYLIMIT
= rrq
->value
;
1393 else if (rrq
->flags
& IW_RETRY_SHORT
)
1394 HFA384X_RID_SHORTRETRYLIMIT
= rrq
->value
;
1396 HFA384X_RID_LONGRETRYLIMIT
= rrq
->value
;
1397 HFA384X_RID_SHORTRETRYLIMIT
= rrq
->value
;
1402 if (rrq
->flags
& IW_RETRY_LIFETIME
) {
1403 HFA384X_RID_MAXTRANSMITLIFETIME
= rrq
->value
/ 1024;
1410 static int prism2_ioctl_giwretry(struct net_device
*dev
,
1411 struct iw_request_info
*info
,
1412 struct iw_param
*rrq
, char *extra
)
1414 struct hostap_interface
*iface
;
1415 local_info_t
*local
;
1416 __le16 shortretry
, longretry
, lifetime
, altretry
;
1418 iface
= netdev_priv(dev
);
1419 local
= iface
->local
;
1421 if (local
->func
->get_rid(dev
, HFA384X_RID_SHORTRETRYLIMIT
, &shortretry
,
1423 local
->func
->get_rid(dev
, HFA384X_RID_LONGRETRYLIMIT
, &longretry
,
1425 local
->func
->get_rid(dev
, HFA384X_RID_MAXTRANSMITLIFETIME
,
1426 &lifetime
, 2, 1) < 0)
1431 if ((rrq
->flags
& IW_RETRY_TYPE
) == IW_RETRY_LIFETIME
) {
1432 rrq
->flags
= IW_RETRY_LIFETIME
;
1433 rrq
->value
= le16_to_cpu(lifetime
) * 1024;
1435 if (local
->manual_retry_count
>= 0) {
1436 rrq
->flags
= IW_RETRY_LIMIT
;
1437 if (local
->func
->get_rid(dev
,
1438 HFA384X_RID_CNFALTRETRYCOUNT
,
1439 &altretry
, 2, 1) >= 0)
1440 rrq
->value
= le16_to_cpu(altretry
);
1442 rrq
->value
= local
->manual_retry_count
;
1443 } else if ((rrq
->flags
& IW_RETRY_LONG
)) {
1444 rrq
->flags
= IW_RETRY_LIMIT
| IW_RETRY_LONG
;
1445 rrq
->value
= le16_to_cpu(longretry
);
1447 rrq
->flags
= IW_RETRY_LIMIT
;
1448 rrq
->value
= le16_to_cpu(shortretry
);
1449 if (shortretry
!= longretry
)
1450 rrq
->flags
|= IW_RETRY_SHORT
;
1457 /* Note! This TX power controlling is experimental and should not be used in
1458 * production use. It just sets raw power register and does not use any kind of
1459 * feedback information from the measured TX power (CR58). This is now
1460 * commented out to make sure that it is not used by accident. TX power
1461 * configuration will be enabled again after proper algorithm using feedback
1462 * has been implemented. */
1464 #ifdef RAW_TXPOWER_SETTING
1465 /* Map HFA386x's CR31 to and from dBm with some sort of ad hoc mapping..
1466 * This version assumes following mapping:
1467 * CR31 is 7-bit value with -64 to +63 range.
1468 * -64 is mapped into +20dBm and +63 into -43dBm.
1469 * This is certainly not an exact mapping for every card, but at least
1470 * increasing dBm value should correspond to increasing TX power.
1473 static int prism2_txpower_hfa386x_to_dBm(u16 val
)
1485 static u16
prism2_txpower_dBm_to_hfa386x(int val
)
1491 else if (val
< -128)
1496 return (unsigned char) tmp
;
1498 #endif /* RAW_TXPOWER_SETTING */
1501 static int prism2_ioctl_siwtxpow(struct net_device
*dev
,
1502 struct iw_request_info
*info
,
1503 struct iw_param
*rrq
, char *extra
)
1505 struct hostap_interface
*iface
;
1506 local_info_t
*local
;
1507 #ifdef RAW_TXPOWER_SETTING
1513 iface
= netdev_priv(dev
);
1514 local
= iface
->local
;
1516 if (rrq
->disabled
) {
1517 if (local
->txpower_type
!= PRISM2_TXPOWER_OFF
) {
1518 val
= 0xff; /* use all standby and sleep modes */
1519 ret
= local
->func
->cmd(dev
, HFA384X_CMDCODE_WRITEMIF
,
1520 HFA386X_CR_A_D_TEST_MODES2
,
1522 printk(KERN_DEBUG
"%s: Turning radio off: %s\n",
1523 dev
->name
, ret
? "failed" : "OK");
1524 local
->txpower_type
= PRISM2_TXPOWER_OFF
;
1526 return (ret
? -EOPNOTSUPP
: 0);
1529 if (local
->txpower_type
== PRISM2_TXPOWER_OFF
) {
1530 val
= 0; /* disable all standby and sleep modes */
1531 ret
= local
->func
->cmd(dev
, HFA384X_CMDCODE_WRITEMIF
,
1532 HFA386X_CR_A_D_TEST_MODES2
, &val
, NULL
);
1533 printk(KERN_DEBUG
"%s: Turning radio on: %s\n",
1534 dev
->name
, ret
? "failed" : "OK");
1535 local
->txpower_type
= PRISM2_TXPOWER_UNKNOWN
;
1538 #ifdef RAW_TXPOWER_SETTING
1539 if (!rrq
->fixed
&& local
->txpower_type
!= PRISM2_TXPOWER_AUTO
) {
1540 printk(KERN_DEBUG
"Setting ALC on\n");
1541 val
= HFA384X_TEST_CFG_BIT_ALC
;
1542 local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
1543 (HFA384X_TEST_CFG_BITS
<< 8), 1, &val
, NULL
);
1544 local
->txpower_type
= PRISM2_TXPOWER_AUTO
;
1548 if (local
->txpower_type
!= PRISM2_TXPOWER_FIXED
) {
1549 printk(KERN_DEBUG
"Setting ALC off\n");
1550 val
= HFA384X_TEST_CFG_BIT_ALC
;
1551 local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
1552 (HFA384X_TEST_CFG_BITS
<< 8), 0, &val
, NULL
);
1553 local
->txpower_type
= PRISM2_TXPOWER_FIXED
;
1556 if (rrq
->flags
== IW_TXPOW_DBM
)
1558 else if (rrq
->flags
== IW_TXPOW_MWATT
)
1562 printk(KERN_DEBUG
"Setting TX power to %d %s\n", rrq
->value
, tmp
);
1564 if (rrq
->flags
!= IW_TXPOW_DBM
) {
1565 printk("SIOCSIWTXPOW with mW is not supported; use dBm\n");
1569 local
->txpower
= rrq
->value
;
1570 val
= prism2_txpower_dBm_to_hfa386x(local
->txpower
);
1571 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_WRITEMIF
,
1572 HFA386X_CR_MANUAL_TX_POWER
, &val
, NULL
))
1574 #else /* RAW_TXPOWER_SETTING */
1577 #endif /* RAW_TXPOWER_SETTING */
1582 static int prism2_ioctl_giwtxpow(struct net_device
*dev
,
1583 struct iw_request_info
*info
,
1584 struct iw_param
*rrq
, char *extra
)
1586 #ifdef RAW_TXPOWER_SETTING
1587 struct hostap_interface
*iface
;
1588 local_info_t
*local
;
1591 iface
= netdev_priv(dev
);
1592 local
= iface
->local
;
1594 rrq
->flags
= IW_TXPOW_DBM
;
1598 if (local
->txpower_type
== PRISM2_TXPOWER_AUTO
) {
1599 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_READMIF
,
1600 HFA386X_CR_MANUAL_TX_POWER
,
1601 NULL
, &resp0
) == 0) {
1602 rrq
->value
= prism2_txpower_hfa386x_to_dBm(resp0
);
1604 /* Could not get real txpower; guess 15 dBm */
1607 } else if (local
->txpower_type
== PRISM2_TXPOWER_OFF
) {
1610 } else if (local
->txpower_type
== PRISM2_TXPOWER_FIXED
) {
1611 rrq
->value
= local
->txpower
;
1614 printk("SIOCGIWTXPOW - unknown txpower_type=%d\n",
1615 local
->txpower_type
);
1618 #else /* RAW_TXPOWER_SETTING */
1620 #endif /* RAW_TXPOWER_SETTING */
1624 #ifndef PRISM2_NO_STATION_MODES
1626 /* HostScan request works with and without host_roaming mode. In addition, it
1627 * does not break current association. However, it requires newer station
1628 * firmware version (>= 1.3.1) than scan request. */
1629 static int prism2_request_hostscan(struct net_device
*dev
,
1630 u8
*ssid
, u8 ssid_len
)
1632 struct hostap_interface
*iface
;
1633 local_info_t
*local
;
1634 struct hfa384x_hostscan_request scan_req
;
1636 iface
= netdev_priv(dev
);
1637 local
= iface
->local
;
1639 memset(&scan_req
, 0, sizeof(scan_req
));
1640 scan_req
.channel_list
= cpu_to_le16(local
->channel_mask
&
1641 local
->scan_channel_mask
);
1642 scan_req
.txrate
= cpu_to_le16(HFA384X_RATES_1MBPS
);
1646 scan_req
.target_ssid_len
= cpu_to_le16(ssid_len
);
1647 memcpy(scan_req
.target_ssid
, ssid
, ssid_len
);
1650 if (local
->func
->set_rid(dev
, HFA384X_RID_HOSTSCAN
, &scan_req
,
1651 sizeof(scan_req
))) {
1652 printk(KERN_DEBUG
"%s: HOSTSCAN failed\n", dev
->name
);
1659 static int prism2_request_scan(struct net_device
*dev
)
1661 struct hostap_interface
*iface
;
1662 local_info_t
*local
;
1663 struct hfa384x_scan_request scan_req
;
1666 iface
= netdev_priv(dev
);
1667 local
= iface
->local
;
1669 memset(&scan_req
, 0, sizeof(scan_req
));
1670 scan_req
.channel_list
= cpu_to_le16(local
->channel_mask
&
1671 local
->scan_channel_mask
);
1672 scan_req
.txrate
= cpu_to_le16(HFA384X_RATES_1MBPS
);
1675 * It seems to be enough to set roaming mode for a short moment to
1676 * host-based and then setup scanrequest data and return the mode to
1679 * Master mode would need to drop to Managed mode for a short while
1680 * to make scanning work.. Or sweep through the different channels and
1681 * use passive scan based on beacons. */
1683 if (!local
->host_roaming
)
1684 hostap_set_word(dev
, HFA384X_RID_CNFROAMINGMODE
,
1685 HFA384X_ROAMING_HOST
);
1687 if (local
->func
->set_rid(dev
, HFA384X_RID_SCANREQUEST
, &scan_req
,
1688 sizeof(scan_req
))) {
1689 printk(KERN_DEBUG
"SCANREQUEST failed\n");
1693 if (!local
->host_roaming
)
1694 hostap_set_word(dev
, HFA384X_RID_CNFROAMINGMODE
,
1695 HFA384X_ROAMING_FIRMWARE
);
1700 #else /* !PRISM2_NO_STATION_MODES */
1702 static inline int prism2_request_hostscan(struct net_device
*dev
,
1703 u8
*ssid
, u8 ssid_len
)
1709 static inline int prism2_request_scan(struct net_device
*dev
)
1714 #endif /* !PRISM2_NO_STATION_MODES */
1717 static int prism2_ioctl_siwscan(struct net_device
*dev
,
1718 struct iw_request_info
*info
,
1719 struct iw_point
*data
, char *extra
)
1721 struct hostap_interface
*iface
;
1722 local_info_t
*local
;
1724 u8
*ssid
= NULL
, ssid_len
= 0;
1725 struct iw_scan_req
*req
= (struct iw_scan_req
*) extra
;
1727 iface
= netdev_priv(dev
);
1728 local
= iface
->local
;
1730 if (data
->length
< sizeof(struct iw_scan_req
))
1733 if (local
->iw_mode
== IW_MODE_MASTER
) {
1734 /* In master mode, we just return the results of our local
1735 * tables, so we don't need to start anything...
1741 if (!local
->dev_enabled
)
1744 if (req
&& data
->flags
& IW_SCAN_THIS_ESSID
) {
1746 ssid_len
= req
->essid_len
;
1749 ((local
->iw_mode
!= IW_MODE_INFRA
&&
1750 local
->iw_mode
!= IW_MODE_ADHOC
) ||
1751 (local
->sta_fw_ver
< PRISM2_FW_VER(1,3,1))))
1755 if (local
->sta_fw_ver
>= PRISM2_FW_VER(1,3,1))
1756 ret
= prism2_request_hostscan(dev
, ssid
, ssid_len
);
1758 ret
= prism2_request_scan(dev
);
1761 local
->scan_timestamp
= jiffies
;
1763 /* Could inquire F101, F103 or wait for SIOCGIWSCAN and read RID */
1769 #ifndef PRISM2_NO_STATION_MODES
1770 static char * __prism2_translate_scan(local_info_t
*local
,
1771 struct iw_request_info
*info
,
1772 struct hfa384x_hostscan_result
*scan
,
1773 struct hostap_bss_info
*bss
,
1774 char *current_ev
, char *end_buf
)
1777 struct iw_event iwe
;
1787 ssid_len
= bss
->ssid_len
;
1791 ssid_len
= le16_to_cpu(scan
->ssid_len
);
1792 bssid
= scan
->bssid
;
1797 /* First entry *MUST* be the AP MAC address */
1798 memset(&iwe
, 0, sizeof(iwe
));
1799 iwe
.cmd
= SIOCGIWAP
;
1800 iwe
.u
.ap_addr
.sa_family
= ARPHRD_ETHER
;
1801 memcpy(iwe
.u
.ap_addr
.sa_data
, bssid
, ETH_ALEN
);
1802 current_ev
= iwe_stream_add_event(info
, current_ev
, end_buf
, &iwe
,
1805 /* Other entries will be displayed in the order we give them */
1807 memset(&iwe
, 0, sizeof(iwe
));
1808 iwe
.cmd
= SIOCGIWESSID
;
1809 iwe
.u
.data
.length
= ssid_len
;
1810 iwe
.u
.data
.flags
= 1;
1811 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1814 memset(&iwe
, 0, sizeof(iwe
));
1815 iwe
.cmd
= SIOCGIWMODE
;
1817 capabilities
= bss
->capab_info
;
1819 capabilities
= le16_to_cpu(scan
->capability
);
1821 if (capabilities
& (WLAN_CAPABILITY_ESS
|
1822 WLAN_CAPABILITY_IBSS
)) {
1823 if (capabilities
& WLAN_CAPABILITY_ESS
)
1824 iwe
.u
.mode
= IW_MODE_MASTER
;
1826 iwe
.u
.mode
= IW_MODE_ADHOC
;
1827 current_ev
= iwe_stream_add_event(info
, current_ev
, end_buf
,
1828 &iwe
, IW_EV_UINT_LEN
);
1831 memset(&iwe
, 0, sizeof(iwe
));
1832 iwe
.cmd
= SIOCGIWFREQ
;
1834 chan
= le16_to_cpu(scan
->chid
);
1842 iwe
.u
.freq
.m
= freq_list
[chan
- 1] * 100000;
1844 current_ev
= iwe_stream_add_event(info
, current_ev
, end_buf
,
1845 &iwe
, IW_EV_FREQ_LEN
);
1849 memset(&iwe
, 0, sizeof(iwe
));
1851 if (local
->last_scan_type
== PRISM2_HOSTSCAN
) {
1852 iwe
.u
.qual
.level
= le16_to_cpu(scan
->sl
);
1853 iwe
.u
.qual
.noise
= le16_to_cpu(scan
->anl
);
1856 HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan
->sl
));
1858 HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan
->anl
));
1860 iwe
.u
.qual
.updated
= IW_QUAL_LEVEL_UPDATED
1861 | IW_QUAL_NOISE_UPDATED
1862 | IW_QUAL_QUAL_INVALID
1864 current_ev
= iwe_stream_add_event(info
, current_ev
, end_buf
,
1865 &iwe
, IW_EV_QUAL_LEN
);
1868 memset(&iwe
, 0, sizeof(iwe
));
1869 iwe
.cmd
= SIOCGIWENCODE
;
1870 if (capabilities
& WLAN_CAPABILITY_PRIVACY
)
1871 iwe
.u
.data
.flags
= IW_ENCODE_ENABLED
| IW_ENCODE_NOKEY
;
1873 iwe
.u
.data
.flags
= IW_ENCODE_DISABLED
;
1874 iwe
.u
.data
.length
= 0;
1875 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
, &iwe
, "");
1877 /* TODO: add SuppRates into BSS table */
1879 memset(&iwe
, 0, sizeof(iwe
));
1880 iwe
.cmd
= SIOCGIWRATE
;
1881 current_val
= current_ev
+ iwe_stream_lcp_len(info
);
1882 pos
= scan
->sup_rates
;
1883 for (i
= 0; i
< sizeof(scan
->sup_rates
); i
++) {
1886 /* Bit rate given in 500 kb/s units (+ 0x80) */
1887 iwe
.u
.bitrate
.value
= ((pos
[i
] & 0x7f) * 500000);
1888 current_val
= iwe_stream_add_value(
1889 info
, current_ev
, current_val
, end_buf
, &iwe
,
1892 /* Check if we added any event */
1893 if ((current_val
- current_ev
) > iwe_stream_lcp_len(info
))
1894 current_ev
= current_val
;
1897 /* TODO: add BeaconInt,resp_rate,atim into BSS table */
1898 buf
= kmalloc(MAX_WPA_IE_LEN
* 2 + 30, GFP_ATOMIC
);
1900 memset(&iwe
, 0, sizeof(iwe
));
1901 iwe
.cmd
= IWEVCUSTOM
;
1902 sprintf(buf
, "bcn_int=%d", le16_to_cpu(scan
->beacon_interval
));
1903 iwe
.u
.data
.length
= strlen(buf
);
1904 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1907 memset(&iwe
, 0, sizeof(iwe
));
1908 iwe
.cmd
= IWEVCUSTOM
;
1909 sprintf(buf
, "resp_rate=%d", le16_to_cpu(scan
->rate
));
1910 iwe
.u
.data
.length
= strlen(buf
);
1911 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1914 if (local
->last_scan_type
== PRISM2_HOSTSCAN
&&
1915 (capabilities
& WLAN_CAPABILITY_IBSS
)) {
1916 memset(&iwe
, 0, sizeof(iwe
));
1917 iwe
.cmd
= IWEVCUSTOM
;
1918 sprintf(buf
, "atim=%d", le16_to_cpu(scan
->atim
));
1919 iwe
.u
.data
.length
= strlen(buf
);
1920 current_ev
= iwe_stream_add_point(info
, current_ev
,
1921 end_buf
, &iwe
, buf
);
1926 if (bss
&& bss
->wpa_ie_len
> 0 && bss
->wpa_ie_len
<= MAX_WPA_IE_LEN
) {
1927 memset(&iwe
, 0, sizeof(iwe
));
1928 iwe
.cmd
= IWEVGENIE
;
1929 iwe
.u
.data
.length
= bss
->wpa_ie_len
;
1930 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1934 if (bss
&& bss
->rsn_ie_len
> 0 && bss
->rsn_ie_len
<= MAX_WPA_IE_LEN
) {
1935 memset(&iwe
, 0, sizeof(iwe
));
1936 iwe
.cmd
= IWEVGENIE
;
1937 iwe
.u
.data
.length
= bss
->rsn_ie_len
;
1938 current_ev
= iwe_stream_add_point(info
, current_ev
, end_buf
,
1946 /* Translate scan data returned from the card to a card independent
1947 * format that the Wireless Tools will understand - Jean II */
1948 static inline int prism2_translate_scan(local_info_t
*local
,
1949 struct iw_request_info
*info
,
1950 char *buffer
, int buflen
)
1952 struct hfa384x_hostscan_result
*scan
;
1953 int entry
, hostscan
;
1954 char *current_ev
= buffer
;
1955 char *end_buf
= buffer
+ buflen
;
1956 struct list_head
*ptr
;
1958 spin_lock_bh(&local
->lock
);
1960 list_for_each(ptr
, &local
->bss_list
) {
1961 struct hostap_bss_info
*bss
;
1962 bss
= list_entry(ptr
, struct hostap_bss_info
, list
);
1966 hostscan
= local
->last_scan_type
== PRISM2_HOSTSCAN
;
1967 for (entry
= 0; entry
< local
->last_scan_results_count
; entry
++) {
1969 scan
= &local
->last_scan_results
[entry
];
1971 /* Report every SSID if the AP is using multiple SSIDs. If no
1972 * BSS record is found (e.g., when WPA mode is disabled),
1973 * report the AP once. */
1974 list_for_each(ptr
, &local
->bss_list
) {
1975 struct hostap_bss_info
*bss
;
1976 bss
= list_entry(ptr
, struct hostap_bss_info
, list
);
1977 if (memcmp(bss
->bssid
, scan
->bssid
, ETH_ALEN
) == 0) {
1979 current_ev
= __prism2_translate_scan(
1980 local
, info
, scan
, bss
, current_ev
,
1986 current_ev
= __prism2_translate_scan(
1987 local
, info
, scan
, NULL
, current_ev
, end_buf
);
1989 /* Check if there is space for one more entry */
1990 if ((end_buf
- current_ev
) <= IW_EV_ADDR_LEN
) {
1991 /* Ask user space to try again with a bigger buffer */
1992 spin_unlock_bh(&local
->lock
);
1997 /* Prism2 firmware has limits (32 at least in some versions) for number
1998 * of BSSes in scan results. Extend this limit by using local BSS list.
2000 list_for_each(ptr
, &local
->bss_list
) {
2001 struct hostap_bss_info
*bss
;
2002 bss
= list_entry(ptr
, struct hostap_bss_info
, list
);
2005 current_ev
= __prism2_translate_scan(local
, info
, NULL
, bss
,
2006 current_ev
, end_buf
);
2007 /* Check if there is space for one more entry */
2008 if ((end_buf
- current_ev
) <= IW_EV_ADDR_LEN
) {
2009 /* Ask user space to try again with a bigger buffer */
2010 spin_unlock_bh(&local
->lock
);
2015 spin_unlock_bh(&local
->lock
);
2017 return current_ev
- buffer
;
2019 #endif /* PRISM2_NO_STATION_MODES */
2022 static inline int prism2_ioctl_giwscan_sta(struct net_device
*dev
,
2023 struct iw_request_info
*info
,
2024 struct iw_point
*data
, char *extra
)
2026 #ifdef PRISM2_NO_STATION_MODES
2028 #else /* PRISM2_NO_STATION_MODES */
2029 struct hostap_interface
*iface
;
2030 local_info_t
*local
;
2033 iface
= netdev_priv(dev
);
2034 local
= iface
->local
;
2036 /* Wait until the scan is finished. We can probably do better
2037 * than that - Jean II */
2038 if (local
->scan_timestamp
&&
2039 time_before(jiffies
, local
->scan_timestamp
+ 3 * HZ
)) {
2040 /* Important note : we don't want to block the caller
2041 * until results are ready for various reasons.
2042 * First, managing wait queues is complex and racy
2043 * (there may be multiple simultaneous callers).
2044 * Second, we grab some rtnetlink lock before coming
2045 * here (in dev_ioctl()).
2046 * Third, the caller can wait on the Wireless Event
2050 local
->scan_timestamp
= 0;
2052 res
= prism2_translate_scan(local
, info
, extra
, data
->length
);
2061 #endif /* PRISM2_NO_STATION_MODES */
2065 static int prism2_ioctl_giwscan(struct net_device
*dev
,
2066 struct iw_request_info
*info
,
2067 struct iw_point
*data
, char *extra
)
2069 struct hostap_interface
*iface
;
2070 local_info_t
*local
;
2073 iface
= netdev_priv(dev
);
2074 local
= iface
->local
;
2076 if (local
->iw_mode
== IW_MODE_MASTER
) {
2077 /* In MASTER mode, it doesn't make sense to go around
2078 * scanning the frequencies and make the stations we serve
2079 * wait when what the user is really interested about is the
2080 * list of stations and access points we are talking to.
2081 * So, just extract results from our cache...
2084 /* Translate to WE format */
2085 res
= prism2_ap_translate_scan(dev
, info
, extra
);
2087 printk(KERN_DEBUG
"Scan result translation succeeded "
2088 "(length=%d)\n", res
);
2093 "Scan result translation failed (res=%d)\n",
2100 return prism2_ioctl_giwscan_sta(dev
, info
, data
, extra
);
2105 static const struct iw_priv_args prism2_priv
[] = {
2106 { PRISM2_IOCTL_MONITOR
,
2107 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "monitor" },
2108 { PRISM2_IOCTL_READMIF
,
2109 IW_PRIV_TYPE_BYTE
| IW_PRIV_SIZE_FIXED
| 1,
2110 IW_PRIV_TYPE_BYTE
| IW_PRIV_SIZE_FIXED
| 1, "readmif" },
2111 { PRISM2_IOCTL_WRITEMIF
,
2112 IW_PRIV_TYPE_BYTE
| IW_PRIV_SIZE_FIXED
| 2, 0, "writemif" },
2113 { PRISM2_IOCTL_RESET
,
2114 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "reset" },
2115 { PRISM2_IOCTL_INQUIRE
,
2116 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "inquire" },
2117 { PRISM2_IOCTL_SET_RID_WORD
,
2118 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 2, 0, "set_rid_word" },
2119 { PRISM2_IOCTL_MACCMD
,
2120 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "maccmd" },
2121 { PRISM2_IOCTL_WDS_ADD
,
2122 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "wds_add" },
2123 { PRISM2_IOCTL_WDS_DEL
,
2124 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "wds_del" },
2125 { PRISM2_IOCTL_ADDMAC
,
2126 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "addmac" },
2127 { PRISM2_IOCTL_DELMAC
,
2128 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "delmac" },
2129 { PRISM2_IOCTL_KICKMAC
,
2130 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, "kickmac" },
2131 /* --- raw access to sub-ioctls --- */
2132 { PRISM2_IOCTL_PRISM2_PARAM
,
2133 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 2, 0, "prism2_param" },
2134 { PRISM2_IOCTL_GET_PRISM2_PARAM
,
2135 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1,
2136 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getprism2_param" },
2137 /* --- sub-ioctls handlers --- */
2138 { PRISM2_IOCTL_PRISM2_PARAM
,
2139 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "" },
2140 { PRISM2_IOCTL_GET_PRISM2_PARAM
,
2141 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "" },
2142 /* --- sub-ioctls definitions --- */
2143 { PRISM2_PARAM_TXRATECTRL
,
2144 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "txratectrl" },
2145 { PRISM2_PARAM_TXRATECTRL
,
2146 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gettxratectrl" },
2147 { PRISM2_PARAM_BEACON_INT
,
2148 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "beacon_int" },
2149 { PRISM2_PARAM_BEACON_INT
,
2150 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getbeacon_int" },
2151 #ifndef PRISM2_NO_STATION_MODES
2152 { PRISM2_PARAM_PSEUDO_IBSS
,
2153 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "pseudo_ibss" },
2154 { PRISM2_PARAM_PSEUDO_IBSS
,
2155 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getpseudo_ibss" },
2156 #endif /* PRISM2_NO_STATION_MODES */
2158 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "alc" },
2160 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getalc" },
2161 { PRISM2_PARAM_DUMP
,
2162 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "dump" },
2163 { PRISM2_PARAM_DUMP
,
2164 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getdump" },
2165 { PRISM2_PARAM_OTHER_AP_POLICY
,
2166 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "other_ap_policy" },
2167 { PRISM2_PARAM_OTHER_AP_POLICY
,
2168 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getother_ap_pol" },
2169 { PRISM2_PARAM_AP_MAX_INACTIVITY
,
2170 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "max_inactivity" },
2171 { PRISM2_PARAM_AP_MAX_INACTIVITY
,
2172 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getmax_inactivi" },
2173 { PRISM2_PARAM_AP_BRIDGE_PACKETS
,
2174 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "bridge_packets" },
2175 { PRISM2_PARAM_AP_BRIDGE_PACKETS
,
2176 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getbridge_packe" },
2177 { PRISM2_PARAM_DTIM_PERIOD
,
2178 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "dtim_period" },
2179 { PRISM2_PARAM_DTIM_PERIOD
,
2180 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getdtim_period" },
2181 { PRISM2_PARAM_AP_NULLFUNC_ACK
,
2182 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "nullfunc_ack" },
2183 { PRISM2_PARAM_AP_NULLFUNC_ACK
,
2184 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getnullfunc_ack" },
2185 { PRISM2_PARAM_MAX_WDS
,
2186 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "max_wds" },
2187 { PRISM2_PARAM_MAX_WDS
,
2188 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getmax_wds" },
2189 { PRISM2_PARAM_AP_AUTOM_AP_WDS
,
2190 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "autom_ap_wds" },
2191 { PRISM2_PARAM_AP_AUTOM_AP_WDS
,
2192 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getautom_ap_wds" },
2193 { PRISM2_PARAM_AP_AUTH_ALGS
,
2194 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "ap_auth_algs" },
2195 { PRISM2_PARAM_AP_AUTH_ALGS
,
2196 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getap_auth_algs" },
2197 { PRISM2_PARAM_MONITOR_ALLOW_FCSERR
,
2198 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "allow_fcserr" },
2199 { PRISM2_PARAM_MONITOR_ALLOW_FCSERR
,
2200 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getallow_fcserr" },
2201 { PRISM2_PARAM_HOST_ENCRYPT
,
2202 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "host_encrypt" },
2203 { PRISM2_PARAM_HOST_ENCRYPT
,
2204 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethost_encrypt" },
2205 { PRISM2_PARAM_HOST_DECRYPT
,
2206 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "host_decrypt" },
2207 { PRISM2_PARAM_HOST_DECRYPT
,
2208 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethost_decrypt" },
2209 #ifndef PRISM2_NO_STATION_MODES
2210 { PRISM2_PARAM_HOST_ROAMING
,
2211 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "host_roaming" },
2212 { PRISM2_PARAM_HOST_ROAMING
,
2213 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethost_roaming" },
2214 #endif /* PRISM2_NO_STATION_MODES */
2215 { PRISM2_PARAM_BCRX_STA_KEY
,
2216 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "bcrx_sta_key" },
2217 { PRISM2_PARAM_BCRX_STA_KEY
,
2218 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getbcrx_sta_key" },
2219 { PRISM2_PARAM_IEEE_802_1X
,
2220 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "ieee_802_1x" },
2221 { PRISM2_PARAM_IEEE_802_1X
,
2222 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getieee_802_1x" },
2223 { PRISM2_PARAM_ANTSEL_TX
,
2224 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "antsel_tx" },
2225 { PRISM2_PARAM_ANTSEL_TX
,
2226 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getantsel_tx" },
2227 { PRISM2_PARAM_ANTSEL_RX
,
2228 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "antsel_rx" },
2229 { PRISM2_PARAM_ANTSEL_RX
,
2230 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getantsel_rx" },
2231 { PRISM2_PARAM_MONITOR_TYPE
,
2232 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "monitor_type" },
2233 { PRISM2_PARAM_MONITOR_TYPE
,
2234 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getmonitor_type" },
2235 { PRISM2_PARAM_WDS_TYPE
,
2236 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "wds_type" },
2237 { PRISM2_PARAM_WDS_TYPE
,
2238 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getwds_type" },
2239 { PRISM2_PARAM_HOSTSCAN
,
2240 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "hostscan" },
2241 { PRISM2_PARAM_HOSTSCAN
,
2242 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethostscan" },
2243 { PRISM2_PARAM_AP_SCAN
,
2244 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "ap_scan" },
2245 { PRISM2_PARAM_AP_SCAN
,
2246 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getap_scan" },
2247 { PRISM2_PARAM_ENH_SEC
,
2248 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "enh_sec" },
2249 { PRISM2_PARAM_ENH_SEC
,
2250 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getenh_sec" },
2251 #ifdef PRISM2_IO_DEBUG
2252 { PRISM2_PARAM_IO_DEBUG
,
2253 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "io_debug" },
2254 { PRISM2_PARAM_IO_DEBUG
,
2255 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getio_debug" },
2256 #endif /* PRISM2_IO_DEBUG */
2257 { PRISM2_PARAM_BASIC_RATES
,
2258 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "basic_rates" },
2259 { PRISM2_PARAM_BASIC_RATES
,
2260 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getbasic_rates" },
2261 { PRISM2_PARAM_OPER_RATES
,
2262 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "oper_rates" },
2263 { PRISM2_PARAM_OPER_RATES
,
2264 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getoper_rates" },
2265 { PRISM2_PARAM_HOSTAPD
,
2266 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "hostapd" },
2267 { PRISM2_PARAM_HOSTAPD
,
2268 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethostapd" },
2269 { PRISM2_PARAM_HOSTAPD_STA
,
2270 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "hostapd_sta" },
2271 { PRISM2_PARAM_HOSTAPD_STA
,
2272 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gethostapd_sta" },
2274 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "wpa" },
2276 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getwpa" },
2277 { PRISM2_PARAM_PRIVACY_INVOKED
,
2278 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "privacy_invoked" },
2279 { PRISM2_PARAM_PRIVACY_INVOKED
,
2280 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getprivacy_invo" },
2281 { PRISM2_PARAM_TKIP_COUNTERMEASURES
,
2282 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "tkip_countermea" },
2283 { PRISM2_PARAM_TKIP_COUNTERMEASURES
,
2284 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "gettkip_counter" },
2285 { PRISM2_PARAM_DROP_UNENCRYPTED
,
2286 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "drop_unencrypte" },
2287 { PRISM2_PARAM_DROP_UNENCRYPTED
,
2288 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getdrop_unencry" },
2289 { PRISM2_PARAM_SCAN_CHANNEL_MASK
,
2290 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, "scan_channels" },
2291 { PRISM2_PARAM_SCAN_CHANNEL_MASK
,
2292 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, "getscan_channel" },
2296 static int prism2_ioctl_priv_inquire(struct net_device
*dev
, int *i
)
2298 struct hostap_interface
*iface
;
2299 local_info_t
*local
;
2301 iface
= netdev_priv(dev
);
2302 local
= iface
->local
;
2304 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_INQUIRE
, *i
, NULL
, NULL
))
2311 static int prism2_ioctl_priv_prism2_param(struct net_device
*dev
,
2312 struct iw_request_info
*info
,
2313 void *wrqu
, char *extra
)
2315 struct hostap_interface
*iface
;
2316 local_info_t
*local
;
2317 int *i
= (int *) extra
;
2319 int value
= *(i
+ 1);
2323 iface
= netdev_priv(dev
);
2324 local
= iface
->local
;
2327 case PRISM2_PARAM_TXRATECTRL
:
2328 local
->fw_tx_rate_control
= value
;
2331 case PRISM2_PARAM_BEACON_INT
:
2332 if (hostap_set_word(dev
, HFA384X_RID_CNFBEACONINT
, value
) ||
2333 local
->func
->reset_port(dev
))
2336 local
->beacon_int
= value
;
2339 #ifndef PRISM2_NO_STATION_MODES
2340 case PRISM2_PARAM_PSEUDO_IBSS
:
2341 if (value
== local
->pseudo_adhoc
)
2344 if (value
!= 0 && value
!= 1) {
2349 printk(KERN_DEBUG
"prism2: %s: pseudo IBSS change %d -> %d\n",
2350 dev
->name
, local
->pseudo_adhoc
, value
);
2351 local
->pseudo_adhoc
= value
;
2352 if (local
->iw_mode
!= IW_MODE_ADHOC
)
2355 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
2356 hostap_get_porttype(local
))) {
2361 if (local
->func
->reset_port(dev
))
2364 #endif /* PRISM2_NO_STATION_MODES */
2366 case PRISM2_PARAM_ALC
:
2367 printk(KERN_DEBUG
"%s: %s ALC\n", dev
->name
,
2368 value
== 0 ? "Disabling" : "Enabling");
2369 val
= HFA384X_TEST_CFG_BIT_ALC
;
2370 local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
2371 (HFA384X_TEST_CFG_BITS
<< 8),
2372 value
== 0 ? 0 : 1, &val
, NULL
);
2375 case PRISM2_PARAM_DUMP
:
2376 local
->frame_dump
= value
;
2379 case PRISM2_PARAM_OTHER_AP_POLICY
:
2380 if (value
< 0 || value
> 3) {
2384 if (local
->ap
!= NULL
)
2385 local
->ap
->ap_policy
= value
;
2388 case PRISM2_PARAM_AP_MAX_INACTIVITY
:
2389 if (value
< 0 || value
> 7 * 24 * 60 * 60) {
2393 if (local
->ap
!= NULL
)
2394 local
->ap
->max_inactivity
= value
* HZ
;
2397 case PRISM2_PARAM_AP_BRIDGE_PACKETS
:
2398 if (local
->ap
!= NULL
)
2399 local
->ap
->bridge_packets
= value
;
2402 case PRISM2_PARAM_DTIM_PERIOD
:
2403 if (value
< 0 || value
> 65535) {
2407 if (hostap_set_word(dev
, HFA384X_RID_CNFOWNDTIMPERIOD
, value
)
2408 || local
->func
->reset_port(dev
))
2411 local
->dtim_period
= value
;
2414 case PRISM2_PARAM_AP_NULLFUNC_ACK
:
2415 if (local
->ap
!= NULL
)
2416 local
->ap
->nullfunc_ack
= value
;
2419 case PRISM2_PARAM_MAX_WDS
:
2420 local
->wds_max_connections
= value
;
2423 case PRISM2_PARAM_AP_AUTOM_AP_WDS
:
2424 if (local
->ap
!= NULL
) {
2425 if (!local
->ap
->autom_ap_wds
&& value
) {
2426 /* add WDS link to all APs in STA table */
2427 hostap_add_wds_links(local
);
2429 local
->ap
->autom_ap_wds
= value
;
2433 case PRISM2_PARAM_AP_AUTH_ALGS
:
2434 local
->auth_algs
= value
;
2435 if (hostap_set_auth_algs(local
))
2439 case PRISM2_PARAM_MONITOR_ALLOW_FCSERR
:
2440 local
->monitor_allow_fcserr
= value
;
2443 case PRISM2_PARAM_HOST_ENCRYPT
:
2444 local
->host_encrypt
= value
;
2445 if (hostap_set_encryption(local
) ||
2446 local
->func
->reset_port(dev
))
2450 case PRISM2_PARAM_HOST_DECRYPT
:
2451 local
->host_decrypt
= value
;
2452 if (hostap_set_encryption(local
) ||
2453 local
->func
->reset_port(dev
))
2457 #ifndef PRISM2_NO_STATION_MODES
2458 case PRISM2_PARAM_HOST_ROAMING
:
2459 if (value
< 0 || value
> 2) {
2463 local
->host_roaming
= value
;
2464 if (hostap_set_roaming(local
) || local
->func
->reset_port(dev
))
2467 #endif /* PRISM2_NO_STATION_MODES */
2469 case PRISM2_PARAM_BCRX_STA_KEY
:
2470 local
->bcrx_sta_key
= value
;
2473 case PRISM2_PARAM_IEEE_802_1X
:
2474 local
->ieee_802_1x
= value
;
2477 case PRISM2_PARAM_ANTSEL_TX
:
2478 if (value
< 0 || value
> HOSTAP_ANTSEL_HIGH
) {
2482 local
->antsel_tx
= value
;
2483 hostap_set_antsel(local
);
2486 case PRISM2_PARAM_ANTSEL_RX
:
2487 if (value
< 0 || value
> HOSTAP_ANTSEL_HIGH
) {
2491 local
->antsel_rx
= value
;
2492 hostap_set_antsel(local
);
2495 case PRISM2_PARAM_MONITOR_TYPE
:
2496 if (value
!= PRISM2_MONITOR_80211
&&
2497 value
!= PRISM2_MONITOR_CAPHDR
&&
2498 value
!= PRISM2_MONITOR_PRISM
&&
2499 value
!= PRISM2_MONITOR_RADIOTAP
) {
2503 local
->monitor_type
= value
;
2504 if (local
->iw_mode
== IW_MODE_MONITOR
)
2505 hostap_monitor_set_type(local
);
2508 case PRISM2_PARAM_WDS_TYPE
:
2509 local
->wds_type
= value
;
2512 case PRISM2_PARAM_HOSTSCAN
:
2514 struct hfa384x_hostscan_request scan_req
;
2517 memset(&scan_req
, 0, sizeof(scan_req
));
2518 scan_req
.channel_list
= cpu_to_le16(0x3fff);
2520 case 1: rate
= HFA384X_RATES_1MBPS
; break;
2521 case 2: rate
= HFA384X_RATES_2MBPS
; break;
2522 case 3: rate
= HFA384X_RATES_5MBPS
; break;
2523 case 4: rate
= HFA384X_RATES_11MBPS
; break;
2524 default: rate
= HFA384X_RATES_1MBPS
; break;
2526 scan_req
.txrate
= cpu_to_le16(rate
);
2527 /* leave SSID empty to accept all SSIDs */
2529 if (local
->iw_mode
== IW_MODE_MASTER
) {
2530 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
2531 HFA384X_PORTTYPE_BSS
) ||
2532 local
->func
->reset_port(dev
))
2533 printk(KERN_DEBUG
"Leaving Host AP mode "
2534 "for HostScan failed\n");
2537 if (local
->func
->set_rid(dev
, HFA384X_RID_HOSTSCAN
, &scan_req
,
2538 sizeof(scan_req
))) {
2539 printk(KERN_DEBUG
"HOSTSCAN failed\n");
2542 if (local
->iw_mode
== IW_MODE_MASTER
) {
2543 wait_queue_t __wait
;
2544 init_waitqueue_entry(&__wait
, current
);
2545 add_wait_queue(&local
->hostscan_wq
, &__wait
);
2546 set_current_state(TASK_INTERRUPTIBLE
);
2547 schedule_timeout(HZ
);
2548 if (signal_pending(current
))
2550 set_current_state(TASK_RUNNING
);
2551 remove_wait_queue(&local
->hostscan_wq
, &__wait
);
2553 if (hostap_set_word(dev
, HFA384X_RID_CNFPORTTYPE
,
2554 HFA384X_PORTTYPE_HOSTAP
) ||
2555 local
->func
->reset_port(dev
))
2556 printk(KERN_DEBUG
"Returning to Host AP mode "
2557 "after HostScan failed\n");
2562 case PRISM2_PARAM_AP_SCAN
:
2563 local
->passive_scan_interval
= value
;
2564 if (timer_pending(&local
->passive_scan_timer
))
2565 del_timer(&local
->passive_scan_timer
);
2567 local
->passive_scan_timer
.expires
= jiffies
+
2568 local
->passive_scan_interval
* HZ
;
2569 add_timer(&local
->passive_scan_timer
);
2573 case PRISM2_PARAM_ENH_SEC
:
2574 if (value
< 0 || value
> 3) {
2578 local
->enh_sec
= value
;
2579 if (hostap_set_word(dev
, HFA384X_RID_CNFENHSECURITY
,
2581 local
->func
->reset_port(dev
)) {
2582 printk(KERN_INFO
"%s: cnfEnhSecurity requires STA f/w "
2583 "1.6.3 or newer\n", dev
->name
);
2588 #ifdef PRISM2_IO_DEBUG
2589 case PRISM2_PARAM_IO_DEBUG
:
2590 local
->io_debug_enabled
= value
;
2592 #endif /* PRISM2_IO_DEBUG */
2594 case PRISM2_PARAM_BASIC_RATES
:
2595 if ((value
& local
->tx_rate_control
) != value
|| value
== 0) {
2596 printk(KERN_INFO
"%s: invalid basic rate set - basic "
2597 "rates must be in supported rate set\n",
2602 local
->basic_rates
= value
;
2603 if (hostap_set_word(dev
, HFA384X_RID_CNFBASICRATES
,
2604 local
->basic_rates
) ||
2605 local
->func
->reset_port(dev
))
2609 case PRISM2_PARAM_OPER_RATES
:
2610 local
->tx_rate_control
= value
;
2611 if (hostap_set_rate(dev
))
2615 case PRISM2_PARAM_HOSTAPD
:
2616 ret
= hostap_set_hostapd(local
, value
, 1);
2619 case PRISM2_PARAM_HOSTAPD_STA
:
2620 ret
= hostap_set_hostapd_sta(local
, value
, 1);
2623 case PRISM2_PARAM_WPA
:
2625 if (local
->sta_fw_ver
< PRISM2_FW_VER(1,7,0))
2627 else if (hostap_set_word(dev
, HFA384X_RID_SSNHANDLINGMODE
,
2632 case PRISM2_PARAM_PRIVACY_INVOKED
:
2633 local
->privacy_invoked
= value
;
2634 if (hostap_set_encryption(local
) ||
2635 local
->func
->reset_port(dev
))
2639 case PRISM2_PARAM_TKIP_COUNTERMEASURES
:
2640 local
->tkip_countermeasures
= value
;
2643 case PRISM2_PARAM_DROP_UNENCRYPTED
:
2644 local
->drop_unencrypted
= value
;
2647 case PRISM2_PARAM_SCAN_CHANNEL_MASK
:
2648 local
->scan_channel_mask
= value
;
2652 printk(KERN_DEBUG
"%s: prism2_param: unknown param %d\n",
2662 static int prism2_ioctl_priv_get_prism2_param(struct net_device
*dev
,
2663 struct iw_request_info
*info
,
2664 void *wrqu
, char *extra
)
2666 struct hostap_interface
*iface
;
2667 local_info_t
*local
;
2668 int *param
= (int *) extra
;
2671 iface
= netdev_priv(dev
);
2672 local
= iface
->local
;
2675 case PRISM2_PARAM_TXRATECTRL
:
2676 *param
= local
->fw_tx_rate_control
;
2679 case PRISM2_PARAM_BEACON_INT
:
2680 *param
= local
->beacon_int
;
2683 case PRISM2_PARAM_PSEUDO_IBSS
:
2684 *param
= local
->pseudo_adhoc
;
2687 case PRISM2_PARAM_ALC
:
2688 ret
= -EOPNOTSUPP
; /* FIX */
2691 case PRISM2_PARAM_DUMP
:
2692 *param
= local
->frame_dump
;
2695 case PRISM2_PARAM_OTHER_AP_POLICY
:
2696 if (local
->ap
!= NULL
)
2697 *param
= local
->ap
->ap_policy
;
2702 case PRISM2_PARAM_AP_MAX_INACTIVITY
:
2703 if (local
->ap
!= NULL
)
2704 *param
= local
->ap
->max_inactivity
/ HZ
;
2709 case PRISM2_PARAM_AP_BRIDGE_PACKETS
:
2710 if (local
->ap
!= NULL
)
2711 *param
= local
->ap
->bridge_packets
;
2716 case PRISM2_PARAM_DTIM_PERIOD
:
2717 *param
= local
->dtim_period
;
2720 case PRISM2_PARAM_AP_NULLFUNC_ACK
:
2721 if (local
->ap
!= NULL
)
2722 *param
= local
->ap
->nullfunc_ack
;
2727 case PRISM2_PARAM_MAX_WDS
:
2728 *param
= local
->wds_max_connections
;
2731 case PRISM2_PARAM_AP_AUTOM_AP_WDS
:
2732 if (local
->ap
!= NULL
)
2733 *param
= local
->ap
->autom_ap_wds
;
2738 case PRISM2_PARAM_AP_AUTH_ALGS
:
2739 *param
= local
->auth_algs
;
2742 case PRISM2_PARAM_MONITOR_ALLOW_FCSERR
:
2743 *param
= local
->monitor_allow_fcserr
;
2746 case PRISM2_PARAM_HOST_ENCRYPT
:
2747 *param
= local
->host_encrypt
;
2750 case PRISM2_PARAM_HOST_DECRYPT
:
2751 *param
= local
->host_decrypt
;
2754 case PRISM2_PARAM_HOST_ROAMING
:
2755 *param
= local
->host_roaming
;
2758 case PRISM2_PARAM_BCRX_STA_KEY
:
2759 *param
= local
->bcrx_sta_key
;
2762 case PRISM2_PARAM_IEEE_802_1X
:
2763 *param
= local
->ieee_802_1x
;
2766 case PRISM2_PARAM_ANTSEL_TX
:
2767 *param
= local
->antsel_tx
;
2770 case PRISM2_PARAM_ANTSEL_RX
:
2771 *param
= local
->antsel_rx
;
2774 case PRISM2_PARAM_MONITOR_TYPE
:
2775 *param
= local
->monitor_type
;
2778 case PRISM2_PARAM_WDS_TYPE
:
2779 *param
= local
->wds_type
;
2782 case PRISM2_PARAM_HOSTSCAN
:
2786 case PRISM2_PARAM_AP_SCAN
:
2787 *param
= local
->passive_scan_interval
;
2790 case PRISM2_PARAM_ENH_SEC
:
2791 *param
= local
->enh_sec
;
2794 #ifdef PRISM2_IO_DEBUG
2795 case PRISM2_PARAM_IO_DEBUG
:
2796 *param
= local
->io_debug_enabled
;
2798 #endif /* PRISM2_IO_DEBUG */
2800 case PRISM2_PARAM_BASIC_RATES
:
2801 *param
= local
->basic_rates
;
2804 case PRISM2_PARAM_OPER_RATES
:
2805 *param
= local
->tx_rate_control
;
2808 case PRISM2_PARAM_HOSTAPD
:
2809 *param
= local
->hostapd
;
2812 case PRISM2_PARAM_HOSTAPD_STA
:
2813 *param
= local
->hostapd_sta
;
2816 case PRISM2_PARAM_WPA
:
2817 if (local
->sta_fw_ver
< PRISM2_FW_VER(1,7,0))
2819 *param
= local
->wpa
;
2822 case PRISM2_PARAM_PRIVACY_INVOKED
:
2823 *param
= local
->privacy_invoked
;
2826 case PRISM2_PARAM_TKIP_COUNTERMEASURES
:
2827 *param
= local
->tkip_countermeasures
;
2830 case PRISM2_PARAM_DROP_UNENCRYPTED
:
2831 *param
= local
->drop_unencrypted
;
2834 case PRISM2_PARAM_SCAN_CHANNEL_MASK
:
2835 *param
= local
->scan_channel_mask
;
2839 printk(KERN_DEBUG
"%s: get_prism2_param: unknown param %d\n",
2849 static int prism2_ioctl_priv_readmif(struct net_device
*dev
,
2850 struct iw_request_info
*info
,
2851 void *wrqu
, char *extra
)
2853 struct hostap_interface
*iface
;
2854 local_info_t
*local
;
2857 iface
= netdev_priv(dev
);
2858 local
= iface
->local
;
2860 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_READMIF
, *extra
, NULL
,
2870 static int prism2_ioctl_priv_writemif(struct net_device
*dev
,
2871 struct iw_request_info
*info
,
2872 void *wrqu
, char *extra
)
2874 struct hostap_interface
*iface
;
2875 local_info_t
*local
;
2878 iface
= netdev_priv(dev
);
2879 local
= iface
->local
;
2883 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_WRITEMIF
, cr
, &val
, NULL
))
2890 static int prism2_ioctl_priv_monitor(struct net_device
*dev
, int *i
)
2892 struct hostap_interface
*iface
;
2893 local_info_t
*local
;
2897 iface
= netdev_priv(dev
);
2898 local
= iface
->local
;
2900 printk(KERN_DEBUG
"%s: process %d (%s) used deprecated iwpriv monitor "
2901 "- update software to use iwconfig mode monitor\n",
2902 dev
->name
, task_pid_nr(current
), current
->comm
);
2904 /* Backward compatibility code - this can be removed at some point */
2907 /* Disable monitor mode - old mode was not saved, so go to
2909 mode
= IW_MODE_MASTER
;
2910 ret
= prism2_ioctl_siwmode(dev
, NULL
, &mode
, NULL
);
2911 } else if (*i
== 1) {
2912 /* netlink socket mode is not supported anymore since it did
2913 * not separate different devices from each other and was not
2914 * best method for delivering large amount of packets to
2917 } else if (*i
== 2 || *i
== 3) {
2920 local
->monitor_type
= PRISM2_MONITOR_80211
;
2923 local
->monitor_type
= PRISM2_MONITOR_PRISM
;
2926 mode
= IW_MODE_MONITOR
;
2927 ret
= prism2_ioctl_siwmode(dev
, NULL
, &mode
, NULL
);
2928 hostap_monitor_mode_enable(local
);
2936 static int prism2_ioctl_priv_reset(struct net_device
*dev
, int *i
)
2938 struct hostap_interface
*iface
;
2939 local_info_t
*local
;
2941 iface
= netdev_priv(dev
);
2942 local
= iface
->local
;
2944 printk(KERN_DEBUG
"%s: manual reset request(%d)\n", dev
->name
, *i
);
2947 /* Disable and enable card */
2948 local
->func
->hw_shutdown(dev
, 1);
2949 local
->func
->hw_config(dev
, 0);
2954 local
->func
->hw_reset(dev
);
2958 /* Disable and enable port 0 */
2959 local
->func
->reset_port(dev
);
2963 prism2_sta_deauth(local
, WLAN_REASON_DEAUTH_LEAVING
);
2964 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_DISABLE
, 0, NULL
,
2970 if (local
->func
->cmd(dev
, HFA384X_CMDCODE_ENABLE
, 0, NULL
,
2976 printk(KERN_DEBUG
"Unknown reset request %d\n", *i
);
2984 static int prism2_ioctl_priv_set_rid_word(struct net_device
*dev
, int *i
)
2987 int value
= *(i
+ 1);
2989 printk(KERN_DEBUG
"%s: Set RID[0x%X] = %d\n", dev
->name
, rid
, value
);
2991 if (hostap_set_word(dev
, rid
, value
))
2998 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
2999 static int ap_mac_cmd_ioctl(local_info_t
*local
, int *cmd
)
3004 case AP_MAC_CMD_POLICY_OPEN
:
3005 local
->ap
->mac_restrictions
.policy
= MAC_POLICY_OPEN
;
3007 case AP_MAC_CMD_POLICY_ALLOW
:
3008 local
->ap
->mac_restrictions
.policy
= MAC_POLICY_ALLOW
;
3010 case AP_MAC_CMD_POLICY_DENY
:
3011 local
->ap
->mac_restrictions
.policy
= MAC_POLICY_DENY
;
3013 case AP_MAC_CMD_FLUSH
:
3014 ap_control_flush_macs(&local
->ap
->mac_restrictions
);
3016 case AP_MAC_CMD_KICKALL
:
3017 ap_control_kickall(local
->ap
);
3018 hostap_deauth_all_stas(local
->dev
, local
->ap
, 0);
3027 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
3030 #ifdef PRISM2_DOWNLOAD_SUPPORT
3031 static int prism2_ioctl_priv_download(local_info_t
*local
, struct iw_point
*p
)
3033 struct prism2_download_param
*param
;
3036 if (p
->length
< sizeof(struct prism2_download_param
) ||
3037 p
->length
> 1024 || !p
->pointer
)
3040 param
= kmalloc(p
->length
, GFP_KERNEL
);
3044 if (copy_from_user(param
, p
->pointer
, p
->length
)) {
3049 if (p
->length
< sizeof(struct prism2_download_param
) +
3050 param
->num_areas
* sizeof(struct prism2_download_area
)) {
3055 ret
= local
->func
->download(local
, param
);
3061 #endif /* PRISM2_DOWNLOAD_SUPPORT */
3064 static int prism2_set_genericelement(struct net_device
*dev
, u8
*elem
,
3067 struct hostap_interface
*iface
= netdev_priv(dev
);
3068 local_info_t
*local
= iface
->local
;
3072 * Add 16-bit length in the beginning of the buffer because Prism2 RID
3075 buf
= kmalloc(len
+ 2, GFP_KERNEL
);
3079 *((__le16
*) buf
) = cpu_to_le16(len
);
3080 memcpy(buf
+ 2, elem
, len
);
3082 kfree(local
->generic_elem
);
3083 local
->generic_elem
= buf
;
3084 local
->generic_elem_len
= len
+ 2;
3086 return local
->func
->set_rid(local
->dev
, HFA384X_RID_GENERICELEMENT
,
3091 static int prism2_ioctl_siwauth(struct net_device
*dev
,
3092 struct iw_request_info
*info
,
3093 struct iw_param
*data
, char *extra
)
3095 struct hostap_interface
*iface
= netdev_priv(dev
);
3096 local_info_t
*local
= iface
->local
;
3098 switch (data
->flags
& IW_AUTH_INDEX
) {
3099 case IW_AUTH_WPA_VERSION
:
3100 case IW_AUTH_CIPHER_PAIRWISE
:
3101 case IW_AUTH_CIPHER_GROUP
:
3102 case IW_AUTH_KEY_MGMT
:
3104 * Host AP driver does not use these parameters and allows
3105 * wpa_supplicant to control them internally.
3108 case IW_AUTH_TKIP_COUNTERMEASURES
:
3109 local
->tkip_countermeasures
= data
->value
;
3111 case IW_AUTH_DROP_UNENCRYPTED
:
3112 local
->drop_unencrypted
= data
->value
;
3114 case IW_AUTH_80211_AUTH_ALG
:
3115 local
->auth_algs
= data
->value
;
3117 case IW_AUTH_WPA_ENABLED
:
3118 if (data
->value
== 0) {
3120 if (local
->sta_fw_ver
< PRISM2_FW_VER(1,7,0))
3122 prism2_set_genericelement(dev
, "", 0);
3123 local
->host_roaming
= 0;
3124 local
->privacy_invoked
= 0;
3125 if (hostap_set_word(dev
, HFA384X_RID_SSNHANDLINGMODE
,
3127 hostap_set_roaming(local
) ||
3128 hostap_set_encryption(local
) ||
3129 local
->func
->reset_port(dev
))
3133 if (local
->sta_fw_ver
< PRISM2_FW_VER(1,7,0))
3135 local
->host_roaming
= 2;
3136 local
->privacy_invoked
= 1;
3138 if (hostap_set_word(dev
, HFA384X_RID_SSNHANDLINGMODE
, 1) ||
3139 hostap_set_roaming(local
) ||
3140 hostap_set_encryption(local
) ||
3141 local
->func
->reset_port(dev
))
3144 case IW_AUTH_RX_UNENCRYPTED_EAPOL
:
3145 local
->ieee_802_1x
= data
->value
;
3147 case IW_AUTH_PRIVACY_INVOKED
:
3148 local
->privacy_invoked
= data
->value
;
3157 static int prism2_ioctl_giwauth(struct net_device
*dev
,
3158 struct iw_request_info
*info
,
3159 struct iw_param
*data
, char *extra
)
3161 struct hostap_interface
*iface
= netdev_priv(dev
);
3162 local_info_t
*local
= iface
->local
;
3164 switch (data
->flags
& IW_AUTH_INDEX
) {
3165 case IW_AUTH_WPA_VERSION
:
3166 case IW_AUTH_CIPHER_PAIRWISE
:
3167 case IW_AUTH_CIPHER_GROUP
:
3168 case IW_AUTH_KEY_MGMT
:
3170 * Host AP driver does not use these parameters and allows
3171 * wpa_supplicant to control them internally.
3174 case IW_AUTH_TKIP_COUNTERMEASURES
:
3175 data
->value
= local
->tkip_countermeasures
;
3177 case IW_AUTH_DROP_UNENCRYPTED
:
3178 data
->value
= local
->drop_unencrypted
;
3180 case IW_AUTH_80211_AUTH_ALG
:
3181 data
->value
= local
->auth_algs
;
3183 case IW_AUTH_WPA_ENABLED
:
3184 data
->value
= local
->wpa
;
3186 case IW_AUTH_RX_UNENCRYPTED_EAPOL
:
3187 data
->value
= local
->ieee_802_1x
;
3196 static int prism2_ioctl_siwencodeext(struct net_device
*dev
,
3197 struct iw_request_info
*info
,
3198 struct iw_point
*erq
, char *extra
)
3200 struct hostap_interface
*iface
= netdev_priv(dev
);
3201 local_info_t
*local
= iface
->local
;
3202 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*) extra
;
3204 struct lib80211_crypto_ops
*ops
;
3205 struct lib80211_crypt_data
**crypt
;
3208 const char *alg
, *module
;
3210 i
= erq
->flags
& IW_ENCODE_INDEX
;
3213 if (i
< 1 || i
> WEP_KEYS
)
3214 i
= local
->crypt_info
.tx_keyidx
;
3217 if (i
< 0 || i
>= WEP_KEYS
)
3220 addr
= ext
->addr
.sa_data
;
3221 if (addr
[0] == 0xff && addr
[1] == 0xff && addr
[2] == 0xff &&
3222 addr
[3] == 0xff && addr
[4] == 0xff && addr
[5] == 0xff) {
3224 crypt
= &local
->crypt_info
.crypt
[i
];
3228 sta_ptr
= ap_crypt_get_ptrs(local
->ap
, addr
, 0, &crypt
);
3229 if (sta_ptr
== NULL
) {
3230 if (local
->iw_mode
== IW_MODE_INFRA
) {
3232 * TODO: add STA entry for the current AP so
3233 * that unicast key can be used. For now, this
3234 * is emulated by using default key idx 0.
3237 crypt
= &local
->crypt_info
.crypt
[i
];
3243 if ((erq
->flags
& IW_ENCODE_DISABLED
) ||
3244 ext
->alg
== IW_ENCODE_ALG_NONE
) {
3246 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
3251 case IW_ENCODE_ALG_WEP
:
3253 module
= "lib80211_crypt_wep";
3255 case IW_ENCODE_ALG_TKIP
:
3257 module
= "lib80211_crypt_tkip";
3259 case IW_ENCODE_ALG_CCMP
:
3261 module
= "lib80211_crypt_ccmp";
3264 printk(KERN_DEBUG
"%s: unsupported algorithm %d\n",
3265 local
->dev
->name
, ext
->alg
);
3270 ops
= lib80211_get_crypto_ops(alg
);
3272 request_module(module
);
3273 ops
= lib80211_get_crypto_ops(alg
);
3276 printk(KERN_DEBUG
"%s: unknown crypto alg '%s'\n",
3277 local
->dev
->name
, alg
);
3282 if (sta_ptr
|| ext
->alg
!= IW_ENCODE_ALG_WEP
) {
3284 * Per station encryption and other than WEP algorithms
3285 * require host-based encryption, so force them on
3288 local
->host_decrypt
= local
->host_encrypt
= 1;
3291 if (*crypt
== NULL
|| (*crypt
)->ops
!= ops
) {
3292 struct lib80211_crypt_data
*new_crypt
;
3294 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
3296 new_crypt
= kzalloc(sizeof(struct lib80211_crypt_data
),
3298 if (new_crypt
== NULL
) {
3302 new_crypt
->ops
= ops
;
3303 if (new_crypt
->ops
&& try_module_get(new_crypt
->ops
->owner
))
3304 new_crypt
->priv
= new_crypt
->ops
->init(i
);
3305 if (new_crypt
->priv
== NULL
) {
3315 * TODO: if ext_flags does not have IW_ENCODE_EXT_RX_SEQ_VALID, the
3316 * existing seq# should not be changed.
3317 * TODO: if ext_flags has IW_ENCODE_EXT_TX_SEQ_VALID, next TX seq#
3318 * should be changed to something else than zero.
3320 if ((!(ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
) || ext
->key_len
> 0)
3321 && (*crypt
)->ops
->set_key
&&
3322 (*crypt
)->ops
->set_key(ext
->key
, ext
->key_len
, ext
->rx_seq
,
3323 (*crypt
)->priv
) < 0) {
3324 printk(KERN_DEBUG
"%s: key setting failed\n",
3330 if (ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
) {
3332 local
->crypt_info
.tx_keyidx
= i
;
3336 if (sta_ptr
== NULL
&& ext
->key_len
> 0) {
3338 for (j
= 0; j
< WEP_KEYS
; j
++) {
3339 if (j
!= i
&& local
->crypt_info
.crypt
[j
]) {
3345 local
->crypt_info
.tx_keyidx
= i
;
3350 hostap_handle_sta_release(sta_ptr
);
3352 local
->open_wep
= erq
->flags
& IW_ENCODE_OPEN
;
3355 * Do not reset port0 if card is in Managed mode since resetting will
3356 * generate new IEEE 802.11 authentication which may end up in looping
3357 * with IEEE 802.1X. Prism2 documentation seem to require port reset
3358 * after WEP configuration. However, keys are apparently changed at
3359 * least in Managed mode.
3362 (hostap_set_encryption(local
) ||
3363 (local
->iw_mode
!= IW_MODE_INFRA
&&
3364 local
->func
->reset_port(local
->dev
))))
3371 static int prism2_ioctl_giwencodeext(struct net_device
*dev
,
3372 struct iw_request_info
*info
,
3373 struct iw_point
*erq
, char *extra
)
3375 struct hostap_interface
*iface
= netdev_priv(dev
);
3376 local_info_t
*local
= iface
->local
;
3377 struct lib80211_crypt_data
**crypt
;
3380 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*) extra
;
3383 max_key_len
= erq
->length
- sizeof(*ext
);
3384 if (max_key_len
< 0)
3387 i
= erq
->flags
& IW_ENCODE_INDEX
;
3388 if (i
< 1 || i
> WEP_KEYS
)
3389 i
= local
->crypt_info
.tx_keyidx
;
3393 addr
= ext
->addr
.sa_data
;
3394 if (addr
[0] == 0xff && addr
[1] == 0xff && addr
[2] == 0xff &&
3395 addr
[3] == 0xff && addr
[4] == 0xff && addr
[5] == 0xff) {
3397 crypt
= &local
->crypt_info
.crypt
[i
];
3400 sta_ptr
= ap_crypt_get_ptrs(local
->ap
, addr
, 0, &crypt
);
3401 if (sta_ptr
== NULL
)
3405 memset(ext
, 0, sizeof(*ext
));
3407 if (*crypt
== NULL
|| (*crypt
)->ops
== NULL
) {
3408 ext
->alg
= IW_ENCODE_ALG_NONE
;
3410 erq
->flags
|= IW_ENCODE_DISABLED
;
3412 if (strcmp((*crypt
)->ops
->name
, "WEP") == 0)
3413 ext
->alg
= IW_ENCODE_ALG_WEP
;
3414 else if (strcmp((*crypt
)->ops
->name
, "TKIP") == 0)
3415 ext
->alg
= IW_ENCODE_ALG_TKIP
;
3416 else if (strcmp((*crypt
)->ops
->name
, "CCMP") == 0)
3417 ext
->alg
= IW_ENCODE_ALG_CCMP
;
3421 if ((*crypt
)->ops
->get_key
) {
3423 (*crypt
)->ops
->get_key(ext
->key
,
3428 (ext
->alg
== IW_ENCODE_ALG_TKIP
||
3429 ext
->alg
== IW_ENCODE_ALG_CCMP
))
3430 ext
->ext_flags
|= IW_ENCODE_EXT_TX_SEQ_VALID
;
3435 hostap_handle_sta_release(sta_ptr
);
3441 static int prism2_ioctl_set_encryption(local_info_t
*local
,
3442 struct prism2_hostapd_param
*param
,
3446 struct lib80211_crypto_ops
*ops
;
3447 struct lib80211_crypt_data
**crypt
;
3450 param
->u
.crypt
.err
= 0;
3451 param
->u
.crypt
.alg
[HOSTAP_CRYPT_ALG_NAME_LEN
- 1] = '\0';
3454 (int) ((char *) param
->u
.crypt
.key
- (char *) param
) +
3455 param
->u
.crypt
.key_len
)
3458 if (param
->sta_addr
[0] == 0xff && param
->sta_addr
[1] == 0xff &&
3459 param
->sta_addr
[2] == 0xff && param
->sta_addr
[3] == 0xff &&
3460 param
->sta_addr
[4] == 0xff && param
->sta_addr
[5] == 0xff) {
3461 if (param
->u
.crypt
.idx
>= WEP_KEYS
)
3464 crypt
= &local
->crypt_info
.crypt
[param
->u
.crypt
.idx
];
3466 if (param
->u
.crypt
.idx
)
3468 sta_ptr
= ap_crypt_get_ptrs(
3469 local
->ap
, param
->sta_addr
,
3470 (param
->u
.crypt
.flags
& HOSTAP_CRYPT_FLAG_PERMANENT
),
3473 if (sta_ptr
== NULL
) {
3474 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_UNKNOWN_ADDR
;
3479 if (strcmp(param
->u
.crypt
.alg
, "none") == 0) {
3481 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
3485 ops
= lib80211_get_crypto_ops(param
->u
.crypt
.alg
);
3486 if (ops
== NULL
&& strcmp(param
->u
.crypt
.alg
, "WEP") == 0) {
3487 request_module("lib80211_crypt_wep");
3488 ops
= lib80211_get_crypto_ops(param
->u
.crypt
.alg
);
3489 } else if (ops
== NULL
&& strcmp(param
->u
.crypt
.alg
, "TKIP") == 0) {
3490 request_module("lib80211_crypt_tkip");
3491 ops
= lib80211_get_crypto_ops(param
->u
.crypt
.alg
);
3492 } else if (ops
== NULL
&& strcmp(param
->u
.crypt
.alg
, "CCMP") == 0) {
3493 request_module("lib80211_crypt_ccmp");
3494 ops
= lib80211_get_crypto_ops(param
->u
.crypt
.alg
);
3497 printk(KERN_DEBUG
"%s: unknown crypto alg '%s'\n",
3498 local
->dev
->name
, param
->u
.crypt
.alg
);
3499 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_UNKNOWN_ALG
;
3504 /* station based encryption and other than WEP algorithms require
3505 * host-based encryption, so force them on automatically */
3506 local
->host_decrypt
= local
->host_encrypt
= 1;
3508 if (*crypt
== NULL
|| (*crypt
)->ops
!= ops
) {
3509 struct lib80211_crypt_data
*new_crypt
;
3511 lib80211_crypt_delayed_deinit(&local
->crypt_info
, crypt
);
3513 new_crypt
= kzalloc(sizeof(struct lib80211_crypt_data
),
3515 if (new_crypt
== NULL
) {
3519 new_crypt
->ops
= ops
;
3520 new_crypt
->priv
= new_crypt
->ops
->init(param
->u
.crypt
.idx
);
3521 if (new_crypt
->priv
== NULL
) {
3523 param
->u
.crypt
.err
=
3524 HOSTAP_CRYPT_ERR_CRYPT_INIT_FAILED
;
3532 if ((!(param
->u
.crypt
.flags
& HOSTAP_CRYPT_FLAG_SET_TX_KEY
) ||
3533 param
->u
.crypt
.key_len
> 0) && (*crypt
)->ops
->set_key
&&
3534 (*crypt
)->ops
->set_key(param
->u
.crypt
.key
,
3535 param
->u
.crypt
.key_len
, param
->u
.crypt
.seq
,
3536 (*crypt
)->priv
) < 0) {
3537 printk(KERN_DEBUG
"%s: key setting failed\n",
3539 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_KEY_SET_FAILED
;
3544 if (param
->u
.crypt
.flags
& HOSTAP_CRYPT_FLAG_SET_TX_KEY
) {
3546 local
->crypt_info
.tx_keyidx
= param
->u
.crypt
.idx
;
3547 else if (param
->u
.crypt
.idx
) {
3548 printk(KERN_DEBUG
"%s: TX key idx setting failed\n",
3550 param
->u
.crypt
.err
=
3551 HOSTAP_CRYPT_ERR_TX_KEY_SET_FAILED
;
3559 hostap_handle_sta_release(sta_ptr
);
3561 /* Do not reset port0 if card is in Managed mode since resetting will
3562 * generate new IEEE 802.11 authentication which may end up in looping
3563 * with IEEE 802.1X. Prism2 documentation seem to require port reset
3564 * after WEP configuration. However, keys are apparently changed at
3565 * least in Managed mode. */
3567 (hostap_set_encryption(local
) ||
3568 (local
->iw_mode
!= IW_MODE_INFRA
&&
3569 local
->func
->reset_port(local
->dev
)))) {
3570 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_CARD_CONF_FAILED
;
3578 static int prism2_ioctl_get_encryption(local_info_t
*local
,
3579 struct prism2_hostapd_param
*param
,
3582 struct lib80211_crypt_data
**crypt
;
3586 param
->u
.crypt
.err
= 0;
3588 max_key_len
= param_len
-
3589 (int) ((char *) param
->u
.crypt
.key
- (char *) param
);
3590 if (max_key_len
< 0)
3593 if (param
->sta_addr
[0] == 0xff && param
->sta_addr
[1] == 0xff &&
3594 param
->sta_addr
[2] == 0xff && param
->sta_addr
[3] == 0xff &&
3595 param
->sta_addr
[4] == 0xff && param
->sta_addr
[5] == 0xff) {
3597 if (param
->u
.crypt
.idx
>= WEP_KEYS
)
3598 param
->u
.crypt
.idx
= local
->crypt_info
.tx_keyidx
;
3599 crypt
= &local
->crypt_info
.crypt
[param
->u
.crypt
.idx
];
3601 param
->u
.crypt
.idx
= 0;
3602 sta_ptr
= ap_crypt_get_ptrs(local
->ap
, param
->sta_addr
, 0,
3605 if (sta_ptr
== NULL
) {
3606 param
->u
.crypt
.err
= HOSTAP_CRYPT_ERR_UNKNOWN_ADDR
;
3611 if (*crypt
== NULL
|| (*crypt
)->ops
== NULL
) {
3612 memcpy(param
->u
.crypt
.alg
, "none", 5);
3613 param
->u
.crypt
.key_len
= 0;
3614 param
->u
.crypt
.idx
= 0xff;
3616 strncpy(param
->u
.crypt
.alg
, (*crypt
)->ops
->name
,
3617 HOSTAP_CRYPT_ALG_NAME_LEN
);
3618 param
->u
.crypt
.key_len
= 0;
3620 memset(param
->u
.crypt
.seq
, 0, 8);
3621 if ((*crypt
)->ops
->get_key
) {
3622 param
->u
.crypt
.key_len
=
3623 (*crypt
)->ops
->get_key(param
->u
.crypt
.key
,
3631 hostap_handle_sta_release(sta_ptr
);
3637 static int prism2_ioctl_get_rid(local_info_t
*local
,
3638 struct prism2_hostapd_param
*param
,
3643 max_len
= param_len
- PRISM2_HOSTAPD_RID_HDR_LEN
;
3647 res
= local
->func
->get_rid(local
->dev
, param
->u
.rid
.rid
,
3648 param
->u
.rid
.data
, param
->u
.rid
.len
, 0);
3650 param
->u
.rid
.len
= res
;
3658 static int prism2_ioctl_set_rid(local_info_t
*local
,
3659 struct prism2_hostapd_param
*param
,
3664 max_len
= param_len
- PRISM2_HOSTAPD_RID_HDR_LEN
;
3665 if (max_len
< 0 || max_len
< param
->u
.rid
.len
)
3668 return local
->func
->set_rid(local
->dev
, param
->u
.rid
.rid
,
3669 param
->u
.rid
.data
, param
->u
.rid
.len
);
3673 static int prism2_ioctl_set_assoc_ap_addr(local_info_t
*local
,
3674 struct prism2_hostapd_param
*param
,
3677 printk(KERN_DEBUG
"%ssta: associated as client with AP %pM\n",
3678 local
->dev
->name
, param
->sta_addr
);
3679 memcpy(local
->assoc_ap_addr
, param
->sta_addr
, ETH_ALEN
);
3684 static int prism2_ioctl_siwgenie(struct net_device
*dev
,
3685 struct iw_request_info
*info
,
3686 struct iw_point
*data
, char *extra
)
3688 return prism2_set_genericelement(dev
, extra
, data
->length
);
3692 static int prism2_ioctl_giwgenie(struct net_device
*dev
,
3693 struct iw_request_info
*info
,
3694 struct iw_point
*data
, char *extra
)
3696 struct hostap_interface
*iface
= netdev_priv(dev
);
3697 local_info_t
*local
= iface
->local
;
3698 int len
= local
->generic_elem_len
- 2;
3700 if (len
<= 0 || local
->generic_elem
== NULL
) {
3705 if (data
->length
< len
)
3709 memcpy(extra
, local
->generic_elem
+ 2, len
);
3715 static int prism2_ioctl_set_generic_element(local_info_t
*local
,
3716 struct prism2_hostapd_param
*param
,
3721 len
= param
->u
.generic_elem
.len
;
3722 max_len
= param_len
- PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN
;
3723 if (max_len
< 0 || max_len
< len
)
3726 return prism2_set_genericelement(local
->dev
,
3727 param
->u
.generic_elem
.data
, len
);
3731 static int prism2_ioctl_siwmlme(struct net_device
*dev
,
3732 struct iw_request_info
*info
,
3733 struct iw_point
*data
, char *extra
)
3735 struct hostap_interface
*iface
= netdev_priv(dev
);
3736 local_info_t
*local
= iface
->local
;
3737 struct iw_mlme
*mlme
= (struct iw_mlme
*) extra
;
3740 reason
= cpu_to_le16(mlme
->reason_code
);
3742 switch (mlme
->cmd
) {
3743 case IW_MLME_DEAUTH
:
3744 return prism2_sta_send_mgmt(local
, mlme
->addr
.sa_data
,
3745 IEEE80211_STYPE_DEAUTH
,
3747 case IW_MLME_DISASSOC
:
3748 return prism2_sta_send_mgmt(local
, mlme
->addr
.sa_data
,
3749 IEEE80211_STYPE_DISASSOC
,
3757 static int prism2_ioctl_mlme(local_info_t
*local
,
3758 struct prism2_hostapd_param
*param
)
3762 reason
= cpu_to_le16(param
->u
.mlme
.reason_code
);
3763 switch (param
->u
.mlme
.cmd
) {
3764 case MLME_STA_DEAUTH
:
3765 return prism2_sta_send_mgmt(local
, param
->sta_addr
,
3766 IEEE80211_STYPE_DEAUTH
,
3768 case MLME_STA_DISASSOC
:
3769 return prism2_sta_send_mgmt(local
, param
->sta_addr
,
3770 IEEE80211_STYPE_DISASSOC
,
3778 static int prism2_ioctl_scan_req(local_info_t
*local
,
3779 struct prism2_hostapd_param
*param
)
3781 #ifndef PRISM2_NO_STATION_MODES
3782 if ((local
->iw_mode
!= IW_MODE_INFRA
&&
3783 local
->iw_mode
!= IW_MODE_ADHOC
) ||
3784 (local
->sta_fw_ver
< PRISM2_FW_VER(1,3,1)))
3787 if (!local
->dev_enabled
)
3790 return prism2_request_hostscan(local
->dev
, param
->u
.scan_req
.ssid
,
3791 param
->u
.scan_req
.ssid_len
);
3792 #else /* PRISM2_NO_STATION_MODES */
3794 #endif /* PRISM2_NO_STATION_MODES */
3798 static int prism2_ioctl_priv_hostapd(local_info_t
*local
, struct iw_point
*p
)
3800 struct prism2_hostapd_param
*param
;
3804 if (p
->length
< sizeof(struct prism2_hostapd_param
) ||
3805 p
->length
> PRISM2_HOSTAPD_MAX_BUF_SIZE
|| !p
->pointer
)
3808 param
= kmalloc(p
->length
, GFP_KERNEL
);
3812 if (copy_from_user(param
, p
->pointer
, p
->length
)) {
3817 switch (param
->cmd
) {
3818 case PRISM2_SET_ENCRYPTION
:
3819 ret
= prism2_ioctl_set_encryption(local
, param
, p
->length
);
3821 case PRISM2_GET_ENCRYPTION
:
3822 ret
= prism2_ioctl_get_encryption(local
, param
, p
->length
);
3824 case PRISM2_HOSTAPD_GET_RID
:
3825 ret
= prism2_ioctl_get_rid(local
, param
, p
->length
);
3827 case PRISM2_HOSTAPD_SET_RID
:
3828 ret
= prism2_ioctl_set_rid(local
, param
, p
->length
);
3830 case PRISM2_HOSTAPD_SET_ASSOC_AP_ADDR
:
3831 ret
= prism2_ioctl_set_assoc_ap_addr(local
, param
, p
->length
);
3833 case PRISM2_HOSTAPD_SET_GENERIC_ELEMENT
:
3834 ret
= prism2_ioctl_set_generic_element(local
, param
,
3837 case PRISM2_HOSTAPD_MLME
:
3838 ret
= prism2_ioctl_mlme(local
, param
);
3840 case PRISM2_HOSTAPD_SCAN_REQ
:
3841 ret
= prism2_ioctl_scan_req(local
, param
);
3844 ret
= prism2_hostapd(local
->ap
, param
);
3849 if (ret
== 1 || !ap_ioctl
) {
3850 if (copy_to_user(p
->pointer
, param
, p
->length
)) {
3853 } else if (ap_ioctl
)
3863 static void prism2_get_drvinfo(struct net_device
*dev
,
3864 struct ethtool_drvinfo
*info
)
3866 struct hostap_interface
*iface
;
3867 local_info_t
*local
;
3869 iface
= netdev_priv(dev
);
3870 local
= iface
->local
;
3872 strlcpy(info
->driver
, "hostap", sizeof(info
->driver
));
3873 snprintf(info
->fw_version
, sizeof(info
->fw_version
),
3874 "%d.%d.%d", (local
->sta_fw_ver
>> 16) & 0xff,
3875 (local
->sta_fw_ver
>> 8) & 0xff,
3876 local
->sta_fw_ver
& 0xff);
3879 const struct ethtool_ops prism2_ethtool_ops
= {
3880 .get_drvinfo
= prism2_get_drvinfo
3884 /* Structures to export the Wireless Handlers */
3886 static const iw_handler prism2_handler
[] =
3888 (iw_handler
) NULL
, /* SIOCSIWCOMMIT */
3889 (iw_handler
) prism2_get_name
, /* SIOCGIWNAME */
3890 (iw_handler
) NULL
, /* SIOCSIWNWID */
3891 (iw_handler
) NULL
, /* SIOCGIWNWID */
3892 (iw_handler
) prism2_ioctl_siwfreq
, /* SIOCSIWFREQ */
3893 (iw_handler
) prism2_ioctl_giwfreq
, /* SIOCGIWFREQ */
3894 (iw_handler
) prism2_ioctl_siwmode
, /* SIOCSIWMODE */
3895 (iw_handler
) prism2_ioctl_giwmode
, /* SIOCGIWMODE */
3896 (iw_handler
) prism2_ioctl_siwsens
, /* SIOCSIWSENS */
3897 (iw_handler
) prism2_ioctl_giwsens
, /* SIOCGIWSENS */
3898 (iw_handler
) NULL
/* not used */, /* SIOCSIWRANGE */
3899 (iw_handler
) prism2_ioctl_giwrange
, /* SIOCGIWRANGE */
3900 (iw_handler
) NULL
/* not used */, /* SIOCSIWPRIV */
3901 (iw_handler
) NULL
/* kernel code */, /* SIOCGIWPRIV */
3902 (iw_handler
) NULL
/* not used */, /* SIOCSIWSTATS */
3903 (iw_handler
) NULL
/* kernel code */, /* SIOCGIWSTATS */
3904 iw_handler_set_spy
, /* SIOCSIWSPY */
3905 iw_handler_get_spy
, /* SIOCGIWSPY */
3906 iw_handler_set_thrspy
, /* SIOCSIWTHRSPY */
3907 iw_handler_get_thrspy
, /* SIOCGIWTHRSPY */
3908 (iw_handler
) prism2_ioctl_siwap
, /* SIOCSIWAP */
3909 (iw_handler
) prism2_ioctl_giwap
, /* SIOCGIWAP */
3910 (iw_handler
) prism2_ioctl_siwmlme
, /* SIOCSIWMLME */
3911 (iw_handler
) prism2_ioctl_giwaplist
, /* SIOCGIWAPLIST */
3912 (iw_handler
) prism2_ioctl_siwscan
, /* SIOCSIWSCAN */
3913 (iw_handler
) prism2_ioctl_giwscan
, /* SIOCGIWSCAN */
3914 (iw_handler
) prism2_ioctl_siwessid
, /* SIOCSIWESSID */
3915 (iw_handler
) prism2_ioctl_giwessid
, /* SIOCGIWESSID */
3916 (iw_handler
) prism2_ioctl_siwnickn
, /* SIOCSIWNICKN */
3917 (iw_handler
) prism2_ioctl_giwnickn
, /* SIOCGIWNICKN */
3918 (iw_handler
) NULL
, /* -- hole -- */
3919 (iw_handler
) NULL
, /* -- hole -- */
3920 (iw_handler
) prism2_ioctl_siwrate
, /* SIOCSIWRATE */
3921 (iw_handler
) prism2_ioctl_giwrate
, /* SIOCGIWRATE */
3922 (iw_handler
) prism2_ioctl_siwrts
, /* SIOCSIWRTS */
3923 (iw_handler
) prism2_ioctl_giwrts
, /* SIOCGIWRTS */
3924 (iw_handler
) prism2_ioctl_siwfrag
, /* SIOCSIWFRAG */
3925 (iw_handler
) prism2_ioctl_giwfrag
, /* SIOCGIWFRAG */
3926 (iw_handler
) prism2_ioctl_siwtxpow
, /* SIOCSIWTXPOW */
3927 (iw_handler
) prism2_ioctl_giwtxpow
, /* SIOCGIWTXPOW */
3928 (iw_handler
) prism2_ioctl_siwretry
, /* SIOCSIWRETRY */
3929 (iw_handler
) prism2_ioctl_giwretry
, /* SIOCGIWRETRY */
3930 (iw_handler
) prism2_ioctl_siwencode
, /* SIOCSIWENCODE */
3931 (iw_handler
) prism2_ioctl_giwencode
, /* SIOCGIWENCODE */
3932 (iw_handler
) prism2_ioctl_siwpower
, /* SIOCSIWPOWER */
3933 (iw_handler
) prism2_ioctl_giwpower
, /* SIOCGIWPOWER */
3934 (iw_handler
) NULL
, /* -- hole -- */
3935 (iw_handler
) NULL
, /* -- hole -- */
3936 (iw_handler
) prism2_ioctl_siwgenie
, /* SIOCSIWGENIE */
3937 (iw_handler
) prism2_ioctl_giwgenie
, /* SIOCGIWGENIE */
3938 (iw_handler
) prism2_ioctl_siwauth
, /* SIOCSIWAUTH */
3939 (iw_handler
) prism2_ioctl_giwauth
, /* SIOCGIWAUTH */
3940 (iw_handler
) prism2_ioctl_siwencodeext
, /* SIOCSIWENCODEEXT */
3941 (iw_handler
) prism2_ioctl_giwencodeext
, /* SIOCGIWENCODEEXT */
3942 (iw_handler
) NULL
, /* SIOCSIWPMKSA */
3943 (iw_handler
) NULL
, /* -- hole -- */
3946 static const iw_handler prism2_private_handler
[] =
3947 { /* SIOCIWFIRSTPRIV + */
3948 (iw_handler
) prism2_ioctl_priv_prism2_param
, /* 0 */
3949 (iw_handler
) prism2_ioctl_priv_get_prism2_param
, /* 1 */
3950 (iw_handler
) prism2_ioctl_priv_writemif
, /* 2 */
3951 (iw_handler
) prism2_ioctl_priv_readmif
, /* 3 */
3954 const struct iw_handler_def hostap_iw_handler_def
=
3956 .num_standard
= ARRAY_SIZE(prism2_handler
),
3957 .num_private
= ARRAY_SIZE(prism2_private_handler
),
3958 .num_private_args
= ARRAY_SIZE(prism2_priv
),
3959 .standard
= (iw_handler
*) prism2_handler
,
3960 .private = (iw_handler
*) prism2_private_handler
,
3961 .private_args
= (struct iw_priv_args
*) prism2_priv
,
3962 .get_wireless_stats
= hostap_get_wireless_stats
,
3966 int hostap_ioctl(struct net_device
*dev
, struct ifreq
*ifr
, int cmd
)
3968 struct iwreq
*wrq
= (struct iwreq
*) ifr
;
3969 struct hostap_interface
*iface
;
3970 local_info_t
*local
;
3973 iface
= netdev_priv(dev
);
3974 local
= iface
->local
;
3977 /* Private ioctls (iwpriv) that have not yet been converted
3978 * into new wireless extensions API */
3980 case PRISM2_IOCTL_INQUIRE
:
3981 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
3982 else ret
= prism2_ioctl_priv_inquire(dev
, (int *) wrq
->u
.name
);
3985 case PRISM2_IOCTL_MONITOR
:
3986 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
3987 else ret
= prism2_ioctl_priv_monitor(dev
, (int *) wrq
->u
.name
);
3990 case PRISM2_IOCTL_RESET
:
3991 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
3992 else ret
= prism2_ioctl_priv_reset(dev
, (int *) wrq
->u
.name
);
3995 case PRISM2_IOCTL_WDS_ADD
:
3996 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
3997 else ret
= prism2_wds_add(local
, wrq
->u
.ap_addr
.sa_data
, 1);
4000 case PRISM2_IOCTL_WDS_DEL
:
4001 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4002 else ret
= prism2_wds_del(local
, wrq
->u
.ap_addr
.sa_data
, 1, 0);
4005 case PRISM2_IOCTL_SET_RID_WORD
:
4006 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4007 else ret
= prism2_ioctl_priv_set_rid_word(dev
,
4008 (int *) wrq
->u
.name
);
4011 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
4012 case PRISM2_IOCTL_MACCMD
:
4013 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4014 else ret
= ap_mac_cmd_ioctl(local
, (int *) wrq
->u
.name
);
4017 case PRISM2_IOCTL_ADDMAC
:
4018 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4019 else ret
= ap_control_add_mac(&local
->ap
->mac_restrictions
,
4020 wrq
->u
.ap_addr
.sa_data
);
4022 case PRISM2_IOCTL_DELMAC
:
4023 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4024 else ret
= ap_control_del_mac(&local
->ap
->mac_restrictions
,
4025 wrq
->u
.ap_addr
.sa_data
);
4027 case PRISM2_IOCTL_KICKMAC
:
4028 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4029 else ret
= ap_control_kick_mac(local
->ap
, local
->dev
,
4030 wrq
->u
.ap_addr
.sa_data
);
4032 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
4035 /* Private ioctls that are not used with iwpriv;
4036 * in SIOCDEVPRIVATE range */
4038 #ifdef PRISM2_DOWNLOAD_SUPPORT
4039 case PRISM2_IOCTL_DOWNLOAD
:
4040 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4041 else ret
= prism2_ioctl_priv_download(local
, &wrq
->u
.data
);
4043 #endif /* PRISM2_DOWNLOAD_SUPPORT */
4045 case PRISM2_IOCTL_HOSTAPD
:
4046 if (!capable(CAP_NET_ADMIN
)) ret
= -EPERM
;
4047 else ret
= prism2_ioctl_priv_hostapd(local
, &wrq
->u
.data
);
4058 /* BUG FIX: Restore power setting value when lost due to F/W bug */
4060 int hostap_restore_power(struct net_device
*dev
)
4062 struct hostap_interface
*iface
= netdev_priv(dev
);
4063 local_info_t
*local
= iface
->local
;
4068 if (local
->txpower_type
== PRISM2_TXPOWER_OFF
) {
4069 val
= 0xff; /* use all standby and sleep modes */
4070 ret
= local
->func
->cmd(dev
, HFA384X_CMDCODE_WRITEMIF
,
4071 HFA386X_CR_A_D_TEST_MODES2
,
4075 #ifdef RAW_TXPOWER_SETTING
4076 if (local
->txpower_type
== PRISM2_TXPOWER_FIXED
) {
4077 val
= HFA384X_TEST_CFG_BIT_ALC
;
4078 local
->func
->cmd(dev
, HFA384X_CMDCODE_TEST
|
4079 (HFA384X_TEST_CFG_BITS
<< 8), 0, &val
, NULL
);
4080 val
= prism2_txpower_dBm_to_hfa386x(local
->txpower
);
4081 ret
= (local
->func
->cmd(dev
, HFA384X_CMDCODE_WRITEMIF
,
4082 HFA386X_CR_MANUAL_TX_POWER
, &val
, NULL
));
4084 #endif /* RAW_TXPOWER_SETTING */
4085 return (ret
? -EOPNOTSUPP
: 0);
4088 EXPORT_SYMBOL(hostap_restore_power
);