3 * Copyright (C) 2002 Intersil Americas Inc.
4 * (C) 2003,2004 Aurelien Alleaume <slts@free.fr>
5 * (C) 2003 Herbert Valerio Riedel <hvr@gnu.org>
6 * (C) 2003 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <linux/module.h>
24 #include <linux/kernel.h>
25 #include <linux/if_arp.h>
26 #include <linux/pci.h>
28 #include <asm/uaccess.h>
30 #include "prismcompat.h"
31 #include "isl_ioctl.h"
32 #include "islpci_mgt.h"
33 #include "isl_oid.h" /* additional types and defs for isl38xx fw */
36 #include <net/iw_handler.h> /* New driver API */
38 #define KEY_SIZE_WEP104 13 /* 104/128-bit WEP keys */
39 #define KEY_SIZE_WEP40 5 /* 40/64-bit WEP keys */
40 /* KEY_SIZE_TKIP should match isl_oid.h, struct obj_key.key[] size */
41 #define KEY_SIZE_TKIP 32 /* TKIP keys */
43 static void prism54_wpa_bss_ie_add(islpci_private *priv, u8 *bssid,
44 u8 *wpa_ie, size_t wpa_ie_len);
45 static size_t prism54_wpa_bss_ie_get(islpci_private *priv, u8 *bssid, u8 *wpa_ie);
46 static int prism54_set_wpa(struct net_device *, struct iw_request_info *,
51 * prism54_mib_mode_helper - MIB change mode helper function
52 * @mib: the &struct islpci_mib object to modify
53 * @iw_mode: new mode (%IW_MODE_*)
55 * This is a helper function, hence it does not lock. Make sure
56 * caller deals with locking *if* necessary. This function sets the
57 * mode-dependent mib values and does the mapping of the Linux
58 * Wireless API modes to Device firmware modes. It also checks for
59 * correct valid Linux wireless modes.
62 prism54_mib_mode_helper(islpci_private *priv, u32 iw_mode)
64 u32 config = INL_CONFIG_MANUALRUN;
67 /* For now, just catch early the Repeater and Secondary modes here */
68 if (iw_mode == IW_MODE_REPEAT || iw_mode == IW_MODE_SECOND) {
70 "%s(): Sorry, Repeater mode and Secondary mode "
71 "are not yet supported by this driver.\n", __FUNCTION__);
75 priv->iw_mode = iw_mode;
79 mode = INL_MODE_CLIENT;
80 bsstype = DOT11_BSSTYPE_ANY;
83 mode = INL_MODE_CLIENT;
84 bsstype = DOT11_BSSTYPE_IBSS;
87 mode = INL_MODE_CLIENT;
88 bsstype = DOT11_BSSTYPE_INFRA;
92 bsstype = DOT11_BSSTYPE_INFRA;
95 mode = INL_MODE_PROMISCUOUS;
96 bsstype = DOT11_BSSTYPE_ANY;
97 config |= INL_CONFIG_RXANNEX;
104 config |= INL_CONFIG_WDS;
105 mgt_set(priv, DOT11_OID_BSSTYPE, &bsstype);
106 mgt_set(priv, OID_INL_CONFIG, &config);
107 mgt_set(priv, OID_INL_MODE, &mode);
113 * prism54_mib_init - fill MIB cache with defaults
115 * this function initializes the struct given as @mib with defaults,
116 * of which many are retrieved from the global module parameter
121 prism54_mib_init(islpci_private *priv)
123 u32 channel, authen, wep, filter, dot1x, mlme, conformance, power, mode;
124 struct obj_buffer psm_buffer = {
125 .size = PSM_BUFFER_SIZE,
126 .addr = priv->device_psm_buffer
129 channel = CARD_DEFAULT_CHANNEL;
130 authen = CARD_DEFAULT_AUTHEN;
131 wep = CARD_DEFAULT_WEP;
132 filter = CARD_DEFAULT_FILTER; /* (0) Do not filter un-encrypted data */
133 dot1x = CARD_DEFAULT_DOT1X;
134 mlme = CARD_DEFAULT_MLME_MODE;
135 conformance = CARD_DEFAULT_CONFORMANCE;
137 mode = CARD_DEFAULT_IW_MODE;
139 mgt_set(priv, DOT11_OID_CHANNEL, &channel);
140 mgt_set(priv, DOT11_OID_AUTHENABLE, &authen);
141 mgt_set(priv, DOT11_OID_PRIVACYINVOKED, &wep);
142 mgt_set(priv, DOT11_OID_PSMBUFFER, &psm_buffer);
143 mgt_set(priv, DOT11_OID_EXUNENCRYPTED, &filter);
144 mgt_set(priv, DOT11_OID_DOT1XENABLE, &dot1x);
145 mgt_set(priv, DOT11_OID_MLMEAUTOLEVEL, &mlme);
146 mgt_set(priv, OID_INL_DOT11D_CONFORMANCE, &conformance);
147 mgt_set(priv, OID_INL_OUTPUTPOWER, &power);
149 /* This sets all of the mode-dependent values */
150 prism54_mib_mode_helper(priv, mode);
153 /* this will be executed outside of atomic context thanks to
154 * schedule_work(), thus we can as well use sleeping semaphore
157 prism54_update_stats(islpci_private *priv)
161 struct obj_bss bss, *bss2;
164 if (down_interruptible(&priv->stats_sem))
168 * I'm not sure if the unit is dBm.
169 * Note : If we are not connected, this value seems to be irrelevant. */
171 mgt_get_request(priv, DOT11_OID_NOISEFLOOR, 0, NULL, &r);
172 priv->local_iwstatistics.qual.noise = r.u;
174 /* Get the rssi of the link. To do this we need to retrieve a bss. */
176 /* First get the MAC address of the AP we are associated with. */
177 mgt_get_request(priv, DOT11_OID_BSSID, 0, NULL, &r);
180 /* copy this MAC to the bss */
181 memcpy(bss.address, data, 6);
184 /* now ask for the corresponding bss */
185 j = mgt_get_request(priv, DOT11_OID_BSSFIND, 0, (void *) &bss, &r);
187 /* report the rssi and use it to calculate
188 * link quality through a signal-noise
190 priv->local_iwstatistics.qual.level = bss2->rssi;
191 priv->local_iwstatistics.qual.qual =
192 bss2->rssi - priv->iwstatistics.qual.noise;
196 /* report that the stats are new */
197 priv->local_iwstatistics.qual.updated = 0x7;
199 /* Rx : unable to decrypt the MPDU */
200 mgt_get_request(priv, DOT11_OID_PRIVRXFAILED, 0, NULL, &r);
201 priv->local_iwstatistics.discard.code = r.u;
203 /* Tx : Max MAC retries num reached */
204 mgt_get_request(priv, DOT11_OID_MPDUTXFAILED, 0, NULL, &r);
205 priv->local_iwstatistics.discard.retries = r.u;
207 up(&priv->stats_sem);
212 struct iw_statistics *
213 prism54_get_wireless_stats(struct net_device *ndev)
215 islpci_private *priv = netdev_priv(ndev);
217 /* If the stats are being updated return old data */
218 if (down_trylock(&priv->stats_sem) == 0) {
219 memcpy(&priv->iwstatistics, &priv->local_iwstatistics,
220 sizeof (struct iw_statistics));
221 /* They won't be marked updated for the next time */
222 priv->local_iwstatistics.qual.updated = 0;
223 up(&priv->stats_sem);
225 priv->iwstatistics.qual.updated = 0;
227 /* Update our wireless stats, but do not schedule to often
229 if ((priv->stats_timestamp == 0) ||
230 time_after(jiffies, priv->stats_timestamp + 1 * HZ)) {
231 schedule_work(&priv->stats_work);
232 priv->stats_timestamp = jiffies;
235 return &priv->iwstatistics;
239 prism54_commit(struct net_device *ndev, struct iw_request_info *info,
240 char *cwrq, char *extra)
242 islpci_private *priv = netdev_priv(ndev);
244 /* simply re-set the last set SSID, this should commit most stuff */
246 /* Commit in Monitor mode is not necessary, also setting essid
247 * in Monitor mode does not make sense and isn't allowed for this
248 * device's firmware */
249 if (priv->iw_mode != IW_MODE_MONITOR)
250 return mgt_set_request(priv, DOT11_OID_SSID, 0, NULL);
255 prism54_get_name(struct net_device *ndev, struct iw_request_info *info,
256 char *cwrq, char *extra)
258 islpci_private *priv = netdev_priv(ndev);
263 if (islpci_get_state(priv) < PRV_STATE_INIT) {
264 strncpy(cwrq, "NOT READY!", IFNAMSIZ);
267 rvalue = mgt_get_request(priv, OID_INL_PHYCAPABILITIES, 0, NULL, &r);
270 case INL_PHYCAP_5000MHZ:
271 capabilities = "IEEE 802.11a/b/g";
274 capabilities = "IEEE 802.11b/g - FAA Support";
276 case INL_PHYCAP_2400MHZ:
278 capabilities = "IEEE 802.11b/g"; /* Default */
281 strncpy(cwrq, capabilities, IFNAMSIZ);
286 prism54_set_freq(struct net_device *ndev, struct iw_request_info *info,
287 struct iw_freq *fwrq, char *extra)
289 islpci_private *priv = netdev_priv(ndev);
294 /* we have a channel number */
297 c = (fwrq->e == 1) ? channel_of_freq(fwrq->m / 100000) : 0;
299 rvalue = c ? mgt_set_request(priv, DOT11_OID_CHANNEL, 0, &c) : -EINVAL;
301 /* Call commit handler */
302 return (rvalue ? rvalue : -EINPROGRESS);
306 prism54_get_freq(struct net_device *ndev, struct iw_request_info *info,
307 struct iw_freq *fwrq, char *extra)
309 islpci_private *priv = netdev_priv(ndev);
313 rvalue = mgt_get_request(priv, DOT11_OID_CHANNEL, 0, NULL, &r);
315 rvalue |= mgt_get_request(priv, DOT11_OID_FREQUENCY, 0, NULL, &r);
323 prism54_set_mode(struct net_device *ndev, struct iw_request_info *info,
324 __u32 * uwrq, char *extra)
326 islpci_private *priv = netdev_priv(ndev);
327 u32 mlmeautolevel = CARD_DEFAULT_MLME_MODE;
329 /* Let's see if the user passed a valid Linux Wireless mode */
330 if (*uwrq > IW_MODE_MONITOR || *uwrq < IW_MODE_AUTO) {
332 "%s: %s() You passed a non-valid init_mode.\n",
333 priv->ndev->name, __FUNCTION__);
337 down_write(&priv->mib_sem);
339 if (prism54_mib_mode_helper(priv, *uwrq)) {
340 up_write(&priv->mib_sem);
344 /* the ACL code needs an intermediate mlmeautolevel. The wpa stuff an
347 if ((*uwrq == IW_MODE_MASTER) && (priv->acl.policy != MAC_POLICY_OPEN))
348 mlmeautolevel = DOT11_MLME_INTERMEDIATE;
350 mlmeautolevel = DOT11_MLME_EXTENDED;
352 mgt_set(priv, DOT11_OID_MLMEAUTOLEVEL, &mlmeautolevel);
354 if (mgt_commit(priv)) {
355 up_write(&priv->mib_sem);
358 priv->ndev->type = (priv->iw_mode == IW_MODE_MONITOR)
359 ? priv->monitor_type : ARPHRD_ETHER;
360 up_write(&priv->mib_sem);
367 prism54_get_mode(struct net_device *ndev, struct iw_request_info *info,
368 __u32 * uwrq, char *extra)
370 islpci_private *priv = netdev_priv(ndev);
372 BUG_ON((priv->iw_mode < IW_MODE_AUTO) || (priv->iw_mode >
374 *uwrq = priv->iw_mode;
379 /* we use DOT11_OID_EDTHRESHOLD. From what I guess the card will not try to
380 * emit data if (sensitivity > rssi - noise) (in dBm).
381 * prism54_set_sens does not seem to work.
385 prism54_set_sens(struct net_device *ndev, struct iw_request_info *info,
386 struct iw_param *vwrq, char *extra)
388 islpci_private *priv = netdev_priv(ndev);
391 /* by default the card sets this to 20. */
392 sens = vwrq->disabled ? 20 : vwrq->value;
394 return mgt_set_request(priv, DOT11_OID_EDTHRESHOLD, 0, &sens);
398 prism54_get_sens(struct net_device *ndev, struct iw_request_info *info,
399 struct iw_param *vwrq, char *extra)
401 islpci_private *priv = netdev_priv(ndev);
405 rvalue = mgt_get_request(priv, DOT11_OID_EDTHRESHOLD, 0, NULL, &r);
408 vwrq->disabled = (vwrq->value == 0);
415 prism54_get_range(struct net_device *ndev, struct iw_request_info *info,
416 struct iw_point *dwrq, char *extra)
418 struct iw_range *range = (struct iw_range *) extra;
419 islpci_private *priv = netdev_priv(ndev);
422 struct obj_frequencies *freq;
425 memset(range, 0, sizeof (struct iw_range));
426 dwrq->length = sizeof (struct iw_range);
428 /* set the wireless extension version number */
429 range->we_version_source = SUPPORTED_WIRELESS_EXT;
430 range->we_version_compiled = WIRELESS_EXT;
432 /* Now the encoding capabilities */
433 range->num_encoding_sizes = 3;
434 /* 64(40) bits WEP */
435 range->encoding_size[0] = 5;
436 /* 128(104) bits WEP */
437 range->encoding_size[1] = 13;
438 /* 256 bits for WPA-PSK */
439 range->encoding_size[2] = 32;
440 /* 4 keys are allowed */
441 range->max_encoding_tokens = 4;
443 /* we don't know the quality range... */
444 range->max_qual.level = 0;
445 range->max_qual.noise = 0;
446 range->max_qual.qual = 0;
447 /* these value describe an average quality. Needs more tweaking... */
448 range->avg_qual.level = -80; /* -80 dBm */
449 range->avg_qual.noise = 0; /* don't know what to put here */
450 range->avg_qual.qual = 0;
452 range->sensitivity = 200;
454 /* retry limit capabilities */
455 range->retry_capa = IW_RETRY_LIMIT | IW_RETRY_LIFETIME;
456 range->retry_flags = IW_RETRY_LIMIT;
457 range->r_time_flags = IW_RETRY_LIFETIME;
459 /* I don't know the range. Put stupid things here */
460 range->min_retry = 1;
461 range->max_retry = 65535;
462 range->min_r_time = 1024;
463 range->max_r_time = 65535 * 1024;
465 /* txpower is supported in dBm's */
466 range->txpower_capa = IW_TXPOW_DBM;
468 /* Event capability (kernel + driver) */
469 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
470 IW_EVENT_CAPA_MASK(SIOCGIWTHRSPY) |
471 IW_EVENT_CAPA_MASK(SIOCGIWAP));
472 range->event_capa[1] = IW_EVENT_CAPA_K_1;
473 range->event_capa[4] = IW_EVENT_CAPA_MASK(IWEVCUSTOM);
475 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
476 IW_ENC_CAPA_CIPHER_TKIP;
478 if (islpci_get_state(priv) < PRV_STATE_INIT)
481 /* Request the device for the supported frequencies
482 * not really relevant since some devices will report the 5 GHz band
483 * frequencies even if they don't support them.
486 mgt_get_request(priv, DOT11_OID_SUPPORTEDFREQUENCIES, 0, NULL, &r);
489 range->num_channels = freq->nr;
490 range->num_frequency = freq->nr;
492 m = min(IW_MAX_FREQUENCIES, (int) freq->nr);
493 for (i = 0; i < m; i++) {
494 range->freq[i].m = freq->mhz[i];
495 range->freq[i].e = 6;
496 range->freq[i].i = channel_of_freq(freq->mhz[i]);
500 rvalue |= mgt_get_request(priv, DOT11_OID_SUPPORTEDRATES, 0, NULL, &r);
503 /* We got an array of char. It is NULL terminated. */
505 while ((i < IW_MAX_BITRATES) && (*data != 0)) {
506 /* the result must be in bps. The card gives us 500Kbps */
507 range->bitrate[i] = *data * 500000;
511 range->num_bitrates = i;
520 prism54_set_wap(struct net_device *ndev, struct iw_request_info *info,
521 struct sockaddr *awrq, char *extra)
523 islpci_private *priv = netdev_priv(ndev);
527 if (awrq->sa_family != ARPHRD_ETHER)
530 /* prepare the structure for the set object */
531 memcpy(&bssid[0], awrq->sa_data, 6);
533 /* set the bssid -- does this make sense when in AP mode? */
534 rvalue = mgt_set_request(priv, DOT11_OID_BSSID, 0, &bssid);
536 return (rvalue ? rvalue : -EINPROGRESS); /* Call commit handler */
542 prism54_get_wap(struct net_device *ndev, struct iw_request_info *info,
543 struct sockaddr *awrq, char *extra)
545 islpci_private *priv = netdev_priv(ndev);
549 rvalue = mgt_get_request(priv, DOT11_OID_BSSID, 0, NULL, &r);
550 memcpy(awrq->sa_data, r.ptr, 6);
551 awrq->sa_family = ARPHRD_ETHER;
558 prism54_set_scan(struct net_device *dev, struct iw_request_info *info,
559 struct iw_param *vwrq, char *extra)
561 /* hehe the device does this automagicaly */
565 /* a little helper that will translate our data into a card independent
566 * format that the Wireless Tools will understand. This was inspired by
567 * the "Aironet driver for 4500 and 4800 series cards" (GPL)
571 prism54_translate_bss(struct net_device *ndev, char *current_ev,
572 char *end_buf, struct obj_bss *bss, char noise)
574 struct iw_event iwe; /* Temporary buffer */
576 islpci_private *priv = netdev_priv(ndev);
577 u8 wpa_ie[MAX_WPA_IE_LEN];
580 /* The first entry must be the MAC address */
581 memcpy(iwe.u.ap_addr.sa_data, bss->address, 6);
582 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
585 iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_ADDR_LEN);
587 /* The following entries will be displayed in the same order we give them */
590 iwe.u.data.length = bss->ssid.length;
591 iwe.u.data.flags = 1;
592 iwe.cmd = SIOCGIWESSID;
593 current_ev = iwe_stream_add_point(current_ev, end_buf,
594 &iwe, bss->ssid.octets);
598 #define CAP_IBSS 0x02
599 #define CAP_CRYPT 0x10
605 iwe.u.mode = IW_MODE_MASTER;
606 else if (cap & CAP_IBSS)
607 iwe.u.mode = IW_MODE_ADHOC;
608 iwe.cmd = SIOCGIWMODE;
611 iwe_stream_add_event(current_ev, end_buf, &iwe,
614 /* Encryption capability */
616 iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
618 iwe.u.data.flags = IW_ENCODE_DISABLED;
619 iwe.u.data.length = 0;
620 iwe.cmd = SIOCGIWENCODE;
621 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, NULL);
623 /* Add frequency. (short) bss->channel is the frequency in MHz */
624 iwe.u.freq.m = bss->channel;
626 iwe.cmd = SIOCGIWFREQ;
628 iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
630 /* Add quality statistics */
631 iwe.u.qual.level = bss->rssi;
632 iwe.u.qual.noise = noise;
633 /* do a simple SNR for quality */
634 iwe.u.qual.qual = bss->rssi - noise;
637 iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
639 /* Add WPA/RSN Information Element, if any */
640 wpa_ie_len = prism54_wpa_bss_ie_get(priv, bss->address, wpa_ie);
641 if (wpa_ie_len > 0) {
643 iwe.u.data.length = min(wpa_ie_len, (size_t)MAX_WPA_IE_LEN);
644 current_ev = iwe_stream_add_point(current_ev, end_buf,
651 prism54_get_scan(struct net_device *ndev, struct iw_request_info *info,
652 struct iw_point *dwrq, char *extra)
654 islpci_private *priv = netdev_priv(ndev);
656 struct obj_bsslist *bsslist;
658 char *current_ev = extra;
661 if (islpci_get_state(priv) < PRV_STATE_INIT) {
662 /* device is not ready, fail gently */
667 /* first get the noise value. We will use it to report the link quality */
668 rvalue = mgt_get_request(priv, DOT11_OID_NOISEFLOOR, 0, NULL, &r);
671 /* Ask the device for a list of known bss.
672 * The old API, using SIOCGIWAPLIST, had a hard limit of IW_MAX_AP=64.
673 * The new API, using SIOCGIWSCAN, is only limited by the buffer size.
674 * WE-14->WE-16, the buffer is limited to IW_SCAN_MAX_DATA bytes.
675 * Starting with WE-17, the buffer can be as big as needed.
676 * But the device won't repport anything if you change the value
677 * of IWMAX_BSS=24. */
679 rvalue |= mgt_get_request(priv, DOT11_OID_BSSLIST, 0, NULL, &r);
682 /* ok now, scan the list and translate its info */
683 for (i = 0; i < (int) bsslist->nr; i++) {
684 current_ev = prism54_translate_bss(ndev, current_ev,
685 extra + dwrq->length,
686 &(bsslist->bsslist[i]),
689 /* Check if there is space for one more entry */
690 if((extra + dwrq->length - current_ev) <= IW_EV_ADDR_LEN) {
691 /* Ask user space to try again with a bigger buffer */
698 dwrq->length = (current_ev - extra);
699 dwrq->flags = 0; /* todo */
705 prism54_set_essid(struct net_device *ndev, struct iw_request_info *info,
706 struct iw_point *dwrq, char *extra)
708 islpci_private *priv = netdev_priv(ndev);
709 struct obj_ssid essid;
711 memset(essid.octets, 0, 33);
713 /* Check if we were asked for `any' */
714 if (dwrq->flags && dwrq->length) {
715 if (dwrq->length > min(33, IW_ESSID_MAX_SIZE + 1))
717 essid.length = dwrq->length - 1;
718 memcpy(essid.octets, extra, dwrq->length);
722 if (priv->iw_mode != IW_MODE_MONITOR)
723 return mgt_set_request(priv, DOT11_OID_SSID, 0, &essid);
725 /* If in monitor mode, just save to mib */
726 mgt_set(priv, DOT11_OID_SSID, &essid);
732 prism54_get_essid(struct net_device *ndev, struct iw_request_info *info,
733 struct iw_point *dwrq, char *extra)
735 islpci_private *priv = netdev_priv(ndev);
736 struct obj_ssid *essid;
740 rvalue = mgt_get_request(priv, DOT11_OID_SSID, 0, NULL, &r);
744 dwrq->flags = 1; /* set ESSID to ON for Wireless Extensions */
745 /* if it is too big, trunk it */
746 dwrq->length = min((u8)IW_ESSID_MAX_SIZE, essid->length);
751 essid->octets[essid->length] = '\0';
752 memcpy(extra, essid->octets, dwrq->length);
758 /* Provides no functionality, just completes the ioctl. In essence this is a
759 * just a cosmetic ioctl.
762 prism54_set_nick(struct net_device *ndev, struct iw_request_info *info,
763 struct iw_point *dwrq, char *extra)
765 islpci_private *priv = netdev_priv(ndev);
767 if (dwrq->length > IW_ESSID_MAX_SIZE)
770 down_write(&priv->mib_sem);
771 memset(priv->nickname, 0, sizeof (priv->nickname));
772 memcpy(priv->nickname, extra, dwrq->length);
773 up_write(&priv->mib_sem);
779 prism54_get_nick(struct net_device *ndev, struct iw_request_info *info,
780 struct iw_point *dwrq, char *extra)
782 islpci_private *priv = netdev_priv(ndev);
786 down_read(&priv->mib_sem);
787 dwrq->length = strlen(priv->nickname) + 1;
788 memcpy(extra, priv->nickname, dwrq->length);
789 up_read(&priv->mib_sem);
794 /* Set the allowed Bitrates */
797 prism54_set_rate(struct net_device *ndev,
798 struct iw_request_info *info,
799 struct iw_param *vwrq, char *extra)
802 islpci_private *priv = netdev_priv(ndev);
808 if (vwrq->value == -1) {
809 /* auto mode. No limit. */
811 return mgt_set_request(priv, DOT11_OID_PROFILES, 0, &profile);
814 ret = mgt_get_request(priv, DOT11_OID_SUPPORTEDRATES, 0, NULL, &r);
820 rate = (u32) (vwrq->value / 500000);
825 if (rate && (data[i] == rate)) {
828 if (vwrq->value == i) {
843 /* Now, check if we want a fixed or auto value */
851 printk("prism54 rate: ");
853 printk("%u ", data[i]);
859 ret = mgt_set_request(priv, DOT11_OID_PROFILES, 0, &profile);
860 ret |= mgt_set_request(priv, DOT11_OID_EXTENDEDRATES, 0, data);
861 ret |= mgt_set_request(priv, DOT11_OID_RATES, 0, data);
868 /* Get the current bit rate */
870 prism54_get_rate(struct net_device *ndev,
871 struct iw_request_info *info,
872 struct iw_param *vwrq, char *extra)
874 islpci_private *priv = netdev_priv(ndev);
879 /* Get the current bit rate */
880 if ((rvalue = mgt_get_request(priv, GEN_OID_LINKSTATE, 0, NULL, &r)))
882 vwrq->value = r.u * 500000;
884 /* request the device for the enabled rates */
885 rvalue = mgt_get_request(priv, DOT11_OID_RATES, 0, NULL, &r);
891 vwrq->fixed = (data[0] != 0) && (data[1] == 0);
898 prism54_set_rts(struct net_device *ndev, struct iw_request_info *info,
899 struct iw_param *vwrq, char *extra)
901 islpci_private *priv = netdev_priv(ndev);
903 return mgt_set_request(priv, DOT11_OID_RTSTHRESH, 0, &vwrq->value);
907 prism54_get_rts(struct net_device *ndev, struct iw_request_info *info,
908 struct iw_param *vwrq, char *extra)
910 islpci_private *priv = netdev_priv(ndev);
914 /* get the rts threshold */
915 rvalue = mgt_get_request(priv, DOT11_OID_RTSTHRESH, 0, NULL, &r);
922 prism54_set_frag(struct net_device *ndev, struct iw_request_info *info,
923 struct iw_param *vwrq, char *extra)
925 islpci_private *priv = netdev_priv(ndev);
927 return mgt_set_request(priv, DOT11_OID_FRAGTHRESH, 0, &vwrq->value);
931 prism54_get_frag(struct net_device *ndev, struct iw_request_info *info,
932 struct iw_param *vwrq, char *extra)
934 islpci_private *priv = netdev_priv(ndev);
938 rvalue = mgt_get_request(priv, DOT11_OID_FRAGTHRESH, 0, NULL, &r);
944 /* Here we have (min,max) = max retries for (small frames, big frames). Where
945 * big frame <=> bigger than the rts threshold
946 * small frame <=> smaller than the rts threshold
947 * This is not really the behavior expected by the wireless tool but it seems
948 * to be a common behavior in other drivers.
952 prism54_set_retry(struct net_device *ndev, struct iw_request_info *info,
953 struct iw_param *vwrq, char *extra)
955 islpci_private *priv = netdev_priv(ndev);
956 u32 slimit = 0, llimit = 0; /* short and long limit */
961 /* we cannot disable this feature */
964 if (vwrq->flags & IW_RETRY_LIMIT) {
965 if (vwrq->flags & IW_RETRY_MIN)
966 slimit = vwrq->value;
967 else if (vwrq->flags & IW_RETRY_MAX)
968 llimit = vwrq->value;
970 /* we are asked to set both */
971 slimit = vwrq->value;
972 llimit = vwrq->value;
975 if (vwrq->flags & IW_RETRY_LIFETIME)
976 /* Wireless tools use us unit while the device uses 1024 us unit */
977 lifetime = vwrq->value / 1024;
979 /* now set what is requested */
982 mgt_set_request(priv, DOT11_OID_SHORTRETRIES, 0, &slimit);
985 mgt_set_request(priv, DOT11_OID_LONGRETRIES, 0, &llimit);
988 mgt_set_request(priv, DOT11_OID_MAXTXLIFETIME, 0,
994 prism54_get_retry(struct net_device *ndev, struct iw_request_info *info,
995 struct iw_param *vwrq, char *extra)
997 islpci_private *priv = netdev_priv(ndev);
1000 vwrq->disabled = 0; /* It cannot be disabled */
1002 if ((vwrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
1003 /* we are asked for the life time */
1005 mgt_get_request(priv, DOT11_OID_MAXTXLIFETIME, 0, NULL, &r);
1006 vwrq->value = r.u * 1024;
1007 vwrq->flags = IW_RETRY_LIFETIME;
1008 } else if ((vwrq->flags & IW_RETRY_MAX)) {
1009 /* we are asked for the long retry limit */
1011 mgt_get_request(priv, DOT11_OID_LONGRETRIES, 0, NULL, &r);
1013 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
1015 /* default. get the short retry limit */
1017 mgt_get_request(priv, DOT11_OID_SHORTRETRIES, 0, NULL, &r);
1019 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_MIN;
1026 prism54_set_encode(struct net_device *ndev, struct iw_request_info *info,
1027 struct iw_point *dwrq, char *extra)
1029 islpci_private *priv = netdev_priv(ndev);
1030 int rvalue = 0, force = 0;
1031 int authen = DOT11_AUTH_OS, invoke = 0, exunencrypt = 0;
1034 /* with the new API, it's impossible to get a NULL pointer.
1035 * New version of iwconfig set the IW_ENCODE_NOKEY flag
1036 * when no key is given, but older versions don't. */
1038 if (dwrq->length > 0) {
1039 /* we have a key to set */
1040 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
1042 struct obj_key key = { DOT11_PRIV_WEP, 0, "" };
1044 /* get the current key index */
1045 rvalue = mgt_get_request(priv, DOT11_OID_DEFKEYID, 0, NULL, &r);
1046 current_index = r.u;
1047 /* Verify that the key is not marked as invalid */
1048 if (!(dwrq->flags & IW_ENCODE_NOKEY)) {
1049 if (dwrq->length > KEY_SIZE_TKIP) {
1050 /* User-provided key data too big */
1053 if (dwrq->length > KEY_SIZE_WEP104) {
1055 key.type = DOT11_PRIV_TKIP;
1056 key.length = KEY_SIZE_TKIP;
1057 } else if (dwrq->length > KEY_SIZE_WEP40) {
1059 key.length = KEY_SIZE_WEP104;
1062 key.length = KEY_SIZE_WEP40;
1064 memset(key.key, 0, sizeof (key.key));
1065 memcpy(key.key, extra, dwrq->length);
1067 if ((index < 0) || (index > 3))
1068 /* no index provided use the current one */
1069 index = current_index;
1071 /* now send the key to the card */
1073 mgt_set_request(priv, DOT11_OID_DEFKEYX, index,
1077 * If a valid key is set, encryption should be enabled
1078 * (user may turn it off later).
1079 * This is also how "iwconfig ethX key on" works
1081 if ((index == current_index) && (key.length > 0))
1084 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
1085 if ((index >= 0) && (index <= 3)) {
1086 /* we want to set the key index */
1088 mgt_set_request(priv, DOT11_OID_DEFKEYID, 0,
1091 if (!dwrq->flags & IW_ENCODE_MODE) {
1092 /* we cannot do anything. Complain. */
1097 /* now read the flags */
1098 if (dwrq->flags & IW_ENCODE_DISABLED) {
1099 /* Encoding disabled,
1100 * authen = DOT11_AUTH_OS;
1102 * exunencrypt = 0; */
1104 if (dwrq->flags & IW_ENCODE_OPEN)
1105 /* Encode but accept non-encoded packets. No auth */
1107 if ((dwrq->flags & IW_ENCODE_RESTRICTED) || force) {
1108 /* Refuse non-encoded packets. Auth */
1109 authen = DOT11_AUTH_BOTH;
1113 /* do the change if requested */
1114 if ((dwrq->flags & IW_ENCODE_MODE) || force) {
1116 mgt_set_request(priv, DOT11_OID_AUTHENABLE, 0, &authen);
1118 mgt_set_request(priv, DOT11_OID_PRIVACYINVOKED, 0, &invoke);
1120 mgt_set_request(priv, DOT11_OID_EXUNENCRYPTED, 0,
1127 prism54_get_encode(struct net_device *ndev, struct iw_request_info *info,
1128 struct iw_point *dwrq, char *extra)
1130 islpci_private *priv = netdev_priv(ndev);
1131 struct obj_key *key;
1132 u32 devindex, index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
1133 u32 authen = 0, invoke = 0, exunencrypt = 0;
1137 /* first get the flags */
1138 rvalue = mgt_get_request(priv, DOT11_OID_AUTHENABLE, 0, NULL, &r);
1140 rvalue |= mgt_get_request(priv, DOT11_OID_PRIVACYINVOKED, 0, NULL, &r);
1142 rvalue |= mgt_get_request(priv, DOT11_OID_EXUNENCRYPTED, 0, NULL, &r);
1145 if (invoke && (authen == DOT11_AUTH_BOTH) && exunencrypt)
1146 dwrq->flags = IW_ENCODE_RESTRICTED;
1147 else if ((authen == DOT11_AUTH_OS) && !exunencrypt) {
1149 dwrq->flags = IW_ENCODE_OPEN;
1151 dwrq->flags = IW_ENCODE_DISABLED;
1153 /* The card should not work in this state */
1156 /* get the current device key index */
1157 rvalue |= mgt_get_request(priv, DOT11_OID_DEFKEYID, 0, NULL, &r);
1159 /* Now get the key, return it */
1160 if ((index < 0) || (index > 3))
1161 /* no index provided, use the current one */
1163 rvalue |= mgt_get_request(priv, DOT11_OID_DEFKEYX, index, NULL, &r);
1165 dwrq->length = key->length;
1166 memcpy(extra, key->key, dwrq->length);
1168 /* return the used key index */
1169 dwrq->flags |= devindex + 1;
1175 prism54_get_txpower(struct net_device *ndev, struct iw_request_info *info,
1176 struct iw_param *vwrq, char *extra)
1178 islpci_private *priv = netdev_priv(ndev);
1182 rvalue = mgt_get_request(priv, OID_INL_OUTPUTPOWER, 0, NULL, &r);
1183 /* intersil firmware operates in 0.25 dBm (1/4 dBm) */
1184 vwrq->value = (s32) r.u / 4;
1186 /* radio is not turned of
1187 * btw: how is possible to turn off only the radio
1195 prism54_set_txpower(struct net_device *ndev, struct iw_request_info *info,
1196 struct iw_param *vwrq, char *extra)
1198 islpci_private *priv = netdev_priv(ndev);
1199 s32 u = vwrq->value;
1201 /* intersil firmware operates in 0.25 dBm (1/4) */
1203 if (vwrq->disabled) {
1204 /* don't know how to disable radio */
1206 "%s: %s() disabling radio is not yet supported.\n",
1207 priv->ndev->name, __FUNCTION__);
1209 } else if (vwrq->fixed)
1210 /* currently only fixed value is supported */
1211 return mgt_set_request(priv, OID_INL_OUTPUTPOWER, 0, &u);
1214 "%s: %s() auto power will be implemented later.\n",
1215 priv->ndev->name, __FUNCTION__);
1220 static int prism54_set_genie(struct net_device *ndev,
1221 struct iw_request_info *info,
1222 struct iw_point *data, char *extra)
1224 islpci_private *priv = netdev_priv(ndev);
1226 struct obj_attachment *attach;
1228 if (data->length > MAX_WPA_IE_LEN ||
1229 (data->length && extra == NULL))
1232 memcpy(priv->wpa_ie, extra, data->length);
1233 priv->wpa_ie_len = data->length;
1235 alen = sizeof(*attach) + priv->wpa_ie_len;
1236 attach = kzalloc(alen, GFP_KERNEL);
1240 #define WLAN_FC_TYPE_MGMT 0
1241 #define WLAN_FC_STYPE_ASSOC_REQ 0
1242 #define WLAN_FC_STYPE_REASSOC_REQ 2
1244 /* Note: endianness is covered by mgt_set_varlen */
1245 attach->type = (WLAN_FC_TYPE_MGMT << 2) |
1246 (WLAN_FC_STYPE_ASSOC_REQ << 4);
1248 attach->size = priv->wpa_ie_len;
1249 memcpy(attach->data, extra, priv->wpa_ie_len);
1251 ret = mgt_set_varlen(priv, DOT11_OID_ATTACHMENT, attach,
1254 attach->type = (WLAN_FC_TYPE_MGMT << 2) |
1255 (WLAN_FC_STYPE_REASSOC_REQ << 4);
1257 ret = mgt_set_varlen(priv, DOT11_OID_ATTACHMENT, attach,
1260 printk(KERN_DEBUG "%s: WPA IE Attachment was set\n",
1269 static int prism54_get_genie(struct net_device *ndev,
1270 struct iw_request_info *info,
1271 struct iw_point *data, char *extra)
1273 islpci_private *priv = netdev_priv(ndev);
1274 int len = priv->wpa_ie_len;
1281 if (data->length < len)
1285 memcpy(extra, priv->wpa_ie, len);
1290 static int prism54_set_auth(struct net_device *ndev,
1291 struct iw_request_info *info,
1292 union iwreq_data *wrqu, char *extra)
1294 islpci_private *priv = netdev_priv(ndev);
1295 struct iw_param *param = &wrqu->param;
1296 u32 mlmelevel = 0, authen = 0, dot1x = 0;
1297 u32 exunencrypt = 0, privinvoked = 0, wpa = 0;
1302 if (islpci_get_state(priv) < PRV_STATE_INIT)
1305 /* first get the flags */
1306 down_write(&priv->mib_sem);
1307 wpa = old_wpa = priv->wpa;
1308 up_write(&priv->mib_sem);
1309 ret = mgt_get_request(priv, DOT11_OID_AUTHENABLE, 0, NULL, &r);
1311 ret = mgt_get_request(priv, DOT11_OID_PRIVACYINVOKED, 0, NULL, &r);
1313 ret = mgt_get_request(priv, DOT11_OID_EXUNENCRYPTED, 0, NULL, &r);
1315 ret = mgt_get_request(priv, DOT11_OID_DOT1XENABLE, 0, NULL, &r);
1317 ret = mgt_get_request(priv, DOT11_OID_MLMEAUTOLEVEL, 0, NULL, &r);
1323 switch (param->flags & IW_AUTH_INDEX) {
1324 case IW_AUTH_CIPHER_PAIRWISE:
1325 case IW_AUTH_CIPHER_GROUP:
1326 case IW_AUTH_KEY_MGMT:
1329 case IW_AUTH_WPA_ENABLED:
1330 /* Do the same thing as IW_AUTH_WPA_VERSION */
1333 privinvoked = 1; /* For privacy invoked */
1334 exunencrypt = 1; /* Filter out all unencrypted frames */
1335 dot1x = 0x01; /* To enable eap filter */
1336 mlmelevel = DOT11_MLME_EXTENDED;
1337 authen = DOT11_AUTH_OS; /* Only WEP uses _SK and _BOTH */
1341 exunencrypt = 0; /* Do not filter un-encrypted data */
1343 mlmelevel = DOT11_MLME_AUTO;
1347 case IW_AUTH_WPA_VERSION:
1348 if (param->value & IW_AUTH_WPA_VERSION_DISABLED) {
1351 exunencrypt = 0; /* Do not filter un-encrypted data */
1353 mlmelevel = DOT11_MLME_AUTO;
1355 if (param->value & IW_AUTH_WPA_VERSION_WPA)
1357 else if (param->value & IW_AUTH_WPA_VERSION_WPA2)
1359 privinvoked = 1; /* For privacy invoked */
1360 exunencrypt = 1; /* Filter out all unencrypted frames */
1361 dot1x = 0x01; /* To enable eap filter */
1362 mlmelevel = DOT11_MLME_EXTENDED;
1363 authen = DOT11_AUTH_OS; /* Only WEP uses _SK and _BOTH */
1367 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
1368 dot1x = param->value ? 1 : 0;
1371 case IW_AUTH_PRIVACY_INVOKED:
1372 privinvoked = param->value ? 1 : 0;
1374 case IW_AUTH_DROP_UNENCRYPTED:
1375 exunencrypt = param->value ? 1 : 0;
1378 case IW_AUTH_80211_AUTH_ALG:
1379 if (param->value & IW_AUTH_ALG_SHARED_KEY) {
1380 /* Only WEP uses _SK and _BOTH */
1385 authen = DOT11_AUTH_SK;
1386 } else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM) {
1387 authen = DOT11_AUTH_OS;
1398 /* Set all the values */
1399 down_write(&priv->mib_sem);
1401 up_write(&priv->mib_sem);
1402 mgt_set_request(priv, DOT11_OID_AUTHENABLE, 0, &authen);
1403 mgt_set_request(priv, DOT11_OID_PRIVACYINVOKED, 0, &privinvoked);
1404 mgt_set_request(priv, DOT11_OID_EXUNENCRYPTED, 0, &exunencrypt);
1405 mgt_set_request(priv, DOT11_OID_DOT1XENABLE, 0, &dot1x);
1406 mgt_set_request(priv, DOT11_OID_MLMEAUTOLEVEL, 0, &mlmelevel);
1412 static int prism54_get_auth(struct net_device *ndev,
1413 struct iw_request_info *info,
1414 union iwreq_data *wrqu, char *extra)
1416 islpci_private *priv = netdev_priv(ndev);
1417 struct iw_param *param = &wrqu->param;
1422 if (islpci_get_state(priv) < PRV_STATE_INIT)
1425 /* first get the flags */
1426 down_write(&priv->mib_sem);
1428 up_write(&priv->mib_sem);
1430 switch (param->flags & IW_AUTH_INDEX) {
1431 case IW_AUTH_CIPHER_PAIRWISE:
1432 case IW_AUTH_CIPHER_GROUP:
1433 case IW_AUTH_KEY_MGMT:
1435 * wpa_supplicant will control these internally
1440 case IW_AUTH_WPA_VERSION:
1443 param->value = IW_AUTH_WPA_VERSION_WPA;
1446 param->value = IW_AUTH_WPA_VERSION_WPA2;
1450 param->value = IW_AUTH_WPA_VERSION_DISABLED;
1455 case IW_AUTH_DROP_UNENCRYPTED:
1456 ret = mgt_get_request(priv, DOT11_OID_EXUNENCRYPTED, 0, NULL, &r);
1458 param->value = r.u > 0 ? 1 : 0;
1461 case IW_AUTH_80211_AUTH_ALG:
1462 ret = mgt_get_request(priv, DOT11_OID_AUTHENABLE, 0, NULL, &r);
1466 param->value = IW_AUTH_ALG_OPEN_SYSTEM;
1468 case DOT11_AUTH_BOTH:
1470 param->value = IW_AUTH_ALG_SHARED_KEY;
1471 case DOT11_AUTH_NONE:
1479 case IW_AUTH_WPA_ENABLED:
1480 param->value = wpa > 0 ? 1 : 0;
1483 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
1484 ret = mgt_get_request(priv, DOT11_OID_DOT1XENABLE, 0, NULL, &r);
1486 param->value = r.u > 0 ? 1 : 0;
1489 case IW_AUTH_PRIVACY_INVOKED:
1490 ret = mgt_get_request(priv, DOT11_OID_PRIVACYINVOKED, 0, NULL, &r);
1492 param->value = r.u > 0 ? 1 : 0;
1501 static int prism54_set_encodeext(struct net_device *ndev,
1502 struct iw_request_info *info,
1503 union iwreq_data *wrqu,
1506 islpci_private *priv = netdev_priv(ndev);
1507 struct iw_point *encoding = &wrqu->encoding;
1508 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
1509 int idx, alg = ext->alg, set_key = 1;
1511 int authen = DOT11_AUTH_OS, invoke = 0, exunencrypt = 0;
1514 if (islpci_get_state(priv) < PRV_STATE_INIT)
1517 /* Determine and validate the key index */
1518 idx = (encoding->flags & IW_ENCODE_INDEX) - 1;
1520 if (idx < 0 || idx > 3)
1523 ret = mgt_get_request(priv, DOT11_OID_DEFKEYID, 0, NULL, &r);
1529 if (encoding->flags & IW_ENCODE_DISABLED)
1530 alg = IW_ENCODE_ALG_NONE;
1532 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
1533 /* Only set transmit key index here, actual
1534 * key is set below if needed.
1536 ret = mgt_set_request(priv, DOT11_OID_DEFKEYID, 0, &idx);
1537 set_key = ext->key_len > 0 ? 1 : 0;
1541 struct obj_key key = { DOT11_PRIV_WEP, 0, "" };
1543 case IW_ENCODE_ALG_NONE:
1545 case IW_ENCODE_ALG_WEP:
1546 if (ext->key_len > KEY_SIZE_WEP104) {
1550 if (ext->key_len > KEY_SIZE_WEP40)
1551 key.length = KEY_SIZE_WEP104;
1553 key.length = KEY_SIZE_WEP40;
1555 case IW_ENCODE_ALG_TKIP:
1556 if (ext->key_len > KEY_SIZE_TKIP) {
1560 key.type = DOT11_PRIV_TKIP;
1561 key.length = KEY_SIZE_TKIP;
1567 memset(key.key, 0, sizeof(key.key));
1568 memcpy(key.key, ext->key, ext->key_len);
1569 ret = mgt_set_request(priv, DOT11_OID_DEFKEYX, idx,
1576 /* Read the flags */
1577 if (encoding->flags & IW_ENCODE_DISABLED) {
1578 /* Encoding disabled,
1579 * authen = DOT11_AUTH_OS;
1581 * exunencrypt = 0; */
1583 if (encoding->flags & IW_ENCODE_OPEN) {
1584 /* Encode but accept non-encoded packets. No auth */
1587 if (encoding->flags & IW_ENCODE_RESTRICTED) {
1588 /* Refuse non-encoded packets. Auth */
1589 authen = DOT11_AUTH_BOTH;
1594 /* do the change if requested */
1595 if (encoding->flags & IW_ENCODE_MODE) {
1596 ret = mgt_set_request(priv, DOT11_OID_AUTHENABLE, 0,
1598 ret = mgt_set_request(priv, DOT11_OID_PRIVACYINVOKED, 0,
1600 ret = mgt_set_request(priv, DOT11_OID_EXUNENCRYPTED, 0,
1609 static int prism54_get_encodeext(struct net_device *ndev,
1610 struct iw_request_info *info,
1611 union iwreq_data *wrqu,
1614 islpci_private *priv = netdev_priv(ndev);
1615 struct iw_point *encoding = &wrqu->encoding;
1616 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
1617 int idx, max_key_len;
1619 int authen = DOT11_AUTH_OS, invoke = 0, exunencrypt = 0, wpa = 0;
1622 if (islpci_get_state(priv) < PRV_STATE_INIT)
1625 /* first get the flags */
1626 ret = mgt_get_request(priv, DOT11_OID_AUTHENABLE, 0, NULL, &r);
1628 ret = mgt_get_request(priv, DOT11_OID_PRIVACYINVOKED, 0, NULL, &r);
1630 ret = mgt_get_request(priv, DOT11_OID_EXUNENCRYPTED, 0, NULL, &r);
1635 max_key_len = encoding->length - sizeof(*ext);
1636 if (max_key_len < 0)
1639 idx = (encoding->flags & IW_ENCODE_INDEX) - 1;
1641 if (idx < 0 || idx > 3)
1644 ret = mgt_get_request(priv, DOT11_OID_DEFKEYID, 0, NULL, &r);
1650 encoding->flags = idx + 1;
1651 memset(ext, 0, sizeof(*ext));
1654 case DOT11_AUTH_BOTH:
1656 wrqu->encoding.flags |= IW_ENCODE_RESTRICTED;
1659 wrqu->encoding.flags |= IW_ENCODE_OPEN;
1663 down_write(&priv->mib_sem);
1665 up_write(&priv->mib_sem);
1667 if (authen == DOT11_AUTH_OS && !exunencrypt && !invoke && !wpa) {
1669 ext->alg = IW_ENCODE_ALG_NONE;
1671 wrqu->encoding.flags |= IW_ENCODE_DISABLED;
1673 struct obj_key *key;
1675 ret = mgt_get_request(priv, DOT11_OID_DEFKEYX, idx, NULL, &r);
1679 if (max_key_len < key->length) {
1683 memcpy(ext->key, key->key, key->length);
1684 ext->key_len = key->length;
1686 switch (key->type) {
1687 case DOT11_PRIV_TKIP:
1688 ext->alg = IW_ENCODE_ALG_TKIP;
1691 case DOT11_PRIV_WEP:
1692 ext->alg = IW_ENCODE_ALG_WEP;
1695 wrqu->encoding.flags |= IW_ENCODE_ENABLED;
1704 prism54_reset(struct net_device *ndev, struct iw_request_info *info,
1705 __u32 * uwrq, char *extra)
1707 islpci_reset(netdev_priv(ndev), 0);
1713 prism54_get_oid(struct net_device *ndev, struct iw_request_info *info,
1714 struct iw_point *dwrq, char *extra)
1718 enum oid_num_t n = dwrq->flags;
1720 rvalue = mgt_get_request((islpci_private *) ndev->priv, n, 0, NULL, &r);
1721 dwrq->length = mgt_response_to_str(n, &r, extra);
1722 if ((isl_oid[n].flags & OID_FLAG_TYPE) != OID_TYPE_U32)
1728 prism54_set_u32(struct net_device *ndev, struct iw_request_info *info,
1729 __u32 * uwrq, char *extra)
1731 u32 oid = uwrq[0], u = uwrq[1];
1733 return mgt_set_request((islpci_private *) ndev->priv, oid, 0, &u);
1737 prism54_set_raw(struct net_device *ndev, struct iw_request_info *info,
1738 struct iw_point *dwrq, char *extra)
1740 u32 oid = dwrq->flags;
1742 return mgt_set_request((islpci_private *) ndev->priv, oid, 0, extra);
1746 prism54_acl_init(struct islpci_acl *acl)
1748 sema_init(&acl->sem, 1);
1749 INIT_LIST_HEAD(&acl->mac_list);
1751 acl->policy = MAC_POLICY_OPEN;
1755 prism54_clear_mac(struct islpci_acl *acl)
1757 struct list_head *ptr, *next;
1758 struct mac_entry *entry;
1760 if (down_interruptible(&acl->sem))
1763 if (acl->size == 0) {
1768 for (ptr = acl->mac_list.next, next = ptr->next;
1769 ptr != &acl->mac_list; ptr = next, next = ptr->next) {
1770 entry = list_entry(ptr, struct mac_entry, _list);
1779 prism54_acl_clean(struct islpci_acl *acl)
1781 prism54_clear_mac(acl);
1785 prism54_add_mac(struct net_device *ndev, struct iw_request_info *info,
1786 struct sockaddr *awrq, char *extra)
1788 islpci_private *priv = netdev_priv(ndev);
1789 struct islpci_acl *acl = &priv->acl;
1790 struct mac_entry *entry;
1791 struct sockaddr *addr = (struct sockaddr *) extra;
1793 if (addr->sa_family != ARPHRD_ETHER)
1796 entry = kmalloc(sizeof (struct mac_entry), GFP_KERNEL);
1800 memcpy(entry->addr, addr->sa_data, ETH_ALEN);
1802 if (down_interruptible(&acl->sem)) {
1804 return -ERESTARTSYS;
1806 list_add_tail(&entry->_list, &acl->mac_list);
1814 prism54_del_mac(struct net_device *ndev, struct iw_request_info *info,
1815 struct sockaddr *awrq, char *extra)
1817 islpci_private *priv = netdev_priv(ndev);
1818 struct islpci_acl *acl = &priv->acl;
1819 struct mac_entry *entry;
1820 struct list_head *ptr;
1821 struct sockaddr *addr = (struct sockaddr *) extra;
1823 if (addr->sa_family != ARPHRD_ETHER)
1826 if (down_interruptible(&acl->sem))
1827 return -ERESTARTSYS;
1828 for (ptr = acl->mac_list.next; ptr != &acl->mac_list; ptr = ptr->next) {
1829 entry = list_entry(ptr, struct mac_entry, _list);
1831 if (memcmp(entry->addr, addr->sa_data, ETH_ALEN) == 0) {
1844 prism54_get_mac(struct net_device *ndev, struct iw_request_info *info,
1845 struct iw_point *dwrq, char *extra)
1847 islpci_private *priv = netdev_priv(ndev);
1848 struct islpci_acl *acl = &priv->acl;
1849 struct mac_entry *entry;
1850 struct list_head *ptr;
1851 struct sockaddr *dst = (struct sockaddr *) extra;
1855 if (down_interruptible(&acl->sem))
1856 return -ERESTARTSYS;
1858 for (ptr = acl->mac_list.next; ptr != &acl->mac_list; ptr = ptr->next) {
1859 entry = list_entry(ptr, struct mac_entry, _list);
1861 memcpy(dst->sa_data, entry->addr, ETH_ALEN);
1862 dst->sa_family = ARPHRD_ETHER;
1870 /* Setting policy also clears the MAC acl, even if we don't change the defaut
1875 prism54_set_policy(struct net_device *ndev, struct iw_request_info *info,
1876 __u32 * uwrq, char *extra)
1878 islpci_private *priv = netdev_priv(ndev);
1879 struct islpci_acl *acl = &priv->acl;
1882 prism54_clear_mac(acl);
1884 if ((*uwrq < MAC_POLICY_OPEN) || (*uwrq > MAC_POLICY_REJECT))
1887 down_write(&priv->mib_sem);
1889 acl->policy = *uwrq;
1891 /* the ACL code needs an intermediate mlmeautolevel */
1892 if ((priv->iw_mode == IW_MODE_MASTER) &&
1893 (acl->policy != MAC_POLICY_OPEN))
1894 mlmeautolevel = DOT11_MLME_INTERMEDIATE;
1896 mlmeautolevel = CARD_DEFAULT_MLME_MODE;
1898 mlmeautolevel = DOT11_MLME_EXTENDED;
1899 mgt_set(priv, DOT11_OID_MLMEAUTOLEVEL, &mlmeautolevel);
1900 /* restart the card with our new policy */
1901 if (mgt_commit(priv)) {
1902 up_write(&priv->mib_sem);
1905 up_write(&priv->mib_sem);
1911 prism54_get_policy(struct net_device *ndev, struct iw_request_info *info,
1912 __u32 * uwrq, char *extra)
1914 islpci_private *priv = netdev_priv(ndev);
1915 struct islpci_acl *acl = &priv->acl;
1917 *uwrq = acl->policy;
1922 /* Return 1 only if client should be accepted. */
1925 prism54_mac_accept(struct islpci_acl *acl, char *mac)
1927 struct list_head *ptr;
1928 struct mac_entry *entry;
1931 if (down_interruptible(&acl->sem))
1932 return -ERESTARTSYS;
1934 if (acl->policy == MAC_POLICY_OPEN) {
1939 for (ptr = acl->mac_list.next; ptr != &acl->mac_list; ptr = ptr->next) {
1940 entry = list_entry(ptr, struct mac_entry, _list);
1941 if (memcmp(entry->addr, mac, ETH_ALEN) == 0) {
1946 res = (acl->policy == MAC_POLICY_ACCEPT) ? !res : res;
1953 prism54_kick_all(struct net_device *ndev, struct iw_request_info *info,
1954 struct iw_point *dwrq, char *extra)
1956 struct obj_mlme *mlme;
1959 mlme = kmalloc(sizeof (struct obj_mlme), GFP_KERNEL);
1963 /* Tell the card to kick every client */
1966 mgt_set_request(netdev_priv(ndev), DOT11_OID_DISASSOCIATE, 0, mlme);
1973 prism54_kick_mac(struct net_device *ndev, struct iw_request_info *info,
1974 struct sockaddr *awrq, char *extra)
1976 struct obj_mlme *mlme;
1977 struct sockaddr *addr = (struct sockaddr *) extra;
1980 if (addr->sa_family != ARPHRD_ETHER)
1983 mlme = kmalloc(sizeof (struct obj_mlme), GFP_KERNEL);
1987 /* Tell the card to only kick the corresponding bastard */
1988 memcpy(mlme->address, addr->sa_data, ETH_ALEN);
1991 mgt_set_request(netdev_priv(ndev), DOT11_OID_DISASSOCIATE, 0, mlme);
1998 /* Translate a TRAP oid into a wireless event. Called in islpci_mgt_receive. */
2001 format_event(islpci_private *priv, char *dest, const char *str,
2002 const struct obj_mlme *mlme, u16 *length, int error)
2004 const u8 *a = mlme->address;
2005 int n = snprintf(dest, IW_CUSTOM_MAX,
2006 "%s %s %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X %s (%2.2X)",
2008 ((priv->iw_mode == IW_MODE_MASTER) ? "from" : "to"),
2009 a[0], a[1], a[2], a[3], a[4], a[5],
2010 (error ? (mlme->code ? " : REJECTED " : " : ACCEPTED ")
2012 BUG_ON(n > IW_CUSTOM_MAX);
2017 send_formatted_event(islpci_private *priv, const char *str,
2018 const struct obj_mlme *mlme, int error)
2020 union iwreq_data wrqu;
2023 memptr = kmalloc(IW_CUSTOM_MAX, GFP_KERNEL);
2026 wrqu.data.pointer = memptr;
2027 wrqu.data.length = 0;
2028 format_event(priv, memptr, str, mlme, &wrqu.data.length,
2030 wireless_send_event(priv->ndev, IWEVCUSTOM, &wrqu, memptr);
2035 send_simple_event(islpci_private *priv, const char *str)
2037 union iwreq_data wrqu;
2039 int n = strlen(str);
2041 memptr = kmalloc(IW_CUSTOM_MAX, GFP_KERNEL);
2044 BUG_ON(n > IW_CUSTOM_MAX);
2045 wrqu.data.pointer = memptr;
2046 wrqu.data.length = n;
2047 strcpy(memptr, str);
2048 wireless_send_event(priv->ndev, IWEVCUSTOM, &wrqu, memptr);
2053 link_changed(struct net_device *ndev, u32 bitrate)
2055 islpci_private *priv = netdev_priv(ndev);
2058 if (priv->iw_mode == IW_MODE_INFRA) {
2059 union iwreq_data uwrq;
2060 prism54_get_wap(ndev, NULL, (struct sockaddr *) &uwrq,
2062 wireless_send_event(ndev, SIOCGIWAP, &uwrq, NULL);
2064 send_simple_event(netdev_priv(ndev),
2065 "Link established");
2067 send_simple_event(netdev_priv(ndev), "Link lost");
2070 /* Beacon/ProbeResp payload header */
2071 struct ieee80211_beacon_phdr {
2075 } __attribute__ ((packed));
2077 #define WLAN_EID_GENERIC 0xdd
2078 static u8 wpa_oid[4] = { 0x00, 0x50, 0xf2, 1 };
2080 #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
2081 #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
2084 prism54_wpa_bss_ie_add(islpci_private *priv, u8 *bssid,
2085 u8 *wpa_ie, size_t wpa_ie_len)
2087 struct list_head *ptr;
2088 struct islpci_bss_wpa_ie *bss = NULL;
2090 if (wpa_ie_len > MAX_WPA_IE_LEN)
2091 wpa_ie_len = MAX_WPA_IE_LEN;
2093 if (down_interruptible(&priv->wpa_sem))
2096 /* try to use existing entry */
2097 list_for_each(ptr, &priv->bss_wpa_list) {
2098 bss = list_entry(ptr, struct islpci_bss_wpa_ie, list);
2099 if (memcmp(bss->bssid, bssid, ETH_ALEN) == 0) {
2100 list_move(&bss->list, &priv->bss_wpa_list);
2107 /* add a new BSS entry; if max number of entries is already
2108 * reached, replace the least recently updated */
2109 if (priv->num_bss_wpa >= MAX_BSS_WPA_IE_COUNT) {
2110 bss = list_entry(priv->bss_wpa_list.prev,
2111 struct islpci_bss_wpa_ie, list);
2112 list_del(&bss->list);
2114 bss = kmalloc(sizeof (*bss), GFP_ATOMIC);
2116 priv->num_bss_wpa++;
2117 memset(bss, 0, sizeof (*bss));
2121 memcpy(bss->bssid, bssid, ETH_ALEN);
2122 list_add(&bss->list, &priv->bss_wpa_list);
2127 memcpy(bss->wpa_ie, wpa_ie, wpa_ie_len);
2128 bss->wpa_ie_len = wpa_ie_len;
2129 bss->last_update = jiffies;
2131 printk(KERN_DEBUG "Failed to add BSS WPA entry for " MACSTR
2132 "\n", MAC2STR(bssid));
2135 /* expire old entries from WPA list */
2136 while (priv->num_bss_wpa > 0) {
2137 bss = list_entry(priv->bss_wpa_list.prev,
2138 struct islpci_bss_wpa_ie, list);
2139 if (!time_after(jiffies, bss->last_update + 60 * HZ))
2142 list_del(&bss->list);
2143 priv->num_bss_wpa--;
2151 prism54_wpa_bss_ie_get(islpci_private *priv, u8 *bssid, u8 *wpa_ie)
2153 struct list_head *ptr;
2154 struct islpci_bss_wpa_ie *bss = NULL;
2157 if (down_interruptible(&priv->wpa_sem))
2160 list_for_each(ptr, &priv->bss_wpa_list) {
2161 bss = list_entry(ptr, struct islpci_bss_wpa_ie, list);
2162 if (memcmp(bss->bssid, bssid, ETH_ALEN) == 0)
2167 len = bss->wpa_ie_len;
2168 memcpy(wpa_ie, bss->wpa_ie, len);
2176 prism54_wpa_bss_ie_init(islpci_private *priv)
2178 INIT_LIST_HEAD(&priv->bss_wpa_list);
2179 sema_init(&priv->wpa_sem, 1);
2183 prism54_wpa_bss_ie_clean(islpci_private *priv)
2185 struct list_head *ptr, *n;
2187 list_for_each_safe(ptr, n, &priv->bss_wpa_list) {
2188 struct islpci_bss_wpa_ie *bss;
2189 bss = list_entry(ptr, struct islpci_bss_wpa_ie, list);
2195 prism54_process_bss_data(islpci_private *priv, u32 oid, u8 *addr,
2196 u8 *payload, size_t len)
2198 struct ieee80211_beacon_phdr *hdr;
2204 hdr = (struct ieee80211_beacon_phdr *) payload;
2205 pos = (u8 *) (hdr + 1);
2206 end = payload + len;
2208 if (pos + 2 + pos[1] > end) {
2209 printk(KERN_DEBUG "Parsing Beacon/ProbeResp failed "
2210 "for " MACSTR "\n", MAC2STR(addr));
2213 if (pos[0] == WLAN_EID_GENERIC && pos[1] >= 4 &&
2214 memcmp(pos + 2, wpa_oid, 4) == 0) {
2215 prism54_wpa_bss_ie_add(priv, addr, pos, pos[1] + 2);
2223 handle_request(islpci_private *priv, struct obj_mlme *mlme, enum oid_num_t oid)
2225 if (((mlme->state == DOT11_STATE_AUTHING) ||
2226 (mlme->state == DOT11_STATE_ASSOCING))
2227 && mgt_mlme_answer(priv)) {
2228 /* Someone is requesting auth and we must respond. Just send back
2229 * the trap with error code set accordingly.
2231 mlme->code = prism54_mac_accept(&priv->acl,
2232 mlme->address) ? 0 : 1;
2233 mgt_set_request(priv, oid, 0, mlme);
2238 prism54_process_trap_helper(islpci_private *priv, enum oid_num_t oid,
2241 struct obj_mlme *mlme = (struct obj_mlme *) data;
2242 struct obj_mlmeex *mlmeex = (struct obj_mlmeex *) data;
2243 struct obj_mlmeex *confirm;
2244 u8 wpa_ie[MAX_WPA_IE_LEN];
2246 size_t len = 0; /* u16, better? */
2247 u8 *payload = NULL, *pos = NULL;
2250 /* I think all trapable objects are listed here.
2251 * Some oids have a EX version. The difference is that they are emitted
2252 * in DOT11_MLME_EXTENDED mode (set with DOT11_OID_MLMEAUTOLEVEL)
2254 * The few events already defined by the wireless tools are not really
2255 * suited. We use the more flexible custom event facility.
2258 if (oid >= DOT11_OID_BEACON) {
2260 payload = pos = mlmeex->data;
2263 /* I fear prism54_process_bss_data won't work with big endian data */
2264 if ((oid == DOT11_OID_BEACON) || (oid == DOT11_OID_PROBE))
2265 prism54_process_bss_data(priv, oid, mlmeex->address,
2268 mgt_le_to_cpu(isl_oid[oid].flags & OID_FLAG_TYPE, (void *) mlme);
2272 case GEN_OID_LINKSTATE:
2273 link_changed(priv->ndev, (u32) *data);
2276 case DOT11_OID_MICFAILURE:
2277 send_simple_event(priv, "Mic failure");
2280 case DOT11_OID_DEAUTHENTICATE:
2281 send_formatted_event(priv, "DeAuthenticate request", mlme, 0);
2284 case DOT11_OID_AUTHENTICATE:
2285 handle_request(priv, mlme, oid);
2286 send_formatted_event(priv, "Authenticate request", mlme, 1);
2289 case DOT11_OID_DISASSOCIATE:
2290 send_formatted_event(priv, "Disassociate request", mlme, 0);
2293 case DOT11_OID_ASSOCIATE:
2294 handle_request(priv, mlme, oid);
2295 send_formatted_event(priv, "Associate request", mlme, 1);
2298 case DOT11_OID_REASSOCIATE:
2299 handle_request(priv, mlme, oid);
2300 send_formatted_event(priv, "ReAssociate request", mlme, 1);
2303 case DOT11_OID_BEACON:
2304 send_formatted_event(priv,
2305 "Received a beacon from an unkown AP",
2309 case DOT11_OID_PROBE:
2310 /* we received a probe from a client. */
2311 send_formatted_event(priv, "Received a probe from client", mlme,
2315 /* Note : "mlme" is actually a "struct obj_mlmeex *" here, but this
2316 * is backward compatible layout-wise with "struct obj_mlme".
2319 case DOT11_OID_DEAUTHENTICATEEX:
2320 send_formatted_event(priv, "DeAuthenticate request", mlme, 0);
2323 case DOT11_OID_AUTHENTICATEEX:
2324 handle_request(priv, mlme, oid);
2325 send_formatted_event(priv, "Authenticate request (ex)", mlme, 1);
2327 if (priv->iw_mode != IW_MODE_MASTER
2328 && mlmeex->state != DOT11_STATE_AUTHING)
2331 confirm = kmalloc(sizeof(struct obj_mlmeex) + 6, GFP_ATOMIC);
2336 memcpy(&confirm->address, mlmeex->address, ETH_ALEN);
2337 printk(KERN_DEBUG "Authenticate from: address:\t%02x:%02x:%02x:%02x:%02x:%02x\n",
2345 confirm->id = -1; /* or mlmeex->id ? */
2346 confirm->state = 0; /* not used */
2349 confirm->data[0] = 0x00;
2350 confirm->data[1] = 0x00;
2351 confirm->data[2] = 0x02;
2352 confirm->data[3] = 0x00;
2353 confirm->data[4] = 0x00;
2354 confirm->data[5] = 0x00;
2356 ret = mgt_set_varlen(priv, DOT11_OID_ASSOCIATEEX, confirm, 6);
2363 case DOT11_OID_DISASSOCIATEEX:
2364 send_formatted_event(priv, "Disassociate request (ex)", mlme, 0);
2367 case DOT11_OID_ASSOCIATEEX:
2368 handle_request(priv, mlme, oid);
2369 send_formatted_event(priv, "Associate request (ex)", mlme, 1);
2371 if (priv->iw_mode != IW_MODE_MASTER
2372 && mlmeex->state != DOT11_STATE_ASSOCING)
2375 confirm = kmalloc(sizeof(struct obj_mlmeex), GFP_ATOMIC);
2380 memcpy(&confirm->address, mlmeex->address, ETH_ALEN);
2382 confirm->id = ((struct obj_mlmeex *)mlme)->id;
2383 confirm->state = 0; /* not used */
2386 wpa_ie_len = prism54_wpa_bss_ie_get(priv, mlmeex->address, wpa_ie);
2389 printk(KERN_DEBUG "No WPA IE found from "
2390 "address:\t%02x:%02x:%02x:%02x:%02x:%02x\n",
2402 confirm->size = wpa_ie_len;
2403 memcpy(&confirm->data, wpa_ie, wpa_ie_len);
2405 mgt_set_varlen(priv, oid, confirm, wpa_ie_len);
2411 case DOT11_OID_REASSOCIATEEX:
2412 handle_request(priv, mlme, oid);
2413 send_formatted_event(priv, "Reassociate request (ex)", mlme, 1);
2415 if (priv->iw_mode != IW_MODE_MASTER
2416 && mlmeex->state != DOT11_STATE_ASSOCING)
2419 confirm = kmalloc(sizeof(struct obj_mlmeex), GFP_ATOMIC);
2424 memcpy(&confirm->address, mlmeex->address, ETH_ALEN);
2426 confirm->id = mlmeex->id;
2427 confirm->state = 0; /* not used */
2430 wpa_ie_len = prism54_wpa_bss_ie_get(priv, mlmeex->address, wpa_ie);
2433 printk(KERN_DEBUG "No WPA IE found from "
2434 "address:\t%02x:%02x:%02x:%02x:%02x:%02x\n",
2446 confirm->size = wpa_ie_len;
2447 memcpy(&confirm->data, wpa_ie, wpa_ie_len);
2449 mgt_set_varlen(priv, oid, confirm, wpa_ie_len);
2463 * Process a device trap. This is called via schedule_work(), outside of
2464 * interrupt context, no locks held.
2467 prism54_process_trap(void *data)
2469 struct islpci_mgmtframe *frame = data;
2470 struct net_device *ndev = frame->ndev;
2471 enum oid_num_t n = mgt_oidtonum(frame->header->oid);
2473 if (n != OID_NUM_LAST)
2474 prism54_process_trap_helper(netdev_priv(ndev), n, frame->data);
2475 islpci_mgt_release(frame);
2479 prism54_set_mac_address(struct net_device *ndev, void *addr)
2481 islpci_private *priv = netdev_priv(ndev);
2484 if (ndev->addr_len != 6)
2486 ret = mgt_set_request(priv, GEN_OID_MACADDRESS, 0,
2487 &((struct sockaddr *) addr)->sa_data);
2489 memcpy(priv->ndev->dev_addr,
2490 &((struct sockaddr *) addr)->sa_data, 6);
2495 /* Note: currently, use hostapd ioctl from the Host AP driver for WPA
2496 * support. This is to be replaced with Linux wireless extensions once they
2497 * get WPA support. */
2499 /* Note II: please leave all this together as it will be easier to remove later,
2500 * once wireless extensions add WPA support -mcgrof */
2502 /* PRISM54_HOSTAPD ioctl() cmd: */
2504 PRISM2_SET_ENCRYPTION = 6,
2505 PRISM2_HOSTAPD_SET_GENERIC_ELEMENT = 12,
2506 PRISM2_HOSTAPD_MLME = 13,
2507 PRISM2_HOSTAPD_SCAN_REQ = 14,
2510 #define PRISM54_SET_WPA SIOCIWFIRSTPRIV+12
2511 #define PRISM54_HOSTAPD SIOCIWFIRSTPRIV+25
2512 #define PRISM54_DROP_UNENCRYPTED SIOCIWFIRSTPRIV+26
2514 #define PRISM2_HOSTAPD_MAX_BUF_SIZE 1024
2515 #define PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN \
2516 ((int) (&((struct prism2_hostapd_param *) 0)->u.generic_elem.data))
2518 /* Maximum length for algorithm names (-1 for nul termination)
2519 * used in ioctl() */
2520 #define HOSTAP_CRYPT_ALG_NAME_LEN 16
2522 struct prism2_hostapd_param {
2524 u8 sta_addr[ETH_ALEN];
2527 u8 alg[HOSTAP_CRYPT_ALG_NAME_LEN];
2531 u8 seq[8]; /* sequence counter (set: RX, get: TX) */
2540 #define MLME_STA_DEAUTH 0
2541 #define MLME_STA_DISASSOC 1
2554 prism2_ioctl_set_encryption(struct net_device *dev,
2555 struct prism2_hostapd_param *param,
2558 islpci_private *priv = netdev_priv(dev);
2559 int rvalue = 0, force = 0;
2560 int authen = DOT11_AUTH_OS, invoke = 0, exunencrypt = 0;
2563 /* with the new API, it's impossible to get a NULL pointer.
2564 * New version of iwconfig set the IW_ENCODE_NOKEY flag
2565 * when no key is given, but older versions don't. */
2567 if (param->u.crypt.key_len > 0) {
2568 /* we have a key to set */
2569 int index = param->u.crypt.idx;
2571 struct obj_key key = { DOT11_PRIV_TKIP, 0, "" };
2573 /* get the current key index */
2574 rvalue = mgt_get_request(priv, DOT11_OID_DEFKEYID, 0, NULL, &r);
2575 current_index = r.u;
2576 /* Verify that the key is not marked as invalid */
2577 if (!(param->u.crypt.flags & IW_ENCODE_NOKEY)) {
2578 key.length = param->u.crypt.key_len > sizeof (param->u.crypt.key) ?
2579 sizeof (param->u.crypt.key) : param->u.crypt.key_len;
2580 memcpy(key.key, param->u.crypt.key, key.length);
2581 if (key.length == 32)
2582 /* we want WPA-PSK */
2583 key.type = DOT11_PRIV_TKIP;
2584 if ((index < 0) || (index > 3))
2585 /* no index provided use the current one */
2586 index = current_index;
2588 /* now send the key to the card */
2590 mgt_set_request(priv, DOT11_OID_DEFKEYX, index,
2594 * If a valid key is set, encryption should be enabled
2595 * (user may turn it off later).
2596 * This is also how "iwconfig ethX key on" works
2598 if ((index == current_index) && (key.length > 0))
2601 int index = (param->u.crypt.flags & IW_ENCODE_INDEX) - 1;
2602 if ((index >= 0) && (index <= 3)) {
2603 /* we want to set the key index */
2605 mgt_set_request(priv, DOT11_OID_DEFKEYID, 0,
2608 if (!param->u.crypt.flags & IW_ENCODE_MODE) {
2609 /* we cannot do anything. Complain. */
2614 /* now read the flags */
2615 if (param->u.crypt.flags & IW_ENCODE_DISABLED) {
2616 /* Encoding disabled,
2617 * authen = DOT11_AUTH_OS;
2619 * exunencrypt = 0; */
2621 if (param->u.crypt.flags & IW_ENCODE_OPEN)
2622 /* Encode but accept non-encoded packets. No auth */
2624 if ((param->u.crypt.flags & IW_ENCODE_RESTRICTED) || force) {
2625 /* Refuse non-encoded packets. Auth */
2626 authen = DOT11_AUTH_BOTH;
2630 /* do the change if requested */
2631 if ((param->u.crypt.flags & IW_ENCODE_MODE) || force) {
2633 mgt_set_request(priv, DOT11_OID_AUTHENABLE, 0, &authen);
2635 mgt_set_request(priv, DOT11_OID_PRIVACYINVOKED, 0, &invoke);
2637 mgt_set_request(priv, DOT11_OID_EXUNENCRYPTED, 0,
2644 prism2_ioctl_set_generic_element(struct net_device *ndev,
2645 struct prism2_hostapd_param *param,
2648 islpci_private *priv = netdev_priv(ndev);
2649 int max_len, len, alen, ret=0;
2650 struct obj_attachment *attach;
2652 len = param->u.generic_elem.len;
2653 max_len = param_len - PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN;
2654 if (max_len < 0 || max_len < len)
2657 alen = sizeof(*attach) + len;
2658 attach = kmalloc(alen, GFP_KERNEL);
2662 memset(attach, 0, alen);
2663 #define WLAN_FC_TYPE_MGMT 0
2664 #define WLAN_FC_STYPE_ASSOC_REQ 0
2665 #define WLAN_FC_STYPE_REASSOC_REQ 2
2667 /* Note: endianness is covered by mgt_set_varlen */
2669 attach->type = (WLAN_FC_TYPE_MGMT << 2) |
2670 (WLAN_FC_STYPE_ASSOC_REQ << 4);
2673 memcpy(attach->data, param->u.generic_elem.data, len);
2675 ret = mgt_set_varlen(priv, DOT11_OID_ATTACHMENT, attach, len);
2678 attach->type = (WLAN_FC_TYPE_MGMT << 2) |
2679 (WLAN_FC_STYPE_REASSOC_REQ << 4);
2681 ret = mgt_set_varlen(priv, DOT11_OID_ATTACHMENT, attach, len);
2684 printk(KERN_DEBUG "%s: WPA IE Attachment was set\n",
2694 prism2_ioctl_mlme(struct net_device *dev, struct prism2_hostapd_param *param)
2700 prism2_ioctl_scan_req(struct net_device *ndev,
2701 struct prism2_hostapd_param *param)
2703 islpci_private *priv = netdev_priv(ndev);
2705 struct obj_bsslist *bsslist;
2708 char *current_ev = "foo";
2711 if (islpci_get_state(priv) < PRV_STATE_INIT) {
2712 /* device is not ready, fail gently */
2716 /* first get the noise value. We will use it to report the link quality */
2717 rvalue = mgt_get_request(priv, DOT11_OID_NOISEFLOOR, 0, NULL, &r);
2720 /* Ask the device for a list of known bss. We can report at most
2721 * IW_MAX_AP=64 to the range struct. But the device won't repport anything
2722 * if you change the value of IWMAX_BSS=24.
2724 rvalue |= mgt_get_request(priv, DOT11_OID_BSSLIST, 0, NULL, &r);
2727 /* ok now, scan the list and translate its info */
2728 for (i = 0; i < min(IW_MAX_AP, (int) bsslist->nr); i++)
2729 current_ev = prism54_translate_bss(ndev, current_ev,
2730 extra + IW_SCAN_MAX_DATA,
2731 &(bsslist->bsslist[i]),
2739 prism54_hostapd(struct net_device *ndev, struct iw_point *p)
2741 struct prism2_hostapd_param *param;
2745 printk(KERN_DEBUG "prism54_hostapd - len=%d\n", p->length);
2746 if (p->length < sizeof(struct prism2_hostapd_param) ||
2747 p->length > PRISM2_HOSTAPD_MAX_BUF_SIZE || !p->pointer)
2750 param = (struct prism2_hostapd_param *) kmalloc(p->length, GFP_KERNEL);
2754 if (copy_from_user(param, p->pointer, p->length)) {
2759 switch (param->cmd) {
2760 case PRISM2_SET_ENCRYPTION:
2761 printk(KERN_DEBUG "%s: Caught WPA supplicant set encryption request\n",
2763 ret = prism2_ioctl_set_encryption(ndev, param, p->length);
2765 case PRISM2_HOSTAPD_SET_GENERIC_ELEMENT:
2766 printk(KERN_DEBUG "%s: Caught WPA supplicant set WPA IE request\n",
2768 ret = prism2_ioctl_set_generic_element(ndev, param,
2771 case PRISM2_HOSTAPD_MLME:
2772 printk(KERN_DEBUG "%s: Caught WPA supplicant MLME request\n",
2774 ret = prism2_ioctl_mlme(ndev, param);
2776 case PRISM2_HOSTAPD_SCAN_REQ:
2777 printk(KERN_DEBUG "%s: Caught WPA supplicant scan request\n",
2779 ret = prism2_ioctl_scan_req(ndev, param);
2781 case PRISM54_SET_WPA:
2782 printk(KERN_DEBUG "%s: Caught WPA supplicant wpa init request\n",
2785 ret = prism54_set_wpa(ndev, NULL, &uwrq, NULL);
2787 case PRISM54_DROP_UNENCRYPTED:
2788 printk(KERN_DEBUG "%s: Caught WPA drop unencrypted request\n",
2792 mgt_set(priv, DOT11_OID_EXUNENCRYPTED, &uwrq);
2793 down_write(&priv->mib_sem);
2795 up_write(&priv->mib_sem);
2797 /* Not necessary, as set_wpa does it, should we just do it here though? */
2801 printk(KERN_DEBUG "%s: Caught a WPA supplicant request that is not supported\n",
2807 if (ret == 0 && copy_to_user(p->pointer, param, p->length))
2816 prism54_set_wpa(struct net_device *ndev, struct iw_request_info *info,
2817 __u32 * uwrq, char *extra)
2819 islpci_private *priv = netdev_priv(ndev);
2820 u32 mlme, authen, dot1x, filter, wep;
2822 if (islpci_get_state(priv) < PRV_STATE_INIT)
2825 wep = 1; /* For privacy invoked */
2826 filter = 1; /* Filter out all unencrypted frames */
2827 dot1x = 0x01; /* To enable eap filter */
2828 mlme = DOT11_MLME_EXTENDED;
2829 authen = DOT11_AUTH_OS; /* Only WEP uses _SK and _BOTH */
2831 down_write(&priv->mib_sem);
2834 switch (priv->wpa) {
2836 case 0: /* Clears/disables WPA and friends */
2838 filter = 0; /* Do not filter un-encrypted data */
2840 mlme = DOT11_MLME_AUTO;
2841 printk("%s: Disabling WPA\n", ndev->name);
2845 printk("%s: Enabling WPA\n", ndev->name);
2848 up_write(&priv->mib_sem);
2850 mgt_set_request(priv, DOT11_OID_AUTHENABLE, 0, &authen);
2851 mgt_set_request(priv, DOT11_OID_PRIVACYINVOKED, 0, &wep);
2852 mgt_set_request(priv, DOT11_OID_EXUNENCRYPTED, 0, &filter);
2853 mgt_set_request(priv, DOT11_OID_DOT1XENABLE, 0, &dot1x);
2854 mgt_set_request(priv, DOT11_OID_MLMEAUTOLEVEL, 0, &mlme);
2860 prism54_get_wpa(struct net_device *ndev, struct iw_request_info *info,
2861 __u32 * uwrq, char *extra)
2863 islpci_private *priv = netdev_priv(ndev);
2869 prism54_set_prismhdr(struct net_device *ndev, struct iw_request_info *info,
2870 __u32 * uwrq, char *extra)
2872 islpci_private *priv = netdev_priv(ndev);
2873 priv->monitor_type =
2874 (*uwrq ? ARPHRD_IEEE80211_PRISM : ARPHRD_IEEE80211);
2875 if (priv->iw_mode == IW_MODE_MONITOR)
2876 priv->ndev->type = priv->monitor_type;
2882 prism54_get_prismhdr(struct net_device *ndev, struct iw_request_info *info,
2883 __u32 * uwrq, char *extra)
2885 islpci_private *priv = netdev_priv(ndev);
2886 *uwrq = (priv->monitor_type == ARPHRD_IEEE80211_PRISM);
2891 prism54_debug_oid(struct net_device *ndev, struct iw_request_info *info,
2892 __u32 * uwrq, char *extra)
2894 islpci_private *priv = netdev_priv(ndev);
2896 priv->priv_oid = *uwrq;
2897 printk("%s: oid 0x%08X\n", ndev->name, *uwrq);
2903 prism54_debug_get_oid(struct net_device *ndev, struct iw_request_info *info,
2904 struct iw_point *data, char *extra)
2906 islpci_private *priv = netdev_priv(ndev);
2907 struct islpci_mgmtframe *response;
2910 printk("%s: get_oid 0x%08X\n", ndev->name, priv->priv_oid);
2913 if (islpci_get_state(priv) >= PRV_STATE_INIT) {
2915 islpci_mgt_transaction(priv->ndev, PIMFOR_OP_GET,
2916 priv->priv_oid, extra, 256,
2918 printk("%s: ret: %i\n", ndev->name, ret);
2919 if (ret || !response
2920 || response->header->operation == PIMFOR_OP_ERROR) {
2922 islpci_mgt_release(response);
2924 printk("%s: EIO\n", ndev->name);
2928 data->length = response->header->length;
2929 memcpy(extra, response->data, data->length);
2930 islpci_mgt_release(response);
2931 printk("%s: len: %i\n", ndev->name, data->length);
2939 prism54_debug_set_oid(struct net_device *ndev, struct iw_request_info *info,
2940 struct iw_point *data, char *extra)
2942 islpci_private *priv = netdev_priv(ndev);
2943 struct islpci_mgmtframe *response;
2944 int ret = 0, response_op = PIMFOR_OP_ERROR;
2946 printk("%s: set_oid 0x%08X\tlen: %d\n", ndev->name, priv->priv_oid,
2949 if (islpci_get_state(priv) >= PRV_STATE_INIT) {
2951 islpci_mgt_transaction(priv->ndev, PIMFOR_OP_SET,
2952 priv->priv_oid, extra, data->length,
2954 printk("%s: ret: %i\n", ndev->name, ret);
2955 if (ret || !response
2956 || response->header->operation == PIMFOR_OP_ERROR) {
2958 islpci_mgt_release(response);
2960 printk("%s: EIO\n", ndev->name);
2964 response_op = response->header->operation;
2965 printk("%s: response_op: %i\n", ndev->name,
2967 islpci_mgt_release(response);
2971 return (ret ? ret : -EINPROGRESS);
2975 prism54_set_spy(struct net_device *ndev,
2976 struct iw_request_info *info,
2977 union iwreq_data *uwrq, char *extra)
2979 islpci_private *priv = netdev_priv(ndev);
2980 u32 u, oid = OID_INL_CONFIG;
2982 down_write(&priv->mib_sem);
2983 mgt_get(priv, OID_INL_CONFIG, &u);
2985 if ((uwrq->data.length == 0) && (priv->spy_data.spy_number > 0))
2987 u &= ~INL_CONFIG_RXANNEX;
2988 else if ((uwrq->data.length > 0) && (priv->spy_data.spy_number == 0))
2990 u |= INL_CONFIG_RXANNEX;
2992 mgt_set(priv, OID_INL_CONFIG, &u);
2993 mgt_commit_list(priv, &oid, 1);
2994 up_write(&priv->mib_sem);
2996 return iw_handler_set_spy(ndev, info, uwrq, extra);
2999 static const iw_handler prism54_handler[] = {
3000 (iw_handler) prism54_commit, /* SIOCSIWCOMMIT */
3001 (iw_handler) prism54_get_name, /* SIOCGIWNAME */
3002 (iw_handler) NULL, /* SIOCSIWNWID */
3003 (iw_handler) NULL, /* SIOCGIWNWID */
3004 (iw_handler) prism54_set_freq, /* SIOCSIWFREQ */
3005 (iw_handler) prism54_get_freq, /* SIOCGIWFREQ */
3006 (iw_handler) prism54_set_mode, /* SIOCSIWMODE */
3007 (iw_handler) prism54_get_mode, /* SIOCGIWMODE */
3008 (iw_handler) prism54_set_sens, /* SIOCSIWSENS */
3009 (iw_handler) prism54_get_sens, /* SIOCGIWSENS */
3010 (iw_handler) NULL, /* SIOCSIWRANGE */
3011 (iw_handler) prism54_get_range, /* SIOCGIWRANGE */
3012 (iw_handler) NULL, /* SIOCSIWPRIV */
3013 (iw_handler) NULL, /* SIOCGIWPRIV */
3014 (iw_handler) NULL, /* SIOCSIWSTATS */
3015 (iw_handler) NULL, /* SIOCGIWSTATS */
3016 prism54_set_spy, /* SIOCSIWSPY */
3017 iw_handler_get_spy, /* SIOCGIWSPY */
3018 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
3019 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
3020 (iw_handler) prism54_set_wap, /* SIOCSIWAP */
3021 (iw_handler) prism54_get_wap, /* SIOCGIWAP */
3022 (iw_handler) NULL, /* -- hole -- */
3023 (iw_handler) NULL, /* SIOCGIWAPLIST depreciated */
3024 (iw_handler) prism54_set_scan, /* SIOCSIWSCAN */
3025 (iw_handler) prism54_get_scan, /* SIOCGIWSCAN */
3026 (iw_handler) prism54_set_essid, /* SIOCSIWESSID */
3027 (iw_handler) prism54_get_essid, /* SIOCGIWESSID */
3028 (iw_handler) prism54_set_nick, /* SIOCSIWNICKN */
3029 (iw_handler) prism54_get_nick, /* SIOCGIWNICKN */
3030 (iw_handler) NULL, /* -- hole -- */
3031 (iw_handler) NULL, /* -- hole -- */
3032 (iw_handler) prism54_set_rate, /* SIOCSIWRATE */
3033 (iw_handler) prism54_get_rate, /* SIOCGIWRATE */
3034 (iw_handler) prism54_set_rts, /* SIOCSIWRTS */
3035 (iw_handler) prism54_get_rts, /* SIOCGIWRTS */
3036 (iw_handler) prism54_set_frag, /* SIOCSIWFRAG */
3037 (iw_handler) prism54_get_frag, /* SIOCGIWFRAG */
3038 (iw_handler) prism54_set_txpower, /* SIOCSIWTXPOW */
3039 (iw_handler) prism54_get_txpower, /* SIOCGIWTXPOW */
3040 (iw_handler) prism54_set_retry, /* SIOCSIWRETRY */
3041 (iw_handler) prism54_get_retry, /* SIOCGIWRETRY */
3042 (iw_handler) prism54_set_encode, /* SIOCSIWENCODE */
3043 (iw_handler) prism54_get_encode, /* SIOCGIWENCODE */
3044 (iw_handler) NULL, /* SIOCSIWPOWER */
3045 (iw_handler) NULL, /* SIOCGIWPOWER */
3046 NULL, /* -- hole -- */
3047 NULL, /* -- hole -- */
3048 (iw_handler) prism54_set_genie, /* SIOCSIWGENIE */
3049 (iw_handler) prism54_get_genie, /* SIOCGIWGENIE */
3050 (iw_handler) prism54_set_auth, /* SIOCSIWAUTH */
3051 (iw_handler) prism54_get_auth, /* SIOCGIWAUTH */
3052 (iw_handler) prism54_set_encodeext, /* SIOCSIWENCODEEXT */
3053 (iw_handler) prism54_get_encodeext, /* SIOCGIWENCODEEXT */
3054 NULL, /* SIOCSIWPMKSA */
3057 /* The low order bit identify a SET (0) or a GET (1) ioctl. */
3059 #define PRISM54_RESET SIOCIWFIRSTPRIV
3060 #define PRISM54_GET_POLICY SIOCIWFIRSTPRIV+1
3061 #define PRISM54_SET_POLICY SIOCIWFIRSTPRIV+2
3062 #define PRISM54_GET_MAC SIOCIWFIRSTPRIV+3
3063 #define PRISM54_ADD_MAC SIOCIWFIRSTPRIV+4
3065 #define PRISM54_DEL_MAC SIOCIWFIRSTPRIV+6
3067 #define PRISM54_KICK_MAC SIOCIWFIRSTPRIV+8
3069 #define PRISM54_KICK_ALL SIOCIWFIRSTPRIV+10
3071 #define PRISM54_GET_WPA SIOCIWFIRSTPRIV+11
3072 #define PRISM54_SET_WPA SIOCIWFIRSTPRIV+12
3074 #define PRISM54_DBG_OID SIOCIWFIRSTPRIV+14
3075 #define PRISM54_DBG_GET_OID SIOCIWFIRSTPRIV+15
3076 #define PRISM54_DBG_SET_OID SIOCIWFIRSTPRIV+16
3078 #define PRISM54_GET_OID SIOCIWFIRSTPRIV+17
3079 #define PRISM54_SET_OID_U32 SIOCIWFIRSTPRIV+18
3080 #define PRISM54_SET_OID_STR SIOCIWFIRSTPRIV+20
3081 #define PRISM54_SET_OID_ADDR SIOCIWFIRSTPRIV+22
3083 #define PRISM54_GET_PRISMHDR SIOCIWFIRSTPRIV+23
3084 #define PRISM54_SET_PRISMHDR SIOCIWFIRSTPRIV+24
3086 #define IWPRIV_SET_U32(n,x) { n, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "s_"x }
3087 #define IWPRIV_SET_SSID(n,x) { n, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 1, 0, "s_"x }
3088 #define IWPRIV_SET_ADDR(n,x) { n, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "s_"x }
3089 #define IWPRIV_GET(n,x) { n, 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | PRIV_STR_SIZE, "g_"x }
3091 #define IWPRIV_U32(n,x) IWPRIV_SET_U32(n,x), IWPRIV_GET(n,x)
3092 #define IWPRIV_SSID(n,x) IWPRIV_SET_SSID(n,x), IWPRIV_GET(n,x)
3093 #define IWPRIV_ADDR(n,x) IWPRIV_SET_ADDR(n,x), IWPRIV_GET(n,x)
3095 /* Note : limited to 128 private ioctls (wireless tools 26) */
3097 static const struct iw_priv_args prism54_private_args[] = {
3098 /*{ cmd, set_args, get_args, name } */
3099 {PRISM54_RESET, 0, 0, "reset"},
3100 {PRISM54_GET_PRISMHDR, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
3102 {PRISM54_SET_PRISMHDR, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
3104 {PRISM54_GET_POLICY, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
3106 {PRISM54_SET_POLICY, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
3108 {PRISM54_GET_MAC, 0, IW_PRIV_TYPE_ADDR | 64, "getMac"},
3109 {PRISM54_ADD_MAC, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0,
3111 {PRISM54_DEL_MAC, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0,
3113 {PRISM54_KICK_MAC, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0,
3115 {PRISM54_KICK_ALL, 0, 0, "kickAll"},
3116 {PRISM54_GET_WPA, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
3118 {PRISM54_SET_WPA, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
3120 {PRISM54_DBG_OID, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
3122 {PRISM54_DBG_GET_OID, 0, IW_PRIV_TYPE_BYTE | 256, "dbg_get_oid"},
3123 {PRISM54_DBG_SET_OID, IW_PRIV_TYPE_BYTE | 256, 0, "dbg_set_oid"},
3124 /* --- sub-ioctls handlers --- */
3126 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | PRIV_STR_SIZE, ""},
3127 {PRISM54_SET_OID_U32,
3128 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, ""},
3129 {PRISM54_SET_OID_STR,
3130 IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 1, 0, ""},
3131 {PRISM54_SET_OID_ADDR,
3132 IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, ""},
3133 /* --- sub-ioctls definitions --- */
3134 IWPRIV_ADDR(GEN_OID_MACADDRESS, "addr"),
3135 IWPRIV_GET(GEN_OID_LINKSTATE, "linkstate"),
3136 IWPRIV_U32(DOT11_OID_BSSTYPE, "bsstype"),
3137 IWPRIV_ADDR(DOT11_OID_BSSID, "bssid"),
3138 IWPRIV_U32(DOT11_OID_STATE, "state"),
3139 IWPRIV_U32(DOT11_OID_AID, "aid"),
3141 IWPRIV_SSID(DOT11_OID_SSIDOVERRIDE, "ssidoverride"),
3143 IWPRIV_U32(DOT11_OID_MEDIUMLIMIT, "medlimit"),
3144 IWPRIV_U32(DOT11_OID_BEACONPERIOD, "beacon"),
3145 IWPRIV_U32(DOT11_OID_DTIMPERIOD, "dtimperiod"),
3147 IWPRIV_U32(DOT11_OID_AUTHENABLE, "authenable"),
3148 IWPRIV_U32(DOT11_OID_PRIVACYINVOKED, "privinvok"),
3149 IWPRIV_U32(DOT11_OID_EXUNENCRYPTED, "exunencrypt"),
3151 IWPRIV_U32(DOT11_OID_REKEYTHRESHOLD, "rekeythresh"),
3153 IWPRIV_U32(DOT11_OID_MAXTXLIFETIME, "maxtxlife"),
3154 IWPRIV_U32(DOT11_OID_MAXRXLIFETIME, "maxrxlife"),
3155 IWPRIV_U32(DOT11_OID_ALOFT_FIXEDRATE, "fixedrate"),
3156 IWPRIV_U32(DOT11_OID_MAXFRAMEBURST, "frameburst"),
3157 IWPRIV_U32(DOT11_OID_PSM, "psm"),
3159 IWPRIV_U32(DOT11_OID_BRIDGELOCAL, "bridge"),
3160 IWPRIV_U32(DOT11_OID_CLIENTS, "clients"),
3161 IWPRIV_U32(DOT11_OID_CLIENTSASSOCIATED, "clientassoc"),
3162 IWPRIV_U32(DOT11_OID_DOT1XENABLE, "dot1xenable"),
3163 IWPRIV_U32(DOT11_OID_ANTENNARX, "rxant"),
3164 IWPRIV_U32(DOT11_OID_ANTENNATX, "txant"),
3165 IWPRIV_U32(DOT11_OID_ANTENNADIVERSITY, "antdivers"),
3166 IWPRIV_U32(DOT11_OID_EDTHRESHOLD, "edthresh"),
3167 IWPRIV_U32(DOT11_OID_PREAMBLESETTINGS, "preamble"),
3168 IWPRIV_GET(DOT11_OID_RATES, "rates"),
3169 IWPRIV_U32(DOT11_OID_OUTPUTPOWER, ".11outpower"),
3170 IWPRIV_GET(DOT11_OID_SUPPORTEDRATES, "supprates"),
3171 IWPRIV_GET(DOT11_OID_SUPPORTEDFREQUENCIES, "suppfreq"),
3173 IWPRIV_U32(DOT11_OID_NOISEFLOOR, "noisefloor"),
3174 IWPRIV_GET(DOT11_OID_FREQUENCYACTIVITY, "freqactivity"),
3175 IWPRIV_U32(DOT11_OID_NONERPPROTECTION, "nonerpprotec"),
3176 IWPRIV_U32(DOT11_OID_PROFILES, "profile"),
3177 IWPRIV_GET(DOT11_OID_EXTENDEDRATES, "extrates"),
3178 IWPRIV_U32(DOT11_OID_MLMEAUTOLEVEL, "mlmelevel"),
3180 IWPRIV_GET(DOT11_OID_BSSS, "bsss"),
3181 IWPRIV_GET(DOT11_OID_BSSLIST, "bsslist"),
3182 IWPRIV_U32(OID_INL_MODE, "mode"),
3183 IWPRIV_U32(OID_INL_CONFIG, "config"),
3184 IWPRIV_U32(OID_INL_DOT11D_CONFORMANCE, ".11dconform"),
3185 IWPRIV_GET(OID_INL_PHYCAPABILITIES, "phycapa"),
3186 IWPRIV_U32(OID_INL_OUTPUTPOWER, "outpower"),
3189 static const iw_handler prism54_private_handler[] = {
3190 (iw_handler) prism54_reset,
3191 (iw_handler) prism54_get_policy,
3192 (iw_handler) prism54_set_policy,
3193 (iw_handler) prism54_get_mac,
3194 (iw_handler) prism54_add_mac,
3196 (iw_handler) prism54_del_mac,
3198 (iw_handler) prism54_kick_mac,
3200 (iw_handler) prism54_kick_all,
3201 (iw_handler) prism54_get_wpa,
3202 (iw_handler) prism54_set_wpa,
3204 (iw_handler) prism54_debug_oid,
3205 (iw_handler) prism54_debug_get_oid,
3206 (iw_handler) prism54_debug_set_oid,
3207 (iw_handler) prism54_get_oid,
3208 (iw_handler) prism54_set_u32,
3210 (iw_handler) prism54_set_raw,
3212 (iw_handler) prism54_set_raw,
3213 (iw_handler) prism54_get_prismhdr,
3214 (iw_handler) prism54_set_prismhdr,
3217 const struct iw_handler_def prism54_handler_def = {
3218 .num_standard = sizeof (prism54_handler) / sizeof (iw_handler),
3219 .num_private = sizeof (prism54_private_handler) / sizeof (iw_handler),
3221 sizeof (prism54_private_args) / sizeof (struct iw_priv_args),
3222 .standard = (iw_handler *) prism54_handler,
3223 .private = (iw_handler *) prism54_private_handler,
3224 .private_args = (struct iw_priv_args *) prism54_private_args,
3225 .get_wireless_stats = prism54_get_wireless_stats,
3228 /* For wpa_supplicant */
3231 prism54_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
3233 struct iwreq *wrq = (struct iwreq *) rq;
3236 case PRISM54_HOSTAPD:
3237 if (!capable(CAP_NET_ADMIN))
3239 ret = prism54_hostapd(ndev, &wrq->u.data);