1 /* ioctl() (mostly Linux Wireless Extensions) routines for Host AP driver */
3 #include <linux/types.h>
4 #include <linux/ethtool.h>
5 #include <net/ieee80211_crypt.h>
7 #include "hostap_wlan.h"
11 static struct iw_statistics *hostap_get_wireless_stats(struct net_device *dev)
13 struct hostap_interface *iface;
15 struct iw_statistics *wstats;
17 iface = netdev_priv(dev);
20 /* Why are we doing that ? Jean II */
21 if (iface->type != HOSTAP_INTERFACE_MAIN)
24 wstats = &local->wstats;
27 wstats->discard.code =
28 local->comm_tallies.rx_discards_wep_undecryptable;
29 wstats->discard.misc =
30 local->comm_tallies.rx_fcs_errors +
31 local->comm_tallies.rx_discards_no_buffer +
32 local->comm_tallies.tx_discards_wrong_sa;
34 wstats->discard.retries =
35 local->comm_tallies.tx_retry_limit_exceeded;
36 wstats->discard.fragment =
37 local->comm_tallies.rx_message_in_bad_msg_fragments;
39 if (local->iw_mode != IW_MODE_MASTER &&
40 local->iw_mode != IW_MODE_REPEAT) {
43 /* RID reading might sleep and it must not be called in
44 * interrupt context or while atomic. However, this
45 * function seems to be called while atomic (at least in Linux
46 * 2.5.59). Update signal quality values only if in suitable
47 * context. Otherwise, previous values read from tick timer
51 #endif /* in_atomic */
53 if (update && prism2_update_comms_qual(dev) == 0)
54 wstats->qual.updated = IW_QUAL_ALL_UPDATED |
57 wstats->qual.qual = local->comms_qual;
58 wstats->qual.level = local->avg_signal;
59 wstats->qual.noise = local->avg_noise;
61 wstats->qual.qual = 0;
62 wstats->qual.level = 0;
63 wstats->qual.noise = 0;
64 wstats->qual.updated = IW_QUAL_ALL_INVALID;
71 static int prism2_get_datarates(struct net_device *dev, u8 *rates)
73 struct hostap_interface *iface;
79 iface = netdev_priv(dev);
82 len = local->func->get_rid(dev, HFA384X_RID_SUPPORTEDDATARATES, buf,
87 val = le16_to_cpu(*(__le16 *) buf); /* string length */
89 if (len - 2 < val || val > 10)
92 memcpy(rates, buf + 2, val);
97 static int prism2_get_name(struct net_device *dev,
98 struct iw_request_info *info,
99 char *name, char *extra)
102 int len, i, over2 = 0;
104 len = prism2_get_datarates(dev, rates);
106 for (i = 0; i < len; i++) {
107 if (rates[i] == 0x0b || rates[i] == 0x16) {
113 strcpy(name, over2 ? "IEEE 802.11b" : "IEEE 802.11-DS");
119 static void prism2_crypt_delayed_deinit(local_info_t *local,
120 struct ieee80211_crypt_data **crypt)
122 struct ieee80211_crypt_data *tmp;
131 /* must not run ops->deinit() while there may be pending encrypt or
132 * decrypt operations. Use a list of delayed deinits to avoid needing
135 spin_lock_irqsave(&local->lock, flags);
136 list_add(&tmp->list, &local->crypt_deinit_list);
137 if (!timer_pending(&local->crypt_deinit_timer)) {
138 local->crypt_deinit_timer.expires = jiffies + HZ;
139 add_timer(&local->crypt_deinit_timer);
141 spin_unlock_irqrestore(&local->lock, flags);
145 static int prism2_ioctl_siwencode(struct net_device *dev,
146 struct iw_request_info *info,
147 struct iw_point *erq, char *keybuf)
149 struct hostap_interface *iface;
152 struct ieee80211_crypt_data **crypt;
154 iface = netdev_priv(dev);
155 local = iface->local;
157 i = erq->flags & IW_ENCODE_INDEX;
159 i = local->tx_keyidx;
162 if (i < 0 || i >= WEP_KEYS)
165 crypt = &local->crypt[i];
167 if (erq->flags & IW_ENCODE_DISABLED) {
169 prism2_crypt_delayed_deinit(local, crypt);
173 if (*crypt != NULL && (*crypt)->ops != NULL &&
174 strcmp((*crypt)->ops->name, "WEP") != 0) {
175 /* changing to use WEP; deinit previously used algorithm */
176 prism2_crypt_delayed_deinit(local, crypt);
179 if (*crypt == NULL) {
180 struct ieee80211_crypt_data *new_crypt;
182 /* take WEP into use */
183 new_crypt = kzalloc(sizeof(struct ieee80211_crypt_data),
185 if (new_crypt == NULL)
187 new_crypt->ops = ieee80211_get_crypto_ops("WEP");
188 if (!new_crypt->ops) {
189 request_module("ieee80211_crypt_wep");
190 new_crypt->ops = ieee80211_get_crypto_ops("WEP");
193 new_crypt->priv = new_crypt->ops->init(i);
194 if (!new_crypt->ops || !new_crypt->priv) {
198 printk(KERN_WARNING "%s: could not initialize WEP: "
199 "load module hostap_crypt_wep.o\n",
206 if (erq->length > 0) {
207 int len = erq->length <= 5 ? 5 : 13;
209 if (len > erq->length)
210 memset(keybuf + erq->length, 0, len - erq->length);
211 (*crypt)->ops->set_key(keybuf, len, NULL, (*crypt)->priv);
212 for (j = 0; j < WEP_KEYS; j++) {
213 if (j != i && local->crypt[j]) {
219 local->tx_keyidx = i;
221 /* No key data - just set the default TX key index */
222 local->tx_keyidx = i;
226 local->open_wep = erq->flags & IW_ENCODE_OPEN;
228 if (hostap_set_encryption(local)) {
229 printk(KERN_DEBUG "%s: set_encryption failed\n", dev->name);
233 /* Do not reset port0 if card is in Managed mode since resetting will
234 * generate new IEEE 802.11 authentication which may end up in looping
235 * with IEEE 802.1X. Prism2 documentation seem to require port reset
236 * after WEP configuration. However, keys are apparently changed at
237 * least in Managed mode. */
238 if (local->iw_mode != IW_MODE_INFRA && local->func->reset_port(dev)) {
239 printk(KERN_DEBUG "%s: reset_port failed\n", dev->name);
247 static int prism2_ioctl_giwencode(struct net_device *dev,
248 struct iw_request_info *info,
249 struct iw_point *erq, char *key)
251 struct hostap_interface *iface;
255 struct ieee80211_crypt_data *crypt;
257 iface = netdev_priv(dev);
258 local = iface->local;
260 i = erq->flags & IW_ENCODE_INDEX;
262 i = local->tx_keyidx;
265 if (i < 0 || i >= WEP_KEYS)
268 crypt = local->crypt[i];
271 if (crypt == NULL || crypt->ops == NULL) {
273 erq->flags |= IW_ENCODE_DISABLED;
277 if (strcmp(crypt->ops->name, "WEP") != 0) {
278 /* only WEP is supported with wireless extensions, so just
279 * report that encryption is used */
281 erq->flags |= IW_ENCODE_ENABLED;
285 /* Reads from HFA384X_RID_CNFDEFAULTKEY* return bogus values, so show
286 * the keys from driver buffer */
287 len = crypt->ops->get_key(key, WEP_KEY_LEN, NULL, crypt->priv);
288 erq->length = (len >= 0 ? len : 0);
290 if (local->func->get_rid(dev, HFA384X_RID_CNFWEPFLAGS, &val, 2, 1) < 0)
292 printk("CNFWEPFLAGS reading failed\n");
296 if (val & HFA384X_WEPFLAGS_PRIVACYINVOKED)
297 erq->flags |= IW_ENCODE_ENABLED;
299 erq->flags |= IW_ENCODE_DISABLED;
300 if (val & HFA384X_WEPFLAGS_EXCLUDEUNENCRYPTED)
301 erq->flags |= IW_ENCODE_RESTRICTED;
303 erq->flags |= IW_ENCODE_OPEN;
309 static int hostap_set_rate(struct net_device *dev)
311 struct hostap_interface *iface;
313 int ret, basic_rates;
315 iface = netdev_priv(dev);
316 local = iface->local;
318 basic_rates = local->basic_rates & local->tx_rate_control;
319 if (!basic_rates || basic_rates != local->basic_rates) {
320 printk(KERN_INFO "%s: updating basic rate set automatically "
321 "to match with the new supported rate set\n",
324 basic_rates = local->tx_rate_control;
326 local->basic_rates = basic_rates;
327 if (hostap_set_word(dev, HFA384X_RID_CNFBASICRATES,
329 printk(KERN_WARNING "%s: failed to set "
330 "cnfBasicRates\n", dev->name);
333 ret = (hostap_set_word(dev, HFA384X_RID_TXRATECONTROL,
334 local->tx_rate_control) ||
335 hostap_set_word(dev, HFA384X_RID_CNFSUPPORTEDRATES,
336 local->tx_rate_control) ||
337 local->func->reset_port(dev));
340 printk(KERN_WARNING "%s: TXRateControl/cnfSupportedRates "
341 "setting to 0x%x failed\n",
342 dev->name, local->tx_rate_control);
345 /* Update TX rate configuration for all STAs based on new operational
347 hostap_update_rates(local);
353 static int prism2_ioctl_siwrate(struct net_device *dev,
354 struct iw_request_info *info,
355 struct iw_param *rrq, char *extra)
357 struct hostap_interface *iface;
360 iface = netdev_priv(dev);
361 local = iface->local;
364 switch (rrq->value) {
366 local->tx_rate_control = HFA384X_RATES_11MBPS;
369 local->tx_rate_control = HFA384X_RATES_5MBPS;
372 local->tx_rate_control = HFA384X_RATES_2MBPS;
375 local->tx_rate_control = HFA384X_RATES_1MBPS;
378 local->tx_rate_control = HFA384X_RATES_1MBPS |
379 HFA384X_RATES_2MBPS | HFA384X_RATES_5MBPS |
380 HFA384X_RATES_11MBPS;
384 switch (rrq->value) {
386 local->tx_rate_control = HFA384X_RATES_1MBPS |
387 HFA384X_RATES_2MBPS | HFA384X_RATES_5MBPS |
388 HFA384X_RATES_11MBPS;
391 local->tx_rate_control = HFA384X_RATES_1MBPS |
392 HFA384X_RATES_2MBPS | HFA384X_RATES_5MBPS;
395 local->tx_rate_control = HFA384X_RATES_1MBPS |
399 local->tx_rate_control = HFA384X_RATES_1MBPS;
402 local->tx_rate_control = HFA384X_RATES_1MBPS |
403 HFA384X_RATES_2MBPS | HFA384X_RATES_5MBPS |
404 HFA384X_RATES_11MBPS;
409 return hostap_set_rate(dev);
413 static int prism2_ioctl_giwrate(struct net_device *dev,
414 struct iw_request_info *info,
415 struct iw_param *rrq, char *extra)
418 struct hostap_interface *iface;
422 iface = netdev_priv(dev);
423 local = iface->local;
425 if (local->func->get_rid(dev, HFA384X_RID_TXRATECONTROL, &val, 2, 1) <
429 if ((val & 0x1) && (val > 1))
434 if (local->iw_mode == IW_MODE_MASTER && local->ap != NULL &&
435 !local->fw_tx_rate_control) {
436 /* HFA384X_RID_CURRENTTXRATE seems to always be 2 Mbps in
437 * Host AP mode, so use the recorded TX rate of the last sent
439 rrq->value = local->ap->last_tx_rate > 0 ?
440 local->ap->last_tx_rate * 100000 : 11000000;
444 if (local->func->get_rid(dev, HFA384X_RID_CURRENTTXRATE, &val, 2, 1) <
449 case HFA384X_RATES_1MBPS:
450 rrq->value = 1000000;
452 case HFA384X_RATES_2MBPS:
453 rrq->value = 2000000;
455 case HFA384X_RATES_5MBPS:
456 rrq->value = 5500000;
458 case HFA384X_RATES_11MBPS:
459 rrq->value = 11000000;
462 /* should not happen */
463 rrq->value = 11000000;
472 static int prism2_ioctl_siwsens(struct net_device *dev,
473 struct iw_request_info *info,
474 struct iw_param *sens, char *extra)
476 struct hostap_interface *iface;
479 iface = netdev_priv(dev);
480 local = iface->local;
482 /* Set the desired AP density */
483 if (sens->value < 1 || sens->value > 3)
486 if (hostap_set_word(dev, HFA384X_RID_CNFSYSTEMSCALE, sens->value) ||
487 local->func->reset_port(dev))
493 static int prism2_ioctl_giwsens(struct net_device *dev,
494 struct iw_request_info *info,
495 struct iw_param *sens, char *extra)
497 struct hostap_interface *iface;
501 iface = netdev_priv(dev);
502 local = iface->local;
504 /* Get the current AP density */
505 if (local->func->get_rid(dev, HFA384X_RID_CNFSYSTEMSCALE, &val, 2, 1) <
509 sens->value = le16_to_cpu(val);
516 /* Deprecated in new wireless extension API */
517 static int prism2_ioctl_giwaplist(struct net_device *dev,
518 struct iw_request_info *info,
519 struct iw_point *data, char *extra)
521 struct hostap_interface *iface;
523 struct sockaddr *addr;
524 struct iw_quality *qual;
526 iface = netdev_priv(dev);
527 local = iface->local;
529 if (local->iw_mode != IW_MODE_MASTER) {
530 printk(KERN_DEBUG "SIOCGIWAPLIST is currently only supported "
531 "in Host AP mode\n");
536 addr = kmalloc(sizeof(struct sockaddr) * IW_MAX_AP, GFP_KERNEL);
537 qual = kmalloc(sizeof(struct iw_quality) * IW_MAX_AP, GFP_KERNEL);
538 if (addr == NULL || qual == NULL) {
545 data->length = prism2_ap_get_sta_qual(local, addr, qual, IW_MAX_AP, 1);
547 memcpy(extra, &addr, sizeof(struct sockaddr) * data->length);
548 data->flags = 1; /* has quality information */
549 memcpy(extra + sizeof(struct sockaddr) * data->length, &qual,
550 sizeof(struct iw_quality) * data->length);
558 static int prism2_ioctl_siwrts(struct net_device *dev,
559 struct iw_request_info *info,
560 struct iw_param *rts, char *extra)
562 struct hostap_interface *iface;
566 iface = netdev_priv(dev);
567 local = iface->local;
570 val = cpu_to_le16(2347);
571 else if (rts->value < 0 || rts->value > 2347)
574 val = cpu_to_le16(rts->value);
576 if (local->func->set_rid(dev, HFA384X_RID_RTSTHRESHOLD, &val, 2) ||
577 local->func->reset_port(dev))
580 local->rts_threshold = rts->value;
585 static int prism2_ioctl_giwrts(struct net_device *dev,
586 struct iw_request_info *info,
587 struct iw_param *rts, char *extra)
589 struct hostap_interface *iface;
593 iface = netdev_priv(dev);
594 local = iface->local;
596 if (local->func->get_rid(dev, HFA384X_RID_RTSTHRESHOLD, &val, 2, 1) <
600 rts->value = le16_to_cpu(val);
601 rts->disabled = (rts->value == 2347);
608 static int prism2_ioctl_siwfrag(struct net_device *dev,
609 struct iw_request_info *info,
610 struct iw_param *rts, char *extra)
612 struct hostap_interface *iface;
616 iface = netdev_priv(dev);
617 local = iface->local;
620 val = cpu_to_le16(2346);
621 else if (rts->value < 256 || rts->value > 2346)
624 val = cpu_to_le16(rts->value & ~0x1); /* even numbers only */
626 local->fragm_threshold = rts->value & ~0x1;
627 if (local->func->set_rid(dev, HFA384X_RID_FRAGMENTATIONTHRESHOLD, &val,
629 || local->func->reset_port(dev))
635 static int prism2_ioctl_giwfrag(struct net_device *dev,
636 struct iw_request_info *info,
637 struct iw_param *rts, char *extra)
639 struct hostap_interface *iface;
643 iface = netdev_priv(dev);
644 local = iface->local;
646 if (local->func->get_rid(dev, HFA384X_RID_FRAGMENTATIONTHRESHOLD,
650 rts->value = le16_to_cpu(val);
651 rts->disabled = (rts->value == 2346);
658 #ifndef PRISM2_NO_STATION_MODES
659 static int hostap_join_ap(struct net_device *dev)
661 struct hostap_interface *iface;
663 struct hfa384x_join_request req;
666 struct hfa384x_hostscan_result *entry;
667 DECLARE_MAC_BUF(mac);
669 iface = netdev_priv(dev);
670 local = iface->local;
672 memcpy(req.bssid, local->preferred_ap, ETH_ALEN);
675 spin_lock_irqsave(&local->lock, flags);
676 for (i = 0; i < local->last_scan_results_count; i++) {
677 if (!local->last_scan_results)
679 entry = &local->last_scan_results[i];
680 if (memcmp(local->preferred_ap, entry->bssid, ETH_ALEN) == 0) {
681 req.channel = entry->chid;
685 spin_unlock_irqrestore(&local->lock, flags);
687 if (local->func->set_rid(dev, HFA384X_RID_JOINREQUEST, &req,
689 printk(KERN_DEBUG "%s: JoinRequest %s"
691 dev->name, print_mac(mac, local->preferred_ap));
695 printk(KERN_DEBUG "%s: Trying to join BSSID %s\n",
696 dev->name, print_mac(mac, local->preferred_ap));
700 #endif /* PRISM2_NO_STATION_MODES */
703 static int prism2_ioctl_siwap(struct net_device *dev,
704 struct iw_request_info *info,
705 struct sockaddr *ap_addr, char *extra)
707 #ifdef PRISM2_NO_STATION_MODES
709 #else /* PRISM2_NO_STATION_MODES */
710 struct hostap_interface *iface;
713 iface = netdev_priv(dev);
714 local = iface->local;
716 memcpy(local->preferred_ap, &ap_addr->sa_data, ETH_ALEN);
718 if (local->host_roaming == 1 && local->iw_mode == IW_MODE_INFRA) {
719 struct hfa384x_scan_request scan_req;
720 memset(&scan_req, 0, sizeof(scan_req));
721 scan_req.channel_list = cpu_to_le16(0x3fff);
722 scan_req.txrate = cpu_to_le16(HFA384X_RATES_1MBPS);
723 if (local->func->set_rid(dev, HFA384X_RID_SCANREQUEST,
724 &scan_req, sizeof(scan_req))) {
725 printk(KERN_DEBUG "%s: ScanResults request failed - "
726 "preferred AP delayed to next unsolicited "
727 "scan\n", dev->name);
729 } else if (local->host_roaming == 2 &&
730 local->iw_mode == IW_MODE_INFRA) {
731 if (hostap_join_ap(dev))
734 printk(KERN_DEBUG "%s: Preferred AP (SIOCSIWAP) is used only "
735 "in Managed mode when host_roaming is enabled\n",
740 #endif /* PRISM2_NO_STATION_MODES */
743 static int prism2_ioctl_giwap(struct net_device *dev,
744 struct iw_request_info *info,
745 struct sockaddr *ap_addr, char *extra)
747 struct hostap_interface *iface;
750 iface = netdev_priv(dev);
751 local = iface->local;
753 ap_addr->sa_family = ARPHRD_ETHER;
754 switch (iface->type) {
755 case HOSTAP_INTERFACE_AP:
756 memcpy(&ap_addr->sa_data, dev->dev_addr, ETH_ALEN);
758 case HOSTAP_INTERFACE_STA:
759 memcpy(&ap_addr->sa_data, local->assoc_ap_addr, ETH_ALEN);
761 case HOSTAP_INTERFACE_WDS:
762 memcpy(&ap_addr->sa_data, iface->u.wds.remote_addr, ETH_ALEN);
765 if (local->func->get_rid(dev, HFA384X_RID_CURRENTBSSID,
766 &ap_addr->sa_data, ETH_ALEN, 1) < 0)
769 /* local->bssid is also updated in LinkStatus handler when in
771 memcpy(local->bssid, &ap_addr->sa_data, ETH_ALEN);
779 static int prism2_ioctl_siwnickn(struct net_device *dev,
780 struct iw_request_info *info,
781 struct iw_point *data, char *nickname)
783 struct hostap_interface *iface;
786 iface = netdev_priv(dev);
787 local = iface->local;
789 memset(local->name, 0, sizeof(local->name));
790 memcpy(local->name, nickname, data->length);
793 if (hostap_set_string(dev, HFA384X_RID_CNFOWNNAME, local->name) ||
794 local->func->reset_port(dev))
800 static int prism2_ioctl_giwnickn(struct net_device *dev,
801 struct iw_request_info *info,
802 struct iw_point *data, char *nickname)
804 struct hostap_interface *iface;
807 char name[MAX_NAME_LEN + 3];
810 iface = netdev_priv(dev);
811 local = iface->local;
813 len = local->func->get_rid(dev, HFA384X_RID_CNFOWNNAME,
814 &name, MAX_NAME_LEN + 2, 0);
815 val = le16_to_cpu(*(__le16 *) name);
816 if (len > MAX_NAME_LEN + 2 || len < 0 || val > MAX_NAME_LEN)
819 name[val + 2] = '\0';
820 data->length = val + 1;
821 memcpy(nickname, name + 2, val + 1);
827 static int prism2_ioctl_siwfreq(struct net_device *dev,
828 struct iw_request_info *info,
829 struct iw_freq *freq, char *extra)
831 struct hostap_interface *iface;
834 iface = netdev_priv(dev);
835 local = iface->local;
839 freq->m / 100000 >= freq_list[0] &&
840 freq->m / 100000 <= freq_list[FREQ_COUNT - 1]) {
842 int fr = freq->m / 100000;
843 for (ch = 0; ch < FREQ_COUNT; ch++) {
844 if (fr == freq_list[ch]) {
852 if (freq->e != 0 || freq->m < 1 || freq->m > FREQ_COUNT ||
853 !(local->channel_mask & (1 << (freq->m - 1))))
856 local->channel = freq->m; /* channel is used in prism2_setup_rids() */
857 if (hostap_set_word(dev, HFA384X_RID_CNFOWNCHANNEL, local->channel) ||
858 local->func->reset_port(dev))
864 static int prism2_ioctl_giwfreq(struct net_device *dev,
865 struct iw_request_info *info,
866 struct iw_freq *freq, char *extra)
868 struct hostap_interface *iface;
872 iface = netdev_priv(dev);
873 local = iface->local;
875 if (local->func->get_rid(dev, HFA384X_RID_CURRENTCHANNEL, &val, 2, 1) <
880 if (val < 1 || val > FREQ_COUNT)
883 freq->m = freq_list[val - 1] * 100000;
890 static void hostap_monitor_set_type(local_info_t *local)
892 struct net_device *dev = local->ddev;
897 if (local->monitor_type == PRISM2_MONITOR_PRISM ||
898 local->monitor_type == PRISM2_MONITOR_CAPHDR) {
899 dev->type = ARPHRD_IEEE80211_PRISM;
900 } else if (local->monitor_type == PRISM2_MONITOR_RADIOTAP) {
901 dev->type = ARPHRD_IEEE80211_RADIOTAP;
903 dev->type = ARPHRD_IEEE80211;
908 static int prism2_ioctl_siwessid(struct net_device *dev,
909 struct iw_request_info *info,
910 struct iw_point *data, char *ssid)
912 struct hostap_interface *iface;
915 iface = netdev_priv(dev);
916 local = iface->local;
918 if (iface->type == HOSTAP_INTERFACE_WDS)
921 if (data->flags == 0)
922 ssid[0] = '\0'; /* ANY */
924 if (local->iw_mode == IW_MODE_MASTER && ssid[0] == '\0') {
925 /* Setting SSID to empty string seems to kill the card in
927 printk(KERN_DEBUG "%s: Host AP mode does not support "
928 "'Any' essid\n", dev->name);
932 memcpy(local->essid, ssid, data->length);
933 local->essid[data->length] = '\0';
935 if ((!local->fw_ap &&
936 hostap_set_string(dev, HFA384X_RID_CNFDESIREDSSID, local->essid))
937 || hostap_set_string(dev, HFA384X_RID_CNFOWNSSID, local->essid) ||
938 local->func->reset_port(dev))
944 static int prism2_ioctl_giwessid(struct net_device *dev,
945 struct iw_request_info *info,
946 struct iw_point *data, char *essid)
948 struct hostap_interface *iface;
952 iface = netdev_priv(dev);
953 local = iface->local;
955 if (iface->type == HOSTAP_INTERFACE_WDS)
958 data->flags = 1; /* active */
959 if (local->iw_mode == IW_MODE_MASTER) {
960 data->length = strlen(local->essid);
961 memcpy(essid, local->essid, IW_ESSID_MAX_SIZE);
964 char ssid[MAX_SSID_LEN + 2];
965 memset(ssid, 0, sizeof(ssid));
966 len = local->func->get_rid(dev, HFA384X_RID_CURRENTSSID,
967 &ssid, MAX_SSID_LEN + 2, 0);
968 val = le16_to_cpu(*(__le16 *) ssid);
969 if (len > MAX_SSID_LEN + 2 || len < 0 || val > MAX_SSID_LEN) {
973 memcpy(essid, ssid + 2, IW_ESSID_MAX_SIZE);
980 static int prism2_ioctl_giwrange(struct net_device *dev,
981 struct iw_request_info *info,
982 struct iw_point *data, char *extra)
984 struct hostap_interface *iface;
986 struct iw_range *range = (struct iw_range *) extra;
991 iface = netdev_priv(dev);
992 local = iface->local;
994 data->length = sizeof(struct iw_range);
995 memset(range, 0, sizeof(struct iw_range));
997 /* TODO: could fill num_txpower and txpower array with
998 * something; however, there are 128 different values.. */
1000 range->txpower_capa = IW_TXPOW_DBM;
1002 if (local->iw_mode == IW_MODE_INFRA || local->iw_mode == IW_MODE_ADHOC)
1004 range->min_pmp = 1 * 1024;
1005 range->max_pmp = 65535 * 1024;
1006 range->min_pmt = 1 * 1024;
1007 range->max_pmt = 1000 * 1024;
1008 range->pmp_flags = IW_POWER_PERIOD;
1009 range->pmt_flags = IW_POWER_TIMEOUT;
1010 range->pm_capa = IW_POWER_PERIOD | IW_POWER_TIMEOUT |
1011 IW_POWER_UNICAST_R | IW_POWER_ALL_R;
1014 range->we_version_compiled = WIRELESS_EXT;
1015 range->we_version_source = 18;
1017 range->retry_capa = IW_RETRY_LIMIT;
1018 range->retry_flags = IW_RETRY_LIMIT;
1019 range->min_retry = 0;
1020 range->max_retry = 255;
1022 range->num_channels = FREQ_COUNT;
1025 for (i = 0; i < FREQ_COUNT; i++) {
1026 if (local->channel_mask & (1 << i)) {
1027 range->freq[val].i = i + 1;
1028 range->freq[val].m = freq_list[i] * 100000;
1029 range->freq[val].e = 1;
1032 if (val == IW_MAX_FREQUENCIES)
1035 range->num_frequency = val;
1037 if (local->sta_fw_ver >= PRISM2_FW_VER(1,3,1)) {
1038 range->max_qual.qual = 70; /* what is correct max? This was not
1039 * documented exactly. At least
1040 * 69 has been observed. */
1041 range->max_qual.level = 0; /* dB */
1042 range->max_qual.noise = 0; /* dB */
1044 /* What would be suitable values for "average/typical" qual? */
1045 range->avg_qual.qual = 20;
1046 range->avg_qual.level = -60;
1047 range->avg_qual.noise = -95;
1049 range->max_qual.qual = 92; /* 0 .. 92 */
1050 range->max_qual.level = 154; /* 27 .. 154 */
1051 range->max_qual.noise = 154; /* 27 .. 154 */
1053 range->sensitivity = 3;
1055 range->max_encoding_tokens = WEP_KEYS;
1056 range->num_encoding_sizes = 2;
1057 range->encoding_size[0] = 5;
1058 range->encoding_size[1] = 13;
1061 len = prism2_get_datarates(dev, rates);
1062 range->num_bitrates = 0;
1063 for (i = 0; i < len; i++) {
1064 if (range->num_bitrates < IW_MAX_BITRATES) {
1065 range->bitrate[range->num_bitrates] =
1067 range->num_bitrates++;
1069 if (rates[i] == 0x0b || rates[i] == 0x16)
1072 /* estimated maximum TCP throughput values (bps) */
1073 range->throughput = over2 ? 5500000 : 1500000;
1076 range->max_rts = 2347;
1077 range->min_frag = 256;
1078 range->max_frag = 2346;
1080 /* Event capability (kernel + driver) */
1081 range->event_capa[0] = (IW_EVENT_CAPA_K_0 |
1082 IW_EVENT_CAPA_MASK(SIOCGIWTHRSPY) |
1083 IW_EVENT_CAPA_MASK(SIOCGIWAP) |
1084 IW_EVENT_CAPA_MASK(SIOCGIWSCAN));
1085 range->event_capa[1] = IW_EVENT_CAPA_K_1;
1086 range->event_capa[4] = (IW_EVENT_CAPA_MASK(IWEVTXDROP) |
1087 IW_EVENT_CAPA_MASK(IWEVCUSTOM) |
1088 IW_EVENT_CAPA_MASK(IWEVREGISTERED) |
1089 IW_EVENT_CAPA_MASK(IWEVEXPIRED));
1091 range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 |
1092 IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP;
1094 if (local->sta_fw_ver >= PRISM2_FW_VER(1,3,1))
1095 range->scan_capa = IW_SCAN_CAPA_ESSID;
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;
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;
1324 __le16 enable, mcast;
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_LONG)
1416 HFA384X_RID_LONGRETRYLIMIT = rrq->value;
1417 else if (rrq->flags & IW_RETRY_SHORT)
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 __le16 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)
1455 if ((rrq->flags & IW_RETRY_TYPE) == IW_RETRY_LIFETIME) {
1456 rrq->flags = IW_RETRY_LIFETIME;
1457 rrq->value = le16_to_cpu(lifetime) * 1024;
1459 if (local->manual_retry_count >= 0) {
1460 rrq->flags = IW_RETRY_LIMIT;
1461 if (local->func->get_rid(dev,
1462 HFA384X_RID_CNFALTRETRYCOUNT,
1463 &altretry, 2, 1) >= 0)
1464 rrq->value = le16_to_cpu(altretry);
1466 rrq->value = local->manual_retry_count;
1467 } else if ((rrq->flags & IW_RETRY_LONG)) {
1468 rrq->flags = IW_RETRY_LIMIT | IW_RETRY_LONG;
1469 rrq->value = le16_to_cpu(longretry);
1471 rrq->flags = IW_RETRY_LIMIT;
1472 rrq->value = le16_to_cpu(shortretry);
1473 if (shortretry != longretry)
1474 rrq->flags |= IW_RETRY_SHORT;
1481 /* Note! This TX power controlling is experimental and should not be used in
1482 * production use. It just sets raw power register and does not use any kind of
1483 * feedback information from the measured TX power (CR58). This is now
1484 * commented out to make sure that it is not used by accident. TX power
1485 * configuration will be enabled again after proper algorithm using feedback
1486 * has been implemented. */
1488 #ifdef RAW_TXPOWER_SETTING
1489 /* Map HFA386x's CR31 to and from dBm with some sort of ad hoc mapping..
1490 * This version assumes following mapping:
1491 * CR31 is 7-bit value with -64 to +63 range.
1492 * -64 is mapped into +20dBm and +63 into -43dBm.
1493 * This is certainly not an exact mapping for every card, but at least
1494 * increasing dBm value should correspond to increasing TX power.
1497 static int prism2_txpower_hfa386x_to_dBm(u16 val)
1510 static u16 prism2_txpower_dBm_to_hfa386x(int val)
1523 return (unsigned char) tmp;
1525 #endif /* RAW_TXPOWER_SETTING */
1528 static int prism2_ioctl_siwtxpow(struct net_device *dev,
1529 struct iw_request_info *info,
1530 struct iw_param *rrq, char *extra)
1532 struct hostap_interface *iface;
1533 local_info_t *local;
1534 #ifdef RAW_TXPOWER_SETTING
1540 iface = netdev_priv(dev);
1541 local = iface->local;
1543 if (rrq->disabled) {
1544 if (local->txpower_type != PRISM2_TXPOWER_OFF) {
1545 val = 0xff; /* use all standby and sleep modes */
1546 ret = local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
1547 HFA386X_CR_A_D_TEST_MODES2,
1549 printk(KERN_DEBUG "%s: Turning radio off: %s\n",
1550 dev->name, ret ? "failed" : "OK");
1551 local->txpower_type = PRISM2_TXPOWER_OFF;
1553 return (ret ? -EOPNOTSUPP : 0);
1556 if (local->txpower_type == PRISM2_TXPOWER_OFF) {
1557 val = 0; /* disable all standby and sleep modes */
1558 ret = local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
1559 HFA386X_CR_A_D_TEST_MODES2, &val, NULL);
1560 printk(KERN_DEBUG "%s: Turning radio on: %s\n",
1561 dev->name, ret ? "failed" : "OK");
1562 local->txpower_type = PRISM2_TXPOWER_UNKNOWN;
1565 #ifdef RAW_TXPOWER_SETTING
1566 if (!rrq->fixed && local->txpower_type != PRISM2_TXPOWER_AUTO) {
1567 printk(KERN_DEBUG "Setting ALC on\n");
1568 val = HFA384X_TEST_CFG_BIT_ALC;
1569 local->func->cmd(dev, HFA384X_CMDCODE_TEST |
1570 (HFA384X_TEST_CFG_BITS << 8), 1, &val, NULL);
1571 local->txpower_type = PRISM2_TXPOWER_AUTO;
1575 if (local->txpower_type != PRISM2_TXPOWER_FIXED) {
1576 printk(KERN_DEBUG "Setting ALC off\n");
1577 val = HFA384X_TEST_CFG_BIT_ALC;
1578 local->func->cmd(dev, HFA384X_CMDCODE_TEST |
1579 (HFA384X_TEST_CFG_BITS << 8), 0, &val, NULL);
1580 local->txpower_type = PRISM2_TXPOWER_FIXED;
1583 if (rrq->flags == IW_TXPOW_DBM)
1585 else if (rrq->flags == IW_TXPOW_MWATT)
1589 printk(KERN_DEBUG "Setting TX power to %d %s\n", rrq->value, tmp);
1591 if (rrq->flags != IW_TXPOW_DBM) {
1592 printk("SIOCSIWTXPOW with mW is not supported; use dBm\n");
1596 local->txpower = rrq->value;
1597 val = prism2_txpower_dBm_to_hfa386x(local->txpower);
1598 if (local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF,
1599 HFA386X_CR_MANUAL_TX_POWER, &val, NULL))
1601 #else /* RAW_TXPOWER_SETTING */
1604 #endif /* RAW_TXPOWER_SETTING */
1609 static int prism2_ioctl_giwtxpow(struct net_device *dev,
1610 struct iw_request_info *info,
1611 struct iw_param *rrq, char *extra)
1613 #ifdef RAW_TXPOWER_SETTING
1614 struct hostap_interface *iface;
1615 local_info_t *local;
1618 iface = netdev_priv(dev);
1619 local = iface->local;
1621 rrq->flags = IW_TXPOW_DBM;
1625 if (local->txpower_type == PRISM2_TXPOWER_AUTO) {
1626 if (local->func->cmd(dev, HFA384X_CMDCODE_READMIF,
1627 HFA386X_CR_MANUAL_TX_POWER,
1628 NULL, &resp0) == 0) {
1629 rrq->value = prism2_txpower_hfa386x_to_dBm(resp0);
1631 /* Could not get real txpower; guess 15 dBm */
1634 } else if (local->txpower_type == PRISM2_TXPOWER_OFF) {
1637 } else if (local->txpower_type == PRISM2_TXPOWER_FIXED) {
1638 rrq->value = local->txpower;
1641 printk("SIOCGIWTXPOW - unknown txpower_type=%d\n",
1642 local->txpower_type);
1645 #else /* RAW_TXPOWER_SETTING */
1647 #endif /* RAW_TXPOWER_SETTING */
1651 #ifndef PRISM2_NO_STATION_MODES
1653 /* HostScan request works with and without host_roaming mode. In addition, it
1654 * does not break current association. However, it requires newer station
1655 * firmware version (>= 1.3.1) than scan request. */
1656 static int prism2_request_hostscan(struct net_device *dev,
1657 u8 *ssid, u8 ssid_len)
1659 struct hostap_interface *iface;
1660 local_info_t *local;
1661 struct hfa384x_hostscan_request scan_req;
1663 iface = netdev_priv(dev);
1664 local = iface->local;
1666 memset(&scan_req, 0, sizeof(scan_req));
1667 scan_req.channel_list = cpu_to_le16(local->channel_mask &
1668 local->scan_channel_mask);
1669 scan_req.txrate = __constant_cpu_to_le16(HFA384X_RATES_1MBPS);
1673 scan_req.target_ssid_len = cpu_to_le16(ssid_len);
1674 memcpy(scan_req.target_ssid, ssid, ssid_len);
1677 if (local->func->set_rid(dev, HFA384X_RID_HOSTSCAN, &scan_req,
1678 sizeof(scan_req))) {
1679 printk(KERN_DEBUG "%s: HOSTSCAN failed\n", dev->name);
1686 static int prism2_request_scan(struct net_device *dev)
1688 struct hostap_interface *iface;
1689 local_info_t *local;
1690 struct hfa384x_scan_request scan_req;
1693 iface = netdev_priv(dev);
1694 local = iface->local;
1696 memset(&scan_req, 0, sizeof(scan_req));
1697 scan_req.channel_list = cpu_to_le16(local->channel_mask &
1698 local->scan_channel_mask);
1699 scan_req.txrate = __constant_cpu_to_le16(HFA384X_RATES_1MBPS);
1702 * It seems to be enough to set roaming mode for a short moment to
1703 * host-based and then setup scanrequest data and return the mode to
1706 * Master mode would need to drop to Managed mode for a short while
1707 * to make scanning work.. Or sweep through the different channels and
1708 * use passive scan based on beacons. */
1710 if (!local->host_roaming)
1711 hostap_set_word(dev, HFA384X_RID_CNFROAMINGMODE,
1712 HFA384X_ROAMING_HOST);
1714 if (local->func->set_rid(dev, HFA384X_RID_SCANREQUEST, &scan_req,
1715 sizeof(scan_req))) {
1716 printk(KERN_DEBUG "SCANREQUEST failed\n");
1720 if (!local->host_roaming)
1721 hostap_set_word(dev, HFA384X_RID_CNFROAMINGMODE,
1722 HFA384X_ROAMING_FIRMWARE);
1727 #else /* !PRISM2_NO_STATION_MODES */
1729 static inline int prism2_request_hostscan(struct net_device *dev,
1730 u8 *ssid, u8 ssid_len)
1736 static inline int prism2_request_scan(struct net_device *dev)
1741 #endif /* !PRISM2_NO_STATION_MODES */
1744 static int prism2_ioctl_siwscan(struct net_device *dev,
1745 struct iw_request_info *info,
1746 struct iw_point *data, char *extra)
1748 struct hostap_interface *iface;
1749 local_info_t *local;
1751 u8 *ssid = NULL, ssid_len = 0;
1752 struct iw_scan_req *req = (struct iw_scan_req *) extra;
1754 iface = netdev_priv(dev);
1755 local = iface->local;
1757 if (data->length < sizeof(struct iw_scan_req))
1760 if (local->iw_mode == IW_MODE_MASTER) {
1761 /* In master mode, we just return the results of our local
1762 * tables, so we don't need to start anything...
1768 if (!local->dev_enabled)
1771 if (req && data->flags & IW_SCAN_THIS_ESSID) {
1773 ssid_len = req->essid_len;
1776 ((local->iw_mode != IW_MODE_INFRA &&
1777 local->iw_mode != IW_MODE_ADHOC) ||
1778 (local->sta_fw_ver < PRISM2_FW_VER(1,3,1))))
1782 if (local->sta_fw_ver >= PRISM2_FW_VER(1,3,1))
1783 ret = prism2_request_hostscan(dev, ssid, ssid_len);
1785 ret = prism2_request_scan(dev);
1788 local->scan_timestamp = jiffies;
1790 /* Could inquire F101, F103 or wait for SIOCGIWSCAN and read RID */
1796 #ifndef PRISM2_NO_STATION_MODES
1797 static char * __prism2_translate_scan(local_info_t *local,
1798 struct iw_request_info *info,
1799 struct hfa384x_hostscan_result *scan,
1800 struct hostap_bss_info *bss,
1801 char *current_ev, char *end_buf)
1804 struct iw_event iwe;
1814 ssid_len = bss->ssid_len;
1818 ssid_len = le16_to_cpu(scan->ssid_len);
1819 bssid = scan->bssid;
1824 /* First entry *MUST* be the AP MAC address */
1825 memset(&iwe, 0, sizeof(iwe));
1826 iwe.cmd = SIOCGIWAP;
1827 iwe.u.ap_addr.sa_family = ARPHRD_ETHER;
1828 memcpy(iwe.u.ap_addr.sa_data, bssid, ETH_ALEN);
1829 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe,
1832 /* Other entries will be displayed in the order we give them */
1834 memset(&iwe, 0, sizeof(iwe));
1835 iwe.cmd = SIOCGIWESSID;
1836 iwe.u.data.length = ssid_len;
1837 iwe.u.data.flags = 1;
1838 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
1841 memset(&iwe, 0, sizeof(iwe));
1842 iwe.cmd = SIOCGIWMODE;
1844 capabilities = bss->capab_info;
1846 capabilities = le16_to_cpu(scan->capability);
1848 if (capabilities & (WLAN_CAPABILITY_ESS |
1849 WLAN_CAPABILITY_IBSS)) {
1850 if (capabilities & WLAN_CAPABILITY_ESS)
1851 iwe.u.mode = IW_MODE_MASTER;
1853 iwe.u.mode = IW_MODE_ADHOC;
1854 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
1855 &iwe, IW_EV_UINT_LEN);
1858 memset(&iwe, 0, sizeof(iwe));
1859 iwe.cmd = SIOCGIWFREQ;
1861 chan = le16_to_cpu(scan->chid);
1869 iwe.u.freq.m = freq_list[chan - 1] * 100000;
1871 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
1872 &iwe, IW_EV_FREQ_LEN);
1876 memset(&iwe, 0, sizeof(iwe));
1878 if (local->last_scan_type == PRISM2_HOSTSCAN) {
1879 iwe.u.qual.level = le16_to_cpu(scan->sl);
1880 iwe.u.qual.noise = le16_to_cpu(scan->anl);
1883 HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan->sl));
1885 HFA384X_LEVEL_TO_dBm(le16_to_cpu(scan->anl));
1887 iwe.u.qual.updated = IW_QUAL_LEVEL_UPDATED
1888 | IW_QUAL_NOISE_UPDATED
1889 | IW_QUAL_QUAL_INVALID
1891 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
1892 &iwe, IW_EV_QUAL_LEN);
1895 memset(&iwe, 0, sizeof(iwe));
1896 iwe.cmd = SIOCGIWENCODE;
1897 if (capabilities & WLAN_CAPABILITY_PRIVACY)
1898 iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY;
1900 iwe.u.data.flags = IW_ENCODE_DISABLED;
1901 iwe.u.data.length = 0;
1902 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe, "");
1904 /* TODO: add SuppRates into BSS table */
1906 memset(&iwe, 0, sizeof(iwe));
1907 iwe.cmd = SIOCGIWRATE;
1908 current_val = current_ev + iwe_stream_lcp_len(info);
1909 pos = scan->sup_rates;
1910 for (i = 0; i < sizeof(scan->sup_rates); i++) {
1913 /* Bit rate given in 500 kb/s units (+ 0x80) */
1914 iwe.u.bitrate.value = ((pos[i] & 0x7f) * 500000);
1915 current_val = iwe_stream_add_value(
1916 info, current_ev, current_val, end_buf, &iwe,
1919 /* Check if we added any event */
1920 if ((current_val - current_ev) > iwe_stream_lcp_len(info))
1921 current_ev = current_val;
1924 /* TODO: add BeaconInt,resp_rate,atim into BSS table */
1925 buf = kmalloc(MAX_WPA_IE_LEN * 2 + 30, GFP_ATOMIC);
1927 memset(&iwe, 0, sizeof(iwe));
1928 iwe.cmd = IWEVCUSTOM;
1929 sprintf(buf, "bcn_int=%d", le16_to_cpu(scan->beacon_interval));
1930 iwe.u.data.length = strlen(buf);
1931 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
1934 memset(&iwe, 0, sizeof(iwe));
1935 iwe.cmd = IWEVCUSTOM;
1936 sprintf(buf, "resp_rate=%d", le16_to_cpu(scan->rate));
1937 iwe.u.data.length = strlen(buf);
1938 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
1941 if (local->last_scan_type == PRISM2_HOSTSCAN &&
1942 (capabilities & WLAN_CAPABILITY_IBSS)) {
1943 memset(&iwe, 0, sizeof(iwe));
1944 iwe.cmd = IWEVCUSTOM;
1945 sprintf(buf, "atim=%d", le16_to_cpu(scan->atim));
1946 iwe.u.data.length = strlen(buf);
1947 current_ev = iwe_stream_add_point(info, current_ev,
1948 end_buf, &iwe, buf);
1953 if (bss && bss->wpa_ie_len > 0 && bss->wpa_ie_len <= MAX_WPA_IE_LEN) {
1954 memset(&iwe, 0, sizeof(iwe));
1955 iwe.cmd = IWEVGENIE;
1956 iwe.u.data.length = bss->wpa_ie_len;
1957 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
1961 if (bss && bss->rsn_ie_len > 0 && bss->rsn_ie_len <= MAX_WPA_IE_LEN) {
1962 memset(&iwe, 0, sizeof(iwe));
1963 iwe.cmd = IWEVGENIE;
1964 iwe.u.data.length = bss->rsn_ie_len;
1965 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
1973 /* Translate scan data returned from the card to a card independant
1974 * format that the Wireless Tools will understand - Jean II */
1975 static inline int prism2_translate_scan(local_info_t *local,
1976 struct iw_request_info *info,
1977 char *buffer, int buflen)
1979 struct hfa384x_hostscan_result *scan;
1980 int entry, hostscan;
1981 char *current_ev = buffer;
1982 char *end_buf = buffer + buflen;
1983 struct list_head *ptr;
1985 spin_lock_bh(&local->lock);
1987 list_for_each(ptr, &local->bss_list) {
1988 struct hostap_bss_info *bss;
1989 bss = list_entry(ptr, struct hostap_bss_info, list);
1993 hostscan = local->last_scan_type == PRISM2_HOSTSCAN;
1994 for (entry = 0; entry < local->last_scan_results_count; entry++) {
1996 scan = &local->last_scan_results[entry];
1998 /* Report every SSID if the AP is using multiple SSIDs. If no
1999 * BSS record is found (e.g., when WPA mode is disabled),
2000 * report the AP once. */
2001 list_for_each(ptr, &local->bss_list) {
2002 struct hostap_bss_info *bss;
2003 bss = list_entry(ptr, struct hostap_bss_info, list);
2004 if (memcmp(bss->bssid, scan->bssid, ETH_ALEN) == 0) {
2006 current_ev = __prism2_translate_scan(
2007 local, info, scan, bss, current_ev,
2013 current_ev = __prism2_translate_scan(
2014 local, info, 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, info, 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, info, 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, info, 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 &&
2526 value != PRISM2_MONITOR_RADIOTAP) {
2530 local->monitor_type = value;
2531 if (local->iw_mode == IW_MODE_MONITOR)
2532 hostap_monitor_set_type(local);
2535 case PRISM2_PARAM_WDS_TYPE:
2536 local->wds_type = value;
2539 case PRISM2_PARAM_HOSTSCAN:
2541 struct hfa384x_hostscan_request scan_req;
2544 memset(&scan_req, 0, sizeof(scan_req));
2545 scan_req.channel_list = __constant_cpu_to_le16(0x3fff);
2547 case 1: rate = HFA384X_RATES_1MBPS; break;
2548 case 2: rate = HFA384X_RATES_2MBPS; break;
2549 case 3: rate = HFA384X_RATES_5MBPS; break;
2550 case 4: rate = HFA384X_RATES_11MBPS; break;
2551 default: rate = HFA384X_RATES_1MBPS; break;
2553 scan_req.txrate = cpu_to_le16(rate);
2554 /* leave SSID empty to accept all SSIDs */
2556 if (local->iw_mode == IW_MODE_MASTER) {
2557 if (hostap_set_word(dev, HFA384X_RID_CNFPORTTYPE,
2558 HFA384X_PORTTYPE_BSS) ||
2559 local->func->reset_port(dev))
2560 printk(KERN_DEBUG "Leaving Host AP mode "
2561 "for HostScan failed\n");
2564 if (local->func->set_rid(dev, HFA384X_RID_HOSTSCAN, &scan_req,
2565 sizeof(scan_req))) {
2566 printk(KERN_DEBUG "HOSTSCAN failed\n");
2569 if (local->iw_mode == IW_MODE_MASTER) {
2570 wait_queue_t __wait;
2571 init_waitqueue_entry(&__wait, current);
2572 add_wait_queue(&local->hostscan_wq, &__wait);
2573 set_current_state(TASK_INTERRUPTIBLE);
2574 schedule_timeout(HZ);
2575 if (signal_pending(current))
2577 set_current_state(TASK_RUNNING);
2578 remove_wait_queue(&local->hostscan_wq, &__wait);
2580 if (hostap_set_word(dev, HFA384X_RID_CNFPORTTYPE,
2581 HFA384X_PORTTYPE_HOSTAP) ||
2582 local->func->reset_port(dev))
2583 printk(KERN_DEBUG "Returning to Host AP mode "
2584 "after HostScan failed\n");
2589 case PRISM2_PARAM_AP_SCAN:
2590 local->passive_scan_interval = value;
2591 if (timer_pending(&local->passive_scan_timer))
2592 del_timer(&local->passive_scan_timer);
2594 local->passive_scan_timer.expires = jiffies +
2595 local->passive_scan_interval * HZ;
2596 add_timer(&local->passive_scan_timer);
2600 case PRISM2_PARAM_ENH_SEC:
2601 if (value < 0 || value > 3) {
2605 local->enh_sec = value;
2606 if (hostap_set_word(dev, HFA384X_RID_CNFENHSECURITY,
2608 local->func->reset_port(dev)) {
2609 printk(KERN_INFO "%s: cnfEnhSecurity requires STA f/w "
2610 "1.6.3 or newer\n", dev->name);
2615 #ifdef PRISM2_IO_DEBUG
2616 case PRISM2_PARAM_IO_DEBUG:
2617 local->io_debug_enabled = value;
2619 #endif /* PRISM2_IO_DEBUG */
2621 case PRISM2_PARAM_BASIC_RATES:
2622 if ((value & local->tx_rate_control) != value || value == 0) {
2623 printk(KERN_INFO "%s: invalid basic rate set - basic "
2624 "rates must be in supported rate set\n",
2629 local->basic_rates = value;
2630 if (hostap_set_word(dev, HFA384X_RID_CNFBASICRATES,
2631 local->basic_rates) ||
2632 local->func->reset_port(dev))
2636 case PRISM2_PARAM_OPER_RATES:
2637 local->tx_rate_control = value;
2638 if (hostap_set_rate(dev))
2642 case PRISM2_PARAM_HOSTAPD:
2643 ret = hostap_set_hostapd(local, value, 1);
2646 case PRISM2_PARAM_HOSTAPD_STA:
2647 ret = hostap_set_hostapd_sta(local, value, 1);
2650 case PRISM2_PARAM_WPA:
2652 if (local->sta_fw_ver < PRISM2_FW_VER(1,7,0))
2654 else if (hostap_set_word(dev, HFA384X_RID_SSNHANDLINGMODE,
2659 case PRISM2_PARAM_PRIVACY_INVOKED:
2660 local->privacy_invoked = value;
2661 if (hostap_set_encryption(local) ||
2662 local->func->reset_port(dev))
2666 case PRISM2_PARAM_TKIP_COUNTERMEASURES:
2667 local->tkip_countermeasures = value;
2670 case PRISM2_PARAM_DROP_UNENCRYPTED:
2671 local->drop_unencrypted = value;
2674 case PRISM2_PARAM_SCAN_CHANNEL_MASK:
2675 local->scan_channel_mask = value;
2679 printk(KERN_DEBUG "%s: prism2_param: unknown param %d\n",
2689 static int prism2_ioctl_priv_get_prism2_param(struct net_device *dev,
2690 struct iw_request_info *info,
2691 void *wrqu, char *extra)
2693 struct hostap_interface *iface;
2694 local_info_t *local;
2695 int *param = (int *) extra;
2698 iface = netdev_priv(dev);
2699 local = iface->local;
2702 case PRISM2_PARAM_TXRATECTRL:
2703 *param = local->fw_tx_rate_control;
2706 case PRISM2_PARAM_BEACON_INT:
2707 *param = local->beacon_int;
2710 case PRISM2_PARAM_PSEUDO_IBSS:
2711 *param = local->pseudo_adhoc;
2714 case PRISM2_PARAM_ALC:
2715 ret = -EOPNOTSUPP; /* FIX */
2718 case PRISM2_PARAM_DUMP:
2719 *param = local->frame_dump;
2722 case PRISM2_PARAM_OTHER_AP_POLICY:
2723 if (local->ap != NULL)
2724 *param = local->ap->ap_policy;
2729 case PRISM2_PARAM_AP_MAX_INACTIVITY:
2730 if (local->ap != NULL)
2731 *param = local->ap->max_inactivity / HZ;
2736 case PRISM2_PARAM_AP_BRIDGE_PACKETS:
2737 if (local->ap != NULL)
2738 *param = local->ap->bridge_packets;
2743 case PRISM2_PARAM_DTIM_PERIOD:
2744 *param = local->dtim_period;
2747 case PRISM2_PARAM_AP_NULLFUNC_ACK:
2748 if (local->ap != NULL)
2749 *param = local->ap->nullfunc_ack;
2754 case PRISM2_PARAM_MAX_WDS:
2755 *param = local->wds_max_connections;
2758 case PRISM2_PARAM_AP_AUTOM_AP_WDS:
2759 if (local->ap != NULL)
2760 *param = local->ap->autom_ap_wds;
2765 case PRISM2_PARAM_AP_AUTH_ALGS:
2766 *param = local->auth_algs;
2769 case PRISM2_PARAM_MONITOR_ALLOW_FCSERR:
2770 *param = local->monitor_allow_fcserr;
2773 case PRISM2_PARAM_HOST_ENCRYPT:
2774 *param = local->host_encrypt;
2777 case PRISM2_PARAM_HOST_DECRYPT:
2778 *param = local->host_decrypt;
2781 case PRISM2_PARAM_HOST_ROAMING:
2782 *param = local->host_roaming;
2785 case PRISM2_PARAM_BCRX_STA_KEY:
2786 *param = local->bcrx_sta_key;
2789 case PRISM2_PARAM_IEEE_802_1X:
2790 *param = local->ieee_802_1x;
2793 case PRISM2_PARAM_ANTSEL_TX:
2794 *param = local->antsel_tx;
2797 case PRISM2_PARAM_ANTSEL_RX:
2798 *param = local->antsel_rx;
2801 case PRISM2_PARAM_MONITOR_TYPE:
2802 *param = local->monitor_type;
2805 case PRISM2_PARAM_WDS_TYPE:
2806 *param = local->wds_type;
2809 case PRISM2_PARAM_HOSTSCAN:
2813 case PRISM2_PARAM_AP_SCAN:
2814 *param = local->passive_scan_interval;
2817 case PRISM2_PARAM_ENH_SEC:
2818 *param = local->enh_sec;
2821 #ifdef PRISM2_IO_DEBUG
2822 case PRISM2_PARAM_IO_DEBUG:
2823 *param = local->io_debug_enabled;
2825 #endif /* PRISM2_IO_DEBUG */
2827 case PRISM2_PARAM_BASIC_RATES:
2828 *param = local->basic_rates;
2831 case PRISM2_PARAM_OPER_RATES:
2832 *param = local->tx_rate_control;
2835 case PRISM2_PARAM_HOSTAPD:
2836 *param = local->hostapd;
2839 case PRISM2_PARAM_HOSTAPD_STA:
2840 *param = local->hostapd_sta;
2843 case PRISM2_PARAM_WPA:
2844 if (local->sta_fw_ver < PRISM2_FW_VER(1,7,0))
2846 *param = local->wpa;
2849 case PRISM2_PARAM_PRIVACY_INVOKED:
2850 *param = local->privacy_invoked;
2853 case PRISM2_PARAM_TKIP_COUNTERMEASURES:
2854 *param = local->tkip_countermeasures;
2857 case PRISM2_PARAM_DROP_UNENCRYPTED:
2858 *param = local->drop_unencrypted;
2861 case PRISM2_PARAM_SCAN_CHANNEL_MASK:
2862 *param = local->scan_channel_mask;
2866 printk(KERN_DEBUG "%s: get_prism2_param: unknown param %d\n",
2876 static int prism2_ioctl_priv_readmif(struct net_device *dev,
2877 struct iw_request_info *info,
2878 void *wrqu, char *extra)
2880 struct hostap_interface *iface;
2881 local_info_t *local;
2884 iface = netdev_priv(dev);
2885 local = iface->local;
2887 if (local->func->cmd(dev, HFA384X_CMDCODE_READMIF, *extra, NULL,
2897 static int prism2_ioctl_priv_writemif(struct net_device *dev,
2898 struct iw_request_info *info,
2899 void *wrqu, char *extra)
2901 struct hostap_interface *iface;
2902 local_info_t *local;
2905 iface = netdev_priv(dev);
2906 local = iface->local;
2910 if (local->func->cmd(dev, HFA384X_CMDCODE_WRITEMIF, cr, &val, NULL))
2917 static int prism2_ioctl_priv_monitor(struct net_device *dev, int *i)
2919 struct hostap_interface *iface;
2920 local_info_t *local;
2924 iface = netdev_priv(dev);
2925 local = iface->local;
2927 printk(KERN_DEBUG "%s: process %d (%s) used deprecated iwpriv monitor "
2928 "- update software to use iwconfig mode monitor\n",
2929 dev->name, task_pid_nr(current), current->comm);
2931 /* Backward compatibility code - this can be removed at some point */
2934 /* Disable monitor mode - old mode was not saved, so go to
2936 mode = IW_MODE_MASTER;
2937 ret = prism2_ioctl_siwmode(dev, NULL, &mode, NULL);
2938 } else if (*i == 1) {
2939 /* netlink socket mode is not supported anymore since it did
2940 * not separate different devices from each other and was not
2941 * best method for delivering large amount of packets to
2944 } else if (*i == 2 || *i == 3) {
2947 local->monitor_type = PRISM2_MONITOR_80211;
2950 local->monitor_type = PRISM2_MONITOR_PRISM;
2953 mode = IW_MODE_MONITOR;
2954 ret = prism2_ioctl_siwmode(dev, NULL, &mode, NULL);
2955 hostap_monitor_mode_enable(local);
2963 static int prism2_ioctl_priv_reset(struct net_device *dev, int *i)
2965 struct hostap_interface *iface;
2966 local_info_t *local;
2968 iface = netdev_priv(dev);
2969 local = iface->local;
2971 printk(KERN_DEBUG "%s: manual reset request(%d)\n", dev->name, *i);
2974 /* Disable and enable card */
2975 local->func->hw_shutdown(dev, 1);
2976 local->func->hw_config(dev, 0);
2981 local->func->hw_reset(dev);
2985 /* Disable and enable port 0 */
2986 local->func->reset_port(dev);
2990 prism2_sta_deauth(local, WLAN_REASON_DEAUTH_LEAVING);
2991 if (local->func->cmd(dev, HFA384X_CMDCODE_DISABLE, 0, NULL,
2997 if (local->func->cmd(dev, HFA384X_CMDCODE_ENABLE, 0, NULL,
3003 printk(KERN_DEBUG "Unknown reset request %d\n", *i);
3011 static int prism2_ioctl_priv_set_rid_word(struct net_device *dev, int *i)
3014 int value = *(i + 1);
3016 printk(KERN_DEBUG "%s: Set RID[0x%X] = %d\n", dev->name, rid, value);
3018 if (hostap_set_word(dev, rid, value))
3025 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
3026 static int ap_mac_cmd_ioctl(local_info_t *local, int *cmd)
3031 case AP_MAC_CMD_POLICY_OPEN:
3032 local->ap->mac_restrictions.policy = MAC_POLICY_OPEN;
3034 case AP_MAC_CMD_POLICY_ALLOW:
3035 local->ap->mac_restrictions.policy = MAC_POLICY_ALLOW;
3037 case AP_MAC_CMD_POLICY_DENY:
3038 local->ap->mac_restrictions.policy = MAC_POLICY_DENY;
3040 case AP_MAC_CMD_FLUSH:
3041 ap_control_flush_macs(&local->ap->mac_restrictions);
3043 case AP_MAC_CMD_KICKALL:
3044 ap_control_kickall(local->ap);
3045 hostap_deauth_all_stas(local->dev, local->ap, 0);
3054 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
3057 #ifdef PRISM2_DOWNLOAD_SUPPORT
3058 static int prism2_ioctl_priv_download(local_info_t *local, struct iw_point *p)
3060 struct prism2_download_param *param;
3063 if (p->length < sizeof(struct prism2_download_param) ||
3064 p->length > 1024 || !p->pointer)
3067 param = (struct prism2_download_param *)
3068 kmalloc(p->length, GFP_KERNEL);
3072 if (copy_from_user(param, p->pointer, p->length)) {
3077 if (p->length < sizeof(struct prism2_download_param) +
3078 param->num_areas * sizeof(struct prism2_download_area)) {
3083 ret = local->func->download(local, param);
3089 #endif /* PRISM2_DOWNLOAD_SUPPORT */
3092 static int prism2_set_genericelement(struct net_device *dev, u8 *elem,
3095 struct hostap_interface *iface = netdev_priv(dev);
3096 local_info_t *local = iface->local;
3100 * Add 16-bit length in the beginning of the buffer because Prism2 RID
3103 buf = kmalloc(len + 2, GFP_KERNEL);
3107 *((__le16 *) buf) = cpu_to_le16(len);
3108 memcpy(buf + 2, elem, len);
3110 kfree(local->generic_elem);
3111 local->generic_elem = buf;
3112 local->generic_elem_len = len + 2;
3114 return local->func->set_rid(local->dev, HFA384X_RID_GENERICELEMENT,
3119 static int prism2_ioctl_siwauth(struct net_device *dev,
3120 struct iw_request_info *info,
3121 struct iw_param *data, char *extra)
3123 struct hostap_interface *iface = netdev_priv(dev);
3124 local_info_t *local = iface->local;
3126 switch (data->flags & IW_AUTH_INDEX) {
3127 case IW_AUTH_WPA_VERSION:
3128 case IW_AUTH_CIPHER_PAIRWISE:
3129 case IW_AUTH_CIPHER_GROUP:
3130 case IW_AUTH_KEY_MGMT:
3132 * Host AP driver does not use these parameters and allows
3133 * wpa_supplicant to control them internally.
3136 case IW_AUTH_TKIP_COUNTERMEASURES:
3137 local->tkip_countermeasures = data->value;
3139 case IW_AUTH_DROP_UNENCRYPTED:
3140 local->drop_unencrypted = data->value;
3142 case IW_AUTH_80211_AUTH_ALG:
3143 local->auth_algs = data->value;
3145 case IW_AUTH_WPA_ENABLED:
3146 if (data->value == 0) {
3148 if (local->sta_fw_ver < PRISM2_FW_VER(1,7,0))
3150 prism2_set_genericelement(dev, "", 0);
3151 local->host_roaming = 0;
3152 local->privacy_invoked = 0;
3153 if (hostap_set_word(dev, HFA384X_RID_SSNHANDLINGMODE,
3155 hostap_set_roaming(local) ||
3156 hostap_set_encryption(local) ||
3157 local->func->reset_port(dev))
3161 if (local->sta_fw_ver < PRISM2_FW_VER(1,7,0))
3163 local->host_roaming = 2;
3164 local->privacy_invoked = 1;
3166 if (hostap_set_word(dev, HFA384X_RID_SSNHANDLINGMODE, 1) ||
3167 hostap_set_roaming(local) ||
3168 hostap_set_encryption(local) ||
3169 local->func->reset_port(dev))
3172 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
3173 local->ieee_802_1x = data->value;
3175 case IW_AUTH_PRIVACY_INVOKED:
3176 local->privacy_invoked = data->value;
3185 static int prism2_ioctl_giwauth(struct net_device *dev,
3186 struct iw_request_info *info,
3187 struct iw_param *data, char *extra)
3189 struct hostap_interface *iface = netdev_priv(dev);
3190 local_info_t *local = iface->local;
3192 switch (data->flags & IW_AUTH_INDEX) {
3193 case IW_AUTH_WPA_VERSION:
3194 case IW_AUTH_CIPHER_PAIRWISE:
3195 case IW_AUTH_CIPHER_GROUP:
3196 case IW_AUTH_KEY_MGMT:
3198 * Host AP driver does not use these parameters and allows
3199 * wpa_supplicant to control them internally.
3202 case IW_AUTH_TKIP_COUNTERMEASURES:
3203 data->value = local->tkip_countermeasures;
3205 case IW_AUTH_DROP_UNENCRYPTED:
3206 data->value = local->drop_unencrypted;
3208 case IW_AUTH_80211_AUTH_ALG:
3209 data->value = local->auth_algs;
3211 case IW_AUTH_WPA_ENABLED:
3212 data->value = local->wpa;
3214 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
3215 data->value = local->ieee_802_1x;
3224 static int prism2_ioctl_siwencodeext(struct net_device *dev,
3225 struct iw_request_info *info,
3226 struct iw_point *erq, char *extra)
3228 struct hostap_interface *iface = netdev_priv(dev);
3229 local_info_t *local = iface->local;
3230 struct iw_encode_ext *ext = (struct iw_encode_ext *) extra;
3232 struct ieee80211_crypto_ops *ops;
3233 struct ieee80211_crypt_data **crypt;
3236 const char *alg, *module;
3238 i = erq->flags & IW_ENCODE_INDEX;
3241 if (i < 1 || i > WEP_KEYS)
3242 i = local->tx_keyidx;
3245 if (i < 0 || i >= WEP_KEYS)
3248 addr = ext->addr.sa_data;
3249 if (addr[0] == 0xff && addr[1] == 0xff && addr[2] == 0xff &&
3250 addr[3] == 0xff && addr[4] == 0xff && addr[5] == 0xff) {
3252 crypt = &local->crypt[i];
3256 sta_ptr = ap_crypt_get_ptrs(local->ap, addr, 0, &crypt);
3257 if (sta_ptr == NULL) {
3258 if (local->iw_mode == IW_MODE_INFRA) {
3260 * TODO: add STA entry for the current AP so
3261 * that unicast key can be used. For now, this
3262 * is emulated by using default key idx 0.
3265 crypt = &local->crypt[i];
3271 if ((erq->flags & IW_ENCODE_DISABLED) ||
3272 ext->alg == IW_ENCODE_ALG_NONE) {
3274 prism2_crypt_delayed_deinit(local, crypt);
3279 case IW_ENCODE_ALG_WEP:
3281 module = "ieee80211_crypt_wep";
3283 case IW_ENCODE_ALG_TKIP:
3285 module = "ieee80211_crypt_tkip";
3287 case IW_ENCODE_ALG_CCMP:
3289 module = "ieee80211_crypt_ccmp";
3292 printk(KERN_DEBUG "%s: unsupported algorithm %d\n",
3293 local->dev->name, ext->alg);
3298 ops = ieee80211_get_crypto_ops(alg);
3300 request_module(module);
3301 ops = ieee80211_get_crypto_ops(alg);
3304 printk(KERN_DEBUG "%s: unknown crypto alg '%s'\n",
3305 local->dev->name, alg);
3310 if (sta_ptr || ext->alg != IW_ENCODE_ALG_WEP) {
3312 * Per station encryption and other than WEP algorithms
3313 * require host-based encryption, so force them on
3316 local->host_decrypt = local->host_encrypt = 1;
3319 if (*crypt == NULL || (*crypt)->ops != ops) {
3320 struct ieee80211_crypt_data *new_crypt;
3322 prism2_crypt_delayed_deinit(local, crypt);
3324 new_crypt = kzalloc(sizeof(struct ieee80211_crypt_data),
3326 if (new_crypt == NULL) {
3330 new_crypt->ops = ops;
3331 new_crypt->priv = new_crypt->ops->init(i);
3332 if (new_crypt->priv == NULL) {
3342 * TODO: if ext_flags does not have IW_ENCODE_EXT_RX_SEQ_VALID, the
3343 * existing seq# should not be changed.
3344 * TODO: if ext_flags has IW_ENCODE_EXT_TX_SEQ_VALID, next TX seq#
3345 * should be changed to something else than zero.
3347 if ((!(ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) || ext->key_len > 0)
3348 && (*crypt)->ops->set_key &&
3349 (*crypt)->ops->set_key(ext->key, ext->key_len, ext->rx_seq,
3350 (*crypt)->priv) < 0) {
3351 printk(KERN_DEBUG "%s: key setting failed\n",
3357 if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) {
3359 local->tx_keyidx = i;
3363 if (sta_ptr == NULL && ext->key_len > 0) {
3365 for (j = 0; j < WEP_KEYS; j++) {
3366 if (j != i && local->crypt[j]) {
3372 local->tx_keyidx = i;
3377 hostap_handle_sta_release(sta_ptr);
3379 local->open_wep = erq->flags & IW_ENCODE_OPEN;
3382 * Do not reset port0 if card is in Managed mode since resetting will
3383 * generate new IEEE 802.11 authentication which may end up in looping
3384 * with IEEE 802.1X. Prism2 documentation seem to require port reset
3385 * after WEP configuration. However, keys are apparently changed at
3386 * least in Managed mode.
3389 (hostap_set_encryption(local) ||
3390 (local->iw_mode != IW_MODE_INFRA &&
3391 local->func->reset_port(local->dev))))
3398 static int prism2_ioctl_giwencodeext(struct net_device *dev,
3399 struct iw_request_info *info,
3400 struct iw_point *erq, char *extra)
3402 struct hostap_interface *iface = netdev_priv(dev);
3403 local_info_t *local = iface->local;
3404 struct ieee80211_crypt_data **crypt;
3407 struct iw_encode_ext *ext = (struct iw_encode_ext *) extra;
3410 max_key_len = erq->length - sizeof(*ext);
3411 if (max_key_len < 0)
3414 i = erq->flags & IW_ENCODE_INDEX;
3415 if (i < 1 || i > WEP_KEYS)
3416 i = local->tx_keyidx;
3420 addr = ext->addr.sa_data;
3421 if (addr[0] == 0xff && addr[1] == 0xff && addr[2] == 0xff &&
3422 addr[3] == 0xff && addr[4] == 0xff && addr[5] == 0xff) {
3424 crypt = &local->crypt[i];
3427 sta_ptr = ap_crypt_get_ptrs(local->ap, addr, 0, &crypt);
3428 if (sta_ptr == NULL)
3432 memset(ext, 0, sizeof(*ext));
3434 if (*crypt == NULL || (*crypt)->ops == NULL) {
3435 ext->alg = IW_ENCODE_ALG_NONE;
3437 erq->flags |= IW_ENCODE_DISABLED;
3439 if (strcmp((*crypt)->ops->name, "WEP") == 0)
3440 ext->alg = IW_ENCODE_ALG_WEP;
3441 else if (strcmp((*crypt)->ops->name, "TKIP") == 0)
3442 ext->alg = IW_ENCODE_ALG_TKIP;
3443 else if (strcmp((*crypt)->ops->name, "CCMP") == 0)
3444 ext->alg = IW_ENCODE_ALG_CCMP;
3448 if ((*crypt)->ops->get_key) {
3450 (*crypt)->ops->get_key(ext->key,
3455 (ext->alg == IW_ENCODE_ALG_TKIP ||
3456 ext->alg == IW_ENCODE_ALG_CCMP))
3457 ext->ext_flags |= IW_ENCODE_EXT_TX_SEQ_VALID;
3462 hostap_handle_sta_release(sta_ptr);
3468 static int prism2_ioctl_set_encryption(local_info_t *local,
3469 struct prism2_hostapd_param *param,
3473 struct ieee80211_crypto_ops *ops;
3474 struct ieee80211_crypt_data **crypt;
3477 param->u.crypt.err = 0;
3478 param->u.crypt.alg[HOSTAP_CRYPT_ALG_NAME_LEN - 1] = '\0';
3481 (int) ((char *) param->u.crypt.key - (char *) param) +
3482 param->u.crypt.key_len)
3485 if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
3486 param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
3487 param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) {
3488 if (param->u.crypt.idx >= WEP_KEYS)
3491 crypt = &local->crypt[param->u.crypt.idx];
3493 if (param->u.crypt.idx)
3495 sta_ptr = ap_crypt_get_ptrs(
3496 local->ap, param->sta_addr,
3497 (param->u.crypt.flags & HOSTAP_CRYPT_FLAG_PERMANENT),
3500 if (sta_ptr == NULL) {
3501 param->u.crypt.err = HOSTAP_CRYPT_ERR_UNKNOWN_ADDR;
3506 if (strcmp(param->u.crypt.alg, "none") == 0) {
3508 prism2_crypt_delayed_deinit(local, crypt);
3512 ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
3513 if (ops == NULL && strcmp(param->u.crypt.alg, "WEP") == 0) {
3514 request_module("ieee80211_crypt_wep");
3515 ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
3516 } else if (ops == NULL && strcmp(param->u.crypt.alg, "TKIP") == 0) {
3517 request_module("ieee80211_crypt_tkip");
3518 ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
3519 } else if (ops == NULL && strcmp(param->u.crypt.alg, "CCMP") == 0) {
3520 request_module("ieee80211_crypt_ccmp");
3521 ops = ieee80211_get_crypto_ops(param->u.crypt.alg);
3524 printk(KERN_DEBUG "%s: unknown crypto alg '%s'\n",
3525 local->dev->name, param->u.crypt.alg);
3526 param->u.crypt.err = HOSTAP_CRYPT_ERR_UNKNOWN_ALG;
3531 /* station based encryption and other than WEP algorithms require
3532 * host-based encryption, so force them on automatically */
3533 local->host_decrypt = local->host_encrypt = 1;
3535 if (*crypt == NULL || (*crypt)->ops != ops) {
3536 struct ieee80211_crypt_data *new_crypt;
3538 prism2_crypt_delayed_deinit(local, crypt);
3540 new_crypt = kzalloc(sizeof(struct ieee80211_crypt_data),
3542 if (new_crypt == NULL) {
3546 new_crypt->ops = ops;
3547 new_crypt->priv = new_crypt->ops->init(param->u.crypt.idx);
3548 if (new_crypt->priv == NULL) {
3550 param->u.crypt.err =
3551 HOSTAP_CRYPT_ERR_CRYPT_INIT_FAILED;
3559 if ((!(param->u.crypt.flags & HOSTAP_CRYPT_FLAG_SET_TX_KEY) ||
3560 param->u.crypt.key_len > 0) && (*crypt)->ops->set_key &&
3561 (*crypt)->ops->set_key(param->u.crypt.key,
3562 param->u.crypt.key_len, param->u.crypt.seq,
3563 (*crypt)->priv) < 0) {
3564 printk(KERN_DEBUG "%s: key setting failed\n",
3566 param->u.crypt.err = HOSTAP_CRYPT_ERR_KEY_SET_FAILED;
3571 if (param->u.crypt.flags & HOSTAP_CRYPT_FLAG_SET_TX_KEY) {
3573 local->tx_keyidx = param->u.crypt.idx;
3574 else if (param->u.crypt.idx) {
3575 printk(KERN_DEBUG "%s: TX key idx setting failed\n",
3577 param->u.crypt.err =
3578 HOSTAP_CRYPT_ERR_TX_KEY_SET_FAILED;
3586 hostap_handle_sta_release(sta_ptr);
3588 /* Do not reset port0 if card is in Managed mode since resetting will
3589 * generate new IEEE 802.11 authentication which may end up in looping
3590 * with IEEE 802.1X. Prism2 documentation seem to require port reset
3591 * after WEP configuration. However, keys are apparently changed at
3592 * least in Managed mode. */
3594 (hostap_set_encryption(local) ||
3595 (local->iw_mode != IW_MODE_INFRA &&
3596 local->func->reset_port(local->dev)))) {
3597 param->u.crypt.err = HOSTAP_CRYPT_ERR_CARD_CONF_FAILED;
3605 static int prism2_ioctl_get_encryption(local_info_t *local,
3606 struct prism2_hostapd_param *param,
3609 struct ieee80211_crypt_data **crypt;
3613 param->u.crypt.err = 0;
3615 max_key_len = param_len -
3616 (int) ((char *) param->u.crypt.key - (char *) param);
3617 if (max_key_len < 0)
3620 if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
3621 param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
3622 param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) {
3624 if (param->u.crypt.idx >= WEP_KEYS)
3625 param->u.crypt.idx = local->tx_keyidx;
3626 crypt = &local->crypt[param->u.crypt.idx];
3628 param->u.crypt.idx = 0;
3629 sta_ptr = ap_crypt_get_ptrs(local->ap, param->sta_addr, 0,
3632 if (sta_ptr == NULL) {
3633 param->u.crypt.err = HOSTAP_CRYPT_ERR_UNKNOWN_ADDR;
3638 if (*crypt == NULL || (*crypt)->ops == NULL) {
3639 memcpy(param->u.crypt.alg, "none", 5);
3640 param->u.crypt.key_len = 0;
3641 param->u.crypt.idx = 0xff;
3643 strncpy(param->u.crypt.alg, (*crypt)->ops->name,
3644 HOSTAP_CRYPT_ALG_NAME_LEN);
3645 param->u.crypt.key_len = 0;
3647 memset(param->u.crypt.seq, 0, 8);
3648 if ((*crypt)->ops->get_key) {
3649 param->u.crypt.key_len =
3650 (*crypt)->ops->get_key(param->u.crypt.key,
3658 hostap_handle_sta_release(sta_ptr);
3664 static int prism2_ioctl_get_rid(local_info_t *local,
3665 struct prism2_hostapd_param *param,
3670 max_len = param_len - PRISM2_HOSTAPD_RID_HDR_LEN;
3674 res = local->func->get_rid(local->dev, param->u.rid.rid,
3675 param->u.rid.data, param->u.rid.len, 0);
3677 param->u.rid.len = res;
3685 static int prism2_ioctl_set_rid(local_info_t *local,
3686 struct prism2_hostapd_param *param,
3691 max_len = param_len - PRISM2_HOSTAPD_RID_HDR_LEN;
3692 if (max_len < 0 || max_len < param->u.rid.len)
3695 return local->func->set_rid(local->dev, param->u.rid.rid,
3696 param->u.rid.data, param->u.rid.len);
3700 static int prism2_ioctl_set_assoc_ap_addr(local_info_t *local,
3701 struct prism2_hostapd_param *param,
3704 DECLARE_MAC_BUF(mac);
3705 printk(KERN_DEBUG "%ssta: associated as client with AP "
3707 local->dev->name, print_mac(mac, param->sta_addr));
3708 memcpy(local->assoc_ap_addr, param->sta_addr, ETH_ALEN);
3713 static int prism2_ioctl_siwgenie(struct net_device *dev,
3714 struct iw_request_info *info,
3715 struct iw_point *data, char *extra)
3717 return prism2_set_genericelement(dev, extra, data->length);
3721 static int prism2_ioctl_giwgenie(struct net_device *dev,
3722 struct iw_request_info *info,
3723 struct iw_point *data, char *extra)
3725 struct hostap_interface *iface = netdev_priv(dev);
3726 local_info_t *local = iface->local;
3727 int len = local->generic_elem_len - 2;
3729 if (len <= 0 || local->generic_elem == NULL) {
3734 if (data->length < len)
3738 memcpy(extra, local->generic_elem + 2, len);
3744 static int prism2_ioctl_set_generic_element(local_info_t *local,
3745 struct prism2_hostapd_param *param,
3750 len = param->u.generic_elem.len;
3751 max_len = param_len - PRISM2_HOSTAPD_GENERIC_ELEMENT_HDR_LEN;
3752 if (max_len < 0 || max_len < len)
3755 return prism2_set_genericelement(local->dev,
3756 param->u.generic_elem.data, len);
3760 static int prism2_ioctl_siwmlme(struct net_device *dev,
3761 struct iw_request_info *info,
3762 struct iw_point *data, char *extra)
3764 struct hostap_interface *iface = netdev_priv(dev);
3765 local_info_t *local = iface->local;
3766 struct iw_mlme *mlme = (struct iw_mlme *) extra;
3769 reason = cpu_to_le16(mlme->reason_code);
3771 switch (mlme->cmd) {
3772 case IW_MLME_DEAUTH:
3773 return prism2_sta_send_mgmt(local, mlme->addr.sa_data,
3774 IEEE80211_STYPE_DEAUTH,
3776 case IW_MLME_DISASSOC:
3777 return prism2_sta_send_mgmt(local, mlme->addr.sa_data,
3778 IEEE80211_STYPE_DISASSOC,
3786 static int prism2_ioctl_mlme(local_info_t *local,
3787 struct prism2_hostapd_param *param)
3791 reason = cpu_to_le16(param->u.mlme.reason_code);
3792 switch (param->u.mlme.cmd) {
3793 case MLME_STA_DEAUTH:
3794 return prism2_sta_send_mgmt(local, param->sta_addr,
3795 IEEE80211_STYPE_DEAUTH,
3797 case MLME_STA_DISASSOC:
3798 return prism2_sta_send_mgmt(local, param->sta_addr,
3799 IEEE80211_STYPE_DISASSOC,
3807 static int prism2_ioctl_scan_req(local_info_t *local,
3808 struct prism2_hostapd_param *param)
3810 #ifndef PRISM2_NO_STATION_MODES
3811 if ((local->iw_mode != IW_MODE_INFRA &&
3812 local->iw_mode != IW_MODE_ADHOC) ||
3813 (local->sta_fw_ver < PRISM2_FW_VER(1,3,1)))
3816 if (!local->dev_enabled)
3819 return prism2_request_hostscan(local->dev, param->u.scan_req.ssid,
3820 param->u.scan_req.ssid_len);
3821 #else /* PRISM2_NO_STATION_MODES */
3823 #endif /* PRISM2_NO_STATION_MODES */
3827 static int prism2_ioctl_priv_hostapd(local_info_t *local, struct iw_point *p)
3829 struct prism2_hostapd_param *param;
3833 if (p->length < sizeof(struct prism2_hostapd_param) ||
3834 p->length > PRISM2_HOSTAPD_MAX_BUF_SIZE || !p->pointer)
3837 param = kmalloc(p->length, GFP_KERNEL);
3841 if (copy_from_user(param, p->pointer, p->length)) {
3846 switch (param->cmd) {
3847 case PRISM2_SET_ENCRYPTION:
3848 ret = prism2_ioctl_set_encryption(local, param, p->length);
3850 case PRISM2_GET_ENCRYPTION:
3851 ret = prism2_ioctl_get_encryption(local, param, p->length);
3853 case PRISM2_HOSTAPD_GET_RID:
3854 ret = prism2_ioctl_get_rid(local, param, p->length);
3856 case PRISM2_HOSTAPD_SET_RID:
3857 ret = prism2_ioctl_set_rid(local, param, p->length);
3859 case PRISM2_HOSTAPD_SET_ASSOC_AP_ADDR:
3860 ret = prism2_ioctl_set_assoc_ap_addr(local, param, p->length);
3862 case PRISM2_HOSTAPD_SET_GENERIC_ELEMENT:
3863 ret = prism2_ioctl_set_generic_element(local, param,
3866 case PRISM2_HOSTAPD_MLME:
3867 ret = prism2_ioctl_mlme(local, param);
3869 case PRISM2_HOSTAPD_SCAN_REQ:
3870 ret = prism2_ioctl_scan_req(local, param);
3873 ret = prism2_hostapd(local->ap, param);
3878 if (ret == 1 || !ap_ioctl) {
3879 if (copy_to_user(p->pointer, param, p->length)) {
3882 } else if (ap_ioctl)
3892 static void prism2_get_drvinfo(struct net_device *dev,
3893 struct ethtool_drvinfo *info)
3895 struct hostap_interface *iface;
3896 local_info_t *local;
3898 iface = netdev_priv(dev);
3899 local = iface->local;
3901 strncpy(info->driver, "hostap", sizeof(info->driver) - 1);
3902 snprintf(info->fw_version, sizeof(info->fw_version) - 1,
3903 "%d.%d.%d", (local->sta_fw_ver >> 16) & 0xff,
3904 (local->sta_fw_ver >> 8) & 0xff,
3905 local->sta_fw_ver & 0xff);
3908 const struct ethtool_ops prism2_ethtool_ops = {
3909 .get_drvinfo = prism2_get_drvinfo
3913 /* Structures to export the Wireless Handlers */
3915 static const iw_handler prism2_handler[] =
3917 (iw_handler) NULL, /* SIOCSIWCOMMIT */
3918 (iw_handler) prism2_get_name, /* SIOCGIWNAME */
3919 (iw_handler) NULL, /* SIOCSIWNWID */
3920 (iw_handler) NULL, /* SIOCGIWNWID */
3921 (iw_handler) prism2_ioctl_siwfreq, /* SIOCSIWFREQ */
3922 (iw_handler) prism2_ioctl_giwfreq, /* SIOCGIWFREQ */
3923 (iw_handler) prism2_ioctl_siwmode, /* SIOCSIWMODE */
3924 (iw_handler) prism2_ioctl_giwmode, /* SIOCGIWMODE */
3925 (iw_handler) prism2_ioctl_siwsens, /* SIOCSIWSENS */
3926 (iw_handler) prism2_ioctl_giwsens, /* SIOCGIWSENS */
3927 (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */
3928 (iw_handler) prism2_ioctl_giwrange, /* SIOCGIWRANGE */
3929 (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */
3930 (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */
3931 (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
3932 (iw_handler) NULL /* kernel code */, /* SIOCGIWSTATS */
3933 iw_handler_set_spy, /* SIOCSIWSPY */
3934 iw_handler_get_spy, /* SIOCGIWSPY */
3935 iw_handler_set_thrspy, /* SIOCSIWTHRSPY */
3936 iw_handler_get_thrspy, /* SIOCGIWTHRSPY */
3937 (iw_handler) prism2_ioctl_siwap, /* SIOCSIWAP */
3938 (iw_handler) prism2_ioctl_giwap, /* SIOCGIWAP */
3939 (iw_handler) prism2_ioctl_siwmlme, /* SIOCSIWMLME */
3940 (iw_handler) prism2_ioctl_giwaplist, /* SIOCGIWAPLIST */
3941 (iw_handler) prism2_ioctl_siwscan, /* SIOCSIWSCAN */
3942 (iw_handler) prism2_ioctl_giwscan, /* SIOCGIWSCAN */
3943 (iw_handler) prism2_ioctl_siwessid, /* SIOCSIWESSID */
3944 (iw_handler) prism2_ioctl_giwessid, /* SIOCGIWESSID */
3945 (iw_handler) prism2_ioctl_siwnickn, /* SIOCSIWNICKN */
3946 (iw_handler) prism2_ioctl_giwnickn, /* SIOCGIWNICKN */
3947 (iw_handler) NULL, /* -- hole -- */
3948 (iw_handler) NULL, /* -- hole -- */
3949 (iw_handler) prism2_ioctl_siwrate, /* SIOCSIWRATE */
3950 (iw_handler) prism2_ioctl_giwrate, /* SIOCGIWRATE */
3951 (iw_handler) prism2_ioctl_siwrts, /* SIOCSIWRTS */
3952 (iw_handler) prism2_ioctl_giwrts, /* SIOCGIWRTS */
3953 (iw_handler) prism2_ioctl_siwfrag, /* SIOCSIWFRAG */
3954 (iw_handler) prism2_ioctl_giwfrag, /* SIOCGIWFRAG */
3955 (iw_handler) prism2_ioctl_siwtxpow, /* SIOCSIWTXPOW */
3956 (iw_handler) prism2_ioctl_giwtxpow, /* SIOCGIWTXPOW */
3957 (iw_handler) prism2_ioctl_siwretry, /* SIOCSIWRETRY */
3958 (iw_handler) prism2_ioctl_giwretry, /* SIOCGIWRETRY */
3959 (iw_handler) prism2_ioctl_siwencode, /* SIOCSIWENCODE */
3960 (iw_handler) prism2_ioctl_giwencode, /* SIOCGIWENCODE */
3961 (iw_handler) prism2_ioctl_siwpower, /* SIOCSIWPOWER */
3962 (iw_handler) prism2_ioctl_giwpower, /* SIOCGIWPOWER */
3963 (iw_handler) NULL, /* -- hole -- */
3964 (iw_handler) NULL, /* -- hole -- */
3965 (iw_handler) prism2_ioctl_siwgenie, /* SIOCSIWGENIE */
3966 (iw_handler) prism2_ioctl_giwgenie, /* SIOCGIWGENIE */
3967 (iw_handler) prism2_ioctl_siwauth, /* SIOCSIWAUTH */
3968 (iw_handler) prism2_ioctl_giwauth, /* SIOCGIWAUTH */
3969 (iw_handler) prism2_ioctl_siwencodeext, /* SIOCSIWENCODEEXT */
3970 (iw_handler) prism2_ioctl_giwencodeext, /* SIOCGIWENCODEEXT */
3971 (iw_handler) NULL, /* SIOCSIWPMKSA */
3972 (iw_handler) NULL, /* -- hole -- */
3975 static const iw_handler prism2_private_handler[] =
3976 { /* SIOCIWFIRSTPRIV + */
3977 (iw_handler) prism2_ioctl_priv_prism2_param, /* 0 */
3978 (iw_handler) prism2_ioctl_priv_get_prism2_param, /* 1 */
3979 (iw_handler) prism2_ioctl_priv_writemif, /* 2 */
3980 (iw_handler) prism2_ioctl_priv_readmif, /* 3 */
3983 const struct iw_handler_def hostap_iw_handler_def =
3985 .num_standard = ARRAY_SIZE(prism2_handler),
3986 .num_private = ARRAY_SIZE(prism2_private_handler),
3987 .num_private_args = ARRAY_SIZE(prism2_priv),
3988 .standard = (iw_handler *) prism2_handler,
3989 .private = (iw_handler *) prism2_private_handler,
3990 .private_args = (struct iw_priv_args *) prism2_priv,
3991 .get_wireless_stats = hostap_get_wireless_stats,
3995 int hostap_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
3997 struct iwreq *wrq = (struct iwreq *) ifr;
3998 struct hostap_interface *iface;
3999 local_info_t *local;
4002 iface = netdev_priv(dev);
4003 local = iface->local;
4006 /* Private ioctls (iwpriv) that have not yet been converted
4007 * into new wireless extensions API */
4009 case PRISM2_IOCTL_INQUIRE:
4010 if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
4011 else ret = prism2_ioctl_priv_inquire(dev, (int *) wrq->u.name);
4014 case PRISM2_IOCTL_MONITOR:
4015 if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
4016 else ret = prism2_ioctl_priv_monitor(dev, (int *) wrq->u.name);
4019 case PRISM2_IOCTL_RESET:
4020 if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
4021 else ret = prism2_ioctl_priv_reset(dev, (int *) wrq->u.name);
4024 case PRISM2_IOCTL_WDS_ADD:
4025 if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
4026 else ret = prism2_wds_add(local, wrq->u.ap_addr.sa_data, 1);
4029 case PRISM2_IOCTL_WDS_DEL:
4030 if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
4031 else ret = prism2_wds_del(local, wrq->u.ap_addr.sa_data, 1, 0);
4034 case PRISM2_IOCTL_SET_RID_WORD:
4035 if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
4036 else ret = prism2_ioctl_priv_set_rid_word(dev,
4037 (int *) wrq->u.name);
4040 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
4041 case PRISM2_IOCTL_MACCMD:
4042 if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
4043 else ret = ap_mac_cmd_ioctl(local, (int *) wrq->u.name);
4046 case PRISM2_IOCTL_ADDMAC:
4047 if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
4048 else ret = ap_control_add_mac(&local->ap->mac_restrictions,
4049 wrq->u.ap_addr.sa_data);
4051 case PRISM2_IOCTL_DELMAC:
4052 if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
4053 else ret = ap_control_del_mac(&local->ap->mac_restrictions,
4054 wrq->u.ap_addr.sa_data);
4056 case PRISM2_IOCTL_KICKMAC:
4057 if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
4058 else ret = ap_control_kick_mac(local->ap, local->dev,
4059 wrq->u.ap_addr.sa_data);
4061 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */
4064 /* Private ioctls that are not used with iwpriv;
4065 * in SIOCDEVPRIVATE range */
4067 #ifdef PRISM2_DOWNLOAD_SUPPORT
4068 case PRISM2_IOCTL_DOWNLOAD:
4069 if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
4070 else ret = prism2_ioctl_priv_download(local, &wrq->u.data);
4072 #endif /* PRISM2_DOWNLOAD_SUPPORT */
4074 case PRISM2_IOCTL_HOSTAPD:
4075 if (!capable(CAP_NET_ADMIN)) ret = -EPERM;
4076 else ret = prism2_ioctl_priv_hostapd(local, &wrq->u.data);