3 #include <linux/slab.h>
4 #include <linux/types.h>
5 #include <linux/sched.h>
6 #include <linux/ethtool.h>
7 #include <linux/if_arp.h>
8 #include <linux/module.h>
18 struct hostap_interface *iface;
22 iface = netdev_priv(dev);
26 if (iface->type != HOSTAP_INTERFACE_MAIN)
29 wstats = &local->wstats;
33 local->comm_tallies.rx_discards_wep_undecryptable;
35 local->comm_tallies.rx_fcs_errors +
36 local->comm_tallies.rx_discards_no_buffer +
37 local->comm_tallies.tx_discards_wrong_sa;
40 local->comm_tallies.tx_retry_limit_exceeded;
42 local->comm_tallies.rx_message_in_bad_msg_fragments;
62 wstats->
qual.qual = local->comms_qual;
63 wstats->
qual.level = local->avg_signal;
64 wstats->
qual.noise = local->avg_noise;
66 wstats->
qual.qual = 0;
67 wstats->
qual.level = 0;
68 wstats->
qual.noise = 0;
76 static int prism2_get_datarates(
struct net_device *dev,
u8 *rates)
78 struct hostap_interface *iface;
84 iface = netdev_priv(dev);
94 if (len - 2 < val || val > 10)
97 memcpy(rates, buf + 2, val);
102 static int prism2_get_name(
struct net_device *dev,
107 int len,
i, over2 = 0;
109 len = prism2_get_datarates(dev, rates);
111 for (i = 0; i < len; i++) {
112 if (rates[i] == 0x0b || rates[i] == 0x16) {
118 strcpy(name, over2 ?
"IEEE 802.11b" :
"IEEE 802.11-DS");
124 static int prism2_ioctl_siwencode(
struct net_device *dev,
128 struct hostap_interface *iface;
133 iface = netdev_priv(dev);
134 local = iface->local;
138 i = local->crypt_info.tx_keyidx;
144 crypt = &local->crypt_info.crypt[
i];
152 if (*crypt !=
NULL && (*crypt)->ops !=
NULL &&
153 strcmp((*crypt)->ops->name,
"WEP") != 0) {
158 if (*crypt ==
NULL) {
164 if (new_crypt ==
NULL)
167 if (!new_crypt->
ops) {
168 request_module(
"lib80211_crypt_wep");
171 if (new_crypt->
ops && try_module_get(new_crypt->
ops->owner))
172 new_crypt->
priv = new_crypt->
ops->init(i);
173 if (!new_crypt->
ops || !new_crypt->
priv) {
178 "load module hostap_crypt_wep.o\n",
186 int len = erq->
length <= 5 ? 5 : 13;
190 (*crypt)->ops->set_key(keybuf, len,
NULL, (*crypt)->priv);
192 if (
j != i && local->crypt_info.crypt[
j]) {
198 local->crypt_info.tx_keyidx =
i;
201 local->crypt_info.tx_keyidx =
i;
217 if (local->iw_mode !=
IW_MODE_INFRA && local->func->reset_port(dev)) {
226 static int prism2_ioctl_giwencode(
struct net_device *dev,
230 struct hostap_interface *iface;
236 iface = netdev_priv(dev);
237 local = iface->local;
241 i = local->crypt_info.tx_keyidx;
244 if (i < 0 || i >= WEP_KEYS)
247 crypt = local->crypt_info.crypt[
i];
256 if (
strcmp(crypt->
ops->name,
"WEP") != 0) {
267 erq->
length = (len >= 0 ? len : 0);
271 printk(
"CNFWEPFLAGS reading failed\n");
288 static int hostap_set_rate(
struct net_device *dev)
290 struct hostap_interface *iface;
292 int ret, basic_rates;
294 iface = netdev_priv(dev);
295 local = iface->local;
297 basic_rates = local->basic_rates & local->tx_rate_control;
298 if (!basic_rates || basic_rates != local->basic_rates) {
300 "to match with the new supported rate set\n",
303 basic_rates = local->tx_rate_control;
305 local->basic_rates = basic_rates;
309 "cnfBasicRates\n", dev->
name);
313 local->tx_rate_control) ||
315 local->tx_rate_control) ||
316 local->func->reset_port(dev));
320 "setting to 0x%x failed\n",
321 dev->
name, local->tx_rate_control);
332 static int prism2_ioctl_siwrate(
struct net_device *dev,
336 struct hostap_interface *iface;
339 iface = netdev_priv(dev);
340 local = iface->local;
343 switch (rrq->
value) {
363 switch (rrq->
value) {
388 return hostap_set_rate(dev);
392 static int prism2_ioctl_giwrate(
struct net_device *dev,
397 struct hostap_interface *iface;
401 iface = netdev_priv(dev);
402 local = iface->local;
408 if ((val & 0x1) && (val > 1))
414 !local->fw_tx_rate_control) {
418 rrq->
value = local->ap->last_tx_rate > 0 ?
419 local->ap->last_tx_rate * 100000 : 11000000;
429 rrq->
value = 1000000;
432 rrq->
value = 2000000;
435 rrq->
value = 5500000;
438 rrq->
value = 11000000;
442 rrq->
value = 11000000;
451 static int prism2_ioctl_siwsens(
struct net_device *dev,
455 struct hostap_interface *iface;
458 iface = netdev_priv(dev);
459 local = iface->local;
466 local->func->reset_port(dev))
472 static int prism2_ioctl_giwsens(
struct net_device *dev,
476 struct hostap_interface *iface;
480 iface = netdev_priv(dev);
481 local = iface->local;
496 static int prism2_ioctl_giwaplist(
struct net_device *dev,
500 struct hostap_interface *iface;
505 iface = netdev_priv(dev);
506 local = iface->local;
510 "in Host AP mode\n");
537 static int prism2_ioctl_siwrts(
struct net_device *dev,
541 struct hostap_interface *iface;
545 iface = netdev_priv(dev);
546 local = iface->local;
556 local->func->reset_port(dev))
559 local->rts_threshold = rts->
value;
564 static int prism2_ioctl_giwrts(
struct net_device *dev,
568 struct hostap_interface *iface;
572 iface = netdev_priv(dev);
573 local = iface->local;
587 static int prism2_ioctl_siwfrag(
struct net_device *dev,
591 struct hostap_interface *iface;
595 iface = netdev_priv(dev);
596 local = iface->local;
600 else if (rts->
value < 256 || rts->
value > 2346)
605 local->fragm_threshold = rts->
value & ~0x1;
608 || local->func->reset_port(dev))
614 static int prism2_ioctl_giwfrag(
struct net_device *dev,
618 struct hostap_interface *iface;
622 iface = netdev_priv(dev);
623 local = iface->local;
637 #ifndef PRISM2_NO_STATION_MODES
638 static int hostap_join_ap(
struct net_device *dev)
640 struct hostap_interface *iface;
647 iface = netdev_priv(dev);
648 local = iface->local;
654 for (i = 0; i < local->last_scan_results_count; i++) {
655 if (!local->last_scan_results)
657 entry = &local->last_scan_results[
i];
663 spin_unlock_irqrestore(&local->lock, flags);
668 dev->
name, local->preferred_ap);
673 dev->
name, local->preferred_ap);
680 static int prism2_ioctl_siwap(
struct net_device *dev,
682 struct sockaddr *ap_addr,
char *extra)
684 #ifdef PRISM2_NO_STATION_MODES
687 struct hostap_interface *iface;
690 iface = netdev_priv(dev);
691 local = iface->local;
695 if (local->host_roaming == 1 && local->iw_mode ==
IW_MODE_INFRA) {
697 memset(&scan_req, 0,
sizeof(scan_req));
701 &scan_req,
sizeof(scan_req))) {
703 "preferred AP delayed to next unsolicited "
704 "scan\n", dev->
name);
706 }
else if (local->host_roaming == 2 &&
708 if (hostap_join_ap(dev))
712 "in Managed mode when host_roaming is enabled\n",
720 static int prism2_ioctl_giwap(
struct net_device *dev,
722 struct sockaddr *ap_addr,
char *extra)
724 struct hostap_interface *iface;
727 iface = netdev_priv(dev);
728 local = iface->local;
731 switch (iface->type) {
732 case HOSTAP_INTERFACE_AP:
735 case HOSTAP_INTERFACE_STA:
738 case HOSTAP_INTERFACE_WDS:
756 static int prism2_ioctl_siwnickn(
struct net_device *dev,
758 struct iw_point *data,
char *nickname)
760 struct hostap_interface *iface;
763 iface = netdev_priv(dev);
764 local = iface->local;
766 memset(local->name, 0,
sizeof(local->name));
771 local->func->reset_port(dev))
777 static int prism2_ioctl_giwnickn(
struct net_device *dev,
779 struct iw_point *data,
char *nickname)
781 struct hostap_interface *iface;
787 iface = netdev_priv(dev);
788 local = iface->local;
796 name[val + 2] =
'\0';
798 memcpy(nickname, name + 2, val + 1);
804 static int prism2_ioctl_siwfreq(
struct net_device *dev,
808 struct hostap_interface *iface;
811 iface = netdev_priv(dev);
812 local = iface->local;
816 freq->
m / 100000 >= freq_list[0] &&
819 int fr = freq->
m / 100000;
821 if (fr == freq_list[ch]) {
829 if (freq->
e != 0 || freq->
m < 1 || freq->
m > FREQ_COUNT ||
830 !(local->channel_mask & (1 << (freq->
m - 1))))
833 local->channel = freq->
m;
835 local->func->reset_port(dev))
841 static int prism2_ioctl_giwfreq(
struct net_device *dev,
843 struct iw_freq *freq,
char *extra)
845 struct hostap_interface *iface;
849 iface = netdev_priv(dev);
850 local = iface->local;
857 if (val < 1 || val > FREQ_COUNT)
860 freq->
m = freq_list[val - 1] * 100000;
867 static void hostap_monitor_set_type(
local_info_t *local)
874 if (local->monitor_type == PRISM2_MONITOR_PRISM ||
875 local->monitor_type == PRISM2_MONITOR_CAPHDR) {
877 }
else if (local->monitor_type == PRISM2_MONITOR_RADIOTAP) {
885 static int prism2_ioctl_siwessid(
struct net_device *dev,
889 struct hostap_interface *iface;
892 iface = netdev_priv(dev);
893 local = iface->local;
895 if (iface->type == HOSTAP_INTERFACE_WDS)
898 if (data->
flags == 0)
905 "'Any' essid\n", dev->
name);
910 local->essid[data->
length] =
'\0';
912 if ((!local->fw_ap &&
915 local->func->reset_port(dev))
921 static int prism2_ioctl_giwessid(
struct net_device *dev,
925 struct hostap_interface *iface;
929 iface = netdev_priv(dev);
930 local = iface->local;
932 if (iface->type == HOSTAP_INTERFACE_WDS)
941 char ssid[MAX_SSID_LEN + 2];
942 memset(ssid, 0,
sizeof(ssid));
944 &ssid, MAX_SSID_LEN + 2, 0);
946 if (len > MAX_SSID_LEN + 2 || len < 0 || val > MAX_SSID_LEN) {
957 static int prism2_ioctl_giwrange(
struct net_device *dev,
961 struct hostap_interface *iface;
968 iface = netdev_priv(dev);
969 local = iface->local;
1003 if (local->channel_mask & (1 << i)) {
1005 range->
freq[
val].m = freq_list[
i] * 100000;
1014 if (local->sta_fw_ver >= PRISM2_FW_VER(1,3,1)) {
1038 len = prism2_get_datarates(dev, rates);
1040 for (i = 0; i < len; i++) {
1046 if (rates[i] == 0x0b || rates[i] == 0x16)
1050 range->
throughput = over2 ? 5500000 : 1500000;
1071 if (local->sta_fw_ver >= PRISM2_FW_VER(1,3,1))
1078 static int hostap_monitor_mode_enable(
local_info_t *local)
1083 hostap_monitor_set_type(local);
1102 if (local->func->reset_port(dev) ||
1114 static int hostap_monitor_mode_disable(
local_info_t *local)
1132 static int prism2_ioctl_siwmode(
struct net_device *dev,
1136 struct hostap_interface *iface;
1138 int double_reset = 0;
1140 iface = netdev_priv(dev);
1141 local = iface->local;
1148 #ifdef PRISM2_NO_STATION_MODES
1153 if (*mode == local->iw_mode)
1158 "mode\n", dev->
name);
1163 hostap_monitor_mode_disable(local);
1175 "%d -> %d\n", dev->
name, local->iw_mode, *mode);
1176 local->iw_mode = *
mode;
1179 hostap_monitor_mode_enable(local);
1180 else if (local->iw_mode ==
IW_MODE_MASTER && !local->host_encrypt &&
1181 !local->fw_encrypt_ok) {
1183 "a workaround for firmware bug in Host AP mode WEP\n",
1185 local->host_encrypt = 1;
1192 if (local->func->reset_port(dev))
1194 if (double_reset && local->func->reset_port(dev))
1208 static int prism2_ioctl_giwmode(
struct net_device *dev,
1210 __u32 *mode,
char *extra)
1212 struct hostap_interface *iface;
1215 iface = netdev_priv(dev);
1216 local = iface->local;
1218 switch (iface->type) {
1219 case HOSTAP_INTERFACE_STA:
1222 case HOSTAP_INTERFACE_WDS:
1226 *mode = local->iw_mode;
1233 static int prism2_ioctl_siwpower(
struct net_device *dev,
1237 #ifdef PRISM2_NO_STATION_MODES
1292 static int prism2_ioctl_giwpower(
struct net_device *dev,
1296 #ifdef PRISM2_NO_STATION_MODES
1299 struct hostap_interface *iface;
1303 iface = netdev_priv(dev);
1304 local = iface->local;
1319 if (local->func->get_rid(dev,
1321 &timeout, 2, 1) < 0)
1350 static int prism2_ioctl_siwretry(
struct net_device *dev,
1354 struct hostap_interface *iface;
1357 iface = netdev_priv(dev);
1358 local = iface->local;
1366 if (rrq->
value < 0) {
1369 local->manual_retry_count = -1;
1375 "setting to %d failed\n",
1380 local->manual_retry_count = rrq->
value;
1411 static int prism2_ioctl_giwretry(
struct net_device *dev,
1415 struct hostap_interface *iface;
1417 __le16 shortretry, longretry, lifetime, altretry;
1419 iface = netdev_priv(dev);
1420 local = iface->local;
1427 &lifetime, 2, 1) < 0)
1436 if (local->manual_retry_count >= 0) {
1438 if (local->func->get_rid(dev,
1440 &altretry, 2, 1) >= 0)
1443 rrq->
value = local->manual_retry_count;
1450 if (shortretry != longretry)
1465 #ifdef RAW_TXPOWER_SETTING
1474 static int prism2_txpower_hfa386x_to_dBm(
u16 val)
1487 static u16 prism2_txpower_dBm_to_hfa386x(
int val)
1500 return (
unsigned char)
tmp;
1505 static int prism2_ioctl_siwtxpow(
struct net_device *dev,
1509 struct hostap_interface *iface;
1511 #ifdef RAW_TXPOWER_SETTING
1517 iface = netdev_priv(dev);
1518 local = iface->local;
1521 if (local->txpower_type != PRISM2_TXPOWER_OFF) {
1527 dev->
name, ret ?
"failed" :
"OK");
1528 local->txpower_type = PRISM2_TXPOWER_OFF;
1533 if (local->txpower_type == PRISM2_TXPOWER_OFF) {
1538 dev->
name, ret ?
"failed" :
"OK");
1539 local->txpower_type = PRISM2_TXPOWER_UNKNOWN;
1542 #ifdef RAW_TXPOWER_SETTING
1543 if (!rrq->
fixed && local->txpower_type != PRISM2_TXPOWER_AUTO) {
1548 local->txpower_type = PRISM2_TXPOWER_AUTO;
1552 if (local->txpower_type != PRISM2_TXPOWER_FIXED) {
1557 local->txpower_type = PRISM2_TXPOWER_FIXED;
1569 printk(
"SIOCSIWTXPOW with mW is not supported; use dBm\n");
1573 local->txpower = rrq->
value;
1574 val = prism2_txpower_dBm_to_hfa386x(local->txpower);
1586 static int prism2_ioctl_giwtxpow(
struct net_device *dev,
1590 #ifdef RAW_TXPOWER_SETTING
1591 struct hostap_interface *iface;
1595 iface = netdev_priv(dev);
1596 local = iface->local;
1602 if (local->txpower_type == PRISM2_TXPOWER_AUTO) {
1605 NULL, &resp0) == 0) {
1606 rrq->
value = prism2_txpower_hfa386x_to_dBm(resp0);
1611 }
else if (local->txpower_type == PRISM2_TXPOWER_OFF) {
1614 }
else if (local->txpower_type == PRISM2_TXPOWER_FIXED) {
1615 rrq->
value = local->txpower;
1618 printk(
"SIOCGIWTXPOW - unknown txpower_type=%d\n",
1619 local->txpower_type);
1628 #ifndef PRISM2_NO_STATION_MODES
1633 static int prism2_request_hostscan(
struct net_device *dev,
1634 u8 *ssid,
u8 ssid_len)
1636 struct hostap_interface *iface;
1640 iface = netdev_priv(dev);
1641 local = iface->local;
1643 memset(&scan_req, 0,
sizeof(scan_req));
1644 scan_req.channel_list =
cpu_to_le16(local->channel_mask &
1645 local->scan_channel_mask);
1651 memcpy(scan_req.target_ssid, ssid, ssid_len);
1655 sizeof(scan_req))) {
1663 static int prism2_request_scan(
struct net_device *dev)
1665 struct hostap_interface *iface;
1670 iface = netdev_priv(dev);
1671 local = iface->local;
1673 memset(&scan_req, 0,
sizeof(scan_req));
1674 scan_req.channel_list =
cpu_to_le16(local->channel_mask &
1675 local->scan_channel_mask);
1687 if (!local->host_roaming)
1692 sizeof(scan_req))) {
1697 if (!local->host_roaming)
1706 static inline int prism2_request_hostscan(
struct net_device *dev,
1707 u8 *ssid,
u8 ssid_len)
1713 static inline int prism2_request_scan(
struct net_device *dev)
1721 static int prism2_ioctl_siwscan(
struct net_device *dev,
1723 struct iw_point *data,
char *extra)
1725 struct hostap_interface *iface;
1728 u8 *ssid =
NULL, ssid_len = 0;
1731 iface = netdev_priv(dev);
1732 local = iface->local;
1745 if (!local->dev_enabled)
1755 (local->sta_fw_ver < PRISM2_FW_VER(1,3,1))))
1759 if (local->sta_fw_ver >= PRISM2_FW_VER(1,3,1))
1760 ret = prism2_request_hostscan(dev, ssid, ssid_len);
1762 ret = prism2_request_scan(dev);
1765 local->scan_timestamp =
jiffies;
1773 #ifndef PRISM2_NO_STATION_MODES
1774 static char * __prism2_translate_scan(
local_info_t *local,
1777 struct hostap_bss_info *bss,
1778 char *current_ev,
char *end_buf)
1791 ssid_len = bss->ssid_len;
1796 bssid = scan->
bssid;
1802 memset(&iwe, 0,
sizeof(iwe));
1806 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe,
1811 memset(&iwe, 0,
sizeof(iwe));
1813 iwe.u.data.length = ssid_len;
1814 iwe.u.data.flags = 1;
1815 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
1818 memset(&iwe, 0,
sizeof(iwe));
1821 capabilities = bss->capab_info;
1831 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
1835 memset(&iwe, 0,
sizeof(iwe));
1846 iwe.u.freq.m = freq_list[chan - 1] * 100000;
1848 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
1853 memset(&iwe, 0,
sizeof(iwe));
1855 if (local->last_scan_type == PRISM2_HOSTSCAN) {
1868 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
1872 memset(&iwe, 0,
sizeof(iwe));
1878 iwe.u.data.length = 0;
1879 current_ev = iwe_stream_add_point(info, current_ev, end_buf, &iwe,
"");
1883 memset(&iwe, 0,
sizeof(iwe));
1885 current_val = current_ev + iwe_stream_lcp_len(info);
1887 for (i = 0; i <
sizeof(scan->
sup_rates); i++) {
1891 iwe.u.bitrate.value = ((pos[
i] & 0x7f) * 500000);
1892 current_val = iwe_stream_add_value(
1893 info, current_ev, current_val, end_buf, &iwe,
1897 if ((current_val - current_ev) > iwe_stream_lcp_len(info))
1898 current_ev = current_val;
1904 memset(&iwe, 0,
sizeof(iwe));
1907 iwe.u.data.length =
strlen(buf);
1908 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
1911 memset(&iwe, 0,
sizeof(iwe));
1914 iwe.u.data.length =
strlen(buf);
1915 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
1918 if (local->last_scan_type == PRISM2_HOSTSCAN &&
1920 memset(&iwe, 0,
sizeof(iwe));
1923 iwe.u.data.length =
strlen(buf);
1924 current_ev = iwe_stream_add_point(info, current_ev,
1925 end_buf, &iwe, buf);
1930 if (bss && bss->wpa_ie_len > 0 && bss->wpa_ie_len <=
MAX_WPA_IE_LEN) {
1931 memset(&iwe, 0,
sizeof(iwe));
1933 iwe.u.data.length = bss->wpa_ie_len;
1934 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
1938 if (bss && bss->rsn_ie_len > 0 && bss->rsn_ie_len <=
MAX_WPA_IE_LEN) {
1939 memset(&iwe, 0,
sizeof(iwe));
1941 iwe.u.data.length = bss->rsn_ie_len;
1942 current_ev = iwe_stream_add_point(info, current_ev, end_buf,
1952 static inline int prism2_translate_scan(
local_info_t *local,
1957 int entry, hostscan;
1958 char *current_ev =
buffer;
1959 char *end_buf = buffer +
buflen;
1962 spin_lock_bh(&local->lock);
1965 struct hostap_bss_info *bss;
1970 hostscan = local->last_scan_type == PRISM2_HOSTSCAN;
1971 for (entry = 0; entry < local->last_scan_results_count; entry++) {
1973 scan = &local->last_scan_results[
entry];
1979 struct hostap_bss_info *bss;
1983 current_ev = __prism2_translate_scan(
1984 local, info, scan, bss, current_ev,
1990 current_ev = __prism2_translate_scan(
1991 local, info, scan,
NULL, current_ev, end_buf);
1996 spin_unlock_bh(&local->lock);
2005 struct hostap_bss_info *bss;
2009 current_ev = __prism2_translate_scan(local, info,
NULL, bss,
2010 current_ev, end_buf);
2014 spin_unlock_bh(&local->lock);
2019 spin_unlock_bh(&local->lock);
2021 return current_ev -
buffer;
2026 static inline int prism2_ioctl_giwscan_sta(
struct net_device *dev,
2028 struct iw_point *data,
char *extra)
2030 #ifdef PRISM2_NO_STATION_MODES
2033 struct hostap_interface *iface;
2037 iface = netdev_priv(dev);
2038 local = iface->local;
2042 if (local->scan_timestamp &&
2054 local->scan_timestamp = 0;
2056 res = prism2_translate_scan(local, info, extra, data->
length);
2069 static int prism2_ioctl_giwscan(
struct net_device *dev,
2071 struct iw_point *data,
char *extra)
2073 struct hostap_interface *iface;
2077 iface = netdev_priv(dev);
2078 local = iface->local;
2092 "(length=%d)\n", res);
2097 "Scan result translation failed (res=%d)\n",
2104 return prism2_ioctl_giwscan_sta(dev, info, data, extra);
2155 #ifndef PRISM2_NO_STATION_MODES
2213 #ifndef PRISM2_NO_STATION_MODES
2255 #ifdef PRISM2_IO_DEBUG
2300 static int prism2_ioctl_priv_inquire(
struct net_device *dev,
int *i)
2302 struct hostap_interface *iface;
2305 iface = netdev_priv(dev);
2306 local = iface->local;
2315 static int prism2_ioctl_priv_prism2_param(
struct net_device *dev,
2317 void *wrqu,
char *extra)
2319 struct hostap_interface *iface;
2321 int *i = (
int *) extra;
2323 int value = *(i + 1);
2327 iface = netdev_priv(dev);
2328 local = iface->local;
2332 local->fw_tx_rate_control =
value;
2337 local->func->reset_port(dev))
2340 local->beacon_int =
value;
2343 #ifndef PRISM2_NO_STATION_MODES
2345 if (value == local->pseudo_adhoc)
2348 if (value != 0 && value != 1) {
2354 dev->
name, local->pseudo_adhoc, value);
2355 local->pseudo_adhoc =
value;
2365 if (local->func->reset_port(dev))
2372 value == 0 ?
"Disabling" :
"Enabling");
2376 value == 0 ? 0 : 1, &val,
NULL);
2380 local->frame_dump =
value;
2384 if (value < 0 || value > 3) {
2388 if (local->ap !=
NULL)
2389 local->ap->ap_policy =
value;
2393 if (value < 0 || value > 7 * 24 * 60 * 60) {
2397 if (local->ap !=
NULL)
2398 local->ap->max_inactivity = value *
HZ;
2402 if (local->ap !=
NULL)
2403 local->ap->bridge_packets =
value;
2407 if (value < 0 || value > 65535) {
2412 || local->func->reset_port(dev))
2415 local->dtim_period =
value;
2419 if (local->ap !=
NULL)
2420 local->ap->nullfunc_ack =
value;
2424 local->wds_max_connections =
value;
2428 if (local->ap !=
NULL) {
2429 if (!local->ap->autom_ap_wds && value) {
2433 local->ap->autom_ap_wds =
value;
2438 local->auth_algs =
value;
2444 local->monitor_allow_fcserr =
value;
2448 local->host_encrypt =
value;
2450 local->func->reset_port(dev))
2455 local->host_decrypt =
value;
2457 local->func->reset_port(dev))
2461 #ifndef PRISM2_NO_STATION_MODES
2463 if (value < 0 || value > 2) {
2467 local->host_roaming =
value;
2474 local->bcrx_sta_key =
value;
2478 local->ieee_802_1x =
value;
2486 local->antsel_tx =
value;
2491 if (value < 0 || value > HOSTAP_ANTSEL_HIGH) {
2495 local->antsel_rx =
value;
2500 if (value != PRISM2_MONITOR_80211 &&
2501 value != PRISM2_MONITOR_CAPHDR &&
2502 value != PRISM2_MONITOR_PRISM &&
2503 value != PRISM2_MONITOR_RADIOTAP) {
2507 local->monitor_type =
value;
2509 hostap_monitor_set_type(local);
2513 local->wds_type =
value;
2521 memset(&scan_req, 0,
sizeof(scan_req));
2536 local->func->reset_port(dev))
2538 "for HostScan failed\n");
2542 sizeof(scan_req))) {
2548 init_waitqueue_entry(&__wait,
current);
2559 local->func->reset_port(dev))
2561 "after HostScan failed\n");
2567 local->passive_scan_interval =
value;
2568 if (timer_pending(&local->passive_scan_timer))
2571 local->passive_scan_timer.expires =
jiffies +
2572 local->passive_scan_interval *
HZ;
2578 if (value < 0 || value > 3) {
2582 local->enh_sec =
value;
2585 local->func->reset_port(dev)) {
2587 "1.6.3 or newer\n", dev->
name);
2592 #ifdef PRISM2_IO_DEBUG
2594 local->io_debug_enabled =
value;
2599 if ((value & local->tx_rate_control) != value || value == 0) {
2601 "rates must be in supported rate set\n",
2606 local->basic_rates =
value;
2608 local->basic_rates) ||
2609 local->func->reset_port(dev))
2614 local->tx_rate_control =
value;
2615 if (hostap_set_rate(dev))
2629 if (local->sta_fw_ver < PRISM2_FW_VER(1,7,0))
2637 local->privacy_invoked =
value;
2639 local->func->reset_port(dev))
2644 local->tkip_countermeasures =
value;
2648 local->drop_unencrypted =
value;
2652 local->scan_channel_mask =
value;
2666 static int prism2_ioctl_priv_get_prism2_param(
struct net_device *dev,
2668 void *wrqu,
char *extra)
2670 struct hostap_interface *iface;
2672 int *param = (
int *) extra;
2675 iface = netdev_priv(dev);
2676 local = iface->local;
2680 *param = local->fw_tx_rate_control;
2684 *param = local->beacon_int;
2688 *param = local->pseudo_adhoc;
2696 *param = local->frame_dump;
2700 if (local->ap !=
NULL)
2701 *param = local->ap->ap_policy;
2707 if (local->ap !=
NULL)
2708 *param = local->ap->max_inactivity /
HZ;
2714 if (local->ap !=
NULL)
2715 *param = local->ap->bridge_packets;
2721 *param = local->dtim_period;
2725 if (local->ap !=
NULL)
2726 *param = local->ap->nullfunc_ack;
2732 *param = local->wds_max_connections;
2736 if (local->ap !=
NULL)
2737 *param = local->ap->autom_ap_wds;
2743 *param = local->auth_algs;
2747 *param = local->monitor_allow_fcserr;
2751 *param = local->host_encrypt;
2755 *param = local->host_decrypt;
2759 *param = local->host_roaming;
2763 *param = local->bcrx_sta_key;
2767 *param = local->ieee_802_1x;
2771 *param = local->antsel_tx;
2775 *param = local->antsel_rx;
2779 *param = local->monitor_type;
2783 *param = local->wds_type;
2791 *param = local->passive_scan_interval;
2795 *param = local->enh_sec;
2798 #ifdef PRISM2_IO_DEBUG
2800 *param = local->io_debug_enabled;
2805 *param = local->basic_rates;
2809 *param = local->tx_rate_control;
2813 *param = local->hostapd;
2817 *param = local->hostapd_sta;
2821 if (local->sta_fw_ver < PRISM2_FW_VER(1,7,0))
2823 *param = local->wpa;
2827 *param = local->privacy_invoked;
2831 *param = local->tkip_countermeasures;
2835 *param = local->drop_unencrypted;
2839 *param = local->scan_channel_mask;
2853 static int prism2_ioctl_priv_readmif(
struct net_device *dev,
2855 void *wrqu,
char *extra)
2857 struct hostap_interface *iface;
2861 iface = netdev_priv(dev);
2862 local = iface->local;
2874 static int prism2_ioctl_priv_writemif(
struct net_device *dev,
2876 void *wrqu,
char *extra)
2878 struct hostap_interface *iface;
2882 iface = netdev_priv(dev);
2883 local = iface->local;
2894 static int prism2_ioctl_priv_monitor(
struct net_device *dev,
int *i)
2896 struct hostap_interface *iface;
2901 iface = netdev_priv(dev);
2902 local = iface->local;
2905 "- update software to use iwconfig mode monitor\n",
2914 ret = prism2_ioctl_siwmode(dev,
NULL, &mode,
NULL);
2915 }
else if (*i == 1) {
2921 }
else if (*i == 2 || *i == 3) {
2924 local->monitor_type = PRISM2_MONITOR_80211;
2927 local->monitor_type = PRISM2_MONITOR_PRISM;
2931 ret = prism2_ioctl_siwmode(dev,
NULL, &mode,
NULL);
2932 hostap_monitor_mode_enable(local);
2940 static int prism2_ioctl_priv_reset(
struct net_device *dev,
int *i)
2942 struct hostap_interface *iface;
2945 iface = netdev_priv(dev);
2946 local = iface->local;
2952 local->func->hw_shutdown(dev, 1);
2953 local->func->hw_config(dev, 0);
2958 local->func->hw_reset(dev);
2963 local->func->reset_port(dev);
2988 static int prism2_ioctl_priv_set_rid_word(
struct net_device *dev,
int *i)
2991 int value = *(i + 1);
3002 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
3009 local->ap->mac_restrictions.policy = MAC_POLICY_OPEN;
3012 local->ap->mac_restrictions.policy = MAC_POLICY_ALLOW;
3015 local->ap->mac_restrictions.policy = MAC_POLICY_DENY;
3034 #ifdef PRISM2_DOWNLOAD_SUPPORT
3054 param->
num_areas *
sizeof(
struct prism2_download_area)) {
3059 ret = local->func->download(local, param);
3071 struct hostap_interface *iface = netdev_priv(dev);
3084 memcpy(buf + 2, elem, len);
3086 kfree(local->generic_elem);
3087 local->generic_elem =
buf;
3088 local->generic_elem_len = len + 2;
3095 static int prism2_ioctl_siwauth(
struct net_device *dev,
3097 struct iw_param *data,
char *extra)
3099 struct hostap_interface *iface = netdev_priv(dev);
3113 local->tkip_countermeasures = data->
value;
3116 local->drop_unencrypted = data->
value;
3119 local->auth_algs = data->
value;
3122 if (data->
value == 0) {
3124 if (local->sta_fw_ver < PRISM2_FW_VER(1,7,0))
3126 prism2_set_genericelement(dev,
"", 0);
3127 local->host_roaming = 0;
3128 local->privacy_invoked = 0;
3133 local->func->reset_port(dev))
3137 if (local->sta_fw_ver < PRISM2_FW_VER(1,7,0))
3139 local->host_roaming = 2;
3140 local->privacy_invoked = 1;
3145 local->func->reset_port(dev))
3149 local->ieee_802_1x = data->
value;
3152 local->privacy_invoked = data->
value;
3161 static int prism2_ioctl_giwauth(
struct net_device *dev,
3163 struct iw_param *data,
char *extra)
3165 struct hostap_interface *iface = netdev_priv(dev);
3179 data->
value = local->tkip_countermeasures;
3182 data->
value = local->drop_unencrypted;
3185 data->
value = local->auth_algs;
3188 data->
value = local->wpa;
3191 data->
value = local->ieee_802_1x;
3200 static int prism2_ioctl_siwencodeext(
struct net_device *dev,
3204 struct hostap_interface *iface = netdev_priv(dev);
3212 const char *alg, *
module;
3217 if (i < 1 || i > WEP_KEYS)
3218 i = local->crypt_info.tx_keyidx;
3221 if (i < 0 || i >= WEP_KEYS)
3224 addr = ext->
addr.sa_data;
3225 if (is_broadcast_ether_addr(addr)) {
3227 crypt = &local->crypt_info.crypt[
i];
3232 if (sta_ptr ==
NULL) {
3240 crypt = &local->crypt_info.crypt[
i];
3256 module =
"lib80211_crypt_wep";
3260 module =
"lib80211_crypt_tkip";
3264 module =
"lib80211_crypt_ccmp";
3268 local->
dev->name, ext->
alg);
3275 request_module(module);
3280 local->
dev->name, alg);
3291 local->host_decrypt = local->host_encrypt = 1;
3294 if (*crypt ==
NULL || (*crypt)->ops != ops) {
3301 if (new_crypt ==
NULL) {
3306 if (new_crypt->
ops && try_module_get(new_crypt->
ops->owner))
3307 new_crypt->
priv = new_crypt->
ops->init(i);
3324 && (*crypt)->ops->set_key &&
3326 (*crypt)->priv) < 0) {
3335 local->crypt_info.tx_keyidx =
i;
3342 if (
j != i && local->crypt_info.crypt[
j]) {
3348 local->crypt_info.tx_keyidx =
i;
3367 local->func->reset_port(local->
dev))))
3374 static int prism2_ioctl_giwencodeext(
struct net_device *dev,
3378 struct hostap_interface *iface = netdev_priv(dev);
3386 max_key_len = erq->
length -
sizeof(*ext);
3387 if (max_key_len < 0)
3391 if (i < 1 || i > WEP_KEYS)
3392 i = local->crypt_info.tx_keyidx;
3396 addr = ext->
addr.sa_data;
3397 if (is_broadcast_ether_addr(addr)) {
3399 crypt = &local->crypt_info.crypt[
i];
3403 if (sta_ptr ==
NULL)
3407 memset(ext, 0,
sizeof(*ext));
3409 if (*crypt ==
NULL || (*crypt)->ops ==
NULL) {
3414 if (
strcmp((*crypt)->ops->name,
"WEP") == 0)
3416 else if (
strcmp((*crypt)->ops->name,
"TKIP") == 0)
3418 else if (
strcmp((*crypt)->ops->name,
"CCMP") == 0)
3423 if ((*crypt)->ops->get_key) {
3425 (*crypt)->ops->get_key(ext->
key,
3443 static int prism2_ioctl_set_encryption(
local_info_t *local,
3456 (
int) ((
char *) param->
u.
crypt.key - (
char *) param) +
3460 if (is_broadcast_ether_addr(param->
sta_addr)) {
3461 if (param->
u.
crypt.idx >= WEP_KEYS)
3464 crypt = &local->crypt_info.crypt[param->
u.
crypt.idx];
3473 if (sta_ptr ==
NULL) {
3487 request_module(
"lib80211_crypt_wep");
3490 request_module(
"lib80211_crypt_tkip");
3493 request_module(
"lib80211_crypt_ccmp");
3506 local->host_decrypt = local->host_encrypt = 1;
3508 if (*crypt ==
NULL || (*crypt)->ops != ops) {
3515 if (new_crypt ==
NULL) {
3533 param->
u.
crypt.key_len > 0) && (*crypt)->ops->set_key &&
3534 (*crypt)->ops->set_key(param->
u.
crypt.key,
3536 (*crypt)->priv) < 0) {
3546 local->crypt_info.tx_keyidx = param->
u.
crypt.idx;
3547 else if (param->
u.
crypt.idx) {
3569 local->func->reset_port(local->
dev)))) {
3578 static int prism2_ioctl_get_encryption(
local_info_t *local,
3588 max_key_len = param_len -
3589 (
int) ((
char *) param->
u.crypt.key - (
char *) param);
3590 if (max_key_len < 0)
3593 if (is_broadcast_ether_addr(param->sta_addr)) {
3595 if (param->u.crypt.idx >= WEP_KEYS)
3596 param->u.crypt.idx = local->crypt_info.tx_keyidx;
3597 crypt = &local->crypt_info.crypt[param->u.crypt.idx];
3599 param->u.crypt.idx = 0;
3603 if (sta_ptr ==
NULL) {
3609 if (*crypt ==
NULL || (*crypt)->ops ==
NULL) {
3610 memcpy(param->u.crypt.alg,
"none", 5);
3611 param->u.crypt.key_len = 0;
3612 param->u.crypt.idx = 0xff;
3614 strncpy(param->u.crypt.alg, (*crypt)->ops->name,
3616 param->u.crypt.key_len = 0;
3618 memset(param->u.crypt.seq, 0, 8);
3619 if ((*crypt)->ops->get_key) {
3620 param->u.crypt.key_len =
3621 (*crypt)->ops->get_key(param->u.crypt.key,
3645 res = local->func->get_rid(local->
dev, param->
u.
rid.rid,
3646 param->
u.
rid.data, param->
u.
rid.len, 0);
3663 if (max_len < 0 || max_len < param->
u.rid.len)
3666 return local->func->set_rid(local->
dev, param->
u.
rid.rid,
3667 param->
u.
rid.data, param->
u.
rid.len);
3671 static int prism2_ioctl_set_assoc_ap_addr(
local_info_t *local,
3682 static int prism2_ioctl_siwgenie(
struct net_device *dev,
3684 struct iw_point *data,
char *extra)
3686 return prism2_set_genericelement(dev, extra, data->
length);
3690 static int prism2_ioctl_giwgenie(
struct net_device *dev,
3692 struct iw_point *data,
char *extra)
3694 struct hostap_interface *iface = netdev_priv(dev);
3696 int len = local->generic_elem_len - 2;
3698 if (len <= 0 || local->generic_elem ==
NULL) {
3707 memcpy(extra, local->generic_elem + 2, len);
3713 static int prism2_ioctl_set_generic_element(
local_info_t *local,
3721 if (max_len < 0 || max_len < len)
3724 return prism2_set_genericelement(local->
dev,
3729 static int prism2_ioctl_siwmlme(
struct net_device *dev,
3731 struct iw_point *data,
char *extra)
3733 struct hostap_interface *iface = netdev_priv(dev);
3740 switch (mlme->
cmd) {
3761 switch (param->
u.
mlme.cmd) {
3779 #ifndef PRISM2_NO_STATION_MODES
3782 (local->sta_fw_ver < PRISM2_FW_VER(1,3,1)))
3785 if (!local->dev_enabled)
3788 return prism2_request_hostscan(local->
dev, param->
u.
scan_req.ssid,
3815 switch (param->
cmd) {
3817 ret = prism2_ioctl_set_encryption(local, param, p->
length);
3820 ret = prism2_ioctl_get_encryption(local, param, p->
length);
3823 ret = prism2_ioctl_get_rid(local, param, p->
length);
3826 ret = prism2_ioctl_set_rid(local, param, p->
length);
3829 ret = prism2_ioctl_set_assoc_ap_addr(local, param, p->
length);
3832 ret = prism2_ioctl_set_generic_element(local, param,
3836 ret = prism2_ioctl_mlme(local, param);
3839 ret = prism2_ioctl_scan_req(local, param);
3847 if (ret == 1 || !ap_ioctl) {
3851 }
else if (ap_ioctl)
3861 static void prism2_get_drvinfo(
struct net_device *dev,
3864 struct hostap_interface *iface;
3867 iface = netdev_priv(dev);
3868 local = iface->local;
3872 "%d.%d.%d", (local->sta_fw_ver >> 16) & 0xff,
3873 (local->sta_fw_ver >> 8) & 0xff,
3874 local->sta_fw_ver & 0xff);
3878 .get_drvinfo = prism2_get_drvinfo
3947 (
iw_handler) prism2_ioctl_priv_get_prism2_param,
3955 .num_private =
ARRAY_SIZE(prism2_private_handler),
3958 .
private = (
iw_handler *) prism2_private_handler,
3967 struct hostap_interface *iface;
3971 iface = netdev_priv(dev);
3972 local = iface->local;
3980 else ret = prism2_ioctl_priv_inquire(dev, (
int *) wrq->
u.
name);
3985 else ret = prism2_ioctl_priv_monitor(dev, (
int *) wrq->
u.
name);
3990 else ret = prism2_ioctl_priv_reset(dev, (
int *) wrq->
u.
name);
4005 else ret = prism2_ioctl_priv_set_rid_word(dev,
4006 (
int *) wrq->
u.
name);
4009 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
4012 else ret = ap_mac_cmd_ioctl(local, (
int *) wrq->
u.
name);
4036 #ifdef PRISM2_DOWNLOAD_SUPPORT
4039 else ret = prism2_ioctl_priv_download(local, &wrq->
u.
data);
4045 else ret = prism2_ioctl_priv_hostapd(local, &wrq->
u.
data);