2 * Copyright (C) 2002 Intersil Americas Inc.
3 * (C) 2003,2004 Aurelien Alleaume <slts@free.fr>
4 * (C) 2003 Herbert Valerio Riedel <hvr@gnu.org>
5 * (C) 2003 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <linux/module.h>
23 #include <linux/kernel.h>
24 #include <linux/if_arp.h>
25 #include <linux/pci.h>
27 #include <asm/uaccess.h>
29 #include "prismcompat.h"
30 #include "isl_ioctl.h"
31 #include "islpci_mgt.h"
32 #include "isl_oid.h" /* additional types and defs for isl38xx fw */
35 #include <net/iw_handler.h> /* New driver API */
37 #define KEY_SIZE_WEP104 13 /* 104/128-bit WEP keys */
38 #define KEY_SIZE_WEP40 5 /* 40/64-bit WEP keys */
39 /* KEY_SIZE_TKIP should match isl_oid.h, struct obj_key.key[] size */
40 #define KEY_SIZE_TKIP 32 /* TKIP keys */
42 static void prism54_wpa_bss_ie_add(islpci_private
*priv
, u8
*bssid
,
43 u8
*wpa_ie
, size_t wpa_ie_len
);
44 static size_t prism54_wpa_bss_ie_get(islpci_private
*priv
, u8
*bssid
, u8
*wpa_ie
);
45 static int prism54_set_wpa(struct net_device
*, struct iw_request_info
*,
49 static const unsigned char scan_rate_list
[] = { 2, 4, 11, 22,
54 * prism54_mib_mode_helper - MIB change mode helper function
55 * @mib: the &struct islpci_mib object to modify
56 * @iw_mode: new mode (%IW_MODE_*)
58 * This is a helper function, hence it does not lock. Make sure
59 * caller deals with locking *if* necessary. This function sets the
60 * mode-dependent mib values and does the mapping of the Linux
61 * Wireless API modes to Device firmware modes. It also checks for
62 * correct valid Linux wireless modes.
65 prism54_mib_mode_helper(islpci_private
*priv
, u32 iw_mode
)
67 u32 config
= INL_CONFIG_MANUALRUN
;
70 /* For now, just catch early the Repeater and Secondary modes here */
71 if (iw_mode
== IW_MODE_REPEAT
|| iw_mode
== IW_MODE_SECOND
) {
73 "%s(): Sorry, Repeater mode and Secondary mode "
74 "are not yet supported by this driver.\n", __FUNCTION__
);
78 priv
->iw_mode
= iw_mode
;
82 mode
= INL_MODE_CLIENT
;
83 bsstype
= DOT11_BSSTYPE_ANY
;
86 mode
= INL_MODE_CLIENT
;
87 bsstype
= DOT11_BSSTYPE_IBSS
;
90 mode
= INL_MODE_CLIENT
;
91 bsstype
= DOT11_BSSTYPE_INFRA
;
95 bsstype
= DOT11_BSSTYPE_INFRA
;
98 mode
= INL_MODE_PROMISCUOUS
;
99 bsstype
= DOT11_BSSTYPE_ANY
;
100 config
|= INL_CONFIG_RXANNEX
;
107 config
|= INL_CONFIG_WDS
;
108 mgt_set(priv
, DOT11_OID_BSSTYPE
, &bsstype
);
109 mgt_set(priv
, OID_INL_CONFIG
, &config
);
110 mgt_set(priv
, OID_INL_MODE
, &mode
);
116 * prism54_mib_init - fill MIB cache with defaults
118 * this function initializes the struct given as @mib with defaults,
119 * of which many are retrieved from the global module parameter
124 prism54_mib_init(islpci_private
*priv
)
126 u32 channel
, authen
, wep
, filter
, dot1x
, mlme
, conformance
, power
, mode
;
127 struct obj_buffer psm_buffer
= {
128 .size
= PSM_BUFFER_SIZE
,
129 .addr
= priv
->device_psm_buffer
132 channel
= CARD_DEFAULT_CHANNEL
;
133 authen
= CARD_DEFAULT_AUTHEN
;
134 wep
= CARD_DEFAULT_WEP
;
135 filter
= CARD_DEFAULT_FILTER
; /* (0) Do not filter un-encrypted data */
136 dot1x
= CARD_DEFAULT_DOT1X
;
137 mlme
= CARD_DEFAULT_MLME_MODE
;
138 conformance
= CARD_DEFAULT_CONFORMANCE
;
140 mode
= CARD_DEFAULT_IW_MODE
;
142 mgt_set(priv
, DOT11_OID_CHANNEL
, &channel
);
143 mgt_set(priv
, DOT11_OID_AUTHENABLE
, &authen
);
144 mgt_set(priv
, DOT11_OID_PRIVACYINVOKED
, &wep
);
145 mgt_set(priv
, DOT11_OID_PSMBUFFER
, &psm_buffer
);
146 mgt_set(priv
, DOT11_OID_EXUNENCRYPTED
, &filter
);
147 mgt_set(priv
, DOT11_OID_DOT1XENABLE
, &dot1x
);
148 mgt_set(priv
, DOT11_OID_MLMEAUTOLEVEL
, &mlme
);
149 mgt_set(priv
, OID_INL_DOT11D_CONFORMANCE
, &conformance
);
150 mgt_set(priv
, OID_INL_OUTPUTPOWER
, &power
);
152 /* This sets all of the mode-dependent values */
153 prism54_mib_mode_helper(priv
, mode
);
156 /* this will be executed outside of atomic context thanks to
157 * schedule_work(), thus we can as well use sleeping semaphore
160 prism54_update_stats(struct work_struct
*work
)
162 islpci_private
*priv
= container_of(work
, islpci_private
, stats_work
);
165 struct obj_bss bss
, *bss2
;
168 if (down_interruptible(&priv
->stats_sem
))
172 * I'm not sure if the unit is dBm.
173 * Note : If we are not connected, this value seems to be irrelevant. */
175 mgt_get_request(priv
, DOT11_OID_NOISEFLOOR
, 0, NULL
, &r
);
176 priv
->local_iwstatistics
.qual
.noise
= r
.u
;
178 /* Get the rssi of the link. To do this we need to retrieve a bss. */
180 /* First get the MAC address of the AP we are associated with. */
181 mgt_get_request(priv
, DOT11_OID_BSSID
, 0, NULL
, &r
);
184 /* copy this MAC to the bss */
185 memcpy(bss
.address
, data
, 6);
188 /* now ask for the corresponding bss */
189 j
= mgt_get_request(priv
, DOT11_OID_BSSFIND
, 0, (void *) &bss
, &r
);
191 /* report the rssi and use it to calculate
192 * link quality through a signal-noise
194 priv
->local_iwstatistics
.qual
.level
= bss2
->rssi
;
195 priv
->local_iwstatistics
.qual
.qual
=
196 bss2
->rssi
- priv
->iwstatistics
.qual
.noise
;
200 /* report that the stats are new */
201 priv
->local_iwstatistics
.qual
.updated
= 0x7;
203 /* Rx : unable to decrypt the MPDU */
204 mgt_get_request(priv
, DOT11_OID_PRIVRXFAILED
, 0, NULL
, &r
);
205 priv
->local_iwstatistics
.discard
.code
= r
.u
;
207 /* Tx : Max MAC retries num reached */
208 mgt_get_request(priv
, DOT11_OID_MPDUTXFAILED
, 0, NULL
, &r
);
209 priv
->local_iwstatistics
.discard
.retries
= r
.u
;
211 up(&priv
->stats_sem
);
216 struct iw_statistics
*
217 prism54_get_wireless_stats(struct net_device
*ndev
)
219 islpci_private
*priv
= netdev_priv(ndev
);
221 /* If the stats are being updated return old data */
222 if (down_trylock(&priv
->stats_sem
) == 0) {
223 memcpy(&priv
->iwstatistics
, &priv
->local_iwstatistics
,
224 sizeof (struct iw_statistics
));
225 /* They won't be marked updated for the next time */
226 priv
->local_iwstatistics
.qual
.updated
= 0;
227 up(&priv
->stats_sem
);
229 priv
->iwstatistics
.qual
.updated
= 0;
231 /* Update our wireless stats, but do not schedule to often
233 if ((priv
->stats_timestamp
== 0) ||
234 time_after(jiffies
, priv
->stats_timestamp
+ 1 * HZ
)) {
235 schedule_work(&priv
->stats_work
);
236 priv
->stats_timestamp
= jiffies
;
239 return &priv
->iwstatistics
;
243 prism54_commit(struct net_device
*ndev
, struct iw_request_info
*info
,
244 char *cwrq
, char *extra
)
246 islpci_private
*priv
= netdev_priv(ndev
);
248 /* simply re-set the last set SSID, this should commit most stuff */
250 /* Commit in Monitor mode is not necessary, also setting essid
251 * in Monitor mode does not make sense and isn't allowed for this
252 * device's firmware */
253 if (priv
->iw_mode
!= IW_MODE_MONITOR
)
254 return mgt_set_request(priv
, DOT11_OID_SSID
, 0, NULL
);
259 prism54_get_name(struct net_device
*ndev
, struct iw_request_info
*info
,
260 char *cwrq
, char *extra
)
262 islpci_private
*priv
= netdev_priv(ndev
);
267 if (islpci_get_state(priv
) < PRV_STATE_INIT
) {
268 strncpy(cwrq
, "NOT READY!", IFNAMSIZ
);
271 rvalue
= mgt_get_request(priv
, OID_INL_PHYCAPABILITIES
, 0, NULL
, &r
);
274 case INL_PHYCAP_5000MHZ
:
275 capabilities
= "IEEE 802.11a/b/g";
278 capabilities
= "IEEE 802.11b/g - FAA Support";
280 case INL_PHYCAP_2400MHZ
:
282 capabilities
= "IEEE 802.11b/g"; /* Default */
285 strncpy(cwrq
, capabilities
, IFNAMSIZ
);
290 prism54_set_freq(struct net_device
*ndev
, struct iw_request_info
*info
,
291 struct iw_freq
*fwrq
, char *extra
)
293 islpci_private
*priv
= netdev_priv(ndev
);
298 /* we have a channel number */
301 c
= (fwrq
->e
== 1) ? channel_of_freq(fwrq
->m
/ 100000) : 0;
303 rvalue
= c
? mgt_set_request(priv
, DOT11_OID_CHANNEL
, 0, &c
) : -EINVAL
;
305 /* Call commit handler */
306 return (rvalue
? rvalue
: -EINPROGRESS
);
310 prism54_get_freq(struct net_device
*ndev
, struct iw_request_info
*info
,
311 struct iw_freq
*fwrq
, char *extra
)
313 islpci_private
*priv
= netdev_priv(ndev
);
317 rvalue
= mgt_get_request(priv
, DOT11_OID_CHANNEL
, 0, NULL
, &r
);
319 rvalue
|= mgt_get_request(priv
, DOT11_OID_FREQUENCY
, 0, NULL
, &r
);
327 prism54_set_mode(struct net_device
*ndev
, struct iw_request_info
*info
,
328 __u32
* uwrq
, char *extra
)
330 islpci_private
*priv
= netdev_priv(ndev
);
331 u32 mlmeautolevel
= CARD_DEFAULT_MLME_MODE
;
333 /* Let's see if the user passed a valid Linux Wireless mode */
334 if (*uwrq
> IW_MODE_MONITOR
|| *uwrq
< IW_MODE_AUTO
) {
336 "%s: %s() You passed a non-valid init_mode.\n",
337 priv
->ndev
->name
, __FUNCTION__
);
341 down_write(&priv
->mib_sem
);
343 if (prism54_mib_mode_helper(priv
, *uwrq
)) {
344 up_write(&priv
->mib_sem
);
348 /* the ACL code needs an intermediate mlmeautolevel. The wpa stuff an
351 if ((*uwrq
== IW_MODE_MASTER
) && (priv
->acl
.policy
!= MAC_POLICY_OPEN
))
352 mlmeautolevel
= DOT11_MLME_INTERMEDIATE
;
354 mlmeautolevel
= DOT11_MLME_EXTENDED
;
356 mgt_set(priv
, DOT11_OID_MLMEAUTOLEVEL
, &mlmeautolevel
);
358 if (mgt_commit(priv
)) {
359 up_write(&priv
->mib_sem
);
362 priv
->ndev
->type
= (priv
->iw_mode
== IW_MODE_MONITOR
)
363 ? priv
->monitor_type
: ARPHRD_ETHER
;
364 up_write(&priv
->mib_sem
);
371 prism54_get_mode(struct net_device
*ndev
, struct iw_request_info
*info
,
372 __u32
* uwrq
, char *extra
)
374 islpci_private
*priv
= netdev_priv(ndev
);
376 BUG_ON((priv
->iw_mode
< IW_MODE_AUTO
) || (priv
->iw_mode
>
378 *uwrq
= priv
->iw_mode
;
383 /* we use DOT11_OID_EDTHRESHOLD. From what I guess the card will not try to
384 * emit data if (sensitivity > rssi - noise) (in dBm).
385 * prism54_set_sens does not seem to work.
389 prism54_set_sens(struct net_device
*ndev
, struct iw_request_info
*info
,
390 struct iw_param
*vwrq
, char *extra
)
392 islpci_private
*priv
= netdev_priv(ndev
);
395 /* by default the card sets this to 20. */
396 sens
= vwrq
->disabled
? 20 : vwrq
->value
;
398 return mgt_set_request(priv
, DOT11_OID_EDTHRESHOLD
, 0, &sens
);
402 prism54_get_sens(struct net_device
*ndev
, struct iw_request_info
*info
,
403 struct iw_param
*vwrq
, char *extra
)
405 islpci_private
*priv
= netdev_priv(ndev
);
409 rvalue
= mgt_get_request(priv
, DOT11_OID_EDTHRESHOLD
, 0, NULL
, &r
);
412 vwrq
->disabled
= (vwrq
->value
== 0);
419 prism54_get_range(struct net_device
*ndev
, struct iw_request_info
*info
,
420 struct iw_point
*dwrq
, char *extra
)
422 struct iw_range
*range
= (struct iw_range
*) extra
;
423 islpci_private
*priv
= netdev_priv(ndev
);
426 struct obj_frequencies
*freq
;
429 memset(range
, 0, sizeof (struct iw_range
));
430 dwrq
->length
= sizeof (struct iw_range
);
432 /* set the wireless extension version number */
433 range
->we_version_source
= SUPPORTED_WIRELESS_EXT
;
434 range
->we_version_compiled
= WIRELESS_EXT
;
436 /* Now the encoding capabilities */
437 range
->num_encoding_sizes
= 3;
438 /* 64(40) bits WEP */
439 range
->encoding_size
[0] = 5;
440 /* 128(104) bits WEP */
441 range
->encoding_size
[1] = 13;
442 /* 256 bits for WPA-PSK */
443 range
->encoding_size
[2] = 32;
444 /* 4 keys are allowed */
445 range
->max_encoding_tokens
= 4;
447 /* we don't know the quality range... */
448 range
->max_qual
.level
= 0;
449 range
->max_qual
.noise
= 0;
450 range
->max_qual
.qual
= 0;
451 /* these value describe an average quality. Needs more tweaking... */
452 range
->avg_qual
.level
= -80; /* -80 dBm */
453 range
->avg_qual
.noise
= 0; /* don't know what to put here */
454 range
->avg_qual
.qual
= 0;
456 range
->sensitivity
= 200;
458 /* retry limit capabilities */
459 range
->retry_capa
= IW_RETRY_LIMIT
| IW_RETRY_LIFETIME
;
460 range
->retry_flags
= IW_RETRY_LIMIT
;
461 range
->r_time_flags
= IW_RETRY_LIFETIME
;
463 /* I don't know the range. Put stupid things here */
464 range
->min_retry
= 1;
465 range
->max_retry
= 65535;
466 range
->min_r_time
= 1024;
467 range
->max_r_time
= 65535 * 1024;
469 /* txpower is supported in dBm's */
470 range
->txpower_capa
= IW_TXPOW_DBM
;
472 /* Event capability (kernel + driver) */
473 range
->event_capa
[0] = (IW_EVENT_CAPA_K_0
|
474 IW_EVENT_CAPA_MASK(SIOCGIWTHRSPY
) |
475 IW_EVENT_CAPA_MASK(SIOCGIWAP
));
476 range
->event_capa
[1] = IW_EVENT_CAPA_K_1
;
477 range
->event_capa
[4] = IW_EVENT_CAPA_MASK(IWEVCUSTOM
);
479 range
->enc_capa
= IW_ENC_CAPA_WPA
| IW_ENC_CAPA_WPA2
|
480 IW_ENC_CAPA_CIPHER_TKIP
;
482 if (islpci_get_state(priv
) < PRV_STATE_INIT
)
485 /* Request the device for the supported frequencies
486 * not really relevant since some devices will report the 5 GHz band
487 * frequencies even if they don't support them.
490 mgt_get_request(priv
, DOT11_OID_SUPPORTEDFREQUENCIES
, 0, NULL
, &r
);
493 range
->num_channels
= freq
->nr
;
494 range
->num_frequency
= freq
->nr
;
496 m
= min(IW_MAX_FREQUENCIES
, (int) freq
->nr
);
497 for (i
= 0; i
< m
; i
++) {
498 range
->freq
[i
].m
= freq
->mhz
[i
];
499 range
->freq
[i
].e
= 6;
500 range
->freq
[i
].i
= channel_of_freq(freq
->mhz
[i
]);
504 rvalue
|= mgt_get_request(priv
, DOT11_OID_SUPPORTEDRATES
, 0, NULL
, &r
);
507 /* We got an array of char. It is NULL terminated. */
509 while ((i
< IW_MAX_BITRATES
) && (*data
!= 0)) {
510 /* the result must be in bps. The card gives us 500Kbps */
511 range
->bitrate
[i
] = *data
* 500000;
515 range
->num_bitrates
= i
;
524 prism54_set_wap(struct net_device
*ndev
, struct iw_request_info
*info
,
525 struct sockaddr
*awrq
, char *extra
)
527 islpci_private
*priv
= netdev_priv(ndev
);
531 if (awrq
->sa_family
!= ARPHRD_ETHER
)
534 /* prepare the structure for the set object */
535 memcpy(&bssid
[0], awrq
->sa_data
, 6);
537 /* set the bssid -- does this make sense when in AP mode? */
538 rvalue
= mgt_set_request(priv
, DOT11_OID_BSSID
, 0, &bssid
);
540 return (rvalue
? rvalue
: -EINPROGRESS
); /* Call commit handler */
546 prism54_get_wap(struct net_device
*ndev
, struct iw_request_info
*info
,
547 struct sockaddr
*awrq
, char *extra
)
549 islpci_private
*priv
= netdev_priv(ndev
);
553 rvalue
= mgt_get_request(priv
, DOT11_OID_BSSID
, 0, NULL
, &r
);
554 memcpy(awrq
->sa_data
, r
.ptr
, 6);
555 awrq
->sa_family
= ARPHRD_ETHER
;
562 prism54_set_scan(struct net_device
*dev
, struct iw_request_info
*info
,
563 struct iw_param
*vwrq
, char *extra
)
565 /* hehe the device does this automagicaly */
569 /* a little helper that will translate our data into a card independent
570 * format that the Wireless Tools will understand. This was inspired by
571 * the "Aironet driver for 4500 and 4800 series cards" (GPL)
575 prism54_translate_bss(struct net_device
*ndev
, char *current_ev
,
576 char *end_buf
, struct obj_bss
*bss
, char noise
)
578 struct iw_event iwe
; /* Temporary buffer */
580 islpci_private
*priv
= netdev_priv(ndev
);
581 u8 wpa_ie
[MAX_WPA_IE_LEN
];
584 /* The first entry must be the MAC address */
585 memcpy(iwe
.u
.ap_addr
.sa_data
, bss
->address
, 6);
586 iwe
.u
.ap_addr
.sa_family
= ARPHRD_ETHER
;
589 iwe_stream_add_event(current_ev
, end_buf
, &iwe
, IW_EV_ADDR_LEN
);
591 /* The following entries will be displayed in the same order we give them */
594 iwe
.u
.data
.length
= bss
->ssid
.length
;
595 iwe
.u
.data
.flags
= 1;
596 iwe
.cmd
= SIOCGIWESSID
;
597 current_ev
= iwe_stream_add_point(current_ev
, end_buf
,
598 &iwe
, bss
->ssid
.octets
);
602 #define CAP_IBSS 0x02
603 #define CAP_CRYPT 0x10
609 iwe
.u
.mode
= IW_MODE_MASTER
;
610 else if (cap
& CAP_IBSS
)
611 iwe
.u
.mode
= IW_MODE_ADHOC
;
612 iwe
.cmd
= SIOCGIWMODE
;
615 iwe_stream_add_event(current_ev
, end_buf
, &iwe
,
618 /* Encryption capability */
620 iwe
.u
.data
.flags
= IW_ENCODE_ENABLED
| IW_ENCODE_NOKEY
;
622 iwe
.u
.data
.flags
= IW_ENCODE_DISABLED
;
623 iwe
.u
.data
.length
= 0;
624 iwe
.cmd
= SIOCGIWENCODE
;
625 current_ev
= iwe_stream_add_point(current_ev
, end_buf
, &iwe
, NULL
);
627 /* Add frequency. (short) bss->channel is the frequency in MHz */
628 iwe
.u
.freq
.m
= bss
->channel
;
630 iwe
.cmd
= SIOCGIWFREQ
;
632 iwe_stream_add_event(current_ev
, end_buf
, &iwe
, IW_EV_FREQ_LEN
);
634 /* Add quality statistics */
635 iwe
.u
.qual
.level
= bss
->rssi
;
636 iwe
.u
.qual
.noise
= noise
;
637 /* do a simple SNR for quality */
638 iwe
.u
.qual
.qual
= bss
->rssi
- noise
;
641 iwe_stream_add_event(current_ev
, end_buf
, &iwe
, IW_EV_QUAL_LEN
);
643 /* Add WPA/RSN Information Element, if any */
644 wpa_ie_len
= prism54_wpa_bss_ie_get(priv
, bss
->address
, wpa_ie
);
645 if (wpa_ie_len
> 0) {
647 iwe
.u
.data
.length
= min(wpa_ie_len
, (size_t)MAX_WPA_IE_LEN
);
648 current_ev
= iwe_stream_add_point(current_ev
, end_buf
,
651 /* Do the bitrates */
653 char * current_val
= current_ev
+ IW_EV_LCP_LEN
;
657 iwe
.cmd
= SIOCGIWRATE
;
658 /* Those two flags are ignored... */
659 iwe
.u
.bitrate
.fixed
= iwe
.u
.bitrate
.disabled
= 0;
661 /* Parse the bitmask */
663 for(i
= 0; i
< sizeof(scan_rate_list
); i
++) {
664 if(bss
->rates
& mask
) {
665 iwe
.u
.bitrate
.value
= (scan_rate_list
[i
] * 500000);
666 current_val
= iwe_stream_add_value(current_ev
, current_val
,
672 /* Check if we added any event */
673 if ((current_val
- current_ev
) > IW_EV_LCP_LEN
)
674 current_ev
= current_val
;
681 prism54_get_scan(struct net_device
*ndev
, struct iw_request_info
*info
,
682 struct iw_point
*dwrq
, char *extra
)
684 islpci_private
*priv
= netdev_priv(ndev
);
686 struct obj_bsslist
*bsslist
;
688 char *current_ev
= extra
;
691 if (islpci_get_state(priv
) < PRV_STATE_INIT
) {
692 /* device is not ready, fail gently */
697 /* first get the noise value. We will use it to report the link quality */
698 rvalue
= mgt_get_request(priv
, DOT11_OID_NOISEFLOOR
, 0, NULL
, &r
);
701 /* Ask the device for a list of known bss.
702 * The old API, using SIOCGIWAPLIST, had a hard limit of IW_MAX_AP=64.
703 * The new API, using SIOCGIWSCAN, is only limited by the buffer size.
704 * WE-14->WE-16, the buffer is limited to IW_SCAN_MAX_DATA bytes.
705 * Starting with WE-17, the buffer can be as big as needed.
706 * But the device won't repport anything if you change the value
707 * of IWMAX_BSS=24. */
709 rvalue
|= mgt_get_request(priv
, DOT11_OID_BSSLIST
, 0, NULL
, &r
);
712 /* ok now, scan the list and translate its info */
713 for (i
= 0; i
< (int) bsslist
->nr
; i
++) {
714 current_ev
= prism54_translate_bss(ndev
, current_ev
,
715 extra
+ dwrq
->length
,
716 &(bsslist
->bsslist
[i
]),
719 /* Check if there is space for one more entry */
720 if((extra
+ dwrq
->length
- current_ev
) <= IW_EV_ADDR_LEN
) {
721 /* Ask user space to try again with a bigger buffer */
728 dwrq
->length
= (current_ev
- extra
);
729 dwrq
->flags
= 0; /* todo */
735 prism54_set_essid(struct net_device
*ndev
, struct iw_request_info
*info
,
736 struct iw_point
*dwrq
, char *extra
)
738 islpci_private
*priv
= netdev_priv(ndev
);
739 struct obj_ssid essid
;
741 memset(essid
.octets
, 0, 33);
743 /* Check if we were asked for `any' */
744 if (dwrq
->flags
&& dwrq
->length
) {
745 if (dwrq
->length
> 32)
747 essid
.length
= dwrq
->length
;
748 memcpy(essid
.octets
, extra
, dwrq
->length
);
752 if (priv
->iw_mode
!= IW_MODE_MONITOR
)
753 return mgt_set_request(priv
, DOT11_OID_SSID
, 0, &essid
);
755 /* If in monitor mode, just save to mib */
756 mgt_set(priv
, DOT11_OID_SSID
, &essid
);
762 prism54_get_essid(struct net_device
*ndev
, struct iw_request_info
*info
,
763 struct iw_point
*dwrq
, char *extra
)
765 islpci_private
*priv
= netdev_priv(ndev
);
766 struct obj_ssid
*essid
;
770 rvalue
= mgt_get_request(priv
, DOT11_OID_SSID
, 0, NULL
, &r
);
774 dwrq
->flags
= 1; /* set ESSID to ON for Wireless Extensions */
775 /* if it is too big, trunk it */
776 dwrq
->length
= min((u8
)IW_ESSID_MAX_SIZE
, essid
->length
);
781 essid
->octets
[essid
->length
] = '\0';
782 memcpy(extra
, essid
->octets
, dwrq
->length
);
788 /* Provides no functionality, just completes the ioctl. In essence this is a
789 * just a cosmetic ioctl.
792 prism54_set_nick(struct net_device
*ndev
, struct iw_request_info
*info
,
793 struct iw_point
*dwrq
, char *extra
)
795 islpci_private
*priv
= netdev_priv(ndev
);
797 if (dwrq
->length
> IW_ESSID_MAX_SIZE
)
800 down_write(&priv
->mib_sem
);
801 memset(priv
->nickname
, 0, sizeof (priv
->nickname
));
802 memcpy(priv
->nickname
, extra
, dwrq
->length
);
803 up_write(&priv
->mib_sem
);
809 prism54_get_nick(struct net_device
*ndev
, struct iw_request_info
*info
,
810 struct iw_point
*dwrq
, char *extra
)
812 islpci_private
*priv
= netdev_priv(ndev
);
816 down_read(&priv
->mib_sem
);
817 dwrq
->length
= strlen(priv
->nickname
);
818 memcpy(extra
, priv
->nickname
, dwrq
->length
);
819 up_read(&priv
->mib_sem
);
824 /* Set the allowed Bitrates */
827 prism54_set_rate(struct net_device
*ndev
,
828 struct iw_request_info
*info
,
829 struct iw_param
*vwrq
, char *extra
)
832 islpci_private
*priv
= netdev_priv(ndev
);
838 if (vwrq
->value
== -1) {
839 /* auto mode. No limit. */
841 return mgt_set_request(priv
, DOT11_OID_PROFILES
, 0, &profile
);
844 ret
= mgt_get_request(priv
, DOT11_OID_SUPPORTEDRATES
, 0, NULL
, &r
);
850 rate
= (u32
) (vwrq
->value
/ 500000);
855 if (rate
&& (data
[i
] == rate
)) {
858 if (vwrq
->value
== i
) {
873 /* Now, check if we want a fixed or auto value */
881 printk("prism54 rate: ");
883 printk("%u ", data[i]);
889 ret
= mgt_set_request(priv
, DOT11_OID_PROFILES
, 0, &profile
);
890 ret
|= mgt_set_request(priv
, DOT11_OID_EXTENDEDRATES
, 0, data
);
891 ret
|= mgt_set_request(priv
, DOT11_OID_RATES
, 0, data
);
898 /* Get the current bit rate */
900 prism54_get_rate(struct net_device
*ndev
,
901 struct iw_request_info
*info
,
902 struct iw_param
*vwrq
, char *extra
)
904 islpci_private
*priv
= netdev_priv(ndev
);
909 /* Get the current bit rate */
910 if ((rvalue
= mgt_get_request(priv
, GEN_OID_LINKSTATE
, 0, NULL
, &r
)))
912 vwrq
->value
= r
.u
* 500000;
914 /* request the device for the enabled rates */
915 rvalue
= mgt_get_request(priv
, DOT11_OID_RATES
, 0, NULL
, &r
);
921 vwrq
->fixed
= (data
[0] != 0) && (data
[1] == 0);
928 prism54_set_rts(struct net_device
*ndev
, struct iw_request_info
*info
,
929 struct iw_param
*vwrq
, char *extra
)
931 islpci_private
*priv
= netdev_priv(ndev
);
933 return mgt_set_request(priv
, DOT11_OID_RTSTHRESH
, 0, &vwrq
->value
);
937 prism54_get_rts(struct net_device
*ndev
, struct iw_request_info
*info
,
938 struct iw_param
*vwrq
, char *extra
)
940 islpci_private
*priv
= netdev_priv(ndev
);
944 /* get the rts threshold */
945 rvalue
= mgt_get_request(priv
, DOT11_OID_RTSTHRESH
, 0, NULL
, &r
);
952 prism54_set_frag(struct net_device
*ndev
, struct iw_request_info
*info
,
953 struct iw_param
*vwrq
, char *extra
)
955 islpci_private
*priv
= netdev_priv(ndev
);
957 return mgt_set_request(priv
, DOT11_OID_FRAGTHRESH
, 0, &vwrq
->value
);
961 prism54_get_frag(struct net_device
*ndev
, struct iw_request_info
*info
,
962 struct iw_param
*vwrq
, char *extra
)
964 islpci_private
*priv
= netdev_priv(ndev
);
968 rvalue
= mgt_get_request(priv
, DOT11_OID_FRAGTHRESH
, 0, NULL
, &r
);
974 /* Here we have (min,max) = max retries for (small frames, big frames). Where
975 * big frame <=> bigger than the rts threshold
976 * small frame <=> smaller than the rts threshold
977 * This is not really the behavior expected by the wireless tool but it seems
978 * to be a common behavior in other drivers.
982 prism54_set_retry(struct net_device
*ndev
, struct iw_request_info
*info
,
983 struct iw_param
*vwrq
, char *extra
)
985 islpci_private
*priv
= netdev_priv(ndev
);
986 u32 slimit
= 0, llimit
= 0; /* short and long limit */
991 /* we cannot disable this feature */
994 if (vwrq
->flags
& IW_RETRY_LIMIT
) {
995 if (vwrq
->flags
& IW_RETRY_SHORT
)
996 slimit
= vwrq
->value
;
997 else if (vwrq
->flags
& IW_RETRY_LONG
)
998 llimit
= vwrq
->value
;
1000 /* we are asked to set both */
1001 slimit
= vwrq
->value
;
1002 llimit
= vwrq
->value
;
1005 if (vwrq
->flags
& IW_RETRY_LIFETIME
)
1006 /* Wireless tools use us unit while the device uses 1024 us unit */
1007 lifetime
= vwrq
->value
/ 1024;
1009 /* now set what is requested */
1012 mgt_set_request(priv
, DOT11_OID_SHORTRETRIES
, 0, &slimit
);
1015 mgt_set_request(priv
, DOT11_OID_LONGRETRIES
, 0, &llimit
);
1018 mgt_set_request(priv
, DOT11_OID_MAXTXLIFETIME
, 0,
1024 prism54_get_retry(struct net_device
*ndev
, struct iw_request_info
*info
,
1025 struct iw_param
*vwrq
, char *extra
)
1027 islpci_private
*priv
= netdev_priv(ndev
);
1030 vwrq
->disabled
= 0; /* It cannot be disabled */
1032 if ((vwrq
->flags
& IW_RETRY_TYPE
) == IW_RETRY_LIFETIME
) {
1033 /* we are asked for the life time */
1035 mgt_get_request(priv
, DOT11_OID_MAXTXLIFETIME
, 0, NULL
, &r
);
1036 vwrq
->value
= r
.u
* 1024;
1037 vwrq
->flags
= IW_RETRY_LIFETIME
;
1038 } else if ((vwrq
->flags
& IW_RETRY_LONG
)) {
1039 /* we are asked for the long retry limit */
1041 mgt_get_request(priv
, DOT11_OID_LONGRETRIES
, 0, NULL
, &r
);
1043 vwrq
->flags
= IW_RETRY_LIMIT
| IW_RETRY_LONG
;
1045 /* default. get the short retry limit */
1047 mgt_get_request(priv
, DOT11_OID_SHORTRETRIES
, 0, NULL
, &r
);
1049 vwrq
->flags
= IW_RETRY_LIMIT
| IW_RETRY_SHORT
;
1056 prism54_set_encode(struct net_device
*ndev
, struct iw_request_info
*info
,
1057 struct iw_point
*dwrq
, char *extra
)
1059 islpci_private
*priv
= netdev_priv(ndev
);
1060 int rvalue
= 0, force
= 0;
1061 int authen
= DOT11_AUTH_OS
, invoke
= 0, exunencrypt
= 0;
1064 /* with the new API, it's impossible to get a NULL pointer.
1065 * New version of iwconfig set the IW_ENCODE_NOKEY flag
1066 * when no key is given, but older versions don't. */
1068 if (dwrq
->length
> 0) {
1069 /* we have a key to set */
1070 int index
= (dwrq
->flags
& IW_ENCODE_INDEX
) - 1;
1072 struct obj_key key
= { DOT11_PRIV_WEP
, 0, "" };
1074 /* get the current key index */
1075 rvalue
= mgt_get_request(priv
, DOT11_OID_DEFKEYID
, 0, NULL
, &r
);
1076 current_index
= r
.u
;
1077 /* Verify that the key is not marked as invalid */
1078 if (!(dwrq
->flags
& IW_ENCODE_NOKEY
)) {
1079 if (dwrq
->length
> KEY_SIZE_TKIP
) {
1080 /* User-provided key data too big */
1083 if (dwrq
->length
> KEY_SIZE_WEP104
) {
1085 key
.type
= DOT11_PRIV_TKIP
;
1086 key
.length
= KEY_SIZE_TKIP
;
1087 } else if (dwrq
->length
> KEY_SIZE_WEP40
) {
1089 key
.length
= KEY_SIZE_WEP104
;
1092 key
.length
= KEY_SIZE_WEP40
;
1094 memset(key
.key
, 0, sizeof (key
.key
));
1095 memcpy(key
.key
, extra
, dwrq
->length
);
1097 if ((index
< 0) || (index
> 3))
1098 /* no index provided use the current one */
1099 index
= current_index
;
1101 /* now send the key to the card */
1103 mgt_set_request(priv
, DOT11_OID_DEFKEYX
, index
,
1107 * If a valid key is set, encryption should be enabled
1108 * (user may turn it off later).
1109 * This is also how "iwconfig ethX key on" works
1111 if ((index
== current_index
) && (key
.length
> 0))
1114 int index
= (dwrq
->flags
& IW_ENCODE_INDEX
) - 1;
1115 if ((index
>= 0) && (index
<= 3)) {
1116 /* we want to set the key index */
1118 mgt_set_request(priv
, DOT11_OID_DEFKEYID
, 0,
1121 if (!dwrq
->flags
& IW_ENCODE_MODE
) {
1122 /* we cannot do anything. Complain. */
1127 /* now read the flags */
1128 if (dwrq
->flags
& IW_ENCODE_DISABLED
) {
1129 /* Encoding disabled,
1130 * authen = DOT11_AUTH_OS;
1132 * exunencrypt = 0; */
1134 if (dwrq
->flags
& IW_ENCODE_OPEN
)
1135 /* Encode but accept non-encoded packets. No auth */
1137 if ((dwrq
->flags
& IW_ENCODE_RESTRICTED
) || force
) {
1138 /* Refuse non-encoded packets. Auth */
1139 authen
= DOT11_AUTH_BOTH
;
1143 /* do the change if requested */
1144 if ((dwrq
->flags
& IW_ENCODE_MODE
) || force
) {
1146 mgt_set_request(priv
, DOT11_OID_AUTHENABLE
, 0, &authen
);
1148 mgt_set_request(priv
, DOT11_OID_PRIVACYINVOKED
, 0, &invoke
);
1150 mgt_set_request(priv
, DOT11_OID_EXUNENCRYPTED
, 0,
1157 prism54_get_encode(struct net_device
*ndev
, struct iw_request_info
*info
,
1158 struct iw_point
*dwrq
, char *extra
)
1160 islpci_private
*priv
= netdev_priv(ndev
);
1161 struct obj_key
*key
;
1162 u32 devindex
, index
= (dwrq
->flags
& IW_ENCODE_INDEX
) - 1;
1163 u32 authen
= 0, invoke
= 0, exunencrypt
= 0;
1167 /* first get the flags */
1168 rvalue
= mgt_get_request(priv
, DOT11_OID_AUTHENABLE
, 0, NULL
, &r
);
1170 rvalue
|= mgt_get_request(priv
, DOT11_OID_PRIVACYINVOKED
, 0, NULL
, &r
);
1172 rvalue
|= mgt_get_request(priv
, DOT11_OID_EXUNENCRYPTED
, 0, NULL
, &r
);
1175 if (invoke
&& (authen
== DOT11_AUTH_BOTH
) && exunencrypt
)
1176 dwrq
->flags
= IW_ENCODE_RESTRICTED
;
1177 else if ((authen
== DOT11_AUTH_OS
) && !exunencrypt
) {
1179 dwrq
->flags
= IW_ENCODE_OPEN
;
1181 dwrq
->flags
= IW_ENCODE_DISABLED
;
1183 /* The card should not work in this state */
1186 /* get the current device key index */
1187 rvalue
|= mgt_get_request(priv
, DOT11_OID_DEFKEYID
, 0, NULL
, &r
);
1189 /* Now get the key, return it */
1190 if ((index
< 0) || (index
> 3))
1191 /* no index provided, use the current one */
1193 rvalue
|= mgt_get_request(priv
, DOT11_OID_DEFKEYX
, index
, NULL
, &r
);
1195 dwrq
->length
= key
->length
;
1196 memcpy(extra
, key
->key
, dwrq
->length
);
1198 /* return the used key index */
1199 dwrq
->flags
|= devindex
+ 1;
1205 prism54_get_txpower(struct net_device
*ndev
, struct iw_request_info
*info
,
1206 struct iw_param
*vwrq
, char *extra
)
1208 islpci_private
*priv
= netdev_priv(ndev
);
1212 rvalue
= mgt_get_request(priv
, OID_INL_OUTPUTPOWER
, 0, NULL
, &r
);
1213 /* intersil firmware operates in 0.25 dBm (1/4 dBm) */
1214 vwrq
->value
= (s32
) r
.u
/ 4;
1216 /* radio is not turned of
1217 * btw: how is possible to turn off only the radio
1225 prism54_set_txpower(struct net_device
*ndev
, struct iw_request_info
*info
,
1226 struct iw_param
*vwrq
, char *extra
)
1228 islpci_private
*priv
= netdev_priv(ndev
);
1229 s32 u
= vwrq
->value
;
1231 /* intersil firmware operates in 0.25 dBm (1/4) */
1233 if (vwrq
->disabled
) {
1234 /* don't know how to disable radio */
1236 "%s: %s() disabling radio is not yet supported.\n",
1237 priv
->ndev
->name
, __FUNCTION__
);
1239 } else if (vwrq
->fixed
)
1240 /* currently only fixed value is supported */
1241 return mgt_set_request(priv
, OID_INL_OUTPUTPOWER
, 0, &u
);
1244 "%s: %s() auto power will be implemented later.\n",
1245 priv
->ndev
->name
, __FUNCTION__
);
1250 static int prism54_set_genie(struct net_device
*ndev
,
1251 struct iw_request_info
*info
,
1252 struct iw_point
*data
, char *extra
)
1254 islpci_private
*priv
= netdev_priv(ndev
);
1256 struct obj_attachment
*attach
;
1258 if (data
->length
> MAX_WPA_IE_LEN
||
1259 (data
->length
&& extra
== NULL
))
1262 memcpy(priv
->wpa_ie
, extra
, data
->length
);
1263 priv
->wpa_ie_len
= data
->length
;
1265 alen
= sizeof(*attach
) + priv
->wpa_ie_len
;
1266 attach
= kzalloc(alen
, GFP_KERNEL
);
1270 #define WLAN_FC_TYPE_MGMT 0
1271 #define WLAN_FC_STYPE_ASSOC_REQ 0
1272 #define WLAN_FC_STYPE_REASSOC_REQ 2
1274 /* Note: endianness is covered by mgt_set_varlen */
1275 attach
->type
= (WLAN_FC_TYPE_MGMT
<< 2) |
1276 (WLAN_FC_STYPE_ASSOC_REQ
<< 4);
1278 attach
->size
= priv
->wpa_ie_len
;
1279 memcpy(attach
->data
, extra
, priv
->wpa_ie_len
);
1281 ret
= mgt_set_varlen(priv
, DOT11_OID_ATTACHMENT
, attach
,
1284 attach
->type
= (WLAN_FC_TYPE_MGMT
<< 2) |
1285 (WLAN_FC_STYPE_REASSOC_REQ
<< 4);
1287 ret
= mgt_set_varlen(priv
, DOT11_OID_ATTACHMENT
, attach
,
1290 printk(KERN_DEBUG
"%s: WPA IE Attachment was set\n",
1299 static int prism54_get_genie(struct net_device
*ndev
,
1300 struct iw_request_info
*info
,
1301 struct iw_point
*data
, char *extra
)
1303 islpci_private
*priv
= netdev_priv(ndev
);
1304 int len
= priv
->wpa_ie_len
;
1311 if (data
->length
< len
)
1315 memcpy(extra
, priv
->wpa_ie
, len
);
1320 static int prism54_set_auth(struct net_device
*ndev
,
1321 struct iw_request_info
*info
,
1322 union iwreq_data
*wrqu
, char *extra
)
1324 islpci_private
*priv
= netdev_priv(ndev
);
1325 struct iw_param
*param
= &wrqu
->param
;
1326 u32 mlmelevel
= 0, authen
= 0, dot1x
= 0;
1327 u32 exunencrypt
= 0, privinvoked
= 0, wpa
= 0;
1332 if (islpci_get_state(priv
) < PRV_STATE_INIT
)
1335 /* first get the flags */
1336 down_write(&priv
->mib_sem
);
1337 wpa
= old_wpa
= priv
->wpa
;
1338 up_write(&priv
->mib_sem
);
1339 ret
= mgt_get_request(priv
, DOT11_OID_AUTHENABLE
, 0, NULL
, &r
);
1341 ret
= mgt_get_request(priv
, DOT11_OID_PRIVACYINVOKED
, 0, NULL
, &r
);
1343 ret
= mgt_get_request(priv
, DOT11_OID_EXUNENCRYPTED
, 0, NULL
, &r
);
1345 ret
= mgt_get_request(priv
, DOT11_OID_DOT1XENABLE
, 0, NULL
, &r
);
1347 ret
= mgt_get_request(priv
, DOT11_OID_MLMEAUTOLEVEL
, 0, NULL
, &r
);
1353 switch (param
->flags
& IW_AUTH_INDEX
) {
1354 case IW_AUTH_CIPHER_PAIRWISE
:
1355 case IW_AUTH_CIPHER_GROUP
:
1356 case IW_AUTH_KEY_MGMT
:
1359 case IW_AUTH_WPA_ENABLED
:
1360 /* Do the same thing as IW_AUTH_WPA_VERSION */
1363 privinvoked
= 1; /* For privacy invoked */
1364 exunencrypt
= 1; /* Filter out all unencrypted frames */
1365 dot1x
= 0x01; /* To enable eap filter */
1366 mlmelevel
= DOT11_MLME_EXTENDED
;
1367 authen
= DOT11_AUTH_OS
; /* Only WEP uses _SK and _BOTH */
1371 exunencrypt
= 0; /* Do not filter un-encrypted data */
1373 mlmelevel
= DOT11_MLME_AUTO
;
1377 case IW_AUTH_WPA_VERSION
:
1378 if (param
->value
& IW_AUTH_WPA_VERSION_DISABLED
) {
1381 exunencrypt
= 0; /* Do not filter un-encrypted data */
1383 mlmelevel
= DOT11_MLME_AUTO
;
1385 if (param
->value
& IW_AUTH_WPA_VERSION_WPA
)
1387 else if (param
->value
& IW_AUTH_WPA_VERSION_WPA2
)
1389 privinvoked
= 1; /* For privacy invoked */
1390 exunencrypt
= 1; /* Filter out all unencrypted frames */
1391 dot1x
= 0x01; /* To enable eap filter */
1392 mlmelevel
= DOT11_MLME_EXTENDED
;
1393 authen
= DOT11_AUTH_OS
; /* Only WEP uses _SK and _BOTH */
1397 case IW_AUTH_RX_UNENCRYPTED_EAPOL
:
1398 /* dot1x should be the opposite of RX_UNENCRYPTED_EAPOL;
1399 * turn off dot1x when allowing receipt of unencrypted EAPOL
1400 * frames, turn on dot1x when receipt should be disallowed
1402 dot1x
= param
->value
? 0 : 0x01;
1405 case IW_AUTH_PRIVACY_INVOKED
:
1406 privinvoked
= param
->value
? 1 : 0;
1409 case IW_AUTH_DROP_UNENCRYPTED
:
1410 exunencrypt
= param
->value
? 1 : 0;
1413 case IW_AUTH_80211_AUTH_ALG
:
1414 if (param
->value
& IW_AUTH_ALG_SHARED_KEY
) {
1415 /* Only WEP uses _SK and _BOTH */
1420 authen
= DOT11_AUTH_SK
;
1421 } else if (param
->value
& IW_AUTH_ALG_OPEN_SYSTEM
) {
1422 authen
= DOT11_AUTH_OS
;
1433 /* Set all the values */
1434 down_write(&priv
->mib_sem
);
1436 up_write(&priv
->mib_sem
);
1437 mgt_set_request(priv
, DOT11_OID_AUTHENABLE
, 0, &authen
);
1438 mgt_set_request(priv
, DOT11_OID_PRIVACYINVOKED
, 0, &privinvoked
);
1439 mgt_set_request(priv
, DOT11_OID_EXUNENCRYPTED
, 0, &exunencrypt
);
1440 mgt_set_request(priv
, DOT11_OID_DOT1XENABLE
, 0, &dot1x
);
1441 mgt_set_request(priv
, DOT11_OID_MLMEAUTOLEVEL
, 0, &mlmelevel
);
1447 static int prism54_get_auth(struct net_device
*ndev
,
1448 struct iw_request_info
*info
,
1449 union iwreq_data
*wrqu
, char *extra
)
1451 islpci_private
*priv
= netdev_priv(ndev
);
1452 struct iw_param
*param
= &wrqu
->param
;
1457 if (islpci_get_state(priv
) < PRV_STATE_INIT
)
1460 /* first get the flags */
1461 down_write(&priv
->mib_sem
);
1463 up_write(&priv
->mib_sem
);
1465 switch (param
->flags
& IW_AUTH_INDEX
) {
1466 case IW_AUTH_CIPHER_PAIRWISE
:
1467 case IW_AUTH_CIPHER_GROUP
:
1468 case IW_AUTH_KEY_MGMT
:
1470 * wpa_supplicant will control these internally
1475 case IW_AUTH_WPA_VERSION
:
1478 param
->value
= IW_AUTH_WPA_VERSION_WPA
;
1481 param
->value
= IW_AUTH_WPA_VERSION_WPA2
;
1485 param
->value
= IW_AUTH_WPA_VERSION_DISABLED
;
1490 case IW_AUTH_DROP_UNENCRYPTED
:
1491 ret
= mgt_get_request(priv
, DOT11_OID_EXUNENCRYPTED
, 0, NULL
, &r
);
1493 param
->value
= r
.u
> 0 ? 1 : 0;
1496 case IW_AUTH_80211_AUTH_ALG
:
1497 ret
= mgt_get_request(priv
, DOT11_OID_AUTHENABLE
, 0, NULL
, &r
);
1501 param
->value
= IW_AUTH_ALG_OPEN_SYSTEM
;
1503 case DOT11_AUTH_BOTH
:
1505 param
->value
= IW_AUTH_ALG_SHARED_KEY
;
1506 case DOT11_AUTH_NONE
:
1514 case IW_AUTH_WPA_ENABLED
:
1515 param
->value
= wpa
> 0 ? 1 : 0;
1518 case IW_AUTH_RX_UNENCRYPTED_EAPOL
:
1519 ret
= mgt_get_request(priv
, DOT11_OID_DOT1XENABLE
, 0, NULL
, &r
);
1521 param
->value
= r
.u
> 0 ? 1 : 0;
1524 case IW_AUTH_PRIVACY_INVOKED
:
1525 ret
= mgt_get_request(priv
, DOT11_OID_PRIVACYINVOKED
, 0, NULL
, &r
);
1527 param
->value
= r
.u
> 0 ? 1 : 0;
1536 static int prism54_set_encodeext(struct net_device
*ndev
,
1537 struct iw_request_info
*info
,
1538 union iwreq_data
*wrqu
,
1541 islpci_private
*priv
= netdev_priv(ndev
);
1542 struct iw_point
*encoding
= &wrqu
->encoding
;
1543 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*)extra
;
1544 int idx
, alg
= ext
->alg
, set_key
= 1;
1546 int authen
= DOT11_AUTH_OS
, invoke
= 0, exunencrypt
= 0;
1549 if (islpci_get_state(priv
) < PRV_STATE_INIT
)
1552 /* Determine and validate the key index */
1553 idx
= (encoding
->flags
& IW_ENCODE_INDEX
) - 1;
1555 if (idx
< 0 || idx
> 3)
1558 ret
= mgt_get_request(priv
, DOT11_OID_DEFKEYID
, 0, NULL
, &r
);
1564 if (encoding
->flags
& IW_ENCODE_DISABLED
)
1565 alg
= IW_ENCODE_ALG_NONE
;
1567 if (ext
->ext_flags
& IW_ENCODE_EXT_SET_TX_KEY
) {
1568 /* Only set transmit key index here, actual
1569 * key is set below if needed.
1571 ret
= mgt_set_request(priv
, DOT11_OID_DEFKEYID
, 0, &idx
);
1572 set_key
= ext
->key_len
> 0 ? 1 : 0;
1576 struct obj_key key
= { DOT11_PRIV_WEP
, 0, "" };
1578 case IW_ENCODE_ALG_NONE
:
1580 case IW_ENCODE_ALG_WEP
:
1581 if (ext
->key_len
> KEY_SIZE_WEP104
) {
1585 if (ext
->key_len
> KEY_SIZE_WEP40
)
1586 key
.length
= KEY_SIZE_WEP104
;
1588 key
.length
= KEY_SIZE_WEP40
;
1590 case IW_ENCODE_ALG_TKIP
:
1591 if (ext
->key_len
> KEY_SIZE_TKIP
) {
1595 key
.type
= DOT11_PRIV_TKIP
;
1596 key
.length
= KEY_SIZE_TKIP
;
1603 memset(key
.key
, 0, sizeof(key
.key
));
1604 memcpy(key
.key
, ext
->key
, ext
->key_len
);
1605 ret
= mgt_set_request(priv
, DOT11_OID_DEFKEYX
, idx
,
1612 /* Read the flags */
1613 if (encoding
->flags
& IW_ENCODE_DISABLED
) {
1614 /* Encoding disabled,
1615 * authen = DOT11_AUTH_OS;
1617 * exunencrypt = 0; */
1619 if (encoding
->flags
& IW_ENCODE_OPEN
) {
1620 /* Encode but accept non-encoded packets. No auth */
1623 if (encoding
->flags
& IW_ENCODE_RESTRICTED
) {
1624 /* Refuse non-encoded packets. Auth */
1625 authen
= DOT11_AUTH_BOTH
;
1630 /* do the change if requested */
1631 if (encoding
->flags
& IW_ENCODE_MODE
) {
1632 ret
= mgt_set_request(priv
, DOT11_OID_AUTHENABLE
, 0,
1634 ret
= mgt_set_request(priv
, DOT11_OID_PRIVACYINVOKED
, 0,
1636 ret
= mgt_set_request(priv
, DOT11_OID_EXUNENCRYPTED
, 0,
1645 static int prism54_get_encodeext(struct net_device
*ndev
,
1646 struct iw_request_info
*info
,
1647 union iwreq_data
*wrqu
,
1650 islpci_private
*priv
= netdev_priv(ndev
);
1651 struct iw_point
*encoding
= &wrqu
->encoding
;
1652 struct iw_encode_ext
*ext
= (struct iw_encode_ext
*)extra
;
1653 int idx
, max_key_len
;
1655 int authen
= DOT11_AUTH_OS
, invoke
= 0, exunencrypt
= 0, wpa
= 0;
1658 if (islpci_get_state(priv
) < PRV_STATE_INIT
)
1661 /* first get the flags */
1662 ret
= mgt_get_request(priv
, DOT11_OID_AUTHENABLE
, 0, NULL
, &r
);
1664 ret
= mgt_get_request(priv
, DOT11_OID_PRIVACYINVOKED
, 0, NULL
, &r
);
1666 ret
= mgt_get_request(priv
, DOT11_OID_EXUNENCRYPTED
, 0, NULL
, &r
);
1671 max_key_len
= encoding
->length
- sizeof(*ext
);
1672 if (max_key_len
< 0)
1675 idx
= (encoding
->flags
& IW_ENCODE_INDEX
) - 1;
1677 if (idx
< 0 || idx
> 3)
1680 ret
= mgt_get_request(priv
, DOT11_OID_DEFKEYID
, 0, NULL
, &r
);
1686 encoding
->flags
= idx
+ 1;
1687 memset(ext
, 0, sizeof(*ext
));
1690 case DOT11_AUTH_BOTH
:
1692 wrqu
->encoding
.flags
|= IW_ENCODE_RESTRICTED
;
1695 wrqu
->encoding
.flags
|= IW_ENCODE_OPEN
;
1699 down_write(&priv
->mib_sem
);
1701 up_write(&priv
->mib_sem
);
1703 if (authen
== DOT11_AUTH_OS
&& !exunencrypt
&& !invoke
&& !wpa
) {
1705 ext
->alg
= IW_ENCODE_ALG_NONE
;
1707 wrqu
->encoding
.flags
|= IW_ENCODE_DISABLED
;
1709 struct obj_key
*key
;
1711 ret
= mgt_get_request(priv
, DOT11_OID_DEFKEYX
, idx
, NULL
, &r
);
1715 if (max_key_len
< key
->length
) {
1719 memcpy(ext
->key
, key
->key
, key
->length
);
1720 ext
->key_len
= key
->length
;
1722 switch (key
->type
) {
1723 case DOT11_PRIV_TKIP
:
1724 ext
->alg
= IW_ENCODE_ALG_TKIP
;
1727 case DOT11_PRIV_WEP
:
1728 ext
->alg
= IW_ENCODE_ALG_WEP
;
1731 wrqu
->encoding
.flags
|= IW_ENCODE_ENABLED
;
1740 prism54_reset(struct net_device
*ndev
, struct iw_request_info
*info
,
1741 __u32
* uwrq
, char *extra
)
1743 islpci_reset(netdev_priv(ndev
), 0);
1749 prism54_get_oid(struct net_device
*ndev
, struct iw_request_info
*info
,
1750 struct iw_point
*dwrq
, char *extra
)
1754 enum oid_num_t n
= dwrq
->flags
;
1756 rvalue
= mgt_get_request(netdev_priv(ndev
), n
, 0, NULL
, &r
);
1757 dwrq
->length
= mgt_response_to_str(n
, &r
, extra
);
1758 if ((isl_oid
[n
].flags
& OID_FLAG_TYPE
) != OID_TYPE_U32
)
1764 prism54_set_u32(struct net_device
*ndev
, struct iw_request_info
*info
,
1765 __u32
* uwrq
, char *extra
)
1767 u32 oid
= uwrq
[0], u
= uwrq
[1];
1769 return mgt_set_request(netdev_priv(ndev
), oid
, 0, &u
);
1773 prism54_set_raw(struct net_device
*ndev
, struct iw_request_info
*info
,
1774 struct iw_point
*dwrq
, char *extra
)
1776 u32 oid
= dwrq
->flags
;
1778 return mgt_set_request(netdev_priv(ndev
), oid
, 0, extra
);
1782 prism54_acl_init(struct islpci_acl
*acl
)
1784 sema_init(&acl
->sem
, 1);
1785 INIT_LIST_HEAD(&acl
->mac_list
);
1787 acl
->policy
= MAC_POLICY_OPEN
;
1791 prism54_clear_mac(struct islpci_acl
*acl
)
1793 struct list_head
*ptr
, *next
;
1794 struct mac_entry
*entry
;
1796 if (down_interruptible(&acl
->sem
))
1799 if (acl
->size
== 0) {
1804 for (ptr
= acl
->mac_list
.next
, next
= ptr
->next
;
1805 ptr
!= &acl
->mac_list
; ptr
= next
, next
= ptr
->next
) {
1806 entry
= list_entry(ptr
, struct mac_entry
, _list
);
1815 prism54_acl_clean(struct islpci_acl
*acl
)
1817 prism54_clear_mac(acl
);
1821 prism54_add_mac(struct net_device
*ndev
, struct iw_request_info
*info
,
1822 struct sockaddr
*awrq
, char *extra
)
1824 islpci_private
*priv
= netdev_priv(ndev
);
1825 struct islpci_acl
*acl
= &priv
->acl
;
1826 struct mac_entry
*entry
;
1827 struct sockaddr
*addr
= (struct sockaddr
*) extra
;
1829 if (addr
->sa_family
!= ARPHRD_ETHER
)
1832 entry
= kmalloc(sizeof (struct mac_entry
), GFP_KERNEL
);
1836 memcpy(entry
->addr
, addr
->sa_data
, ETH_ALEN
);
1838 if (down_interruptible(&acl
->sem
)) {
1840 return -ERESTARTSYS
;
1842 list_add_tail(&entry
->_list
, &acl
->mac_list
);
1850 prism54_del_mac(struct net_device
*ndev
, struct iw_request_info
*info
,
1851 struct sockaddr
*awrq
, char *extra
)
1853 islpci_private
*priv
= netdev_priv(ndev
);
1854 struct islpci_acl
*acl
= &priv
->acl
;
1855 struct mac_entry
*entry
;
1856 struct sockaddr
*addr
= (struct sockaddr
*) extra
;
1858 if (addr
->sa_family
!= ARPHRD_ETHER
)
1861 if (down_interruptible(&acl
->sem
))
1862 return -ERESTARTSYS
;
1863 list_for_each_entry(entry
, &acl
->mac_list
, _list
) {
1864 if (memcmp(entry
->addr
, addr
->sa_data
, ETH_ALEN
) == 0) {
1865 list_del(&entry
->_list
);
1877 prism54_get_mac(struct net_device
*ndev
, struct iw_request_info
*info
,
1878 struct iw_point
*dwrq
, char *extra
)
1880 islpci_private
*priv
= netdev_priv(ndev
);
1881 struct islpci_acl
*acl
= &priv
->acl
;
1882 struct mac_entry
*entry
;
1883 struct sockaddr
*dst
= (struct sockaddr
*) extra
;
1887 if (down_interruptible(&acl
->sem
))
1888 return -ERESTARTSYS
;
1890 list_for_each_entry(entry
, &acl
->mac_list
, _list
) {
1891 memcpy(dst
->sa_data
, entry
->addr
, ETH_ALEN
);
1892 dst
->sa_family
= ARPHRD_ETHER
;
1900 /* Setting policy also clears the MAC acl, even if we don't change the defaut
1905 prism54_set_policy(struct net_device
*ndev
, struct iw_request_info
*info
,
1906 __u32
* uwrq
, char *extra
)
1908 islpci_private
*priv
= netdev_priv(ndev
);
1909 struct islpci_acl
*acl
= &priv
->acl
;
1912 prism54_clear_mac(acl
);
1914 if ((*uwrq
< MAC_POLICY_OPEN
) || (*uwrq
> MAC_POLICY_REJECT
))
1917 down_write(&priv
->mib_sem
);
1919 acl
->policy
= *uwrq
;
1921 /* the ACL code needs an intermediate mlmeautolevel */
1922 if ((priv
->iw_mode
== IW_MODE_MASTER
) &&
1923 (acl
->policy
!= MAC_POLICY_OPEN
))
1924 mlmeautolevel
= DOT11_MLME_INTERMEDIATE
;
1926 mlmeautolevel
= CARD_DEFAULT_MLME_MODE
;
1928 mlmeautolevel
= DOT11_MLME_EXTENDED
;
1929 mgt_set(priv
, DOT11_OID_MLMEAUTOLEVEL
, &mlmeautolevel
);
1930 /* restart the card with our new policy */
1931 if (mgt_commit(priv
)) {
1932 up_write(&priv
->mib_sem
);
1935 up_write(&priv
->mib_sem
);
1941 prism54_get_policy(struct net_device
*ndev
, struct iw_request_info
*info
,
1942 __u32
* uwrq
, char *extra
)
1944 islpci_private
*priv
= netdev_priv(ndev
);
1945 struct islpci_acl
*acl
= &priv
->acl
;
1947 *uwrq
= acl
->policy
;
1952 /* Return 1 only if client should be accepted. */
1955 prism54_mac_accept(struct islpci_acl
*acl
, char *mac
)
1957 struct mac_entry
*entry
;
1960 if (down_interruptible(&acl
->sem
))
1961 return -ERESTARTSYS
;
1963 if (acl
->policy
== MAC_POLICY_OPEN
) {
1968 list_for_each_entry(entry
, &acl
->mac_list
, _list
) {
1969 if (memcmp(entry
->addr
, mac
, ETH_ALEN
) == 0) {
1974 res
= (acl
->policy
== MAC_POLICY_ACCEPT
) ? !res
: res
;
1981 prism54_kick_all(struct net_device
*ndev
, struct iw_request_info
*info
,
1982 struct iw_point
*dwrq
, char *extra
)
1984 struct obj_mlme
*mlme
;
1987 mlme
= kmalloc(sizeof (struct obj_mlme
), GFP_KERNEL
);
1991 /* Tell the card to kick every client */
1994 mgt_set_request(netdev_priv(ndev
), DOT11_OID_DISASSOCIATE
, 0, mlme
);
2001 prism54_kick_mac(struct net_device
*ndev
, struct iw_request_info
*info
,
2002 struct sockaddr
*awrq
, char *extra
)
2004 struct obj_mlme
*mlme
;
2005 struct sockaddr
*addr
= (struct sockaddr
*) extra
;
2008 if (addr
->sa_family
!= ARPHRD_ETHER
)
2011 mlme
= kmalloc(sizeof (struct obj_mlme
), GFP_KERNEL
);
2015 /* Tell the card to only kick the corresponding bastard */
2016 memcpy(mlme
->address
, addr
->sa_data
, ETH_ALEN
);
2019 mgt_set_request(netdev_priv(ndev
), DOT11_OID_DISASSOCIATE
, 0, mlme
);
2026 /* Translate a TRAP oid into a wireless event. Called in islpci_mgt_receive. */
2029 format_event(islpci_private
*priv
, char *dest
, const char *str
,
2030 const struct obj_mlme
*mlme
, u16
*length
, int error
)
2032 const u8
*a
= mlme
->address
;
2033 int n
= snprintf(dest
, IW_CUSTOM_MAX
,
2034 "%s %s %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X %s (%2.2X)",
2036 ((priv
->iw_mode
== IW_MODE_MASTER
) ? "from" : "to"),
2037 a
[0], a
[1], a
[2], a
[3], a
[4], a
[5],
2038 (error
? (mlme
->code
? " : REJECTED " : " : ACCEPTED ")
2040 BUG_ON(n
> IW_CUSTOM_MAX
);
2045 send_formatted_event(islpci_private
*priv
, const char *str
,
2046 const struct obj_mlme
*mlme
, int error
)
2048 union iwreq_data wrqu
;
2051 memptr
= kmalloc(IW_CUSTOM_MAX
, GFP_KERNEL
);
2054 wrqu
.data
.pointer
= memptr
;
2055 wrqu
.data
.length
= 0;
2056 format_event(priv
, memptr
, str
, mlme
, &wrqu
.data
.length
,
2058 wireless_send_event(priv
->ndev
, IWEVCUSTOM
, &wrqu
, memptr
);
2063 send_simple_event(islpci_private
*priv
, const char *str
)
2065 union iwreq_data wrqu
;
2067 int n
= strlen(str
);
2069 memptr
= kmalloc(IW_CUSTOM_MAX
, GFP_KERNEL
);
2072 BUG_ON(n
> IW_CUSTOM_MAX
);
2073 wrqu
.data
.pointer
= memptr
;
2074 wrqu
.data
.length
= n
;
2075 strcpy(memptr
, str
);
2076 wireless_send_event(priv
->ndev
, IWEVCUSTOM
, &wrqu
, memptr
);
2081 link_changed(struct net_device
*ndev
, u32 bitrate
)
2083 islpci_private
*priv
= netdev_priv(ndev
);
2086 if (priv
->iw_mode
== IW_MODE_INFRA
) {
2087 union iwreq_data uwrq
;
2088 prism54_get_wap(ndev
, NULL
, (struct sockaddr
*) &uwrq
,
2090 wireless_send_event(ndev
, SIOCGIWAP
, &uwrq
, NULL
);
2092 send_simple_event(netdev_priv(ndev
),
2093 "Link established");
2095 send_simple_event(netdev_priv(ndev
), "Link lost");
2098 /* Beacon/ProbeResp payload header */
2099 struct ieee80211_beacon_phdr
{
2103 } __attribute__ ((packed
));
2105 #define WLAN_EID_GENERIC 0xdd
2106 static u8 wpa_oid
[4] = { 0x00, 0x50, 0xf2, 1 };
2108 #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
2109 #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
2112 prism54_wpa_bss_ie_add(islpci_private
*priv
, u8
*bssid
,
2113 u8
*wpa_ie
, size_t wpa_ie_len
)
2115 struct list_head
*ptr
;
2116 struct islpci_bss_wpa_ie
*bss
= NULL
;
2118 if (wpa_ie_len
> MAX_WPA_IE_LEN
)
2119 wpa_ie_len
= MAX_WPA_IE_LEN
;
2121 if (down_interruptible(&priv
->wpa_sem
))
2124 /* try to use existing entry */
2125 list_for_each(ptr
, &priv
->bss_wpa_list
) {
2126 bss
= list_entry(ptr
, struct islpci_bss_wpa_ie
, list
);
2127 if (memcmp(bss
->bssid
, bssid
, ETH_ALEN
) == 0) {
2128 list_move(&bss
->list
, &priv
->bss_wpa_list
);
2135 /* add a new BSS entry; if max number of entries is already
2136 * reached, replace the least recently updated */
2137 if (priv
->num_bss_wpa
>= MAX_BSS_WPA_IE_COUNT
) {
2138 bss
= list_entry(priv
->bss_wpa_list
.prev
,
2139 struct islpci_bss_wpa_ie
, list
);
2140 list_del(&bss
->list
);
2142 bss
= kzalloc(sizeof (*bss
), GFP_ATOMIC
);
2144 priv
->num_bss_wpa
++;
2147 memcpy(bss
->bssid
, bssid
, ETH_ALEN
);
2148 list_add(&bss
->list
, &priv
->bss_wpa_list
);
2153 memcpy(bss
->wpa_ie
, wpa_ie
, wpa_ie_len
);
2154 bss
->wpa_ie_len
= wpa_ie_len
;
2155 bss
->last_update
= jiffies
;
2157 printk(KERN_DEBUG
"Failed to add BSS WPA entry for " MACSTR
2158 "\n", MAC2STR(bssid
));
2161 /* expire old entries from WPA list */
2162 while (priv
->num_bss_wpa
> 0) {
2163 bss
= list_entry(priv
->bss_wpa_list
.prev
,
2164 struct islpci_bss_wpa_ie
, list
);
2165 if (!time_after(jiffies
, bss
->last_update
+ 60 * HZ
))
2168 list_del(&bss
->list
);
2169 priv
->num_bss_wpa
--;
2177 prism54_wpa_bss_ie_get(islpci_private
*priv
, u8
*bssid
, u8
*wpa_ie
)
2179 struct list_head
*ptr
;
2180 struct islpci_bss_wpa_ie
*bss
= NULL
;
2183 if (down_interruptible(&priv
->wpa_sem
))
2186 list_for_each(ptr
, &priv
->bss_wpa_list
) {
2187 bss
= list_entry(ptr
, struct islpci_bss_wpa_ie
, list
);
2188 if (memcmp(bss
->bssid
, bssid
, ETH_ALEN
) == 0)
2193 len
= bss
->wpa_ie_len
;
2194 memcpy(wpa_ie
, bss
->wpa_ie
, len
);
2202 prism54_wpa_bss_ie_init(islpci_private
*priv
)
2204 INIT_LIST_HEAD(&priv
->bss_wpa_list
);
2205 sema_init(&priv
->wpa_sem
, 1);
2209 prism54_wpa_bss_ie_clean(islpci_private
*priv
)
2211 struct islpci_bss_wpa_ie
*bss
, *n
;
2213 list_for_each_entry_safe(bss
, n
, &priv
->bss_wpa_list
, list
) {
2219 prism54_process_bss_data(islpci_private
*priv
, u32 oid
, u8
*addr
,
2220 u8
*payload
, size_t len
)
2222 struct ieee80211_beacon_phdr
*hdr
;
2228 hdr
= (struct ieee80211_beacon_phdr
*) payload
;
2229 pos
= (u8
*) (hdr
+ 1);
2230 end
= payload
+ len
;
2232 if (pos
+ 2 + pos
[1] > end
) {
2233 printk(KERN_DEBUG
"Parsing Beacon/ProbeResp failed "
2234 "for " MACSTR
"\n", MAC2STR(addr
));
2237 if (pos
[0] == WLAN_EID_GENERIC
&& pos
[1] >= 4 &&
2238 memcmp(pos
+ 2, wpa_oid
, 4) == 0) {
2239 prism54_wpa_bss_ie_add(priv
, addr
, pos
, pos
[1] + 2);
2247 handle_request(islpci_private
*priv
, struct obj_mlme
*mlme
, enum oid_num_t oid
)
2249 if (((mlme
->state
== DOT11_STATE_AUTHING
) ||
2250 (mlme
->state
== DOT11_STATE_ASSOCING
))
2251 && mgt_mlme_answer(priv
)) {
2252 /* Someone is requesting auth and we must respond. Just send back
2253 * the trap with error code set accordingly.
2255 mlme
->code
= prism54_mac_accept(&priv
->acl
,
2256 mlme
->address
) ? 0 : 1;
2257 mgt_set_request(priv
, oid
, 0, mlme
);
2262 prism54_process_trap_helper(islpci_private
*priv
, enum oid_num_t oid
,
2265 struct obj_mlme
*mlme
= (struct obj_mlme
*) data
;
2266 struct obj_mlmeex
*mlmeex
= (struct obj_mlmeex
*) data
;
2267 struct obj_mlmeex
*confirm
;
2268 u8 wpa_ie
[MAX_WPA_IE_LEN
];
2270 size_t len
= 0; /* u16, better? */
2271 u8
*payload
= NULL
, *pos
= NULL
;
2274 /* I think all trapable objects are listed here.
2275 * Some oids have a EX version. The difference is that they are emitted
2276 * in DOT11_MLME_EXTENDED mode (set with DOT11_OID_MLMEAUTOLEVEL)
2278 * The few events already defined by the wireless tools are not really
2279 * suited. We use the more flexible custom event facility.
2282 if (oid
>= DOT11_OID_BEACON
) {
2284 payload
= pos
= mlmeex
->data
;
2287 /* I fear prism54_process_bss_data won't work with big endian data */
2288 if ((oid
== DOT11_OID_BEACON
) || (oid
== DOT11_OID_PROBE
))
2289 prism54_process_bss_data(priv
, oid
, mlmeex
->address
,
2292 mgt_le_to_cpu(isl_oid
[oid
].flags
& OID_FLAG_TYPE
, (void *) mlme
);
2296 case GEN_OID_LINKSTATE
:
2297 link_changed(priv
->ndev
, (u32
) *data
);
2300 case DOT11_OID_MICFAILURE
:
2301 send_simple_event(priv
, "Mic failure");
2304 case DOT11_OID_DEAUTHENTICATE
:
2305 send_formatted_event(priv
, "DeAuthenticate request", mlme
, 0);
2308 case DOT11_OID_AUTHENTICATE
:
2309 handle_request(priv
, mlme
, oid
);
2310 send_formatted_event(priv
, "Authenticate request", mlme
, 1);
2313 case DOT11_OID_DISASSOCIATE
:
2314 send_formatted_event(priv
, "Disassociate request", mlme
, 0);
2317 case DOT11_OID_ASSOCIATE
:
2318 handle_request(priv
, mlme
, oid
);
2319 send_formatted_event(priv
, "Associate request", mlme
, 1);
2322 case DOT11_OID_REASSOCIATE
:
2323 handle_request(priv
, mlme
, oid
);
2324 send_formatted_event(priv
, "ReAssociate request", mlme
, 1);
2327 case DOT11_OID_BEACON
:
2328 send_formatted_event(priv
,
2329 "Received a beacon from an unkown AP",
2333 case DOT11_OID_PROBE
:
2334 /* we received a probe from a client. */
2335 send_formatted_event(priv
, "Received a probe from client", mlme
,
2339 /* Note : "mlme" is actually a "struct obj_mlmeex *" here, but this
2340 * is backward compatible layout-wise with "struct obj_mlme".
2343 case DOT11_OID_DEAUTHENTICATEEX
:
2344 send_formatted_event(priv
, "DeAuthenticate request", mlme
, 0);
2347 case DOT11_OID_AUTHENTICATEEX
:
2348 handle_request(priv
, mlme
, oid
);
2349 send_formatted_event(priv
, "Authenticate request (ex)", mlme
, 1);
2351 if (priv
->iw_mode
!= IW_MODE_MASTER
2352 && mlmeex
->state
!= DOT11_STATE_AUTHING
)
2355 confirm
= kmalloc(sizeof(struct obj_mlmeex
) + 6, GFP_ATOMIC
);
2360 memcpy(&confirm
->address
, mlmeex
->address
, ETH_ALEN
);
2361 printk(KERN_DEBUG
"Authenticate from: address:\t%02x:%02x:%02x:%02x:%02x:%02x\n",
2369 confirm
->id
= -1; /* or mlmeex->id ? */
2370 confirm
->state
= 0; /* not used */
2373 confirm
->data
[0] = 0x00;
2374 confirm
->data
[1] = 0x00;
2375 confirm
->data
[2] = 0x02;
2376 confirm
->data
[3] = 0x00;
2377 confirm
->data
[4] = 0x00;
2378 confirm
->data
[5] = 0x00;
2380 ret
= mgt_set_varlen(priv
, DOT11_OID_ASSOCIATEEX
, confirm
, 6);
2387 case DOT11_OID_DISASSOCIATEEX
:
2388 send_formatted_event(priv
, "Disassociate request (ex)", mlme
, 0);
2391 case DOT11_OID_ASSOCIATEEX
:
2392 handle_request(priv
, mlme
, oid
);
2393 send_formatted_event(priv
, "Associate request (ex)", mlme
, 1);
2395 if (priv
->iw_mode
!= IW_MODE_MASTER
2396 && mlmeex
->state
!= DOT11_STATE_ASSOCING
)
2399 confirm
= kmalloc(sizeof(struct obj_mlmeex
), GFP_ATOMIC
);
2404 memcpy(&confirm
->address
, mlmeex
->address
, ETH_ALEN
);
2406 confirm
->id
= ((struct obj_mlmeex
*)mlme
)->id
;
2407 confirm
->state
= 0; /* not used */
2410 wpa_ie_len
= prism54_wpa_bss_ie_get(priv
, mlmeex
->address
, wpa_ie
);
2413 printk(KERN_DEBUG
"No WPA IE found from "
2414 "address:\t%02x:%02x:%02x:%02x:%02x:%02x\n",
2426 confirm
->size
= wpa_ie_len
;
2427 memcpy(&confirm
->data
, wpa_ie
, wpa_ie_len
);
2429 mgt_set_varlen(priv
, oid
, confirm
, wpa_ie_len
);
2435 case DOT11_OID_REASSOCIATEEX
:
2436 handle_request(priv
, mlme
, oid
);
2437 send_formatted_event(priv
, "Reassociate request (ex)", mlme
, 1);
2439 if (priv
->iw_mode
!= IW_MODE_MASTER
2440 && mlmeex
->state
!= DOT11_STATE_ASSOCING
)
2443 confirm
= kmalloc(sizeof(struct obj_mlmeex
), GFP_ATOMIC
);
2448 memcpy(&confirm
->address
, mlmeex
->address
, ETH_ALEN
);
2450 confirm
->id
= mlmeex
->id
;
2451 confirm
->state
= 0; /* not used */
2454 wpa_ie_len
= prism54_wpa_bss_ie_get(priv
, mlmeex
->address
, wpa_ie
);
2457 printk(KERN_DEBUG
"No WPA IE found from "
2458 "address:\t%02x:%02x:%02x:%02x:%02x:%02x\n",
2470 confirm
->size
= wpa_ie_len
;
2471 memcpy(&confirm
->data
, wpa_ie
, wpa_ie_len
);
2473 mgt_set_varlen(priv
, oid
, confirm
, wpa_ie_len
);
2487 * Process a device trap. This is called via schedule_work(), outside of
2488 * interrupt context, no locks held.
2491 prism54_process_trap(struct work_struct
*work
)
2493 struct islpci_mgmtframe
*frame
=
2494 container_of(work
, struct islpci_mgmtframe
, ws
);
2495 struct net_device
*ndev
= frame
->ndev
;
2496 enum oid_num_t n
= mgt_oidtonum(frame
->header
->oid
);
2498 if (n
!= OID_NUM_LAST
)
2499 prism54_process_trap_helper(netdev_priv(ndev
), n
, frame
->data
);
2500 islpci_mgt_release(frame
);
2504 prism54_set_mac_address(struct net_device
*ndev
, void *addr
)
2506 islpci_private
*priv
= netdev_priv(ndev
);
2509 if (ndev
->addr_len
!= 6)
2511 ret
= mgt_set_request(priv
, GEN_OID_MACADDRESS
, 0,
2512 &((struct sockaddr
*) addr
)->sa_data
);
2514 memcpy(priv
->ndev
->dev_addr
,
2515 &((struct sockaddr
*) addr
)->sa_data
, 6);
2520 /* Note: currently, use hostapd ioctl from the Host AP driver for WPA
2521 * support. This is to be replaced with Linux wireless extensions once they
2522 * get WPA support. */
2524 /* Note II: please leave all this together as it will be easier to remove later,
2525 * once wireless extensions add WPA support -mcgrof */
2527 /* PRISM54_HOSTAPD ioctl() cmd: */
2529 PRISM2_SET_ENCRYPTION
= 6,
2530 PRISM2_HOSTAPD_SET_GENERIC_ELEMENT
= 12,
2531 PRISM2_HOSTAPD_MLME
= 13,
2532 PRISM2_HOSTAPD_SCAN_REQ
= 14,
2535 #define PRISM54_SET_WPA SIOCIWFIRSTPRIV+12
2536 #define PRISM54_HOSTAPD SIOCIWFIRSTPRIV+25
2537 #define PRISM54_DROP_UNENCRYPTED SIOCIWFIRSTPRIV+26
2539 #define PRISM2_HOSTAPD_MAX_BUF_SIZE 1024
2540 #define PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN \
2541 ((int) (&((struct prism2_hostapd_param *) 0)->u.generic_elem.data))
2543 /* Maximum length for algorithm names (-1 for nul termination)
2544 * used in ioctl() */
2545 #define HOSTAP_CRYPT_ALG_NAME_LEN 16
2547 struct prism2_hostapd_param
{
2549 u8 sta_addr
[ETH_ALEN
];
2552 u8 alg
[HOSTAP_CRYPT_ALG_NAME_LEN
];
2556 u8 seq
[8]; /* sequence counter (set: RX, get: TX) */
2565 #define MLME_STA_DEAUTH 0
2566 #define MLME_STA_DISASSOC 1
2579 prism2_ioctl_set_encryption(struct net_device
*dev
,
2580 struct prism2_hostapd_param
*param
,
2583 islpci_private
*priv
= netdev_priv(dev
);
2584 int rvalue
= 0, force
= 0;
2585 int authen
= DOT11_AUTH_OS
, invoke
= 0, exunencrypt
= 0;
2588 /* with the new API, it's impossible to get a NULL pointer.
2589 * New version of iwconfig set the IW_ENCODE_NOKEY flag
2590 * when no key is given, but older versions don't. */
2592 if (param
->u
.crypt
.key_len
> 0) {
2593 /* we have a key to set */
2594 int index
= param
->u
.crypt
.idx
;
2596 struct obj_key key
= { DOT11_PRIV_TKIP
, 0, "" };
2598 /* get the current key index */
2599 rvalue
= mgt_get_request(priv
, DOT11_OID_DEFKEYID
, 0, NULL
, &r
);
2600 current_index
= r
.u
;
2601 /* Verify that the key is not marked as invalid */
2602 if (!(param
->u
.crypt
.flags
& IW_ENCODE_NOKEY
)) {
2603 key
.length
= param
->u
.crypt
.key_len
> sizeof (param
->u
.crypt
.key
) ?
2604 sizeof (param
->u
.crypt
.key
) : param
->u
.crypt
.key_len
;
2605 memcpy(key
.key
, param
->u
.crypt
.key
, key
.length
);
2606 if (key
.length
== 32)
2607 /* we want WPA-PSK */
2608 key
.type
= DOT11_PRIV_TKIP
;
2609 if ((index
< 0) || (index
> 3))
2610 /* no index provided use the current one */
2611 index
= current_index
;
2613 /* now send the key to the card */
2615 mgt_set_request(priv
, DOT11_OID_DEFKEYX
, index
,
2619 * If a valid key is set, encryption should be enabled
2620 * (user may turn it off later).
2621 * This is also how "iwconfig ethX key on" works
2623 if ((index
== current_index
) && (key
.length
> 0))
2626 int index
= (param
->u
.crypt
.flags
& IW_ENCODE_INDEX
) - 1;
2627 if ((index
>= 0) && (index
<= 3)) {
2628 /* we want to set the key index */
2630 mgt_set_request(priv
, DOT11_OID_DEFKEYID
, 0,
2633 if (!param
->u
.crypt
.flags
& IW_ENCODE_MODE
) {
2634 /* we cannot do anything. Complain. */
2639 /* now read the flags */
2640 if (param
->u
.crypt
.flags
& IW_ENCODE_DISABLED
) {
2641 /* Encoding disabled,
2642 * authen = DOT11_AUTH_OS;
2644 * exunencrypt = 0; */
2646 if (param
->u
.crypt
.flags
& IW_ENCODE_OPEN
)
2647 /* Encode but accept non-encoded packets. No auth */
2649 if ((param
->u
.crypt
.flags
& IW_ENCODE_RESTRICTED
) || force
) {
2650 /* Refuse non-encoded packets. Auth */
2651 authen
= DOT11_AUTH_BOTH
;
2655 /* do the change if requested */
2656 if ((param
->u
.crypt
.flags
& IW_ENCODE_MODE
) || force
) {
2658 mgt_set_request(priv
, DOT11_OID_AUTHENABLE
, 0, &authen
);
2660 mgt_set_request(priv
, DOT11_OID_PRIVACYINVOKED
, 0, &invoke
);
2662 mgt_set_request(priv
, DOT11_OID_EXUNENCRYPTED
, 0,
2669 prism2_ioctl_set_generic_element(struct net_device
*ndev
,
2670 struct prism2_hostapd_param
*param
,
2673 islpci_private
*priv
= netdev_priv(ndev
);
2674 int max_len
, len
, alen
, ret
=0;
2675 struct obj_attachment
*attach
;
2677 len
= param
->u
.generic_elem
.len
;
2678 max_len
= param_len
- PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN
;
2679 if (max_len
< 0 || max_len
< len
)
2682 alen
= sizeof(*attach
) + len
;
2683 attach
= kzalloc(alen
, GFP_KERNEL
);
2687 #define WLAN_FC_TYPE_MGMT 0
2688 #define WLAN_FC_STYPE_ASSOC_REQ 0
2689 #define WLAN_FC_STYPE_REASSOC_REQ 2
2691 /* Note: endianness is covered by mgt_set_varlen */
2693 attach
->type
= (WLAN_FC_TYPE_MGMT
<< 2) |
2694 (WLAN_FC_STYPE_ASSOC_REQ
<< 4);
2697 memcpy(attach
->data
, param
->u
.generic_elem
.data
, len
);
2699 ret
= mgt_set_varlen(priv
, DOT11_OID_ATTACHMENT
, attach
, len
);
2702 attach
->type
= (WLAN_FC_TYPE_MGMT
<< 2) |
2703 (WLAN_FC_STYPE_REASSOC_REQ
<< 4);
2705 ret
= mgt_set_varlen(priv
, DOT11_OID_ATTACHMENT
, attach
, len
);
2708 printk(KERN_DEBUG
"%s: WPA IE Attachment was set\n",
2718 prism2_ioctl_mlme(struct net_device
*dev
, struct prism2_hostapd_param
*param
)
2724 prism2_ioctl_scan_req(struct net_device
*ndev
,
2725 struct prism2_hostapd_param
*param
)
2727 islpci_private
*priv
= netdev_priv(ndev
);
2729 struct obj_bsslist
*bsslist
;
2732 char *current_ev
= "foo";
2735 if (islpci_get_state(priv
) < PRV_STATE_INIT
) {
2736 /* device is not ready, fail gently */
2740 /* first get the noise value. We will use it to report the link quality */
2741 rvalue
= mgt_get_request(priv
, DOT11_OID_NOISEFLOOR
, 0, NULL
, &r
);
2744 /* Ask the device for a list of known bss. We can report at most
2745 * IW_MAX_AP=64 to the range struct. But the device won't repport anything
2746 * if you change the value of IWMAX_BSS=24.
2748 rvalue
|= mgt_get_request(priv
, DOT11_OID_BSSLIST
, 0, NULL
, &r
);
2751 /* ok now, scan the list and translate its info */
2752 for (i
= 0; i
< min(IW_MAX_AP
, (int) bsslist
->nr
); i
++)
2753 current_ev
= prism54_translate_bss(ndev
, current_ev
,
2754 extra
+ IW_SCAN_MAX_DATA
,
2755 &(bsslist
->bsslist
[i
]),
2763 prism54_hostapd(struct net_device
*ndev
, struct iw_point
*p
)
2765 struct prism2_hostapd_param
*param
;
2769 printk(KERN_DEBUG
"prism54_hostapd - len=%d\n", p
->length
);
2770 if (p
->length
< sizeof(struct prism2_hostapd_param
) ||
2771 p
->length
> PRISM2_HOSTAPD_MAX_BUF_SIZE
|| !p
->pointer
)
2774 param
= kmalloc(p
->length
, GFP_KERNEL
);
2778 if (copy_from_user(param
, p
->pointer
, p
->length
)) {
2783 switch (param
->cmd
) {
2784 case PRISM2_SET_ENCRYPTION
:
2785 printk(KERN_DEBUG
"%s: Caught WPA supplicant set encryption request\n",
2787 ret
= prism2_ioctl_set_encryption(ndev
, param
, p
->length
);
2789 case PRISM2_HOSTAPD_SET_GENERIC_ELEMENT
:
2790 printk(KERN_DEBUG
"%s: Caught WPA supplicant set WPA IE request\n",
2792 ret
= prism2_ioctl_set_generic_element(ndev
, param
,
2795 case PRISM2_HOSTAPD_MLME
:
2796 printk(KERN_DEBUG
"%s: Caught WPA supplicant MLME request\n",
2798 ret
= prism2_ioctl_mlme(ndev
, param
);
2800 case PRISM2_HOSTAPD_SCAN_REQ
:
2801 printk(KERN_DEBUG
"%s: Caught WPA supplicant scan request\n",
2803 ret
= prism2_ioctl_scan_req(ndev
, param
);
2805 case PRISM54_SET_WPA
:
2806 printk(KERN_DEBUG
"%s: Caught WPA supplicant wpa init request\n",
2809 ret
= prism54_set_wpa(ndev
, NULL
, &uwrq
, NULL
);
2811 case PRISM54_DROP_UNENCRYPTED
:
2812 printk(KERN_DEBUG
"%s: Caught WPA drop unencrypted request\n",
2816 mgt_set(priv
, DOT11_OID_EXUNENCRYPTED
, &uwrq
);
2817 down_write(&priv
->mib_sem
);
2819 up_write(&priv
->mib_sem
);
2821 /* Not necessary, as set_wpa does it, should we just do it here though? */
2825 printk(KERN_DEBUG
"%s: Caught a WPA supplicant request that is not supported\n",
2831 if (ret
== 0 && copy_to_user(p
->pointer
, param
, p
->length
))
2840 prism54_set_wpa(struct net_device
*ndev
, struct iw_request_info
*info
,
2841 __u32
* uwrq
, char *extra
)
2843 islpci_private
*priv
= netdev_priv(ndev
);
2844 u32 mlme
, authen
, dot1x
, filter
, wep
;
2846 if (islpci_get_state(priv
) < PRV_STATE_INIT
)
2849 wep
= 1; /* For privacy invoked */
2850 filter
= 1; /* Filter out all unencrypted frames */
2851 dot1x
= 0x01; /* To enable eap filter */
2852 mlme
= DOT11_MLME_EXTENDED
;
2853 authen
= DOT11_AUTH_OS
; /* Only WEP uses _SK and _BOTH */
2855 down_write(&priv
->mib_sem
);
2858 switch (priv
->wpa
) {
2860 case 0: /* Clears/disables WPA and friends */
2862 filter
= 0; /* Do not filter un-encrypted data */
2864 mlme
= DOT11_MLME_AUTO
;
2865 printk("%s: Disabling WPA\n", ndev
->name
);
2869 printk("%s: Enabling WPA\n", ndev
->name
);
2872 up_write(&priv
->mib_sem
);
2874 mgt_set_request(priv
, DOT11_OID_AUTHENABLE
, 0, &authen
);
2875 mgt_set_request(priv
, DOT11_OID_PRIVACYINVOKED
, 0, &wep
);
2876 mgt_set_request(priv
, DOT11_OID_EXUNENCRYPTED
, 0, &filter
);
2877 mgt_set_request(priv
, DOT11_OID_DOT1XENABLE
, 0, &dot1x
);
2878 mgt_set_request(priv
, DOT11_OID_MLMEAUTOLEVEL
, 0, &mlme
);
2884 prism54_get_wpa(struct net_device
*ndev
, struct iw_request_info
*info
,
2885 __u32
* uwrq
, char *extra
)
2887 islpci_private
*priv
= netdev_priv(ndev
);
2893 prism54_set_prismhdr(struct net_device
*ndev
, struct iw_request_info
*info
,
2894 __u32
* uwrq
, char *extra
)
2896 islpci_private
*priv
= netdev_priv(ndev
);
2897 priv
->monitor_type
=
2898 (*uwrq
? ARPHRD_IEEE80211_PRISM
: ARPHRD_IEEE80211
);
2899 if (priv
->iw_mode
== IW_MODE_MONITOR
)
2900 priv
->ndev
->type
= priv
->monitor_type
;
2906 prism54_get_prismhdr(struct net_device
*ndev
, struct iw_request_info
*info
,
2907 __u32
* uwrq
, char *extra
)
2909 islpci_private
*priv
= netdev_priv(ndev
);
2910 *uwrq
= (priv
->monitor_type
== ARPHRD_IEEE80211_PRISM
);
2915 prism54_debug_oid(struct net_device
*ndev
, struct iw_request_info
*info
,
2916 __u32
* uwrq
, char *extra
)
2918 islpci_private
*priv
= netdev_priv(ndev
);
2920 priv
->priv_oid
= *uwrq
;
2921 printk("%s: oid 0x%08X\n", ndev
->name
, *uwrq
);
2927 prism54_debug_get_oid(struct net_device
*ndev
, struct iw_request_info
*info
,
2928 struct iw_point
*data
, char *extra
)
2930 islpci_private
*priv
= netdev_priv(ndev
);
2931 struct islpci_mgmtframe
*response
;
2934 printk("%s: get_oid 0x%08X\n", ndev
->name
, priv
->priv_oid
);
2937 if (islpci_get_state(priv
) >= PRV_STATE_INIT
) {
2939 islpci_mgt_transaction(priv
->ndev
, PIMFOR_OP_GET
,
2940 priv
->priv_oid
, extra
, 256,
2942 printk("%s: ret: %i\n", ndev
->name
, ret
);
2943 if (ret
|| !response
2944 || response
->header
->operation
== PIMFOR_OP_ERROR
) {
2946 islpci_mgt_release(response
);
2948 printk("%s: EIO\n", ndev
->name
);
2952 data
->length
= response
->header
->length
;
2953 memcpy(extra
, response
->data
, data
->length
);
2954 islpci_mgt_release(response
);
2955 printk("%s: len: %i\n", ndev
->name
, data
->length
);
2963 prism54_debug_set_oid(struct net_device
*ndev
, struct iw_request_info
*info
,
2964 struct iw_point
*data
, char *extra
)
2966 islpci_private
*priv
= netdev_priv(ndev
);
2967 struct islpci_mgmtframe
*response
;
2968 int ret
= 0, response_op
= PIMFOR_OP_ERROR
;
2970 printk("%s: set_oid 0x%08X\tlen: %d\n", ndev
->name
, priv
->priv_oid
,
2973 if (islpci_get_state(priv
) >= PRV_STATE_INIT
) {
2975 islpci_mgt_transaction(priv
->ndev
, PIMFOR_OP_SET
,
2976 priv
->priv_oid
, extra
, data
->length
,
2978 printk("%s: ret: %i\n", ndev
->name
, ret
);
2979 if (ret
|| !response
2980 || response
->header
->operation
== PIMFOR_OP_ERROR
) {
2982 islpci_mgt_release(response
);
2984 printk("%s: EIO\n", ndev
->name
);
2988 response_op
= response
->header
->operation
;
2989 printk("%s: response_op: %i\n", ndev
->name
,
2991 islpci_mgt_release(response
);
2995 return (ret
? ret
: -EINPROGRESS
);
2999 prism54_set_spy(struct net_device
*ndev
,
3000 struct iw_request_info
*info
,
3001 union iwreq_data
*uwrq
, char *extra
)
3003 islpci_private
*priv
= netdev_priv(ndev
);
3004 u32 u
, oid
= OID_INL_CONFIG
;
3006 down_write(&priv
->mib_sem
);
3007 mgt_get(priv
, OID_INL_CONFIG
, &u
);
3009 if ((uwrq
->data
.length
== 0) && (priv
->spy_data
.spy_number
> 0))
3011 u
&= ~INL_CONFIG_RXANNEX
;
3012 else if ((uwrq
->data
.length
> 0) && (priv
->spy_data
.spy_number
== 0))
3014 u
|= INL_CONFIG_RXANNEX
;
3016 mgt_set(priv
, OID_INL_CONFIG
, &u
);
3017 mgt_commit_list(priv
, &oid
, 1);
3018 up_write(&priv
->mib_sem
);
3020 return iw_handler_set_spy(ndev
, info
, uwrq
, extra
);
3023 static const iw_handler prism54_handler
[] = {
3024 (iw_handler
) prism54_commit
, /* SIOCSIWCOMMIT */
3025 (iw_handler
) prism54_get_name
, /* SIOCGIWNAME */
3026 (iw_handler
) NULL
, /* SIOCSIWNWID */
3027 (iw_handler
) NULL
, /* SIOCGIWNWID */
3028 (iw_handler
) prism54_set_freq
, /* SIOCSIWFREQ */
3029 (iw_handler
) prism54_get_freq
, /* SIOCGIWFREQ */
3030 (iw_handler
) prism54_set_mode
, /* SIOCSIWMODE */
3031 (iw_handler
) prism54_get_mode
, /* SIOCGIWMODE */
3032 (iw_handler
) prism54_set_sens
, /* SIOCSIWSENS */
3033 (iw_handler
) prism54_get_sens
, /* SIOCGIWSENS */
3034 (iw_handler
) NULL
, /* SIOCSIWRANGE */
3035 (iw_handler
) prism54_get_range
, /* SIOCGIWRANGE */
3036 (iw_handler
) NULL
, /* SIOCSIWPRIV */
3037 (iw_handler
) NULL
, /* SIOCGIWPRIV */
3038 (iw_handler
) NULL
, /* SIOCSIWSTATS */
3039 (iw_handler
) NULL
, /* SIOCGIWSTATS */
3040 prism54_set_spy
, /* SIOCSIWSPY */
3041 iw_handler_get_spy
, /* SIOCGIWSPY */
3042 iw_handler_set_thrspy
, /* SIOCSIWTHRSPY */
3043 iw_handler_get_thrspy
, /* SIOCGIWTHRSPY */
3044 (iw_handler
) prism54_set_wap
, /* SIOCSIWAP */
3045 (iw_handler
) prism54_get_wap
, /* SIOCGIWAP */
3046 (iw_handler
) NULL
, /* -- hole -- */
3047 (iw_handler
) NULL
, /* SIOCGIWAPLIST deprecated */
3048 (iw_handler
) prism54_set_scan
, /* SIOCSIWSCAN */
3049 (iw_handler
) prism54_get_scan
, /* SIOCGIWSCAN */
3050 (iw_handler
) prism54_set_essid
, /* SIOCSIWESSID */
3051 (iw_handler
) prism54_get_essid
, /* SIOCGIWESSID */
3052 (iw_handler
) prism54_set_nick
, /* SIOCSIWNICKN */
3053 (iw_handler
) prism54_get_nick
, /* SIOCGIWNICKN */
3054 (iw_handler
) NULL
, /* -- hole -- */
3055 (iw_handler
) NULL
, /* -- hole -- */
3056 (iw_handler
) prism54_set_rate
, /* SIOCSIWRATE */
3057 (iw_handler
) prism54_get_rate
, /* SIOCGIWRATE */
3058 (iw_handler
) prism54_set_rts
, /* SIOCSIWRTS */
3059 (iw_handler
) prism54_get_rts
, /* SIOCGIWRTS */
3060 (iw_handler
) prism54_set_frag
, /* SIOCSIWFRAG */
3061 (iw_handler
) prism54_get_frag
, /* SIOCGIWFRAG */
3062 (iw_handler
) prism54_set_txpower
, /* SIOCSIWTXPOW */
3063 (iw_handler
) prism54_get_txpower
, /* SIOCGIWTXPOW */
3064 (iw_handler
) prism54_set_retry
, /* SIOCSIWRETRY */
3065 (iw_handler
) prism54_get_retry
, /* SIOCGIWRETRY */
3066 (iw_handler
) prism54_set_encode
, /* SIOCSIWENCODE */
3067 (iw_handler
) prism54_get_encode
, /* SIOCGIWENCODE */
3068 (iw_handler
) NULL
, /* SIOCSIWPOWER */
3069 (iw_handler
) NULL
, /* SIOCGIWPOWER */
3070 NULL
, /* -- hole -- */
3071 NULL
, /* -- hole -- */
3072 (iw_handler
) prism54_set_genie
, /* SIOCSIWGENIE */
3073 (iw_handler
) prism54_get_genie
, /* SIOCGIWGENIE */
3074 (iw_handler
) prism54_set_auth
, /* SIOCSIWAUTH */
3075 (iw_handler
) prism54_get_auth
, /* SIOCGIWAUTH */
3076 (iw_handler
) prism54_set_encodeext
, /* SIOCSIWENCODEEXT */
3077 (iw_handler
) prism54_get_encodeext
, /* SIOCGIWENCODEEXT */
3078 NULL
, /* SIOCSIWPMKSA */
3081 /* The low order bit identify a SET (0) or a GET (1) ioctl. */
3083 #define PRISM54_RESET SIOCIWFIRSTPRIV
3084 #define PRISM54_GET_POLICY SIOCIWFIRSTPRIV+1
3085 #define PRISM54_SET_POLICY SIOCIWFIRSTPRIV+2
3086 #define PRISM54_GET_MAC SIOCIWFIRSTPRIV+3
3087 #define PRISM54_ADD_MAC SIOCIWFIRSTPRIV+4
3089 #define PRISM54_DEL_MAC SIOCIWFIRSTPRIV+6
3091 #define PRISM54_KICK_MAC SIOCIWFIRSTPRIV+8
3093 #define PRISM54_KICK_ALL SIOCIWFIRSTPRIV+10
3095 #define PRISM54_GET_WPA SIOCIWFIRSTPRIV+11
3096 #define PRISM54_SET_WPA SIOCIWFIRSTPRIV+12
3098 #define PRISM54_DBG_OID SIOCIWFIRSTPRIV+14
3099 #define PRISM54_DBG_GET_OID SIOCIWFIRSTPRIV+15
3100 #define PRISM54_DBG_SET_OID SIOCIWFIRSTPRIV+16
3102 #define PRISM54_GET_OID SIOCIWFIRSTPRIV+17
3103 #define PRISM54_SET_OID_U32 SIOCIWFIRSTPRIV+18
3104 #define PRISM54_SET_OID_STR SIOCIWFIRSTPRIV+20
3105 #define PRISM54_SET_OID_ADDR SIOCIWFIRSTPRIV+22
3107 #define PRISM54_GET_PRISMHDR SIOCIWFIRSTPRIV+23
3108 #define PRISM54_SET_PRISMHDR SIOCIWFIRSTPRIV+24
3110 #define IWPRIV_SET_U32(n,x) { n, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "s_"x }
3111 #define IWPRIV_SET_SSID(n,x) { n, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 1, 0, "s_"x }
3112 #define IWPRIV_SET_ADDR(n,x) { n, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "s_"x }
3113 #define IWPRIV_GET(n,x) { n, 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | PRIV_STR_SIZE, "g_"x }
3115 #define IWPRIV_U32(n,x) IWPRIV_SET_U32(n,x), IWPRIV_GET(n,x)
3116 #define IWPRIV_SSID(n,x) IWPRIV_SET_SSID(n,x), IWPRIV_GET(n,x)
3117 #define IWPRIV_ADDR(n,x) IWPRIV_SET_ADDR(n,x), IWPRIV_GET(n,x)
3119 /* Note : limited to 128 private ioctls (wireless tools 26) */
3121 static const struct iw_priv_args prism54_private_args
[] = {
3122 /*{ cmd, set_args, get_args, name } */
3123 {PRISM54_RESET
, 0, 0, "reset"},
3124 {PRISM54_GET_PRISMHDR
, 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1,
3126 {PRISM54_SET_PRISMHDR
, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0,
3128 {PRISM54_GET_POLICY
, 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1,
3130 {PRISM54_SET_POLICY
, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0,
3132 {PRISM54_GET_MAC
, 0, IW_PRIV_TYPE_ADDR
| 64, "getMac"},
3133 {PRISM54_ADD_MAC
, IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0,
3135 {PRISM54_DEL_MAC
, IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0,
3137 {PRISM54_KICK_MAC
, IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0,
3139 {PRISM54_KICK_ALL
, 0, 0, "kickAll"},
3140 {PRISM54_GET_WPA
, 0, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1,
3142 {PRISM54_SET_WPA
, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0,
3144 {PRISM54_DBG_OID
, IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0,
3146 {PRISM54_DBG_GET_OID
, 0, IW_PRIV_TYPE_BYTE
| 256, "dbg_get_oid"},
3147 {PRISM54_DBG_SET_OID
, IW_PRIV_TYPE_BYTE
| 256, 0, "dbg_set_oid"},
3148 /* --- sub-ioctls handlers --- */
3150 0, IW_PRIV_TYPE_CHAR
| IW_PRIV_SIZE_FIXED
| PRIV_STR_SIZE
, ""},
3151 {PRISM54_SET_OID_U32
,
3152 IW_PRIV_TYPE_INT
| IW_PRIV_SIZE_FIXED
| 1, 0, ""},
3153 {PRISM54_SET_OID_STR
,
3154 IW_PRIV_TYPE_CHAR
| IW_PRIV_SIZE_FIXED
| 1, 0, ""},
3155 {PRISM54_SET_OID_ADDR
,
3156 IW_PRIV_TYPE_ADDR
| IW_PRIV_SIZE_FIXED
| 1, 0, ""},
3157 /* --- sub-ioctls definitions --- */
3158 IWPRIV_ADDR(GEN_OID_MACADDRESS
, "addr"),
3159 IWPRIV_GET(GEN_OID_LINKSTATE
, "linkstate"),
3160 IWPRIV_U32(DOT11_OID_BSSTYPE
, "bsstype"),
3161 IWPRIV_ADDR(DOT11_OID_BSSID
, "bssid"),
3162 IWPRIV_U32(DOT11_OID_STATE
, "state"),
3163 IWPRIV_U32(DOT11_OID_AID
, "aid"),
3165 IWPRIV_SSID(DOT11_OID_SSIDOVERRIDE
, "ssidoverride"),
3167 IWPRIV_U32(DOT11_OID_MEDIUMLIMIT
, "medlimit"),
3168 IWPRIV_U32(DOT11_OID_BEACONPERIOD
, "beacon"),
3169 IWPRIV_U32(DOT11_OID_DTIMPERIOD
, "dtimperiod"),
3171 IWPRIV_U32(DOT11_OID_AUTHENABLE
, "authenable"),
3172 IWPRIV_U32(DOT11_OID_PRIVACYINVOKED
, "privinvok"),
3173 IWPRIV_U32(DOT11_OID_EXUNENCRYPTED
, "exunencrypt"),
3175 IWPRIV_U32(DOT11_OID_REKEYTHRESHOLD
, "rekeythresh"),
3177 IWPRIV_U32(DOT11_OID_MAXTXLIFETIME
, "maxtxlife"),
3178 IWPRIV_U32(DOT11_OID_MAXRXLIFETIME
, "maxrxlife"),
3179 IWPRIV_U32(DOT11_OID_ALOFT_FIXEDRATE
, "fixedrate"),
3180 IWPRIV_U32(DOT11_OID_MAXFRAMEBURST
, "frameburst"),
3181 IWPRIV_U32(DOT11_OID_PSM
, "psm"),
3183 IWPRIV_U32(DOT11_OID_BRIDGELOCAL
, "bridge"),
3184 IWPRIV_U32(DOT11_OID_CLIENTS
, "clients"),
3185 IWPRIV_U32(DOT11_OID_CLIENTSASSOCIATED
, "clientassoc"),
3186 IWPRIV_U32(DOT11_OID_DOT1XENABLE
, "dot1xenable"),
3187 IWPRIV_U32(DOT11_OID_ANTENNARX
, "rxant"),
3188 IWPRIV_U32(DOT11_OID_ANTENNATX
, "txant"),
3189 IWPRIV_U32(DOT11_OID_ANTENNADIVERSITY
, "antdivers"),
3190 IWPRIV_U32(DOT11_OID_EDTHRESHOLD
, "edthresh"),
3191 IWPRIV_U32(DOT11_OID_PREAMBLESETTINGS
, "preamble"),
3192 IWPRIV_GET(DOT11_OID_RATES
, "rates"),
3193 IWPRIV_U32(DOT11_OID_OUTPUTPOWER
, ".11outpower"),
3194 IWPRIV_GET(DOT11_OID_SUPPORTEDRATES
, "supprates"),
3195 IWPRIV_GET(DOT11_OID_SUPPORTEDFREQUENCIES
, "suppfreq"),
3197 IWPRIV_U32(DOT11_OID_NOISEFLOOR
, "noisefloor"),
3198 IWPRIV_GET(DOT11_OID_FREQUENCYACTIVITY
, "freqactivity"),
3199 IWPRIV_U32(DOT11_OID_NONERPPROTECTION
, "nonerpprotec"),
3200 IWPRIV_U32(DOT11_OID_PROFILES
, "profile"),
3201 IWPRIV_GET(DOT11_OID_EXTENDEDRATES
, "extrates"),
3202 IWPRIV_U32(DOT11_OID_MLMEAUTOLEVEL
, "mlmelevel"),
3204 IWPRIV_GET(DOT11_OID_BSSS
, "bsss"),
3205 IWPRIV_GET(DOT11_OID_BSSLIST
, "bsslist"),
3206 IWPRIV_U32(OID_INL_MODE
, "mode"),
3207 IWPRIV_U32(OID_INL_CONFIG
, "config"),
3208 IWPRIV_U32(OID_INL_DOT11D_CONFORMANCE
, ".11dconform"),
3209 IWPRIV_GET(OID_INL_PHYCAPABILITIES
, "phycapa"),
3210 IWPRIV_U32(OID_INL_OUTPUTPOWER
, "outpower"),
3213 static const iw_handler prism54_private_handler
[] = {
3214 (iw_handler
) prism54_reset
,
3215 (iw_handler
) prism54_get_policy
,
3216 (iw_handler
) prism54_set_policy
,
3217 (iw_handler
) prism54_get_mac
,
3218 (iw_handler
) prism54_add_mac
,
3220 (iw_handler
) prism54_del_mac
,
3222 (iw_handler
) prism54_kick_mac
,
3224 (iw_handler
) prism54_kick_all
,
3225 (iw_handler
) prism54_get_wpa
,
3226 (iw_handler
) prism54_set_wpa
,
3228 (iw_handler
) prism54_debug_oid
,
3229 (iw_handler
) prism54_debug_get_oid
,
3230 (iw_handler
) prism54_debug_set_oid
,
3231 (iw_handler
) prism54_get_oid
,
3232 (iw_handler
) prism54_set_u32
,
3234 (iw_handler
) prism54_set_raw
,
3236 (iw_handler
) prism54_set_raw
,
3237 (iw_handler
) prism54_get_prismhdr
,
3238 (iw_handler
) prism54_set_prismhdr
,
3241 const struct iw_handler_def prism54_handler_def
= {
3242 .num_standard
= ARRAY_SIZE(prism54_handler
),
3243 .num_private
= ARRAY_SIZE(prism54_private_handler
),
3244 .num_private_args
= ARRAY_SIZE(prism54_private_args
),
3245 .standard
= (iw_handler
*) prism54_handler
,
3246 .private = (iw_handler
*) prism54_private_handler
,
3247 .private_args
= (struct iw_priv_args
*) prism54_private_args
,
3248 .get_wireless_stats
= prism54_get_wireless_stats
,
3251 /* For wpa_supplicant */
3254 prism54_ioctl(struct net_device
*ndev
, struct ifreq
*rq
, int cmd
)
3256 struct iwreq
*wrq
= (struct iwreq
*) rq
;
3259 case PRISM54_HOSTAPD
:
3260 if (!capable(CAP_NET_ADMIN
))
3262 ret
= prism54_hostapd(ndev
, &wrq
->u
.data
);