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 *,
50 static const unsigned char scan_rate_list[] = { 2, 4, 11, 22,
55 * prism54_mib_mode_helper - MIB change mode helper function
56 * @mib: the &struct islpci_mib object to modify
57 * @iw_mode: new mode (%IW_MODE_*)
59 * This is a helper function, hence it does not lock. Make sure
60 * caller deals with locking *if* necessary. This function sets the
61 * mode-dependent mib values and does the mapping of the Linux
62 * Wireless API modes to Device firmware modes. It also checks for
63 * correct valid Linux wireless modes.
66 prism54_mib_mode_helper(islpci_private *priv, u32 iw_mode)
68 u32 config = INL_CONFIG_MANUALRUN;
71 /* For now, just catch early the Repeater and Secondary modes here */
72 if (iw_mode == IW_MODE_REPEAT || iw_mode == IW_MODE_SECOND) {
74 "%s(): Sorry, Repeater mode and Secondary mode "
75 "are not yet supported by this driver.\n", __FUNCTION__);
79 priv->iw_mode = iw_mode;
83 mode = INL_MODE_CLIENT;
84 bsstype = DOT11_BSSTYPE_ANY;
87 mode = INL_MODE_CLIENT;
88 bsstype = DOT11_BSSTYPE_IBSS;
91 mode = INL_MODE_CLIENT;
92 bsstype = DOT11_BSSTYPE_INFRA;
96 bsstype = DOT11_BSSTYPE_INFRA;
99 mode = INL_MODE_PROMISCUOUS;
100 bsstype = DOT11_BSSTYPE_ANY;
101 config |= INL_CONFIG_RXANNEX;
108 config |= INL_CONFIG_WDS;
109 mgt_set(priv, DOT11_OID_BSSTYPE, &bsstype);
110 mgt_set(priv, OID_INL_CONFIG, &config);
111 mgt_set(priv, OID_INL_MODE, &mode);
117 * prism54_mib_init - fill MIB cache with defaults
119 * this function initializes the struct given as @mib with defaults,
120 * of which many are retrieved from the global module parameter
125 prism54_mib_init(islpci_private *priv)
127 u32 channel, authen, wep, filter, dot1x, mlme, conformance, power, mode;
128 struct obj_buffer psm_buffer = {
129 .size = PSM_BUFFER_SIZE,
130 .addr = priv->device_psm_buffer
133 channel = CARD_DEFAULT_CHANNEL;
134 authen = CARD_DEFAULT_AUTHEN;
135 wep = CARD_DEFAULT_WEP;
136 filter = CARD_DEFAULT_FILTER; /* (0) Do not filter un-encrypted data */
137 dot1x = CARD_DEFAULT_DOT1X;
138 mlme = CARD_DEFAULT_MLME_MODE;
139 conformance = CARD_DEFAULT_CONFORMANCE;
141 mode = CARD_DEFAULT_IW_MODE;
143 mgt_set(priv, DOT11_OID_CHANNEL, &channel);
144 mgt_set(priv, DOT11_OID_AUTHENABLE, &authen);
145 mgt_set(priv, DOT11_OID_PRIVACYINVOKED, &wep);
146 mgt_set(priv, DOT11_OID_PSMBUFFER, &psm_buffer);
147 mgt_set(priv, DOT11_OID_EXUNENCRYPTED, &filter);
148 mgt_set(priv, DOT11_OID_DOT1XENABLE, &dot1x);
149 mgt_set(priv, DOT11_OID_MLMEAUTOLEVEL, &mlme);
150 mgt_set(priv, OID_INL_DOT11D_CONFORMANCE, &conformance);
151 mgt_set(priv, OID_INL_OUTPUTPOWER, &power);
153 /* This sets all of the mode-dependent values */
154 prism54_mib_mode_helper(priv, mode);
157 /* this will be executed outside of atomic context thanks to
158 * schedule_work(), thus we can as well use sleeping semaphore
161 prism54_update_stats(struct work_struct *work)
163 islpci_private *priv = container_of(work, islpci_private, stats_work);
166 struct obj_bss bss, *bss2;
169 if (down_interruptible(&priv->stats_sem))
173 * I'm not sure if the unit is dBm.
174 * Note : If we are not connected, this value seems to be irrelevant. */
176 mgt_get_request(priv, DOT11_OID_NOISEFLOOR, 0, NULL, &r);
177 priv->local_iwstatistics.qual.noise = r.u;
179 /* Get the rssi of the link. To do this we need to retrieve a bss. */
181 /* First get the MAC address of the AP we are associated with. */
182 mgt_get_request(priv, DOT11_OID_BSSID, 0, NULL, &r);
185 /* copy this MAC to the bss */
186 memcpy(bss.address, data, 6);
189 /* now ask for the corresponding bss */
190 j = mgt_get_request(priv, DOT11_OID_BSSFIND, 0, (void *) &bss, &r);
192 /* report the rssi and use it to calculate
193 * link quality through a signal-noise
195 priv->local_iwstatistics.qual.level = bss2->rssi;
196 priv->local_iwstatistics.qual.qual =
197 bss2->rssi - priv->iwstatistics.qual.noise;
201 /* report that the stats are new */
202 priv->local_iwstatistics.qual.updated = 0x7;
204 /* Rx : unable to decrypt the MPDU */
205 mgt_get_request(priv, DOT11_OID_PRIVRXFAILED, 0, NULL, &r);
206 priv->local_iwstatistics.discard.code = r.u;
208 /* Tx : Max MAC retries num reached */
209 mgt_get_request(priv, DOT11_OID_MPDUTXFAILED, 0, NULL, &r);
210 priv->local_iwstatistics.discard.retries = r.u;
212 up(&priv->stats_sem);
217 struct iw_statistics *
218 prism54_get_wireless_stats(struct net_device *ndev)
220 islpci_private *priv = netdev_priv(ndev);
222 /* If the stats are being updated return old data */
223 if (down_trylock(&priv->stats_sem) == 0) {
224 memcpy(&priv->iwstatistics, &priv->local_iwstatistics,
225 sizeof (struct iw_statistics));
226 /* They won't be marked updated for the next time */
227 priv->local_iwstatistics.qual.updated = 0;
228 up(&priv->stats_sem);
230 priv->iwstatistics.qual.updated = 0;
232 /* Update our wireless stats, but do not schedule to often
234 if ((priv->stats_timestamp == 0) ||
235 time_after(jiffies, priv->stats_timestamp + 1 * HZ)) {
236 schedule_work(&priv->stats_work);
237 priv->stats_timestamp = jiffies;
240 return &priv->iwstatistics;
244 prism54_commit(struct net_device *ndev, struct iw_request_info *info,
245 char *cwrq, char *extra)
247 islpci_private *priv = netdev_priv(ndev);
249 /* simply re-set the last set SSID, this should commit most stuff */
251 /* Commit in Monitor mode is not necessary, also setting essid
252 * in Monitor mode does not make sense and isn't allowed for this
253 * device's firmware */
254 if (priv->iw_mode != IW_MODE_MONITOR)
255 return mgt_set_request(priv, DOT11_OID_SSID, 0, NULL);
260 prism54_get_name(struct net_device *ndev, struct iw_request_info *info,
261 char *cwrq, char *extra)
263 islpci_private *priv = netdev_priv(ndev);
268 if (islpci_get_state(priv) < PRV_STATE_INIT) {
269 strncpy(cwrq, "NOT READY!", IFNAMSIZ);
272 rvalue = mgt_get_request(priv, OID_INL_PHYCAPABILITIES, 0, NULL, &r);
275 case INL_PHYCAP_5000MHZ:
276 capabilities = "IEEE 802.11a/b/g";
279 capabilities = "IEEE 802.11b/g - FAA Support";
281 case INL_PHYCAP_2400MHZ:
283 capabilities = "IEEE 802.11b/g"; /* Default */
286 strncpy(cwrq, capabilities, IFNAMSIZ);
291 prism54_set_freq(struct net_device *ndev, struct iw_request_info *info,
292 struct iw_freq *fwrq, char *extra)
294 islpci_private *priv = netdev_priv(ndev);
299 /* we have a channel number */
302 c = (fwrq->e == 1) ? channel_of_freq(fwrq->m / 100000) : 0;
304 rvalue = c ? mgt_set_request(priv, DOT11_OID_CHANNEL, 0, &c) : -EINVAL;
306 /* Call commit handler */
307 return (rvalue ? rvalue : -EINPROGRESS);
311 prism54_get_freq(struct net_device *ndev, struct iw_request_info *info,
312 struct iw_freq *fwrq, char *extra)
314 islpci_private *priv = netdev_priv(ndev);
318 rvalue = mgt_get_request(priv, DOT11_OID_CHANNEL, 0, NULL, &r);
320 rvalue |= mgt_get_request(priv, DOT11_OID_FREQUENCY, 0, NULL, &r);
328 prism54_set_mode(struct net_device *ndev, struct iw_request_info *info,
329 __u32 * uwrq, char *extra)
331 islpci_private *priv = netdev_priv(ndev);
332 u32 mlmeautolevel = CARD_DEFAULT_MLME_MODE;
334 /* Let's see if the user passed a valid Linux Wireless mode */
335 if (*uwrq > IW_MODE_MONITOR || *uwrq < IW_MODE_AUTO) {
337 "%s: %s() You passed a non-valid init_mode.\n",
338 priv->ndev->name, __FUNCTION__);
342 down_write(&priv->mib_sem);
344 if (prism54_mib_mode_helper(priv, *uwrq)) {
345 up_write(&priv->mib_sem);
349 /* the ACL code needs an intermediate mlmeautolevel. The wpa stuff an
352 if ((*uwrq == IW_MODE_MASTER) && (priv->acl.policy != MAC_POLICY_OPEN))
353 mlmeautolevel = DOT11_MLME_INTERMEDIATE;
355 mlmeautolevel = DOT11_MLME_EXTENDED;
357 mgt_set(priv, DOT11_OID_MLMEAUTOLEVEL, &mlmeautolevel);
359 if (mgt_commit(priv)) {
360 up_write(&priv->mib_sem);
363 priv->ndev->type = (priv->iw_mode == IW_MODE_MONITOR)
364 ? priv->monitor_type : ARPHRD_ETHER;
365 up_write(&priv->mib_sem);
372 prism54_get_mode(struct net_device *ndev, struct iw_request_info *info,
373 __u32 * uwrq, char *extra)
375 islpci_private *priv = netdev_priv(ndev);
377 BUG_ON((priv->iw_mode < IW_MODE_AUTO) || (priv->iw_mode >
379 *uwrq = priv->iw_mode;
384 /* we use DOT11_OID_EDTHRESHOLD. From what I guess the card will not try to
385 * emit data if (sensitivity > rssi - noise) (in dBm).
386 * prism54_set_sens does not seem to work.
390 prism54_set_sens(struct net_device *ndev, struct iw_request_info *info,
391 struct iw_param *vwrq, char *extra)
393 islpci_private *priv = netdev_priv(ndev);
396 /* by default the card sets this to 20. */
397 sens = vwrq->disabled ? 20 : vwrq->value;
399 return mgt_set_request(priv, DOT11_OID_EDTHRESHOLD, 0, &sens);
403 prism54_get_sens(struct net_device *ndev, struct iw_request_info *info,
404 struct iw_param *vwrq, char *extra)
406 islpci_private *priv = netdev_priv(ndev);
410 rvalue = mgt_get_request(priv, DOT11_OID_EDTHRESHOLD, 0, NULL, &r);
413 vwrq->disabled = (vwrq->value == 0);
420 prism54_get_range(struct net_device *ndev, struct iw_request_info *info,
421 struct iw_point *dwrq, char *extra)
423 struct iw_range *range = (struct iw_range *) extra;
424 islpci_private *priv = netdev_priv(ndev);
427 struct obj_frequencies *freq;
430 memset(range, 0, sizeof (struct iw_range));
431 dwrq->length = sizeof (struct iw_range);
433 /* set the wireless extension version number */
434 range->we_version_source = SUPPORTED_WIRELESS_EXT;
435 range->we_version_compiled = WIRELESS_EXT;
437 /* Now the encoding capabilities */
438 range->num_encoding_sizes = 3;
439 /* 64(40) bits WEP */
440 range->encoding_size[0] = 5;
441 /* 128(104) bits WEP */
442 range->encoding_size[1] = 13;
443 /* 256 bits for WPA-PSK */
444 range->encoding_size[2] = 32;
445 /* 4 keys are allowed */
446 range->max_encoding_tokens = 4;
448 /* we don't know the quality range... */
449 range->max_qual.level = 0;
450 range->max_qual.noise = 0;
451 range->max_qual.qual = 0;
452 /* these value describe an average quality. Needs more tweaking... */
453 range->avg_qual.level = -80; /* -80 dBm */
454 range->avg_qual.noise = 0; /* don't know what to put here */
455 range->avg_qual.qual = 0;
457 range->sensitivity = 200;
459 /* retry limit capabilities */
460 range->retry_capa = IW_RETRY_LIMIT | IW_RETRY_LIFETIME;
461 range->retry_flags = IW_RETRY_LIMIT;
462 range->r_time_flags = IW_RETRY_LIFETIME;
464 /* I don't know the range. Put stupid things here */
465 range->min_retry = 1;
466 range->max_retry = 65535;
467 range->min_r_time = 1024;
468 range->max_r_time = 65535 * 1024;
470 /* txpower is supported in dBm's */
471 range->txpower_capa = IW_TXPOW_DBM;
473 /* Event capability (kernel + driver) */
474 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
475 IW_EVENT_CAPA_MASK(SIOCGIWTHRSPY) |
476 IW_EVENT_CAPA_MASK(SIOCGIWAP));
477 range->event_capa[1] = IW_EVENT_CAPA_K_1;
478 range->event_capa[4] = IW_EVENT_CAPA_MASK(IWEVCUSTOM);
480 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
481 IW_ENC_CAPA_CIPHER_TKIP;
483 if (islpci_get_state(priv) < PRV_STATE_INIT)
486 /* Request the device for the supported frequencies
487 * not really relevant since some devices will report the 5 GHz band
488 * frequencies even if they don't support them.
491 mgt_get_request(priv, DOT11_OID_SUPPORTEDFREQUENCIES, 0, NULL, &r);
494 range->num_channels = freq->nr;
495 range->num_frequency = freq->nr;
497 m = min(IW_MAX_FREQUENCIES, (int) freq->nr);
498 for (i = 0; i < m; i++) {
499 range->freq[i].m = freq->mhz[i];
500 range->freq[i].e = 6;
501 range->freq[i].i = channel_of_freq(freq->mhz[i]);
505 rvalue |= mgt_get_request(priv, DOT11_OID_SUPPORTEDRATES, 0, NULL, &r);
508 /* We got an array of char. It is NULL terminated. */
510 while ((i < IW_MAX_BITRATES) && (*data != 0)) {
511 /* the result must be in bps. The card gives us 500Kbps */
512 range->bitrate[i] = *data * 500000;
516 range->num_bitrates = i;
525 prism54_set_wap(struct net_device *ndev, struct iw_request_info *info,
526 struct sockaddr *awrq, char *extra)
528 islpci_private *priv = netdev_priv(ndev);
532 if (awrq->sa_family != ARPHRD_ETHER)
535 /* prepare the structure for the set object */
536 memcpy(&bssid[0], awrq->sa_data, 6);
538 /* set the bssid -- does this make sense when in AP mode? */
539 rvalue = mgt_set_request(priv, DOT11_OID_BSSID, 0, &bssid);
541 return (rvalue ? rvalue : -EINPROGRESS); /* Call commit handler */
547 prism54_get_wap(struct net_device *ndev, struct iw_request_info *info,
548 struct sockaddr *awrq, char *extra)
550 islpci_private *priv = netdev_priv(ndev);
554 rvalue = mgt_get_request(priv, DOT11_OID_BSSID, 0, NULL, &r);
555 memcpy(awrq->sa_data, r.ptr, 6);
556 awrq->sa_family = ARPHRD_ETHER;
563 prism54_set_scan(struct net_device *dev, struct iw_request_info *info,
564 struct iw_param *vwrq, char *extra)
566 /* hehe the device does this automagicaly */
570 /* a little helper that will translate our data into a card independent
571 * format that the Wireless Tools will understand. This was inspired by
572 * the "Aironet driver for 4500 and 4800 series cards" (GPL)
576 prism54_translate_bss(struct net_device *ndev, char *current_ev,
577 char *end_buf, struct obj_bss *bss, char noise)
579 struct iw_event iwe; /* Temporary buffer */
581 islpci_private *priv = netdev_priv(ndev);
582 u8 wpa_ie[MAX_WPA_IE_LEN];
585 /* The first entry must be the MAC address */
586 memcpy(iwe.u.ap_addr.sa_data, bss->address, 6);
587 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
590 iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_ADDR_LEN);
592 /* The following entries will be displayed in the same order we give them */
595 iwe.u.data.length = bss->ssid.length;
596 iwe.u.data.flags = 1;
597 iwe.cmd = SIOCGIWESSID;
598 current_ev = iwe_stream_add_point(current_ev, end_buf,
599 &iwe, bss->ssid.octets);
603 #define CAP_IBSS 0x02
604 #define CAP_CRYPT 0x10
610 iwe.u.mode = IW_MODE_MASTER;
611 else if (cap & CAP_IBSS)
612 iwe.u.mode = IW_MODE_ADHOC;
613 iwe.cmd = SIOCGIWMODE;
616 iwe_stream_add_event(current_ev, end_buf, &iwe,
619 /* Encryption capability */
621 iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
623 iwe.u.data.flags = IW_ENCODE_DISABLED;
624 iwe.u.data.length = 0;
625 iwe.cmd = SIOCGIWENCODE;
626 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, NULL);
628 /* Add frequency. (short) bss->channel is the frequency in MHz */
629 iwe.u.freq.m = bss->channel;
631 iwe.cmd = SIOCGIWFREQ;
633 iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
635 /* Add quality statistics */
636 iwe.u.qual.level = bss->rssi;
637 iwe.u.qual.noise = noise;
638 /* do a simple SNR for quality */
639 iwe.u.qual.qual = bss->rssi - noise;
642 iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
644 /* Add WPA/RSN Information Element, if any */
645 wpa_ie_len = prism54_wpa_bss_ie_get(priv, bss->address, wpa_ie);
646 if (wpa_ie_len > 0) {
648 iwe.u.data.length = min(wpa_ie_len, (size_t)MAX_WPA_IE_LEN);
649 current_ev = iwe_stream_add_point(current_ev, end_buf,
652 /* Do the bitrates */
654 char * current_val = current_ev + IW_EV_LCP_LEN;
658 iwe.cmd = SIOCGIWRATE;
659 /* Those two flags are ignored... */
660 iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
662 /* Parse the bitmask */
664 for(i = 0; i < sizeof(scan_rate_list); i++) {
665 if(bss->rates & mask) {
666 iwe.u.bitrate.value = (scan_rate_list[i] * 500000);
667 current_val = iwe_stream_add_value(current_ev, current_val,
673 /* Check if we added any event */
674 if ((current_val - current_ev) > IW_EV_LCP_LEN)
675 current_ev = current_val;
682 prism54_get_scan(struct net_device *ndev, struct iw_request_info *info,
683 struct iw_point *dwrq, char *extra)
685 islpci_private *priv = netdev_priv(ndev);
687 struct obj_bsslist *bsslist;
689 char *current_ev = extra;
692 if (islpci_get_state(priv) < PRV_STATE_INIT) {
693 /* device is not ready, fail gently */
698 /* first get the noise value. We will use it to report the link quality */
699 rvalue = mgt_get_request(priv, DOT11_OID_NOISEFLOOR, 0, NULL, &r);
702 /* Ask the device for a list of known bss.
703 * The old API, using SIOCGIWAPLIST, had a hard limit of IW_MAX_AP=64.
704 * The new API, using SIOCGIWSCAN, is only limited by the buffer size.
705 * WE-14->WE-16, the buffer is limited to IW_SCAN_MAX_DATA bytes.
706 * Starting with WE-17, the buffer can be as big as needed.
707 * But the device won't repport anything if you change the value
708 * of IWMAX_BSS=24. */
710 rvalue |= mgt_get_request(priv, DOT11_OID_BSSLIST, 0, NULL, &r);
713 /* ok now, scan the list and translate its info */
714 for (i = 0; i < (int) bsslist->nr; i++) {
715 current_ev = prism54_translate_bss(ndev, current_ev,
716 extra + dwrq->length,
717 &(bsslist->bsslist[i]),
720 /* Check if there is space for one more entry */
721 if((extra + dwrq->length - current_ev) <= IW_EV_ADDR_LEN) {
722 /* Ask user space to try again with a bigger buffer */
729 dwrq->length = (current_ev - extra);
730 dwrq->flags = 0; /* todo */
736 prism54_set_essid(struct net_device *ndev, struct iw_request_info *info,
737 struct iw_point *dwrq, char *extra)
739 islpci_private *priv = netdev_priv(ndev);
740 struct obj_ssid essid;
742 memset(essid.octets, 0, 33);
744 /* Check if we were asked for `any' */
745 if (dwrq->flags && dwrq->length) {
746 if (dwrq->length > 32)
748 essid.length = dwrq->length;
749 memcpy(essid.octets, extra, dwrq->length);
753 if (priv->iw_mode != IW_MODE_MONITOR)
754 return mgt_set_request(priv, DOT11_OID_SSID, 0, &essid);
756 /* If in monitor mode, just save to mib */
757 mgt_set(priv, DOT11_OID_SSID, &essid);
763 prism54_get_essid(struct net_device *ndev, struct iw_request_info *info,
764 struct iw_point *dwrq, char *extra)
766 islpci_private *priv = netdev_priv(ndev);
767 struct obj_ssid *essid;
771 rvalue = mgt_get_request(priv, DOT11_OID_SSID, 0, NULL, &r);
775 dwrq->flags = 1; /* set ESSID to ON for Wireless Extensions */
776 /* if it is too big, trunk it */
777 dwrq->length = min((u8)IW_ESSID_MAX_SIZE, essid->length);
782 essid->octets[essid->length] = '\0';
783 memcpy(extra, essid->octets, dwrq->length);
789 /* Provides no functionality, just completes the ioctl. In essence this is a
790 * just a cosmetic ioctl.
793 prism54_set_nick(struct net_device *ndev, struct iw_request_info *info,
794 struct iw_point *dwrq, char *extra)
796 islpci_private *priv = netdev_priv(ndev);
798 if (dwrq->length > IW_ESSID_MAX_SIZE)
801 down_write(&priv->mib_sem);
802 memset(priv->nickname, 0, sizeof (priv->nickname));
803 memcpy(priv->nickname, extra, dwrq->length);
804 up_write(&priv->mib_sem);
810 prism54_get_nick(struct net_device *ndev, struct iw_request_info *info,
811 struct iw_point *dwrq, char *extra)
813 islpci_private *priv = netdev_priv(ndev);
817 down_read(&priv->mib_sem);
818 dwrq->length = strlen(priv->nickname);
819 memcpy(extra, priv->nickname, dwrq->length);
820 up_read(&priv->mib_sem);
825 /* Set the allowed Bitrates */
828 prism54_set_rate(struct net_device *ndev,
829 struct iw_request_info *info,
830 struct iw_param *vwrq, char *extra)
833 islpci_private *priv = netdev_priv(ndev);
839 if (vwrq->value == -1) {
840 /* auto mode. No limit. */
842 return mgt_set_request(priv, DOT11_OID_PROFILES, 0, &profile);
845 ret = mgt_get_request(priv, DOT11_OID_SUPPORTEDRATES, 0, NULL, &r);
851 rate = (u32) (vwrq->value / 500000);
856 if (rate && (data[i] == rate)) {
859 if (vwrq->value == i) {
874 /* Now, check if we want a fixed or auto value */
882 printk("prism54 rate: ");
884 printk("%u ", data[i]);
890 ret = mgt_set_request(priv, DOT11_OID_PROFILES, 0, &profile);
891 ret |= mgt_set_request(priv, DOT11_OID_EXTENDEDRATES, 0, data);
892 ret |= mgt_set_request(priv, DOT11_OID_RATES, 0, data);
899 /* Get the current bit rate */
901 prism54_get_rate(struct net_device *ndev,
902 struct iw_request_info *info,
903 struct iw_param *vwrq, char *extra)
905 islpci_private *priv = netdev_priv(ndev);
910 /* Get the current bit rate */
911 if ((rvalue = mgt_get_request(priv, GEN_OID_LINKSTATE, 0, NULL, &r)))
913 vwrq->value = r.u * 500000;
915 /* request the device for the enabled rates */
916 rvalue = mgt_get_request(priv, DOT11_OID_RATES, 0, NULL, &r);
922 vwrq->fixed = (data[0] != 0) && (data[1] == 0);
929 prism54_set_rts(struct net_device *ndev, struct iw_request_info *info,
930 struct iw_param *vwrq, char *extra)
932 islpci_private *priv = netdev_priv(ndev);
934 return mgt_set_request(priv, DOT11_OID_RTSTHRESH, 0, &vwrq->value);
938 prism54_get_rts(struct net_device *ndev, struct iw_request_info *info,
939 struct iw_param *vwrq, char *extra)
941 islpci_private *priv = netdev_priv(ndev);
945 /* get the rts threshold */
946 rvalue = mgt_get_request(priv, DOT11_OID_RTSTHRESH, 0, NULL, &r);
953 prism54_set_frag(struct net_device *ndev, struct iw_request_info *info,
954 struct iw_param *vwrq, char *extra)
956 islpci_private *priv = netdev_priv(ndev);
958 return mgt_set_request(priv, DOT11_OID_FRAGTHRESH, 0, &vwrq->value);
962 prism54_get_frag(struct net_device *ndev, struct iw_request_info *info,
963 struct iw_param *vwrq, char *extra)
965 islpci_private *priv = netdev_priv(ndev);
969 rvalue = mgt_get_request(priv, DOT11_OID_FRAGTHRESH, 0, NULL, &r);
975 /* Here we have (min,max) = max retries for (small frames, big frames). Where
976 * big frame <=> bigger than the rts threshold
977 * small frame <=> smaller than the rts threshold
978 * This is not really the behavior expected by the wireless tool but it seems
979 * to be a common behavior in other drivers.
983 prism54_set_retry(struct net_device *ndev, struct iw_request_info *info,
984 struct iw_param *vwrq, char *extra)
986 islpci_private *priv = netdev_priv(ndev);
987 u32 slimit = 0, llimit = 0; /* short and long limit */
992 /* we cannot disable this feature */
995 if (vwrq->flags & IW_RETRY_LIMIT) {
996 if (vwrq->flags & IW_RETRY_SHORT)
997 slimit = vwrq->value;
998 else if (vwrq->flags & IW_RETRY_LONG)
999 llimit = vwrq->value;
1001 /* we are asked to set both */
1002 slimit = vwrq->value;
1003 llimit = vwrq->value;
1006 if (vwrq->flags & IW_RETRY_LIFETIME)
1007 /* Wireless tools use us unit while the device uses 1024 us unit */
1008 lifetime = vwrq->value / 1024;
1010 /* now set what is requested */
1013 mgt_set_request(priv, DOT11_OID_SHORTRETRIES, 0, &slimit);
1016 mgt_set_request(priv, DOT11_OID_LONGRETRIES, 0, &llimit);
1019 mgt_set_request(priv, DOT11_OID_MAXTXLIFETIME, 0,
1025 prism54_get_retry(struct net_device *ndev, struct iw_request_info *info,
1026 struct iw_param *vwrq, char *extra)
1028 islpci_private *priv = netdev_priv(ndev);
1031 vwrq->disabled = 0; /* It cannot be disabled */
1033 if ((vwrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
1034 /* we are asked for the life time */
1036 mgt_get_request(priv, DOT11_OID_MAXTXLIFETIME, 0, NULL, &r);
1037 vwrq->value = r.u * 1024;
1038 vwrq->flags = IW_RETRY_LIFETIME;
1039 } else if ((vwrq->flags & IW_RETRY_LONG)) {
1040 /* we are asked for the long retry limit */
1042 mgt_get_request(priv, DOT11_OID_LONGRETRIES, 0, NULL, &r);
1044 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
1046 /* default. get the short retry limit */
1048 mgt_get_request(priv, DOT11_OID_SHORTRETRIES, 0, NULL, &r);
1050 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
1057 prism54_set_encode(struct net_device *ndev, struct iw_request_info *info,
1058 struct iw_point *dwrq, char *extra)
1060 islpci_private *priv = netdev_priv(ndev);
1061 int rvalue = 0, force = 0;
1062 int authen = DOT11_AUTH_OS, invoke = 0, exunencrypt = 0;
1065 /* with the new API, it's impossible to get a NULL pointer.
1066 * New version of iwconfig set the IW_ENCODE_NOKEY flag
1067 * when no key is given, but older versions don't. */
1069 if (dwrq->length > 0) {
1070 /* we have a key to set */
1071 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
1073 struct obj_key key = { DOT11_PRIV_WEP, 0, "" };
1075 /* get the current key index */
1076 rvalue = mgt_get_request(priv, DOT11_OID_DEFKEYID, 0, NULL, &r);
1077 current_index = r.u;
1078 /* Verify that the key is not marked as invalid */
1079 if (!(dwrq->flags & IW_ENCODE_NOKEY)) {
1080 if (dwrq->length > KEY_SIZE_TKIP) {
1081 /* User-provided key data too big */
1084 if (dwrq->length > KEY_SIZE_WEP104) {
1086 key.type = DOT11_PRIV_TKIP;
1087 key.length = KEY_SIZE_TKIP;
1088 } else if (dwrq->length > KEY_SIZE_WEP40) {
1090 key.length = KEY_SIZE_WEP104;
1093 key.length = KEY_SIZE_WEP40;
1095 memset(key.key, 0, sizeof (key.key));
1096 memcpy(key.key, extra, dwrq->length);
1098 if ((index < 0) || (index > 3))
1099 /* no index provided use the current one */
1100 index = current_index;
1102 /* now send the key to the card */
1104 mgt_set_request(priv, DOT11_OID_DEFKEYX, index,
1108 * If a valid key is set, encryption should be enabled
1109 * (user may turn it off later).
1110 * This is also how "iwconfig ethX key on" works
1112 if ((index == current_index) && (key.length > 0))
1115 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
1116 if ((index >= 0) && (index <= 3)) {
1117 /* we want to set the key index */
1119 mgt_set_request(priv, DOT11_OID_DEFKEYID, 0,
1122 if (!dwrq->flags & IW_ENCODE_MODE) {
1123 /* we cannot do anything. Complain. */
1128 /* now read the flags */
1129 if (dwrq->flags & IW_ENCODE_DISABLED) {
1130 /* Encoding disabled,
1131 * authen = DOT11_AUTH_OS;
1133 * exunencrypt = 0; */
1135 if (dwrq->flags & IW_ENCODE_OPEN)
1136 /* Encode but accept non-encoded packets. No auth */
1138 if ((dwrq->flags & IW_ENCODE_RESTRICTED) || force) {
1139 /* Refuse non-encoded packets. Auth */
1140 authen = DOT11_AUTH_BOTH;
1144 /* do the change if requested */
1145 if ((dwrq->flags & IW_ENCODE_MODE) || force) {
1147 mgt_set_request(priv, DOT11_OID_AUTHENABLE, 0, &authen);
1149 mgt_set_request(priv, DOT11_OID_PRIVACYINVOKED, 0, &invoke);
1151 mgt_set_request(priv, DOT11_OID_EXUNENCRYPTED, 0,
1158 prism54_get_encode(struct net_device *ndev, struct iw_request_info *info,
1159 struct iw_point *dwrq, char *extra)
1161 islpci_private *priv = netdev_priv(ndev);
1162 struct obj_key *key;
1163 u32 devindex, index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
1164 u32 authen = 0, invoke = 0, exunencrypt = 0;
1168 /* first get the flags */
1169 rvalue = mgt_get_request(priv, DOT11_OID_AUTHENABLE, 0, NULL, &r);
1171 rvalue |= mgt_get_request(priv, DOT11_OID_PRIVACYINVOKED, 0, NULL, &r);
1173 rvalue |= mgt_get_request(priv, DOT11_OID_EXUNENCRYPTED, 0, NULL, &r);
1176 if (invoke && (authen == DOT11_AUTH_BOTH) && exunencrypt)
1177 dwrq->flags = IW_ENCODE_RESTRICTED;
1178 else if ((authen == DOT11_AUTH_OS) && !exunencrypt) {
1180 dwrq->flags = IW_ENCODE_OPEN;
1182 dwrq->flags = IW_ENCODE_DISABLED;
1184 /* The card should not work in this state */
1187 /* get the current device key index */
1188 rvalue |= mgt_get_request(priv, DOT11_OID_DEFKEYID, 0, NULL, &r);
1190 /* Now get the key, return it */
1191 if ((index < 0) || (index > 3))
1192 /* no index provided, use the current one */
1194 rvalue |= mgt_get_request(priv, DOT11_OID_DEFKEYX, index, NULL, &r);
1196 dwrq->length = key->length;
1197 memcpy(extra, key->key, dwrq->length);
1199 /* return the used key index */
1200 dwrq->flags |= devindex + 1;
1206 prism54_get_txpower(struct net_device *ndev, struct iw_request_info *info,
1207 struct iw_param *vwrq, char *extra)
1209 islpci_private *priv = netdev_priv(ndev);
1213 rvalue = mgt_get_request(priv, OID_INL_OUTPUTPOWER, 0, NULL, &r);
1214 /* intersil firmware operates in 0.25 dBm (1/4 dBm) */
1215 vwrq->value = (s32) r.u / 4;
1217 /* radio is not turned of
1218 * btw: how is possible to turn off only the radio
1226 prism54_set_txpower(struct net_device *ndev, struct iw_request_info *info,
1227 struct iw_param *vwrq, char *extra)
1229 islpci_private *priv = netdev_priv(ndev);
1230 s32 u = vwrq->value;
1232 /* intersil firmware operates in 0.25 dBm (1/4) */
1234 if (vwrq->disabled) {
1235 /* don't know how to disable radio */
1237 "%s: %s() disabling radio is not yet supported.\n",
1238 priv->ndev->name, __FUNCTION__);
1240 } else if (vwrq->fixed)
1241 /* currently only fixed value is supported */
1242 return mgt_set_request(priv, OID_INL_OUTPUTPOWER, 0, &u);
1245 "%s: %s() auto power will be implemented later.\n",
1246 priv->ndev->name, __FUNCTION__);
1251 static int prism54_set_genie(struct net_device *ndev,
1252 struct iw_request_info *info,
1253 struct iw_point *data, char *extra)
1255 islpci_private *priv = netdev_priv(ndev);
1257 struct obj_attachment *attach;
1259 if (data->length > MAX_WPA_IE_LEN ||
1260 (data->length && extra == NULL))
1263 memcpy(priv->wpa_ie, extra, data->length);
1264 priv->wpa_ie_len = data->length;
1266 alen = sizeof(*attach) + priv->wpa_ie_len;
1267 attach = kzalloc(alen, GFP_KERNEL);
1271 #define WLAN_FC_TYPE_MGMT 0
1272 #define WLAN_FC_STYPE_ASSOC_REQ 0
1273 #define WLAN_FC_STYPE_REASSOC_REQ 2
1275 /* Note: endianness is covered by mgt_set_varlen */
1276 attach->type = (WLAN_FC_TYPE_MGMT << 2) |
1277 (WLAN_FC_STYPE_ASSOC_REQ << 4);
1279 attach->size = priv->wpa_ie_len;
1280 memcpy(attach->data, extra, priv->wpa_ie_len);
1282 ret = mgt_set_varlen(priv, DOT11_OID_ATTACHMENT, attach,
1285 attach->type = (WLAN_FC_TYPE_MGMT << 2) |
1286 (WLAN_FC_STYPE_REASSOC_REQ << 4);
1288 ret = mgt_set_varlen(priv, DOT11_OID_ATTACHMENT, attach,
1291 printk(KERN_DEBUG "%s: WPA IE Attachment was set\n",
1300 static int prism54_get_genie(struct net_device *ndev,
1301 struct iw_request_info *info,
1302 struct iw_point *data, char *extra)
1304 islpci_private *priv = netdev_priv(ndev);
1305 int len = priv->wpa_ie_len;
1312 if (data->length < len)
1316 memcpy(extra, priv->wpa_ie, len);
1321 static int prism54_set_auth(struct net_device *ndev,
1322 struct iw_request_info *info,
1323 union iwreq_data *wrqu, char *extra)
1325 islpci_private *priv = netdev_priv(ndev);
1326 struct iw_param *param = &wrqu->param;
1327 u32 mlmelevel = 0, authen = 0, dot1x = 0;
1328 u32 exunencrypt = 0, privinvoked = 0, wpa = 0;
1333 if (islpci_get_state(priv) < PRV_STATE_INIT)
1336 /* first get the flags */
1337 down_write(&priv->mib_sem);
1338 wpa = old_wpa = priv->wpa;
1339 up_write(&priv->mib_sem);
1340 ret = mgt_get_request(priv, DOT11_OID_AUTHENABLE, 0, NULL, &r);
1342 ret = mgt_get_request(priv, DOT11_OID_PRIVACYINVOKED, 0, NULL, &r);
1344 ret = mgt_get_request(priv, DOT11_OID_EXUNENCRYPTED, 0, NULL, &r);
1346 ret = mgt_get_request(priv, DOT11_OID_DOT1XENABLE, 0, NULL, &r);
1348 ret = mgt_get_request(priv, DOT11_OID_MLMEAUTOLEVEL, 0, NULL, &r);
1354 switch (param->flags & IW_AUTH_INDEX) {
1355 case IW_AUTH_CIPHER_PAIRWISE:
1356 case IW_AUTH_CIPHER_GROUP:
1357 case IW_AUTH_KEY_MGMT:
1360 case IW_AUTH_WPA_ENABLED:
1361 /* Do the same thing as IW_AUTH_WPA_VERSION */
1364 privinvoked = 1; /* For privacy invoked */
1365 exunencrypt = 1; /* Filter out all unencrypted frames */
1366 dot1x = 0x01; /* To enable eap filter */
1367 mlmelevel = DOT11_MLME_EXTENDED;
1368 authen = DOT11_AUTH_OS; /* Only WEP uses _SK and _BOTH */
1372 exunencrypt = 0; /* Do not filter un-encrypted data */
1374 mlmelevel = DOT11_MLME_AUTO;
1378 case IW_AUTH_WPA_VERSION:
1379 if (param->value & IW_AUTH_WPA_VERSION_DISABLED) {
1382 exunencrypt = 0; /* Do not filter un-encrypted data */
1384 mlmelevel = DOT11_MLME_AUTO;
1386 if (param->value & IW_AUTH_WPA_VERSION_WPA)
1388 else if (param->value & IW_AUTH_WPA_VERSION_WPA2)
1390 privinvoked = 1; /* For privacy invoked */
1391 exunencrypt = 1; /* Filter out all unencrypted frames */
1392 dot1x = 0x01; /* To enable eap filter */
1393 mlmelevel = DOT11_MLME_EXTENDED;
1394 authen = DOT11_AUTH_OS; /* Only WEP uses _SK and _BOTH */
1398 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
1399 dot1x = param->value ? 1 : 0;
1402 case IW_AUTH_PRIVACY_INVOKED:
1403 privinvoked = param->value ? 1 : 0;
1405 case IW_AUTH_DROP_UNENCRYPTED:
1406 exunencrypt = param->value ? 1 : 0;
1409 case IW_AUTH_80211_AUTH_ALG:
1410 if (param->value & IW_AUTH_ALG_SHARED_KEY) {
1411 /* Only WEP uses _SK and _BOTH */
1416 authen = DOT11_AUTH_SK;
1417 } else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM) {
1418 authen = DOT11_AUTH_OS;
1429 /* Set all the values */
1430 down_write(&priv->mib_sem);
1432 up_write(&priv->mib_sem);
1433 mgt_set_request(priv, DOT11_OID_AUTHENABLE, 0, &authen);
1434 mgt_set_request(priv, DOT11_OID_PRIVACYINVOKED, 0, &privinvoked);
1435 mgt_set_request(priv, DOT11_OID_EXUNENCRYPTED, 0, &exunencrypt);
1436 mgt_set_request(priv, DOT11_OID_DOT1XENABLE, 0, &dot1x);
1437 mgt_set_request(priv, DOT11_OID_MLMEAUTOLEVEL, 0, &mlmelevel);
1443 static int prism54_get_auth(struct net_device *ndev,
1444 struct iw_request_info *info,
1445 union iwreq_data *wrqu, char *extra)
1447 islpci_private *priv = netdev_priv(ndev);
1448 struct iw_param *param = &wrqu->param;
1453 if (islpci_get_state(priv) < PRV_STATE_INIT)
1456 /* first get the flags */
1457 down_write(&priv->mib_sem);
1459 up_write(&priv->mib_sem);
1461 switch (param->flags & IW_AUTH_INDEX) {
1462 case IW_AUTH_CIPHER_PAIRWISE:
1463 case IW_AUTH_CIPHER_GROUP:
1464 case IW_AUTH_KEY_MGMT:
1466 * wpa_supplicant will control these internally
1471 case IW_AUTH_WPA_VERSION:
1474 param->value = IW_AUTH_WPA_VERSION_WPA;
1477 param->value = IW_AUTH_WPA_VERSION_WPA2;
1481 param->value = IW_AUTH_WPA_VERSION_DISABLED;
1486 case IW_AUTH_DROP_UNENCRYPTED:
1487 ret = mgt_get_request(priv, DOT11_OID_EXUNENCRYPTED, 0, NULL, &r);
1489 param->value = r.u > 0 ? 1 : 0;
1492 case IW_AUTH_80211_AUTH_ALG:
1493 ret = mgt_get_request(priv, DOT11_OID_AUTHENABLE, 0, NULL, &r);
1497 param->value = IW_AUTH_ALG_OPEN_SYSTEM;
1499 case DOT11_AUTH_BOTH:
1501 param->value = IW_AUTH_ALG_SHARED_KEY;
1502 case DOT11_AUTH_NONE:
1510 case IW_AUTH_WPA_ENABLED:
1511 param->value = wpa > 0 ? 1 : 0;
1514 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
1515 ret = mgt_get_request(priv, DOT11_OID_DOT1XENABLE, 0, NULL, &r);
1517 param->value = r.u > 0 ? 1 : 0;
1520 case IW_AUTH_PRIVACY_INVOKED:
1521 ret = mgt_get_request(priv, DOT11_OID_PRIVACYINVOKED, 0, NULL, &r);
1523 param->value = r.u > 0 ? 1 : 0;
1532 static int prism54_set_encodeext(struct net_device *ndev,
1533 struct iw_request_info *info,
1534 union iwreq_data *wrqu,
1537 islpci_private *priv = netdev_priv(ndev);
1538 struct iw_point *encoding = &wrqu->encoding;
1539 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
1540 int idx, alg = ext->alg, set_key = 1;
1542 int authen = DOT11_AUTH_OS, invoke = 0, exunencrypt = 0;
1545 if (islpci_get_state(priv) < PRV_STATE_INIT)
1548 /* Determine and validate the key index */
1549 idx = (encoding->flags & IW_ENCODE_INDEX) - 1;
1551 if (idx < 0 || idx > 3)
1554 ret = mgt_get_request(priv, DOT11_OID_DEFKEYID, 0, NULL, &r);
1560 if (encoding->flags & IW_ENCODE_DISABLED)
1561 alg = IW_ENCODE_ALG_NONE;
1563 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
1564 /* Only set transmit key index here, actual
1565 * key is set below if needed.
1567 ret = mgt_set_request(priv, DOT11_OID_DEFKEYID, 0, &idx);
1568 set_key = ext->key_len > 0 ? 1 : 0;
1572 struct obj_key key = { DOT11_PRIV_WEP, 0, "" };
1574 case IW_ENCODE_ALG_NONE:
1576 case IW_ENCODE_ALG_WEP:
1577 if (ext->key_len > KEY_SIZE_WEP104) {
1581 if (ext->key_len > KEY_SIZE_WEP40)
1582 key.length = KEY_SIZE_WEP104;
1584 key.length = KEY_SIZE_WEP40;
1586 case IW_ENCODE_ALG_TKIP:
1587 if (ext->key_len > KEY_SIZE_TKIP) {
1591 key.type = DOT11_PRIV_TKIP;
1592 key.length = KEY_SIZE_TKIP;
1598 memset(key.key, 0, sizeof(key.key));
1599 memcpy(key.key, ext->key, ext->key_len);
1600 ret = mgt_set_request(priv, DOT11_OID_DEFKEYX, idx,
1607 /* Read the flags */
1608 if (encoding->flags & IW_ENCODE_DISABLED) {
1609 /* Encoding disabled,
1610 * authen = DOT11_AUTH_OS;
1612 * exunencrypt = 0; */
1614 if (encoding->flags & IW_ENCODE_OPEN) {
1615 /* Encode but accept non-encoded packets. No auth */
1618 if (encoding->flags & IW_ENCODE_RESTRICTED) {
1619 /* Refuse non-encoded packets. Auth */
1620 authen = DOT11_AUTH_BOTH;
1625 /* do the change if requested */
1626 if (encoding->flags & IW_ENCODE_MODE) {
1627 ret = mgt_set_request(priv, DOT11_OID_AUTHENABLE, 0,
1629 ret = mgt_set_request(priv, DOT11_OID_PRIVACYINVOKED, 0,
1631 ret = mgt_set_request(priv, DOT11_OID_EXUNENCRYPTED, 0,
1640 static int prism54_get_encodeext(struct net_device *ndev,
1641 struct iw_request_info *info,
1642 union iwreq_data *wrqu,
1645 islpci_private *priv = netdev_priv(ndev);
1646 struct iw_point *encoding = &wrqu->encoding;
1647 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
1648 int idx, max_key_len;
1650 int authen = DOT11_AUTH_OS, invoke = 0, exunencrypt = 0, wpa = 0;
1653 if (islpci_get_state(priv) < PRV_STATE_INIT)
1656 /* first get the flags */
1657 ret = mgt_get_request(priv, DOT11_OID_AUTHENABLE, 0, NULL, &r);
1659 ret = mgt_get_request(priv, DOT11_OID_PRIVACYINVOKED, 0, NULL, &r);
1661 ret = mgt_get_request(priv, DOT11_OID_EXUNENCRYPTED, 0, NULL, &r);
1666 max_key_len = encoding->length - sizeof(*ext);
1667 if (max_key_len < 0)
1670 idx = (encoding->flags & IW_ENCODE_INDEX) - 1;
1672 if (idx < 0 || idx > 3)
1675 ret = mgt_get_request(priv, DOT11_OID_DEFKEYID, 0, NULL, &r);
1681 encoding->flags = idx + 1;
1682 memset(ext, 0, sizeof(*ext));
1685 case DOT11_AUTH_BOTH:
1687 wrqu->encoding.flags |= IW_ENCODE_RESTRICTED;
1690 wrqu->encoding.flags |= IW_ENCODE_OPEN;
1694 down_write(&priv->mib_sem);
1696 up_write(&priv->mib_sem);
1698 if (authen == DOT11_AUTH_OS && !exunencrypt && !invoke && !wpa) {
1700 ext->alg = IW_ENCODE_ALG_NONE;
1702 wrqu->encoding.flags |= IW_ENCODE_DISABLED;
1704 struct obj_key *key;
1706 ret = mgt_get_request(priv, DOT11_OID_DEFKEYX, idx, NULL, &r);
1710 if (max_key_len < key->length) {
1714 memcpy(ext->key, key->key, key->length);
1715 ext->key_len = key->length;
1717 switch (key->type) {
1718 case DOT11_PRIV_TKIP:
1719 ext->alg = IW_ENCODE_ALG_TKIP;
1722 case DOT11_PRIV_WEP:
1723 ext->alg = IW_ENCODE_ALG_WEP;
1726 wrqu->encoding.flags |= IW_ENCODE_ENABLED;
1735 prism54_reset(struct net_device *ndev, struct iw_request_info *info,
1736 __u32 * uwrq, char *extra)
1738 islpci_reset(netdev_priv(ndev), 0);
1744 prism54_get_oid(struct net_device *ndev, struct iw_request_info *info,
1745 struct iw_point *dwrq, char *extra)
1749 enum oid_num_t n = dwrq->flags;
1751 rvalue = mgt_get_request((islpci_private *) ndev->priv, n, 0, NULL, &r);
1752 dwrq->length = mgt_response_to_str(n, &r, extra);
1753 if ((isl_oid[n].flags & OID_FLAG_TYPE) != OID_TYPE_U32)
1759 prism54_set_u32(struct net_device *ndev, struct iw_request_info *info,
1760 __u32 * uwrq, char *extra)
1762 u32 oid = uwrq[0], u = uwrq[1];
1764 return mgt_set_request((islpci_private *) ndev->priv, oid, 0, &u);
1768 prism54_set_raw(struct net_device *ndev, struct iw_request_info *info,
1769 struct iw_point *dwrq, char *extra)
1771 u32 oid = dwrq->flags;
1773 return mgt_set_request((islpci_private *) ndev->priv, oid, 0, extra);
1777 prism54_acl_init(struct islpci_acl *acl)
1779 sema_init(&acl->sem, 1);
1780 INIT_LIST_HEAD(&acl->mac_list);
1782 acl->policy = MAC_POLICY_OPEN;
1786 prism54_clear_mac(struct islpci_acl *acl)
1788 struct list_head *ptr, *next;
1789 struct mac_entry *entry;
1791 if (down_interruptible(&acl->sem))
1794 if (acl->size == 0) {
1799 for (ptr = acl->mac_list.next, next = ptr->next;
1800 ptr != &acl->mac_list; ptr = next, next = ptr->next) {
1801 entry = list_entry(ptr, struct mac_entry, _list);
1810 prism54_acl_clean(struct islpci_acl *acl)
1812 prism54_clear_mac(acl);
1816 prism54_add_mac(struct net_device *ndev, struct iw_request_info *info,
1817 struct sockaddr *awrq, char *extra)
1819 islpci_private *priv = netdev_priv(ndev);
1820 struct islpci_acl *acl = &priv->acl;
1821 struct mac_entry *entry;
1822 struct sockaddr *addr = (struct sockaddr *) extra;
1824 if (addr->sa_family != ARPHRD_ETHER)
1827 entry = kmalloc(sizeof (struct mac_entry), GFP_KERNEL);
1831 memcpy(entry->addr, addr->sa_data, ETH_ALEN);
1833 if (down_interruptible(&acl->sem)) {
1835 return -ERESTARTSYS;
1837 list_add_tail(&entry->_list, &acl->mac_list);
1845 prism54_del_mac(struct net_device *ndev, struct iw_request_info *info,
1846 struct sockaddr *awrq, char *extra)
1848 islpci_private *priv = netdev_priv(ndev);
1849 struct islpci_acl *acl = &priv->acl;
1850 struct mac_entry *entry;
1851 struct list_head *ptr;
1852 struct sockaddr *addr = (struct sockaddr *) extra;
1854 if (addr->sa_family != ARPHRD_ETHER)
1857 if (down_interruptible(&acl->sem))
1858 return -ERESTARTSYS;
1859 for (ptr = acl->mac_list.next; ptr != &acl->mac_list; ptr = ptr->next) {
1860 entry = list_entry(ptr, struct mac_entry, _list);
1862 if (memcmp(entry->addr, addr->sa_data, ETH_ALEN) == 0) {
1875 prism54_get_mac(struct net_device *ndev, struct iw_request_info *info,
1876 struct iw_point *dwrq, char *extra)
1878 islpci_private *priv = netdev_priv(ndev);
1879 struct islpci_acl *acl = &priv->acl;
1880 struct mac_entry *entry;
1881 struct list_head *ptr;
1882 struct sockaddr *dst = (struct sockaddr *) extra;
1886 if (down_interruptible(&acl->sem))
1887 return -ERESTARTSYS;
1889 for (ptr = acl->mac_list.next; ptr != &acl->mac_list; ptr = ptr->next) {
1890 entry = list_entry(ptr, struct mac_entry, _list);
1892 memcpy(dst->sa_data, entry->addr, ETH_ALEN);
1893 dst->sa_family = ARPHRD_ETHER;
1901 /* Setting policy also clears the MAC acl, even if we don't change the defaut
1906 prism54_set_policy(struct net_device *ndev, struct iw_request_info *info,
1907 __u32 * uwrq, char *extra)
1909 islpci_private *priv = netdev_priv(ndev);
1910 struct islpci_acl *acl = &priv->acl;
1913 prism54_clear_mac(acl);
1915 if ((*uwrq < MAC_POLICY_OPEN) || (*uwrq > MAC_POLICY_REJECT))
1918 down_write(&priv->mib_sem);
1920 acl->policy = *uwrq;
1922 /* the ACL code needs an intermediate mlmeautolevel */
1923 if ((priv->iw_mode == IW_MODE_MASTER) &&
1924 (acl->policy != MAC_POLICY_OPEN))
1925 mlmeautolevel = DOT11_MLME_INTERMEDIATE;
1927 mlmeautolevel = CARD_DEFAULT_MLME_MODE;
1929 mlmeautolevel = DOT11_MLME_EXTENDED;
1930 mgt_set(priv, DOT11_OID_MLMEAUTOLEVEL, &mlmeautolevel);
1931 /* restart the card with our new policy */
1932 if (mgt_commit(priv)) {
1933 up_write(&priv->mib_sem);
1936 up_write(&priv->mib_sem);
1942 prism54_get_policy(struct net_device *ndev, struct iw_request_info *info,
1943 __u32 * uwrq, char *extra)
1945 islpci_private *priv = netdev_priv(ndev);
1946 struct islpci_acl *acl = &priv->acl;
1948 *uwrq = acl->policy;
1953 /* Return 1 only if client should be accepted. */
1956 prism54_mac_accept(struct islpci_acl *acl, char *mac)
1958 struct list_head *ptr;
1959 struct mac_entry *entry;
1962 if (down_interruptible(&acl->sem))
1963 return -ERESTARTSYS;
1965 if (acl->policy == MAC_POLICY_OPEN) {
1970 for (ptr = acl->mac_list.next; ptr != &acl->mac_list; ptr = ptr->next) {
1971 entry = list_entry(ptr, struct mac_entry, _list);
1972 if (memcmp(entry->addr, mac, ETH_ALEN) == 0) {
1977 res = (acl->policy == MAC_POLICY_ACCEPT) ? !res : res;
1984 prism54_kick_all(struct net_device *ndev, struct iw_request_info *info,
1985 struct iw_point *dwrq, char *extra)
1987 struct obj_mlme *mlme;
1990 mlme = kmalloc(sizeof (struct obj_mlme), GFP_KERNEL);
1994 /* Tell the card to kick every client */
1997 mgt_set_request(netdev_priv(ndev), DOT11_OID_DISASSOCIATE, 0, mlme);
2004 prism54_kick_mac(struct net_device *ndev, struct iw_request_info *info,
2005 struct sockaddr *awrq, char *extra)
2007 struct obj_mlme *mlme;
2008 struct sockaddr *addr = (struct sockaddr *) extra;
2011 if (addr->sa_family != ARPHRD_ETHER)
2014 mlme = kmalloc(sizeof (struct obj_mlme), GFP_KERNEL);
2018 /* Tell the card to only kick the corresponding bastard */
2019 memcpy(mlme->address, addr->sa_data, ETH_ALEN);
2022 mgt_set_request(netdev_priv(ndev), DOT11_OID_DISASSOCIATE, 0, mlme);
2029 /* Translate a TRAP oid into a wireless event. Called in islpci_mgt_receive. */
2032 format_event(islpci_private *priv, char *dest, const char *str,
2033 const struct obj_mlme *mlme, u16 *length, int error)
2035 const u8 *a = mlme->address;
2036 int n = snprintf(dest, IW_CUSTOM_MAX,
2037 "%s %s %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X %s (%2.2X)",
2039 ((priv->iw_mode == IW_MODE_MASTER) ? "from" : "to"),
2040 a[0], a[1], a[2], a[3], a[4], a[5],
2041 (error ? (mlme->code ? " : REJECTED " : " : ACCEPTED ")
2043 BUG_ON(n > IW_CUSTOM_MAX);
2048 send_formatted_event(islpci_private *priv, const char *str,
2049 const struct obj_mlme *mlme, int error)
2051 union iwreq_data wrqu;
2054 memptr = kmalloc(IW_CUSTOM_MAX, GFP_KERNEL);
2057 wrqu.data.pointer = memptr;
2058 wrqu.data.length = 0;
2059 format_event(priv, memptr, str, mlme, &wrqu.data.length,
2061 wireless_send_event(priv->ndev, IWEVCUSTOM, &wrqu, memptr);
2066 send_simple_event(islpci_private *priv, const char *str)
2068 union iwreq_data wrqu;
2070 int n = strlen(str);
2072 memptr = kmalloc(IW_CUSTOM_MAX, GFP_KERNEL);
2075 BUG_ON(n > IW_CUSTOM_MAX);
2076 wrqu.data.pointer = memptr;
2077 wrqu.data.length = n;
2078 strcpy(memptr, str);
2079 wireless_send_event(priv->ndev, IWEVCUSTOM, &wrqu, memptr);
2084 link_changed(struct net_device *ndev, u32 bitrate)
2086 islpci_private *priv = netdev_priv(ndev);
2089 if (priv->iw_mode == IW_MODE_INFRA) {
2090 union iwreq_data uwrq;
2091 prism54_get_wap(ndev, NULL, (struct sockaddr *) &uwrq,
2093 wireless_send_event(ndev, SIOCGIWAP, &uwrq, NULL);
2095 send_simple_event(netdev_priv(ndev),
2096 "Link established");
2098 send_simple_event(netdev_priv(ndev), "Link lost");
2101 /* Beacon/ProbeResp payload header */
2102 struct ieee80211_beacon_phdr {
2106 } __attribute__ ((packed));
2108 #define WLAN_EID_GENERIC 0xdd
2109 static u8 wpa_oid[4] = { 0x00, 0x50, 0xf2, 1 };
2111 #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
2112 #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
2115 prism54_wpa_bss_ie_add(islpci_private *priv, u8 *bssid,
2116 u8 *wpa_ie, size_t wpa_ie_len)
2118 struct list_head *ptr;
2119 struct islpci_bss_wpa_ie *bss = NULL;
2121 if (wpa_ie_len > MAX_WPA_IE_LEN)
2122 wpa_ie_len = MAX_WPA_IE_LEN;
2124 if (down_interruptible(&priv->wpa_sem))
2127 /* try to use existing entry */
2128 list_for_each(ptr, &priv->bss_wpa_list) {
2129 bss = list_entry(ptr, struct islpci_bss_wpa_ie, list);
2130 if (memcmp(bss->bssid, bssid, ETH_ALEN) == 0) {
2131 list_move(&bss->list, &priv->bss_wpa_list);
2138 /* add a new BSS entry; if max number of entries is already
2139 * reached, replace the least recently updated */
2140 if (priv->num_bss_wpa >= MAX_BSS_WPA_IE_COUNT) {
2141 bss = list_entry(priv->bss_wpa_list.prev,
2142 struct islpci_bss_wpa_ie, list);
2143 list_del(&bss->list);
2145 bss = kmalloc(sizeof (*bss), GFP_ATOMIC);
2147 priv->num_bss_wpa++;
2148 memset(bss, 0, sizeof (*bss));
2152 memcpy(bss->bssid, bssid, ETH_ALEN);
2153 list_add(&bss->list, &priv->bss_wpa_list);
2158 memcpy(bss->wpa_ie, wpa_ie, wpa_ie_len);
2159 bss->wpa_ie_len = wpa_ie_len;
2160 bss->last_update = jiffies;
2162 printk(KERN_DEBUG "Failed to add BSS WPA entry for " MACSTR
2163 "\n", MAC2STR(bssid));
2166 /* expire old entries from WPA list */
2167 while (priv->num_bss_wpa > 0) {
2168 bss = list_entry(priv->bss_wpa_list.prev,
2169 struct islpci_bss_wpa_ie, list);
2170 if (!time_after(jiffies, bss->last_update + 60 * HZ))
2173 list_del(&bss->list);
2174 priv->num_bss_wpa--;
2182 prism54_wpa_bss_ie_get(islpci_private *priv, u8 *bssid, u8 *wpa_ie)
2184 struct list_head *ptr;
2185 struct islpci_bss_wpa_ie *bss = NULL;
2188 if (down_interruptible(&priv->wpa_sem))
2191 list_for_each(ptr, &priv->bss_wpa_list) {
2192 bss = list_entry(ptr, struct islpci_bss_wpa_ie, list);
2193 if (memcmp(bss->bssid, bssid, ETH_ALEN) == 0)
2198 len = bss->wpa_ie_len;
2199 memcpy(wpa_ie, bss->wpa_ie, len);
2207 prism54_wpa_bss_ie_init(islpci_private *priv)
2209 INIT_LIST_HEAD(&priv->bss_wpa_list);
2210 sema_init(&priv->wpa_sem, 1);
2214 prism54_wpa_bss_ie_clean(islpci_private *priv)
2216 struct list_head *ptr, *n;
2218 list_for_each_safe(ptr, n, &priv->bss_wpa_list) {
2219 struct islpci_bss_wpa_ie *bss;
2220 bss = list_entry(ptr, struct islpci_bss_wpa_ie, list);
2226 prism54_process_bss_data(islpci_private *priv, u32 oid, u8 *addr,
2227 u8 *payload, size_t len)
2229 struct ieee80211_beacon_phdr *hdr;
2235 hdr = (struct ieee80211_beacon_phdr *) payload;
2236 pos = (u8 *) (hdr + 1);
2237 end = payload + len;
2239 if (pos + 2 + pos[1] > end) {
2240 printk(KERN_DEBUG "Parsing Beacon/ProbeResp failed "
2241 "for " MACSTR "\n", MAC2STR(addr));
2244 if (pos[0] == WLAN_EID_GENERIC && pos[1] >= 4 &&
2245 memcmp(pos + 2, wpa_oid, 4) == 0) {
2246 prism54_wpa_bss_ie_add(priv, addr, pos, pos[1] + 2);
2254 handle_request(islpci_private *priv, struct obj_mlme *mlme, enum oid_num_t oid)
2256 if (((mlme->state == DOT11_STATE_AUTHING) ||
2257 (mlme->state == DOT11_STATE_ASSOCING))
2258 && mgt_mlme_answer(priv)) {
2259 /* Someone is requesting auth and we must respond. Just send back
2260 * the trap with error code set accordingly.
2262 mlme->code = prism54_mac_accept(&priv->acl,
2263 mlme->address) ? 0 : 1;
2264 mgt_set_request(priv, oid, 0, mlme);
2269 prism54_process_trap_helper(islpci_private *priv, enum oid_num_t oid,
2272 struct obj_mlme *mlme = (struct obj_mlme *) data;
2273 struct obj_mlmeex *mlmeex = (struct obj_mlmeex *) data;
2274 struct obj_mlmeex *confirm;
2275 u8 wpa_ie[MAX_WPA_IE_LEN];
2277 size_t len = 0; /* u16, better? */
2278 u8 *payload = NULL, *pos = NULL;
2281 /* I think all trapable objects are listed here.
2282 * Some oids have a EX version. The difference is that they are emitted
2283 * in DOT11_MLME_EXTENDED mode (set with DOT11_OID_MLMEAUTOLEVEL)
2285 * The few events already defined by the wireless tools are not really
2286 * suited. We use the more flexible custom event facility.
2289 if (oid >= DOT11_OID_BEACON) {
2291 payload = pos = mlmeex->data;
2294 /* I fear prism54_process_bss_data won't work with big endian data */
2295 if ((oid == DOT11_OID_BEACON) || (oid == DOT11_OID_PROBE))
2296 prism54_process_bss_data(priv, oid, mlmeex->address,
2299 mgt_le_to_cpu(isl_oid[oid].flags & OID_FLAG_TYPE, (void *) mlme);
2303 case GEN_OID_LINKSTATE:
2304 link_changed(priv->ndev, (u32) *data);
2307 case DOT11_OID_MICFAILURE:
2308 send_simple_event(priv, "Mic failure");
2311 case DOT11_OID_DEAUTHENTICATE:
2312 send_formatted_event(priv, "DeAuthenticate request", mlme, 0);
2315 case DOT11_OID_AUTHENTICATE:
2316 handle_request(priv, mlme, oid);
2317 send_formatted_event(priv, "Authenticate request", mlme, 1);
2320 case DOT11_OID_DISASSOCIATE:
2321 send_formatted_event(priv, "Disassociate request", mlme, 0);
2324 case DOT11_OID_ASSOCIATE:
2325 handle_request(priv, mlme, oid);
2326 send_formatted_event(priv, "Associate request", mlme, 1);
2329 case DOT11_OID_REASSOCIATE:
2330 handle_request(priv, mlme, oid);
2331 send_formatted_event(priv, "ReAssociate request", mlme, 1);
2334 case DOT11_OID_BEACON:
2335 send_formatted_event(priv,
2336 "Received a beacon from an unkown AP",
2340 case DOT11_OID_PROBE:
2341 /* we received a probe from a client. */
2342 send_formatted_event(priv, "Received a probe from client", mlme,
2346 /* Note : "mlme" is actually a "struct obj_mlmeex *" here, but this
2347 * is backward compatible layout-wise with "struct obj_mlme".
2350 case DOT11_OID_DEAUTHENTICATEEX:
2351 send_formatted_event(priv, "DeAuthenticate request", mlme, 0);
2354 case DOT11_OID_AUTHENTICATEEX:
2355 handle_request(priv, mlme, oid);
2356 send_formatted_event(priv, "Authenticate request (ex)", mlme, 1);
2358 if (priv->iw_mode != IW_MODE_MASTER
2359 && mlmeex->state != DOT11_STATE_AUTHING)
2362 confirm = kmalloc(sizeof(struct obj_mlmeex) + 6, GFP_ATOMIC);
2367 memcpy(&confirm->address, mlmeex->address, ETH_ALEN);
2368 printk(KERN_DEBUG "Authenticate from: address:\t%02x:%02x:%02x:%02x:%02x:%02x\n",
2376 confirm->id = -1; /* or mlmeex->id ? */
2377 confirm->state = 0; /* not used */
2380 confirm->data[0] = 0x00;
2381 confirm->data[1] = 0x00;
2382 confirm->data[2] = 0x02;
2383 confirm->data[3] = 0x00;
2384 confirm->data[4] = 0x00;
2385 confirm->data[5] = 0x00;
2387 ret = mgt_set_varlen(priv, DOT11_OID_ASSOCIATEEX, confirm, 6);
2394 case DOT11_OID_DISASSOCIATEEX:
2395 send_formatted_event(priv, "Disassociate request (ex)", mlme, 0);
2398 case DOT11_OID_ASSOCIATEEX:
2399 handle_request(priv, mlme, oid);
2400 send_formatted_event(priv, "Associate request (ex)", mlme, 1);
2402 if (priv->iw_mode != IW_MODE_MASTER
2403 && mlmeex->state != DOT11_STATE_ASSOCING)
2406 confirm = kmalloc(sizeof(struct obj_mlmeex), GFP_ATOMIC);
2411 memcpy(&confirm->address, mlmeex->address, ETH_ALEN);
2413 confirm->id = ((struct obj_mlmeex *)mlme)->id;
2414 confirm->state = 0; /* not used */
2417 wpa_ie_len = prism54_wpa_bss_ie_get(priv, mlmeex->address, wpa_ie);
2420 printk(KERN_DEBUG "No WPA IE found from "
2421 "address:\t%02x:%02x:%02x:%02x:%02x:%02x\n",
2433 confirm->size = wpa_ie_len;
2434 memcpy(&confirm->data, wpa_ie, wpa_ie_len);
2436 mgt_set_varlen(priv, oid, confirm, wpa_ie_len);
2442 case DOT11_OID_REASSOCIATEEX:
2443 handle_request(priv, mlme, oid);
2444 send_formatted_event(priv, "Reassociate request (ex)", mlme, 1);
2446 if (priv->iw_mode != IW_MODE_MASTER
2447 && mlmeex->state != DOT11_STATE_ASSOCING)
2450 confirm = kmalloc(sizeof(struct obj_mlmeex), GFP_ATOMIC);
2455 memcpy(&confirm->address, mlmeex->address, ETH_ALEN);
2457 confirm->id = mlmeex->id;
2458 confirm->state = 0; /* not used */
2461 wpa_ie_len = prism54_wpa_bss_ie_get(priv, mlmeex->address, wpa_ie);
2464 printk(KERN_DEBUG "No WPA IE found from "
2465 "address:\t%02x:%02x:%02x:%02x:%02x:%02x\n",
2477 confirm->size = wpa_ie_len;
2478 memcpy(&confirm->data, wpa_ie, wpa_ie_len);
2480 mgt_set_varlen(priv, oid, confirm, wpa_ie_len);
2494 * Process a device trap. This is called via schedule_work(), outside of
2495 * interrupt context, no locks held.
2498 prism54_process_trap(struct work_struct *work)
2500 struct islpci_mgmtframe *frame =
2501 container_of(work, struct islpci_mgmtframe, ws);
2502 struct net_device *ndev = frame->ndev;
2503 enum oid_num_t n = mgt_oidtonum(frame->header->oid);
2505 if (n != OID_NUM_LAST)
2506 prism54_process_trap_helper(netdev_priv(ndev), n, frame->data);
2507 islpci_mgt_release(frame);
2511 prism54_set_mac_address(struct net_device *ndev, void *addr)
2513 islpci_private *priv = netdev_priv(ndev);
2516 if (ndev->addr_len != 6)
2518 ret = mgt_set_request(priv, GEN_OID_MACADDRESS, 0,
2519 &((struct sockaddr *) addr)->sa_data);
2521 memcpy(priv->ndev->dev_addr,
2522 &((struct sockaddr *) addr)->sa_data, 6);
2527 /* Note: currently, use hostapd ioctl from the Host AP driver for WPA
2528 * support. This is to be replaced with Linux wireless extensions once they
2529 * get WPA support. */
2531 /* Note II: please leave all this together as it will be easier to remove later,
2532 * once wireless extensions add WPA support -mcgrof */
2534 /* PRISM54_HOSTAPD ioctl() cmd: */
2536 PRISM2_SET_ENCRYPTION = 6,
2537 PRISM2_HOSTAPD_SET_GENERIC_ELEMENT = 12,
2538 PRISM2_HOSTAPD_MLME = 13,
2539 PRISM2_HOSTAPD_SCAN_REQ = 14,
2542 #define PRISM54_SET_WPA SIOCIWFIRSTPRIV+12
2543 #define PRISM54_HOSTAPD SIOCIWFIRSTPRIV+25
2544 #define PRISM54_DROP_UNENCRYPTED SIOCIWFIRSTPRIV+26
2546 #define PRISM2_HOSTAPD_MAX_BUF_SIZE 1024
2547 #define PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN \
2548 ((int) (&((struct prism2_hostapd_param *) 0)->u.generic_elem.data))
2550 /* Maximum length for algorithm names (-1 for nul termination)
2551 * used in ioctl() */
2552 #define HOSTAP_CRYPT_ALG_NAME_LEN 16
2554 struct prism2_hostapd_param {
2556 u8 sta_addr[ETH_ALEN];
2559 u8 alg[HOSTAP_CRYPT_ALG_NAME_LEN];
2563 u8 seq[8]; /* sequence counter (set: RX, get: TX) */
2572 #define MLME_STA_DEAUTH 0
2573 #define MLME_STA_DISASSOC 1
2586 prism2_ioctl_set_encryption(struct net_device *dev,
2587 struct prism2_hostapd_param *param,
2590 islpci_private *priv = netdev_priv(dev);
2591 int rvalue = 0, force = 0;
2592 int authen = DOT11_AUTH_OS, invoke = 0, exunencrypt = 0;
2595 /* with the new API, it's impossible to get a NULL pointer.
2596 * New version of iwconfig set the IW_ENCODE_NOKEY flag
2597 * when no key is given, but older versions don't. */
2599 if (param->u.crypt.key_len > 0) {
2600 /* we have a key to set */
2601 int index = param->u.crypt.idx;
2603 struct obj_key key = { DOT11_PRIV_TKIP, 0, "" };
2605 /* get the current key index */
2606 rvalue = mgt_get_request(priv, DOT11_OID_DEFKEYID, 0, NULL, &r);
2607 current_index = r.u;
2608 /* Verify that the key is not marked as invalid */
2609 if (!(param->u.crypt.flags & IW_ENCODE_NOKEY)) {
2610 key.length = param->u.crypt.key_len > sizeof (param->u.crypt.key) ?
2611 sizeof (param->u.crypt.key) : param->u.crypt.key_len;
2612 memcpy(key.key, param->u.crypt.key, key.length);
2613 if (key.length == 32)
2614 /* we want WPA-PSK */
2615 key.type = DOT11_PRIV_TKIP;
2616 if ((index < 0) || (index > 3))
2617 /* no index provided use the current one */
2618 index = current_index;
2620 /* now send the key to the card */
2622 mgt_set_request(priv, DOT11_OID_DEFKEYX, index,
2626 * If a valid key is set, encryption should be enabled
2627 * (user may turn it off later).
2628 * This is also how "iwconfig ethX key on" works
2630 if ((index == current_index) && (key.length > 0))
2633 int index = (param->u.crypt.flags & IW_ENCODE_INDEX) - 1;
2634 if ((index >= 0) && (index <= 3)) {
2635 /* we want to set the key index */
2637 mgt_set_request(priv, DOT11_OID_DEFKEYID, 0,
2640 if (!param->u.crypt.flags & IW_ENCODE_MODE) {
2641 /* we cannot do anything. Complain. */
2646 /* now read the flags */
2647 if (param->u.crypt.flags & IW_ENCODE_DISABLED) {
2648 /* Encoding disabled,
2649 * authen = DOT11_AUTH_OS;
2651 * exunencrypt = 0; */
2653 if (param->u.crypt.flags & IW_ENCODE_OPEN)
2654 /* Encode but accept non-encoded packets. No auth */
2656 if ((param->u.crypt.flags & IW_ENCODE_RESTRICTED) || force) {
2657 /* Refuse non-encoded packets. Auth */
2658 authen = DOT11_AUTH_BOTH;
2662 /* do the change if requested */
2663 if ((param->u.crypt.flags & IW_ENCODE_MODE) || force) {
2665 mgt_set_request(priv, DOT11_OID_AUTHENABLE, 0, &authen);
2667 mgt_set_request(priv, DOT11_OID_PRIVACYINVOKED, 0, &invoke);
2669 mgt_set_request(priv, DOT11_OID_EXUNENCRYPTED, 0,
2676 prism2_ioctl_set_generic_element(struct net_device *ndev,
2677 struct prism2_hostapd_param *param,
2680 islpci_private *priv = netdev_priv(ndev);
2681 int max_len, len, alen, ret=0;
2682 struct obj_attachment *attach;
2684 len = param->u.generic_elem.len;
2685 max_len = param_len - PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN;
2686 if (max_len < 0 || max_len < len)
2689 alen = sizeof(*attach) + len;
2690 attach = kmalloc(alen, GFP_KERNEL);
2694 memset(attach, 0, alen);
2695 #define WLAN_FC_TYPE_MGMT 0
2696 #define WLAN_FC_STYPE_ASSOC_REQ 0
2697 #define WLAN_FC_STYPE_REASSOC_REQ 2
2699 /* Note: endianness is covered by mgt_set_varlen */
2701 attach->type = (WLAN_FC_TYPE_MGMT << 2) |
2702 (WLAN_FC_STYPE_ASSOC_REQ << 4);
2705 memcpy(attach->data, param->u.generic_elem.data, len);
2707 ret = mgt_set_varlen(priv, DOT11_OID_ATTACHMENT, attach, len);
2710 attach->type = (WLAN_FC_TYPE_MGMT << 2) |
2711 (WLAN_FC_STYPE_REASSOC_REQ << 4);
2713 ret = mgt_set_varlen(priv, DOT11_OID_ATTACHMENT, attach, len);
2716 printk(KERN_DEBUG "%s: WPA IE Attachment was set\n",
2726 prism2_ioctl_mlme(struct net_device *dev, struct prism2_hostapd_param *param)
2732 prism2_ioctl_scan_req(struct net_device *ndev,
2733 struct prism2_hostapd_param *param)
2735 islpci_private *priv = netdev_priv(ndev);
2737 struct obj_bsslist *bsslist;
2740 char *current_ev = "foo";
2743 if (islpci_get_state(priv) < PRV_STATE_INIT) {
2744 /* device is not ready, fail gently */
2748 /* first get the noise value. We will use it to report the link quality */
2749 rvalue = mgt_get_request(priv, DOT11_OID_NOISEFLOOR, 0, NULL, &r);
2752 /* Ask the device for a list of known bss. We can report at most
2753 * IW_MAX_AP=64 to the range struct. But the device won't repport anything
2754 * if you change the value of IWMAX_BSS=24.
2756 rvalue |= mgt_get_request(priv, DOT11_OID_BSSLIST, 0, NULL, &r);
2759 /* ok now, scan the list and translate its info */
2760 for (i = 0; i < min(IW_MAX_AP, (int) bsslist->nr); i++)
2761 current_ev = prism54_translate_bss(ndev, current_ev,
2762 extra + IW_SCAN_MAX_DATA,
2763 &(bsslist->bsslist[i]),
2771 prism54_hostapd(struct net_device *ndev, struct iw_point *p)
2773 struct prism2_hostapd_param *param;
2777 printk(KERN_DEBUG "prism54_hostapd - len=%d\n", p->length);
2778 if (p->length < sizeof(struct prism2_hostapd_param) ||
2779 p->length > PRISM2_HOSTAPD_MAX_BUF_SIZE || !p->pointer)
2782 param = (struct prism2_hostapd_param *) kmalloc(p->length, GFP_KERNEL);
2786 if (copy_from_user(param, p->pointer, p->length)) {
2791 switch (param->cmd) {
2792 case PRISM2_SET_ENCRYPTION:
2793 printk(KERN_DEBUG "%s: Caught WPA supplicant set encryption request\n",
2795 ret = prism2_ioctl_set_encryption(ndev, param, p->length);
2797 case PRISM2_HOSTAPD_SET_GENERIC_ELEMENT:
2798 printk(KERN_DEBUG "%s: Caught WPA supplicant set WPA IE request\n",
2800 ret = prism2_ioctl_set_generic_element(ndev, param,
2803 case PRISM2_HOSTAPD_MLME:
2804 printk(KERN_DEBUG "%s: Caught WPA supplicant MLME request\n",
2806 ret = prism2_ioctl_mlme(ndev, param);
2808 case PRISM2_HOSTAPD_SCAN_REQ:
2809 printk(KERN_DEBUG "%s: Caught WPA supplicant scan request\n",
2811 ret = prism2_ioctl_scan_req(ndev, param);
2813 case PRISM54_SET_WPA:
2814 printk(KERN_DEBUG "%s: Caught WPA supplicant wpa init request\n",
2817 ret = prism54_set_wpa(ndev, NULL, &uwrq, NULL);
2819 case PRISM54_DROP_UNENCRYPTED:
2820 printk(KERN_DEBUG "%s: Caught WPA drop unencrypted request\n",
2824 mgt_set(priv, DOT11_OID_EXUNENCRYPTED, &uwrq);
2825 down_write(&priv->mib_sem);
2827 up_write(&priv->mib_sem);
2829 /* Not necessary, as set_wpa does it, should we just do it here though? */
2833 printk(KERN_DEBUG "%s: Caught a WPA supplicant request that is not supported\n",
2839 if (ret == 0 && copy_to_user(p->pointer, param, p->length))
2848 prism54_set_wpa(struct net_device *ndev, struct iw_request_info *info,
2849 __u32 * uwrq, char *extra)
2851 islpci_private *priv = netdev_priv(ndev);
2852 u32 mlme, authen, dot1x, filter, wep;
2854 if (islpci_get_state(priv) < PRV_STATE_INIT)
2857 wep = 1; /* For privacy invoked */
2858 filter = 1; /* Filter out all unencrypted frames */
2859 dot1x = 0x01; /* To enable eap filter */
2860 mlme = DOT11_MLME_EXTENDED;
2861 authen = DOT11_AUTH_OS; /* Only WEP uses _SK and _BOTH */
2863 down_write(&priv->mib_sem);
2866 switch (priv->wpa) {
2868 case 0: /* Clears/disables WPA and friends */
2870 filter = 0; /* Do not filter un-encrypted data */
2872 mlme = DOT11_MLME_AUTO;
2873 printk("%s: Disabling WPA\n", ndev->name);
2877 printk("%s: Enabling WPA\n", ndev->name);
2880 up_write(&priv->mib_sem);
2882 mgt_set_request(priv, DOT11_OID_AUTHENABLE, 0, &authen);
2883 mgt_set_request(priv, DOT11_OID_PRIVACYINVOKED, 0, &wep);
2884 mgt_set_request(priv, DOT11_OID_EXUNENCRYPTED, 0, &filter);
2885 mgt_set_request(priv, DOT11_OID_DOT1XENABLE, 0, &dot1x);
2886 mgt_set_request(priv, DOT11_OID_MLMEAUTOLEVEL, 0, &mlme);
2892 prism54_get_wpa(struct net_device *ndev, struct iw_request_info *info,
2893 __u32 * uwrq, char *extra)
2895 islpci_private *priv = netdev_priv(ndev);
2901 prism54_set_prismhdr(struct net_device *ndev, struct iw_request_info *info,
2902 __u32 * uwrq, char *extra)
2904 islpci_private *priv = netdev_priv(ndev);
2905 priv->monitor_type =
2906 (*uwrq ? ARPHRD_IEEE80211_PRISM : ARPHRD_IEEE80211);
2907 if (priv->iw_mode == IW_MODE_MONITOR)
2908 priv->ndev->type = priv->monitor_type;
2914 prism54_get_prismhdr(struct net_device *ndev, struct iw_request_info *info,
2915 __u32 * uwrq, char *extra)
2917 islpci_private *priv = netdev_priv(ndev);
2918 *uwrq = (priv->monitor_type == ARPHRD_IEEE80211_PRISM);
2923 prism54_debug_oid(struct net_device *ndev, struct iw_request_info *info,
2924 __u32 * uwrq, char *extra)
2926 islpci_private *priv = netdev_priv(ndev);
2928 priv->priv_oid = *uwrq;
2929 printk("%s: oid 0x%08X\n", ndev->name, *uwrq);
2935 prism54_debug_get_oid(struct net_device *ndev, struct iw_request_info *info,
2936 struct iw_point *data, char *extra)
2938 islpci_private *priv = netdev_priv(ndev);
2939 struct islpci_mgmtframe *response;
2942 printk("%s: get_oid 0x%08X\n", ndev->name, priv->priv_oid);
2945 if (islpci_get_state(priv) >= PRV_STATE_INIT) {
2947 islpci_mgt_transaction(priv->ndev, PIMFOR_OP_GET,
2948 priv->priv_oid, extra, 256,
2950 printk("%s: ret: %i\n", ndev->name, ret);
2951 if (ret || !response
2952 || response->header->operation == PIMFOR_OP_ERROR) {
2954 islpci_mgt_release(response);
2956 printk("%s: EIO\n", ndev->name);
2960 data->length = response->header->length;
2961 memcpy(extra, response->data, data->length);
2962 islpci_mgt_release(response);
2963 printk("%s: len: %i\n", ndev->name, data->length);
2971 prism54_debug_set_oid(struct net_device *ndev, struct iw_request_info *info,
2972 struct iw_point *data, char *extra)
2974 islpci_private *priv = netdev_priv(ndev);
2975 struct islpci_mgmtframe *response;
2976 int ret = 0, response_op = PIMFOR_OP_ERROR;
2978 printk("%s: set_oid 0x%08X\tlen: %d\n", ndev->name, priv->priv_oid,
2981 if (islpci_get_state(priv) >= PRV_STATE_INIT) {
2983 islpci_mgt_transaction(priv->ndev, PIMFOR_OP_SET,
2984 priv->priv_oid, extra, data->length,
2986 printk("%s: ret: %i\n", ndev->name, ret);
2987 if (ret || !response
2988 || response->header->operation == PIMFOR_OP_ERROR) {
2990 islpci_mgt_release(response);
2992 printk("%s: EIO\n", ndev->name);
2996 response_op = response->header->operation;
2997 printk("%s: response_op: %i\n", ndev->name,
2999 islpci_mgt_release(response);
3003 return (ret ? ret : -EINPROGRESS);
3007 prism54_set_spy(struct net_device *ndev,
3008 struct iw_request_info *info,
3009 union iwreq_data *uwrq, char *extra)
3011 islpci_private *priv = netdev_priv(ndev);
3012 u32 u, oid = OID_INL_CONFIG;
3014 down_write(&priv->mib_sem);
3015 mgt_get(priv, OID_INL_CONFIG, &u);
3017 if ((uwrq->data.length == 0) && (priv->spy_data.spy_number > 0))
3019 u &= ~INL_CONFIG_RXANNEX;
3020 else if ((uwrq->data.length > 0) && (priv->spy_data.spy_number == 0))
3022 u |= INL_CONFIG_RXANNEX;
3024 mgt_set(priv, OID_INL_CONFIG, &u);
3025 mgt_commit_list(priv, &oid, 1);
3026 up_write(&priv->mib_sem);
3028 return iw_handler_set_spy(ndev, info, uwrq, extra);
3031 static const iw_handler prism54_handler[] = {
3032 (iw_handler) prism54_commit, /* SIOCSIWCOMMIT */
3033 (iw_handler) prism54_get_name, /* SIOCGIWNAME */
3034 (iw_handler) NULL, /* SIOCSIWNWID */
3035 (iw_handler) NULL, /* SIOCGIWNWID */
3036 (iw_handler) prism54_set_freq, /* SIOCSIWFREQ */
3037 (iw_handler) prism54_get_freq, /* SIOCGIWFREQ */
3038 (iw_handler) prism54_set_mode, /* SIOCSIWMODE */
3039 (iw_handler) prism54_get_mode, /* SIOCGIWMODE */
3040 (iw_handler) prism54_set_sens, /* SIOCSIWSENS */
3041 (iw_handler) prism54_get_sens, /* SIOCGIWSENS */
3042 (iw_handler) NULL, /* SIOCSIWRANGE */
3043 (iw_handler) prism54_get_range, /* SIOCGIWRANGE */
3044 (iw_handler) NULL, /* SIOCSIWPRIV */
3045 (iw_handler) NULL, /* SIOCGIWPRIV */
3046 (iw_handler) NULL, /* SIOCSIWSTATS */
3047 (iw_handler) NULL, /* SIOCGIWSTATS */
3048 prism54_set_spy, /* SIOCSIWSPY */
3049 iw_handler_get_spy, /* SIOCGIWSPY */
3050 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
3051 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
3052 (iw_handler) prism54_set_wap, /* SIOCSIWAP */
3053 (iw_handler) prism54_get_wap, /* SIOCGIWAP */
3054 (iw_handler) NULL, /* -- hole -- */
3055 (iw_handler) NULL, /* SIOCGIWAPLIST depreciated */
3056 (iw_handler) prism54_set_scan, /* SIOCSIWSCAN */
3057 (iw_handler) prism54_get_scan, /* SIOCGIWSCAN */
3058 (iw_handler) prism54_set_essid, /* SIOCSIWESSID */
3059 (iw_handler) prism54_get_essid, /* SIOCGIWESSID */
3060 (iw_handler) prism54_set_nick, /* SIOCSIWNICKN */
3061 (iw_handler) prism54_get_nick, /* SIOCGIWNICKN */
3062 (iw_handler) NULL, /* -- hole -- */
3063 (iw_handler) NULL, /* -- hole -- */
3064 (iw_handler) prism54_set_rate, /* SIOCSIWRATE */
3065 (iw_handler) prism54_get_rate, /* SIOCGIWRATE */
3066 (iw_handler) prism54_set_rts, /* SIOCSIWRTS */
3067 (iw_handler) prism54_get_rts, /* SIOCGIWRTS */
3068 (iw_handler) prism54_set_frag, /* SIOCSIWFRAG */
3069 (iw_handler) prism54_get_frag, /* SIOCGIWFRAG */
3070 (iw_handler) prism54_set_txpower, /* SIOCSIWTXPOW */
3071 (iw_handler) prism54_get_txpower, /* SIOCGIWTXPOW */
3072 (iw_handler) prism54_set_retry, /* SIOCSIWRETRY */
3073 (iw_handler) prism54_get_retry, /* SIOCGIWRETRY */
3074 (iw_handler) prism54_set_encode, /* SIOCSIWENCODE */
3075 (iw_handler) prism54_get_encode, /* SIOCGIWENCODE */
3076 (iw_handler) NULL, /* SIOCSIWPOWER */
3077 (iw_handler) NULL, /* SIOCGIWPOWER */
3078 NULL, /* -- hole -- */
3079 NULL, /* -- hole -- */
3080 (iw_handler) prism54_set_genie, /* SIOCSIWGENIE */
3081 (iw_handler) prism54_get_genie, /* SIOCGIWGENIE */
3082 (iw_handler) prism54_set_auth, /* SIOCSIWAUTH */
3083 (iw_handler) prism54_get_auth, /* SIOCGIWAUTH */
3084 (iw_handler) prism54_set_encodeext, /* SIOCSIWENCODEEXT */
3085 (iw_handler) prism54_get_encodeext, /* SIOCGIWENCODEEXT */
3086 NULL, /* SIOCSIWPMKSA */
3089 /* The low order bit identify a SET (0) or a GET (1) ioctl. */
3091 #define PRISM54_RESET SIOCIWFIRSTPRIV
3092 #define PRISM54_GET_POLICY SIOCIWFIRSTPRIV+1
3093 #define PRISM54_SET_POLICY SIOCIWFIRSTPRIV+2
3094 #define PRISM54_GET_MAC SIOCIWFIRSTPRIV+3
3095 #define PRISM54_ADD_MAC SIOCIWFIRSTPRIV+4
3097 #define PRISM54_DEL_MAC SIOCIWFIRSTPRIV+6
3099 #define PRISM54_KICK_MAC SIOCIWFIRSTPRIV+8
3101 #define PRISM54_KICK_ALL SIOCIWFIRSTPRIV+10
3103 #define PRISM54_GET_WPA SIOCIWFIRSTPRIV+11
3104 #define PRISM54_SET_WPA SIOCIWFIRSTPRIV+12
3106 #define PRISM54_DBG_OID SIOCIWFIRSTPRIV+14
3107 #define PRISM54_DBG_GET_OID SIOCIWFIRSTPRIV+15
3108 #define PRISM54_DBG_SET_OID SIOCIWFIRSTPRIV+16
3110 #define PRISM54_GET_OID SIOCIWFIRSTPRIV+17
3111 #define PRISM54_SET_OID_U32 SIOCIWFIRSTPRIV+18
3112 #define PRISM54_SET_OID_STR SIOCIWFIRSTPRIV+20
3113 #define PRISM54_SET_OID_ADDR SIOCIWFIRSTPRIV+22
3115 #define PRISM54_GET_PRISMHDR SIOCIWFIRSTPRIV+23
3116 #define PRISM54_SET_PRISMHDR SIOCIWFIRSTPRIV+24
3118 #define IWPRIV_SET_U32(n,x) { n, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "s_"x }
3119 #define IWPRIV_SET_SSID(n,x) { n, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 1, 0, "s_"x }
3120 #define IWPRIV_SET_ADDR(n,x) { n, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "s_"x }
3121 #define IWPRIV_GET(n,x) { n, 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | PRIV_STR_SIZE, "g_"x }
3123 #define IWPRIV_U32(n,x) IWPRIV_SET_U32(n,x), IWPRIV_GET(n,x)
3124 #define IWPRIV_SSID(n,x) IWPRIV_SET_SSID(n,x), IWPRIV_GET(n,x)
3125 #define IWPRIV_ADDR(n,x) IWPRIV_SET_ADDR(n,x), IWPRIV_GET(n,x)
3127 /* Note : limited to 128 private ioctls (wireless tools 26) */
3129 static const struct iw_priv_args prism54_private_args[] = {
3130 /*{ cmd, set_args, get_args, name } */
3131 {PRISM54_RESET, 0, 0, "reset"},
3132 {PRISM54_GET_PRISMHDR, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
3134 {PRISM54_SET_PRISMHDR, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
3136 {PRISM54_GET_POLICY, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
3138 {PRISM54_SET_POLICY, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
3140 {PRISM54_GET_MAC, 0, IW_PRIV_TYPE_ADDR | 64, "getMac"},
3141 {PRISM54_ADD_MAC, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0,
3143 {PRISM54_DEL_MAC, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0,
3145 {PRISM54_KICK_MAC, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0,
3147 {PRISM54_KICK_ALL, 0, 0, "kickAll"},
3148 {PRISM54_GET_WPA, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
3150 {PRISM54_SET_WPA, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
3152 {PRISM54_DBG_OID, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
3154 {PRISM54_DBG_GET_OID, 0, IW_PRIV_TYPE_BYTE | 256, "dbg_get_oid"},
3155 {PRISM54_DBG_SET_OID, IW_PRIV_TYPE_BYTE | 256, 0, "dbg_set_oid"},
3156 /* --- sub-ioctls handlers --- */
3158 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | PRIV_STR_SIZE, ""},
3159 {PRISM54_SET_OID_U32,
3160 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, ""},
3161 {PRISM54_SET_OID_STR,
3162 IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 1, 0, ""},
3163 {PRISM54_SET_OID_ADDR,
3164 IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, ""},
3165 /* --- sub-ioctls definitions --- */
3166 IWPRIV_ADDR(GEN_OID_MACADDRESS, "addr"),
3167 IWPRIV_GET(GEN_OID_LINKSTATE, "linkstate"),
3168 IWPRIV_U32(DOT11_OID_BSSTYPE, "bsstype"),
3169 IWPRIV_ADDR(DOT11_OID_BSSID, "bssid"),
3170 IWPRIV_U32(DOT11_OID_STATE, "state"),
3171 IWPRIV_U32(DOT11_OID_AID, "aid"),
3173 IWPRIV_SSID(DOT11_OID_SSIDOVERRIDE, "ssidoverride"),
3175 IWPRIV_U32(DOT11_OID_MEDIUMLIMIT, "medlimit"),
3176 IWPRIV_U32(DOT11_OID_BEACONPERIOD, "beacon"),
3177 IWPRIV_U32(DOT11_OID_DTIMPERIOD, "dtimperiod"),
3179 IWPRIV_U32(DOT11_OID_AUTHENABLE, "authenable"),
3180 IWPRIV_U32(DOT11_OID_PRIVACYINVOKED, "privinvok"),
3181 IWPRIV_U32(DOT11_OID_EXUNENCRYPTED, "exunencrypt"),
3183 IWPRIV_U32(DOT11_OID_REKEYTHRESHOLD, "rekeythresh"),
3185 IWPRIV_U32(DOT11_OID_MAXTXLIFETIME, "maxtxlife"),
3186 IWPRIV_U32(DOT11_OID_MAXRXLIFETIME, "maxrxlife"),
3187 IWPRIV_U32(DOT11_OID_ALOFT_FIXEDRATE, "fixedrate"),
3188 IWPRIV_U32(DOT11_OID_MAXFRAMEBURST, "frameburst"),
3189 IWPRIV_U32(DOT11_OID_PSM, "psm"),
3191 IWPRIV_U32(DOT11_OID_BRIDGELOCAL, "bridge"),
3192 IWPRIV_U32(DOT11_OID_CLIENTS, "clients"),
3193 IWPRIV_U32(DOT11_OID_CLIENTSASSOCIATED, "clientassoc"),
3194 IWPRIV_U32(DOT11_OID_DOT1XENABLE, "dot1xenable"),
3195 IWPRIV_U32(DOT11_OID_ANTENNARX, "rxant"),
3196 IWPRIV_U32(DOT11_OID_ANTENNATX, "txant"),
3197 IWPRIV_U32(DOT11_OID_ANTENNADIVERSITY, "antdivers"),
3198 IWPRIV_U32(DOT11_OID_EDTHRESHOLD, "edthresh"),
3199 IWPRIV_U32(DOT11_OID_PREAMBLESETTINGS, "preamble"),
3200 IWPRIV_GET(DOT11_OID_RATES, "rates"),
3201 IWPRIV_U32(DOT11_OID_OUTPUTPOWER, ".11outpower"),
3202 IWPRIV_GET(DOT11_OID_SUPPORTEDRATES, "supprates"),
3203 IWPRIV_GET(DOT11_OID_SUPPORTEDFREQUENCIES, "suppfreq"),
3205 IWPRIV_U32(DOT11_OID_NOISEFLOOR, "noisefloor"),
3206 IWPRIV_GET(DOT11_OID_FREQUENCYACTIVITY, "freqactivity"),
3207 IWPRIV_U32(DOT11_OID_NONERPPROTECTION, "nonerpprotec"),
3208 IWPRIV_U32(DOT11_OID_PROFILES, "profile"),
3209 IWPRIV_GET(DOT11_OID_EXTENDEDRATES, "extrates"),
3210 IWPRIV_U32(DOT11_OID_MLMEAUTOLEVEL, "mlmelevel"),
3212 IWPRIV_GET(DOT11_OID_BSSS, "bsss"),
3213 IWPRIV_GET(DOT11_OID_BSSLIST, "bsslist"),
3214 IWPRIV_U32(OID_INL_MODE, "mode"),
3215 IWPRIV_U32(OID_INL_CONFIG, "config"),
3216 IWPRIV_U32(OID_INL_DOT11D_CONFORMANCE, ".11dconform"),
3217 IWPRIV_GET(OID_INL_PHYCAPABILITIES, "phycapa"),
3218 IWPRIV_U32(OID_INL_OUTPUTPOWER, "outpower"),
3221 static const iw_handler prism54_private_handler[] = {
3222 (iw_handler) prism54_reset,
3223 (iw_handler) prism54_get_policy,
3224 (iw_handler) prism54_set_policy,
3225 (iw_handler) prism54_get_mac,
3226 (iw_handler) prism54_add_mac,
3228 (iw_handler) prism54_del_mac,
3230 (iw_handler) prism54_kick_mac,
3232 (iw_handler) prism54_kick_all,
3233 (iw_handler) prism54_get_wpa,
3234 (iw_handler) prism54_set_wpa,
3236 (iw_handler) prism54_debug_oid,
3237 (iw_handler) prism54_debug_get_oid,
3238 (iw_handler) prism54_debug_set_oid,
3239 (iw_handler) prism54_get_oid,
3240 (iw_handler) prism54_set_u32,
3242 (iw_handler) prism54_set_raw,
3244 (iw_handler) prism54_set_raw,
3245 (iw_handler) prism54_get_prismhdr,
3246 (iw_handler) prism54_set_prismhdr,
3249 const struct iw_handler_def prism54_handler_def = {
3250 .num_standard = sizeof (prism54_handler) / sizeof (iw_handler),
3251 .num_private = sizeof (prism54_private_handler) / sizeof (iw_handler),
3253 sizeof (prism54_private_args) / sizeof (struct iw_priv_args),
3254 .standard = (iw_handler *) prism54_handler,
3255 .private = (iw_handler *) prism54_private_handler,
3256 .private_args = (struct iw_priv_args *) prism54_private_args,
3257 .get_wireless_stats = prism54_get_wireless_stats,
3260 /* For wpa_supplicant */
3263 prism54_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
3265 struct iwreq *wrq = (struct iwreq *) rq;
3268 case PRISM54_HOSTAPD:
3269 if (!capable(CAP_NET_ADMIN))
3271 ret = prism54_hostapd(ndev, &wrq->u.data);