1 /* Wireless extensions support.
3 * See copyright notice in main.c
5 #include <linux/slab.h>
6 #include <linux/kernel.h>
7 #include <linux/if_arp.h>
8 #include <linux/wireless.h>
9 #include <linux/ieee80211.h>
10 #include <net/iw_handler.h>
11 #include <net/cfg80211.h>
14 #include "hermes_rid.h"
24 #define MAX_RID_LEN 1024
26 /* Helper routine to record keys
27 * It is called under orinoco_lock so it may not sleep */
28 static int orinoco_set_key(struct orinoco_private
*priv
, int index
,
29 enum orinoco_alg alg
, const u8
*key
, int key_len
,
30 const u8
*seq
, int seq_len
)
32 kzfree(priv
->keys
[index
].key
);
33 kzfree(priv
->keys
[index
].seq
);
36 priv
->keys
[index
].key
= kzalloc(key_len
, GFP_ATOMIC
);
37 if (!priv
->keys
[index
].key
)
40 priv
->keys
[index
].key
= NULL
;
43 priv
->keys
[index
].seq
= kzalloc(seq_len
, GFP_ATOMIC
);
44 if (!priv
->keys
[index
].seq
)
47 priv
->keys
[index
].seq
= NULL
;
49 priv
->keys
[index
].key_len
= key_len
;
50 priv
->keys
[index
].seq_len
= seq_len
;
53 memcpy(priv
->keys
[index
].key
, key
, key_len
);
55 memcpy(priv
->keys
[index
].seq
, seq
, seq_len
);
58 case ORINOCO_ALG_TKIP
:
59 priv
->keys
[index
].cipher
= WLAN_CIPHER_SUITE_TKIP
;
63 priv
->keys
[index
].cipher
= (key_len
> SMALL_KEY_SIZE
) ?
64 WLAN_CIPHER_SUITE_WEP104
: WLAN_CIPHER_SUITE_WEP40
;
67 case ORINOCO_ALG_NONE
:
69 priv
->keys
[index
].cipher
= 0;
76 kfree(priv
->keys
[index
].key
);
77 priv
->keys
[index
].key
= NULL
;
80 priv
->keys
[index
].key_len
= 0;
81 priv
->keys
[index
].seq_len
= 0;
82 priv
->keys
[index
].cipher
= 0;
87 static struct iw_statistics
*orinoco_get_wireless_stats(struct net_device
*dev
)
89 struct orinoco_private
*priv
= ndev_priv(dev
);
90 hermes_t
*hw
= &priv
->hw
;
91 struct iw_statistics
*wstats
= &priv
->wstats
;
95 if (!netif_device_present(dev
)) {
96 printk(KERN_WARNING
"%s: get_wireless_stats() called while device not present\n",
101 /* If busy, return the old stats. Returning NULL may cause
102 * the interface to disappear from /proc/net/wireless */
103 if (orinoco_lock(priv
, &flags
) != 0)
106 /* We can't really wait for the tallies inquiry command to
107 * complete, so we just use the previous results and trigger
108 * a new tallies inquiry command for next time - Jean II */
109 hermes_inquire(hw
, HERMES_INQ_TALLIES
);
111 if (priv
->iw_mode
== NL80211_IFTYPE_ADHOC
) {
112 memset(&wstats
->qual
, 0, sizeof(wstats
->qual
));
113 /* If a spy address is defined, we report stats of the
114 * first spy address - Jean II */
115 if (SPY_NUMBER(priv
)) {
116 wstats
->qual
.qual
= priv
->spy_data
.spy_stat
[0].qual
;
117 wstats
->qual
.level
= priv
->spy_data
.spy_stat
[0].level
;
118 wstats
->qual
.noise
= priv
->spy_data
.spy_stat
[0].noise
;
119 wstats
->qual
.updated
=
120 priv
->spy_data
.spy_stat
[0].updated
;
124 __le16 qual
, signal
, noise
, unused
;
127 err
= HERMES_READ_RECORD(hw
, USER_BAP
,
128 HERMES_RID_COMMSQUALITY
, &cq
);
131 wstats
->qual
.qual
= (int)le16_to_cpu(cq
.qual
);
132 wstats
->qual
.level
= (int)le16_to_cpu(cq
.signal
) - 0x95;
133 wstats
->qual
.noise
= (int)le16_to_cpu(cq
.noise
) - 0x95;
134 wstats
->qual
.updated
=
135 IW_QUAL_ALL_UPDATED
| IW_QUAL_DBM
;
139 orinoco_unlock(priv
, &flags
);
143 /********************************************************************/
144 /* Wireless extensions */
145 /********************************************************************/
147 static int orinoco_ioctl_setwap(struct net_device
*dev
,
148 struct iw_request_info
*info
,
149 struct sockaddr
*ap_addr
,
152 struct orinoco_private
*priv
= ndev_priv(dev
);
153 int err
= -EINPROGRESS
; /* Call commit handler */
155 static const u8 off_addr
[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
156 static const u8 any_addr
[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
158 if (orinoco_lock(priv
, &flags
) != 0)
161 /* Enable automatic roaming - no sanity checks are needed */
162 if (memcmp(&ap_addr
->sa_data
, off_addr
, ETH_ALEN
) == 0 ||
163 memcmp(&ap_addr
->sa_data
, any_addr
, ETH_ALEN
) == 0) {
164 priv
->bssid_fixed
= 0;
165 memset(priv
->desired_bssid
, 0, ETH_ALEN
);
167 /* "off" means keep existing connection */
168 if (ap_addr
->sa_data
[0] == 0) {
169 __orinoco_hw_set_wap(priv
);
175 if (priv
->firmware_type
== FIRMWARE_TYPE_AGERE
) {
176 printk(KERN_WARNING
"%s: Lucent/Agere firmware doesn't "
177 "support manual roaming\n",
183 if (priv
->iw_mode
!= NL80211_IFTYPE_STATION
) {
184 printk(KERN_WARNING
"%s: Manual roaming supported only in "
185 "managed mode\n", dev
->name
);
190 /* Intersil firmware hangs without Desired ESSID */
191 if (priv
->firmware_type
== FIRMWARE_TYPE_INTERSIL
&&
192 strlen(priv
->desired_essid
) == 0) {
193 printk(KERN_WARNING
"%s: Desired ESSID must be set for "
194 "manual roaming\n", dev
->name
);
199 /* Finally, enable manual roaming */
200 priv
->bssid_fixed
= 1;
201 memcpy(priv
->desired_bssid
, &ap_addr
->sa_data
, ETH_ALEN
);
204 orinoco_unlock(priv
, &flags
);
208 static int orinoco_ioctl_getwap(struct net_device
*dev
,
209 struct iw_request_info
*info
,
210 struct sockaddr
*ap_addr
,
213 struct orinoco_private
*priv
= ndev_priv(dev
);
218 if (orinoco_lock(priv
, &flags
) != 0)
221 ap_addr
->sa_family
= ARPHRD_ETHER
;
222 err
= orinoco_hw_get_current_bssid(priv
, ap_addr
->sa_data
);
224 orinoco_unlock(priv
, &flags
);
229 static int orinoco_ioctl_setiwencode(struct net_device
*dev
,
230 struct iw_request_info
*info
,
231 struct iw_point
*erq
,
234 struct orinoco_private
*priv
= ndev_priv(dev
);
235 int index
= (erq
->flags
& IW_ENCODE_INDEX
) - 1;
236 int setindex
= priv
->tx_key
;
237 enum orinoco_alg encode_alg
= priv
->encode_alg
;
238 int restricted
= priv
->wep_restrict
;
239 int err
= -EINPROGRESS
; /* Call commit handler */
246 /* We actually have a key to set - check its length */
247 if (erq
->length
> LARGE_KEY_SIZE
)
250 if ((erq
->length
> SMALL_KEY_SIZE
) && !priv
->has_big_wep
)
254 if (orinoco_lock(priv
, &flags
) != 0)
257 /* Clear any TKIP key we have */
258 if ((priv
->has_wpa
) && (priv
->encode_alg
== ORINOCO_ALG_TKIP
))
259 (void) orinoco_clear_tkip_key(priv
, setindex
);
261 if (erq
->length
> 0) {
262 if ((index
< 0) || (index
>= ORINOCO_MAX_KEYS
))
263 index
= priv
->tx_key
;
265 /* Switch on WEP if off */
266 if (encode_alg
!= ORINOCO_ALG_WEP
) {
268 encode_alg
= ORINOCO_ALG_WEP
;
271 /* Important note : if the user do "iwconfig eth0 enc off",
272 * we will arrive there with an index of -1. This is valid
273 * but need to be taken care off... Jean II */
274 if ((index
< 0) || (index
>= ORINOCO_MAX_KEYS
)) {
275 if ((index
!= -1) || (erq
->flags
== 0)) {
280 /* Set the index : Check that the key is valid */
281 if (priv
->keys
[index
].key_len
== 0) {
289 if (erq
->flags
& IW_ENCODE_DISABLED
)
290 encode_alg
= ORINOCO_ALG_NONE
;
291 if (erq
->flags
& IW_ENCODE_OPEN
)
293 if (erq
->flags
& IW_ENCODE_RESTRICTED
)
296 if (erq
->pointer
&& erq
->length
> 0) {
297 err
= orinoco_set_key(priv
, index
, ORINOCO_ALG_WEP
, keybuf
,
298 erq
->length
, NULL
, 0);
300 priv
->tx_key
= setindex
;
302 /* Try fast key change if connected and only keys are changed */
303 if ((priv
->encode_alg
== encode_alg
) &&
304 (priv
->wep_restrict
== restricted
) &&
305 netif_carrier_ok(dev
)) {
306 err
= __orinoco_hw_setup_wepkeys(priv
);
307 /* No need to commit if successful */
311 priv
->encode_alg
= encode_alg
;
312 priv
->wep_restrict
= restricted
;
315 orinoco_unlock(priv
, &flags
);
320 static int orinoco_ioctl_getiwencode(struct net_device
*dev
,
321 struct iw_request_info
*info
,
322 struct iw_point
*erq
,
325 struct orinoco_private
*priv
= ndev_priv(dev
);
326 int index
= (erq
->flags
& IW_ENCODE_INDEX
) - 1;
332 if (orinoco_lock(priv
, &flags
) != 0)
335 if ((index
< 0) || (index
>= ORINOCO_MAX_KEYS
))
336 index
= priv
->tx_key
;
339 if (!priv
->encode_alg
)
340 erq
->flags
|= IW_ENCODE_DISABLED
;
341 erq
->flags
|= index
+ 1;
343 if (priv
->wep_restrict
)
344 erq
->flags
|= IW_ENCODE_RESTRICTED
;
346 erq
->flags
|= IW_ENCODE_OPEN
;
348 erq
->length
= priv
->keys
[index
].key_len
;
350 memcpy(keybuf
, priv
->keys
[index
].key
, erq
->length
);
352 orinoco_unlock(priv
, &flags
);
356 static int orinoco_ioctl_setessid(struct net_device
*dev
,
357 struct iw_request_info
*info
,
358 struct iw_point
*erq
,
361 struct orinoco_private
*priv
= ndev_priv(dev
);
364 /* Note : ESSID is ignored in Ad-Hoc demo mode, but we can set it
365 * anyway... - Jean II */
367 /* Hum... Should not use Wireless Extension constant (may change),
368 * should use our own... - Jean II */
369 if (erq
->length
> IW_ESSID_MAX_SIZE
)
372 if (orinoco_lock(priv
, &flags
) != 0)
375 /* NULL the string (for NULL termination & ESSID = ANY) - Jean II */
376 memset(priv
->desired_essid
, 0, sizeof(priv
->desired_essid
));
378 /* If not ANY, get the new ESSID */
380 memcpy(priv
->desired_essid
, essidbuf
, erq
->length
);
382 orinoco_unlock(priv
, &flags
);
384 return -EINPROGRESS
; /* Call commit handler */
387 static int orinoco_ioctl_getessid(struct net_device
*dev
,
388 struct iw_request_info
*info
,
389 struct iw_point
*erq
,
392 struct orinoco_private
*priv
= ndev_priv(dev
);
397 if (netif_running(dev
)) {
398 err
= orinoco_hw_get_essid(priv
, &active
, essidbuf
);
403 if (orinoco_lock(priv
, &flags
) != 0)
405 memcpy(essidbuf
, priv
->desired_essid
, IW_ESSID_MAX_SIZE
);
406 erq
->length
= strlen(priv
->desired_essid
);
407 orinoco_unlock(priv
, &flags
);
415 static int orinoco_ioctl_setfreq(struct net_device
*dev
,
416 struct iw_request_info
*info
,
420 struct orinoco_private
*priv
= ndev_priv(dev
);
423 int err
= -EINPROGRESS
; /* Call commit handler */
425 /* In infrastructure mode the AP sets the channel */
426 if (priv
->iw_mode
== NL80211_IFTYPE_STATION
)
429 if ((frq
->e
== 0) && (frq
->m
<= 1000)) {
430 /* Setting by channel number */
433 /* Setting by frequency */
437 /* Calculate denominator to rescale to MHz */
438 for (i
= 0; i
< (6 - frq
->e
); i
++)
441 chan
= ieee80211_freq_to_dsss_chan(frq
->m
/ denom
);
444 if ((chan
< 1) || (chan
> NUM_CHANNELS
) ||
445 !(priv
->channel_mask
& (1 << (chan
-1))))
448 if (orinoco_lock(priv
, &flags
) != 0)
451 priv
->channel
= chan
;
452 if (priv
->iw_mode
== NL80211_IFTYPE_MONITOR
) {
453 /* Fast channel change - no commit if successful */
454 hermes_t
*hw
= &priv
->hw
;
455 err
= hw
->ops
->cmd_wait(hw
, HERMES_CMD_TEST
|
456 HERMES_TEST_SET_CHANNEL
,
459 orinoco_unlock(priv
, &flags
);
464 static int orinoco_ioctl_getfreq(struct net_device
*dev
,
465 struct iw_request_info
*info
,
469 struct orinoco_private
*priv
= ndev_priv(dev
);
472 /* Locking done in there */
473 tmp
= orinoco_hw_get_freq(priv
);
477 frq
->m
= tmp
* 100000;
483 static int orinoco_ioctl_getsens(struct net_device
*dev
,
484 struct iw_request_info
*info
,
485 struct iw_param
*srq
,
488 struct orinoco_private
*priv
= ndev_priv(dev
);
489 hermes_t
*hw
= &priv
->hw
;
494 if (!priv
->has_sensitivity
)
497 if (orinoco_lock(priv
, &flags
) != 0)
499 err
= hermes_read_wordrec(hw
, USER_BAP
,
500 HERMES_RID_CNFSYSTEMSCALE
, &val
);
501 orinoco_unlock(priv
, &flags
);
507 srq
->fixed
= 0; /* auto */
512 static int orinoco_ioctl_setsens(struct net_device
*dev
,
513 struct iw_request_info
*info
,
514 struct iw_param
*srq
,
517 struct orinoco_private
*priv
= ndev_priv(dev
);
518 int val
= srq
->value
;
521 if (!priv
->has_sensitivity
)
524 if ((val
< 1) || (val
> 3))
527 if (orinoco_lock(priv
, &flags
) != 0)
529 priv
->ap_density
= val
;
530 orinoco_unlock(priv
, &flags
);
532 return -EINPROGRESS
; /* Call commit handler */
535 static int orinoco_ioctl_setrate(struct net_device
*dev
,
536 struct iw_request_info
*info
,
537 struct iw_param
*rrq
,
540 struct orinoco_private
*priv
= ndev_priv(dev
);
542 int bitrate
; /* 100s of kilobits */
545 /* As the user space doesn't know our highest rate, it uses -1
546 * to ask us to set the highest rate. Test it using "iwconfig
547 * ethX rate auto" - Jean II */
548 if (rrq
->value
== -1)
551 if (rrq
->value
% 100000)
553 bitrate
= rrq
->value
/ 100000;
556 ratemode
= orinoco_get_bitratemode(bitrate
, !rrq
->fixed
);
561 if (orinoco_lock(priv
, &flags
) != 0)
563 priv
->bitratemode
= ratemode
;
564 orinoco_unlock(priv
, &flags
);
569 static int orinoco_ioctl_getrate(struct net_device
*dev
,
570 struct iw_request_info
*info
,
571 struct iw_param
*rrq
,
574 struct orinoco_private
*priv
= ndev_priv(dev
);
576 int bitrate
, automatic
;
579 if (orinoco_lock(priv
, &flags
) != 0)
582 orinoco_get_ratemode_cfg(priv
->bitratemode
, &bitrate
, &automatic
);
584 /* If the interface is running we try to find more about the
586 if (netif_running(dev
))
587 err
= orinoco_hw_get_act_bitrate(priv
, &bitrate
);
589 orinoco_unlock(priv
, &flags
);
591 rrq
->value
= bitrate
;
592 rrq
->fixed
= !automatic
;
598 static int orinoco_ioctl_setpower(struct net_device
*dev
,
599 struct iw_request_info
*info
,
600 struct iw_param
*prq
,
603 struct orinoco_private
*priv
= ndev_priv(dev
);
604 int err
= -EINPROGRESS
; /* Call commit handler */
607 if (orinoco_lock(priv
, &flags
) != 0)
613 switch (prq
->flags
& IW_POWER_MODE
) {
614 case IW_POWER_UNICAST_R
:
623 /* No flags : but we may have a value - Jean II */
630 if (prq
->flags
& IW_POWER_TIMEOUT
) {
632 priv
->pm_timeout
= prq
->value
/ 1000;
634 if (prq
->flags
& IW_POWER_PERIOD
) {
636 priv
->pm_period
= prq
->value
/ 1000;
638 /* It's valid to not have a value if we are just toggling
639 * the flags... Jean II */
647 orinoco_unlock(priv
, &flags
);
652 static int orinoco_ioctl_getpower(struct net_device
*dev
,
653 struct iw_request_info
*info
,
654 struct iw_param
*prq
,
657 struct orinoco_private
*priv
= ndev_priv(dev
);
658 hermes_t
*hw
= &priv
->hw
;
660 u16 enable
, period
, timeout
, mcast
;
663 if (orinoco_lock(priv
, &flags
) != 0)
666 err
= hermes_read_wordrec(hw
, USER_BAP
,
667 HERMES_RID_CNFPMENABLED
, &enable
);
671 err
= hermes_read_wordrec(hw
, USER_BAP
,
672 HERMES_RID_CNFMAXSLEEPDURATION
, &period
);
676 err
= hermes_read_wordrec(hw
, USER_BAP
,
677 HERMES_RID_CNFPMHOLDOVERDURATION
, &timeout
);
681 err
= hermes_read_wordrec(hw
, USER_BAP
,
682 HERMES_RID_CNFMULTICASTRECEIVE
, &mcast
);
686 prq
->disabled
= !enable
;
687 /* Note : by default, display the period */
688 if ((prq
->flags
& IW_POWER_TYPE
) == IW_POWER_TIMEOUT
) {
689 prq
->flags
= IW_POWER_TIMEOUT
;
690 prq
->value
= timeout
* 1000;
692 prq
->flags
= IW_POWER_PERIOD
;
693 prq
->value
= period
* 1000;
696 prq
->flags
|= IW_POWER_ALL_R
;
698 prq
->flags
|= IW_POWER_UNICAST_R
;
701 orinoco_unlock(priv
, &flags
);
706 static int orinoco_ioctl_set_encodeext(struct net_device
*dev
,
707 struct iw_request_info
*info
,
708 union iwreq_data
*wrqu
,
711 struct orinoco_private
*priv
= ndev_priv(dev
);
712 struct iw_point
*encoding
= &wrqu
->encoding
;
713 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*)extra
;
714 int idx
, alg
= ext
->alg
, set_key
= 1;
718 if (orinoco_lock(priv
, &flags
) != 0)
721 /* Determine and validate the key index */
722 idx
= encoding
->flags
& IW_ENCODE_INDEX
;
724 if ((idx
< 1) || (idx
> 4))
730 if (encoding
->flags
& IW_ENCODE_DISABLED
)
731 alg
= IW_ENCODE_ALG_NONE
;
733 if (priv
->has_wpa
&& (alg
!= IW_ENCODE_ALG_TKIP
)) {
734 /* Clear any TKIP TX key we had */
735 (void) orinoco_clear_tkip_key(priv
, priv
->tx_key
);
738 if (ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
) {
740 set_key
= ((alg
== IW_ENCODE_ALG_TKIP
) ||
741 (ext
->key_len
> 0)) ? 1 : 0;
745 /* Set the requested key first */
747 case IW_ENCODE_ALG_NONE
:
748 priv
->encode_alg
= ORINOCO_ALG_NONE
;
749 err
= orinoco_set_key(priv
, idx
, ORINOCO_ALG_NONE
,
753 case IW_ENCODE_ALG_WEP
:
754 if (ext
->key_len
<= 0)
757 priv
->encode_alg
= ORINOCO_ALG_WEP
;
758 err
= orinoco_set_key(priv
, idx
, ORINOCO_ALG_WEP
,
759 ext
->key
, ext
->key_len
, NULL
, 0);
762 case IW_ENCODE_ALG_TKIP
:
766 if (!priv
->has_wpa
||
767 (ext
->key_len
> sizeof(struct orinoco_tkip_key
)))
770 priv
->encode_alg
= ORINOCO_ALG_TKIP
;
772 if (ext
->ext_flags
& IW_ENCODE_EXT_RX_SEQ_VALID
)
773 tkip_iv
= &ext
->rx_seq
[0];
775 err
= orinoco_set_key(priv
, idx
, ORINOCO_ALG_TKIP
,
776 ext
->key
, ext
->key_len
, tkip_iv
,
779 err
= __orinoco_hw_set_tkip_key(priv
, idx
,
780 ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
,
782 tkip_iv
, ORINOCO_SEQ_LEN
, NULL
, 0);
784 printk(KERN_ERR
"%s: Error %d setting TKIP key"
785 "\n", dev
->name
, err
);
795 orinoco_unlock(priv
, &flags
);
800 static int orinoco_ioctl_get_encodeext(struct net_device
*dev
,
801 struct iw_request_info
*info
,
802 union iwreq_data
*wrqu
,
805 struct orinoco_private
*priv
= ndev_priv(dev
);
806 struct iw_point
*encoding
= &wrqu
->encoding
;
807 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*)extra
;
808 int idx
, max_key_len
;
812 if (orinoco_lock(priv
, &flags
) != 0)
816 max_key_len
= encoding
->length
- sizeof(*ext
);
820 idx
= encoding
->flags
& IW_ENCODE_INDEX
;
822 if ((idx
< 1) || (idx
> 4))
828 encoding
->flags
= idx
+ 1;
829 memset(ext
, 0, sizeof(*ext
));
831 switch (priv
->encode_alg
) {
832 case ORINOCO_ALG_NONE
:
833 ext
->alg
= IW_ENCODE_ALG_NONE
;
835 encoding
->flags
|= IW_ENCODE_DISABLED
;
837 case ORINOCO_ALG_WEP
:
838 ext
->alg
= IW_ENCODE_ALG_WEP
;
839 ext
->key_len
= min(priv
->keys
[idx
].key_len
, max_key_len
);
840 memcpy(ext
->key
, priv
->keys
[idx
].key
, ext
->key_len
);
841 encoding
->flags
|= IW_ENCODE_ENABLED
;
843 case ORINOCO_ALG_TKIP
:
844 ext
->alg
= IW_ENCODE_ALG_TKIP
;
845 ext
->key_len
= min(priv
->keys
[idx
].key_len
, max_key_len
);
846 memcpy(ext
->key
, priv
->keys
[idx
].key
, ext
->key_len
);
847 encoding
->flags
|= IW_ENCODE_ENABLED
;
853 orinoco_unlock(priv
, &flags
);
858 static int orinoco_ioctl_set_auth(struct net_device
*dev
,
859 struct iw_request_info
*info
,
860 union iwreq_data
*wrqu
, char *extra
)
862 struct orinoco_private
*priv
= ndev_priv(dev
);
863 hermes_t
*hw
= &priv
->hw
;
864 struct iw_param
*param
= &wrqu
->param
;
866 int ret
= -EINPROGRESS
;
868 if (orinoco_lock(priv
, &flags
) != 0)
871 switch (param
->flags
& IW_AUTH_INDEX
) {
872 case IW_AUTH_WPA_VERSION
:
873 case IW_AUTH_CIPHER_PAIRWISE
:
874 case IW_AUTH_CIPHER_GROUP
:
875 case IW_AUTH_RX_UNENCRYPTED_EAPOL
:
876 case IW_AUTH_PRIVACY_INVOKED
:
877 case IW_AUTH_DROP_UNENCRYPTED
:
879 * orinoco does not use these parameters
883 case IW_AUTH_KEY_MGMT
:
884 /* wl_lkm implies value 2 == PSK for Hermes I
885 * which ties in with WEXT
886 * no other hints tho :(
888 priv
->key_mgmt
= param
->value
;
891 case IW_AUTH_TKIP_COUNTERMEASURES
:
892 /* When countermeasures are enabled, shut down the
893 * card; when disabled, re-enable the card. This must
894 * take effect immediately.
896 * TODO: Make sure that the EAPOL message is getting
897 * out before card disabled
900 priv
->tkip_cm_active
= 1;
901 ret
= hermes_disable_port(hw
, 0);
903 priv
->tkip_cm_active
= 0;
904 ret
= hermes_enable_port(hw
, 0);
908 case IW_AUTH_80211_AUTH_ALG
:
909 if (param
->value
& IW_AUTH_ALG_SHARED_KEY
)
910 priv
->wep_restrict
= 1;
911 else if (param
->value
& IW_AUTH_ALG_OPEN_SYSTEM
)
912 priv
->wep_restrict
= 0;
917 case IW_AUTH_WPA_ENABLED
:
919 priv
->wpa_enabled
= param
->value
? 1 : 0;
923 /* else silently accept disable of WPA */
924 priv
->wpa_enabled
= 0;
932 orinoco_unlock(priv
, &flags
);
936 static int orinoco_ioctl_get_auth(struct net_device
*dev
,
937 struct iw_request_info
*info
,
938 union iwreq_data
*wrqu
, char *extra
)
940 struct orinoco_private
*priv
= ndev_priv(dev
);
941 struct iw_param
*param
= &wrqu
->param
;
945 if (orinoco_lock(priv
, &flags
) != 0)
948 switch (param
->flags
& IW_AUTH_INDEX
) {
949 case IW_AUTH_KEY_MGMT
:
950 param
->value
= priv
->key_mgmt
;
953 case IW_AUTH_TKIP_COUNTERMEASURES
:
954 param
->value
= priv
->tkip_cm_active
;
957 case IW_AUTH_80211_AUTH_ALG
:
958 if (priv
->wep_restrict
)
959 param
->value
= IW_AUTH_ALG_SHARED_KEY
;
961 param
->value
= IW_AUTH_ALG_OPEN_SYSTEM
;
964 case IW_AUTH_WPA_ENABLED
:
965 param
->value
= priv
->wpa_enabled
;
972 orinoco_unlock(priv
, &flags
);
976 static int orinoco_ioctl_set_genie(struct net_device
*dev
,
977 struct iw_request_info
*info
,
978 union iwreq_data
*wrqu
, char *extra
)
980 struct orinoco_private
*priv
= ndev_priv(dev
);
984 /* cut off at IEEE80211_MAX_DATA_LEN */
985 if ((wrqu
->data
.length
> IEEE80211_MAX_DATA_LEN
) ||
986 (wrqu
->data
.length
&& (extra
== NULL
)))
989 if (wrqu
->data
.length
) {
990 buf
= kmemdup(extra
, wrqu
->data
.length
, GFP_KERNEL
);
996 if (orinoco_lock(priv
, &flags
) != 0) {
1001 kfree(priv
->wpa_ie
);
1003 priv
->wpa_ie_len
= wrqu
->data
.length
;
1006 /* Looks like wl_lkm wants to check the auth alg, and
1007 * somehow pass it to the firmware.
1008 * Instead it just calls the key mgmt rid
1009 * - we do this in set auth.
1013 orinoco_unlock(priv
, &flags
);
1017 static int orinoco_ioctl_get_genie(struct net_device
*dev
,
1018 struct iw_request_info
*info
,
1019 union iwreq_data
*wrqu
, char *extra
)
1021 struct orinoco_private
*priv
= ndev_priv(dev
);
1022 unsigned long flags
;
1025 if (orinoco_lock(priv
, &flags
) != 0)
1028 if ((priv
->wpa_ie_len
== 0) || (priv
->wpa_ie
== NULL
)) {
1029 wrqu
->data
.length
= 0;
1033 if (wrqu
->data
.length
< priv
->wpa_ie_len
) {
1038 wrqu
->data
.length
= priv
->wpa_ie_len
;
1039 memcpy(extra
, priv
->wpa_ie
, priv
->wpa_ie_len
);
1042 orinoco_unlock(priv
, &flags
);
1046 static int orinoco_ioctl_set_mlme(struct net_device
*dev
,
1047 struct iw_request_info
*info
,
1048 union iwreq_data
*wrqu
, char *extra
)
1050 struct orinoco_private
*priv
= ndev_priv(dev
);
1051 struct iw_mlme
*mlme
= (struct iw_mlme
*)extra
;
1052 unsigned long flags
;
1055 if (orinoco_lock(priv
, &flags
) != 0)
1058 switch (mlme
->cmd
) {
1059 case IW_MLME_DEAUTH
:
1060 /* silently ignore */
1063 case IW_MLME_DISASSOC
:
1065 ret
= orinoco_hw_disassociate(priv
, mlme
->addr
.sa_data
,
1073 orinoco_unlock(priv
, &flags
);
1077 static int orinoco_ioctl_reset(struct net_device
*dev
,
1078 struct iw_request_info
*info
,
1082 struct orinoco_private
*priv
= ndev_priv(dev
);
1084 if (!capable(CAP_NET_ADMIN
))
1087 if (info
->cmd
== (SIOCIWFIRSTPRIV
+ 0x1)) {
1088 printk(KERN_DEBUG
"%s: Forcing reset!\n", dev
->name
);
1090 /* Firmware reset */
1091 orinoco_reset(&priv
->reset_work
);
1093 printk(KERN_DEBUG
"%s: Force scheduling reset!\n", dev
->name
);
1095 schedule_work(&priv
->reset_work
);
1101 static int orinoco_ioctl_setibssport(struct net_device
*dev
,
1102 struct iw_request_info
*info
,
1107 struct orinoco_private
*priv
= ndev_priv(dev
);
1108 int val
= *((int *) extra
);
1109 unsigned long flags
;
1111 if (orinoco_lock(priv
, &flags
) != 0)
1114 priv
->ibss_port
= val
;
1116 /* Actually update the mode we are using */
1117 set_port_type(priv
);
1119 orinoco_unlock(priv
, &flags
);
1120 return -EINPROGRESS
; /* Call commit handler */
1123 static int orinoco_ioctl_getibssport(struct net_device
*dev
,
1124 struct iw_request_info
*info
,
1128 struct orinoco_private
*priv
= ndev_priv(dev
);
1129 int *val
= (int *) extra
;
1131 *val
= priv
->ibss_port
;
1135 static int orinoco_ioctl_setport3(struct net_device
*dev
,
1136 struct iw_request_info
*info
,
1140 struct orinoco_private
*priv
= ndev_priv(dev
);
1141 int val
= *((int *) extra
);
1143 unsigned long flags
;
1145 if (orinoco_lock(priv
, &flags
) != 0)
1149 case 0: /* Try to do IEEE ad-hoc mode */
1150 if (!priv
->has_ibss
) {
1154 priv
->prefer_port3
= 0;
1158 case 1: /* Try to do Lucent proprietary ad-hoc mode */
1159 if (!priv
->has_port3
) {
1163 priv
->prefer_port3
= 1;
1171 /* Actually update the mode we are using */
1172 set_port_type(priv
);
1176 orinoco_unlock(priv
, &flags
);
1181 static int orinoco_ioctl_getport3(struct net_device
*dev
,
1182 struct iw_request_info
*info
,
1186 struct orinoco_private
*priv
= ndev_priv(dev
);
1187 int *val
= (int *) extra
;
1189 *val
= priv
->prefer_port3
;
1193 static int orinoco_ioctl_setpreamble(struct net_device
*dev
,
1194 struct iw_request_info
*info
,
1198 struct orinoco_private
*priv
= ndev_priv(dev
);
1199 unsigned long flags
;
1202 if (!priv
->has_preamble
)
1205 /* 802.11b has recently defined some short preamble.
1206 * Basically, the Phy header has been reduced in size.
1207 * This increase performance, especially at high rates
1208 * (the preamble is transmitted at 1Mb/s), unfortunately
1209 * this give compatibility troubles... - Jean II */
1210 val
= *((int *) extra
);
1212 if (orinoco_lock(priv
, &flags
) != 0)
1220 orinoco_unlock(priv
, &flags
);
1222 return -EINPROGRESS
; /* Call commit handler */
1225 static int orinoco_ioctl_getpreamble(struct net_device
*dev
,
1226 struct iw_request_info
*info
,
1230 struct orinoco_private
*priv
= ndev_priv(dev
);
1231 int *val
= (int *) extra
;
1233 if (!priv
->has_preamble
)
1236 *val
= priv
->preamble
;
1240 /* ioctl interface to hermes_read_ltv()
1241 * To use with iwpriv, pass the RID as the token argument, e.g.
1242 * iwpriv get_rid [0xfc00]
1243 * At least Wireless Tools 25 is required to use iwpriv.
1244 * For Wireless Tools 25 and 26 append "dummy" are the end. */
1245 static int orinoco_ioctl_getrid(struct net_device
*dev
,
1246 struct iw_request_info
*info
,
1247 struct iw_point
*data
,
1250 struct orinoco_private
*priv
= ndev_priv(dev
);
1251 hermes_t
*hw
= &priv
->hw
;
1252 int rid
= data
->flags
;
1255 unsigned long flags
;
1257 /* It's a "get" function, but we don't want users to access the
1258 * WEP key and other raw firmware data */
1259 if (!capable(CAP_NET_ADMIN
))
1262 if (rid
< 0xfc00 || rid
> 0xffff)
1265 if (orinoco_lock(priv
, &flags
) != 0)
1268 err
= hw
->ops
->read_ltv(hw
, USER_BAP
, rid
, MAX_RID_LEN
, &length
,
1273 data
->length
= min_t(u16
, HERMES_RECLEN_TO_BYTES(length
),
1277 orinoco_unlock(priv
, &flags
);
1282 /* Commit handler, called after set operations */
1283 static int orinoco_ioctl_commit(struct net_device
*dev
,
1284 struct iw_request_info
*info
,
1288 struct orinoco_private
*priv
= ndev_priv(dev
);
1289 unsigned long flags
;
1295 if (orinoco_lock(priv
, &flags
) != 0)
1298 err
= orinoco_commit(priv
);
1300 orinoco_unlock(priv
, &flags
);
1304 static const struct iw_priv_args orinoco_privtab
[] = {
1305 { SIOCIWFIRSTPRIV
+ 0x0, 0, 0, "force_reset" },
1306 { SIOCIWFIRSTPRIV
+ 0x1, 0, 0, "card_reset" },
1307 { SIOCIWFIRSTPRIV
+ 0x2, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1,
1309 { SIOCIWFIRSTPRIV
+ 0x3, 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1,
1311 { SIOCIWFIRSTPRIV
+ 0x4, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1,
1312 0, "set_preamble" },
1313 { SIOCIWFIRSTPRIV
+ 0x5, 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1,
1315 { SIOCIWFIRSTPRIV
+ 0x6, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1,
1316 0, "set_ibssport" },
1317 { SIOCIWFIRSTPRIV
+ 0x7, 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1,
1319 { SIOCIWFIRSTPRIV
+ 0x9, 0, IW_PRIV_TYPE_BYTE
| MAX_RID_LEN
,
1325 * Structures to export the Wireless Handlers
1328 static const iw_handler orinoco_handler
[] = {
1329 IW_HANDLER(SIOCSIWCOMMIT
, (iw_handler
)orinoco_ioctl_commit
),
1330 IW_HANDLER(SIOCGIWNAME
, (iw_handler
)cfg80211_wext_giwname
),
1331 IW_HANDLER(SIOCSIWFREQ
, (iw_handler
)orinoco_ioctl_setfreq
),
1332 IW_HANDLER(SIOCGIWFREQ
, (iw_handler
)orinoco_ioctl_getfreq
),
1333 IW_HANDLER(SIOCSIWMODE
, (iw_handler
)cfg80211_wext_siwmode
),
1334 IW_HANDLER(SIOCGIWMODE
, (iw_handler
)cfg80211_wext_giwmode
),
1335 IW_HANDLER(SIOCSIWSENS
, (iw_handler
)orinoco_ioctl_setsens
),
1336 IW_HANDLER(SIOCGIWSENS
, (iw_handler
)orinoco_ioctl_getsens
),
1337 IW_HANDLER(SIOCGIWRANGE
, (iw_handler
)cfg80211_wext_giwrange
),
1338 IW_HANDLER(SIOCSIWSPY
, iw_handler_set_spy
),
1339 IW_HANDLER(SIOCGIWSPY
, iw_handler_get_spy
),
1340 IW_HANDLER(SIOCSIWTHRSPY
, iw_handler_set_thrspy
),
1341 IW_HANDLER(SIOCGIWTHRSPY
, iw_handler_get_thrspy
),
1342 IW_HANDLER(SIOCSIWAP
, (iw_handler
)orinoco_ioctl_setwap
),
1343 IW_HANDLER(SIOCGIWAP
, (iw_handler
)orinoco_ioctl_getwap
),
1344 IW_HANDLER(SIOCSIWSCAN
, (iw_handler
)cfg80211_wext_siwscan
),
1345 IW_HANDLER(SIOCGIWSCAN
, (iw_handler
)cfg80211_wext_giwscan
),
1346 IW_HANDLER(SIOCSIWESSID
, (iw_handler
)orinoco_ioctl_setessid
),
1347 IW_HANDLER(SIOCGIWESSID
, (iw_handler
)orinoco_ioctl_getessid
),
1348 IW_HANDLER(SIOCSIWRATE
, (iw_handler
)orinoco_ioctl_setrate
),
1349 IW_HANDLER(SIOCGIWRATE
, (iw_handler
)orinoco_ioctl_getrate
),
1350 IW_HANDLER(SIOCSIWRTS
, (iw_handler
)cfg80211_wext_siwrts
),
1351 IW_HANDLER(SIOCGIWRTS
, (iw_handler
)cfg80211_wext_giwrts
),
1352 IW_HANDLER(SIOCSIWFRAG
, (iw_handler
)cfg80211_wext_siwfrag
),
1353 IW_HANDLER(SIOCGIWFRAG
, (iw_handler
)cfg80211_wext_giwfrag
),
1354 IW_HANDLER(SIOCGIWRETRY
, (iw_handler
)cfg80211_wext_giwretry
),
1355 IW_HANDLER(SIOCSIWENCODE
, (iw_handler
)orinoco_ioctl_setiwencode
),
1356 IW_HANDLER(SIOCGIWENCODE
, (iw_handler
)orinoco_ioctl_getiwencode
),
1357 IW_HANDLER(SIOCSIWPOWER
, (iw_handler
)orinoco_ioctl_setpower
),
1358 IW_HANDLER(SIOCGIWPOWER
, (iw_handler
)orinoco_ioctl_getpower
),
1359 IW_HANDLER(SIOCSIWGENIE
, orinoco_ioctl_set_genie
),
1360 IW_HANDLER(SIOCGIWGENIE
, orinoco_ioctl_get_genie
),
1361 IW_HANDLER(SIOCSIWMLME
, orinoco_ioctl_set_mlme
),
1362 IW_HANDLER(SIOCSIWAUTH
, orinoco_ioctl_set_auth
),
1363 IW_HANDLER(SIOCGIWAUTH
, orinoco_ioctl_get_auth
),
1364 IW_HANDLER(SIOCSIWENCODEEXT
, orinoco_ioctl_set_encodeext
),
1365 IW_HANDLER(SIOCGIWENCODEEXT
, orinoco_ioctl_get_encodeext
),
1370 Added typecasting since we no longer use iwreq_data -- Moustafa
1372 static const iw_handler orinoco_private_handler
[] = {
1373 [0] = (iw_handler
)orinoco_ioctl_reset
,
1374 [1] = (iw_handler
)orinoco_ioctl_reset
,
1375 [2] = (iw_handler
)orinoco_ioctl_setport3
,
1376 [3] = (iw_handler
)orinoco_ioctl_getport3
,
1377 [4] = (iw_handler
)orinoco_ioctl_setpreamble
,
1378 [5] = (iw_handler
)orinoco_ioctl_getpreamble
,
1379 [6] = (iw_handler
)orinoco_ioctl_setibssport
,
1380 [7] = (iw_handler
)orinoco_ioctl_getibssport
,
1381 [9] = (iw_handler
)orinoco_ioctl_getrid
,
1384 const struct iw_handler_def orinoco_handler_def
= {
1385 .num_standard
= ARRAY_SIZE(orinoco_handler
),
1386 .num_private
= ARRAY_SIZE(orinoco_private_handler
),
1387 .num_private_args
= ARRAY_SIZE(orinoco_privtab
),
1388 .standard
= orinoco_handler
,
1389 .private = orinoco_private_handler
,
1390 .private_args
= orinoco_privtab
,
1391 .get_wireless_stats
= orinoco_get_wireless_stats
,