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/version.h>
24 #include <linux/module.h>
25 #include <linux/kernel.h>
26 #include <linux/if_arp.h>
27 #include <linux/pci.h>
29 #include <asm/uaccess.h>
31 #include "prismcompat.h"
32 #include "isl_ioctl.h"
33 #include "islpci_mgt.h"
34 #include "isl_oid.h" /* additional types and defs for isl38xx fw */
37 #include <net/iw_handler.h> /* New driver API */
40 * prism54_mib_mode_helper - MIB change mode helper function
41 * @mib: the &struct islpci_mib object to modify
42 * @iw_mode: new mode (%IW_MODE_*)
44 * This is a helper function, hence it does not lock. Make sure
45 * caller deals with locking *if* necessary. This function sets the
46 * mode-dependent mib values and does the mapping of the Linux
47 * Wireless API modes to Device firmware modes. It also checks for
48 * correct valid Linux wireless modes.
51 prism54_mib_mode_helper(islpci_private *priv, u32 iw_mode)
53 u32 config = INL_CONFIG_MANUALRUN;
56 /* For now, just catch early the Repeater and Secondary modes here */
57 if (iw_mode == IW_MODE_REPEAT || iw_mode == IW_MODE_SECOND) {
59 "%s(): Sorry, Repeater mode and Secondary mode "
60 "are not yet supported by this driver.\n", __FUNCTION__);
64 priv->iw_mode = iw_mode;
68 mode = INL_MODE_CLIENT;
69 bsstype = DOT11_BSSTYPE_ANY;
72 mode = INL_MODE_CLIENT;
73 bsstype = DOT11_BSSTYPE_IBSS;
76 mode = INL_MODE_CLIENT;
77 bsstype = DOT11_BSSTYPE_INFRA;
81 bsstype = DOT11_BSSTYPE_INFRA;
84 mode = INL_MODE_PROMISCUOUS;
85 bsstype = DOT11_BSSTYPE_ANY;
86 config |= INL_CONFIG_RXANNEX;
93 config |= INL_CONFIG_WDS;
94 mgt_set(priv, DOT11_OID_BSSTYPE, &bsstype);
95 mgt_set(priv, OID_INL_CONFIG, &config);
96 mgt_set(priv, OID_INL_MODE, &mode);
102 * prism54_mib_init - fill MIB cache with defaults
104 * this function initializes the struct given as @mib with defaults,
105 * of which many are retrieved from the global module parameter
110 prism54_mib_init(islpci_private *priv)
112 u32 channel, authen, wep, filter, dot1x, mlme, conformance, power, mode;
113 struct obj_buffer psm_buffer = {
114 .size = PSM_BUFFER_SIZE,
115 .addr = priv->device_psm_buffer
118 channel = CARD_DEFAULT_CHANNEL;
119 authen = CARD_DEFAULT_AUTHEN;
120 wep = CARD_DEFAULT_WEP;
121 filter = CARD_DEFAULT_FILTER; /* (0) Do not filter un-encrypted data */
122 dot1x = CARD_DEFAULT_DOT1X;
123 mlme = CARD_DEFAULT_MLME_MODE;
124 conformance = CARD_DEFAULT_CONFORMANCE;
126 mode = CARD_DEFAULT_IW_MODE;
128 mgt_set(priv, DOT11_OID_CHANNEL, &channel);
129 mgt_set(priv, DOT11_OID_AUTHENABLE, &authen);
130 mgt_set(priv, DOT11_OID_PRIVACYINVOKED, &wep);
131 mgt_set(priv, DOT11_OID_PSMBUFFER, &psm_buffer);
132 mgt_set(priv, DOT11_OID_EXUNENCRYPTED, &filter);
133 mgt_set(priv, DOT11_OID_DOT1XENABLE, &dot1x);
134 mgt_set(priv, DOT11_OID_MLMEAUTOLEVEL, &mlme);
135 mgt_set(priv, OID_INL_DOT11D_CONFORMANCE, &conformance);
136 mgt_set(priv, OID_INL_OUTPUTPOWER, &power);
138 /* This sets all of the mode-dependent values */
139 prism54_mib_mode_helper(priv, mode);
142 /* this will be executed outside of atomic context thanks to
143 * schedule_work(), thus we can as well use sleeping semaphore
146 prism54_update_stats(islpci_private *priv)
150 struct obj_bss bss, *bss2;
153 if (down_interruptible(&priv->stats_sem))
157 * I'm not sure if the unit is dBm.
158 * Note : If we are not connected, this value seems to be irrelevant. */
160 mgt_get_request(priv, DOT11_OID_NOISEFLOOR, 0, NULL, &r);
161 priv->local_iwstatistics.qual.noise = r.u;
163 /* Get the rssi of the link. To do this we need to retrieve a bss. */
165 /* First get the MAC address of the AP we are associated with. */
166 mgt_get_request(priv, DOT11_OID_BSSID, 0, NULL, &r);
169 /* copy this MAC to the bss */
170 memcpy(bss.address, data, 6);
173 /* now ask for the corresponding bss */
174 j = mgt_get_request(priv, DOT11_OID_BSSFIND, 0, (void *) &bss, &r);
176 /* report the rssi and use it to calculate
177 * link quality through a signal-noise
179 priv->local_iwstatistics.qual.level = bss2->rssi;
180 priv->local_iwstatistics.qual.qual =
181 bss2->rssi - priv->iwstatistics.qual.noise;
185 /* report that the stats are new */
186 priv->local_iwstatistics.qual.updated = 0x7;
188 /* Rx : unable to decrypt the MPDU */
189 mgt_get_request(priv, DOT11_OID_PRIVRXFAILED, 0, NULL, &r);
190 priv->local_iwstatistics.discard.code = r.u;
192 /* Tx : Max MAC retries num reached */
193 mgt_get_request(priv, DOT11_OID_MPDUTXFAILED, 0, NULL, &r);
194 priv->local_iwstatistics.discard.retries = r.u;
196 up(&priv->stats_sem);
201 struct iw_statistics *
202 prism54_get_wireless_stats(struct net_device *ndev)
204 islpci_private *priv = netdev_priv(ndev);
206 /* If the stats are being updated return old data */
207 if (down_trylock(&priv->stats_sem) == 0) {
208 memcpy(&priv->iwstatistics, &priv->local_iwstatistics,
209 sizeof (struct iw_statistics));
210 /* They won't be marked updated for the next time */
211 priv->local_iwstatistics.qual.updated = 0;
212 up(&priv->stats_sem);
214 priv->iwstatistics.qual.updated = 0;
216 /* Update our wireless stats, but do not schedule to often
218 if ((priv->stats_timestamp == 0) ||
219 time_after(jiffies, priv->stats_timestamp + 1 * HZ)) {
220 schedule_work(&priv->stats_work);
221 priv->stats_timestamp = jiffies;
224 return &priv->iwstatistics;
228 prism54_commit(struct net_device *ndev, struct iw_request_info *info,
229 char *cwrq, char *extra)
231 islpci_private *priv = netdev_priv(ndev);
233 /* simply re-set the last set SSID, this should commit most stuff */
235 /* Commit in Monitor mode is not necessary, also setting essid
236 * in Monitor mode does not make sense and isn't allowed for this
237 * device's firmware */
238 if (priv->iw_mode != IW_MODE_MONITOR)
239 return mgt_set_request(priv, DOT11_OID_SSID, 0, NULL);
244 prism54_get_name(struct net_device *ndev, struct iw_request_info *info,
245 char *cwrq, char *extra)
247 islpci_private *priv = netdev_priv(ndev);
252 if (islpci_get_state(priv) < PRV_STATE_INIT) {
253 strncpy(cwrq, "NOT READY!", IFNAMSIZ);
256 rvalue = mgt_get_request(priv, OID_INL_PHYCAPABILITIES, 0, NULL, &r);
259 case INL_PHYCAP_5000MHZ:
260 capabilities = "IEEE 802.11a/b/g";
263 capabilities = "IEEE 802.11b/g - FAA Support";
265 case INL_PHYCAP_2400MHZ:
267 capabilities = "IEEE 802.11b/g"; /* Default */
270 strncpy(cwrq, capabilities, IFNAMSIZ);
275 prism54_set_freq(struct net_device *ndev, struct iw_request_info *info,
276 struct iw_freq *fwrq, char *extra)
278 islpci_private *priv = netdev_priv(ndev);
283 /* we have a channel number */
286 c = (fwrq->e == 1) ? channel_of_freq(fwrq->m / 100000) : 0;
288 rvalue = c ? mgt_set_request(priv, DOT11_OID_CHANNEL, 0, &c) : -EINVAL;
290 /* Call commit handler */
291 return (rvalue ? rvalue : -EINPROGRESS);
295 prism54_get_freq(struct net_device *ndev, struct iw_request_info *info,
296 struct iw_freq *fwrq, char *extra)
298 islpci_private *priv = netdev_priv(ndev);
302 rvalue = mgt_get_request(priv, DOT11_OID_CHANNEL, 0, NULL, &r);
304 rvalue |= mgt_get_request(priv, DOT11_OID_FREQUENCY, 0, NULL, &r);
312 prism54_set_mode(struct net_device *ndev, struct iw_request_info *info,
313 __u32 * uwrq, char *extra)
315 islpci_private *priv = netdev_priv(ndev);
316 u32 mlmeautolevel = CARD_DEFAULT_MLME_MODE;
318 /* Let's see if the user passed a valid Linux Wireless mode */
319 if (*uwrq > IW_MODE_MONITOR || *uwrq < IW_MODE_AUTO) {
321 "%s: %s() You passed a non-valid init_mode.\n",
322 priv->ndev->name, __FUNCTION__);
326 down_write(&priv->mib_sem);
328 if (prism54_mib_mode_helper(priv, *uwrq)) {
329 up_write(&priv->mib_sem);
333 /* the ACL code needs an intermediate mlmeautolevel. The wpa stuff an
336 if ((*uwrq == IW_MODE_MASTER) && (priv->acl.policy != MAC_POLICY_OPEN))
337 mlmeautolevel = DOT11_MLME_INTERMEDIATE;
339 mlmeautolevel = DOT11_MLME_EXTENDED;
341 mgt_set(priv, DOT11_OID_MLMEAUTOLEVEL, &mlmeautolevel);
343 if (mgt_commit(priv)) {
344 up_write(&priv->mib_sem);
347 priv->ndev->type = (priv->iw_mode == IW_MODE_MONITOR)
348 ? priv->monitor_type : ARPHRD_ETHER;
349 up_write(&priv->mib_sem);
356 prism54_get_mode(struct net_device *ndev, struct iw_request_info *info,
357 __u32 * uwrq, char *extra)
359 islpci_private *priv = netdev_priv(ndev);
361 BUG_ON((priv->iw_mode < IW_MODE_AUTO) || (priv->iw_mode >
363 *uwrq = priv->iw_mode;
368 /* we use DOT11_OID_EDTHRESHOLD. From what I guess the card will not try to
369 * emit data if (sensitivity > rssi - noise) (in dBm).
370 * prism54_set_sens does not seem to work.
374 prism54_set_sens(struct net_device *ndev, struct iw_request_info *info,
375 struct iw_param *vwrq, char *extra)
377 islpci_private *priv = netdev_priv(ndev);
380 /* by default the card sets this to 20. */
381 sens = vwrq->disabled ? 20 : vwrq->value;
383 return mgt_set_request(priv, DOT11_OID_EDTHRESHOLD, 0, &sens);
387 prism54_get_sens(struct net_device *ndev, struct iw_request_info *info,
388 struct iw_param *vwrq, char *extra)
390 islpci_private *priv = netdev_priv(ndev);
394 rvalue = mgt_get_request(priv, DOT11_OID_EDTHRESHOLD, 0, NULL, &r);
397 vwrq->disabled = (vwrq->value == 0);
404 prism54_get_range(struct net_device *ndev, struct iw_request_info *info,
405 struct iw_point *dwrq, char *extra)
407 struct iw_range *range = (struct iw_range *) extra;
408 islpci_private *priv = netdev_priv(ndev);
411 struct obj_frequencies *freq;
414 memset(range, 0, sizeof (struct iw_range));
415 dwrq->length = sizeof (struct iw_range);
417 /* set the wireless extension version number */
418 range->we_version_source = SUPPORTED_WIRELESS_EXT;
419 range->we_version_compiled = WIRELESS_EXT;
421 /* Now the encoding capabilities */
422 range->num_encoding_sizes = 3;
423 /* 64(40) bits WEP */
424 range->encoding_size[0] = 5;
425 /* 128(104) bits WEP */
426 range->encoding_size[1] = 13;
427 /* 256 bits for WPA-PSK */
428 range->encoding_size[2] = 32;
429 /* 4 keys are allowed */
430 range->max_encoding_tokens = 4;
432 /* we don't know the quality range... */
433 range->max_qual.level = 0;
434 range->max_qual.noise = 0;
435 range->max_qual.qual = 0;
436 /* these value describe an average quality. Needs more tweaking... */
437 range->avg_qual.level = -80; /* -80 dBm */
438 range->avg_qual.noise = 0; /* don't know what to put here */
439 range->avg_qual.qual = 0;
441 range->sensitivity = 200;
443 /* retry limit capabilities */
444 range->retry_capa = IW_RETRY_LIMIT | IW_RETRY_LIFETIME;
445 range->retry_flags = IW_RETRY_LIMIT;
446 range->r_time_flags = IW_RETRY_LIFETIME;
448 /* I don't know the range. Put stupid things here */
449 range->min_retry = 1;
450 range->max_retry = 65535;
451 range->min_r_time = 1024;
452 range->max_r_time = 65535 * 1024;
454 /* txpower is supported in dBm's */
455 range->txpower_capa = IW_TXPOW_DBM;
457 #if WIRELESS_EXT > 16
458 /* Event capability (kernel + driver) */
459 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
460 IW_EVENT_CAPA_MASK(SIOCGIWTHRSPY) |
461 IW_EVENT_CAPA_MASK(SIOCGIWAP));
462 range->event_capa[1] = IW_EVENT_CAPA_K_1;
463 range->event_capa[4] = IW_EVENT_CAPA_MASK(IWEVCUSTOM);
464 #endif /* WIRELESS_EXT > 16 */
466 if (islpci_get_state(priv) < PRV_STATE_INIT)
469 /* Request the device for the supported frequencies
470 * not really relevant since some devices will report the 5 GHz band
471 * frequencies even if they don't support them.
474 mgt_get_request(priv, DOT11_OID_SUPPORTEDFREQUENCIES, 0, NULL, &r);
477 range->num_channels = freq->nr;
478 range->num_frequency = freq->nr;
480 m = min(IW_MAX_FREQUENCIES, (int) freq->nr);
481 for (i = 0; i < m; i++) {
482 range->freq[i].m = freq->mhz[i];
483 range->freq[i].e = 6;
484 range->freq[i].i = channel_of_freq(freq->mhz[i]);
488 rvalue |= mgt_get_request(priv, DOT11_OID_SUPPORTEDRATES, 0, NULL, &r);
491 /* We got an array of char. It is NULL terminated. */
493 while ((i < IW_MAX_BITRATES) && (*data != 0)) {
494 /* the result must be in bps. The card gives us 500Kbps */
495 range->bitrate[i] = *data * 500000;
499 range->num_bitrates = i;
508 prism54_set_wap(struct net_device *ndev, struct iw_request_info *info,
509 struct sockaddr *awrq, char *extra)
511 islpci_private *priv = netdev_priv(ndev);
515 if (awrq->sa_family != ARPHRD_ETHER)
518 /* prepare the structure for the set object */
519 memcpy(&bssid[0], awrq->sa_data, 6);
521 /* set the bssid -- does this make sense when in AP mode? */
522 rvalue = mgt_set_request(priv, DOT11_OID_BSSID, 0, &bssid);
524 return (rvalue ? rvalue : -EINPROGRESS); /* Call commit handler */
530 prism54_get_wap(struct net_device *ndev, struct iw_request_info *info,
531 struct sockaddr *awrq, char *extra)
533 islpci_private *priv = netdev_priv(ndev);
537 rvalue = mgt_get_request(priv, DOT11_OID_BSSID, 0, NULL, &r);
538 memcpy(awrq->sa_data, r.ptr, 6);
539 awrq->sa_family = ARPHRD_ETHER;
546 prism54_set_scan(struct net_device *dev, struct iw_request_info *info,
547 struct iw_param *vwrq, char *extra)
549 /* hehe the device does this automagicaly */
553 /* a little helper that will translate our data into a card independent
554 * format that the Wireless Tools will understand. This was inspired by
555 * the "Aironet driver for 4500 and 4800 series cards" (GPL)
559 prism54_translate_bss(struct net_device *ndev, char *current_ev,
560 char *end_buf, struct obj_bss *bss, char noise)
562 struct iw_event iwe; /* Temporary buffer */
564 islpci_private *priv = netdev_priv(ndev);
566 /* The first entry must be the MAC address */
567 memcpy(iwe.u.ap_addr.sa_data, bss->address, 6);
568 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
571 iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_ADDR_LEN);
573 /* The following entries will be displayed in the same order we give them */
576 iwe.u.data.length = bss->ssid.length;
577 iwe.u.data.flags = 1;
578 iwe.cmd = SIOCGIWESSID;
579 current_ev = iwe_stream_add_point(current_ev, end_buf,
580 &iwe, bss->ssid.octets);
584 #define CAP_IBSS 0x02
585 #define CAP_CRYPT 0x10
591 iwe.u.mode = IW_MODE_MASTER;
592 else if (cap & CAP_IBSS)
593 iwe.u.mode = IW_MODE_ADHOC;
594 iwe.cmd = SIOCGIWMODE;
597 iwe_stream_add_event(current_ev, end_buf, &iwe,
600 /* Encryption capability */
602 iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
604 iwe.u.data.flags = IW_ENCODE_DISABLED;
605 iwe.u.data.length = 0;
606 iwe.cmd = SIOCGIWENCODE;
607 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, NULL);
609 /* Add frequency. (short) bss->channel is the frequency in MHz */
610 iwe.u.freq.m = bss->channel;
612 iwe.cmd = SIOCGIWFREQ;
614 iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
616 /* Add quality statistics */
617 iwe.u.qual.level = bss->rssi;
618 iwe.u.qual.noise = noise;
619 /* do a simple SNR for quality */
620 iwe.u.qual.qual = bss->rssi - noise;
623 iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
626 u8 wpa_ie[MAX_WPA_IE_LEN];
631 wpa_ie_len = prism54_wpa_ie_get(priv, bss->address, wpa_ie);
632 if (wpa_ie_len > 0 &&
633 (buf = kmalloc(wpa_ie_len * 2 + 10, GFP_ATOMIC))) {
635 p += sprintf(p, "wpa_ie=");
636 for (i = 0; i < wpa_ie_len; i++) {
637 p += sprintf(p, "%02x", wpa_ie[i]);
639 memset(&iwe, 0, sizeof (iwe));
640 iwe.cmd = IWEVCUSTOM;
641 iwe.u.data.length = strlen(buf);
642 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]),
688 #if WIRELESS_EXT > 16
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 */
695 #endif /* WIRELESS_EXT > 16 */
699 dwrq->length = (current_ev - extra);
700 dwrq->flags = 0; /* todo */
706 prism54_set_essid(struct net_device *ndev, struct iw_request_info *info,
707 struct iw_point *dwrq, char *extra)
709 islpci_private *priv = netdev_priv(ndev);
710 struct obj_ssid essid;
712 memset(essid.octets, 0, 33);
714 /* Check if we were asked for `any' */
715 if (dwrq->flags && dwrq->length) {
716 if (dwrq->length > min(33, IW_ESSID_MAX_SIZE + 1))
718 essid.length = dwrq->length - 1;
719 memcpy(essid.octets, extra, dwrq->length);
723 if (priv->iw_mode != IW_MODE_MONITOR)
724 return mgt_set_request(priv, DOT11_OID_SSID, 0, &essid);
726 /* If in monitor mode, just save to mib */
727 mgt_set(priv, DOT11_OID_SSID, &essid);
733 prism54_get_essid(struct net_device *ndev, struct iw_request_info *info,
734 struct iw_point *dwrq, char *extra)
736 islpci_private *priv = netdev_priv(ndev);
737 struct obj_ssid *essid;
741 rvalue = mgt_get_request(priv, DOT11_OID_SSID, 0, NULL, &r);
745 dwrq->flags = 1; /* set ESSID to ON for Wireless Extensions */
746 /* if it is to big, trunk it */
747 dwrq->length = min(IW_ESSID_MAX_SIZE, essid->length + 1);
752 essid->octets[essid->length] = '\0';
753 memcpy(extra, essid->octets, dwrq->length);
759 /* Provides no functionality, just completes the ioctl. In essence this is a
760 * just a cosmetic ioctl.
763 prism54_set_nick(struct net_device *ndev, struct iw_request_info *info,
764 struct iw_point *dwrq, char *extra)
766 islpci_private *priv = netdev_priv(ndev);
768 if (dwrq->length > IW_ESSID_MAX_SIZE)
771 down_write(&priv->mib_sem);
772 memset(priv->nickname, 0, sizeof (priv->nickname));
773 memcpy(priv->nickname, extra, dwrq->length);
774 up_write(&priv->mib_sem);
780 prism54_get_nick(struct net_device *ndev, struct iw_request_info *info,
781 struct iw_point *dwrq, char *extra)
783 islpci_private *priv = netdev_priv(ndev);
787 down_read(&priv->mib_sem);
788 dwrq->length = strlen(priv->nickname) + 1;
789 memcpy(extra, priv->nickname, dwrq->length);
790 up_read(&priv->mib_sem);
795 /* Set the allowed Bitrates */
798 prism54_set_rate(struct net_device *ndev,
799 struct iw_request_info *info,
800 struct iw_param *vwrq, char *extra)
803 islpci_private *priv = netdev_priv(ndev);
809 if (vwrq->value == -1) {
810 /* auto mode. No limit. */
812 return mgt_set_request(priv, DOT11_OID_PROFILES, 0, &profile);
815 ret = mgt_get_request(priv, DOT11_OID_SUPPORTEDRATES, 0, NULL, &r);
821 rate = (u32) (vwrq->value / 500000);
826 if (rate && (data[i] == rate)) {
829 if (vwrq->value == i) {
844 /* Now, check if we want a fixed or auto value */
852 printk("prism54 rate: ");
854 printk("%u ", data[i]);
860 ret = mgt_set_request(priv, DOT11_OID_PROFILES, 0, &profile);
861 ret |= mgt_set_request(priv, DOT11_OID_EXTENDEDRATES, 0, data);
862 ret |= mgt_set_request(priv, DOT11_OID_RATES, 0, data);
869 /* Get the current bit rate */
871 prism54_get_rate(struct net_device *ndev,
872 struct iw_request_info *info,
873 struct iw_param *vwrq, char *extra)
875 islpci_private *priv = netdev_priv(ndev);
880 /* Get the current bit rate */
881 if ((rvalue = mgt_get_request(priv, GEN_OID_LINKSTATE, 0, NULL, &r)))
883 vwrq->value = r.u * 500000;
885 /* request the device for the enabled rates */
886 rvalue = mgt_get_request(priv, DOT11_OID_RATES, 0, NULL, &r);
892 vwrq->fixed = (data[0] != 0) && (data[1] == 0);
899 prism54_set_rts(struct net_device *ndev, struct iw_request_info *info,
900 struct iw_param *vwrq, char *extra)
902 islpci_private *priv = netdev_priv(ndev);
904 return mgt_set_request(priv, DOT11_OID_RTSTHRESH, 0, &vwrq->value);
908 prism54_get_rts(struct net_device *ndev, struct iw_request_info *info,
909 struct iw_param *vwrq, char *extra)
911 islpci_private *priv = netdev_priv(ndev);
915 /* get the rts threshold */
916 rvalue = mgt_get_request(priv, DOT11_OID_RTSTHRESH, 0, NULL, &r);
923 prism54_set_frag(struct net_device *ndev, struct iw_request_info *info,
924 struct iw_param *vwrq, char *extra)
926 islpci_private *priv = netdev_priv(ndev);
928 return mgt_set_request(priv, DOT11_OID_FRAGTHRESH, 0, &vwrq->value);
932 prism54_get_frag(struct net_device *ndev, struct iw_request_info *info,
933 struct iw_param *vwrq, char *extra)
935 islpci_private *priv = netdev_priv(ndev);
939 rvalue = mgt_get_request(priv, DOT11_OID_FRAGTHRESH, 0, NULL, &r);
945 /* Here we have (min,max) = max retries for (small frames, big frames). Where
946 * big frame <=> bigger than the rts threshold
947 * small frame <=> smaller than the rts threshold
948 * This is not really the behavior expected by the wireless tool but it seems
949 * to be a common behavior in other drivers.
953 prism54_set_retry(struct net_device *ndev, struct iw_request_info *info,
954 struct iw_param *vwrq, char *extra)
956 islpci_private *priv = netdev_priv(ndev);
957 u32 slimit = 0, llimit = 0; /* short and long limit */
962 /* we cannot disable this feature */
965 if (vwrq->flags & IW_RETRY_LIMIT) {
966 if (vwrq->flags & IW_RETRY_MIN)
967 slimit = vwrq->value;
968 else if (vwrq->flags & IW_RETRY_MAX)
969 llimit = vwrq->value;
971 /* we are asked to set both */
972 slimit = vwrq->value;
973 llimit = vwrq->value;
976 if (vwrq->flags & IW_RETRY_LIFETIME)
977 /* Wireless tools use us unit while the device uses 1024 us unit */
978 lifetime = vwrq->value / 1024;
980 /* now set what is requested */
983 mgt_set_request(priv, DOT11_OID_SHORTRETRIES, 0, &slimit);
986 mgt_set_request(priv, DOT11_OID_LONGRETRIES, 0, &llimit);
989 mgt_set_request(priv, DOT11_OID_MAXTXLIFETIME, 0,
995 prism54_get_retry(struct net_device *ndev, struct iw_request_info *info,
996 struct iw_param *vwrq, char *extra)
998 islpci_private *priv = netdev_priv(ndev);
1001 vwrq->disabled = 0; /* It cannot be disabled */
1003 if ((vwrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
1004 /* we are asked for the life time */
1006 mgt_get_request(priv, DOT11_OID_MAXTXLIFETIME, 0, NULL, &r);
1007 vwrq->value = r.u * 1024;
1008 vwrq->flags = IW_RETRY_LIFETIME;
1009 } else if ((vwrq->flags & IW_RETRY_MAX)) {
1010 /* we are asked for the long retry limit */
1012 mgt_get_request(priv, DOT11_OID_LONGRETRIES, 0, NULL, &r);
1014 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
1016 /* default. get the short retry limit */
1018 mgt_get_request(priv, DOT11_OID_SHORTRETRIES, 0, NULL, &r);
1020 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_MIN;
1027 prism54_set_encode(struct net_device *ndev, struct iw_request_info *info,
1028 struct iw_point *dwrq, char *extra)
1030 islpci_private *priv = netdev_priv(ndev);
1031 int rvalue = 0, force = 0;
1032 int authen = DOT11_AUTH_OS, invoke = 0, exunencrypt = 0;
1035 /* with the new API, it's impossible to get a NULL pointer.
1036 * New version of iwconfig set the IW_ENCODE_NOKEY flag
1037 * when no key is given, but older versions don't. */
1039 if (dwrq->length > 0) {
1040 /* we have a key to set */
1041 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
1043 struct obj_key key = { DOT11_PRIV_WEP, 0, "" };
1045 /* get the current key index */
1046 rvalue = mgt_get_request(priv, DOT11_OID_DEFKEYID, 0, NULL, &r);
1047 current_index = r.u;
1048 /* Verify that the key is not marked as invalid */
1049 if (!(dwrq->flags & IW_ENCODE_NOKEY)) {
1050 key.length = dwrq->length > sizeof (key.key) ?
1051 sizeof (key.key) : dwrq->length;
1052 memcpy(key.key, extra, key.length);
1053 if (key.length == 32)
1054 /* we want WPA-PSK */
1055 key.type = DOT11_PRIV_TKIP;
1056 if ((index < 0) || (index > 3))
1057 /* no index provided use the current one */
1058 index = current_index;
1060 /* now send the key to the card */
1062 mgt_set_request(priv, DOT11_OID_DEFKEYX, index,
1066 * If a valid key is set, encryption should be enabled
1067 * (user may turn it off later).
1068 * This is also how "iwconfig ethX key on" works
1070 if ((index == current_index) && (key.length > 0))
1073 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
1074 if ((index >= 0) && (index <= 3)) {
1075 /* we want to set the key index */
1077 mgt_set_request(priv, DOT11_OID_DEFKEYID, 0,
1080 if (!dwrq->flags & IW_ENCODE_MODE) {
1081 /* we cannot do anything. Complain. */
1086 /* now read the flags */
1087 if (dwrq->flags & IW_ENCODE_DISABLED) {
1088 /* Encoding disabled,
1089 * authen = DOT11_AUTH_OS;
1091 * exunencrypt = 0; */
1093 if (dwrq->flags & IW_ENCODE_OPEN)
1094 /* Encode but accept non-encoded packets. No auth */
1096 if ((dwrq->flags & IW_ENCODE_RESTRICTED) || force) {
1097 /* Refuse non-encoded packets. Auth */
1098 authen = DOT11_AUTH_BOTH;
1102 /* do the change if requested */
1103 if ((dwrq->flags & IW_ENCODE_MODE) || force) {
1105 mgt_set_request(priv, DOT11_OID_AUTHENABLE, 0, &authen);
1107 mgt_set_request(priv, DOT11_OID_PRIVACYINVOKED, 0, &invoke);
1109 mgt_set_request(priv, DOT11_OID_EXUNENCRYPTED, 0,
1116 prism54_get_encode(struct net_device *ndev, struct iw_request_info *info,
1117 struct iw_point *dwrq, char *extra)
1119 islpci_private *priv = netdev_priv(ndev);
1120 struct obj_key *key;
1121 u32 devindex, index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
1122 u32 authen = 0, invoke = 0, exunencrypt = 0;
1126 /* first get the flags */
1127 rvalue = mgt_get_request(priv, DOT11_OID_AUTHENABLE, 0, NULL, &r);
1129 rvalue |= mgt_get_request(priv, DOT11_OID_PRIVACYINVOKED, 0, NULL, &r);
1131 rvalue |= mgt_get_request(priv, DOT11_OID_EXUNENCRYPTED, 0, NULL, &r);
1134 if (invoke && (authen == DOT11_AUTH_BOTH) && exunencrypt)
1135 dwrq->flags = IW_ENCODE_RESTRICTED;
1136 else if ((authen == DOT11_AUTH_OS) && !exunencrypt) {
1138 dwrq->flags = IW_ENCODE_OPEN;
1140 dwrq->flags = IW_ENCODE_DISABLED;
1142 /* The card should not work in this state */
1145 /* get the current device key index */
1146 rvalue |= mgt_get_request(priv, DOT11_OID_DEFKEYID, 0, NULL, &r);
1148 /* Now get the key, return it */
1149 if ((index < 0) || (index > 3))
1150 /* no index provided, use the current one */
1152 rvalue |= mgt_get_request(priv, DOT11_OID_DEFKEYX, index, NULL, &r);
1154 dwrq->length = key->length;
1155 memcpy(extra, key->key, dwrq->length);
1157 /* return the used key index */
1158 dwrq->flags |= devindex + 1;
1164 prism54_get_txpower(struct net_device *ndev, struct iw_request_info *info,
1165 struct iw_param *vwrq, char *extra)
1167 islpci_private *priv = netdev_priv(ndev);
1171 rvalue = mgt_get_request(priv, OID_INL_OUTPUTPOWER, 0, NULL, &r);
1172 /* intersil firmware operates in 0.25 dBm (1/4 dBm) */
1173 vwrq->value = (s32) r.u / 4;
1175 /* radio is not turned of
1176 * btw: how is possible to turn off only the radio
1184 prism54_set_txpower(struct net_device *ndev, struct iw_request_info *info,
1185 struct iw_param *vwrq, char *extra)
1187 islpci_private *priv = netdev_priv(ndev);
1188 s32 u = vwrq->value;
1190 /* intersil firmware operates in 0.25 dBm (1/4) */
1192 if (vwrq->disabled) {
1193 /* don't know how to disable radio */
1195 "%s: %s() disabling radio is not yet supported.\n",
1196 priv->ndev->name, __FUNCTION__);
1198 } else if (vwrq->fixed)
1199 /* currently only fixed value is supported */
1200 return mgt_set_request(priv, OID_INL_OUTPUTPOWER, 0, &u);
1203 "%s: %s() auto power will be implemented later.\n",
1204 priv->ndev->name, __FUNCTION__);
1210 prism54_reset(struct net_device *ndev, struct iw_request_info *info,
1211 __u32 * uwrq, char *extra)
1213 islpci_reset(netdev_priv(ndev), 0);
1219 prism54_get_oid(struct net_device *ndev, struct iw_request_info *info,
1220 struct iw_point *dwrq, char *extra)
1224 enum oid_num_t n = dwrq->flags;
1226 rvalue = mgt_get_request((islpci_private *) ndev->priv, n, 0, NULL, &r);
1227 dwrq->length = mgt_response_to_str(n, &r, extra);
1228 if ((isl_oid[n].flags & OID_FLAG_TYPE) != OID_TYPE_U32)
1234 prism54_set_u32(struct net_device *ndev, struct iw_request_info *info,
1235 __u32 * uwrq, char *extra)
1237 u32 oid = uwrq[0], u = uwrq[1];
1239 return mgt_set_request((islpci_private *) ndev->priv, oid, 0, &u);
1243 prism54_set_raw(struct net_device *ndev, struct iw_request_info *info,
1244 struct iw_point *dwrq, char *extra)
1246 u32 oid = dwrq->flags;
1248 return mgt_set_request((islpci_private *) ndev->priv, oid, 0, extra);
1252 prism54_acl_init(struct islpci_acl *acl)
1254 sema_init(&acl->sem, 1);
1255 INIT_LIST_HEAD(&acl->mac_list);
1257 acl->policy = MAC_POLICY_OPEN;
1261 prism54_clear_mac(struct islpci_acl *acl)
1263 struct list_head *ptr, *next;
1264 struct mac_entry *entry;
1266 if (down_interruptible(&acl->sem))
1269 if (acl->size == 0) {
1274 for (ptr = acl->mac_list.next, next = ptr->next;
1275 ptr != &acl->mac_list; ptr = next, next = ptr->next) {
1276 entry = list_entry(ptr, struct mac_entry, _list);
1285 prism54_acl_clean(struct islpci_acl *acl)
1287 prism54_clear_mac(acl);
1291 prism54_add_mac(struct net_device *ndev, struct iw_request_info *info,
1292 struct sockaddr *awrq, char *extra)
1294 islpci_private *priv = netdev_priv(ndev);
1295 struct islpci_acl *acl = &priv->acl;
1296 struct mac_entry *entry;
1297 struct sockaddr *addr = (struct sockaddr *) extra;
1299 if (addr->sa_family != ARPHRD_ETHER)
1302 entry = kmalloc(sizeof (struct mac_entry), GFP_KERNEL);
1306 memcpy(entry->addr, addr->sa_data, ETH_ALEN);
1308 if (down_interruptible(&acl->sem)) {
1310 return -ERESTARTSYS;
1312 list_add_tail(&entry->_list, &acl->mac_list);
1320 prism54_del_mac(struct net_device *ndev, struct iw_request_info *info,
1321 struct sockaddr *awrq, char *extra)
1323 islpci_private *priv = netdev_priv(ndev);
1324 struct islpci_acl *acl = &priv->acl;
1325 struct mac_entry *entry;
1326 struct list_head *ptr;
1327 struct sockaddr *addr = (struct sockaddr *) extra;
1329 if (addr->sa_family != ARPHRD_ETHER)
1332 if (down_interruptible(&acl->sem))
1333 return -ERESTARTSYS;
1334 for (ptr = acl->mac_list.next; ptr != &acl->mac_list; ptr = ptr->next) {
1335 entry = list_entry(ptr, struct mac_entry, _list);
1337 if (memcmp(entry->addr, addr->sa_data, ETH_ALEN) == 0) {
1350 prism54_get_mac(struct net_device *ndev, struct iw_request_info *info,
1351 struct iw_point *dwrq, char *extra)
1353 islpci_private *priv = netdev_priv(ndev);
1354 struct islpci_acl *acl = &priv->acl;
1355 struct mac_entry *entry;
1356 struct list_head *ptr;
1357 struct sockaddr *dst = (struct sockaddr *) extra;
1361 if (down_interruptible(&acl->sem))
1362 return -ERESTARTSYS;
1364 for (ptr = acl->mac_list.next; ptr != &acl->mac_list; ptr = ptr->next) {
1365 entry = list_entry(ptr, struct mac_entry, _list);
1367 memcpy(dst->sa_data, entry->addr, ETH_ALEN);
1368 dst->sa_family = ARPHRD_ETHER;
1376 /* Setting policy also clears the MAC acl, even if we don't change the defaut
1381 prism54_set_policy(struct net_device *ndev, struct iw_request_info *info,
1382 __u32 * uwrq, char *extra)
1384 islpci_private *priv = netdev_priv(ndev);
1385 struct islpci_acl *acl = &priv->acl;
1388 prism54_clear_mac(acl);
1390 if ((*uwrq < MAC_POLICY_OPEN) || (*uwrq > MAC_POLICY_REJECT))
1393 down_write(&priv->mib_sem);
1395 acl->policy = *uwrq;
1397 /* the ACL code needs an intermediate mlmeautolevel */
1398 if ((priv->iw_mode == IW_MODE_MASTER) &&
1399 (acl->policy != MAC_POLICY_OPEN))
1400 mlmeautolevel = DOT11_MLME_INTERMEDIATE;
1402 mlmeautolevel = CARD_DEFAULT_MLME_MODE;
1404 mlmeautolevel = DOT11_MLME_EXTENDED;
1405 mgt_set(priv, DOT11_OID_MLMEAUTOLEVEL, &mlmeautolevel);
1406 /* restart the card with our new policy */
1407 if (mgt_commit(priv)) {
1408 up_write(&priv->mib_sem);
1411 up_write(&priv->mib_sem);
1417 prism54_get_policy(struct net_device *ndev, struct iw_request_info *info,
1418 __u32 * uwrq, char *extra)
1420 islpci_private *priv = netdev_priv(ndev);
1421 struct islpci_acl *acl = &priv->acl;
1423 *uwrq = acl->policy;
1428 /* Return 1 only if client should be accepted. */
1431 prism54_mac_accept(struct islpci_acl *acl, char *mac)
1433 struct list_head *ptr;
1434 struct mac_entry *entry;
1437 if (down_interruptible(&acl->sem))
1438 return -ERESTARTSYS;
1440 if (acl->policy == MAC_POLICY_OPEN) {
1445 for (ptr = acl->mac_list.next; ptr != &acl->mac_list; ptr = ptr->next) {
1446 entry = list_entry(ptr, struct mac_entry, _list);
1447 if (memcmp(entry->addr, mac, ETH_ALEN) == 0) {
1452 res = (acl->policy == MAC_POLICY_ACCEPT) ? !res : res;
1459 prism54_kick_all(struct net_device *ndev, struct iw_request_info *info,
1460 struct iw_point *dwrq, char *extra)
1462 struct obj_mlme *mlme;
1465 mlme = kmalloc(sizeof (struct obj_mlme), GFP_KERNEL);
1469 /* Tell the card to kick every client */
1472 mgt_set_request(netdev_priv(ndev), DOT11_OID_DISASSOCIATE, 0, mlme);
1479 prism54_kick_mac(struct net_device *ndev, struct iw_request_info *info,
1480 struct sockaddr *awrq, char *extra)
1482 struct obj_mlme *mlme;
1483 struct sockaddr *addr = (struct sockaddr *) extra;
1486 if (addr->sa_family != ARPHRD_ETHER)
1489 mlme = kmalloc(sizeof (struct obj_mlme), GFP_KERNEL);
1493 /* Tell the card to only kick the corresponding bastard */
1494 memcpy(mlme->address, addr->sa_data, ETH_ALEN);
1497 mgt_set_request(netdev_priv(ndev), DOT11_OID_DISASSOCIATE, 0, mlme);
1504 /* Translate a TRAP oid into a wireless event. Called in islpci_mgt_receive. */
1507 format_event(islpci_private *priv, char *dest, const char *str,
1508 const struct obj_mlme *mlme, u16 *length, int error)
1510 const u8 *a = mlme->address;
1511 int n = snprintf(dest, IW_CUSTOM_MAX,
1512 "%s %s %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X %s (%2.2X)",
1514 ((priv->iw_mode == IW_MODE_MASTER) ? "from" : "to"),
1515 a[0], a[1], a[2], a[3], a[4], a[5],
1516 (error ? (mlme->code ? " : REJECTED " : " : ACCEPTED ")
1518 BUG_ON(n > IW_CUSTOM_MAX);
1523 send_formatted_event(islpci_private *priv, const char *str,
1524 const struct obj_mlme *mlme, int error)
1526 union iwreq_data wrqu;
1529 memptr = kmalloc(IW_CUSTOM_MAX, GFP_KERNEL);
1532 wrqu.data.pointer = memptr;
1533 wrqu.data.length = 0;
1534 format_event(priv, memptr, str, mlme, &wrqu.data.length,
1536 wireless_send_event(priv->ndev, IWEVCUSTOM, &wrqu, memptr);
1541 send_simple_event(islpci_private *priv, const char *str)
1543 union iwreq_data wrqu;
1545 int n = strlen(str);
1547 memptr = kmalloc(IW_CUSTOM_MAX, GFP_KERNEL);
1550 BUG_ON(n > IW_CUSTOM_MAX);
1551 wrqu.data.pointer = memptr;
1552 wrqu.data.length = n;
1553 strcpy(memptr, str);
1554 wireless_send_event(priv->ndev, IWEVCUSTOM, &wrqu, memptr);
1559 link_changed(struct net_device *ndev, u32 bitrate)
1561 islpci_private *priv = netdev_priv(ndev);
1564 if (priv->iw_mode == IW_MODE_INFRA) {
1565 union iwreq_data uwrq;
1566 prism54_get_wap(ndev, NULL, (struct sockaddr *) &uwrq,
1568 wireless_send_event(ndev, SIOCGIWAP, &uwrq, NULL);
1570 send_simple_event(netdev_priv(ndev),
1571 "Link established");
1573 send_simple_event(netdev_priv(ndev), "Link lost");
1576 /* Beacon/ProbeResp payload header */
1577 struct ieee80211_beacon_phdr {
1581 } __attribute__ ((packed));
1583 #define WLAN_EID_GENERIC 0xdd
1584 static u8 wpa_oid[4] = { 0x00, 0x50, 0xf2, 1 };
1586 #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
1587 #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
1590 prism54_wpa_ie_add(islpci_private *priv, u8 *bssid,
1591 u8 *wpa_ie, size_t wpa_ie_len)
1593 struct list_head *ptr;
1594 struct islpci_bss_wpa_ie *bss = NULL;
1596 if (wpa_ie_len > MAX_WPA_IE_LEN)
1597 wpa_ie_len = MAX_WPA_IE_LEN;
1599 if (down_interruptible(&priv->wpa_sem))
1602 /* try to use existing entry */
1603 list_for_each(ptr, &priv->bss_wpa_list) {
1604 bss = list_entry(ptr, struct islpci_bss_wpa_ie, list);
1605 if (memcmp(bss->bssid, bssid, ETH_ALEN) == 0) {
1606 list_move(&bss->list, &priv->bss_wpa_list);
1613 /* add a new BSS entry; if max number of entries is already
1614 * reached, replace the least recently updated */
1615 if (priv->num_bss_wpa >= MAX_BSS_WPA_IE_COUNT) {
1616 bss = list_entry(priv->bss_wpa_list.prev,
1617 struct islpci_bss_wpa_ie, list);
1618 list_del(&bss->list);
1620 bss = kmalloc(sizeof (*bss), GFP_ATOMIC);
1622 priv->num_bss_wpa++;
1623 memset(bss, 0, sizeof (*bss));
1627 memcpy(bss->bssid, bssid, ETH_ALEN);
1628 list_add(&bss->list, &priv->bss_wpa_list);
1633 memcpy(bss->wpa_ie, wpa_ie, wpa_ie_len);
1634 bss->wpa_ie_len = wpa_ie_len;
1635 bss->last_update = jiffies;
1637 printk(KERN_DEBUG "Failed to add BSS WPA entry for " MACSTR
1638 "\n", MAC2STR(bssid));
1641 /* expire old entries from WPA list */
1642 while (priv->num_bss_wpa > 0) {
1643 bss = list_entry(priv->bss_wpa_list.prev,
1644 struct islpci_bss_wpa_ie, list);
1645 if (!time_after(jiffies, bss->last_update + 60 * HZ))
1648 list_del(&bss->list);
1649 priv->num_bss_wpa--;
1657 prism54_wpa_ie_get(islpci_private *priv, u8 *bssid, u8 *wpa_ie)
1659 struct list_head *ptr;
1660 struct islpci_bss_wpa_ie *bss = NULL;
1663 if (down_interruptible(&priv->wpa_sem))
1666 list_for_each(ptr, &priv->bss_wpa_list) {
1667 bss = list_entry(ptr, struct islpci_bss_wpa_ie, list);
1668 if (memcmp(bss->bssid, bssid, ETH_ALEN) == 0)
1673 len = bss->wpa_ie_len;
1674 memcpy(wpa_ie, bss->wpa_ie, len);
1682 prism54_wpa_ie_init(islpci_private *priv)
1684 INIT_LIST_HEAD(&priv->bss_wpa_list);
1685 sema_init(&priv->wpa_sem, 1);
1689 prism54_wpa_ie_clean(islpci_private *priv)
1691 struct list_head *ptr, *n;
1693 list_for_each_safe(ptr, n, &priv->bss_wpa_list) {
1694 struct islpci_bss_wpa_ie *bss;
1695 bss = list_entry(ptr, struct islpci_bss_wpa_ie, list);
1701 prism54_process_bss_data(islpci_private *priv, u32 oid, u8 *addr,
1702 u8 *payload, size_t len)
1704 struct ieee80211_beacon_phdr *hdr;
1710 hdr = (struct ieee80211_beacon_phdr *) payload;
1711 pos = (u8 *) (hdr + 1);
1712 end = payload + len;
1714 if (pos + 2 + pos[1] > end) {
1715 printk(KERN_DEBUG "Parsing Beacon/ProbeResp failed "
1716 "for " MACSTR "\n", MAC2STR(addr));
1719 if (pos[0] == WLAN_EID_GENERIC && pos[1] >= 4 &&
1720 memcmp(pos + 2, wpa_oid, 4) == 0) {
1721 prism54_wpa_ie_add(priv, addr, pos, pos[1] + 2);
1729 handle_request(islpci_private *priv, struct obj_mlme *mlme, enum oid_num_t oid)
1731 if (((mlme->state == DOT11_STATE_AUTHING) ||
1732 (mlme->state == DOT11_STATE_ASSOCING))
1733 && mgt_mlme_answer(priv)) {
1734 /* Someone is requesting auth and we must respond. Just send back
1735 * the trap with error code set accordingly.
1737 mlme->code = prism54_mac_accept(&priv->acl,
1738 mlme->address) ? 0 : 1;
1739 mgt_set_request(priv, oid, 0, mlme);
1744 prism54_process_trap_helper(islpci_private *priv, enum oid_num_t oid,
1747 struct obj_mlme *mlme = (struct obj_mlme *) data;
1748 struct obj_mlmeex *mlmeex = (struct obj_mlmeex *) data;
1749 struct obj_mlmeex *confirm;
1750 u8 wpa_ie[MAX_WPA_IE_LEN];
1752 size_t len = 0; /* u16, better? */
1753 u8 *payload = 0, *pos = 0;
1756 /* I think all trapable objects are listed here.
1757 * Some oids have a EX version. The difference is that they are emitted
1758 * in DOT11_MLME_EXTENDED mode (set with DOT11_OID_MLMEAUTOLEVEL)
1760 * The few events already defined by the wireless tools are not really
1761 * suited. We use the more flexible custom event facility.
1764 if (oid >= DOT11_OID_BEACON) {
1766 payload = pos = mlmeex->data;
1769 /* I fear prism54_process_bss_data won't work with big endian data */
1770 if ((oid == DOT11_OID_BEACON) || (oid == DOT11_OID_PROBE))
1771 prism54_process_bss_data(priv, oid, mlmeex->address,
1774 mgt_le_to_cpu(isl_oid[oid].flags & OID_FLAG_TYPE, (void *) mlme);
1778 case GEN_OID_LINKSTATE:
1779 link_changed(priv->ndev, (u32) *data);
1782 case DOT11_OID_MICFAILURE:
1783 send_simple_event(priv, "Mic failure");
1786 case DOT11_OID_DEAUTHENTICATE:
1787 send_formatted_event(priv, "DeAuthenticate request", mlme, 0);
1790 case DOT11_OID_AUTHENTICATE:
1791 handle_request(priv, mlme, oid);
1792 send_formatted_event(priv, "Authenticate request", mlme, 1);
1795 case DOT11_OID_DISASSOCIATE:
1796 send_formatted_event(priv, "Disassociate request", mlme, 0);
1799 case DOT11_OID_ASSOCIATE:
1800 handle_request(priv, mlme, oid);
1801 send_formatted_event(priv, "Associate request", mlme, 1);
1804 case DOT11_OID_REASSOCIATE:
1805 handle_request(priv, mlme, oid);
1806 send_formatted_event(priv, "ReAssociate request", mlme, 1);
1809 case DOT11_OID_BEACON:
1810 send_formatted_event(priv,
1811 "Received a beacon from an unkown AP",
1815 case DOT11_OID_PROBE:
1816 /* we received a probe from a client. */
1817 send_formatted_event(priv, "Received a probe from client", mlme,
1821 /* Note : "mlme" is actually a "struct obj_mlmeex *" here, but this
1822 * is backward compatible layout-wise with "struct obj_mlme".
1825 case DOT11_OID_DEAUTHENTICATEEX:
1826 send_formatted_event(priv, "DeAuthenticate request", mlme, 0);
1829 case DOT11_OID_AUTHENTICATEEX:
1830 handle_request(priv, mlme, oid);
1831 send_formatted_event(priv, "Authenticate request (ex)", mlme, 1);
1833 if (priv->iw_mode != IW_MODE_MASTER
1834 && mlmeex->state != DOT11_STATE_AUTHING)
1837 confirm = kmalloc(sizeof(struct obj_mlmeex) + 6, GFP_ATOMIC);
1842 memcpy(&confirm->address, mlmeex->address, ETH_ALEN);
1843 printk(KERN_DEBUG "Authenticate from: address:\t%02x:%02x:%02x:%02x:%02x:%02x\n",
1851 confirm->id = -1; /* or mlmeex->id ? */
1852 confirm->state = 0; /* not used */
1855 confirm->data[0] = 0x00;
1856 confirm->data[1] = 0x00;
1857 confirm->data[2] = 0x02;
1858 confirm->data[3] = 0x00;
1859 confirm->data[4] = 0x00;
1860 confirm->data[5] = 0x00;
1862 ret = mgt_set_varlen(priv, DOT11_OID_ASSOCIATEEX, confirm, 6);
1869 case DOT11_OID_DISASSOCIATEEX:
1870 send_formatted_event(priv, "Disassociate request (ex)", mlme, 0);
1873 case DOT11_OID_ASSOCIATEEX:
1874 handle_request(priv, mlme, oid);
1875 send_formatted_event(priv, "Associate request (ex)", mlme, 1);
1877 if (priv->iw_mode != IW_MODE_MASTER
1878 && mlmeex->state != DOT11_STATE_AUTHING)
1881 confirm = kmalloc(sizeof(struct obj_mlmeex), GFP_ATOMIC);
1886 memcpy(&confirm->address, mlmeex->address, ETH_ALEN);
1888 confirm->id = ((struct obj_mlmeex *)mlme)->id;
1889 confirm->state = 0; /* not used */
1892 wpa_ie_len = prism54_wpa_ie_get(priv, mlmeex->address, wpa_ie);
1895 printk(KERN_DEBUG "No WPA IE found from "
1896 "address:\t%02x:%02x:%02x:%02x:%02x:%02x\n",
1908 confirm->size = wpa_ie_len;
1909 memcpy(&confirm->data, wpa_ie, wpa_ie_len);
1911 mgt_set_varlen(priv, oid, confirm, wpa_ie_len);
1917 case DOT11_OID_REASSOCIATEEX:
1918 handle_request(priv, mlme, oid);
1919 send_formatted_event(priv, "Reassociate request (ex)", mlme, 1);
1921 if (priv->iw_mode != IW_MODE_MASTER
1922 && mlmeex->state != DOT11_STATE_ASSOCING)
1925 confirm = kmalloc(sizeof(struct obj_mlmeex), GFP_ATOMIC);
1930 memcpy(&confirm->address, mlmeex->address, ETH_ALEN);
1932 confirm->id = mlmeex->id;
1933 confirm->state = 0; /* not used */
1936 wpa_ie_len = prism54_wpa_ie_get(priv, mlmeex->address, wpa_ie);
1939 printk(KERN_DEBUG "No WPA IE found from "
1940 "address:\t%02x:%02x:%02x:%02x:%02x:%02x\n",
1952 confirm->size = wpa_ie_len;
1953 memcpy(&confirm->data, wpa_ie, wpa_ie_len);
1955 mgt_set_varlen(priv, oid, confirm, wpa_ie_len);
1969 * Process a device trap. This is called via schedule_work(), outside of
1970 * interrupt context, no locks held.
1973 prism54_process_trap(void *data)
1975 struct islpci_mgmtframe *frame = data;
1976 struct net_device *ndev = frame->ndev;
1977 enum oid_num_t n = mgt_oidtonum(frame->header->oid);
1979 if (n != OID_NUM_LAST)
1980 prism54_process_trap_helper(netdev_priv(ndev), n, frame->data);
1981 islpci_mgt_release(frame);
1985 prism54_set_mac_address(struct net_device *ndev, void *addr)
1987 islpci_private *priv = netdev_priv(ndev);
1990 if (ndev->addr_len != 6)
1992 ret = mgt_set_request(priv, GEN_OID_MACADDRESS, 0,
1993 &((struct sockaddr *) addr)->sa_data);
1995 memcpy(priv->ndev->dev_addr,
1996 &((struct sockaddr *) addr)->sa_data, 6);
2001 /* Note: currently, use hostapd ioctl from the Host AP driver for WPA
2002 * support. This is to be replaced with Linux wireless extensions once they
2003 * get WPA support. */
2005 /* Note II: please leave all this together as it will be easier to remove later,
2006 * once wireless extensions add WPA support -mcgrof */
2008 /* PRISM54_HOSTAPD ioctl() cmd: */
2010 PRISM2_SET_ENCRYPTION = 6,
2011 PRISM2_HOSTAPD_SET_GENERIC_ELEMENT = 12,
2012 PRISM2_HOSTAPD_MLME = 13,
2013 PRISM2_HOSTAPD_SCAN_REQ = 14,
2016 #define PRISM54_SET_WPA SIOCIWFIRSTPRIV+12
2017 #define PRISM54_HOSTAPD SIOCIWFIRSTPRIV+25
2018 #define PRISM54_DROP_UNENCRYPTED SIOCIWFIRSTPRIV+26
2020 #define PRISM2_HOSTAPD_MAX_BUF_SIZE 1024
2021 #define PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN \
2022 ((int) (&((struct prism2_hostapd_param *) 0)->u.generic_elem.data))
2024 /* Maximum length for algorithm names (-1 for nul termination)
2025 * used in ioctl() */
2026 #define HOSTAP_CRYPT_ALG_NAME_LEN 16
2028 struct prism2_hostapd_param {
2030 u8 sta_addr[ETH_ALEN];
2033 u8 alg[HOSTAP_CRYPT_ALG_NAME_LEN];
2037 u8 seq[8]; /* sequence counter (set: RX, get: TX) */
2046 #define MLME_STA_DEAUTH 0
2047 #define MLME_STA_DISASSOC 1
2060 prism2_ioctl_set_encryption(struct net_device *dev,
2061 struct prism2_hostapd_param *param,
2064 islpci_private *priv = netdev_priv(dev);
2065 int rvalue = 0, force = 0;
2066 int authen = DOT11_AUTH_OS, invoke = 0, exunencrypt = 0;
2069 /* with the new API, it's impossible to get a NULL pointer.
2070 * New version of iwconfig set the IW_ENCODE_NOKEY flag
2071 * when no key is given, but older versions don't. */
2073 if (param->u.crypt.key_len > 0) {
2074 /* we have a key to set */
2075 int index = param->u.crypt.idx;
2077 struct obj_key key = { DOT11_PRIV_TKIP, 0, "" };
2079 /* get the current key index */
2080 rvalue = mgt_get_request(priv, DOT11_OID_DEFKEYID, 0, NULL, &r);
2081 current_index = r.u;
2082 /* Verify that the key is not marked as invalid */
2083 if (!(param->u.crypt.flags & IW_ENCODE_NOKEY)) {
2084 key.length = param->u.crypt.key_len > sizeof (param->u.crypt.key) ?
2085 sizeof (param->u.crypt.key) : param->u.crypt.key_len;
2086 memcpy(key.key, param->u.crypt.key, key.length);
2087 if (key.length == 32)
2088 /* we want WPA-PSK */
2089 key.type = DOT11_PRIV_TKIP;
2090 if ((index < 0) || (index > 3))
2091 /* no index provided use the current one */
2092 index = current_index;
2094 /* now send the key to the card */
2096 mgt_set_request(priv, DOT11_OID_DEFKEYX, index,
2100 * If a valid key is set, encryption should be enabled
2101 * (user may turn it off later).
2102 * This is also how "iwconfig ethX key on" works
2104 if ((index == current_index) && (key.length > 0))
2107 int index = (param->u.crypt.flags & IW_ENCODE_INDEX) - 1;
2108 if ((index >= 0) && (index <= 3)) {
2109 /* we want to set the key index */
2111 mgt_set_request(priv, DOT11_OID_DEFKEYID, 0,
2114 if (!param->u.crypt.flags & IW_ENCODE_MODE) {
2115 /* we cannot do anything. Complain. */
2120 /* now read the flags */
2121 if (param->u.crypt.flags & IW_ENCODE_DISABLED) {
2122 /* Encoding disabled,
2123 * authen = DOT11_AUTH_OS;
2125 * exunencrypt = 0; */
2127 if (param->u.crypt.flags & IW_ENCODE_OPEN)
2128 /* Encode but accept non-encoded packets. No auth */
2130 if ((param->u.crypt.flags & IW_ENCODE_RESTRICTED) || force) {
2131 /* Refuse non-encoded packets. Auth */
2132 authen = DOT11_AUTH_BOTH;
2136 /* do the change if requested */
2137 if ((param->u.crypt.flags & IW_ENCODE_MODE) || force) {
2139 mgt_set_request(priv, DOT11_OID_AUTHENABLE, 0, &authen);
2141 mgt_set_request(priv, DOT11_OID_PRIVACYINVOKED, 0, &invoke);
2143 mgt_set_request(priv, DOT11_OID_EXUNENCRYPTED, 0,
2150 prism2_ioctl_set_generic_element(struct net_device *ndev,
2151 struct prism2_hostapd_param *param,
2154 islpci_private *priv = netdev_priv(ndev);
2155 int max_len, len, alen, ret=0;
2156 struct obj_attachment *attach;
2158 len = param->u.generic_elem.len;
2159 max_len = param_len - PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN;
2160 if (max_len < 0 || max_len < len)
2163 alen = sizeof(*attach) + len;
2164 attach = kmalloc(alen, GFP_KERNEL);
2168 memset(attach, 0, alen);
2169 #define WLAN_FC_TYPE_MGMT 0
2170 #define WLAN_FC_STYPE_ASSOC_REQ 0
2171 #define WLAN_FC_STYPE_REASSOC_REQ 2
2173 /* Note: endianness is covered by mgt_set_varlen */
2175 attach->type = (WLAN_FC_TYPE_MGMT << 2) |
2176 (WLAN_FC_STYPE_ASSOC_REQ << 4);
2179 memcpy(attach->data, param->u.generic_elem.data, len);
2181 ret = mgt_set_varlen(priv, DOT11_OID_ATTACHMENT, attach, len);
2184 attach->type = (WLAN_FC_TYPE_MGMT << 2) |
2185 (WLAN_FC_STYPE_REASSOC_REQ << 4);
2187 ret = mgt_set_varlen(priv, DOT11_OID_ATTACHMENT, attach, len);
2190 printk(KERN_DEBUG "%s: WPA IE Attachment was set\n",
2200 prism2_ioctl_mlme(struct net_device *dev, struct prism2_hostapd_param *param)
2206 prism2_ioctl_scan_req(struct net_device *ndev,
2207 struct prism2_hostapd_param *param)
2209 islpci_private *priv = netdev_priv(ndev);
2211 struct obj_bsslist *bsslist;
2214 char *current_ev = "foo";
2217 if (islpci_get_state(priv) < PRV_STATE_INIT) {
2218 /* device is not ready, fail gently */
2222 /* first get the noise value. We will use it to report the link quality */
2223 rvalue = mgt_get_request(priv, DOT11_OID_NOISEFLOOR, 0, NULL, &r);
2226 /* Ask the device for a list of known bss. We can report at most
2227 * IW_MAX_AP=64 to the range struct. But the device won't repport anything
2228 * if you change the value of IWMAX_BSS=24.
2230 rvalue |= mgt_get_request(priv, DOT11_OID_BSSLIST, 0, NULL, &r);
2233 /* ok now, scan the list and translate its info */
2234 for (i = 0; i < min(IW_MAX_AP, (int) bsslist->nr); i++)
2235 current_ev = prism54_translate_bss(ndev, current_ev,
2236 extra + IW_SCAN_MAX_DATA,
2237 &(bsslist->bsslist[i]),
2245 prism54_hostapd(struct net_device *ndev, struct iw_point *p)
2247 struct prism2_hostapd_param *param;
2251 printk(KERN_DEBUG "prism54_hostapd - len=%d\n", p->length);
2252 if (p->length < sizeof(struct prism2_hostapd_param) ||
2253 p->length > PRISM2_HOSTAPD_MAX_BUF_SIZE || !p->pointer)
2256 param = (struct prism2_hostapd_param *) kmalloc(p->length, GFP_KERNEL);
2260 if (copy_from_user(param, p->pointer, p->length)) {
2265 switch (param->cmd) {
2266 case PRISM2_SET_ENCRYPTION:
2267 printk(KERN_DEBUG "%s: Caught WPA supplicant set encryption request\n",
2269 ret = prism2_ioctl_set_encryption(ndev, param, p->length);
2271 case PRISM2_HOSTAPD_SET_GENERIC_ELEMENT:
2272 printk(KERN_DEBUG "%s: Caught WPA supplicant set WPA IE request\n",
2274 ret = prism2_ioctl_set_generic_element(ndev, param,
2277 case PRISM2_HOSTAPD_MLME:
2278 printk(KERN_DEBUG "%s: Caught WPA supplicant MLME request\n",
2280 ret = prism2_ioctl_mlme(ndev, param);
2282 case PRISM2_HOSTAPD_SCAN_REQ:
2283 printk(KERN_DEBUG "%s: Caught WPA supplicant scan request\n",
2285 ret = prism2_ioctl_scan_req(ndev, param);
2287 case PRISM54_SET_WPA:
2288 printk(KERN_DEBUG "%s: Caught WPA supplicant wpa init request\n",
2291 ret = prism54_set_wpa(ndev, NULL, &uwrq, NULL);
2293 case PRISM54_DROP_UNENCRYPTED:
2294 printk(KERN_DEBUG "%s: Caught WPA drop unencrypted request\n",
2298 mgt_set(priv, DOT11_OID_EXUNENCRYPTED, &uwrq);
2299 down_write(&priv->mib_sem);
2301 up_write(&priv->mib_sem);
2303 /* Not necessary, as set_wpa does it, should we just do it here though? */
2307 printk(KERN_DEBUG "%s: Caught a WPA supplicant request that is not supported\n",
2313 if (ret == 0 && copy_to_user(p->pointer, param, p->length))
2322 prism54_set_wpa(struct net_device *ndev, struct iw_request_info *info,
2323 __u32 * uwrq, char *extra)
2325 islpci_private *priv = netdev_priv(ndev);
2326 u32 mlme, authen, dot1x, filter, wep;
2328 if (islpci_get_state(priv) < PRV_STATE_INIT)
2331 wep = 1; /* For privacy invoked */
2332 filter = 1; /* Filter out all unencrypted frames */
2333 dot1x = 0x01; /* To enable eap filter */
2334 mlme = DOT11_MLME_EXTENDED;
2335 authen = DOT11_AUTH_OS; /* Only WEP uses _SK and _BOTH */
2337 down_write(&priv->mib_sem);
2340 switch (priv->wpa) {
2342 case 0: /* Clears/disables WPA and friends */
2344 filter = 0; /* Do not filter un-encrypted data */
2346 mlme = DOT11_MLME_AUTO;
2347 printk("%s: Disabling WPA\n", ndev->name);
2351 printk("%s: Enabling WPA\n", ndev->name);
2354 up_write(&priv->mib_sem);
2356 mgt_set_request(priv, DOT11_OID_AUTHENABLE, 0, &authen);
2357 mgt_set_request(priv, DOT11_OID_PRIVACYINVOKED, 0, &wep);
2358 mgt_set_request(priv, DOT11_OID_EXUNENCRYPTED, 0, &filter);
2359 mgt_set_request(priv, DOT11_OID_DOT1XENABLE, 0, &dot1x);
2360 mgt_set_request(priv, DOT11_OID_MLMEAUTOLEVEL, 0, &mlme);
2366 prism54_get_wpa(struct net_device *ndev, struct iw_request_info *info,
2367 __u32 * uwrq, char *extra)
2369 islpci_private *priv = netdev_priv(ndev);
2375 prism54_set_prismhdr(struct net_device *ndev, struct iw_request_info *info,
2376 __u32 * uwrq, char *extra)
2378 islpci_private *priv = netdev_priv(ndev);
2379 priv->monitor_type =
2380 (*uwrq ? ARPHRD_IEEE80211_PRISM : ARPHRD_IEEE80211);
2381 if (priv->iw_mode == IW_MODE_MONITOR)
2382 priv->ndev->type = priv->monitor_type;
2388 prism54_get_prismhdr(struct net_device *ndev, struct iw_request_info *info,
2389 __u32 * uwrq, char *extra)
2391 islpci_private *priv = netdev_priv(ndev);
2392 *uwrq = (priv->monitor_type == ARPHRD_IEEE80211_PRISM);
2397 prism54_debug_oid(struct net_device *ndev, struct iw_request_info *info,
2398 __u32 * uwrq, char *extra)
2400 islpci_private *priv = netdev_priv(ndev);
2402 priv->priv_oid = *uwrq;
2403 printk("%s: oid 0x%08X\n", ndev->name, *uwrq);
2409 prism54_debug_get_oid(struct net_device *ndev, struct iw_request_info *info,
2410 struct iw_point *data, char *extra)
2412 islpci_private *priv = netdev_priv(ndev);
2413 struct islpci_mgmtframe *response;
2416 printk("%s: get_oid 0x%08X\n", ndev->name, priv->priv_oid);
2419 if (islpci_get_state(priv) >= PRV_STATE_INIT) {
2421 islpci_mgt_transaction(priv->ndev, PIMFOR_OP_GET,
2422 priv->priv_oid, extra, 256,
2424 printk("%s: ret: %i\n", ndev->name, ret);
2425 if (ret || !response
2426 || response->header->operation == PIMFOR_OP_ERROR) {
2428 islpci_mgt_release(response);
2430 printk("%s: EIO\n", ndev->name);
2434 data->length = response->header->length;
2435 memcpy(extra, response->data, data->length);
2436 islpci_mgt_release(response);
2437 printk("%s: len: %i\n", ndev->name, data->length);
2445 prism54_debug_set_oid(struct net_device *ndev, struct iw_request_info *info,
2446 struct iw_point *data, char *extra)
2448 islpci_private *priv = netdev_priv(ndev);
2449 struct islpci_mgmtframe *response;
2450 int ret = 0, response_op = PIMFOR_OP_ERROR;
2452 printk("%s: set_oid 0x%08X\tlen: %d\n", ndev->name, priv->priv_oid,
2455 if (islpci_get_state(priv) >= PRV_STATE_INIT) {
2457 islpci_mgt_transaction(priv->ndev, PIMFOR_OP_SET,
2458 priv->priv_oid, extra, data->length,
2460 printk("%s: ret: %i\n", ndev->name, ret);
2461 if (ret || !response
2462 || response->header->operation == PIMFOR_OP_ERROR) {
2464 islpci_mgt_release(response);
2466 printk("%s: EIO\n", ndev->name);
2470 response_op = response->header->operation;
2471 printk("%s: response_op: %i\n", ndev->name,
2473 islpci_mgt_release(response);
2477 return (ret ? ret : -EINPROGRESS);
2481 prism54_set_spy(struct net_device *ndev,
2482 struct iw_request_info *info,
2483 union iwreq_data *uwrq, char *extra)
2485 islpci_private *priv = netdev_priv(ndev);
2486 u32 u, oid = OID_INL_CONFIG;
2488 down_write(&priv->mib_sem);
2489 mgt_get(priv, OID_INL_CONFIG, &u);
2491 if ((uwrq->data.length == 0) && (priv->spy_data.spy_number > 0))
2493 u &= ~INL_CONFIG_RXANNEX;
2494 else if ((uwrq->data.length > 0) && (priv->spy_data.spy_number == 0))
2496 u |= INL_CONFIG_RXANNEX;
2498 mgt_set(priv, OID_INL_CONFIG, &u);
2499 mgt_commit_list(priv, &oid, 1);
2500 up_write(&priv->mib_sem);
2502 return iw_handler_set_spy(ndev, info, uwrq, extra);
2505 static const iw_handler prism54_handler[] = {
2506 (iw_handler) prism54_commit, /* SIOCSIWCOMMIT */
2507 (iw_handler) prism54_get_name, /* SIOCGIWNAME */
2508 (iw_handler) NULL, /* SIOCSIWNWID */
2509 (iw_handler) NULL, /* SIOCGIWNWID */
2510 (iw_handler) prism54_set_freq, /* SIOCSIWFREQ */
2511 (iw_handler) prism54_get_freq, /* SIOCGIWFREQ */
2512 (iw_handler) prism54_set_mode, /* SIOCSIWMODE */
2513 (iw_handler) prism54_get_mode, /* SIOCGIWMODE */
2514 (iw_handler) prism54_set_sens, /* SIOCSIWSENS */
2515 (iw_handler) prism54_get_sens, /* SIOCGIWSENS */
2516 (iw_handler) NULL, /* SIOCSIWRANGE */
2517 (iw_handler) prism54_get_range, /* SIOCGIWRANGE */
2518 (iw_handler) NULL, /* SIOCSIWPRIV */
2519 (iw_handler) NULL, /* SIOCGIWPRIV */
2520 (iw_handler) NULL, /* SIOCSIWSTATS */
2521 (iw_handler) NULL, /* SIOCGIWSTATS */
2522 prism54_set_spy, /* SIOCSIWSPY */
2523 iw_handler_get_spy, /* SIOCGIWSPY */
2524 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
2525 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
2526 (iw_handler) prism54_set_wap, /* SIOCSIWAP */
2527 (iw_handler) prism54_get_wap, /* SIOCGIWAP */
2528 (iw_handler) NULL, /* -- hole -- */
2529 (iw_handler) NULL, /* SIOCGIWAPLIST depreciated */
2530 (iw_handler) prism54_set_scan, /* SIOCSIWSCAN */
2531 (iw_handler) prism54_get_scan, /* SIOCGIWSCAN */
2532 (iw_handler) prism54_set_essid, /* SIOCSIWESSID */
2533 (iw_handler) prism54_get_essid, /* SIOCGIWESSID */
2534 (iw_handler) prism54_set_nick, /* SIOCSIWNICKN */
2535 (iw_handler) prism54_get_nick, /* SIOCGIWNICKN */
2536 (iw_handler) NULL, /* -- hole -- */
2537 (iw_handler) NULL, /* -- hole -- */
2538 (iw_handler) prism54_set_rate, /* SIOCSIWRATE */
2539 (iw_handler) prism54_get_rate, /* SIOCGIWRATE */
2540 (iw_handler) prism54_set_rts, /* SIOCSIWRTS */
2541 (iw_handler) prism54_get_rts, /* SIOCGIWRTS */
2542 (iw_handler) prism54_set_frag, /* SIOCSIWFRAG */
2543 (iw_handler) prism54_get_frag, /* SIOCGIWFRAG */
2544 (iw_handler) prism54_set_txpower, /* SIOCSIWTXPOW */
2545 (iw_handler) prism54_get_txpower, /* SIOCGIWTXPOW */
2546 (iw_handler) prism54_set_retry, /* SIOCSIWRETRY */
2547 (iw_handler) prism54_get_retry, /* SIOCGIWRETRY */
2548 (iw_handler) prism54_set_encode, /* SIOCSIWENCODE */
2549 (iw_handler) prism54_get_encode, /* SIOCGIWENCODE */
2550 (iw_handler) NULL, /* SIOCSIWPOWER */
2551 (iw_handler) NULL, /* SIOCGIWPOWER */
2554 /* The low order bit identify a SET (0) or a GET (1) ioctl. */
2556 #define PRISM54_RESET SIOCIWFIRSTPRIV
2557 #define PRISM54_GET_POLICY SIOCIWFIRSTPRIV+1
2558 #define PRISM54_SET_POLICY SIOCIWFIRSTPRIV+2
2559 #define PRISM54_GET_MAC SIOCIWFIRSTPRIV+3
2560 #define PRISM54_ADD_MAC SIOCIWFIRSTPRIV+4
2562 #define PRISM54_DEL_MAC SIOCIWFIRSTPRIV+6
2564 #define PRISM54_KICK_MAC SIOCIWFIRSTPRIV+8
2566 #define PRISM54_KICK_ALL SIOCIWFIRSTPRIV+10
2568 #define PRISM54_GET_WPA SIOCIWFIRSTPRIV+11
2569 #define PRISM54_SET_WPA SIOCIWFIRSTPRIV+12
2571 #define PRISM54_DBG_OID SIOCIWFIRSTPRIV+14
2572 #define PRISM54_DBG_GET_OID SIOCIWFIRSTPRIV+15
2573 #define PRISM54_DBG_SET_OID SIOCIWFIRSTPRIV+16
2575 #define PRISM54_GET_OID SIOCIWFIRSTPRIV+17
2576 #define PRISM54_SET_OID_U32 SIOCIWFIRSTPRIV+18
2577 #define PRISM54_SET_OID_STR SIOCIWFIRSTPRIV+20
2578 #define PRISM54_SET_OID_ADDR SIOCIWFIRSTPRIV+22
2580 #define PRISM54_GET_PRISMHDR SIOCIWFIRSTPRIV+23
2581 #define PRISM54_SET_PRISMHDR SIOCIWFIRSTPRIV+24
2583 #define IWPRIV_SET_U32(n,x) { n, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "s_"x }
2584 #define IWPRIV_SET_SSID(n,x) { n, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 1, 0, "s_"x }
2585 #define IWPRIV_SET_ADDR(n,x) { n, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "s_"x }
2586 #define IWPRIV_GET(n,x) { n, 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | PRIV_STR_SIZE, "g_"x }
2588 #define IWPRIV_U32(n,x) IWPRIV_SET_U32(n,x), IWPRIV_GET(n,x)
2589 #define IWPRIV_SSID(n,x) IWPRIV_SET_SSID(n,x), IWPRIV_GET(n,x)
2590 #define IWPRIV_ADDR(n,x) IWPRIV_SET_ADDR(n,x), IWPRIV_GET(n,x)
2592 /* Note : limited to 128 private ioctls (wireless tools 26) */
2594 static const struct iw_priv_args prism54_private_args[] = {
2595 /*{ cmd, set_args, get_args, name } */
2596 {PRISM54_RESET, 0, 0, "reset"},
2597 {PRISM54_GET_PRISMHDR, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
2599 {PRISM54_SET_PRISMHDR, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
2601 {PRISM54_GET_POLICY, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
2603 {PRISM54_SET_POLICY, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
2605 {PRISM54_GET_MAC, 0, IW_PRIV_TYPE_ADDR | 64, "getMac"},
2606 {PRISM54_ADD_MAC, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0,
2608 {PRISM54_DEL_MAC, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0,
2610 {PRISM54_KICK_MAC, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0,
2612 {PRISM54_KICK_ALL, 0, 0, "kickAll"},
2613 {PRISM54_GET_WPA, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
2615 {PRISM54_SET_WPA, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
2617 {PRISM54_DBG_OID, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
2619 {PRISM54_DBG_GET_OID, 0, IW_PRIV_TYPE_BYTE | 256, "dbg_get_oid"},
2620 {PRISM54_DBG_SET_OID, IW_PRIV_TYPE_BYTE | 256, 0, "dbg_set_oid"},
2621 /* --- sub-ioctls handlers --- */
2623 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | PRIV_STR_SIZE, ""},
2624 {PRISM54_SET_OID_U32,
2625 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, ""},
2626 {PRISM54_SET_OID_STR,
2627 IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 1, 0, ""},
2628 {PRISM54_SET_OID_ADDR,
2629 IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, ""},
2630 /* --- sub-ioctls definitions --- */
2631 IWPRIV_ADDR(GEN_OID_MACADDRESS, "addr"),
2632 IWPRIV_GET(GEN_OID_LINKSTATE, "linkstate"),
2633 IWPRIV_U32(DOT11_OID_BSSTYPE, "bsstype"),
2634 IWPRIV_ADDR(DOT11_OID_BSSID, "bssid"),
2635 IWPRIV_U32(DOT11_OID_STATE, "state"),
2636 IWPRIV_U32(DOT11_OID_AID, "aid"),
2638 IWPRIV_SSID(DOT11_OID_SSIDOVERRIDE, "ssidoverride"),
2640 IWPRIV_U32(DOT11_OID_MEDIUMLIMIT, "medlimit"),
2641 IWPRIV_U32(DOT11_OID_BEACONPERIOD, "beacon"),
2642 IWPRIV_U32(DOT11_OID_DTIMPERIOD, "dtimperiod"),
2644 IWPRIV_U32(DOT11_OID_AUTHENABLE, "authenable"),
2645 IWPRIV_U32(DOT11_OID_PRIVACYINVOKED, "privinvok"),
2646 IWPRIV_U32(DOT11_OID_EXUNENCRYPTED, "exunencrypt"),
2648 IWPRIV_U32(DOT11_OID_REKEYTHRESHOLD, "rekeythresh"),
2650 IWPRIV_U32(DOT11_OID_MAXTXLIFETIME, "maxtxlife"),
2651 IWPRIV_U32(DOT11_OID_MAXRXLIFETIME, "maxrxlife"),
2652 IWPRIV_U32(DOT11_OID_ALOFT_FIXEDRATE, "fixedrate"),
2653 IWPRIV_U32(DOT11_OID_MAXFRAMEBURST, "frameburst"),
2654 IWPRIV_U32(DOT11_OID_PSM, "psm"),
2656 IWPRIV_U32(DOT11_OID_BRIDGELOCAL, "bridge"),
2657 IWPRIV_U32(DOT11_OID_CLIENTS, "clients"),
2658 IWPRIV_U32(DOT11_OID_CLIENTSASSOCIATED, "clientassoc"),
2659 IWPRIV_U32(DOT11_OID_DOT1XENABLE, "dot1xenable"),
2660 IWPRIV_U32(DOT11_OID_ANTENNARX, "rxant"),
2661 IWPRIV_U32(DOT11_OID_ANTENNATX, "txant"),
2662 IWPRIV_U32(DOT11_OID_ANTENNADIVERSITY, "antdivers"),
2663 IWPRIV_U32(DOT11_OID_EDTHRESHOLD, "edthresh"),
2664 IWPRIV_U32(DOT11_OID_PREAMBLESETTINGS, "preamble"),
2665 IWPRIV_GET(DOT11_OID_RATES, "rates"),
2666 IWPRIV_U32(DOT11_OID_OUTPUTPOWER, ".11outpower"),
2667 IWPRIV_GET(DOT11_OID_SUPPORTEDRATES, "supprates"),
2668 IWPRIV_GET(DOT11_OID_SUPPORTEDFREQUENCIES, "suppfreq"),
2670 IWPRIV_U32(DOT11_OID_NOISEFLOOR, "noisefloor"),
2671 IWPRIV_GET(DOT11_OID_FREQUENCYACTIVITY, "freqactivity"),
2672 IWPRIV_U32(DOT11_OID_NONERPPROTECTION, "nonerpprotec"),
2673 IWPRIV_U32(DOT11_OID_PROFILES, "profile"),
2674 IWPRIV_GET(DOT11_OID_EXTENDEDRATES, "extrates"),
2675 IWPRIV_U32(DOT11_OID_MLMEAUTOLEVEL, "mlmelevel"),
2677 IWPRIV_GET(DOT11_OID_BSSS, "bsss"),
2678 IWPRIV_GET(DOT11_OID_BSSLIST, "bsslist"),
2679 IWPRIV_U32(OID_INL_MODE, "mode"),
2680 IWPRIV_U32(OID_INL_CONFIG, "config"),
2681 IWPRIV_U32(OID_INL_DOT11D_CONFORMANCE, ".11dconform"),
2682 IWPRIV_GET(OID_INL_PHYCAPABILITIES, "phycapa"),
2683 IWPRIV_U32(OID_INL_OUTPUTPOWER, "outpower"),
2686 static const iw_handler prism54_private_handler[] = {
2687 (iw_handler) prism54_reset,
2688 (iw_handler) prism54_get_policy,
2689 (iw_handler) prism54_set_policy,
2690 (iw_handler) prism54_get_mac,
2691 (iw_handler) prism54_add_mac,
2693 (iw_handler) prism54_del_mac,
2695 (iw_handler) prism54_kick_mac,
2697 (iw_handler) prism54_kick_all,
2698 (iw_handler) prism54_get_wpa,
2699 (iw_handler) prism54_set_wpa,
2701 (iw_handler) prism54_debug_oid,
2702 (iw_handler) prism54_debug_get_oid,
2703 (iw_handler) prism54_debug_set_oid,
2704 (iw_handler) prism54_get_oid,
2705 (iw_handler) prism54_set_u32,
2707 (iw_handler) prism54_set_raw,
2709 (iw_handler) prism54_set_raw,
2710 (iw_handler) prism54_get_prismhdr,
2711 (iw_handler) prism54_set_prismhdr,
2714 const struct iw_handler_def prism54_handler_def = {
2715 .num_standard = sizeof (prism54_handler) / sizeof (iw_handler),
2716 .num_private = sizeof (prism54_private_handler) / sizeof (iw_handler),
2718 sizeof (prism54_private_args) / sizeof (struct iw_priv_args),
2719 .standard = (iw_handler *) prism54_handler,
2720 .private = (iw_handler *) prism54_private_handler,
2721 .private_args = (struct iw_priv_args *) prism54_private_args,
2722 #if WIRELESS_EXT == 16
2723 .spy_offset = offsetof(islpci_private, spy_data),
2724 #endif /* WIRELESS_EXT == 16 */
2727 /* For wpa_supplicant */
2730 prism54_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
2732 struct iwreq *wrq = (struct iwreq *) rq;
2735 case PRISM54_HOSTAPD:
2736 if (!capable(CAP_NET_ADMIN))
2738 ret = prism54_hostapd(ndev, &wrq->u.data);