1 /* ioctl() (mostly Linux Wireless Extensions) routines for Host AP driver */
3 #include <linux/types.h>
4 #include <linux/smp_lock.h>
5 #include <linux/ethtool.h>
6 #include <net/ieee80211_crypt.h>
8 #include "hostap_wlan.h"
10 #include "hostap_ap.h"
12 static struct iw_statistics *hostap_get_wireless_stats(struct net_device *dev)
14 struct hostap_interface *iface;
16 struct iw_statistics *wstats;
18 iface = netdev_priv(dev);
21 /* Why are we doing that ? Jean II */
22 if (iface->type != HOSTAP_INTERFACE_MAIN)
25 wstats = &local->wstats;
28 wstats->discard.code =
29 local->comm_tallies.rx_discards_wep_undecryptable;
30 wstats->discard.misc =
31 local->comm_tallies.rx_fcs_errors +
32 local->comm_tallies.rx_discards_no_buffer +
33 local->comm_tallies.tx_discards_wrong_sa;
35 wstats->discard.retries =
36 local->comm_tallies.tx_retry_limit_exceeded;
37 wstats->discard.fragment =
38 local->comm_tallies.rx_message_in_bad_msg_fragments;
40 if (local->iw_mode != IW_MODE_MASTER &&
41 local->iw_mode != IW_MODE_REPEAT) {
44 /* RID reading might sleep and it must not be called in
45 * interrupt context or while atomic. However, this
46 * function seems to be called while atomic (at least in Linux
47 * 2.5.59). Update signal quality values only if in suitable
48 * context. Otherwise, previous values read from tick timer
52 #endif /* in_atomic */
54 if (update && prism2_update_comms_qual(dev) == 0)
55 wstats->qual.updated = IW_QUAL_ALL_UPDATED |
58 wstats->qual.qual = local->comms_qual;
59 wstats->qual.level = local->avg_signal;
60 wstats->qual.noise = local->avg_noise;
62 wstats->qual.qual = 0;
63 wstats->qual.level = 0;
64 wstats->qual.noise = 0;
65 wstats->qual.updated = IW_QUAL_ALL_INVALID;
72 static int prism2_get_datarates(struct net_device *dev, u8 *rates)
74 struct hostap_interface *iface;
80 iface = netdev_priv(dev);
83 len = local->func->get_rid(dev, HFA384X_RID_SUPPORTEDDATARATES, buf,
88 val = le16_to_cpu(*(u16 *) buf); /* string length */
90 if (len - 2 < val || val > 10)
93 memcpy(rates, buf + 2, val);
98 static int prism2_get_name(struct net_device *dev,
99 struct iw_request_info *info,
100 char *name, char *extra)
103 int len, i, over2 = 0;
105 len = prism2_get_datarates(dev, rates);
107 for (i = 0; i < len; i++) {
108 if (rates[i] == 0x0b || rates[i] == 0x16) {
114 strcpy(name, over2 ? "IEEE 802.11b" : "IEEE 802.11-DS");
120 static void prism2_crypt_delayed_deinit(local_info_t *local,
121 struct ieee80211_crypt_data **crypt)
123 struct ieee80211_crypt_data *tmp;
132 /* must not run ops->deinit() while there may be pending encrypt or
133 * decrypt operations. Use a list of delayed deinits to avoid needing
136 spin_lock_irqsave(&local->lock, flags);
137 list_add(&tmp->list, &local->crypt_deinit_list);
138 if (!timer_pending(&local->crypt_deinit_timer)) {
139 local->crypt_deinit_timer.expires = jiffies + HZ;
140 add_timer(&local->crypt_deinit_timer);
142 spin_unlock_irqrestore(&local->lock, flags);
146 static int prism2_ioctl_siwencode(struct net_device *dev,
147 struct iw_request_info *info,
148 struct iw_point *erq, char *keybuf)
150 struct hostap_interface *iface;
153 struct ieee80211_crypt_data **crypt;
155 iface = netdev_priv(dev);
156 local = iface->local;
158 i = erq->flags & IW_ENCODE_INDEX;
160 i = local->tx_keyidx;
163 if (i < 0 || i >= WEP_KEYS)
166 crypt = &local->crypt[i];
168 if (erq->flags & IW_ENCODE_DISABLED) {
170 prism2_crypt_delayed_deinit(local, crypt);
174 if (*crypt != NULL && (*crypt)->ops != NULL &&
175 strcmp((*crypt)->ops->name, "WEP") != 0) {
176 /* changing to use WEP; deinit previously used algorithm */
177 prism2_crypt_delayed_deinit(local, crypt);
180 if (*crypt == NULL) {
181 struct ieee80211_crypt_data *new_crypt;
183 /* take WEP into use */
184 new_crypt = (struct ieee80211_crypt_data *)
185 kmalloc(sizeof(struct ieee80211_crypt_data),
187 if (new_crypt == NULL)
189 memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
190 new_crypt->ops = ieee80211_get_crypto_ops("WEP");
191 if (!new_crypt->ops) {
192 request_module("ieee80211_crypt_wep");
193 new_crypt->ops = ieee80211_get_crypto_ops("WEP");
196 new_crypt->priv = new_crypt->ops->init(i);
197 if (!new_crypt->ops || !new_crypt->priv) {
201 printk(KERN_WARNING "%s: could not initialize WEP: "
202 "load module hostap_crypt_wep.o\n",
209 if (erq->length > 0) {
210 int len = erq->length <= 5 ? 5 : 13;
212 if (len > erq->length)
213 memset(keybuf + erq->length, 0, len - erq->length);
214 (*crypt)->ops->set_key(keybuf, len, NULL, (*crypt)->priv);
215 for (j = 0; j < WEP_KEYS; j++) {
216 if (j != i && local->crypt[j]) {
222 local->tx_keyidx = i;
224 /* No key data - just set the default TX key index */
225 local->tx_keyidx = i;
229 local->open_wep = erq->flags & IW_ENCODE_OPEN;
231 if (hostap_set_encryption(local)) {
232 printk(KERN_DEBUG "%s: set_encryption failed\n", dev->name);
236 /* Do not reset port0 if card is in Managed mode since resetting will
237 * generate new IEEE 802.11 authentication which may end up in looping
238 * with IEEE 802.1X. Prism2 documentation seem to require port reset
239 * after WEP configuration. However, keys are apparently changed at
240 * least in Managed mode. */
241 if (local->iw_mode != IW_MODE_INFRA && local->func->reset_port(dev)) {
242 printk(KERN_DEBUG "%s: reset_port failed\n", dev->name);
250 static int prism2_ioctl_giwencode(struct net_device *dev,
251 struct iw_request_info *info,
252 struct iw_point *erq, char *key)
254 struct hostap_interface *iface;
258 struct ieee80211_crypt_data *crypt;
260 iface = netdev_priv(dev);
261 local = iface->local;
263 i = erq->flags & IW_ENCODE_INDEX;
265 i = local->tx_keyidx;
268 if (i < 0 || i >= WEP_KEYS)
271 crypt = local->crypt[i];
274 if (crypt == NULL || crypt->ops == NULL) {
276 erq->flags |= IW_ENCODE_DISABLED;
280 if (strcmp(crypt->ops->name, "WEP") != 0) {
281 /* only WEP is supported with wireless extensions, so just
282 * report that encryption is used */
284 erq->flags |= IW_ENCODE_ENABLED;
288 /* Reads from HFA384X_RID_CNFDEFAULTKEY* return bogus values, so show
289 * the keys from driver buffer */
290 len = crypt->ops->get_key(key, WEP_KEY_LEN, NULL, crypt->priv);
291 erq->length = (len >= 0 ? len : 0);
293 if (local->func->get_rid(dev, HFA384X_RID_CNFWEPFLAGS, &val, 2, 1) < 0)
295 printk("CNFWEPFLAGS reading failed\n");
299 if (val & HFA384X_WEPFLAGS_PRIVACYINVOKED)
300 erq->flags |= IW_ENCODE_ENABLED;
302 erq->flags |= IW_ENCODE_DISABLED;
303 if (val & HFA384X_WEPFLAGS_EXCLUDEUNENCRYPTED)
304 erq->flags |= IW_ENCODE_RESTRICTED;
306 erq->flags |= IW_ENCODE_OPEN;
312 static int hostap_set_rate(struct net_device *dev)
314 struct hostap_interface *iface;
316 int ret, basic_rates;
318 iface = netdev_priv(dev);
319 local = iface->local;
321 basic_rates = local->basic_rates & local->tx_rate_control;
322 if (!basic_rates || basic_rates != local->basic_rates) {
323 printk(KERN_INFO "%s: updating basic rate set automatically "
324 "to match with the new supported rate set\n",
327 basic_rates = local->tx_rate_control;
329 local->basic_rates = basic_rates;
330 if (hostap_set_word(dev, HFA384X_RID_CNFBASICRATES,
332 printk(KERN_WARNING "%s: failed to set "
333 "cnfBasicRates\n", dev->name);
336 ret = (hostap_set_word(dev, HFA384X_RID_TXRATECONTROL,
337 local->tx_rate_control) ||
338 hostap_set_word(dev, HFA384X_RID_CNFSUPPORTEDRATES,
339 local->tx_rate_control) ||
340 local->func->reset_port(dev));
343 printk(KERN_WARNING "%s: TXRateControl/cnfSupportedRates "
344 "setting to 0x%x failed\n",
345 dev->name, local->tx_rate_control);
348 /* Update TX rate configuration for all STAs based on new operational
350 hostap_update_rates(local);
356 static int prism2_ioctl_siwrate(struct net_device *dev,
357 struct iw_request_info *info,
358 struct iw_param *rrq, char *extra)
360 struct hostap_interface *iface;
363 iface = netdev_priv(dev);
364 local = iface->local;
367 switch (rrq->value) {
369 local->tx_rate_control = HFA384X_RATES_11MBPS;
372 local->tx_rate_control = HFA384X_RATES_5MBPS;
375 local->tx_rate_control = HFA384X_RATES_2MBPS;
378 local->tx_rate_control = HFA384X_RATES_1MBPS;
381 local->tx_rate_control = HFA384X_RATES_1MBPS |
382 HFA384X_RATES_2MBPS | HFA384X_RATES_5MBPS |
383 HFA384X_RATES_11MBPS;
387 switch (rrq->value) {
389 local->tx_rate_control = HFA384X_RATES_1MBPS |
390 HFA384X_RATES_2MBPS | HFA384X_RATES_5MBPS |
391 HFA384X_RATES_11MBPS;
394 local->tx_rate_control = HFA384X_RATES_1MBPS |
395 HFA384X_RATES_2MBPS | HFA384X_RATES_5MBPS;
398 local->tx_rate_control = HFA384X_RATES_1MBPS |
402 local->tx_rate_control = HFA384X_RATES_1MBPS;
405 local->tx_rate_control = HFA384X_RATES_1MBPS |
406 HFA384X_RATES_2MBPS | HFA384X_RATES_5MBPS |
407 HFA384X_RATES_11MBPS;
412 return hostap_set_rate(dev);
416 static int prism2_ioctl_giwrate(struct net_device *dev,
417 struct iw_request_info *info,
418 struct iw_param *rrq, char *extra)
421 struct hostap_interface *iface;
425 iface = netdev_priv(dev);
426 local = iface->local;
428 if (local->func->get_rid(dev, HFA384X_RID_TXRATECONTROL, &val, 2, 1) <
432 if ((val & 0x1) && (val > 1))
437 if (local->iw_mode == IW_MODE_MASTER && local->ap != NULL &&
438 !local->fw_tx_rate_control) {
439 /* HFA384X_RID_CURRENTTXRATE seems to always be 2 Mbps in
440 * Host AP mode, so use the recorded TX rate of the last sent
442 rrq->value = local->ap->last_tx_rate > 0 ?
443 local->ap->last_tx_rate * 100000 : 11000000;
447 if (local->func->get_rid(dev, HFA384X_RID_CURRENTTXRATE, &val, 2, 1) <
452 case HFA384X_RATES_1MBPS:
453 rrq->value = 1000000;
455 case HFA384X_RATES_2MBPS:
456 rrq->value = 2000000;
458 case HFA384X_RATES_5MBPS:
459 rrq->value = 5500000;
461 case HFA384X_RATES_11MBPS:
462 rrq->value = 11000000;
465 /* should not happen */
466 rrq->value = 11000000;
475 static int prism2_ioctl_siwsens(struct net_device *dev,
476 struct iw_request_info *info,
477 struct iw_param *sens, char *extra)
479 struct hostap_interface *iface;
482 iface = netdev_priv(dev);
483 local = iface->local;
485 /* Set the desired AP density */
486 if (sens->value < 1 || sens->value > 3)
489 if (hostap_set_word(dev, HFA384X_RID_CNFSYSTEMSCALE, sens->value) ||
490 local->func->reset_port(dev))
496 static int prism2_ioctl_giwsens(struct net_device *dev,
497 struct iw_request_info *info,
498 struct iw_param *sens, char *extra)
500 struct hostap_interface *iface;
504 iface = netdev_priv(dev);
505 local = iface->local;
507 /* Get the current AP density */
508 if (local->func->get_rid(dev, HFA384X_RID_CNFSYSTEMSCALE, &val, 2, 1) <
512 sens->value = __le16_to_cpu(val);
519 /* Deprecated in new wireless extension API */
520 static int prism2_ioctl_giwaplist(struct net_device *dev,
521 struct iw_request_info *info,
522 struct iw_point *data, char *extra)
524 struct hostap_interface *iface;
526 struct sockaddr *addr;
527 struct iw_quality *qual;
529 iface = netdev_priv(dev);
530 local = iface->local;
532 if (local->iw_mode != IW_MODE_MASTER) {
533 printk(KERN_DEBUG "SIOCGIWAPLIST is currently only supported "
534 "in Host AP mode\n");
539 addr = kmalloc(sizeof(struct sockaddr) * IW_MAX_AP, GFP_KERNEL);
540 qual = kmalloc(sizeof(struct iw_quality) * IW_MAX_AP, GFP_KERNEL);
541 if (addr == NULL || qual == NULL) {
548 data->length = prism2_ap_get_sta_qual(local, addr, qual, IW_MAX_AP, 1);
550 memcpy(extra, &addr, sizeof(struct sockaddr) * data->length);
551 data->flags = 1; /* has quality information */
552 memcpy(extra + sizeof(struct sockaddr) * data->length, &qual,
553 sizeof(struct iw_quality) * data->length);
561 static int prism2_ioctl_siwrts(struct net_device *dev,
562 struct iw_request_info *info,
563 struct iw_param *rts, char *extra)
565 struct hostap_interface *iface;
569 iface = netdev_priv(dev);
570 local = iface->local;
573 val = __constant_cpu_to_le16(2347);
574 else if (rts->value < 0 || rts->value > 2347)
577 val = __cpu_to_le16(rts->value);
579 if (local->func->set_rid(dev, HFA384X_RID_RTSTHRESHOLD, &val, 2) ||
580 local->func->reset_port(dev))
583 local->rts_threshold = rts->value;
588 static int prism2_ioctl_giwrts(struct net_device *dev,
589 struct iw_request_info *info,
590 struct iw_param *rts, char *extra)
592 struct hostap_interface *iface;
596 iface = netdev_priv(dev);
597 local = iface->local;
599 if (local->func->get_rid(dev, HFA384X_RID_RTSTHRESHOLD, &val, 2, 1) <
603 rts->value = __le16_to_cpu(val);
604 rts->disabled = (rts->value == 2347);
611 static int prism2_ioctl_siwfrag(struct net_device *dev,
612 struct iw_request_info *info,
613 struct iw_param *rts, char *extra)
615 struct hostap_interface *iface;
619 iface = netdev_priv(dev);
620 local = iface->local;
623 val = __constant_cpu_to_le16(2346);
624 else if (rts->value < 256 || rts->value > 2346)
627 val = __cpu_to_le16(rts->value & ~0x1); /* even numbers only */
629 local->fragm_threshold = rts->value & ~0x1;
630 if (local->func->set_rid(dev, HFA384X_RID_FRAGMENTATIONTHRESHOLD, &val,
632 || local->func->reset_port(dev))
638 static int prism2_ioctl_giwfrag(struct net_device *dev,
639 struct iw_request_info *info,
640 struct iw_param *rts, char *extra)
642 struct hostap_interface *iface;
646 iface = netdev_priv(dev);
647 local = iface->local;
649 if (local->func->get_rid(dev, HFA384X_RID_FRAGMENTATIONTHRESHOLD,
653 rts->value = __le16_to_cpu(val);
654 rts->disabled = (rts->value == 2346);
661 #ifndef PRISM2_NO_STATION_MODES
662 static int hostap_join_ap(struct net_device *dev)
664 struct hostap_interface *iface;
666 struct hfa384x_join_request req;
669 struct hfa384x_hostscan_result *entry;
671 iface = netdev_priv(dev);
672 local = iface->local;
674 memcpy(req.bssid, local->preferred_ap, ETH_ALEN);
677 spin_lock_irqsave(&local->lock, flags);
678 for (i = 0; i < local->last_scan_results_count; i++) {
679 if (!local->last_scan_results)
681 entry = &local->last_scan_results[i];
682 if (memcmp(local->preferred_ap, entry->bssid, ETH_ALEN) == 0) {
683 req.channel = entry->chid;
687 spin_unlock_irqrestore(&local->lock, flags);
689 if (local->func->set_rid(dev, HFA384X_RID_JOINREQUEST, &req,
691 printk(KERN_DEBUG "%s: JoinRequest " MACSTR
693 dev->name, MAC2STR(local->preferred_ap));
697 printk(KERN_DEBUG "%s: Trying to join BSSID " MACSTR "\n",
698 dev->name, MAC2STR(local->preferred_ap));
702 #endif /* PRISM2_NO_STATION_MODES */
705 static int prism2_ioctl_siwap(struct net_device *dev,
706 struct iw_request_info *info,
707 struct sockaddr *ap_addr, char *extra)
709 #ifdef PRISM2_NO_STATION_MODES
711 #else /* PRISM2_NO_STATION_MODES */
712 struct hostap_interface *iface;
715 iface = netdev_priv(dev);
716 local = iface->local;
718 memcpy(local->preferred_ap, &ap_addr->sa_data, ETH_ALEN);
720 if (local->host_roaming == 1 && local->iw_mode == IW_MODE_INFRA) {
721 struct hfa384x_scan_request scan_req;
722 memset(&scan_req, 0, sizeof(scan_req));
723 scan_req.channel_list = __constant_cpu_to_le16(0x3fff);
724 scan_req.txrate = __constant_cpu_to_le16(HFA384X_RATES_1MBPS);
725 if (local->func->set_rid(dev, HFA384X_RID_SCANREQUEST,
726 &scan_req, sizeof(scan_req))) {
727 printk(KERN_DEBUG "%s: ScanResults request failed - "
728 "preferred AP delayed to next unsolicited "
729 "scan\n", dev->name);
731 } else if (local->host_roaming == 2 &&
732 local->iw_mode == IW_MODE_INFRA) {
733 if (hostap_join_ap(dev))
736 printk(KERN_DEBUG "%s: Preferred AP (SIOCSIWAP) is used only "
737 "in Managed mode when host_roaming is enabled\n",
742 #endif /* PRISM2_NO_STATION_MODES */
745 static int prism2_ioctl_giwap(struct net_device *dev,
746 struct iw_request_info *info,
747 struct sockaddr *ap_addr, char *extra)
749 struct hostap_interface *iface;
752 iface = netdev_priv(dev);
753 local = iface->local;
755 ap_addr->sa_family = ARPHRD_ETHER;
756 switch (iface->type) {
757 case HOSTAP_INTERFACE_AP:
758 memcpy(&ap_addr->sa_data, dev->dev_addr, ETH_ALEN);
760 case HOSTAP_INTERFACE_STA:
761 memcpy(&ap_addr->sa_data, local->assoc_ap_addr, ETH_ALEN);
763 case HOSTAP_INTERFACE_WDS:
764 memcpy(&ap_addr->sa_data, iface->u.wds.remote_addr, ETH_ALEN);
767 if (local->func->get_rid(dev, HFA384X_RID_CURRENTBSSID,
768 &ap_addr->sa_data, ETH_ALEN, 1) < 0)
771 /* local->bssid is also updated in LinkStatus handler when in
773 memcpy(local->bssid, &ap_addr->sa_data, ETH_ALEN);
781 static int prism2_ioctl_siwnickn(struct net_device *dev,
782 struct iw_request_info *info,
783 struct iw_point *data, char *nickname)
785 struct hostap_interface *iface;
788 iface = netdev_priv(dev);
789 local = iface->local;
791 memset(local->name, 0, sizeof(local->name));
792 memcpy(local->name, nickname, data->length);
795 if (hostap_set_string(dev, HFA384X_RID_CNFOWNNAME, local->name) ||
796 local->func->reset_port(dev))
802 static int prism2_ioctl_giwnickn(struct net_device *dev,
803 struct iw_request_info *info,
804 struct iw_point *data, char *nickname)
806 struct hostap_interface *iface;
809 char name[MAX_NAME_LEN + 3];
812 iface = netdev_priv(dev);
813 local = iface->local;
815 len = local->func->get_rid(dev, HFA384X_RID_CNFOWNNAME,
816 &name, MAX_NAME_LEN + 2, 0);
817 val = __le16_to_cpu(*(u16 *) name);
818 if (len > MAX_NAME_LEN + 2 || len < 0 || val > MAX_NAME_LEN)
821 name[val + 2] = '\0';
822 data->length = val + 1;
823 memcpy(nickname, name + 2, val + 1);
829 static int prism2_ioctl_siwfreq(struct net_device *dev,
830 struct iw_request_info *info,
831 struct iw_freq *freq, char *extra)
833 struct hostap_interface *iface;
836 iface = netdev_priv(dev);
837 local = iface->local;
841 freq->m / 100000 >= freq_list[0] &&
842 freq->m / 100000 <= freq_list[FREQ_COUNT - 1]) {
844 int fr = freq->m / 100000;
845 for (ch = 0; ch < FREQ_COUNT; ch++) {
846 if (fr == freq_list[ch]) {
854 if (freq->e != 0 || freq->m < 1 || freq->m > FREQ_COUNT ||
855 !(local->channel_mask & (1 << (freq->m - 1))))
858 local->channel = freq->m; /* channel is used in prism2_setup_rids() */
859 if (hostap_set_word(dev, HFA384X_RID_CNFOWNCHANNEL, local->channel) ||
860 local->func->reset_port(dev))
866 static int prism2_ioctl_giwfreq(struct net_device *dev,
867 struct iw_request_info *info,
868 struct iw_freq *freq, char *extra)
870 struct hostap_interface *iface;
874 iface = netdev_priv(dev);
875 local = iface->local;
877 if (local->func->get_rid(dev, HFA384X_RID_CURRENTCHANNEL, &val, 2, 1) <
882 if (val < 1 || val > FREQ_COUNT)
885 freq->m = freq_list[val - 1] * 100000;
892 static void hostap_monitor_set_type(local_info_t *local)
894 struct net_device *dev = local->ddev;
899 if (local->monitor_type == PRISM2_MONITOR_PRISM ||
900 local->monitor_type == PRISM2_MONITOR_CAPHDR) {
901 dev->type = ARPHRD_IEEE80211_PRISM;
902 dev->hard_header_parse =
903 hostap_80211_prism_header_parse;
905 dev->type = ARPHRD_IEEE80211;
906 dev->hard_header_parse = hostap_80211_header_parse;
911 static int prism2_ioctl_siwessid(struct net_device *dev,
912 struct iw_request_info *info,
913 struct iw_point *data, char *ssid)
915 struct hostap_interface *iface;
918 iface = netdev_priv(dev);
919 local = iface->local;
921 if (iface->type == HOSTAP_INTERFACE_WDS)
924 if (data->flags == 0)
925 ssid[0] = '\0'; /* ANY */
927 if (local->iw_mode == IW_MODE_MASTER && ssid[0] == '\0') {
928 /* Setting SSID to empty string seems to kill the card in
930 printk(KERN_DEBUG "%s: Host AP mode does not support "
931 "'Any' essid\n", dev->name);
935 memcpy(local->essid, ssid, data->length);
936 local->essid[data->length] = '\0';
938 if ((!local->fw_ap &&
939 hostap_set_string(dev, HFA384X_RID_CNFDESIREDSSID, local->essid))
940 || hostap_set_string(dev, HFA384X_RID_CNFOWNSSID, local->essid) ||
941 local->func->reset_port(dev))
947 static int prism2_ioctl_giwessid(struct net_device *dev,
948 struct iw_request_info *info,
949 struct iw_point *data, char *essid)
951 struct hostap_interface *iface;
955 iface = netdev_priv(dev);
956 local = iface->local;
958 if (iface->type == HOSTAP_INTERFACE_WDS)
961 data->flags = 1; /* active */
962 if (local->iw_mode == IW_MODE_MASTER) {
963 data->length = strlen(local->essid);
964 memcpy(essid, local->essid, IW_ESSID_MAX_SIZE);
967 char ssid[MAX_SSID_LEN + 2];
968 memset(ssid, 0, sizeof(ssid));
969 len = local->func->get_rid(dev, HFA384X_RID_CURRENTSSID,
970 &ssid, MAX_SSID_LEN + 2, 0);
971 val = __le16_to_cpu(*(u16 *) ssid);
972 if (len > MAX_SSID_LEN + 2 || len < 0 || val > MAX_SSID_LEN) {
976 memcpy(essid, ssid + 2, IW_ESSID_MAX_SIZE);
983 static int prism2_ioctl_giwrange(struct net_device *dev,
984 struct iw_request_info *info,
985 struct iw_point *data, char *extra)
987 struct hostap_interface *iface;
989 struct iw_range *range = (struct iw_range *) extra;
994 iface = netdev_priv(dev);
995 local = iface->local;
997 data->length = sizeof(struct iw_range);
998 memset(range, 0, sizeof(struct iw_range));
1000 /* TODO: could fill num_txpower and txpower array with
1001 * something; however, there are 128 different values.. */
1003 range->txpower_capa = IW_TXPOW_DBM;
1005 if (local->iw_mode == IW_MODE_INFRA || local->iw_mode == IW_MODE_ADHOC)
1007 range->min_pmp = 1 * 1024;
1008 range->max_pmp = 65535 * 1024;
1009 range->min_pmt = 1 * 1024;
1010 range->max_pmt = 1000 * 1024;
1011 range->pmp_flags = IW_POWER_PERIOD;
1012 range->pmt_flags = IW_POWER_TIMEOUT;
1013 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |
1014 IW_POWER_UNICAST_R | IW_POWER_ALL_R;
1017 range->we_version_compiled = WIRELESS_EXT;
1018 range->we_version_source = 18;
1020 range->retry_capa = IW_RETRY_LIMIT;
1021 range->retry_flags = IW_RETRY_LIMIT;
1022 range->min_retry = 0;
1023 range->max_retry = 255;
1025 range->num_channels = FREQ_COUNT;
1028 for (i = 0; i < FREQ_COUNT; i++) {
1029 if (local->channel_mask & (1 << i)) {
1030 range->freq[val].i = i + 1;
1031 range->freq[val].m = freq_list[i] * 100000;
1032 range->freq[val].e = 1;
1035 if (val == IW_MAX_FREQUENCIES)
1038 range->num_frequency = val;
1040 if (local->sta_fw_ver >= PRISM2_FW_VER(1,3,1)) {
1041 range->max_qual.qual = 70; /* what is correct max? This was not
1042 * documented exactly. At least
1043 * 69 has been observed. */
1044 range->max_qual.level = 0; /* dB */
1045 range->max_qual.noise = 0; /* dB */
1047 /* What would be suitable values for "average/typical" qual? */
1048 range->avg_qual.qual = 20;
1049 range->avg_qual.level = -60;
1050 range->avg_qual.noise = -95;
1052 range->max_qual.qual = 92; /* 0 .. 92 */
1053 range->max_qual.level = 154; /* 27 .. 154 */
1054 range->max_qual.noise = 154; /* 27 .. 154 */
1056 range->sensitivity = 3;
1058 range->max_encoding_tokens = WEP_KEYS;
1059 range->num_encoding_sizes = 2;
1060 range->encoding_size[0] = 5;
1061 range->encoding_size[1] = 13;
1064 len = prism2_get_datarates(dev, rates);
1065 range->num_bitrates = 0;
1066 for (i = 0; i < len; i++) {
1067 if (range->num_bitrates < IW_MAX_BITRATES) {
1068 range->bitrate[range->num_bitrates] =
1070 range->num_bitrates++;
1072 if (rates[i] == 0x0b || rates[i] == 0x16)
1075 /* estimated maximum TCP throughput values (bps) */
1076 range->throughput = over2 ? 5500000 : 1500000;
1079 range->max_rts = 2347;
1080 range->min_frag = 256;
1081 range->max_frag = 2346;
1083 /* Event capability (kernel + driver) */
1084 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
1085 IW_EVENT_CAPA_MASK(SIOCGIWTHRSPY) |
1086 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
1087 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
1088 range->event_capa[1] = IW_EVENT_CAPA_K_1;
1089 range->event_capa[4] = (IW_EVENT_CAPA_MASK(IWEVTXDROP) |
1090 IW_EVENT_CAPA_MASK(IWEVCUSTOM) |
1091 IW_EVENT_CAPA_MASK(IWEVREGISTERED) |
1092 IW_EVENT_CAPA_MASK(IWEVEXPIRED));
1094 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
1095 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
1101 static int hostap_monitor_mode_enable(local_info_t *local)
1103 struct net_device *dev = local->dev;
1105 printk(KERN_DEBUG "Enabling monitor mode\n");
1106 hostap_monitor_set_type(local);
1108 if (hostap_set_word(dev, HFA384X_RID_CNFPORTTYPE,
1109 HFA384X_PORTTYPE_PSEUDO_IBSS)) {
1110 printk(KERN_DEBUG "Port type setting for monitor mode "
1115 /* Host decrypt is needed to get the IV and ICV fields;
1116 * however, monitor mode seems to remove WEP flag from frame
1118 if (hostap_set_word(dev, HFA384X_RID_CNFWEPFLAGS,
1119 HFA384X_WEPFLAGS_HOSTENCRYPT |
1120 HFA384X_WEPFLAGS_HOSTDECRYPT)) {
1121 printk(KERN_DEBUG "WEP flags setting failed\n");
1125 if (local->func->reset_port(dev) ||
1126 local->func->cmd(dev, HFA384X_CMDCODE_TEST |
1127 (HFA384X_TEST_MONITOR << 8),
1129 printk(KERN_DEBUG "Setting monitor mode failed\n");
1137 static int hostap_monitor_mode_disable(local_info_t *local)
1139 struct net_device *dev = local->ddev;
1144 printk(KERN_DEBUG "%s: Disabling monitor mode\n", dev->name);
1145 dev->type = ARPHRD_ETHER;
1146 dev->hard_header_parse = local->saved_eth_header_parse;
1147 if (local->func->cmd(dev, HFA384X_CMDCODE_TEST |
1148 (HFA384X_TEST_STOP << 8),
1151 return hostap_set_encryption(local);
1155 static int prism2_ioctl_siwmode(struct net_device *dev,
1156 struct iw_request_info *info,
1157 __u32 *mode, char *extra)
1159 struct hostap_interface *iface;
1160 local_info_t *local;
1161 int double_reset = 0;
1163 iface = netdev_priv(dev);
1164 local = iface->local;
1166 if (*mode != IW_MODE_ADHOC && *mode != IW_MODE_INFRA &&
1167 *mode != IW_MODE_MASTER && *mode != IW_MODE_REPEAT &&
1168 *mode != IW_MODE_MONITOR)
1171 #ifdef PRISM2_NO_STATION_MODES
1172 if (*mode == IW_MODE_ADHOC || *mode == IW_MODE_INFRA)
1174 #endif /* PRISM2_NO_STATION_MODES */
1176 if (*mode == local->iw_mode)
1179 if (*mode == IW_MODE_MASTER && local->essid[0] == '\0') {
1180 printk(KERN_WARNING "%s: empty SSID not allowed in Master "
1181 "mode\n", dev->name);
1185 if (local->iw_mode == IW_MODE_MONITOR)
1186 hostap_monitor_mode_disable(local);
1188 if ((local->iw_mode == IW_MODE_ADHOC ||
1189 local->iw_mode == IW_MODE_MONITOR) && *mode == IW_MODE_MASTER) {
1190 /* There seems to be a firmware bug in at least STA f/w v1.5.6
1191 * that leaves beacon frames to use IBSS type when moving from
1192 * IBSS to Host AP mode. Doing double Port0 reset seems to be
1193 * enough to workaround this. */
1197 printk(KERN_DEBUG "prism2: %s: operating mode changed "
1198 "%d -> %d\n", dev->name, local->iw_mode, *mode);
1199 local->iw_mode = *mode;
1201 if (local->iw_mode == IW_MODE_MONITOR)
1202 hostap_monitor_mode_enable(local);
1203 else if (local->iw_mode == IW_MODE_MASTER && !local->host_encrypt &&
1204 !local->fw_encrypt_ok) {
1205 printk(KERN_DEBUG "%s: defaulting to host-based encryption as "
1206 "a workaround for firmware bug in Host AP mode WEP\n",
1208 local->host_encrypt = 1;
1211 if (hostap_set_word(dev, HFA384X_RID_CNFPORTTYPE,
1212 hostap_get_porttype(local)))
1215 if (local->func->reset_port(dev))
1217 if (double_reset && local->func->reset_port(dev))
1220 if (local->iw_mode != IW_MODE_INFRA && local->iw_mode != IW_MODE_ADHOC)
1222 /* netif_carrier is used only in client modes for now, so make
1223 * sure carrier is on when moving to non-client modes. */
1224 netif_carrier_on(local->dev);
1225 netif_carrier_on(local->ddev);
1231 static int prism2_ioctl_giwmode(struct net_device *dev,
1232 struct iw_request_info *info,
1233 __u32 *mode, char *extra)
1235 struct hostap_interface *iface;
1236 local_info_t *local;
1238 iface = netdev_priv(dev);
1239 local = iface->local;
1241 switch (iface->type) {
1242 case HOSTAP_INTERFACE_STA:
1243 *mode = IW_MODE_INFRA;
1245 case HOSTAP_INTERFACE_WDS:
1246 *mode = IW_MODE_REPEAT;
1249 *mode = local->iw_mode;
1256 static int prism2_ioctl_siwpower(struct net_device *dev,
1257 struct iw_request_info *info,
1258 struct iw_param *wrq, char *extra)
1260 #ifdef PRISM2_NO_STATION_MODES
1262 #else /* PRISM2_NO_STATION_MODES */
1266 return hostap_set_word(dev, HFA384X_RID_CNFPMENABLED, 0);
1268 switch (wrq->flags & IW_POWER_MODE) {
1269 case IW_POWER_UNICAST_R:
1270 ret = hostap_set_word(dev, HFA384X_RID_CNFMULTICASTRECEIVE, 0);
1273 ret = hostap_set_word(dev, HFA384X_RID_CNFPMENABLED, 1);
1277 case IW_POWER_ALL_R:
1278 ret = hostap_set_word(dev, HFA384X_RID_CNFMULTICASTRECEIVE, 1);
1281 ret = hostap_set_word(dev, HFA384X_RID_CNFPMENABLED, 1);
1291 if (wrq->flags & IW_POWER_TIMEOUT) {
1292 ret = hostap_set_word(dev, HFA384X_RID_CNFPMENABLED, 1);
1295 ret = hostap_set_word(dev, HFA384X_RID_CNFPMHOLDOVERDURATION,
1300 if (wrq->flags & IW_POWER_PERIOD) {
1301 ret = hostap_set_word(dev, HFA384X_RID_CNFPMENABLED, 1);
1304 ret = hostap_set_word(dev, HFA384X_RID_CNFMAXSLEEPDURATION,
1311 #endif /* PRISM2_NO_STATION_MODES */
1315 static int prism2_ioctl_giwpower(struct net_device *dev,
1316 struct iw_request_info *info,
1317 struct iw_param *rrq, char *extra)
1319 #ifdef PRISM2_NO_STATION_MODES
1321 #else /* PRISM2_NO_STATION_MODES */
1322 struct hostap_interface *iface;
1323 local_info_t *local;
1326 iface = netdev_priv(dev);
1327 local = iface->local;
1329 if (local->func->get_rid(dev, HFA384X_RID_CNFPMENABLED, &enable, 2, 1)
1333 if (!__le16_to_cpu(enable)) {
1340 if ((rrq->flags & IW_POWER_TYPE) == IW_POWER_TIMEOUT) {
1342 if (local->func->get_rid(dev,
1343 HFA384X_RID_CNFPMHOLDOVERDURATION,
1344 &timeout, 2, 1) < 0)
1347 rrq->flags = IW_POWER_TIMEOUT;
1348 rrq->value = __le16_to_cpu(timeout) * 1024;
1351 if (local->func->get_rid(dev, HFA384X_RID_CNFMAXSLEEPDURATION,
1355 rrq->flags = IW_POWER_PERIOD;
1356 rrq->value = __le16_to_cpu(period) * 1024;
1359 if (local->func->get_rid(dev, HFA384X_RID_CNFMULTICASTRECEIVE, &mcast,
1363 if (__le16_to_cpu(mcast))
1364 rrq->flags |= IW_POWER_ALL_R;
1366 rrq->flags |= IW_POWER_UNICAST_R;
1369 #endif /* PRISM2_NO_STATION_MODES */
1373 static int prism2_ioctl_siwretry(struct net_device *dev,
1374 struct iw_request_info *info,
1375 struct iw_param *rrq, char *extra)
1377 struct hostap_interface *iface;
1378 local_info_t *local;
1380 iface = netdev_priv(dev);
1381 local = iface->local;
1386 /* setting retry limits is not supported with the current station
1387 * firmware code; simulate this with alternative retry count for now */
1388 if (rrq->flags == IW_RETRY_LIMIT) {
1389 if (rrq->value < 0) {
1390 /* disable manual retry count setting and use firmware
1392 local->manual_retry_count = -1;
1393 local->tx_control &= ~HFA384X_TX_CTRL_ALT_RTRY;
1395 if (hostap_set_word(dev, HFA384X_RID_CNFALTRETRYCOUNT,
1397 printk(KERN_DEBUG "%s: Alternate retry count "
1398 "setting to %d failed\n",
1399 dev->name, rrq->value);
1403 local->manual_retry_count = rrq->value;
1404 local->tx_control |= HFA384X_TX_CTRL_ALT_RTRY;
1412 /* what could be done, if firmware would support this.. */
1414 if (rrq->flags & IW_RETRY_LIMIT) {
1415 if (rrq->flags & IW_RETRY_MAX)
1416 HFA384X_RID_LONGRETRYLIMIT = rrq->value;
1417 else if (rrq->flags & IW_RETRY_MIN)
1418 HFA384X_RID_SHORTRETRYLIMIT = rrq->value;
1420 HFA384X_RID_LONGRETRYLIMIT = rrq->value;
1421 HFA384X_RID_SHORTRETRYLIMIT = rrq->value;
1426 if (rrq->flags & IW_RETRY_LIFETIME) {
1427 HFA384X_RID_MAXTRANSMITLIFETIME = rrq->value / 1024;
1434 static int prism2_ioctl_giwretry(struct net_device *dev,
1435 struct iw_request_info *info,
1436 struct iw_param *rrq, char *extra)
1438 struct hostap_interface *iface;
1439 local_info_t *local;
1440 u16 shortretry, longretry, lifetime, altretry;
1442 iface = netdev_priv(dev);
1443 local = iface->local;
1445 if (local->func->get_rid(dev, HFA384X_RID_SHORTRETRYLIMIT, &shortretry,
1447 local->func->get_rid(dev, HFA384X_RID_LONGRETRYLIMIT, &longretry,
1449 local->func->get_rid(dev, HFA384X_RID_MAXTRANSMITLIFETIME,
1450 &lifetime, 2, 1) < 0)
1453 le16_to_cpus(&shortretry);
1454 le16_to_cpus(&longretry);
1455 le16_to_cpus(&lifetime);
1459 if ((rrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
1460 rrq->flags = IW_RETRY_LIFETIME;
1461 rrq->value = lifetime * 1024;
1463 if (local->manual_retry_count >= 0) {
1464 rrq->flags = IW_RETRY_LIMIT;
1465 if (local->func->get_rid(dev,
1466 HFA384X_RID_CNFALTRETRYCOUNT,
1467 &altretry, 2, 1) >= 0)
1468 rrq->value = le16_to_cpu(altretry);
1470 rrq->value = local->manual_retry_count;
1471 } else if ((rrq->flags & IW_RETRY_MAX)) {
1472 rrq->flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
1473 rrq->value = longretry;
1475 rrq->flags = IW_RETRY_LIMIT;
1476 rrq->value = shortretry;
1477 if (shortretry != longretry)
1478 rrq->flags |= IW_RETRY_MIN;
1485 /* Note! This TX power controlling is experimental and should not be used in
1486 * production use. It just sets raw power register and does not use any kind of
1487 * feedback information from the measured TX power (CR58). This is now
1488 * commented out to make sure that it is not used by accident. TX power
1489 * configuration will be enabled again after proper algorithm using feedback
1490 * has been implemented. */
1492 #ifdef RAW_TXPOWER_SETTING
1493 /* Map HFA386x's CR31 to and from dBm with some sort of ad hoc mapping..
1494 * This version assumes following mapping:
1495 * CR31 is 7-bit value with -64 to +63 range.
1496 * -64 is mapped into +20dBm and +63 into -43dBm.
1497 * This is certainly not an exact mapping for every card, but at least
1498 * increasing dBm value should correspond to increasing TX power.
1501 static int prism2_txpower_hfa386x_to_dBm(u16 val)
1514 static u16 prism2_txpower_dBm_to_hfa386x(int val)
1527 return (unsigned char) tmp;
1529 #endif /* RAW_TXPOWER_SETTING */
1532 static int prism2_ioctl_siwtxpow(struct net_device *dev,
1533 struct iw_request_info *info,
1534 struct iw_param *rrq, char *extra)
1536 struct hostap_interface *iface;
1537 local_info_t *local;
1538 #ifdef RAW_TXPOWER_SETTING
1544 iface = netdev_priv(dev);
1545 local = iface->local;
1547 if (rrq->disabled) {
1548 if (local->txpower_type != PRISM2_TXPOWER_OFF) {
1549 val = 0xff; /* use all standby and sleep modes */
1550 ret = local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
1551 HFA386X_CR_A_D_TEST_MODES2,
1553 printk(KERN_DEBUG "%s: Turning radio off: %s\n",
1554 dev->name, ret ? "failed" : "OK");
1555 local->txpower_type = PRISM2_TXPOWER_OFF;
1557 return (ret ? -EOPNOTSUPP : 0);
1560 if (local->txpower_type == PRISM2_TXPOWER_OFF) {
1561 val = 0; /* disable all standby and sleep modes */
1562 ret = local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
1563 HFA386X_CR_A_D_TEST_MODES2, &val, NULL);
1564 printk(KERN_DEBUG "%s: Turning radio on: %s\n",
1565 dev->name, ret ? "failed" : "OK");
1566 local->txpower_type = PRISM2_TXPOWER_UNKNOWN;
1569 #ifdef RAW_TXPOWER_SETTING
1570 if (!rrq->fixed && local->txpower_type != PRISM2_TXPOWER_AUTO) {
1571 printk(KERN_DEBUG "Setting ALC on\n");
1572 val = HFA384X_TEST_CFG_BIT_ALC;
1573 local->func->cmd(dev, HFA384X_CMDCODE_TEST |
1574 (HFA384X_TEST_CFG_BITS << 8), 1, &val, NULL);
1575 local->txpower_type = PRISM2_TXPOWER_AUTO;
1579 if (local->txpower_type != PRISM2_TXPOWER_FIXED) {
1580 printk(KERN_DEBUG "Setting ALC off\n");
1581 val = HFA384X_TEST_CFG_BIT_ALC;
1582 local->func->cmd(dev, HFA384X_CMDCODE_TEST |
1583 (HFA384X_TEST_CFG_BITS << 8), 0, &val, NULL);
1584 local->txpower_type = PRISM2_TXPOWER_FIXED;
1587 if (rrq->flags == IW_TXPOW_DBM)
1589 else if (rrq->flags == IW_TXPOW_MWATT)
1593 printk(KERN_DEBUG "Setting TX power to %d %s\n", rrq->value, tmp);
1595 if (rrq->flags != IW_TXPOW_DBM) {
1596 printk("SIOCSIWTXPOW with mW is not supported; use dBm\n");
1600 local->txpower = rrq->value;
1601 val = prism2_txpower_dBm_to_hfa386x(local->txpower);
1602 if (local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
1603 HFA386X_CR_MANUAL_TX_POWER, &val, NULL))
1605 #else /* RAW_TXPOWER_SETTING */
1608 #endif /* RAW_TXPOWER_SETTING */
1613 static int prism2_ioctl_giwtxpow(struct net_device *dev,
1614 struct iw_request_info *info,
1615 struct iw_param *rrq, char *extra)
1617 #ifdef RAW_TXPOWER_SETTING
1618 struct hostap_interface *iface;
1619 local_info_t *local;
1622 iface = netdev_priv(dev);
1623 local = iface->local;
1625 rrq->flags = IW_TXPOW_DBM;
1629 if (local->txpower_type == PRISM2_TXPOWER_AUTO) {
1630 if (local->func->cmd(dev, HFA384X_CMDCODE_READMIF,
1631 HFA386X_CR_MANUAL_TX_POWER,
1632 NULL, &resp0) == 0) {
1633 rrq->value = prism2_txpower_hfa386x_to_dBm(resp0);
1635 /* Could not get real txpower; guess 15 dBm */
1638 } else if (local->txpower_type == PRISM2_TXPOWER_OFF) {
1641 } else if (local->txpower_type == PRISM2_TXPOWER_FIXED) {
1642 rrq->value = local->txpower;
1645 printk("SIOCGIWTXPOW - unknown txpower_type=%d\n",
1646 local->txpower_type);
1649 #else /* RAW_TXPOWER_SETTING */
1651 #endif /* RAW_TXPOWER_SETTING */
1655 #ifndef PRISM2_NO_STATION_MODES
1657 /* HostScan request works with and without host_roaming mode. In addition, it
1658 * does not break current association. However, it requires newer station
1659 * firmware version (>= 1.3.1) than scan request. */
1660 static int prism2_request_hostscan(struct net_device *dev,
1661 u8 *ssid, u8 ssid_len)
1663 struct hostap_interface *iface;
1664 local_info_t *local;
1665 struct hfa384x_hostscan_request scan_req;
1667 iface = netdev_priv(dev);
1668 local = iface->local;
1670 memset(&scan_req, 0, sizeof(scan_req));
1671 scan_req.channel_list = cpu_to_le16(local->channel_mask &
1672 local->scan_channel_mask);
1673 scan_req.txrate = __constant_cpu_to_le16(HFA384X_RATES_1MBPS);
1677 scan_req.target_ssid_len = cpu_to_le16(ssid_len);
1678 memcpy(scan_req.target_ssid, ssid, ssid_len);
1681 if (local->func->set_rid(dev, HFA384X_RID_HOSTSCAN, &scan_req,
1682 sizeof(scan_req))) {
1683 printk(KERN_DEBUG "%s: HOSTSCAN failed\n", dev->name);
1690 static int prism2_request_scan(struct net_device *dev)
1692 struct hostap_interface *iface;
1693 local_info_t *local;
1694 struct hfa384x_scan_request scan_req;
1697 iface = netdev_priv(dev);
1698 local = iface->local;
1700 memset(&scan_req, 0, sizeof(scan_req));
1701 scan_req.channel_list = cpu_to_le16(local->channel_mask &
1702 local->scan_channel_mask);
1703 scan_req.txrate = __constant_cpu_to_le16(HFA384X_RATES_1MBPS);
1706 * It seems to be enough to set roaming mode for a short moment to
1707 * host-based and then setup scanrequest data and return the mode to
1710 * Master mode would need to drop to Managed mode for a short while
1711 * to make scanning work.. Or sweep through the different channels and
1712 * use passive scan based on beacons. */
1714 if (!local->host_roaming)
1715 hostap_set_word(dev, HFA384X_RID_CNFROAMINGMODE,
1716 HFA384X_ROAMING_HOST);
1718 if (local->func->set_rid(dev, HFA384X_RID_SCANREQUEST, &scan_req,
1719 sizeof(scan_req))) {
1720 printk(KERN_DEBUG "SCANREQUEST failed\n");
1724 if (!local->host_roaming)
1725 hostap_set_word(dev, HFA384X_RID_CNFROAMINGMODE,
1726 HFA384X_ROAMING_FIRMWARE);
1731 #else /* !PRISM2_NO_STATION_MODES */
1733 static inline int prism2_request_hostscan(struct net_device *dev,
1734 u8 *ssid, u8 ssid_len)
1740 static inline int prism2_request_scan(struct net_device *dev)
1745 #endif /* !PRISM2_NO_STATION_MODES */
1748 static int prism2_ioctl_siwscan(struct net_device *dev,
1749 struct iw_request_info *info,
1750 struct iw_point *data, char *extra)
1752 struct hostap_interface *iface;
1753 local_info_t *local;
1755 u8 *ssid = NULL, ssid_len = 0;
1756 struct iw_scan_req *req = (struct iw_scan_req *) extra;
1758 iface = netdev_priv(dev);
1759 local = iface->local;
1761 if (data->length < sizeof(struct iw_scan_req))
1764 if (local->iw_mode == IW_MODE_MASTER) {
1765 /* In master mode, we just return the results of our local
1766 * tables, so we don't need to start anything...
1772 if (!local->dev_enabled)
1775 if (req && data->flags & IW_SCAN_THIS_ESSID) {
1777 ssid_len = req->essid_len;
1780 ((local->iw_mode != IW_MODE_INFRA &&
1781 local->iw_mode != IW_MODE_ADHOC) ||
1782 (local->sta_fw_ver < PRISM2_FW_VER(1,3,1))))
1786 if (local->sta_fw_ver >= PRISM2_FW_VER(1,3,1))
1787 ret = prism2_request_hostscan(dev, ssid, ssid_len);
1789 ret = prism2_request_scan(dev);
1792 local->scan_timestamp = jiffies;
1794 /* Could inquire F101, F103 or wait for SIOCGIWSCAN and read RID */
1800 #ifndef PRISM2_NO_STATION_MODES
1801 static char * __prism2_translate_scan(local_info_t *local,
1802 struct hfa384x_hostscan_result *scan,
1803 struct hostap_bss_info *bss,
1804 char *current_ev, char *end_buf)
1807 struct iw_event iwe;
1817 ssid_len = bss->ssid_len;
1821 ssid_len = le16_to_cpu(scan->ssid_len);
1822 bssid = scan->bssid;
1827 /* First entry *MUST* be the AP MAC address */
1828 memset(&iwe, 0, sizeof(iwe));
1829 iwe.cmd = SIOCGIWAP;
1830 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
1831 memcpy(iwe.u.ap_addr.sa_data, bssid, ETH_ALEN);
1832 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
1835 /* Other entries will be displayed in the order we give them */
1837 memset(&iwe, 0, sizeof(iwe));
1838 iwe.cmd = SIOCGIWESSID;
1839 iwe.u.data.length = ssid_len;
1840 iwe.u.data.flags = 1;
1841 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, ssid);
1843 memset(&iwe, 0, sizeof(iwe));
1844 iwe.cmd = SIOCGIWMODE;
1846 capabilities = bss->capab_info;
1848 capabilities = le16_to_cpu(scan->capability);
1850 if (capabilities & (WLAN_CAPABILITY_ESS |
1851 WLAN_CAPABILITY_IBSS)) {
1852 if (capabilities & WLAN_CAPABILITY_ESS)
1853 iwe.u.mode = IW_MODE_MASTER;
1855 iwe.u.mode = IW_MODE_ADHOC;
1856 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
1860 memset(&iwe, 0, sizeof(iwe));
1861 iwe.cmd = SIOCGIWFREQ;
1871 iwe.u.freq.m = freq_list[le16_to_cpu(chan - 1)] * 100000;
1873 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
1878 memset(&iwe, 0, sizeof(iwe));
1880 if (local->last_scan_type == PRISM2_HOSTSCAN) {
1881 iwe.u.qual.level = le16_to_cpu(scan->sl);
1882 iwe.u.qual.noise = le16_to_cpu(scan->anl);
1885 HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan->sl));
1887 HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan->anl));
1889 iwe.u.qual.updated = IW_QUAL_LEVEL_UPDATED
1890 | IW_QUAL_NOISE_UPDATED
1891 | IW_QUAL_QUAL_INVALID
1893 current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe,
1897 memset(&iwe, 0, sizeof(iwe));
1898 iwe.cmd = SIOCGIWENCODE;
1899 if (capabilities & WLAN_CAPABILITY_PRIVACY)
1900 iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
1902 iwe.u.data.flags = IW_ENCODE_DISABLED;
1903 iwe.u.data.length = 0;
1904 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, "");
1906 /* TODO: add SuppRates into BSS table */
1908 memset(&iwe, 0, sizeof(iwe));
1909 iwe.cmd = SIOCGIWRATE;
1910 current_val = current_ev + IW_EV_LCP_LEN;
1911 pos = scan->sup_rates;
1912 for (i = 0; i < sizeof(scan->sup_rates); i++) {
1915 /* Bit rate given in 500 kb/s units (+ 0x80) */
1916 iwe.u.bitrate.value = ((pos[i] & 0x7f) * 500000);
1917 current_val = iwe_stream_add_value(
1918 current_ev, current_val, end_buf, &iwe,
1921 /* Check if we added any event */
1922 if ((current_val - current_ev) > IW_EV_LCP_LEN)
1923 current_ev = current_val;
1926 /* TODO: add BeaconInt,resp_rate,atim into BSS table */
1927 buf = kmalloc(MAX_WPA_IE_LEN * 2 + 30, GFP_ATOMIC);
1929 memset(&iwe, 0, sizeof(iwe));
1930 iwe.cmd = IWEVCUSTOM;
1931 sprintf(buf, "bcn_int=%d", le16_to_cpu(scan->beacon_interval));
1932 iwe.u.data.length = strlen(buf);
1933 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe,
1936 memset(&iwe, 0, sizeof(iwe));
1937 iwe.cmd = IWEVCUSTOM;
1938 sprintf(buf, "resp_rate=%d", le16_to_cpu(scan->rate));
1939 iwe.u.data.length = strlen(buf);
1940 current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe,
1943 if (local->last_scan_type == PRISM2_HOSTSCAN &&
1944 (capabilities & WLAN_CAPABILITY_IBSS)) {
1945 memset(&iwe, 0, sizeof(iwe));
1946 iwe.cmd = IWEVCUSTOM;
1947 sprintf(buf, "atim=%d", le16_to_cpu(scan->atim));
1948 iwe.u.data.length = strlen(buf);
1949 current_ev = iwe_stream_add_point(current_ev, end_buf,
1955 if (bss && bss->wpa_ie_len > 0 && bss->wpa_ie_len <= MAX_WPA_IE_LEN) {
1956 memset(&iwe, 0, sizeof(iwe));
1957 iwe.cmd = IWEVGENIE;
1958 iwe.u.data.length = bss->wpa_ie_len;
1959 current_ev = iwe_stream_add_point(
1960 current_ev, end_buf, &iwe, bss->wpa_ie);
1963 if (bss && bss->rsn_ie_len > 0 && bss->rsn_ie_len <= MAX_WPA_IE_LEN) {
1964 memset(&iwe, 0, sizeof(iwe));
1965 iwe.cmd = IWEVGENIE;
1966 iwe.u.data.length = bss->rsn_ie_len;
1967 current_ev = iwe_stream_add_point(
1968 current_ev, end_buf, &iwe, bss->rsn_ie);
1975 /* Translate scan data returned from the card to a card independant
1976 * format that the Wireless Tools will understand - Jean II */
1977 static inline int prism2_translate_scan(local_info_t *local,
1978 char *buffer, int buflen)
1980 struct hfa384x_hostscan_result *scan;
1981 int entry, hostscan;
1982 char *current_ev = buffer;
1983 char *end_buf = buffer + buflen;
1984 struct list_head *ptr;
1986 spin_lock_bh(&local->lock);
1988 list_for_each(ptr, &local->bss_list) {
1989 struct hostap_bss_info *bss;
1990 bss = list_entry(ptr, struct hostap_bss_info, list);
1994 hostscan = local->last_scan_type == PRISM2_HOSTSCAN;
1995 for (entry = 0; entry < local->last_scan_results_count; entry++) {
1997 scan = &local->last_scan_results[entry];
1999 /* Report every SSID if the AP is using multiple SSIDs. If no
2000 * BSS record is found (e.g., when WPA mode is disabled),
2001 * report the AP once. */
2002 list_for_each(ptr, &local->bss_list) {
2003 struct hostap_bss_info *bss;
2004 bss = list_entry(ptr, struct hostap_bss_info, list);
2005 if (memcmp(bss->bssid, scan->bssid, ETH_ALEN) == 0) {
2007 current_ev = __prism2_translate_scan(
2008 local, scan, bss, current_ev, end_buf);
2013 current_ev = __prism2_translate_scan(
2014 local, scan, NULL, current_ev, end_buf);
2016 /* Check if there is space for one more entry */
2017 if ((end_buf - current_ev) <= IW_EV_ADDR_LEN) {
2018 /* Ask user space to try again with a bigger buffer */
2019 spin_unlock_bh(&local->lock);
2024 /* Prism2 firmware has limits (32 at least in some versions) for number
2025 * of BSSes in scan results. Extend this limit by using local BSS list.
2027 list_for_each(ptr, &local->bss_list) {
2028 struct hostap_bss_info *bss;
2029 bss = list_entry(ptr, struct hostap_bss_info, list);
2032 current_ev = __prism2_translate_scan(local, NULL, bss,
2033 current_ev, end_buf);
2034 /* Check if there is space for one more entry */
2035 if ((end_buf - current_ev) <= IW_EV_ADDR_LEN) {
2036 /* Ask user space to try again with a bigger buffer */
2037 spin_unlock_bh(&local->lock);
2042 spin_unlock_bh(&local->lock);
2044 return current_ev - buffer;
2046 #endif /* PRISM2_NO_STATION_MODES */
2049 static inline int prism2_ioctl_giwscan_sta(struct net_device *dev,
2050 struct iw_request_info *info,
2051 struct iw_point *data, char *extra)
2053 #ifdef PRISM2_NO_STATION_MODES
2055 #else /* PRISM2_NO_STATION_MODES */
2056 struct hostap_interface *iface;
2057 local_info_t *local;
2060 iface = netdev_priv(dev);
2061 local = iface->local;
2063 /* Wait until the scan is finished. We can probably do better
2064 * than that - Jean II */
2065 if (local->scan_timestamp &&
2066 time_before(jiffies, local->scan_timestamp + 3 * HZ)) {
2067 /* Important note : we don't want to block the caller
2068 * until results are ready for various reasons.
2069 * First, managing wait queues is complex and racy
2070 * (there may be multiple simultaneous callers).
2071 * Second, we grab some rtnetlink lock before comming
2072 * here (in dev_ioctl()).
2073 * Third, the caller can wait on the Wireless Event
2077 local->scan_timestamp = 0;
2079 res = prism2_translate_scan(local, extra, data->length);
2088 #endif /* PRISM2_NO_STATION_MODES */
2092 static int prism2_ioctl_giwscan(struct net_device *dev,
2093 struct iw_request_info *info,
2094 struct iw_point *data, char *extra)
2096 struct hostap_interface *iface;
2097 local_info_t *local;
2100 iface = netdev_priv(dev);
2101 local = iface->local;
2103 if (local->iw_mode == IW_MODE_MASTER) {
2104 /* In MASTER mode, it doesn't make sense to go around
2105 * scanning the frequencies and make the stations we serve
2106 * wait when what the user is really interested about is the
2107 * list of stations and access points we are talking to.
2108 * So, just extract results from our cache...
2111 /* Translate to WE format */
2112 res = prism2_ap_translate_scan(dev, extra);
2114 printk(KERN_DEBUG "Scan result translation succeeded "
2115 "(length=%d)\n", res);
2120 "Scan result translation failed (res=%d)\n",
2127 return prism2_ioctl_giwscan_sta(dev, info, data, extra);
2132 static const struct iw_priv_args prism2_priv[] = {
2133 { PRISM2_IOCTL_MONITOR,
2134 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "monitor" },
2135 { PRISM2_IOCTL_READMIF,
2136 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1,
2137 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, "readmif" },
2138 { PRISM2_IOCTL_WRITEMIF,
2139 IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 2, 0, "writemif" },
2140 { PRISM2_IOCTL_RESET,
2141 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "reset" },
2142 { PRISM2_IOCTL_INQUIRE,
2143 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "inquire" },
2144 { PRISM2_IOCTL_SET_RID_WORD,
2145 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "set_rid_word" },
2146 { PRISM2_IOCTL_MACCMD,
2147 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "maccmd" },
2148 { PRISM2_IOCTL_WDS_ADD,
2149 IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "wds_add" },
2150 { PRISM2_IOCTL_WDS_DEL,
2151 IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "wds_del" },
2152 { PRISM2_IOCTL_ADDMAC,
2153 IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "addmac" },
2154 { PRISM2_IOCTL_DELMAC,
2155 IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "delmac" },
2156 { PRISM2_IOCTL_KICKMAC,
2157 IW_PRIV_TYPE_ADDR | IW_PRIV_SIZE_FIXED | 1, 0, "kickmac" },
2158 /* --- raw access to sub-ioctls --- */
2159 { PRISM2_IOCTL_PRISM2_PARAM,
2160 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "prism2_param" },
2161 { PRISM2_IOCTL_GET_PRISM2_PARAM,
2162 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1,
2163 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getprism2_param" },
2164 /* --- sub-ioctls handlers --- */
2165 { PRISM2_IOCTL_PRISM2_PARAM,
2166 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "" },
2167 { PRISM2_IOCTL_GET_PRISM2_PARAM,
2168 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "" },
2169 /* --- sub-ioctls definitions --- */
2170 { PRISM2_PARAM_TXRATECTRL,
2171 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "txratectrl" },
2172 { PRISM2_PARAM_TXRATECTRL,
2173 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "gettxratectrl" },
2174 { PRISM2_PARAM_BEACON_INT,
2175 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "beacon_int" },
2176 { PRISM2_PARAM_BEACON_INT,
2177 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getbeacon_int" },
2178 #ifndef PRISM2_NO_STATION_MODES
2179 { PRISM2_PARAM_PSEUDO_IBSS,
2180 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "pseudo_ibss" },
2181 { PRISM2_PARAM_PSEUDO_IBSS,
2182 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getpseudo_ibss" },
2183 #endif /* PRISM2_NO_STATION_MODES */
2185 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "alc" },
2187 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getalc" },
2188 { PRISM2_PARAM_DUMP,
2189 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "dump" },
2190 { PRISM2_PARAM_DUMP,
2191 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getdump" },
2192 { PRISM2_PARAM_OTHER_AP_POLICY,
2193 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "other_ap_policy" },
2194 { PRISM2_PARAM_OTHER_AP_POLICY,
2195 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getother_ap_pol" },
2196 { PRISM2_PARAM_AP_MAX_INACTIVITY,
2197 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "max_inactivity" },
2198 { PRISM2_PARAM_AP_MAX_INACTIVITY,
2199 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getmax_inactivi" },
2200 { PRISM2_PARAM_AP_BRIDGE_PACKETS,
2201 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "bridge_packets" },
2202 { PRISM2_PARAM_AP_BRIDGE_PACKETS,
2203 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getbridge_packe" },
2204 { PRISM2_PARAM_DTIM_PERIOD,
2205 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "dtim_period" },
2206 { PRISM2_PARAM_DTIM_PERIOD,
2207 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getdtim_period" },
2208 { PRISM2_PARAM_AP_NULLFUNC_ACK,
2209 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "nullfunc_ack" },
2210 { PRISM2_PARAM_AP_NULLFUNC_ACK,
2211 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getnullfunc_ack" },
2212 { PRISM2_PARAM_MAX_WDS,
2213 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "max_wds" },
2214 { PRISM2_PARAM_MAX_WDS,
2215 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getmax_wds" },
2216 { PRISM2_PARAM_AP_AUTOM_AP_WDS,
2217 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "autom_ap_wds" },
2218 { PRISM2_PARAM_AP_AUTOM_AP_WDS,
2219 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getautom_ap_wds" },
2220 { PRISM2_PARAM_AP_AUTH_ALGS,
2221 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "ap_auth_algs" },
2222 { PRISM2_PARAM_AP_AUTH_ALGS,
2223 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getap_auth_algs" },
2224 { PRISM2_PARAM_MONITOR_ALLOW_FCSERR,
2225 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "allow_fcserr" },
2226 { PRISM2_PARAM_MONITOR_ALLOW_FCSERR,
2227 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getallow_fcserr" },
2228 { PRISM2_PARAM_HOST_ENCRYPT,
2229 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "host_encrypt" },
2230 { PRISM2_PARAM_HOST_ENCRYPT,
2231 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "gethost_encrypt" },
2232 { PRISM2_PARAM_HOST_DECRYPT,
2233 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "host_decrypt" },
2234 { PRISM2_PARAM_HOST_DECRYPT,
2235 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "gethost_decrypt" },
2236 #ifndef PRISM2_NO_STATION_MODES
2237 { PRISM2_PARAM_HOST_ROAMING,
2238 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "host_roaming" },
2239 { PRISM2_PARAM_HOST_ROAMING,
2240 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "gethost_roaming" },
2241 #endif /* PRISM2_NO_STATION_MODES */
2242 { PRISM2_PARAM_BCRX_STA_KEY,
2243 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "bcrx_sta_key" },
2244 { PRISM2_PARAM_BCRX_STA_KEY,
2245 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getbcrx_sta_key" },
2246 { PRISM2_PARAM_IEEE_802_1X,
2247 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "ieee_802_1x" },
2248 { PRISM2_PARAM_IEEE_802_1X,
2249 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getieee_802_1x" },
2250 { PRISM2_PARAM_ANTSEL_TX,
2251 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "antsel_tx" },
2252 { PRISM2_PARAM_ANTSEL_TX,
2253 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getantsel_tx" },
2254 { PRISM2_PARAM_ANTSEL_RX,
2255 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "antsel_rx" },
2256 { PRISM2_PARAM_ANTSEL_RX,
2257 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getantsel_rx" },
2258 { PRISM2_PARAM_MONITOR_TYPE,
2259 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "monitor_type" },
2260 { PRISM2_PARAM_MONITOR_TYPE,
2261 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getmonitor_type" },
2262 { PRISM2_PARAM_WDS_TYPE,
2263 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wds_type" },
2264 { PRISM2_PARAM_WDS_TYPE,
2265 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwds_type" },
2266 { PRISM2_PARAM_HOSTSCAN,
2267 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hostscan" },
2268 { PRISM2_PARAM_HOSTSCAN,
2269 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "gethostscan" },
2270 { PRISM2_PARAM_AP_SCAN,
2271 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "ap_scan" },
2272 { PRISM2_PARAM_AP_SCAN,
2273 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getap_scan" },
2274 { PRISM2_PARAM_ENH_SEC,
2275 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "enh_sec" },
2276 { PRISM2_PARAM_ENH_SEC,
2277 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getenh_sec" },
2278 #ifdef PRISM2_IO_DEBUG
2279 { PRISM2_PARAM_IO_DEBUG,
2280 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "io_debug" },
2281 { PRISM2_PARAM_IO_DEBUG,
2282 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getio_debug" },
2283 #endif /* PRISM2_IO_DEBUG */
2284 { PRISM2_PARAM_BASIC_RATES,
2285 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "basic_rates" },
2286 { PRISM2_PARAM_BASIC_RATES,
2287 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getbasic_rates" },
2288 { PRISM2_PARAM_OPER_RATES,
2289 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "oper_rates" },
2290 { PRISM2_PARAM_OPER_RATES,
2291 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getoper_rates" },
2292 { PRISM2_PARAM_HOSTAPD,
2293 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hostapd" },
2294 { PRISM2_PARAM_HOSTAPD,
2295 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "gethostapd" },
2296 { PRISM2_PARAM_HOSTAPD_STA,
2297 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "hostapd_sta" },
2298 { PRISM2_PARAM_HOSTAPD_STA,
2299 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "gethostapd_sta" },
2301 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wpa" },
2303 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getwpa" },
2304 { PRISM2_PARAM_PRIVACY_INVOKED,
2305 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "privacy_invoked" },
2306 { PRISM2_PARAM_PRIVACY_INVOKED,
2307 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getprivacy_invo" },
2308 { PRISM2_PARAM_TKIP_COUNTERMEASURES,
2309 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "tkip_countermea" },
2310 { PRISM2_PARAM_TKIP_COUNTERMEASURES,
2311 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "gettkip_counter" },
2312 { PRISM2_PARAM_DROP_UNENCRYPTED,
2313 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "drop_unencrypte" },
2314 { PRISM2_PARAM_DROP_UNENCRYPTED,
2315 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getdrop_unencry" },
2316 { PRISM2_PARAM_SCAN_CHANNEL_MASK,
2317 IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "scan_channels" },
2318 { PRISM2_PARAM_SCAN_CHANNEL_MASK,
2319 0, IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, "getscan_channel" },
2323 static int prism2_ioctl_priv_inquire(struct net_device *dev, int *i)
2325 struct hostap_interface *iface;
2326 local_info_t *local;
2328 iface = netdev_priv(dev);
2329 local = iface->local;
2331 if (local->func->cmd(dev, HFA384X_CMDCODE_INQUIRE, *i, NULL, NULL))
2338 static int prism2_ioctl_priv_prism2_param(struct net_device *dev,
2339 struct iw_request_info *info,
2340 void *wrqu, char *extra)
2342 struct hostap_interface *iface;
2343 local_info_t *local;
2344 int *i = (int *) extra;
2346 int value = *(i + 1);
2350 iface = netdev_priv(dev);
2351 local = iface->local;
2354 case PRISM2_PARAM_TXRATECTRL:
2355 local->fw_tx_rate_control = value;
2358 case PRISM2_PARAM_BEACON_INT:
2359 if (hostap_set_word(dev, HFA384X_RID_CNFBEACONINT, value) ||
2360 local->func->reset_port(dev))
2363 local->beacon_int = value;
2366 #ifndef PRISM2_NO_STATION_MODES
2367 case PRISM2_PARAM_PSEUDO_IBSS:
2368 if (value == local->pseudo_adhoc)
2371 if (value != 0 && value != 1) {
2376 printk(KERN_DEBUG "prism2: %s: pseudo IBSS change %d -> %d\n",
2377 dev->name, local->pseudo_adhoc, value);
2378 local->pseudo_adhoc = value;
2379 if (local->iw_mode != IW_MODE_ADHOC)
2382 if (hostap_set_word(dev, HFA384X_RID_CNFPORTTYPE,
2383 hostap_get_porttype(local))) {
2388 if (local->func->reset_port(dev))
2391 #endif /* PRISM2_NO_STATION_MODES */
2393 case PRISM2_PARAM_ALC:
2394 printk(KERN_DEBUG "%s: %s ALC\n", dev->name,
2395 value == 0 ? "Disabling" : "Enabling");
2396 val = HFA384X_TEST_CFG_BIT_ALC;
2397 local->func->cmd(dev, HFA384X_CMDCODE_TEST |
2398 (HFA384X_TEST_CFG_BITS << 8),
2399 value == 0 ? 0 : 1, &val, NULL);
2402 case PRISM2_PARAM_DUMP:
2403 local->frame_dump = value;
2406 case PRISM2_PARAM_OTHER_AP_POLICY:
2407 if (value < 0 || value > 3) {
2411 if (local->ap != NULL)
2412 local->ap->ap_policy = value;
2415 case PRISM2_PARAM_AP_MAX_INACTIVITY:
2416 if (value < 0 || value > 7 * 24 * 60 * 60) {
2420 if (local->ap != NULL)
2421 local->ap->max_inactivity = value * HZ;
2424 case PRISM2_PARAM_AP_BRIDGE_PACKETS:
2425 if (local->ap != NULL)
2426 local->ap->bridge_packets = value;
2429 case PRISM2_PARAM_DTIM_PERIOD:
2430 if (value < 0 || value > 65535) {
2434 if (hostap_set_word(dev, HFA384X_RID_CNFOWNDTIMPERIOD, value)
2435 || local->func->reset_port(dev))
2438 local->dtim_period = value;
2441 case PRISM2_PARAM_AP_NULLFUNC_ACK:
2442 if (local->ap != NULL)
2443 local->ap->nullfunc_ack = value;
2446 case PRISM2_PARAM_MAX_WDS:
2447 local->wds_max_connections = value;
2450 case PRISM2_PARAM_AP_AUTOM_AP_WDS:
2451 if (local->ap != NULL) {
2452 if (!local->ap->autom_ap_wds && value) {
2453 /* add WDS link to all APs in STA table */
2454 hostap_add_wds_links(local);
2456 local->ap->autom_ap_wds = value;
2460 case PRISM2_PARAM_AP_AUTH_ALGS:
2461 local->auth_algs = value;
2462 if (hostap_set_auth_algs(local))
2466 case PRISM2_PARAM_MONITOR_ALLOW_FCSERR:
2467 local->monitor_allow_fcserr = value;
2470 case PRISM2_PARAM_HOST_ENCRYPT:
2471 local->host_encrypt = value;
2472 if (hostap_set_encryption(local) ||
2473 local->func->reset_port(dev))
2477 case PRISM2_PARAM_HOST_DECRYPT:
2478 local->host_decrypt = value;
2479 if (hostap_set_encryption(local) ||
2480 local->func->reset_port(dev))
2484 #ifndef PRISM2_NO_STATION_MODES
2485 case PRISM2_PARAM_HOST_ROAMING:
2486 if (value < 0 || value > 2) {
2490 local->host_roaming = value;
2491 if (hostap_set_roaming(local) || local->func->reset_port(dev))
2494 #endif /* PRISM2_NO_STATION_MODES */
2496 case PRISM2_PARAM_BCRX_STA_KEY:
2497 local->bcrx_sta_key = value;
2500 case PRISM2_PARAM_IEEE_802_1X:
2501 local->ieee_802_1x = value;
2504 case PRISM2_PARAM_ANTSEL_TX:
2505 if (value < 0 || value > HOSTAP_ANTSEL_HIGH) {
2509 local->antsel_tx = value;
2510 hostap_set_antsel(local);
2513 case PRISM2_PARAM_ANTSEL_RX:
2514 if (value < 0 || value > HOSTAP_ANTSEL_HIGH) {
2518 local->antsel_rx = value;
2519 hostap_set_antsel(local);
2522 case PRISM2_PARAM_MONITOR_TYPE:
2523 if (value != PRISM2_MONITOR_80211 &&
2524 value != PRISM2_MONITOR_CAPHDR &&
2525 value != PRISM2_MONITOR_PRISM) {
2529 local->monitor_type = value;
2530 if (local->iw_mode == IW_MODE_MONITOR)
2531 hostap_monitor_set_type(local);
2534 case PRISM2_PARAM_WDS_TYPE:
2535 local->wds_type = value;
2538 case PRISM2_PARAM_HOSTSCAN:
2540 struct hfa384x_hostscan_request scan_req;
2543 memset(&scan_req, 0, sizeof(scan_req));
2544 scan_req.channel_list = __constant_cpu_to_le16(0x3fff);
2546 case 1: rate = HFA384X_RATES_1MBPS; break;
2547 case 2: rate = HFA384X_RATES_2MBPS; break;
2548 case 3: rate = HFA384X_RATES_5MBPS; break;
2549 case 4: rate = HFA384X_RATES_11MBPS; break;
2550 default: rate = HFA384X_RATES_1MBPS; break;
2552 scan_req.txrate = cpu_to_le16(rate);
2553 /* leave SSID empty to accept all SSIDs */
2555 if (local->iw_mode == IW_MODE_MASTER) {
2556 if (hostap_set_word(dev, HFA384X_RID_CNFPORTTYPE,
2557 HFA384X_PORTTYPE_BSS) ||
2558 local->func->reset_port(dev))
2559 printk(KERN_DEBUG "Leaving Host AP mode "
2560 "for HostScan failed\n");
2563 if (local->func->set_rid(dev, HFA384X_RID_HOSTSCAN, &scan_req,
2564 sizeof(scan_req))) {
2565 printk(KERN_DEBUG "HOSTSCAN failed\n");
2568 if (local->iw_mode == IW_MODE_MASTER) {
2569 wait_queue_t __wait;
2570 init_waitqueue_entry(&__wait, current);
2571 add_wait_queue(&local->hostscan_wq, &__wait);
2572 set_current_state(TASK_INTERRUPTIBLE);
2573 schedule_timeout(HZ);
2574 if (signal_pending(current))
2576 set_current_state(TASK_RUNNING);
2577 remove_wait_queue(&local->hostscan_wq, &__wait);
2579 if (hostap_set_word(dev, HFA384X_RID_CNFPORTTYPE,
2580 HFA384X_PORTTYPE_HOSTAP) ||
2581 local->func->reset_port(dev))
2582 printk(KERN_DEBUG "Returning to Host AP mode "
2583 "after HostScan failed\n");
2588 case PRISM2_PARAM_AP_SCAN:
2589 local->passive_scan_interval = value;
2590 if (timer_pending(&local->passive_scan_timer))
2591 del_timer(&local->passive_scan_timer);
2593 local->passive_scan_timer.expires = jiffies +
2594 local->passive_scan_interval * HZ;
2595 add_timer(&local->passive_scan_timer);
2599 case PRISM2_PARAM_ENH_SEC:
2600 if (value < 0 || value > 3) {
2604 local->enh_sec = value;
2605 if (hostap_set_word(dev, HFA384X_RID_CNFENHSECURITY,
2607 local->func->reset_port(dev)) {
2608 printk(KERN_INFO "%s: cnfEnhSecurity requires STA f/w "
2609 "1.6.3 or newer\n", dev->name);
2614 #ifdef PRISM2_IO_DEBUG
2615 case PRISM2_PARAM_IO_DEBUG:
2616 local->io_debug_enabled = value;
2618 #endif /* PRISM2_IO_DEBUG */
2620 case PRISM2_PARAM_BASIC_RATES:
2621 if ((value & local->tx_rate_control) != value || value == 0) {
2622 printk(KERN_INFO "%s: invalid basic rate set - basic "
2623 "rates must be in supported rate set\n",
2628 local->basic_rates = value;
2629 if (hostap_set_word(dev, HFA384X_RID_CNFBASICRATES,
2630 local->basic_rates) ||
2631 local->func->reset_port(dev))
2635 case PRISM2_PARAM_OPER_RATES:
2636 local->tx_rate_control = value;
2637 if (hostap_set_rate(dev))
2641 case PRISM2_PARAM_HOSTAPD:
2642 ret = hostap_set_hostapd(local, value, 1);
2645 case PRISM2_PARAM_HOSTAPD_STA:
2646 ret = hostap_set_hostapd_sta(local, value, 1);
2649 case PRISM2_PARAM_WPA:
2651 if (local->sta_fw_ver < PRISM2_FW_VER(1,7,0))
2653 else if (hostap_set_word(dev, HFA384X_RID_SSNHANDLINGMODE,
2658 case PRISM2_PARAM_PRIVACY_INVOKED:
2659 local->privacy_invoked = value;
2660 if (hostap_set_encryption(local) ||
2661 local->func->reset_port(dev))
2665 case PRISM2_PARAM_TKIP_COUNTERMEASURES:
2666 local->tkip_countermeasures = value;
2669 case PRISM2_PARAM_DROP_UNENCRYPTED:
2670 local->drop_unencrypted = value;
2673 case PRISM2_PARAM_SCAN_CHANNEL_MASK:
2674 local->scan_channel_mask = value;
2678 printk(KERN_DEBUG "%s: prism2_param: unknown param %d\n",
2688 static int prism2_ioctl_priv_get_prism2_param(struct net_device *dev,
2689 struct iw_request_info *info,
2690 void *wrqu, char *extra)
2692 struct hostap_interface *iface;
2693 local_info_t *local;
2694 int *param = (int *) extra;
2697 iface = netdev_priv(dev);
2698 local = iface->local;
2701 case PRISM2_PARAM_TXRATECTRL:
2702 *param = local->fw_tx_rate_control;
2705 case PRISM2_PARAM_BEACON_INT:
2706 *param = local->beacon_int;
2709 case PRISM2_PARAM_PSEUDO_IBSS:
2710 *param = local->pseudo_adhoc;
2713 case PRISM2_PARAM_ALC:
2714 ret = -EOPNOTSUPP; /* FIX */
2717 case PRISM2_PARAM_DUMP:
2718 *param = local->frame_dump;
2721 case PRISM2_PARAM_OTHER_AP_POLICY:
2722 if (local->ap != NULL)
2723 *param = local->ap->ap_policy;
2728 case PRISM2_PARAM_AP_MAX_INACTIVITY:
2729 if (local->ap != NULL)
2730 *param = local->ap->max_inactivity / HZ;
2735 case PRISM2_PARAM_AP_BRIDGE_PACKETS:
2736 if (local->ap != NULL)
2737 *param = local->ap->bridge_packets;
2742 case PRISM2_PARAM_DTIM_PERIOD:
2743 *param = local->dtim_period;
2746 case PRISM2_PARAM_AP_NULLFUNC_ACK:
2747 if (local->ap != NULL)
2748 *param = local->ap->nullfunc_ack;
2753 case PRISM2_PARAM_MAX_WDS:
2754 *param = local->wds_max_connections;
2757 case PRISM2_PARAM_AP_AUTOM_AP_WDS:
2758 if (local->ap != NULL)
2759 *param = local->ap->autom_ap_wds;
2764 case PRISM2_PARAM_AP_AUTH_ALGS:
2765 *param = local->auth_algs;
2768 case PRISM2_PARAM_MONITOR_ALLOW_FCSERR:
2769 *param = local->monitor_allow_fcserr;
2772 case PRISM2_PARAM_HOST_ENCRYPT:
2773 *param = local->host_encrypt;
2776 case PRISM2_PARAM_HOST_DECRYPT:
2777 *param = local->host_decrypt;
2780 case PRISM2_PARAM_HOST_ROAMING:
2781 *param = local->host_roaming;
2784 case PRISM2_PARAM_BCRX_STA_KEY:
2785 *param = local->bcrx_sta_key;
2788 case PRISM2_PARAM_IEEE_802_1X:
2789 *param = local->ieee_802_1x;
2792 case PRISM2_PARAM_ANTSEL_TX:
2793 *param = local->antsel_tx;
2796 case PRISM2_PARAM_ANTSEL_RX:
2797 *param = local->antsel_rx;
2800 case PRISM2_PARAM_MONITOR_TYPE:
2801 *param = local->monitor_type;
2804 case PRISM2_PARAM_WDS_TYPE:
2805 *param = local->wds_type;
2808 case PRISM2_PARAM_HOSTSCAN:
2812 case PRISM2_PARAM_AP_SCAN:
2813 *param = local->passive_scan_interval;
2816 case PRISM2_PARAM_ENH_SEC:
2817 *param = local->enh_sec;
2820 #ifdef PRISM2_IO_DEBUG
2821 case PRISM2_PARAM_IO_DEBUG:
2822 *param = local->io_debug_enabled;
2824 #endif /* PRISM2_IO_DEBUG */
2826 case PRISM2_PARAM_BASIC_RATES:
2827 *param = local->basic_rates;
2830 case PRISM2_PARAM_OPER_RATES:
2831 *param = local->tx_rate_control;
2834 case PRISM2_PARAM_HOSTAPD:
2835 *param = local->hostapd;
2838 case PRISM2_PARAM_HOSTAPD_STA:
2839 *param = local->hostapd_sta;
2842 case PRISM2_PARAM_WPA:
2843 if (local->sta_fw_ver < PRISM2_FW_VER(1,7,0))
2845 *param = local->wpa;
2848 case PRISM2_PARAM_PRIVACY_INVOKED:
2849 *param = local->privacy_invoked;
2852 case PRISM2_PARAM_TKIP_COUNTERMEASURES:
2853 *param = local->tkip_countermeasures;
2856 case PRISM2_PARAM_DROP_UNENCRYPTED:
2857 *param = local->drop_unencrypted;
2860 case PRISM2_PARAM_SCAN_CHANNEL_MASK:
2861 *param = local->scan_channel_mask;
2865 printk(KERN_DEBUG "%s: get_prism2_param: unknown param %d\n",
2875 static int prism2_ioctl_priv_readmif(struct net_device *dev,
2876 struct iw_request_info *info,
2877 void *wrqu, char *extra)
2879 struct hostap_interface *iface;
2880 local_info_t *local;
2883 iface = netdev_priv(dev);
2884 local = iface->local;
2886 if (local->func->cmd(dev, HFA384X_CMDCODE_READMIF, *extra, NULL,
2896 static int prism2_ioctl_priv_writemif(struct net_device *dev,
2897 struct iw_request_info *info,
2898 void *wrqu, char *extra)
2900 struct hostap_interface *iface;
2901 local_info_t *local;
2904 iface = netdev_priv(dev);
2905 local = iface->local;
2909 if (local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF, cr, &val, NULL))
2916 static int prism2_ioctl_priv_monitor(struct net_device *dev, int *i)
2918 struct hostap_interface *iface;
2919 local_info_t *local;
2923 iface = netdev_priv(dev);
2924 local = iface->local;
2926 printk(KERN_DEBUG "%s: process %d (%s) used deprecated iwpriv monitor "
2927 "- update software to use iwconfig mode monitor\n",
2928 dev->name, current->pid, current->comm);
2930 /* Backward compatibility code - this can be removed at some point */
2933 /* Disable monitor mode - old mode was not saved, so go to
2935 mode = IW_MODE_MASTER;
2936 ret = prism2_ioctl_siwmode(dev, NULL, &mode, NULL);
2937 } else if (*i == 1) {
2938 /* netlink socket mode is not supported anymore since it did
2939 * not separate different devices from each other and was not
2940 * best method for delivering large amount of packets to
2943 } else if (*i == 2 || *i == 3) {
2946 local->monitor_type = PRISM2_MONITOR_80211;
2949 local->monitor_type = PRISM2_MONITOR_PRISM;
2952 mode = IW_MODE_MONITOR;
2953 ret = prism2_ioctl_siwmode(dev, NULL, &mode, NULL);
2954 hostap_monitor_mode_enable(local);
2962 static int prism2_ioctl_priv_reset(struct net_device *dev, int *i)
2964 struct hostap_interface *iface;
2965 local_info_t *local;
2967 iface = netdev_priv(dev);
2968 local = iface->local;
2970 printk(KERN_DEBUG "%s: manual reset request(%d)\n", dev->name, *i);
2973 /* Disable and enable card */
2974 local->func->hw_shutdown(dev, 1);
2975 local->func->hw_config(dev, 0);
2980 local->func->hw_reset(dev);
2984 /* Disable and enable port 0 */
2985 local->func->reset_port(dev);
2989 prism2_sta_deauth(local, WLAN_REASON_DEAUTH_LEAVING);
2990 if (local->func->cmd(dev, HFA384X_CMDCODE_DISABLE, 0, NULL,
2996 if (local->func->cmd(dev, HFA384X_CMDCODE_ENABLE, 0, NULL,
3002 printk(KERN_DEBUG "Unknown reset request %d\n", *i);
3010 static int prism2_ioctl_priv_set_rid_word(struct net_device *dev, int *i)
3013 int value = *(i + 1);
3015 printk(KERN_DEBUG "%s: Set RID[0x%X] = %d\n", dev->name, rid, value);
3017 if (hostap_set_word(dev, rid, value))
3024 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
3025 static int ap_mac_cmd_ioctl(local_info_t *local, int *cmd)
3030 case AP_MAC_CMD_POLICY_OPEN:
3031 local->ap->mac_restrictions.policy = MAC_POLICY_OPEN;
3033 case AP_MAC_CMD_POLICY_ALLOW:
3034 local->ap->mac_restrictions.policy = MAC_POLICY_ALLOW;
3036 case AP_MAC_CMD_POLICY_DENY:
3037 local->ap->mac_restrictions.policy = MAC_POLICY_DENY;
3039 case AP_MAC_CMD_FLUSH:
3040 ap_control_flush_macs(&local->ap->mac_restrictions);
3042 case AP_MAC_CMD_KICKALL:
3043 ap_control_kickall(local->ap);
3044 hostap_deauth_all_stas(local->dev, local->ap, 0);
3053 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
3056 #ifdef PRISM2_DOWNLOAD_SUPPORT
3057 static int prism2_ioctl_priv_download(local_info_t *local, struct iw_point *p)
3059 struct prism2_download_param *param;
3062 if (p->length < sizeof(struct prism2_download_param) ||
3063 p->length > 1024 || !p->pointer)
3066 param = (struct prism2_download_param *)
3067 kmalloc(p->length, GFP_KERNEL);
3071 if (copy_from_user(param, p->pointer, p->length)) {
3076 if (p->length < sizeof(struct prism2_download_param) +
3077 param->num_areas * sizeof(struct prism2_download_area)) {
3082 ret = local->func->download(local, param);
3088 #endif /* PRISM2_DOWNLOAD_SUPPORT */
3091 static int prism2_set_genericelement(struct net_device *dev, u8 *elem,
3094 struct hostap_interface *iface = dev->priv;
3095 local_info_t *local = iface->local;
3099 * Add 16-bit length in the beginning of the buffer because Prism2 RID
3102 buf = kmalloc(len + 2, GFP_KERNEL);
3106 *((u16 *) buf) = cpu_to_le16(len);
3107 memcpy(buf + 2, elem, len);
3109 kfree(local->generic_elem);
3110 local->generic_elem = buf;
3111 local->generic_elem_len = len + 2;
3113 return local->func->set_rid(local->dev, HFA384X_RID_GENERICELEMENT,
3118 static int prism2_ioctl_siwauth(struct net_device *dev,
3119 struct iw_request_info *info,
3120 struct iw_param *data, char *extra)
3122 struct hostap_interface *iface = dev->priv;
3123 local_info_t *local = iface->local;
3125 switch (data->flags & IW_AUTH_INDEX) {
3126 case IW_AUTH_WPA_VERSION:
3127 case IW_AUTH_CIPHER_PAIRWISE:
3128 case IW_AUTH_CIPHER_GROUP:
3129 case IW_AUTH_KEY_MGMT:
3131 * Host AP driver does not use these parameters and allows
3132 * wpa_supplicant to control them internally.
3135 case IW_AUTH_TKIP_COUNTERMEASURES:
3136 local->tkip_countermeasures = data->value;
3138 case IW_AUTH_DROP_UNENCRYPTED:
3139 local->drop_unencrypted = data->value;
3141 case IW_AUTH_80211_AUTH_ALG:
3142 local->auth_algs = data->value;
3144 case IW_AUTH_WPA_ENABLED:
3145 if (data->value == 0) {
3147 if (local->sta_fw_ver < PRISM2_FW_VER(1,7,0))
3149 prism2_set_genericelement(dev, "", 0);
3150 local->host_roaming = 0;
3151 local->privacy_invoked = 0;
3152 if (hostap_set_word(dev, HFA384X_RID_SSNHANDLINGMODE,
3154 hostap_set_roaming(local) ||
3155 hostap_set_encryption(local) ||
3156 local->func->reset_port(dev))
3160 if (local->sta_fw_ver < PRISM2_FW_VER(1,7,0))
3162 local->host_roaming = 2;
3163 local->privacy_invoked = 1;
3165 if (hostap_set_word(dev, HFA384X_RID_SSNHANDLINGMODE, 1) ||
3166 hostap_set_roaming(local) ||
3167 hostap_set_encryption(local) ||
3168 local->func->reset_port(dev))
3171 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
3172 local->ieee_802_1x = data->value;
3174 case IW_AUTH_PRIVACY_INVOKED:
3175 local->privacy_invoked = data->value;
3184 static int prism2_ioctl_giwauth(struct net_device *dev,
3185 struct iw_request_info *info,
3186 struct iw_param *data, char *extra)
3188 struct hostap_interface *iface = dev->priv;
3189 local_info_t *local = iface->local;
3191 switch (data->flags & IW_AUTH_INDEX) {
3192 case IW_AUTH_WPA_VERSION:
3193 case IW_AUTH_CIPHER_PAIRWISE:
3194 case IW_AUTH_CIPHER_GROUP:
3195 case IW_AUTH_KEY_MGMT:
3197 * Host AP driver does not use these parameters and allows
3198 * wpa_supplicant to control them internally.
3201 case IW_AUTH_TKIP_COUNTERMEASURES:
3202 data->value = local->tkip_countermeasures;
3204 case IW_AUTH_DROP_UNENCRYPTED:
3205 data->value = local->drop_unencrypted;
3207 case IW_AUTH_80211_AUTH_ALG:
3208 data->value = local->auth_algs;
3210 case IW_AUTH_WPA_ENABLED:
3211 data->value = local->wpa;
3213 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
3214 data->value = local->ieee_802_1x;
3223 static int prism2_ioctl_siwencodeext(struct net_device *dev,
3224 struct iw_request_info *info,
3225 struct iw_point *erq, char *extra)
3227 struct hostap_interface *iface = dev->priv;
3228 local_info_t *local = iface->local;
3229 struct iw_encode_ext *ext = (struct iw_encode_ext *) extra;
3231 struct ieee80211_crypto_ops *ops;
3232 struct ieee80211_crypt_data **crypt;
3235 const char *alg, *module;
3237 i = erq->flags & IW_ENCODE_INDEX;
3240 if (i < 1 || i > WEP_KEYS)
3241 i = local->tx_keyidx;
3244 if (i < 0 || i >= WEP_KEYS)
3247 addr = ext->addr.sa_data;
3248 if (addr[0] == 0xff && addr[1] == 0xff && addr[2] == 0xff &&
3249 addr[3] == 0xff && addr[4] == 0xff && addr[5] == 0xff) {
3251 crypt = &local->crypt[i];
3255 sta_ptr = ap_crypt_get_ptrs(local->ap, addr, 0, &crypt);
3256 if (sta_ptr == NULL) {
3257 if (local->iw_mode == IW_MODE_INFRA) {
3259 * TODO: add STA entry for the current AP so
3260 * that unicast key can be used. For now, this
3261 * is emulated by using default key idx 0.
3264 crypt = &local->crypt[i];
3270 if ((erq->flags & IW_ENCODE_DISABLED) ||
3271 ext->alg == IW_ENCODE_ALG_NONE) {
3273 prism2_crypt_delayed_deinit(local, crypt);
3278 case IW_ENCODE_ALG_WEP:
3280 module = "ieee80211_crypt_wep";
3282 case IW_ENCODE_ALG_TKIP:
3284 module = "ieee80211_crypt_tkip";
3286 case IW_ENCODE_ALG_CCMP:
3288 module = "ieee80211_crypt_ccmp";
3291 printk(KERN_DEBUG "%s: unsupported algorithm %d\n",
3292 local->dev->name, ext->alg);
3297 ops = ieee80211_get_crypto_ops(alg);
3299 request_module(module);
3300 ops = ieee80211_get_crypto_ops(alg);
3303 printk(KERN_DEBUG "%s: unknown crypto alg '%s'\n",
3304 local->dev->name, alg);
3309 if (sta_ptr || ext->alg != IW_ENCODE_ALG_WEP) {
3311 * Per station encryption and other than WEP algorithms
3312 * require host-based encryption, so force them on
3315 local->host_decrypt = local->host_encrypt = 1;
3318 if (*crypt == NULL || (*crypt)->ops != ops) {
3319 struct ieee80211_crypt_data *new_crypt;
3321 prism2_crypt_delayed_deinit(local, crypt);
3323 new_crypt = (struct ieee80211_crypt_data *)
3324 kmalloc(sizeof(struct ieee80211_crypt_data),
3326 if (new_crypt == NULL) {
3330 memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
3331 new_crypt->ops = ops;
3332 new_crypt->priv = new_crypt->ops->init(i);
3333 if (new_crypt->priv == NULL) {
3343 * TODO: if ext_flags does not have IW_ENCODE_EXT_RX_SEQ_VALID, the
3344 * existing seq# should not be changed.
3345 * TODO: if ext_flags has IW_ENCODE_EXT_TX_SEQ_VALID, next TX seq#
3346 * should be changed to something else than zero.
3348 if ((!(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) || ext->key_len > 0)
3349 && (*crypt)->ops->set_key &&
3350 (*crypt)->ops->set_key(ext->key, ext->key_len, ext->rx_seq,
3351 (*crypt)->priv) < 0) {
3352 printk(KERN_DEBUG "%s: key setting failed\n",
3358 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
3360 local->tx_keyidx = i;
3368 if (sta_ptr == NULL && ext->key_len > 0) {
3370 for (j = 0; j < WEP_KEYS; j++) {
3371 if (j != i && local->crypt[j]) {
3377 local->tx_keyidx = i;
3382 hostap_handle_sta_release(sta_ptr);
3384 local->open_wep = erq->flags & IW_ENCODE_OPEN;
3387 * Do not reset port0 if card is in Managed mode since resetting will
3388 * generate new IEEE 802.11 authentication which may end up in looping
3389 * with IEEE 802.1X. Prism2 documentation seem to require port reset
3390 * after WEP configuration. However, keys are apparently changed at
3391 * least in Managed mode.
3394 (hostap_set_encryption(local) ||
3395 (local->iw_mode != IW_MODE_INFRA &&
3396 local->func->reset_port(local->dev))))
3403 static int prism2_ioctl_giwencodeext(struct net_device *dev,
3404 struct iw_request_info *info,
3405 struct iw_point *erq, char *extra)
3407 struct hostap_interface *iface = dev->priv;
3408 local_info_t *local = iface->local;
3409 struct ieee80211_crypt_data **crypt;
3412 struct iw_encode_ext *ext = (struct iw_encode_ext *) extra;
3415 max_key_len = erq->length - sizeof(*ext);
3416 if (max_key_len < 0)
3419 i = erq->flags & IW_ENCODE_INDEX;
3420 if (i < 1 || i > WEP_KEYS)
3421 i = local->tx_keyidx;
3425 addr = ext->addr.sa_data;
3426 if (addr[0] == 0xff && addr[1] == 0xff && addr[2] == 0xff &&
3427 addr[3] == 0xff && addr[4] == 0xff && addr[5] == 0xff) {
3429 crypt = &local->crypt[i];
3432 sta_ptr = ap_crypt_get_ptrs(local->ap, addr, 0, &crypt);
3433 if (sta_ptr == NULL)
3437 memset(ext, 0, sizeof(*ext));
3439 if (*crypt == NULL || (*crypt)->ops == NULL) {
3440 ext->alg = IW_ENCODE_ALG_NONE;
3442 erq->flags |= IW_ENCODE_DISABLED;
3444 if (strcmp((*crypt)->ops->name, "WEP") == 0)
3445 ext->alg = IW_ENCODE_ALG_WEP;
3446 else if (strcmp((*crypt)->ops->name, "TKIP") == 0)
3447 ext->alg = IW_ENCODE_ALG_TKIP;
3448 else if (strcmp((*crypt)->ops->name, "CCMP") == 0)
3449 ext->alg = IW_ENCODE_ALG_CCMP;
3453 if ((*crypt)->ops->get_key) {
3455 (*crypt)->ops->get_key(ext->key,
3460 (ext->alg == IW_ENCODE_ALG_TKIP ||
3461 ext->alg == IW_ENCODE_ALG_CCMP))
3462 ext->ext_flags |= IW_ENCODE_EXT_TX_SEQ_VALID;
3467 hostap_handle_sta_release(sta_ptr);
3473 static int prism2_ioctl_set_encryption(local_info_t *local,
3474 struct prism2_hostapd_param *param,
3478 struct ieee80211_crypto_ops *ops;
3479 struct ieee80211_crypt_data **crypt;
3482 param->u.crypt.err = 0;
3483 param->u.crypt.alg[HOSTAP_CRYPT_ALG_NAME_LEN - 1] = '\0';
3486 (int) ((char *) param->u.crypt.key - (char *) param) +
3487 param->u.crypt.key_len)
3490 if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
3491 param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
3492 param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) {
3493 if (param->u.crypt.idx >= WEP_KEYS)
3496 crypt = &local->crypt[param->u.crypt.idx];
3498 if (param->u.crypt.idx)
3500 sta_ptr = ap_crypt_get_ptrs(
3501 local->ap, param->sta_addr,
3502 (param->u.crypt.flags & HOSTAP_CRYPT_FLAG_PERMANENT),
3505 if (sta_ptr == NULL) {
3506 param->u.crypt.err = HOSTAP_CRYPT_ERR_UNKNOWN_ADDR;
3511 if (strcmp(param->u.crypt.alg, "none") == 0) {
3513 prism2_crypt_delayed_deinit(local, crypt);
3517 ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
3518 if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) {
3519 request_module("ieee80211_crypt_wep");
3520 ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
3521 } else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) {
3522 request_module("ieee80211_crypt_tkip");
3523 ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
3524 } else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) {
3525 request_module("ieee80211_crypt_ccmp");
3526 ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
3529 printk(KERN_DEBUG "%s: unknown crypto alg '%s'\n",
3530 local->dev->name, param->u.crypt.alg);
3531 param->u.crypt.err = HOSTAP_CRYPT_ERR_UNKNOWN_ALG;
3536 /* station based encryption and other than WEP algorithms require
3537 * host-based encryption, so force them on automatically */
3538 local->host_decrypt = local->host_encrypt = 1;
3540 if (*crypt == NULL || (*crypt)->ops != ops) {
3541 struct ieee80211_crypt_data *new_crypt;
3543 prism2_crypt_delayed_deinit(local, crypt);
3545 new_crypt = (struct ieee80211_crypt_data *)
3546 kmalloc(sizeof(struct ieee80211_crypt_data),
3548 if (new_crypt == NULL) {
3552 memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data));
3553 new_crypt->ops = ops;
3554 new_crypt->priv = new_crypt->ops->init(param->u.crypt.idx);
3555 if (new_crypt->priv == NULL) {
3557 param->u.crypt.err =
3558 HOSTAP_CRYPT_ERR_CRYPT_INIT_FAILED;
3566 if ((!(param->u.crypt.flags & HOSTAP_CRYPT_FLAG_SET_TX_KEY) ||
3567 param->u.crypt.key_len > 0) && (*crypt)->ops->set_key &&
3568 (*crypt)->ops->set_key(param->u.crypt.key,
3569 param->u.crypt.key_len, param->u.crypt.seq,
3570 (*crypt)->priv) < 0) {
3571 printk(KERN_DEBUG "%s: key setting failed\n",
3573 param->u.crypt.err = HOSTAP_CRYPT_ERR_KEY_SET_FAILED;
3578 if (param->u.crypt.flags & HOSTAP_CRYPT_FLAG_SET_TX_KEY) {
3580 local->tx_keyidx = param->u.crypt.idx;
3581 else if (param->u.crypt.idx) {
3582 printk(KERN_DEBUG "%s: TX key idx setting failed\n",
3584 param->u.crypt.err =
3585 HOSTAP_CRYPT_ERR_TX_KEY_SET_FAILED;
3593 hostap_handle_sta_release(sta_ptr);
3595 /* Do not reset port0 if card is in Managed mode since resetting will
3596 * generate new IEEE 802.11 authentication which may end up in looping
3597 * with IEEE 802.1X. Prism2 documentation seem to require port reset
3598 * after WEP configuration. However, keys are apparently changed at
3599 * least in Managed mode. */
3601 (hostap_set_encryption(local) ||
3602 (local->iw_mode != IW_MODE_INFRA &&
3603 local->func->reset_port(local->dev)))) {
3604 param->u.crypt.err = HOSTAP_CRYPT_ERR_CARD_CONF_FAILED;
3612 static int prism2_ioctl_get_encryption(local_info_t *local,
3613 struct prism2_hostapd_param *param,
3616 struct ieee80211_crypt_data **crypt;
3620 param->u.crypt.err = 0;
3622 max_key_len = param_len -
3623 (int) ((char *) param->u.crypt.key - (char *) param);
3624 if (max_key_len < 0)
3627 if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
3628 param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
3629 param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) {
3631 if (param->u.crypt.idx >= WEP_KEYS)
3632 param->u.crypt.idx = local->tx_keyidx;
3633 crypt = &local->crypt[param->u.crypt.idx];
3635 param->u.crypt.idx = 0;
3636 sta_ptr = ap_crypt_get_ptrs(local->ap, param->sta_addr, 0,
3639 if (sta_ptr == NULL) {
3640 param->u.crypt.err = HOSTAP_CRYPT_ERR_UNKNOWN_ADDR;
3645 if (*crypt == NULL || (*crypt)->ops == NULL) {
3646 memcpy(param->u.crypt.alg, "none", 5);
3647 param->u.crypt.key_len = 0;
3648 param->u.crypt.idx = 0xff;
3650 strncpy(param->u.crypt.alg, (*crypt)->ops->name,
3651 HOSTAP_CRYPT_ALG_NAME_LEN);
3652 param->u.crypt.key_len = 0;
3654 memset(param->u.crypt.seq, 0, 8);
3655 if ((*crypt)->ops->get_key) {
3656 param->u.crypt.key_len =
3657 (*crypt)->ops->get_key(param->u.crypt.key,
3665 hostap_handle_sta_release(sta_ptr);
3671 static int prism2_ioctl_get_rid(local_info_t *local,
3672 struct prism2_hostapd_param *param,
3677 max_len = param_len - PRISM2_HOSTAPD_RID_HDR_LEN;
3681 res = local->func->get_rid(local->dev, param->u.rid.rid,
3682 param->u.rid.data, param->u.rid.len, 0);
3684 param->u.rid.len = res;
3692 static int prism2_ioctl_set_rid(local_info_t *local,
3693 struct prism2_hostapd_param *param,
3698 max_len = param_len - PRISM2_HOSTAPD_RID_HDR_LEN;
3699 if (max_len < 0 || max_len < param->u.rid.len)
3702 return local->func->set_rid(local->dev, param->u.rid.rid,
3703 param->u.rid.data, param->u.rid.len);
3707 static int prism2_ioctl_set_assoc_ap_addr(local_info_t *local,
3708 struct prism2_hostapd_param *param,
3711 printk(KERN_DEBUG "%ssta: associated as client with AP " MACSTR "\n",
3712 local->dev->name, MAC2STR(param->sta_addr));
3713 memcpy(local->assoc_ap_addr, param->sta_addr, ETH_ALEN);
3718 static int prism2_ioctl_siwgenie(struct net_device *dev,
3719 struct iw_request_info *info,
3720 struct iw_point *data, char *extra)
3722 return prism2_set_genericelement(dev, extra, data->length);
3726 static int prism2_ioctl_giwgenie(struct net_device *dev,
3727 struct iw_request_info *info,
3728 struct iw_point *data, char *extra)
3730 struct hostap_interface *iface = dev->priv;
3731 local_info_t *local = iface->local;
3732 int len = local->generic_elem_len - 2;
3734 if (len <= 0 || local->generic_elem == NULL) {
3739 if (data->length < len)
3743 memcpy(extra, local->generic_elem + 2, len);
3749 static int prism2_ioctl_set_generic_element(local_info_t *local,
3750 struct prism2_hostapd_param *param,
3755 len = param->u.generic_elem.len;
3756 max_len = param_len - PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN;
3757 if (max_len < 0 || max_len < len)
3760 return prism2_set_genericelement(local->dev,
3761 param->u.generic_elem.data, len);
3765 static int prism2_ioctl_siwmlme(struct net_device *dev,
3766 struct iw_request_info *info,
3767 struct iw_point *data, char *extra)
3769 struct hostap_interface *iface = dev->priv;
3770 local_info_t *local = iface->local;
3771 struct iw_mlme *mlme = (struct iw_mlme *) extra;
3774 reason = cpu_to_le16(mlme->reason_code);
3776 switch (mlme->cmd) {
3777 case IW_MLME_DEAUTH:
3778 return prism2_sta_send_mgmt(local, mlme->addr.sa_data,
3779 IEEE80211_STYPE_DEAUTH,
3781 case IW_MLME_DISASSOC:
3782 return prism2_sta_send_mgmt(local, mlme->addr.sa_data,
3783 IEEE80211_STYPE_DISASSOC,
3791 static int prism2_ioctl_mlme(local_info_t *local,
3792 struct prism2_hostapd_param *param)
3796 reason = cpu_to_le16(param->u.mlme.reason_code);
3797 switch (param->u.mlme.cmd) {
3798 case MLME_STA_DEAUTH:
3799 return prism2_sta_send_mgmt(local, param->sta_addr,
3800 IEEE80211_STYPE_DEAUTH,
3802 case MLME_STA_DISASSOC:
3803 return prism2_sta_send_mgmt(local, param->sta_addr,
3804 IEEE80211_STYPE_DISASSOC,
3812 static int prism2_ioctl_scan_req(local_info_t *local,
3813 struct prism2_hostapd_param *param)
3815 #ifndef PRISM2_NO_STATION_MODES
3816 if ((local->iw_mode != IW_MODE_INFRA &&
3817 local->iw_mode != IW_MODE_ADHOC) ||
3818 (local->sta_fw_ver < PRISM2_FW_VER(1,3,1)))
3821 if (!local->dev_enabled)
3824 return prism2_request_hostscan(local->dev, param->u.scan_req.ssid,
3825 param->u.scan_req.ssid_len);
3826 #else /* PRISM2_NO_STATION_MODES */
3828 #endif /* PRISM2_NO_STATION_MODES */
3832 static int prism2_ioctl_priv_hostapd(local_info_t *local, struct iw_point *p)
3834 struct prism2_hostapd_param *param;
3838 if (p->length < sizeof(struct prism2_hostapd_param) ||
3839 p->length > PRISM2_HOSTAPD_MAX_BUF_SIZE || !p->pointer)
3842 param = (struct prism2_hostapd_param *) kmalloc(p->length, GFP_KERNEL);
3846 if (copy_from_user(param, p->pointer, p->length)) {
3851 switch (param->cmd) {
3852 case PRISM2_SET_ENCRYPTION:
3853 ret = prism2_ioctl_set_encryption(local, param, p->length);
3855 case PRISM2_GET_ENCRYPTION:
3856 ret = prism2_ioctl_get_encryption(local, param, p->length);
3858 case PRISM2_HOSTAPD_GET_RID:
3859 ret = prism2_ioctl_get_rid(local, param, p->length);
3861 case PRISM2_HOSTAPD_SET_RID:
3862 ret = prism2_ioctl_set_rid(local, param, p->length);
3864 case PRISM2_HOSTAPD_SET_ASSOC_AP_ADDR:
3865 ret = prism2_ioctl_set_assoc_ap_addr(local, param, p->length);
3867 case PRISM2_HOSTAPD_SET_GENERIC_ELEMENT:
3868 ret = prism2_ioctl_set_generic_element(local, param,
3871 case PRISM2_HOSTAPD_MLME:
3872 ret = prism2_ioctl_mlme(local, param);
3874 case PRISM2_HOSTAPD_SCAN_REQ:
3875 ret = prism2_ioctl_scan_req(local, param);
3878 ret = prism2_hostapd(local->ap, param);
3883 if (ret == 1 || !ap_ioctl) {
3884 if (copy_to_user(p->pointer, param, p->length)) {
3887 } else if (ap_ioctl)
3897 static void prism2_get_drvinfo(struct net_device *dev,
3898 struct ethtool_drvinfo *info)
3900 struct hostap_interface *iface;
3901 local_info_t *local;
3903 iface = netdev_priv(dev);
3904 local = iface->local;
3906 strncpy(info->driver, "hostap", sizeof(info->driver) - 1);
3907 strncpy(info->version, PRISM2_VERSION,
3908 sizeof(info->version) - 1);
3909 snprintf(info->fw_version, sizeof(info->fw_version) - 1,
3910 "%d.%d.%d", (local->sta_fw_ver >> 16) & 0xff,
3911 (local->sta_fw_ver >> 8) & 0xff,
3912 local->sta_fw_ver & 0xff);
3915 struct ethtool_ops prism2_ethtool_ops = {
3916 .get_drvinfo = prism2_get_drvinfo
3920 /* Structures to export the Wireless Handlers */
3922 static const iw_handler prism2_handler[] =
3924 (iw_handler) NULL, /* SIOCSIWCOMMIT */
3925 (iw_handler) prism2_get_name, /* SIOCGIWNAME */
3926 (iw_handler) NULL, /* SIOCSIWNWID */
3927 (iw_handler) NULL, /* SIOCGIWNWID */
3928 (iw_handler) prism2_ioctl_siwfreq, /* SIOCSIWFREQ */
3929 (iw_handler) prism2_ioctl_giwfreq, /* SIOCGIWFREQ */
3930 (iw_handler) prism2_ioctl_siwmode, /* SIOCSIWMODE */
3931 (iw_handler) prism2_ioctl_giwmode, /* SIOCGIWMODE */
3932 (iw_handler) prism2_ioctl_siwsens, /* SIOCSIWSENS */
3933 (iw_handler) prism2_ioctl_giwsens, /* SIOCGIWSENS */
3934 (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
3935 (iw_handler) prism2_ioctl_giwrange, /* SIOCGIWRANGE */
3936 (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
3937 (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
3938 (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
3939 (iw_handler) NULL /* kernel code */, /* SIOCGIWSTATS */
3940 iw_handler_set_spy, /* SIOCSIWSPY */
3941 iw_handler_get_spy, /* SIOCGIWSPY */
3942 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
3943 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
3944 (iw_handler) prism2_ioctl_siwap, /* SIOCSIWAP */
3945 (iw_handler) prism2_ioctl_giwap, /* SIOCGIWAP */
3946 (iw_handler) prism2_ioctl_siwmlme, /* SIOCSIWMLME */
3947 (iw_handler) prism2_ioctl_giwaplist, /* SIOCGIWAPLIST */
3948 (iw_handler) prism2_ioctl_siwscan, /* SIOCSIWSCAN */
3949 (iw_handler) prism2_ioctl_giwscan, /* SIOCGIWSCAN */
3950 (iw_handler) prism2_ioctl_siwessid, /* SIOCSIWESSID */
3951 (iw_handler) prism2_ioctl_giwessid, /* SIOCGIWESSID */
3952 (iw_handler) prism2_ioctl_siwnickn, /* SIOCSIWNICKN */
3953 (iw_handler) prism2_ioctl_giwnickn, /* SIOCGIWNICKN */
3954 (iw_handler) NULL, /* -- hole -- */
3955 (iw_handler) NULL, /* -- hole -- */
3956 (iw_handler) prism2_ioctl_siwrate, /* SIOCSIWRATE */
3957 (iw_handler) prism2_ioctl_giwrate, /* SIOCGIWRATE */
3958 (iw_handler) prism2_ioctl_siwrts, /* SIOCSIWRTS */
3959 (iw_handler) prism2_ioctl_giwrts, /* SIOCGIWRTS */
3960 (iw_handler) prism2_ioctl_siwfrag, /* SIOCSIWFRAG */
3961 (iw_handler) prism2_ioctl_giwfrag, /* SIOCGIWFRAG */
3962 (iw_handler) prism2_ioctl_siwtxpow, /* SIOCSIWTXPOW */
3963 (iw_handler) prism2_ioctl_giwtxpow, /* SIOCGIWTXPOW */
3964 (iw_handler) prism2_ioctl_siwretry, /* SIOCSIWRETRY */
3965 (iw_handler) prism2_ioctl_giwretry, /* SIOCGIWRETRY */
3966 (iw_handler) prism2_ioctl_siwencode, /* SIOCSIWENCODE */
3967 (iw_handler) prism2_ioctl_giwencode, /* SIOCGIWENCODE */
3968 (iw_handler) prism2_ioctl_siwpower, /* SIOCSIWPOWER */
3969 (iw_handler) prism2_ioctl_giwpower, /* SIOCGIWPOWER */
3970 (iw_handler) NULL, /* -- hole -- */
3971 (iw_handler) NULL, /* -- hole -- */
3972 (iw_handler) prism2_ioctl_siwgenie, /* SIOCSIWGENIE */
3973 (iw_handler) prism2_ioctl_giwgenie, /* SIOCGIWGENIE */
3974 (iw_handler) prism2_ioctl_siwauth, /* SIOCSIWAUTH */
3975 (iw_handler) prism2_ioctl_giwauth, /* SIOCGIWAUTH */
3976 (iw_handler) prism2_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */
3977 (iw_handler) prism2_ioctl_giwencodeext, /* SIOCGIWENCODEEXT */
3978 (iw_handler) NULL, /* SIOCSIWPMKSA */
3979 (iw_handler) NULL, /* -- hole -- */
3982 static const iw_handler prism2_private_handler[] =
3983 { /* SIOCIWFIRSTPRIV + */
3984 (iw_handler) prism2_ioctl_priv_prism2_param, /* 0 */
3985 (iw_handler) prism2_ioctl_priv_get_prism2_param, /* 1 */
3986 (iw_handler) prism2_ioctl_priv_writemif, /* 2 */
3987 (iw_handler) prism2_ioctl_priv_readmif, /* 3 */
3990 const struct iw_handler_def hostap_iw_handler_def =
3992 .num_standard = sizeof(prism2_handler) / sizeof(iw_handler),
3993 .num_private = sizeof(prism2_private_handler) / sizeof(iw_handler),
3994 .num_private_args = sizeof(prism2_priv) / sizeof(struct iw_priv_args),
3995 .standard = (iw_handler *) prism2_handler,
3996 .private = (iw_handler *) prism2_private_handler,
3997 .private_args = (struct iw_priv_args *) prism2_priv,
3998 .get_wireless_stats = hostap_get_wireless_stats,
4002 int hostap_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
4004 struct iwreq *wrq = (struct iwreq *) ifr;
4005 struct hostap_interface *iface;
4006 local_info_t *local;
4009 iface = netdev_priv(dev);
4010 local = iface->local;
4013 /* Private ioctls (iwpriv) that have not yet been converted
4014 * into new wireless extensions API */
4016 case PRISM2_IOCTL_INQUIRE:
4017 if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
4018 else ret = prism2_ioctl_priv_inquire(dev, (int *) wrq->u.name);
4021 case PRISM2_IOCTL_MONITOR:
4022 if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
4023 else ret = prism2_ioctl_priv_monitor(dev, (int *) wrq->u.name);
4026 case PRISM2_IOCTL_RESET:
4027 if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
4028 else ret = prism2_ioctl_priv_reset(dev, (int *) wrq->u.name);
4031 case PRISM2_IOCTL_WDS_ADD:
4032 if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
4033 else ret = prism2_wds_add(local, wrq->u.ap_addr.sa_data, 1);
4036 case PRISM2_IOCTL_WDS_DEL:
4037 if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
4038 else ret = prism2_wds_del(local, wrq->u.ap_addr.sa_data, 1, 0);
4041 case PRISM2_IOCTL_SET_RID_WORD:
4042 if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
4043 else ret = prism2_ioctl_priv_set_rid_word(dev,
4044 (int *) wrq->u.name);
4047 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
4048 case PRISM2_IOCTL_MACCMD:
4049 if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
4050 else ret = ap_mac_cmd_ioctl(local, (int *) wrq->u.name);
4053 case PRISM2_IOCTL_ADDMAC:
4054 if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
4055 else ret = ap_control_add_mac(&local->ap->mac_restrictions,
4056 wrq->u.ap_addr.sa_data);
4058 case PRISM2_IOCTL_DELMAC:
4059 if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
4060 else ret = ap_control_del_mac(&local->ap->mac_restrictions,
4061 wrq->u.ap_addr.sa_data);
4063 case PRISM2_IOCTL_KICKMAC:
4064 if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
4065 else ret = ap_control_kick_mac(local->ap, local->dev,
4066 wrq->u.ap_addr.sa_data);
4068 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
4071 /* Private ioctls that are not used with iwpriv;
4072 * in SIOCDEVPRIVATE range */
4074 #ifdef PRISM2_DOWNLOAD_SUPPORT
4075 case PRISM2_IOCTL_DOWNLOAD:
4076 if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
4077 else ret = prism2_ioctl_priv_download(local, &wrq->u.data);
4079 #endif /* PRISM2_DOWNLOAD_SUPPORT */
4081 case PRISM2_IOCTL_HOSTAPD:
4082 if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
4083 else ret = prism2_ioctl_priv_hostapd(local, &wrq->u.data);