2 * Copyright (C) 2002 Intersil Americas Inc.
3 * (C) 2003,2004 Aurelien Alleaume <slts@free.fr>
4 * (C) 2003 Herbert Valerio Riedel <hvr@gnu.org>
5 * (C) 2003 Luis R. Rodriguez <mcgrof@ruslug.rutgers.edu>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <linux/module.h>
23 #include <linux/kernel.h>
24 #include <linux/if_arp.h>
25 #include <linux/pci.h>
27 #include <asm/uaccess.h>
29 #include "prismcompat.h"
30 #include "isl_ioctl.h"
31 #include "islpci_mgt.h"
32 #include "isl_oid.h" /* additional types and defs for isl38xx fw */
35 #include <net/iw_handler.h> /* New driver API */
37 #define KEY_SIZE_WEP104 13 /* 104/128-bit WEP keys */
38 #define KEY_SIZE_WEP40 5 /* 40/64-bit WEP keys */
39 /* KEY_SIZE_TKIP should match isl_oid.h, struct obj_key.key[] size */
40 #define KEY_SIZE_TKIP 32 /* TKIP keys */
42 static void prism54_wpa_bss_ie_add(islpci_private *priv, u8 *bssid,
43 u8 *wpa_ie, size_t wpa_ie_len);
44 static size_t prism54_wpa_bss_ie_get(islpci_private *priv, u8 *bssid, u8 *wpa_ie);
45 static int prism54_set_wpa(struct net_device *, struct iw_request_info *,
49 static const unsigned char scan_rate_list[] = { 2, 4, 11, 22,
54 * prism54_mib_mode_helper - MIB change mode helper function
55 * @mib: the &struct islpci_mib object to modify
56 * @iw_mode: new mode (%IW_MODE_*)
58 * This is a helper function, hence it does not lock. Make sure
59 * caller deals with locking *if* necessary. This function sets the
60 * mode-dependent mib values and does the mapping of the Linux
61 * Wireless API modes to Device firmware modes. It also checks for
62 * correct valid Linux wireless modes.
65 prism54_mib_mode_helper(islpci_private *priv, u32 iw_mode)
67 u32 config = INL_CONFIG_MANUALRUN;
70 /* For now, just catch early the Repeater and Secondary modes here */
71 if (iw_mode == IW_MODE_REPEAT || iw_mode == IW_MODE_SECOND) {
73 "%s(): Sorry, Repeater mode and Secondary mode "
74 "are not yet supported by this driver.\n", __FUNCTION__);
78 priv->iw_mode = iw_mode;
82 mode = INL_MODE_CLIENT;
83 bsstype = DOT11_BSSTYPE_ANY;
86 mode = INL_MODE_CLIENT;
87 bsstype = DOT11_BSSTYPE_IBSS;
90 mode = INL_MODE_CLIENT;
91 bsstype = DOT11_BSSTYPE_INFRA;
95 bsstype = DOT11_BSSTYPE_INFRA;
98 mode = INL_MODE_PROMISCUOUS;
99 bsstype = DOT11_BSSTYPE_ANY;
100 config |= INL_CONFIG_RXANNEX;
107 config |= INL_CONFIG_WDS;
108 mgt_set(priv, DOT11_OID_BSSTYPE, &bsstype);
109 mgt_set(priv, OID_INL_CONFIG, &config);
110 mgt_set(priv, OID_INL_MODE, &mode);
116 * prism54_mib_init - fill MIB cache with defaults
118 * this function initializes the struct given as @mib with defaults,
119 * of which many are retrieved from the global module parameter
124 prism54_mib_init(islpci_private *priv)
126 u32 channel, authen, wep, filter, dot1x, mlme, conformance, power, mode;
127 struct obj_buffer psm_buffer = {
128 .size = PSM_BUFFER_SIZE,
129 .addr = priv->device_psm_buffer
132 channel = CARD_DEFAULT_CHANNEL;
133 authen = CARD_DEFAULT_AUTHEN;
134 wep = CARD_DEFAULT_WEP;
135 filter = CARD_DEFAULT_FILTER; /* (0) Do not filter un-encrypted data */
136 dot1x = CARD_DEFAULT_DOT1X;
137 mlme = CARD_DEFAULT_MLME_MODE;
138 conformance = CARD_DEFAULT_CONFORMANCE;
140 mode = CARD_DEFAULT_IW_MODE;
142 mgt_set(priv, DOT11_OID_CHANNEL, &channel);
143 mgt_set(priv, DOT11_OID_AUTHENABLE, &authen);
144 mgt_set(priv, DOT11_OID_PRIVACYINVOKED, &wep);
145 mgt_set(priv, DOT11_OID_PSMBUFFER, &psm_buffer);
146 mgt_set(priv, DOT11_OID_EXUNENCRYPTED, &filter);
147 mgt_set(priv, DOT11_OID_DOT1XENABLE, &dot1x);
148 mgt_set(priv, DOT11_OID_MLMEAUTOLEVEL, &mlme);
149 mgt_set(priv, OID_INL_DOT11D_CONFORMANCE, &conformance);
150 mgt_set(priv, OID_INL_OUTPUTPOWER, &power);
152 /* This sets all of the mode-dependent values */
153 prism54_mib_mode_helper(priv, mode);
156 /* this will be executed outside of atomic context thanks to
157 * schedule_work(), thus we can as well use sleeping semaphore
160 prism54_update_stats(islpci_private *priv)
164 struct obj_bss bss, *bss2;
167 if (down_interruptible(&priv->stats_sem))
171 * I'm not sure if the unit is dBm.
172 * Note : If we are not connected, this value seems to be irrelevant. */
174 mgt_get_request(priv, DOT11_OID_NOISEFLOOR, 0, NULL, &r);
175 priv->local_iwstatistics.qual.noise = r.u;
177 /* Get the rssi of the link. To do this we need to retrieve a bss. */
179 /* First get the MAC address of the AP we are associated with. */
180 mgt_get_request(priv, DOT11_OID_BSSID, 0, NULL, &r);
183 /* copy this MAC to the bss */
184 memcpy(bss.address, data, 6);
187 /* now ask for the corresponding bss */
188 j = mgt_get_request(priv, DOT11_OID_BSSFIND, 0, (void *) &bss, &r);
190 /* report the rssi and use it to calculate
191 * link quality through a signal-noise
193 priv->local_iwstatistics.qual.level = bss2->rssi;
194 priv->local_iwstatistics.qual.qual =
195 bss2->rssi - priv->iwstatistics.qual.noise;
199 /* report that the stats are new */
200 priv->local_iwstatistics.qual.updated = 0x7;
202 /* Rx : unable to decrypt the MPDU */
203 mgt_get_request(priv, DOT11_OID_PRIVRXFAILED, 0, NULL, &r);
204 priv->local_iwstatistics.discard.code = r.u;
206 /* Tx : Max MAC retries num reached */
207 mgt_get_request(priv, DOT11_OID_MPDUTXFAILED, 0, NULL, &r);
208 priv->local_iwstatistics.discard.retries = r.u;
210 up(&priv->stats_sem);
215 struct iw_statistics *
216 prism54_get_wireless_stats(struct net_device *ndev)
218 islpci_private *priv = netdev_priv(ndev);
220 /* If the stats are being updated return old data */
221 if (down_trylock(&priv->stats_sem) == 0) {
222 memcpy(&priv->iwstatistics, &priv->local_iwstatistics,
223 sizeof (struct iw_statistics));
224 /* They won't be marked updated for the next time */
225 priv->local_iwstatistics.qual.updated = 0;
226 up(&priv->stats_sem);
228 priv->iwstatistics.qual.updated = 0;
230 /* Update our wireless stats, but do not schedule to often
232 if ((priv->stats_timestamp == 0) ||
233 time_after(jiffies, priv->stats_timestamp + 1 * HZ)) {
234 schedule_work(&priv->stats_work);
235 priv->stats_timestamp = jiffies;
238 return &priv->iwstatistics;
242 prism54_commit(struct net_device *ndev, struct iw_request_info *info,
243 char *cwrq, char *extra)
245 islpci_private *priv = netdev_priv(ndev);
247 /* simply re-set the last set SSID, this should commit most stuff */
249 /* Commit in Monitor mode is not necessary, also setting essid
250 * in Monitor mode does not make sense and isn't allowed for this
251 * device's firmware */
252 if (priv->iw_mode != IW_MODE_MONITOR)
253 return mgt_set_request(priv, DOT11_OID_SSID, 0, NULL);
258 prism54_get_name(struct net_device *ndev, struct iw_request_info *info,
259 char *cwrq, char *extra)
261 islpci_private *priv = netdev_priv(ndev);
266 if (islpci_get_state(priv) < PRV_STATE_INIT) {
267 strncpy(cwrq, "NOT READY!", IFNAMSIZ);
270 rvalue = mgt_get_request(priv, OID_INL_PHYCAPABILITIES, 0, NULL, &r);
273 case INL_PHYCAP_5000MHZ:
274 capabilities = "IEEE 802.11a/b/g";
277 capabilities = "IEEE 802.11b/g - FAA Support";
279 case INL_PHYCAP_2400MHZ:
281 capabilities = "IEEE 802.11b/g"; /* Default */
284 strncpy(cwrq, capabilities, IFNAMSIZ);
289 prism54_set_freq(struct net_device *ndev, struct iw_request_info *info,
290 struct iw_freq *fwrq, char *extra)
292 islpci_private *priv = netdev_priv(ndev);
297 /* we have a channel number */
300 c = (fwrq->e == 1) ? channel_of_freq(fwrq->m / 100000) : 0;
302 rvalue = c ? mgt_set_request(priv, DOT11_OID_CHANNEL, 0, &c) : -EINVAL;
304 /* Call commit handler */
305 return (rvalue ? rvalue : -EINPROGRESS);
309 prism54_get_freq(struct net_device *ndev, struct iw_request_info *info,
310 struct iw_freq *fwrq, char *extra)
312 islpci_private *priv = netdev_priv(ndev);
316 rvalue = mgt_get_request(priv, DOT11_OID_CHANNEL, 0, NULL, &r);
318 rvalue |= mgt_get_request(priv, DOT11_OID_FREQUENCY, 0, NULL, &r);
326 prism54_set_mode(struct net_device *ndev, struct iw_request_info *info,
327 __u32 * uwrq, char *extra)
329 islpci_private *priv = netdev_priv(ndev);
330 u32 mlmeautolevel = CARD_DEFAULT_MLME_MODE;
332 /* Let's see if the user passed a valid Linux Wireless mode */
333 if (*uwrq > IW_MODE_MONITOR || *uwrq < IW_MODE_AUTO) {
335 "%s: %s() You passed a non-valid init_mode.\n",
336 priv->ndev->name, __FUNCTION__);
340 down_write(&priv->mib_sem);
342 if (prism54_mib_mode_helper(priv, *uwrq)) {
343 up_write(&priv->mib_sem);
347 /* the ACL code needs an intermediate mlmeautolevel. The wpa stuff an
350 if ((*uwrq == IW_MODE_MASTER) && (priv->acl.policy != MAC_POLICY_OPEN))
351 mlmeautolevel = DOT11_MLME_INTERMEDIATE;
353 mlmeautolevel = DOT11_MLME_EXTENDED;
355 mgt_set(priv, DOT11_OID_MLMEAUTOLEVEL, &mlmeautolevel);
357 if (mgt_commit(priv)) {
358 up_write(&priv->mib_sem);
361 priv->ndev->type = (priv->iw_mode == IW_MODE_MONITOR)
362 ? priv->monitor_type : ARPHRD_ETHER;
363 up_write(&priv->mib_sem);
370 prism54_get_mode(struct net_device *ndev, struct iw_request_info *info,
371 __u32 * uwrq, char *extra)
373 islpci_private *priv = netdev_priv(ndev);
375 BUG_ON((priv->iw_mode < IW_MODE_AUTO) || (priv->iw_mode >
377 *uwrq = priv->iw_mode;
382 /* we use DOT11_OID_EDTHRESHOLD. From what I guess the card will not try to
383 * emit data if (sensitivity > rssi - noise) (in dBm).
384 * prism54_set_sens does not seem to work.
388 prism54_set_sens(struct net_device *ndev, struct iw_request_info *info,
389 struct iw_param *vwrq, char *extra)
391 islpci_private *priv = netdev_priv(ndev);
394 /* by default the card sets this to 20. */
395 sens = vwrq->disabled ? 20 : vwrq->value;
397 return mgt_set_request(priv, DOT11_OID_EDTHRESHOLD, 0, &sens);
401 prism54_get_sens(struct net_device *ndev, struct iw_request_info *info,
402 struct iw_param *vwrq, char *extra)
404 islpci_private *priv = netdev_priv(ndev);
408 rvalue = mgt_get_request(priv, DOT11_OID_EDTHRESHOLD, 0, NULL, &r);
411 vwrq->disabled = (vwrq->value == 0);
418 prism54_get_range(struct net_device *ndev, struct iw_request_info *info,
419 struct iw_point *dwrq, char *extra)
421 struct iw_range *range = (struct iw_range *) extra;
422 islpci_private *priv = netdev_priv(ndev);
425 struct obj_frequencies *freq;
428 memset(range, 0, sizeof (struct iw_range));
429 dwrq->length = sizeof (struct iw_range);
431 /* set the wireless extension version number */
432 range->we_version_source = SUPPORTED_WIRELESS_EXT;
433 range->we_version_compiled = WIRELESS_EXT;
435 /* Now the encoding capabilities */
436 range->num_encoding_sizes = 3;
437 /* 64(40) bits WEP */
438 range->encoding_size[0] = 5;
439 /* 128(104) bits WEP */
440 range->encoding_size[1] = 13;
441 /* 256 bits for WPA-PSK */
442 range->encoding_size[2] = 32;
443 /* 4 keys are allowed */
444 range->max_encoding_tokens = 4;
446 /* we don't know the quality range... */
447 range->max_qual.level = 0;
448 range->max_qual.noise = 0;
449 range->max_qual.qual = 0;
450 /* these value describe an average quality. Needs more tweaking... */
451 range->avg_qual.level = -80; /* -80 dBm */
452 range->avg_qual.noise = 0; /* don't know what to put here */
453 range->avg_qual.qual = 0;
455 range->sensitivity = 200;
457 /* retry limit capabilities */
458 range->retry_capa = IW_RETRY_LIMIT | IW_RETRY_LIFETIME;
459 range->retry_flags = IW_RETRY_LIMIT;
460 range->r_time_flags = IW_RETRY_LIFETIME;
462 /* I don't know the range. Put stupid things here */
463 range->min_retry = 1;
464 range->max_retry = 65535;
465 range->min_r_time = 1024;
466 range->max_r_time = 65535 * 1024;
468 /* txpower is supported in dBm's */
469 range->txpower_capa = IW_TXPOW_DBM;
471 /* Event capability (kernel + driver) */
472 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
473 IW_EVENT_CAPA_MASK(SIOCGIWTHRSPY) |
474 IW_EVENT_CAPA_MASK(SIOCGIWAP));
475 range->event_capa[1] = IW_EVENT_CAPA_K_1;
476 range->event_capa[4] = IW_EVENT_CAPA_MASK(IWEVCUSTOM);
478 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
479 IW_ENC_CAPA_CIPHER_TKIP;
481 if (islpci_get_state(priv) < PRV_STATE_INIT)
484 /* Request the device for the supported frequencies
485 * not really relevant since some devices will report the 5 GHz band
486 * frequencies even if they don't support them.
489 mgt_get_request(priv, DOT11_OID_SUPPORTEDFREQUENCIES, 0, NULL, &r);
492 range->num_channels = freq->nr;
493 range->num_frequency = freq->nr;
495 m = min(IW_MAX_FREQUENCIES, (int) freq->nr);
496 for (i = 0; i < m; i++) {
497 range->freq[i].m = freq->mhz[i];
498 range->freq[i].e = 6;
499 range->freq[i].i = channel_of_freq(freq->mhz[i]);
503 rvalue |= mgt_get_request(priv, DOT11_OID_SUPPORTEDRATES, 0, NULL, &r);
506 /* We got an array of char. It is NULL terminated. */
508 while ((i < IW_MAX_BITRATES) && (*data != 0)) {
509 /* the result must be in bps. The card gives us 500Kbps */
510 range->bitrate[i] = *data * 500000;
514 range->num_bitrates = i;
523 prism54_set_wap(struct net_device *ndev, struct iw_request_info *info,
524 struct sockaddr *awrq, char *extra)
526 islpci_private *priv = netdev_priv(ndev);
530 if (awrq->sa_family != ARPHRD_ETHER)
533 /* prepare the structure for the set object */
534 memcpy(&bssid[0], awrq->sa_data, 6);
536 /* set the bssid -- does this make sense when in AP mode? */
537 rvalue = mgt_set_request(priv, DOT11_OID_BSSID, 0, &bssid);
539 return (rvalue ? rvalue : -EINPROGRESS); /* Call commit handler */
545 prism54_get_wap(struct net_device *ndev, struct iw_request_info *info,
546 struct sockaddr *awrq, char *extra)
548 islpci_private *priv = netdev_priv(ndev);
552 rvalue = mgt_get_request(priv, DOT11_OID_BSSID, 0, NULL, &r);
553 memcpy(awrq->sa_data, r.ptr, 6);
554 awrq->sa_family = ARPHRD_ETHER;
561 prism54_set_scan(struct net_device *dev, struct iw_request_info *info,
562 struct iw_param *vwrq, char *extra)
564 /* hehe the device does this automagicaly */
568 /* a little helper that will translate our data into a card independent
569 * format that the Wireless Tools will understand. This was inspired by
570 * the "Aironet driver for 4500 and 4800 series cards" (GPL)
574 prism54_translate_bss(struct net_device *ndev, char *current_ev,
575 char *end_buf, struct obj_bss *bss, char noise)
577 struct iw_event iwe; /* Temporary buffer */
579 islpci_private *priv = netdev_priv(ndev);
580 u8 wpa_ie[MAX_WPA_IE_LEN];
583 /* The first entry must be the MAC address */
584 memcpy(iwe.u.ap_addr.sa_data, bss->address, 6);
585 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
588 iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_ADDR_LEN);
590 /* The following entries will be displayed in the same order we give them */
593 iwe.u.data.length = bss->ssid.length;
594 iwe.u.data.flags = 1;
595 iwe.cmd = SIOCGIWESSID;
596 current_ev = iwe_stream_add_point(current_ev, end_buf,
597 &iwe, bss->ssid.octets);
601 #define CAP_IBSS 0x02
602 #define CAP_CRYPT 0x10
608 iwe.u.mode = IW_MODE_MASTER;
609 else if (cap & CAP_IBSS)
610 iwe.u.mode = IW_MODE_ADHOC;
611 iwe.cmd = SIOCGIWMODE;
614 iwe_stream_add_event(current_ev, end_buf, &iwe,
617 /* Encryption capability */
619 iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
621 iwe.u.data.flags = IW_ENCODE_DISABLED;
622 iwe.u.data.length = 0;
623 iwe.cmd = SIOCGIWENCODE;
624 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, NULL);
626 /* Add frequency. (short) bss->channel is the frequency in MHz */
627 iwe.u.freq.m = bss->channel;
629 iwe.cmd = SIOCGIWFREQ;
631 iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_FREQ_LEN);
633 /* Add quality statistics */
634 iwe.u.qual.level = bss->rssi;
635 iwe.u.qual.noise = noise;
636 /* do a simple SNR for quality */
637 iwe.u.qual.qual = bss->rssi - noise;
640 iwe_stream_add_event(current_ev, end_buf, &iwe, IW_EV_QUAL_LEN);
642 /* Add WPA/RSN Information Element, if any */
643 wpa_ie_len = prism54_wpa_bss_ie_get(priv, bss->address, wpa_ie);
644 if (wpa_ie_len > 0) {
646 iwe.u.data.length = min(wpa_ie_len, (size_t)MAX_WPA_IE_LEN);
647 current_ev = iwe_stream_add_point(current_ev, end_buf,
650 /* Do the bitrates */
652 char * current_val = current_ev + IW_EV_LCP_LEN;
656 iwe.cmd = SIOCGIWRATE;
657 /* Those two flags are ignored... */
658 iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0;
660 /* Parse the bitmask */
662 for(i = 0; i < sizeof(scan_rate_list); i++) {
663 if(bss->rates & mask) {
664 iwe.u.bitrate.value = (scan_rate_list[i] * 500000);
665 current_val = iwe_stream_add_value(current_ev, current_val,
671 /* Check if we added any event */
672 if ((current_val - current_ev) > IW_EV_LCP_LEN)
673 current_ev = current_val;
680 prism54_get_scan(struct net_device *ndev, struct iw_request_info *info,
681 struct iw_point *dwrq, char *extra)
683 islpci_private *priv = netdev_priv(ndev);
685 struct obj_bsslist *bsslist;
687 char *current_ev = extra;
690 if (islpci_get_state(priv) < PRV_STATE_INIT) {
691 /* device is not ready, fail gently */
696 /* first get the noise value. We will use it to report the link quality */
697 rvalue = mgt_get_request(priv, DOT11_OID_NOISEFLOOR, 0, NULL, &r);
700 /* Ask the device for a list of known bss.
701 * The old API, using SIOCGIWAPLIST, had a hard limit of IW_MAX_AP=64.
702 * The new API, using SIOCGIWSCAN, is only limited by the buffer size.
703 * WE-14->WE-16, the buffer is limited to IW_SCAN_MAX_DATA bytes.
704 * Starting with WE-17, the buffer can be as big as needed.
705 * But the device won't repport anything if you change the value
706 * of IWMAX_BSS=24. */
708 rvalue |= mgt_get_request(priv, DOT11_OID_BSSLIST, 0, NULL, &r);
711 /* ok now, scan the list and translate its info */
712 for (i = 0; i < (int) bsslist->nr; i++) {
713 current_ev = prism54_translate_bss(ndev, current_ev,
714 extra + dwrq->length,
715 &(bsslist->bsslist[i]),
718 /* Check if there is space for one more entry */
719 if((extra + dwrq->length - current_ev) <= IW_EV_ADDR_LEN) {
720 /* Ask user space to try again with a bigger buffer */
727 dwrq->length = (current_ev - extra);
728 dwrq->flags = 0; /* todo */
734 prism54_set_essid(struct net_device *ndev, struct iw_request_info *info,
735 struct iw_point *dwrq, char *extra)
737 islpci_private *priv = netdev_priv(ndev);
738 struct obj_ssid essid;
740 memset(essid.octets, 0, 33);
742 /* Check if we were asked for `any' */
743 if (dwrq->flags && dwrq->length) {
744 if (dwrq->length > 32)
746 essid.length = dwrq->length;
747 memcpy(essid.octets, extra, dwrq->length);
751 if (priv->iw_mode != IW_MODE_MONITOR)
752 return mgt_set_request(priv, DOT11_OID_SSID, 0, &essid);
754 /* If in monitor mode, just save to mib */
755 mgt_set(priv, DOT11_OID_SSID, &essid);
761 prism54_get_essid(struct net_device *ndev, struct iw_request_info *info,
762 struct iw_point *dwrq, char *extra)
764 islpci_private *priv = netdev_priv(ndev);
765 struct obj_ssid *essid;
769 rvalue = mgt_get_request(priv, DOT11_OID_SSID, 0, NULL, &r);
773 dwrq->flags = 1; /* set ESSID to ON for Wireless Extensions */
774 /* if it is too big, trunk it */
775 dwrq->length = min((u8)IW_ESSID_MAX_SIZE, essid->length);
780 essid->octets[essid->length] = '\0';
781 memcpy(extra, essid->octets, dwrq->length);
787 /* Provides no functionality, just completes the ioctl. In essence this is a
788 * just a cosmetic ioctl.
791 prism54_set_nick(struct net_device *ndev, struct iw_request_info *info,
792 struct iw_point *dwrq, char *extra)
794 islpci_private *priv = netdev_priv(ndev);
796 if (dwrq->length > IW_ESSID_MAX_SIZE)
799 down_write(&priv->mib_sem);
800 memset(priv->nickname, 0, sizeof (priv->nickname));
801 memcpy(priv->nickname, extra, dwrq->length);
802 up_write(&priv->mib_sem);
808 prism54_get_nick(struct net_device *ndev, struct iw_request_info *info,
809 struct iw_point *dwrq, char *extra)
811 islpci_private *priv = netdev_priv(ndev);
815 down_read(&priv->mib_sem);
816 dwrq->length = strlen(priv->nickname);
817 memcpy(extra, priv->nickname, dwrq->length);
818 up_read(&priv->mib_sem);
823 /* Set the allowed Bitrates */
826 prism54_set_rate(struct net_device *ndev,
827 struct iw_request_info *info,
828 struct iw_param *vwrq, char *extra)
831 islpci_private *priv = netdev_priv(ndev);
837 if (vwrq->value == -1) {
838 /* auto mode. No limit. */
840 return mgt_set_request(priv, DOT11_OID_PROFILES, 0, &profile);
843 ret = mgt_get_request(priv, DOT11_OID_SUPPORTEDRATES, 0, NULL, &r);
849 rate = (u32) (vwrq->value / 500000);
854 if (rate && (data[i] == rate)) {
857 if (vwrq->value == i) {
872 /* Now, check if we want a fixed or auto value */
880 printk("prism54 rate: ");
882 printk("%u ", data[i]);
888 ret = mgt_set_request(priv, DOT11_OID_PROFILES, 0, &profile);
889 ret |= mgt_set_request(priv, DOT11_OID_EXTENDEDRATES, 0, data);
890 ret |= mgt_set_request(priv, DOT11_OID_RATES, 0, data);
897 /* Get the current bit rate */
899 prism54_get_rate(struct net_device *ndev,
900 struct iw_request_info *info,
901 struct iw_param *vwrq, char *extra)
903 islpci_private *priv = netdev_priv(ndev);
908 /* Get the current bit rate */
909 if ((rvalue = mgt_get_request(priv, GEN_OID_LINKSTATE, 0, NULL, &r)))
911 vwrq->value = r.u * 500000;
913 /* request the device for the enabled rates */
914 rvalue = mgt_get_request(priv, DOT11_OID_RATES, 0, NULL, &r);
920 vwrq->fixed = (data[0] != 0) && (data[1] == 0);
927 prism54_set_rts(struct net_device *ndev, struct iw_request_info *info,
928 struct iw_param *vwrq, char *extra)
930 islpci_private *priv = netdev_priv(ndev);
932 return mgt_set_request(priv, DOT11_OID_RTSTHRESH, 0, &vwrq->value);
936 prism54_get_rts(struct net_device *ndev, struct iw_request_info *info,
937 struct iw_param *vwrq, char *extra)
939 islpci_private *priv = netdev_priv(ndev);
943 /* get the rts threshold */
944 rvalue = mgt_get_request(priv, DOT11_OID_RTSTHRESH, 0, NULL, &r);
951 prism54_set_frag(struct net_device *ndev, struct iw_request_info *info,
952 struct iw_param *vwrq, char *extra)
954 islpci_private *priv = netdev_priv(ndev);
956 return mgt_set_request(priv, DOT11_OID_FRAGTHRESH, 0, &vwrq->value);
960 prism54_get_frag(struct net_device *ndev, struct iw_request_info *info,
961 struct iw_param *vwrq, char *extra)
963 islpci_private *priv = netdev_priv(ndev);
967 rvalue = mgt_get_request(priv, DOT11_OID_FRAGTHRESH, 0, NULL, &r);
973 /* Here we have (min,max) = max retries for (small frames, big frames). Where
974 * big frame <=> bigger than the rts threshold
975 * small frame <=> smaller than the rts threshold
976 * This is not really the behavior expected by the wireless tool but it seems
977 * to be a common behavior in other drivers.
981 prism54_set_retry(struct net_device *ndev, struct iw_request_info *info,
982 struct iw_param *vwrq, char *extra)
984 islpci_private *priv = netdev_priv(ndev);
985 u32 slimit = 0, llimit = 0; /* short and long limit */
990 /* we cannot disable this feature */
993 if (vwrq->flags & IW_RETRY_LIMIT) {
994 if (vwrq->flags & IW_RETRY_SHORT)
995 slimit = vwrq->value;
996 else if (vwrq->flags & IW_RETRY_LONG)
997 llimit = vwrq->value;
999 /* we are asked to set both */
1000 slimit = vwrq->value;
1001 llimit = vwrq->value;
1004 if (vwrq->flags & IW_RETRY_LIFETIME)
1005 /* Wireless tools use us unit while the device uses 1024 us unit */
1006 lifetime = vwrq->value / 1024;
1008 /* now set what is requested */
1011 mgt_set_request(priv, DOT11_OID_SHORTRETRIES, 0, &slimit);
1014 mgt_set_request(priv, DOT11_OID_LONGRETRIES, 0, &llimit);
1017 mgt_set_request(priv, DOT11_OID_MAXTXLIFETIME, 0,
1023 prism54_get_retry(struct net_device *ndev, struct iw_request_info *info,
1024 struct iw_param *vwrq, char *extra)
1026 islpci_private *priv = netdev_priv(ndev);
1029 vwrq->disabled = 0; /* It cannot be disabled */
1031 if ((vwrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
1032 /* we are asked for the life time */
1034 mgt_get_request(priv, DOT11_OID_MAXTXLIFETIME, 0, NULL, &r);
1035 vwrq->value = r.u * 1024;
1036 vwrq->flags = IW_RETRY_LIFETIME;
1037 } else if ((vwrq->flags & IW_RETRY_LONG)) {
1038 /* we are asked for the long retry limit */
1040 mgt_get_request(priv, DOT11_OID_LONGRETRIES, 0, NULL, &r);
1042 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
1044 /* default. get the short retry limit */
1046 mgt_get_request(priv, DOT11_OID_SHORTRETRIES, 0, NULL, &r);
1048 vwrq->flags = IW_RETRY_LIMIT | IW_RETRY_SHORT;
1055 prism54_set_encode(struct net_device *ndev, struct iw_request_info *info,
1056 struct iw_point *dwrq, char *extra)
1058 islpci_private *priv = netdev_priv(ndev);
1059 int rvalue = 0, force = 0;
1060 int authen = DOT11_AUTH_OS, invoke = 0, exunencrypt = 0;
1063 /* with the new API, it's impossible to get a NULL pointer.
1064 * New version of iwconfig set the IW_ENCODE_NOKEY flag
1065 * when no key is given, but older versions don't. */
1067 if (dwrq->length > 0) {
1068 /* we have a key to set */
1069 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
1071 struct obj_key key = { DOT11_PRIV_WEP, 0, "" };
1073 /* get the current key index */
1074 rvalue = mgt_get_request(priv, DOT11_OID_DEFKEYID, 0, NULL, &r);
1075 current_index = r.u;
1076 /* Verify that the key is not marked as invalid */
1077 if (!(dwrq->flags & IW_ENCODE_NOKEY)) {
1078 if (dwrq->length > KEY_SIZE_TKIP) {
1079 /* User-provided key data too big */
1082 if (dwrq->length > KEY_SIZE_WEP104) {
1084 key.type = DOT11_PRIV_TKIP;
1085 key.length = KEY_SIZE_TKIP;
1086 } else if (dwrq->length > KEY_SIZE_WEP40) {
1088 key.length = KEY_SIZE_WEP104;
1091 key.length = KEY_SIZE_WEP40;
1093 memset(key.key, 0, sizeof (key.key));
1094 memcpy(key.key, extra, dwrq->length);
1096 if ((index < 0) || (index > 3))
1097 /* no index provided use the current one */
1098 index = current_index;
1100 /* now send the key to the card */
1102 mgt_set_request(priv, DOT11_OID_DEFKEYX, index,
1106 * If a valid key is set, encryption should be enabled
1107 * (user may turn it off later).
1108 * This is also how "iwconfig ethX key on" works
1110 if ((index == current_index) && (key.length > 0))
1113 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
1114 if ((index >= 0) && (index <= 3)) {
1115 /* we want to set the key index */
1117 mgt_set_request(priv, DOT11_OID_DEFKEYID, 0,
1120 if (!dwrq->flags & IW_ENCODE_MODE) {
1121 /* we cannot do anything. Complain. */
1126 /* now read the flags */
1127 if (dwrq->flags & IW_ENCODE_DISABLED) {
1128 /* Encoding disabled,
1129 * authen = DOT11_AUTH_OS;
1131 * exunencrypt = 0; */
1133 if (dwrq->flags & IW_ENCODE_OPEN)
1134 /* Encode but accept non-encoded packets. No auth */
1136 if ((dwrq->flags & IW_ENCODE_RESTRICTED) || force) {
1137 /* Refuse non-encoded packets. Auth */
1138 authen = DOT11_AUTH_BOTH;
1142 /* do the change if requested */
1143 if ((dwrq->flags & IW_ENCODE_MODE) || force) {
1145 mgt_set_request(priv, DOT11_OID_AUTHENABLE, 0, &authen);
1147 mgt_set_request(priv, DOT11_OID_PRIVACYINVOKED, 0, &invoke);
1149 mgt_set_request(priv, DOT11_OID_EXUNENCRYPTED, 0,
1156 prism54_get_encode(struct net_device *ndev, struct iw_request_info *info,
1157 struct iw_point *dwrq, char *extra)
1159 islpci_private *priv = netdev_priv(ndev);
1160 struct obj_key *key;
1161 u32 devindex, index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
1162 u32 authen = 0, invoke = 0, exunencrypt = 0;
1166 /* first get the flags */
1167 rvalue = mgt_get_request(priv, DOT11_OID_AUTHENABLE, 0, NULL, &r);
1169 rvalue |= mgt_get_request(priv, DOT11_OID_PRIVACYINVOKED, 0, NULL, &r);
1171 rvalue |= mgt_get_request(priv, DOT11_OID_EXUNENCRYPTED, 0, NULL, &r);
1174 if (invoke && (authen == DOT11_AUTH_BOTH) && exunencrypt)
1175 dwrq->flags = IW_ENCODE_RESTRICTED;
1176 else if ((authen == DOT11_AUTH_OS) && !exunencrypt) {
1178 dwrq->flags = IW_ENCODE_OPEN;
1180 dwrq->flags = IW_ENCODE_DISABLED;
1182 /* The card should not work in this state */
1185 /* get the current device key index */
1186 rvalue |= mgt_get_request(priv, DOT11_OID_DEFKEYID, 0, NULL, &r);
1188 /* Now get the key, return it */
1189 if ((index < 0) || (index > 3))
1190 /* no index provided, use the current one */
1192 rvalue |= mgt_get_request(priv, DOT11_OID_DEFKEYX, index, NULL, &r);
1194 dwrq->length = key->length;
1195 memcpy(extra, key->key, dwrq->length);
1197 /* return the used key index */
1198 dwrq->flags |= devindex + 1;
1204 prism54_get_txpower(struct net_device *ndev, struct iw_request_info *info,
1205 struct iw_param *vwrq, char *extra)
1207 islpci_private *priv = netdev_priv(ndev);
1211 rvalue = mgt_get_request(priv, OID_INL_OUTPUTPOWER, 0, NULL, &r);
1212 /* intersil firmware operates in 0.25 dBm (1/4 dBm) */
1213 vwrq->value = (s32) r.u / 4;
1215 /* radio is not turned of
1216 * btw: how is possible to turn off only the radio
1224 prism54_set_txpower(struct net_device *ndev, struct iw_request_info *info,
1225 struct iw_param *vwrq, char *extra)
1227 islpci_private *priv = netdev_priv(ndev);
1228 s32 u = vwrq->value;
1230 /* intersil firmware operates in 0.25 dBm (1/4) */
1232 if (vwrq->disabled) {
1233 /* don't know how to disable radio */
1235 "%s: %s() disabling radio is not yet supported.\n",
1236 priv->ndev->name, __FUNCTION__);
1238 } else if (vwrq->fixed)
1239 /* currently only fixed value is supported */
1240 return mgt_set_request(priv, OID_INL_OUTPUTPOWER, 0, &u);
1243 "%s: %s() auto power will be implemented later.\n",
1244 priv->ndev->name, __FUNCTION__);
1249 static int prism54_set_genie(struct net_device *ndev,
1250 struct iw_request_info *info,
1251 struct iw_point *data, char *extra)
1253 islpci_private *priv = netdev_priv(ndev);
1255 struct obj_attachment *attach;
1257 if (data->length > MAX_WPA_IE_LEN ||
1258 (data->length && extra == NULL))
1261 memcpy(priv->wpa_ie, extra, data->length);
1262 priv->wpa_ie_len = data->length;
1264 alen = sizeof(*attach) + priv->wpa_ie_len;
1265 attach = kzalloc(alen, GFP_KERNEL);
1269 #define WLAN_FC_TYPE_MGMT 0
1270 #define WLAN_FC_STYPE_ASSOC_REQ 0
1271 #define WLAN_FC_STYPE_REASSOC_REQ 2
1273 /* Note: endianness is covered by mgt_set_varlen */
1274 attach->type = (WLAN_FC_TYPE_MGMT << 2) |
1275 (WLAN_FC_STYPE_ASSOC_REQ << 4);
1277 attach->size = priv->wpa_ie_len;
1278 memcpy(attach->data, extra, priv->wpa_ie_len);
1280 ret = mgt_set_varlen(priv, DOT11_OID_ATTACHMENT, attach,
1283 attach->type = (WLAN_FC_TYPE_MGMT << 2) |
1284 (WLAN_FC_STYPE_REASSOC_REQ << 4);
1286 ret = mgt_set_varlen(priv, DOT11_OID_ATTACHMENT, attach,
1289 printk(KERN_DEBUG "%s: WPA IE Attachment was set\n",
1298 static int prism54_get_genie(struct net_device *ndev,
1299 struct iw_request_info *info,
1300 struct iw_point *data, char *extra)
1302 islpci_private *priv = netdev_priv(ndev);
1303 int len = priv->wpa_ie_len;
1310 if (data->length < len)
1314 memcpy(extra, priv->wpa_ie, len);
1319 static int prism54_set_auth(struct net_device *ndev,
1320 struct iw_request_info *info,
1321 union iwreq_data *wrqu, char *extra)
1323 islpci_private *priv = netdev_priv(ndev);
1324 struct iw_param *param = &wrqu->param;
1325 u32 mlmelevel = 0, authen = 0, dot1x = 0;
1326 u32 exunencrypt = 0, privinvoked = 0, wpa = 0;
1331 if (islpci_get_state(priv) < PRV_STATE_INIT)
1334 /* first get the flags */
1335 down_write(&priv->mib_sem);
1336 wpa = old_wpa = priv->wpa;
1337 up_write(&priv->mib_sem);
1338 ret = mgt_get_request(priv, DOT11_OID_AUTHENABLE, 0, NULL, &r);
1340 ret = mgt_get_request(priv, DOT11_OID_PRIVACYINVOKED, 0, NULL, &r);
1342 ret = mgt_get_request(priv, DOT11_OID_EXUNENCRYPTED, 0, NULL, &r);
1344 ret = mgt_get_request(priv, DOT11_OID_DOT1XENABLE, 0, NULL, &r);
1346 ret = mgt_get_request(priv, DOT11_OID_MLMEAUTOLEVEL, 0, NULL, &r);
1352 switch (param->flags & IW_AUTH_INDEX) {
1353 case IW_AUTH_CIPHER_PAIRWISE:
1354 case IW_AUTH_CIPHER_GROUP:
1355 case IW_AUTH_KEY_MGMT:
1358 case IW_AUTH_WPA_ENABLED:
1359 /* Do the same thing as IW_AUTH_WPA_VERSION */
1362 privinvoked = 1; /* For privacy invoked */
1363 exunencrypt = 1; /* Filter out all unencrypted frames */
1364 dot1x = 0x01; /* To enable eap filter */
1365 mlmelevel = DOT11_MLME_EXTENDED;
1366 authen = DOT11_AUTH_OS; /* Only WEP uses _SK and _BOTH */
1370 exunencrypt = 0; /* Do not filter un-encrypted data */
1372 mlmelevel = DOT11_MLME_AUTO;
1376 case IW_AUTH_WPA_VERSION:
1377 if (param->value & IW_AUTH_WPA_VERSION_DISABLED) {
1380 exunencrypt = 0; /* Do not filter un-encrypted data */
1382 mlmelevel = DOT11_MLME_AUTO;
1384 if (param->value & IW_AUTH_WPA_VERSION_WPA)
1386 else if (param->value & IW_AUTH_WPA_VERSION_WPA2)
1388 privinvoked = 1; /* For privacy invoked */
1389 exunencrypt = 1; /* Filter out all unencrypted frames */
1390 dot1x = 0x01; /* To enable eap filter */
1391 mlmelevel = DOT11_MLME_EXTENDED;
1392 authen = DOT11_AUTH_OS; /* Only WEP uses _SK and _BOTH */
1396 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
1397 dot1x = param->value ? 1 : 0;
1400 case IW_AUTH_PRIVACY_INVOKED:
1401 privinvoked = param->value ? 1 : 0;
1403 case IW_AUTH_DROP_UNENCRYPTED:
1404 exunencrypt = param->value ? 1 : 0;
1407 case IW_AUTH_80211_AUTH_ALG:
1408 if (param->value & IW_AUTH_ALG_SHARED_KEY) {
1409 /* Only WEP uses _SK and _BOTH */
1414 authen = DOT11_AUTH_SK;
1415 } else if (param->value & IW_AUTH_ALG_OPEN_SYSTEM) {
1416 authen = DOT11_AUTH_OS;
1427 /* Set all the values */
1428 down_write(&priv->mib_sem);
1430 up_write(&priv->mib_sem);
1431 mgt_set_request(priv, DOT11_OID_AUTHENABLE, 0, &authen);
1432 mgt_set_request(priv, DOT11_OID_PRIVACYINVOKED, 0, &privinvoked);
1433 mgt_set_request(priv, DOT11_OID_EXUNENCRYPTED, 0, &exunencrypt);
1434 mgt_set_request(priv, DOT11_OID_DOT1XENABLE, 0, &dot1x);
1435 mgt_set_request(priv, DOT11_OID_MLMEAUTOLEVEL, 0, &mlmelevel);
1441 static int prism54_get_auth(struct net_device *ndev,
1442 struct iw_request_info *info,
1443 union iwreq_data *wrqu, char *extra)
1445 islpci_private *priv = netdev_priv(ndev);
1446 struct iw_param *param = &wrqu->param;
1451 if (islpci_get_state(priv) < PRV_STATE_INIT)
1454 /* first get the flags */
1455 down_write(&priv->mib_sem);
1457 up_write(&priv->mib_sem);
1459 switch (param->flags & IW_AUTH_INDEX) {
1460 case IW_AUTH_CIPHER_PAIRWISE:
1461 case IW_AUTH_CIPHER_GROUP:
1462 case IW_AUTH_KEY_MGMT:
1464 * wpa_supplicant will control these internally
1469 case IW_AUTH_WPA_VERSION:
1472 param->value = IW_AUTH_WPA_VERSION_WPA;
1475 param->value = IW_AUTH_WPA_VERSION_WPA2;
1479 param->value = IW_AUTH_WPA_VERSION_DISABLED;
1484 case IW_AUTH_DROP_UNENCRYPTED:
1485 ret = mgt_get_request(priv, DOT11_OID_EXUNENCRYPTED, 0, NULL, &r);
1487 param->value = r.u > 0 ? 1 : 0;
1490 case IW_AUTH_80211_AUTH_ALG:
1491 ret = mgt_get_request(priv, DOT11_OID_AUTHENABLE, 0, NULL, &r);
1495 param->value = IW_AUTH_ALG_OPEN_SYSTEM;
1497 case DOT11_AUTH_BOTH:
1499 param->value = IW_AUTH_ALG_SHARED_KEY;
1500 case DOT11_AUTH_NONE:
1508 case IW_AUTH_WPA_ENABLED:
1509 param->value = wpa > 0 ? 1 : 0;
1512 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
1513 ret = mgt_get_request(priv, DOT11_OID_DOT1XENABLE, 0, NULL, &r);
1515 param->value = r.u > 0 ? 1 : 0;
1518 case IW_AUTH_PRIVACY_INVOKED:
1519 ret = mgt_get_request(priv, DOT11_OID_PRIVACYINVOKED, 0, NULL, &r);
1521 param->value = r.u > 0 ? 1 : 0;
1530 static int prism54_set_encodeext(struct net_device *ndev,
1531 struct iw_request_info *info,
1532 union iwreq_data *wrqu,
1535 islpci_private *priv = netdev_priv(ndev);
1536 struct iw_point *encoding = &wrqu->encoding;
1537 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
1538 int idx, alg = ext->alg, set_key = 1;
1540 int authen = DOT11_AUTH_OS, invoke = 0, exunencrypt = 0;
1543 if (islpci_get_state(priv) < PRV_STATE_INIT)
1546 /* Determine and validate the key index */
1547 idx = (encoding->flags & IW_ENCODE_INDEX) - 1;
1549 if (idx < 0 || idx > 3)
1552 ret = mgt_get_request(priv, DOT11_OID_DEFKEYID, 0, NULL, &r);
1558 if (encoding->flags & IW_ENCODE_DISABLED)
1559 alg = IW_ENCODE_ALG_NONE;
1561 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
1562 /* Only set transmit key index here, actual
1563 * key is set below if needed.
1565 ret = mgt_set_request(priv, DOT11_OID_DEFKEYID, 0, &idx);
1566 set_key = ext->key_len > 0 ? 1 : 0;
1570 struct obj_key key = { DOT11_PRIV_WEP, 0, "" };
1572 case IW_ENCODE_ALG_NONE:
1574 case IW_ENCODE_ALG_WEP:
1575 if (ext->key_len > KEY_SIZE_WEP104) {
1579 if (ext->key_len > KEY_SIZE_WEP40)
1580 key.length = KEY_SIZE_WEP104;
1582 key.length = KEY_SIZE_WEP40;
1584 case IW_ENCODE_ALG_TKIP:
1585 if (ext->key_len > KEY_SIZE_TKIP) {
1589 key.type = DOT11_PRIV_TKIP;
1590 key.length = KEY_SIZE_TKIP;
1596 memset(key.key, 0, sizeof(key.key));
1597 memcpy(key.key, ext->key, ext->key_len);
1598 ret = mgt_set_request(priv, DOT11_OID_DEFKEYX, idx,
1605 /* Read the flags */
1606 if (encoding->flags & IW_ENCODE_DISABLED) {
1607 /* Encoding disabled,
1608 * authen = DOT11_AUTH_OS;
1610 * exunencrypt = 0; */
1612 if (encoding->flags & IW_ENCODE_OPEN) {
1613 /* Encode but accept non-encoded packets. No auth */
1616 if (encoding->flags & IW_ENCODE_RESTRICTED) {
1617 /* Refuse non-encoded packets. Auth */
1618 authen = DOT11_AUTH_BOTH;
1623 /* do the change if requested */
1624 if (encoding->flags & IW_ENCODE_MODE) {
1625 ret = mgt_set_request(priv, DOT11_OID_AUTHENABLE, 0,
1627 ret = mgt_set_request(priv, DOT11_OID_PRIVACYINVOKED, 0,
1629 ret = mgt_set_request(priv, DOT11_OID_EXUNENCRYPTED, 0,
1638 static int prism54_get_encodeext(struct net_device *ndev,
1639 struct iw_request_info *info,
1640 union iwreq_data *wrqu,
1643 islpci_private *priv = netdev_priv(ndev);
1644 struct iw_point *encoding = &wrqu->encoding;
1645 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
1646 int idx, max_key_len;
1648 int authen = DOT11_AUTH_OS, invoke = 0, exunencrypt = 0, wpa = 0;
1651 if (islpci_get_state(priv) < PRV_STATE_INIT)
1654 /* first get the flags */
1655 ret = mgt_get_request(priv, DOT11_OID_AUTHENABLE, 0, NULL, &r);
1657 ret = mgt_get_request(priv, DOT11_OID_PRIVACYINVOKED, 0, NULL, &r);
1659 ret = mgt_get_request(priv, DOT11_OID_EXUNENCRYPTED, 0, NULL, &r);
1664 max_key_len = encoding->length - sizeof(*ext);
1665 if (max_key_len < 0)
1668 idx = (encoding->flags & IW_ENCODE_INDEX) - 1;
1670 if (idx < 0 || idx > 3)
1673 ret = mgt_get_request(priv, DOT11_OID_DEFKEYID, 0, NULL, &r);
1679 encoding->flags = idx + 1;
1680 memset(ext, 0, sizeof(*ext));
1683 case DOT11_AUTH_BOTH:
1685 wrqu->encoding.flags |= IW_ENCODE_RESTRICTED;
1688 wrqu->encoding.flags |= IW_ENCODE_OPEN;
1692 down_write(&priv->mib_sem);
1694 up_write(&priv->mib_sem);
1696 if (authen == DOT11_AUTH_OS && !exunencrypt && !invoke && !wpa) {
1698 ext->alg = IW_ENCODE_ALG_NONE;
1700 wrqu->encoding.flags |= IW_ENCODE_DISABLED;
1702 struct obj_key *key;
1704 ret = mgt_get_request(priv, DOT11_OID_DEFKEYX, idx, NULL, &r);
1708 if (max_key_len < key->length) {
1712 memcpy(ext->key, key->key, key->length);
1713 ext->key_len = key->length;
1715 switch (key->type) {
1716 case DOT11_PRIV_TKIP:
1717 ext->alg = IW_ENCODE_ALG_TKIP;
1720 case DOT11_PRIV_WEP:
1721 ext->alg = IW_ENCODE_ALG_WEP;
1724 wrqu->encoding.flags |= IW_ENCODE_ENABLED;
1733 prism54_reset(struct net_device *ndev, struct iw_request_info *info,
1734 __u32 * uwrq, char *extra)
1736 islpci_reset(netdev_priv(ndev), 0);
1742 prism54_get_oid(struct net_device *ndev, struct iw_request_info *info,
1743 struct iw_point *dwrq, char *extra)
1747 enum oid_num_t n = dwrq->flags;
1749 rvalue = mgt_get_request((islpci_private *) ndev->priv, n, 0, NULL, &r);
1750 dwrq->length = mgt_response_to_str(n, &r, extra);
1751 if ((isl_oid[n].flags & OID_FLAG_TYPE) != OID_TYPE_U32)
1757 prism54_set_u32(struct net_device *ndev, struct iw_request_info *info,
1758 __u32 * uwrq, char *extra)
1760 u32 oid = uwrq[0], u = uwrq[1];
1762 return mgt_set_request((islpci_private *) ndev->priv, oid, 0, &u);
1766 prism54_set_raw(struct net_device *ndev, struct iw_request_info *info,
1767 struct iw_point *dwrq, char *extra)
1769 u32 oid = dwrq->flags;
1771 return mgt_set_request((islpci_private *) ndev->priv, oid, 0, extra);
1775 prism54_acl_init(struct islpci_acl *acl)
1777 sema_init(&acl->sem, 1);
1778 INIT_LIST_HEAD(&acl->mac_list);
1780 acl->policy = MAC_POLICY_OPEN;
1784 prism54_clear_mac(struct islpci_acl *acl)
1786 struct list_head *ptr, *next;
1787 struct mac_entry *entry;
1789 if (down_interruptible(&acl->sem))
1792 if (acl->size == 0) {
1797 for (ptr = acl->mac_list.next, next = ptr->next;
1798 ptr != &acl->mac_list; ptr = next, next = ptr->next) {
1799 entry = list_entry(ptr, struct mac_entry, _list);
1808 prism54_acl_clean(struct islpci_acl *acl)
1810 prism54_clear_mac(acl);
1814 prism54_add_mac(struct net_device *ndev, struct iw_request_info *info,
1815 struct sockaddr *awrq, char *extra)
1817 islpci_private *priv = netdev_priv(ndev);
1818 struct islpci_acl *acl = &priv->acl;
1819 struct mac_entry *entry;
1820 struct sockaddr *addr = (struct sockaddr *) extra;
1822 if (addr->sa_family != ARPHRD_ETHER)
1825 entry = kmalloc(sizeof (struct mac_entry), GFP_KERNEL);
1829 memcpy(entry->addr, addr->sa_data, ETH_ALEN);
1831 if (down_interruptible(&acl->sem)) {
1833 return -ERESTARTSYS;
1835 list_add_tail(&entry->_list, &acl->mac_list);
1843 prism54_del_mac(struct net_device *ndev, struct iw_request_info *info,
1844 struct sockaddr *awrq, char *extra)
1846 islpci_private *priv = netdev_priv(ndev);
1847 struct islpci_acl *acl = &priv->acl;
1848 struct mac_entry *entry;
1849 struct list_head *ptr;
1850 struct sockaddr *addr = (struct sockaddr *) extra;
1852 if (addr->sa_family != ARPHRD_ETHER)
1855 if (down_interruptible(&acl->sem))
1856 return -ERESTARTSYS;
1857 for (ptr = acl->mac_list.next; ptr != &acl->mac_list; ptr = ptr->next) {
1858 entry = list_entry(ptr, struct mac_entry, _list);
1860 if (memcmp(entry->addr, addr->sa_data, ETH_ALEN) == 0) {
1873 prism54_get_mac(struct net_device *ndev, struct iw_request_info *info,
1874 struct iw_point *dwrq, char *extra)
1876 islpci_private *priv = netdev_priv(ndev);
1877 struct islpci_acl *acl = &priv->acl;
1878 struct mac_entry *entry;
1879 struct list_head *ptr;
1880 struct sockaddr *dst = (struct sockaddr *) extra;
1884 if (down_interruptible(&acl->sem))
1885 return -ERESTARTSYS;
1887 for (ptr = acl->mac_list.next; ptr != &acl->mac_list; ptr = ptr->next) {
1888 entry = list_entry(ptr, struct mac_entry, _list);
1890 memcpy(dst->sa_data, entry->addr, ETH_ALEN);
1891 dst->sa_family = ARPHRD_ETHER;
1899 /* Setting policy also clears the MAC acl, even if we don't change the defaut
1904 prism54_set_policy(struct net_device *ndev, struct iw_request_info *info,
1905 __u32 * uwrq, char *extra)
1907 islpci_private *priv = netdev_priv(ndev);
1908 struct islpci_acl *acl = &priv->acl;
1911 prism54_clear_mac(acl);
1913 if ((*uwrq < MAC_POLICY_OPEN) || (*uwrq > MAC_POLICY_REJECT))
1916 down_write(&priv->mib_sem);
1918 acl->policy = *uwrq;
1920 /* the ACL code needs an intermediate mlmeautolevel */
1921 if ((priv->iw_mode == IW_MODE_MASTER) &&
1922 (acl->policy != MAC_POLICY_OPEN))
1923 mlmeautolevel = DOT11_MLME_INTERMEDIATE;
1925 mlmeautolevel = CARD_DEFAULT_MLME_MODE;
1927 mlmeautolevel = DOT11_MLME_EXTENDED;
1928 mgt_set(priv, DOT11_OID_MLMEAUTOLEVEL, &mlmeautolevel);
1929 /* restart the card with our new policy */
1930 if (mgt_commit(priv)) {
1931 up_write(&priv->mib_sem);
1934 up_write(&priv->mib_sem);
1940 prism54_get_policy(struct net_device *ndev, struct iw_request_info *info,
1941 __u32 * uwrq, char *extra)
1943 islpci_private *priv = netdev_priv(ndev);
1944 struct islpci_acl *acl = &priv->acl;
1946 *uwrq = acl->policy;
1951 /* Return 1 only if client should be accepted. */
1954 prism54_mac_accept(struct islpci_acl *acl, char *mac)
1956 struct list_head *ptr;
1957 struct mac_entry *entry;
1960 if (down_interruptible(&acl->sem))
1961 return -ERESTARTSYS;
1963 if (acl->policy == MAC_POLICY_OPEN) {
1968 for (ptr = acl->mac_list.next; ptr != &acl->mac_list; ptr = ptr->next) {
1969 entry = list_entry(ptr, struct mac_entry, _list);
1970 if (memcmp(entry->addr, mac, ETH_ALEN) == 0) {
1975 res = (acl->policy == MAC_POLICY_ACCEPT) ? !res : res;
1982 prism54_kick_all(struct net_device *ndev, struct iw_request_info *info,
1983 struct iw_point *dwrq, char *extra)
1985 struct obj_mlme *mlme;
1988 mlme = kmalloc(sizeof (struct obj_mlme), GFP_KERNEL);
1992 /* Tell the card to kick every client */
1995 mgt_set_request(netdev_priv(ndev), DOT11_OID_DISASSOCIATE, 0, mlme);
2002 prism54_kick_mac(struct net_device *ndev, struct iw_request_info *info,
2003 struct sockaddr *awrq, char *extra)
2005 struct obj_mlme *mlme;
2006 struct sockaddr *addr = (struct sockaddr *) extra;
2009 if (addr->sa_family != ARPHRD_ETHER)
2012 mlme = kmalloc(sizeof (struct obj_mlme), GFP_KERNEL);
2016 /* Tell the card to only kick the corresponding bastard */
2017 memcpy(mlme->address, addr->sa_data, ETH_ALEN);
2020 mgt_set_request(netdev_priv(ndev), DOT11_OID_DISASSOCIATE, 0, mlme);
2027 /* Translate a TRAP oid into a wireless event. Called in islpci_mgt_receive. */
2030 format_event(islpci_private *priv, char *dest, const char *str,
2031 const struct obj_mlme *mlme, u16 *length, int error)
2033 const u8 *a = mlme->address;
2034 int n = snprintf(dest, IW_CUSTOM_MAX,
2035 "%s %s %2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X %s (%2.2X)",
2037 ((priv->iw_mode == IW_MODE_MASTER) ? "from" : "to"),
2038 a[0], a[1], a[2], a[3], a[4], a[5],
2039 (error ? (mlme->code ? " : REJECTED " : " : ACCEPTED ")
2041 BUG_ON(n > IW_CUSTOM_MAX);
2046 send_formatted_event(islpci_private *priv, const char *str,
2047 const struct obj_mlme *mlme, int error)
2049 union iwreq_data wrqu;
2052 memptr = kmalloc(IW_CUSTOM_MAX, GFP_KERNEL);
2055 wrqu.data.pointer = memptr;
2056 wrqu.data.length = 0;
2057 format_event(priv, memptr, str, mlme, &wrqu.data.length,
2059 wireless_send_event(priv->ndev, IWEVCUSTOM, &wrqu, memptr);
2064 send_simple_event(islpci_private *priv, const char *str)
2066 union iwreq_data wrqu;
2068 int n = strlen(str);
2070 memptr = kmalloc(IW_CUSTOM_MAX, GFP_KERNEL);
2073 BUG_ON(n > IW_CUSTOM_MAX);
2074 wrqu.data.pointer = memptr;
2075 wrqu.data.length = n;
2076 strcpy(memptr, str);
2077 wireless_send_event(priv->ndev, IWEVCUSTOM, &wrqu, memptr);
2082 link_changed(struct net_device *ndev, u32 bitrate)
2084 islpci_private *priv = netdev_priv(ndev);
2087 if (priv->iw_mode == IW_MODE_INFRA) {
2088 union iwreq_data uwrq;
2089 prism54_get_wap(ndev, NULL, (struct sockaddr *) &uwrq,
2091 wireless_send_event(ndev, SIOCGIWAP, &uwrq, NULL);
2093 send_simple_event(netdev_priv(ndev),
2094 "Link established");
2096 send_simple_event(netdev_priv(ndev), "Link lost");
2099 /* Beacon/ProbeResp payload header */
2100 struct ieee80211_beacon_phdr {
2104 } __attribute__ ((packed));
2106 #define WLAN_EID_GENERIC 0xdd
2107 static u8 wpa_oid[4] = { 0x00, 0x50, 0xf2, 1 };
2109 #define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
2110 #define MACSTR "%02x:%02x:%02x:%02x:%02x:%02x"
2113 prism54_wpa_bss_ie_add(islpci_private *priv, u8 *bssid,
2114 u8 *wpa_ie, size_t wpa_ie_len)
2116 struct list_head *ptr;
2117 struct islpci_bss_wpa_ie *bss = NULL;
2119 if (wpa_ie_len > MAX_WPA_IE_LEN)
2120 wpa_ie_len = MAX_WPA_IE_LEN;
2122 if (down_interruptible(&priv->wpa_sem))
2125 /* try to use existing entry */
2126 list_for_each(ptr, &priv->bss_wpa_list) {
2127 bss = list_entry(ptr, struct islpci_bss_wpa_ie, list);
2128 if (memcmp(bss->bssid, bssid, ETH_ALEN) == 0) {
2129 list_move(&bss->list, &priv->bss_wpa_list);
2136 /* add a new BSS entry; if max number of entries is already
2137 * reached, replace the least recently updated */
2138 if (priv->num_bss_wpa >= MAX_BSS_WPA_IE_COUNT) {
2139 bss = list_entry(priv->bss_wpa_list.prev,
2140 struct islpci_bss_wpa_ie, list);
2141 list_del(&bss->list);
2143 bss = kmalloc(sizeof (*bss), GFP_ATOMIC);
2145 priv->num_bss_wpa++;
2146 memset(bss, 0, sizeof (*bss));
2150 memcpy(bss->bssid, bssid, ETH_ALEN);
2151 list_add(&bss->list, &priv->bss_wpa_list);
2156 memcpy(bss->wpa_ie, wpa_ie, wpa_ie_len);
2157 bss->wpa_ie_len = wpa_ie_len;
2158 bss->last_update = jiffies;
2160 printk(KERN_DEBUG "Failed to add BSS WPA entry for " MACSTR
2161 "\n", MAC2STR(bssid));
2164 /* expire old entries from WPA list */
2165 while (priv->num_bss_wpa > 0) {
2166 bss = list_entry(priv->bss_wpa_list.prev,
2167 struct islpci_bss_wpa_ie, list);
2168 if (!time_after(jiffies, bss->last_update + 60 * HZ))
2171 list_del(&bss->list);
2172 priv->num_bss_wpa--;
2180 prism54_wpa_bss_ie_get(islpci_private *priv, u8 *bssid, u8 *wpa_ie)
2182 struct list_head *ptr;
2183 struct islpci_bss_wpa_ie *bss = NULL;
2186 if (down_interruptible(&priv->wpa_sem))
2189 list_for_each(ptr, &priv->bss_wpa_list) {
2190 bss = list_entry(ptr, struct islpci_bss_wpa_ie, list);
2191 if (memcmp(bss->bssid, bssid, ETH_ALEN) == 0)
2196 len = bss->wpa_ie_len;
2197 memcpy(wpa_ie, bss->wpa_ie, len);
2205 prism54_wpa_bss_ie_init(islpci_private *priv)
2207 INIT_LIST_HEAD(&priv->bss_wpa_list);
2208 sema_init(&priv->wpa_sem, 1);
2212 prism54_wpa_bss_ie_clean(islpci_private *priv)
2214 struct list_head *ptr, *n;
2216 list_for_each_safe(ptr, n, &priv->bss_wpa_list) {
2217 struct islpci_bss_wpa_ie *bss;
2218 bss = list_entry(ptr, struct islpci_bss_wpa_ie, list);
2224 prism54_process_bss_data(islpci_private *priv, u32 oid, u8 *addr,
2225 u8 *payload, size_t len)
2227 struct ieee80211_beacon_phdr *hdr;
2233 hdr = (struct ieee80211_beacon_phdr *) payload;
2234 pos = (u8 *) (hdr + 1);
2235 end = payload + len;
2237 if (pos + 2 + pos[1] > end) {
2238 printk(KERN_DEBUG "Parsing Beacon/ProbeResp failed "
2239 "for " MACSTR "\n", MAC2STR(addr));
2242 if (pos[0] == WLAN_EID_GENERIC && pos[1] >= 4 &&
2243 memcmp(pos + 2, wpa_oid, 4) == 0) {
2244 prism54_wpa_bss_ie_add(priv, addr, pos, pos[1] + 2);
2252 handle_request(islpci_private *priv, struct obj_mlme *mlme, enum oid_num_t oid)
2254 if (((mlme->state == DOT11_STATE_AUTHING) ||
2255 (mlme->state == DOT11_STATE_ASSOCING))
2256 && mgt_mlme_answer(priv)) {
2257 /* Someone is requesting auth and we must respond. Just send back
2258 * the trap with error code set accordingly.
2260 mlme->code = prism54_mac_accept(&priv->acl,
2261 mlme->address) ? 0 : 1;
2262 mgt_set_request(priv, oid, 0, mlme);
2267 prism54_process_trap_helper(islpci_private *priv, enum oid_num_t oid,
2270 struct obj_mlme *mlme = (struct obj_mlme *) data;
2271 struct obj_mlmeex *mlmeex = (struct obj_mlmeex *) data;
2272 struct obj_mlmeex *confirm;
2273 u8 wpa_ie[MAX_WPA_IE_LEN];
2275 size_t len = 0; /* u16, better? */
2276 u8 *payload = NULL, *pos = NULL;
2279 /* I think all trapable objects are listed here.
2280 * Some oids have a EX version. The difference is that they are emitted
2281 * in DOT11_MLME_EXTENDED mode (set with DOT11_OID_MLMEAUTOLEVEL)
2283 * The few events already defined by the wireless tools are not really
2284 * suited. We use the more flexible custom event facility.
2287 if (oid >= DOT11_OID_BEACON) {
2289 payload = pos = mlmeex->data;
2292 /* I fear prism54_process_bss_data won't work with big endian data */
2293 if ((oid == DOT11_OID_BEACON) || (oid == DOT11_OID_PROBE))
2294 prism54_process_bss_data(priv, oid, mlmeex->address,
2297 mgt_le_to_cpu(isl_oid[oid].flags & OID_FLAG_TYPE, (void *) mlme);
2301 case GEN_OID_LINKSTATE:
2302 link_changed(priv->ndev, (u32) *data);
2305 case DOT11_OID_MICFAILURE:
2306 send_simple_event(priv, "Mic failure");
2309 case DOT11_OID_DEAUTHENTICATE:
2310 send_formatted_event(priv, "DeAuthenticate request", mlme, 0);
2313 case DOT11_OID_AUTHENTICATE:
2314 handle_request(priv, mlme, oid);
2315 send_formatted_event(priv, "Authenticate request", mlme, 1);
2318 case DOT11_OID_DISASSOCIATE:
2319 send_formatted_event(priv, "Disassociate request", mlme, 0);
2322 case DOT11_OID_ASSOCIATE:
2323 handle_request(priv, mlme, oid);
2324 send_formatted_event(priv, "Associate request", mlme, 1);
2327 case DOT11_OID_REASSOCIATE:
2328 handle_request(priv, mlme, oid);
2329 send_formatted_event(priv, "ReAssociate request", mlme, 1);
2332 case DOT11_OID_BEACON:
2333 send_formatted_event(priv,
2334 "Received a beacon from an unkown AP",
2338 case DOT11_OID_PROBE:
2339 /* we received a probe from a client. */
2340 send_formatted_event(priv, "Received a probe from client", mlme,
2344 /* Note : "mlme" is actually a "struct obj_mlmeex *" here, but this
2345 * is backward compatible layout-wise with "struct obj_mlme".
2348 case DOT11_OID_DEAUTHENTICATEEX:
2349 send_formatted_event(priv, "DeAuthenticate request", mlme, 0);
2352 case DOT11_OID_AUTHENTICATEEX:
2353 handle_request(priv, mlme, oid);
2354 send_formatted_event(priv, "Authenticate request (ex)", mlme, 1);
2356 if (priv->iw_mode != IW_MODE_MASTER
2357 && mlmeex->state != DOT11_STATE_AUTHING)
2360 confirm = kmalloc(sizeof(struct obj_mlmeex) + 6, GFP_ATOMIC);
2365 memcpy(&confirm->address, mlmeex->address, ETH_ALEN);
2366 printk(KERN_DEBUG "Authenticate from: address:\t%02x:%02x:%02x:%02x:%02x:%02x\n",
2374 confirm->id = -1; /* or mlmeex->id ? */
2375 confirm->state = 0; /* not used */
2378 confirm->data[0] = 0x00;
2379 confirm->data[1] = 0x00;
2380 confirm->data[2] = 0x02;
2381 confirm->data[3] = 0x00;
2382 confirm->data[4] = 0x00;
2383 confirm->data[5] = 0x00;
2385 ret = mgt_set_varlen(priv, DOT11_OID_ASSOCIATEEX, confirm, 6);
2392 case DOT11_OID_DISASSOCIATEEX:
2393 send_formatted_event(priv, "Disassociate request (ex)", mlme, 0);
2396 case DOT11_OID_ASSOCIATEEX:
2397 handle_request(priv, mlme, oid);
2398 send_formatted_event(priv, "Associate request (ex)", mlme, 1);
2400 if (priv->iw_mode != IW_MODE_MASTER
2401 && mlmeex->state != DOT11_STATE_ASSOCING)
2404 confirm = kmalloc(sizeof(struct obj_mlmeex), GFP_ATOMIC);
2409 memcpy(&confirm->address, mlmeex->address, ETH_ALEN);
2411 confirm->id = ((struct obj_mlmeex *)mlme)->id;
2412 confirm->state = 0; /* not used */
2415 wpa_ie_len = prism54_wpa_bss_ie_get(priv, mlmeex->address, wpa_ie);
2418 printk(KERN_DEBUG "No WPA IE found from "
2419 "address:\t%02x:%02x:%02x:%02x:%02x:%02x\n",
2431 confirm->size = wpa_ie_len;
2432 memcpy(&confirm->data, wpa_ie, wpa_ie_len);
2434 mgt_set_varlen(priv, oid, confirm, wpa_ie_len);
2440 case DOT11_OID_REASSOCIATEEX:
2441 handle_request(priv, mlme, oid);
2442 send_formatted_event(priv, "Reassociate request (ex)", mlme, 1);
2444 if (priv->iw_mode != IW_MODE_MASTER
2445 && mlmeex->state != DOT11_STATE_ASSOCING)
2448 confirm = kmalloc(sizeof(struct obj_mlmeex), GFP_ATOMIC);
2453 memcpy(&confirm->address, mlmeex->address, ETH_ALEN);
2455 confirm->id = mlmeex->id;
2456 confirm->state = 0; /* not used */
2459 wpa_ie_len = prism54_wpa_bss_ie_get(priv, mlmeex->address, wpa_ie);
2462 printk(KERN_DEBUG "No WPA IE found from "
2463 "address:\t%02x:%02x:%02x:%02x:%02x:%02x\n",
2475 confirm->size = wpa_ie_len;
2476 memcpy(&confirm->data, wpa_ie, wpa_ie_len);
2478 mgt_set_varlen(priv, oid, confirm, wpa_ie_len);
2492 * Process a device trap. This is called via schedule_work(), outside of
2493 * interrupt context, no locks held.
2496 prism54_process_trap(void *data)
2498 struct islpci_mgmtframe *frame = data;
2499 struct net_device *ndev = frame->ndev;
2500 enum oid_num_t n = mgt_oidtonum(frame->header->oid);
2502 if (n != OID_NUM_LAST)
2503 prism54_process_trap_helper(netdev_priv(ndev), n, frame->data);
2504 islpci_mgt_release(frame);
2508 prism54_set_mac_address(struct net_device *ndev, void *addr)
2510 islpci_private *priv = netdev_priv(ndev);
2513 if (ndev->addr_len != 6)
2515 ret = mgt_set_request(priv, GEN_OID_MACADDRESS, 0,
2516 &((struct sockaddr *) addr)->sa_data);
2518 memcpy(priv->ndev->dev_addr,
2519 &((struct sockaddr *) addr)->sa_data, 6);
2524 /* Note: currently, use hostapd ioctl from the Host AP driver for WPA
2525 * support. This is to be replaced with Linux wireless extensions once they
2526 * get WPA support. */
2528 /* Note II: please leave all this together as it will be easier to remove later,
2529 * once wireless extensions add WPA support -mcgrof */
2531 /* PRISM54_HOSTAPD ioctl() cmd: */
2533 PRISM2_SET_ENCRYPTION = 6,
2534 PRISM2_HOSTAPD_SET_GENERIC_ELEMENT = 12,
2535 PRISM2_HOSTAPD_MLME = 13,
2536 PRISM2_HOSTAPD_SCAN_REQ = 14,
2539 #define PRISM54_SET_WPA SIOCIWFIRSTPRIV+12
2540 #define PRISM54_HOSTAPD SIOCIWFIRSTPRIV+25
2541 #define PRISM54_DROP_UNENCRYPTED SIOCIWFIRSTPRIV+26
2543 #define PRISM2_HOSTAPD_MAX_BUF_SIZE 1024
2544 #define PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN \
2545 ((int) (&((struct prism2_hostapd_param *) 0)->u.generic_elem.data))
2547 /* Maximum length for algorithm names (-1 for nul termination)
2548 * used in ioctl() */
2549 #define HOSTAP_CRYPT_ALG_NAME_LEN 16
2551 struct prism2_hostapd_param {
2553 u8 sta_addr[ETH_ALEN];
2556 u8 alg[HOSTAP_CRYPT_ALG_NAME_LEN];
2560 u8 seq[8]; /* sequence counter (set: RX, get: TX) */
2569 #define MLME_STA_DEAUTH 0
2570 #define MLME_STA_DISASSOC 1
2583 prism2_ioctl_set_encryption(struct net_device *dev,
2584 struct prism2_hostapd_param *param,
2587 islpci_private *priv = netdev_priv(dev);
2588 int rvalue = 0, force = 0;
2589 int authen = DOT11_AUTH_OS, invoke = 0, exunencrypt = 0;
2592 /* with the new API, it's impossible to get a NULL pointer.
2593 * New version of iwconfig set the IW_ENCODE_NOKEY flag
2594 * when no key is given, but older versions don't. */
2596 if (param->u.crypt.key_len > 0) {
2597 /* we have a key to set */
2598 int index = param->u.crypt.idx;
2600 struct obj_key key = { DOT11_PRIV_TKIP, 0, "" };
2602 /* get the current key index */
2603 rvalue = mgt_get_request(priv, DOT11_OID_DEFKEYID, 0, NULL, &r);
2604 current_index = r.u;
2605 /* Verify that the key is not marked as invalid */
2606 if (!(param->u.crypt.flags & IW_ENCODE_NOKEY)) {
2607 key.length = param->u.crypt.key_len > sizeof (param->u.crypt.key) ?
2608 sizeof (param->u.crypt.key) : param->u.crypt.key_len;
2609 memcpy(key.key, param->u.crypt.key, key.length);
2610 if (key.length == 32)
2611 /* we want WPA-PSK */
2612 key.type = DOT11_PRIV_TKIP;
2613 if ((index < 0) || (index > 3))
2614 /* no index provided use the current one */
2615 index = current_index;
2617 /* now send the key to the card */
2619 mgt_set_request(priv, DOT11_OID_DEFKEYX, index,
2623 * If a valid key is set, encryption should be enabled
2624 * (user may turn it off later).
2625 * This is also how "iwconfig ethX key on" works
2627 if ((index == current_index) && (key.length > 0))
2630 int index = (param->u.crypt.flags & IW_ENCODE_INDEX) - 1;
2631 if ((index >= 0) && (index <= 3)) {
2632 /* we want to set the key index */
2634 mgt_set_request(priv, DOT11_OID_DEFKEYID, 0,
2637 if (!param->u.crypt.flags & IW_ENCODE_MODE) {
2638 /* we cannot do anything. Complain. */
2643 /* now read the flags */
2644 if (param->u.crypt.flags & IW_ENCODE_DISABLED) {
2645 /* Encoding disabled,
2646 * authen = DOT11_AUTH_OS;
2648 * exunencrypt = 0; */
2650 if (param->u.crypt.flags & IW_ENCODE_OPEN)
2651 /* Encode but accept non-encoded packets. No auth */
2653 if ((param->u.crypt.flags & IW_ENCODE_RESTRICTED) || force) {
2654 /* Refuse non-encoded packets. Auth */
2655 authen = DOT11_AUTH_BOTH;
2659 /* do the change if requested */
2660 if ((param->u.crypt.flags & IW_ENCODE_MODE) || force) {
2662 mgt_set_request(priv, DOT11_OID_AUTHENABLE, 0, &authen);
2664 mgt_set_request(priv, DOT11_OID_PRIVACYINVOKED, 0, &invoke);
2666 mgt_set_request(priv, DOT11_OID_EXUNENCRYPTED, 0,
2673 prism2_ioctl_set_generic_element(struct net_device *ndev,
2674 struct prism2_hostapd_param *param,
2677 islpci_private *priv = netdev_priv(ndev);
2678 int max_len, len, alen, ret=0;
2679 struct obj_attachment *attach;
2681 len = param->u.generic_elem.len;
2682 max_len = param_len - PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN;
2683 if (max_len < 0 || max_len < len)
2686 alen = sizeof(*attach) + len;
2687 attach = kmalloc(alen, GFP_KERNEL);
2691 memset(attach, 0, alen);
2692 #define WLAN_FC_TYPE_MGMT 0
2693 #define WLAN_FC_STYPE_ASSOC_REQ 0
2694 #define WLAN_FC_STYPE_REASSOC_REQ 2
2696 /* Note: endianness is covered by mgt_set_varlen */
2698 attach->type = (WLAN_FC_TYPE_MGMT << 2) |
2699 (WLAN_FC_STYPE_ASSOC_REQ << 4);
2702 memcpy(attach->data, param->u.generic_elem.data, len);
2704 ret = mgt_set_varlen(priv, DOT11_OID_ATTACHMENT, attach, len);
2707 attach->type = (WLAN_FC_TYPE_MGMT << 2) |
2708 (WLAN_FC_STYPE_REASSOC_REQ << 4);
2710 ret = mgt_set_varlen(priv, DOT11_OID_ATTACHMENT, attach, len);
2713 printk(KERN_DEBUG "%s: WPA IE Attachment was set\n",
2723 prism2_ioctl_mlme(struct net_device *dev, struct prism2_hostapd_param *param)
2729 prism2_ioctl_scan_req(struct net_device *ndev,
2730 struct prism2_hostapd_param *param)
2732 islpci_private *priv = netdev_priv(ndev);
2734 struct obj_bsslist *bsslist;
2737 char *current_ev = "foo";
2740 if (islpci_get_state(priv) < PRV_STATE_INIT) {
2741 /* device is not ready, fail gently */
2745 /* first get the noise value. We will use it to report the link quality */
2746 rvalue = mgt_get_request(priv, DOT11_OID_NOISEFLOOR, 0, NULL, &r);
2749 /* Ask the device for a list of known bss. We can report at most
2750 * IW_MAX_AP=64 to the range struct. But the device won't repport anything
2751 * if you change the value of IWMAX_BSS=24.
2753 rvalue |= mgt_get_request(priv, DOT11_OID_BSSLIST, 0, NULL, &r);
2756 /* ok now, scan the list and translate its info */
2757 for (i = 0; i < min(IW_MAX_AP, (int) bsslist->nr); i++)
2758 current_ev = prism54_translate_bss(ndev, current_ev,
2759 extra + IW_SCAN_MAX_DATA,
2760 &(bsslist->bsslist[i]),
2768 prism54_hostapd(struct net_device *ndev, struct iw_point *p)
2770 struct prism2_hostapd_param *param;
2774 printk(KERN_DEBUG "prism54_hostapd - len=%d\n", p->length);
2775 if (p->length < sizeof(struct prism2_hostapd_param) ||
2776 p->length > PRISM2_HOSTAPD_MAX_BUF_SIZE || !p->pointer)
2779 param = (struct prism2_hostapd_param *) kmalloc(p->length, GFP_KERNEL);
2783 if (copy_from_user(param, p->pointer, p->length)) {
2788 switch (param->cmd) {
2789 case PRISM2_SET_ENCRYPTION:
2790 printk(KERN_DEBUG "%s: Caught WPA supplicant set encryption request\n",
2792 ret = prism2_ioctl_set_encryption(ndev, param, p->length);
2794 case PRISM2_HOSTAPD_SET_GENERIC_ELEMENT:
2795 printk(KERN_DEBUG "%s: Caught WPA supplicant set WPA IE request\n",
2797 ret = prism2_ioctl_set_generic_element(ndev, param,
2800 case PRISM2_HOSTAPD_MLME:
2801 printk(KERN_DEBUG "%s: Caught WPA supplicant MLME request\n",
2803 ret = prism2_ioctl_mlme(ndev, param);
2805 case PRISM2_HOSTAPD_SCAN_REQ:
2806 printk(KERN_DEBUG "%s: Caught WPA supplicant scan request\n",
2808 ret = prism2_ioctl_scan_req(ndev, param);
2810 case PRISM54_SET_WPA:
2811 printk(KERN_DEBUG "%s: Caught WPA supplicant wpa init request\n",
2814 ret = prism54_set_wpa(ndev, NULL, &uwrq, NULL);
2816 case PRISM54_DROP_UNENCRYPTED:
2817 printk(KERN_DEBUG "%s: Caught WPA drop unencrypted request\n",
2821 mgt_set(priv, DOT11_OID_EXUNENCRYPTED, &uwrq);
2822 down_write(&priv->mib_sem);
2824 up_write(&priv->mib_sem);
2826 /* Not necessary, as set_wpa does it, should we just do it here though? */
2830 printk(KERN_DEBUG "%s: Caught a WPA supplicant request that is not supported\n",
2836 if (ret == 0 && copy_to_user(p->pointer, param, p->length))
2845 prism54_set_wpa(struct net_device *ndev, struct iw_request_info *info,
2846 __u32 * uwrq, char *extra)
2848 islpci_private *priv = netdev_priv(ndev);
2849 u32 mlme, authen, dot1x, filter, wep;
2851 if (islpci_get_state(priv) < PRV_STATE_INIT)
2854 wep = 1; /* For privacy invoked */
2855 filter = 1; /* Filter out all unencrypted frames */
2856 dot1x = 0x01; /* To enable eap filter */
2857 mlme = DOT11_MLME_EXTENDED;
2858 authen = DOT11_AUTH_OS; /* Only WEP uses _SK and _BOTH */
2860 down_write(&priv->mib_sem);
2863 switch (priv->wpa) {
2865 case 0: /* Clears/disables WPA and friends */
2867 filter = 0; /* Do not filter un-encrypted data */
2869 mlme = DOT11_MLME_AUTO;
2870 printk("%s: Disabling WPA\n", ndev->name);
2874 printk("%s: Enabling WPA\n", ndev->name);
2877 up_write(&priv->mib_sem);
2879 mgt_set_request(priv, DOT11_OID_AUTHENABLE, 0, &authen);
2880 mgt_set_request(priv, DOT11_OID_PRIVACYINVOKED, 0, &wep);
2881 mgt_set_request(priv, DOT11_OID_EXUNENCRYPTED, 0, &filter);
2882 mgt_set_request(priv, DOT11_OID_DOT1XENABLE, 0, &dot1x);
2883 mgt_set_request(priv, DOT11_OID_MLMEAUTOLEVEL, 0, &mlme);
2889 prism54_get_wpa(struct net_device *ndev, struct iw_request_info *info,
2890 __u32 * uwrq, char *extra)
2892 islpci_private *priv = netdev_priv(ndev);
2898 prism54_set_prismhdr(struct net_device *ndev, struct iw_request_info *info,
2899 __u32 * uwrq, char *extra)
2901 islpci_private *priv = netdev_priv(ndev);
2902 priv->monitor_type =
2903 (*uwrq ? ARPHRD_IEEE80211_PRISM : ARPHRD_IEEE80211);
2904 if (priv->iw_mode == IW_MODE_MONITOR)
2905 priv->ndev->type = priv->monitor_type;
2911 prism54_get_prismhdr(struct net_device *ndev, struct iw_request_info *info,
2912 __u32 * uwrq, char *extra)
2914 islpci_private *priv = netdev_priv(ndev);
2915 *uwrq = (priv->monitor_type == ARPHRD_IEEE80211_PRISM);
2920 prism54_debug_oid(struct net_device *ndev, struct iw_request_info *info,
2921 __u32 * uwrq, char *extra)
2923 islpci_private *priv = netdev_priv(ndev);
2925 priv->priv_oid = *uwrq;
2926 printk("%s: oid 0x%08X\n", ndev->name, *uwrq);
2932 prism54_debug_get_oid(struct net_device *ndev, struct iw_request_info *info,
2933 struct iw_point *data, char *extra)
2935 islpci_private *priv = netdev_priv(ndev);
2936 struct islpci_mgmtframe *response;
2939 printk("%s: get_oid 0x%08X\n", ndev->name, priv->priv_oid);
2942 if (islpci_get_state(priv) >= PRV_STATE_INIT) {
2944 islpci_mgt_transaction(priv->ndev, PIMFOR_OP_GET,
2945 priv->priv_oid, extra, 256,
2947 printk("%s: ret: %i\n", ndev->name, ret);
2948 if (ret || !response
2949 || response->header->operation == PIMFOR_OP_ERROR) {
2951 islpci_mgt_release(response);
2953 printk("%s: EIO\n", ndev->name);
2957 data->length = response->header->length;
2958 memcpy(extra, response->data, data->length);
2959 islpci_mgt_release(response);
2960 printk("%s: len: %i\n", ndev->name, data->length);
2968 prism54_debug_set_oid(struct net_device *ndev, struct iw_request_info *info,
2969 struct iw_point *data, char *extra)
2971 islpci_private *priv = netdev_priv(ndev);
2972 struct islpci_mgmtframe *response;
2973 int ret = 0, response_op = PIMFOR_OP_ERROR;
2975 printk("%s: set_oid 0x%08X\tlen: %d\n", ndev->name, priv->priv_oid,
2978 if (islpci_get_state(priv) >= PRV_STATE_INIT) {
2980 islpci_mgt_transaction(priv->ndev, PIMFOR_OP_SET,
2981 priv->priv_oid, extra, data->length,
2983 printk("%s: ret: %i\n", ndev->name, ret);
2984 if (ret || !response
2985 || response->header->operation == PIMFOR_OP_ERROR) {
2987 islpci_mgt_release(response);
2989 printk("%s: EIO\n", ndev->name);
2993 response_op = response->header->operation;
2994 printk("%s: response_op: %i\n", ndev->name,
2996 islpci_mgt_release(response);
3000 return (ret ? ret : -EINPROGRESS);
3004 prism54_set_spy(struct net_device *ndev,
3005 struct iw_request_info *info,
3006 union iwreq_data *uwrq, char *extra)
3008 islpci_private *priv = netdev_priv(ndev);
3009 u32 u, oid = OID_INL_CONFIG;
3011 down_write(&priv->mib_sem);
3012 mgt_get(priv, OID_INL_CONFIG, &u);
3014 if ((uwrq->data.length == 0) && (priv->spy_data.spy_number > 0))
3016 u &= ~INL_CONFIG_RXANNEX;
3017 else if ((uwrq->data.length > 0) && (priv->spy_data.spy_number == 0))
3019 u |= INL_CONFIG_RXANNEX;
3021 mgt_set(priv, OID_INL_CONFIG, &u);
3022 mgt_commit_list(priv, &oid, 1);
3023 up_write(&priv->mib_sem);
3025 return iw_handler_set_spy(ndev, info, uwrq, extra);
3028 static const iw_handler prism54_handler[] = {
3029 (iw_handler) prism54_commit, /* SIOCSIWCOMMIT */
3030 (iw_handler) prism54_get_name, /* SIOCGIWNAME */
3031 (iw_handler) NULL, /* SIOCSIWNWID */
3032 (iw_handler) NULL, /* SIOCGIWNWID */
3033 (iw_handler) prism54_set_freq, /* SIOCSIWFREQ */
3034 (iw_handler) prism54_get_freq, /* SIOCGIWFREQ */
3035 (iw_handler) prism54_set_mode, /* SIOCSIWMODE */
3036 (iw_handler) prism54_get_mode, /* SIOCGIWMODE */
3037 (iw_handler) prism54_set_sens, /* SIOCSIWSENS */
3038 (iw_handler) prism54_get_sens, /* SIOCGIWSENS */
3039 (iw_handler) NULL, /* SIOCSIWRANGE */
3040 (iw_handler) prism54_get_range, /* SIOCGIWRANGE */
3041 (iw_handler) NULL, /* SIOCSIWPRIV */
3042 (iw_handler) NULL, /* SIOCGIWPRIV */
3043 (iw_handler) NULL, /* SIOCSIWSTATS */
3044 (iw_handler) NULL, /* SIOCGIWSTATS */
3045 prism54_set_spy, /* SIOCSIWSPY */
3046 iw_handler_get_spy, /* SIOCGIWSPY */
3047 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
3048 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
3049 (iw_handler) prism54_set_wap, /* SIOCSIWAP */
3050 (iw_handler) prism54_get_wap, /* SIOCGIWAP */
3051 (iw_handler) NULL, /* -- hole -- */
3052 (iw_handler) NULL, /* SIOCGIWAPLIST depreciated */
3053 (iw_handler) prism54_set_scan, /* SIOCSIWSCAN */
3054 (iw_handler) prism54_get_scan, /* SIOCGIWSCAN */
3055 (iw_handler) prism54_set_essid, /* SIOCSIWESSID */
3056 (iw_handler) prism54_get_essid, /* SIOCGIWESSID */
3057 (iw_handler) prism54_set_nick, /* SIOCSIWNICKN */
3058 (iw_handler) prism54_get_nick, /* SIOCGIWNICKN */
3059 (iw_handler) NULL, /* -- hole -- */
3060 (iw_handler) NULL, /* -- hole -- */
3061 (iw_handler) prism54_set_rate, /* SIOCSIWRATE */
3062 (iw_handler) prism54_get_rate, /* SIOCGIWRATE */
3063 (iw_handler) prism54_set_rts, /* SIOCSIWRTS */
3064 (iw_handler) prism54_get_rts, /* SIOCGIWRTS */
3065 (iw_handler) prism54_set_frag, /* SIOCSIWFRAG */
3066 (iw_handler) prism54_get_frag, /* SIOCGIWFRAG */
3067 (iw_handler) prism54_set_txpower, /* SIOCSIWTXPOW */
3068 (iw_handler) prism54_get_txpower, /* SIOCGIWTXPOW */
3069 (iw_handler) prism54_set_retry, /* SIOCSIWRETRY */
3070 (iw_handler) prism54_get_retry, /* SIOCGIWRETRY */
3071 (iw_handler) prism54_set_encode, /* SIOCSIWENCODE */
3072 (iw_handler) prism54_get_encode, /* SIOCGIWENCODE */
3073 (iw_handler) NULL, /* SIOCSIWPOWER */
3074 (iw_handler) NULL, /* SIOCGIWPOWER */
3075 NULL, /* -- hole -- */
3076 NULL, /* -- hole -- */
3077 (iw_handler) prism54_set_genie, /* SIOCSIWGENIE */
3078 (iw_handler) prism54_get_genie, /* SIOCGIWGENIE */
3079 (iw_handler) prism54_set_auth, /* SIOCSIWAUTH */
3080 (iw_handler) prism54_get_auth, /* SIOCGIWAUTH */
3081 (iw_handler) prism54_set_encodeext, /* SIOCSIWENCODEEXT */
3082 (iw_handler) prism54_get_encodeext, /* SIOCGIWENCODEEXT */
3083 NULL, /* SIOCSIWPMKSA */
3086 /* The low order bit identify a SET (0) or a GET (1) ioctl. */
3088 #define PRISM54_RESET SIOCIWFIRSTPRIV
3089 #define PRISM54_GET_POLICY SIOCIWFIRSTPRIV+1
3090 #define PRISM54_SET_POLICY SIOCIWFIRSTPRIV+2
3091 #define PRISM54_GET_MAC SIOCIWFIRSTPRIV+3
3092 #define PRISM54_ADD_MAC SIOCIWFIRSTPRIV+4
3094 #define PRISM54_DEL_MAC SIOCIWFIRSTPRIV+6
3096 #define PRISM54_KICK_MAC SIOCIWFIRSTPRIV+8
3098 #define PRISM54_KICK_ALL SIOCIWFIRSTPRIV+10
3100 #define PRISM54_GET_WPA SIOCIWFIRSTPRIV+11
3101 #define PRISM54_SET_WPA SIOCIWFIRSTPRIV+12
3103 #define PRISM54_DBG_OID SIOCIWFIRSTPRIV+14
3104 #define PRISM54_DBG_GET_OID SIOCIWFIRSTPRIV+15
3105 #define PRISM54_DBG_SET_OID SIOCIWFIRSTPRIV+16
3107 #define PRISM54_GET_OID SIOCIWFIRSTPRIV+17
3108 #define PRISM54_SET_OID_U32 SIOCIWFIRSTPRIV+18
3109 #define PRISM54_SET_OID_STR SIOCIWFIRSTPRIV+20
3110 #define PRISM54_SET_OID_ADDR SIOCIWFIRSTPRIV+22
3112 #define PRISM54_GET_PRISMHDR SIOCIWFIRSTPRIV+23
3113 #define PRISM54_SET_PRISMHDR SIOCIWFIRSTPRIV+24
3115 #define IWPRIV_SET_U32(n,x) { n, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "s_"x }
3116 #define IWPRIV_SET_SSID(n,x) { n, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 1, 0, "s_"x }
3117 #define IWPRIV_SET_ADDR(n,x) { n, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "s_"x }
3118 #define IWPRIV_GET(n,x) { n, 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | PRIV_STR_SIZE, "g_"x }
3120 #define IWPRIV_U32(n,x) IWPRIV_SET_U32(n,x), IWPRIV_GET(n,x)
3121 #define IWPRIV_SSID(n,x) IWPRIV_SET_SSID(n,x), IWPRIV_GET(n,x)
3122 #define IWPRIV_ADDR(n,x) IWPRIV_SET_ADDR(n,x), IWPRIV_GET(n,x)
3124 /* Note : limited to 128 private ioctls (wireless tools 26) */
3126 static const struct iw_priv_args prism54_private_args[] = {
3127 /*{ cmd, set_args, get_args, name } */
3128 {PRISM54_RESET, 0, 0, "reset"},
3129 {PRISM54_GET_PRISMHDR, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
3131 {PRISM54_SET_PRISMHDR, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
3133 {PRISM54_GET_POLICY, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
3135 {PRISM54_SET_POLICY, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
3137 {PRISM54_GET_MAC, 0, IW_PRIV_TYPE_ADDR | 64, "getMac"},
3138 {PRISM54_ADD_MAC, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0,
3140 {PRISM54_DEL_MAC, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0,
3142 {PRISM54_KICK_MAC, IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0,
3144 {PRISM54_KICK_ALL, 0, 0, "kickAll"},
3145 {PRISM54_GET_WPA, 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
3147 {PRISM54_SET_WPA, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
3149 {PRISM54_DBG_OID, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0,
3151 {PRISM54_DBG_GET_OID, 0, IW_PRIV_TYPE_BYTE | 256, "dbg_get_oid"},
3152 {PRISM54_DBG_SET_OID, IW_PRIV_TYPE_BYTE | 256, 0, "dbg_set_oid"},
3153 /* --- sub-ioctls handlers --- */
3155 0, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | PRIV_STR_SIZE, ""},
3156 {PRISM54_SET_OID_U32,
3157 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, ""},
3158 {PRISM54_SET_OID_STR,
3159 IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | 1, 0, ""},
3160 {PRISM54_SET_OID_ADDR,
3161 IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, ""},
3162 /* --- sub-ioctls definitions --- */
3163 IWPRIV_ADDR(GEN_OID_MACADDRESS, "addr"),
3164 IWPRIV_GET(GEN_OID_LINKSTATE, "linkstate"),
3165 IWPRIV_U32(DOT11_OID_BSSTYPE, "bsstype"),
3166 IWPRIV_ADDR(DOT11_OID_BSSID, "bssid"),
3167 IWPRIV_U32(DOT11_OID_STATE, "state"),
3168 IWPRIV_U32(DOT11_OID_AID, "aid"),
3170 IWPRIV_SSID(DOT11_OID_SSIDOVERRIDE, "ssidoverride"),
3172 IWPRIV_U32(DOT11_OID_MEDIUMLIMIT, "medlimit"),
3173 IWPRIV_U32(DOT11_OID_BEACONPERIOD, "beacon"),
3174 IWPRIV_U32(DOT11_OID_DTIMPERIOD, "dtimperiod"),
3176 IWPRIV_U32(DOT11_OID_AUTHENABLE, "authenable"),
3177 IWPRIV_U32(DOT11_OID_PRIVACYINVOKED, "privinvok"),
3178 IWPRIV_U32(DOT11_OID_EXUNENCRYPTED, "exunencrypt"),
3180 IWPRIV_U32(DOT11_OID_REKEYTHRESHOLD, "rekeythresh"),
3182 IWPRIV_U32(DOT11_OID_MAXTXLIFETIME, "maxtxlife"),
3183 IWPRIV_U32(DOT11_OID_MAXRXLIFETIME, "maxrxlife"),
3184 IWPRIV_U32(DOT11_OID_ALOFT_FIXEDRATE, "fixedrate"),
3185 IWPRIV_U32(DOT11_OID_MAXFRAMEBURST, "frameburst"),
3186 IWPRIV_U32(DOT11_OID_PSM, "psm"),
3188 IWPRIV_U32(DOT11_OID_BRIDGELOCAL, "bridge"),
3189 IWPRIV_U32(DOT11_OID_CLIENTS, "clients"),
3190 IWPRIV_U32(DOT11_OID_CLIENTSASSOCIATED, "clientassoc"),
3191 IWPRIV_U32(DOT11_OID_DOT1XENABLE, "dot1xenable"),
3192 IWPRIV_U32(DOT11_OID_ANTENNARX, "rxant"),
3193 IWPRIV_U32(DOT11_OID_ANTENNATX, "txant"),
3194 IWPRIV_U32(DOT11_OID_ANTENNADIVERSITY, "antdivers"),
3195 IWPRIV_U32(DOT11_OID_EDTHRESHOLD, "edthresh"),
3196 IWPRIV_U32(DOT11_OID_PREAMBLESETTINGS, "preamble"),
3197 IWPRIV_GET(DOT11_OID_RATES, "rates"),
3198 IWPRIV_U32(DOT11_OID_OUTPUTPOWER, ".11outpower"),
3199 IWPRIV_GET(DOT11_OID_SUPPORTEDRATES, "supprates"),
3200 IWPRIV_GET(DOT11_OID_SUPPORTEDFREQUENCIES, "suppfreq"),
3202 IWPRIV_U32(DOT11_OID_NOISEFLOOR, "noisefloor"),
3203 IWPRIV_GET(DOT11_OID_FREQUENCYACTIVITY, "freqactivity"),
3204 IWPRIV_U32(DOT11_OID_NONERPPROTECTION, "nonerpprotec"),
3205 IWPRIV_U32(DOT11_OID_PROFILES, "profile"),
3206 IWPRIV_GET(DOT11_OID_EXTENDEDRATES, "extrates"),
3207 IWPRIV_U32(DOT11_OID_MLMEAUTOLEVEL, "mlmelevel"),
3209 IWPRIV_GET(DOT11_OID_BSSS, "bsss"),
3210 IWPRIV_GET(DOT11_OID_BSSLIST, "bsslist"),
3211 IWPRIV_U32(OID_INL_MODE, "mode"),
3212 IWPRIV_U32(OID_INL_CONFIG, "config"),
3213 IWPRIV_U32(OID_INL_DOT11D_CONFORMANCE, ".11dconform"),
3214 IWPRIV_GET(OID_INL_PHYCAPABILITIES, "phycapa"),
3215 IWPRIV_U32(OID_INL_OUTPUTPOWER, "outpower"),
3218 static const iw_handler prism54_private_handler[] = {
3219 (iw_handler) prism54_reset,
3220 (iw_handler) prism54_get_policy,
3221 (iw_handler) prism54_set_policy,
3222 (iw_handler) prism54_get_mac,
3223 (iw_handler) prism54_add_mac,
3225 (iw_handler) prism54_del_mac,
3227 (iw_handler) prism54_kick_mac,
3229 (iw_handler) prism54_kick_all,
3230 (iw_handler) prism54_get_wpa,
3231 (iw_handler) prism54_set_wpa,
3233 (iw_handler) prism54_debug_oid,
3234 (iw_handler) prism54_debug_get_oid,
3235 (iw_handler) prism54_debug_set_oid,
3236 (iw_handler) prism54_get_oid,
3237 (iw_handler) prism54_set_u32,
3239 (iw_handler) prism54_set_raw,
3241 (iw_handler) prism54_set_raw,
3242 (iw_handler) prism54_get_prismhdr,
3243 (iw_handler) prism54_set_prismhdr,
3246 const struct iw_handler_def prism54_handler_def = {
3247 .num_standard = sizeof (prism54_handler) / sizeof (iw_handler),
3248 .num_private = sizeof (prism54_private_handler) / sizeof (iw_handler),
3250 sizeof (prism54_private_args) / sizeof (struct iw_priv_args),
3251 .standard = (iw_handler *) prism54_handler,
3252 .private = (iw_handler *) prism54_private_handler,
3253 .private_args = (struct iw_priv_args *) prism54_private_args,
3254 .get_wireless_stats = prism54_get_wireless_stats,
3257 /* For wpa_supplicant */
3260 prism54_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
3262 struct iwreq *wrq = (struct iwreq *) rq;
3265 case PRISM54_HOSTAPD:
3266 if (!capable(CAP_NET_ADMIN))
3268 ret = prism54_hostapd(ndev, &wrq->u.data);