21 #include <linux/random.h>
22 #include <linux/if_arp.h>
23 #include <linux/slab.h>
24 #include <linux/export.h>
34 MODULE_PARM_DESC(other_ap_policy,
"Other AP beacon monitoring policy (0-3)");
58 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
66 #ifndef PRISM2_NO_PROCFS_DEBUG
103 if (s ==
NULL)
return;
115 printk(
"AP: could not remove STA %pM from hash table\n",
122 hostap_event_expired_sta(sta->
local->
dev, sta);
139 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
143 if (!sta->
ap && sta->
u.
sta.challenge)
154 if (local->func->set_tim)
155 local->func->set_tim(local->
dev, aid,
set);
162 memset(&wrqu, 0,
sizeof(wrqu));
169 static void hostap_event_expired_sta(
struct net_device *dev,
173 memset(&wrqu, 0,
sizeof(wrqu));
180 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
182 static void ap_handle_timer(
unsigned long data)
187 unsigned long next_time = 0;
216 sta->
timer.expires = next_time;
226 ap_sta_hash_del(ap, sta);
234 hostap_event_expired_sta(local->
dev, sta);
237 !skb_queue_empty(&sta->
tx_buf)) {
238 hostap_set_tim(local, sta->
aid, 0);
245 "connection to AP %pM\n",
263 "(last=%lu, jiffies=%lu)\n",
265 deauth ?
"deauthentication" :
"disassociation",
273 (
char *) &resp, 2, sta->
addr, 0);
279 " would have been removed, "
280 "but it has 'perm' flag\n",
283 ap_free_sta(ap, sta);
315 for (i = 0; i < 5; i++) {
318 (
char *) &resp, 2, addr, 0);
320 if (!resend || ap->
num_sta <= 0)
328 static int ap_control_proc_read(
char *page,
char **start,
off_t off,
329 int count,
int *eof,
void *data)
342 case MAC_POLICY_OPEN:
345 case MAC_POLICY_ALLOW:
346 policy_txt =
"allow";
348 case MAC_POLICY_DENY:
352 policy_txt =
"unknown";
355 p +=
sprintf(p,
"MAC policy: %s\n", policy_txt);
357 p +=
sprintf(p,
"MAC list:\n");
361 p +=
sprintf(p,
"All entries did not fit one page.\n");
383 spin_lock_bh(&mac_restrictions->
lock);
386 spin_unlock_bh(&mac_restrictions->
lock);
397 spin_lock_bh(&mac_restrictions->
lock);
398 for (ptr = mac_restrictions->
mac_list.next;
406 spin_unlock_bh(&mac_restrictions->
lock);
410 spin_unlock_bh(&mac_restrictions->
lock);
421 if (mac_restrictions->
policy == MAC_POLICY_OPEN)
424 spin_lock_bh(&mac_restrictions->
lock);
431 spin_unlock_bh(&mac_restrictions->
lock);
433 if (mac_restrictions->
policy == MAC_POLICY_ALLOW)
445 if (mac_restrictions->
entries == 0)
448 spin_lock_bh(&mac_restrictions->
lock);
449 for (ptr = mac_restrictions->
mac_list.next, n = ptr->
next;
451 ptr = n, n = ptr->
next) {
457 spin_unlock_bh(&mac_restrictions->
lock);
467 sta = ap_get_sta(ap, mac);
469 ap_sta_hash_del(ap, sta);
479 (
char *) &resp, 2, sta->
addr, 0);
482 hostap_event_expired_sta(dev, sta);
484 ap_free_sta(ap, sta);
499 ptr = n, n = ptr->
next) {
501 ap_sta_hash_del(ap, sta);
504 hostap_event_expired_sta(sta->
local->
dev, sta);
505 ap_free_sta(ap, sta);
511 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
513 #define PROC_LIMIT (PAGE_SIZE - 80)
515 static int prism2_ap_proc_read(
char *page,
char **start,
off_t off,
516 int count,
int *eof,
void *data)
528 p +=
sprintf(p,
"# BSSID CHAN SIGNAL NOISE RATE SSID FLAGS\n");
534 p +=
sprintf(p,
"%pM %d %d %d %d '",
538 for (i = 0; i < sta->
u.
ap.ssid_len; i++)
540 sta->
u.
ap.ssid[i] < 127) ?
559 if ((p - page) <= off) {
566 return (p - page - off);
576 if (sta_fw_ver == PRISM2_FW_VER(0,8,0)) {
578 "firmware upgrade recommended\n");
583 if (sta_fw_ver == PRISM2_FW_VER(1,4,2)) {
585 "version 1.4.2 does not seem to work in Host AP mode\n",
592 static void hostap_ap_tx_cb(
struct sk_buff *
skb,
int ok,
void *data)
597 if (!ap->
local->hostapd || !ap->
local->apdev) {
613 memset(skb->cb, 0,
sizeof(skb->cb));
618 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
620 static void hostap_ap_tx_cb_auth(
struct sk_buff *skb,
int ok,
void *data)
630 if (ap->
local->hostapd) {
639 "frame\n", dev->
name);
650 txt =
"frame was not ACKed";
655 sta = ap_get_sta(ap, hdr->
addr1);
661 txt =
"STA not found";
668 txt =
"STA authenticated";
672 txt =
"authentication failed";
679 "trans#=%d status=%d - %s\n",
681 auth_alg, auth_transaction, status, txt);
688 static void hostap_ap_tx_cb_assoc(
struct sk_buff *skb,
int ok,
void *data)
698 if (ap->
local->hostapd) {
708 "frame\n", dev->
name);
714 txt =
"frame was not ACKed";
719 sta = ap_get_sta(ap, hdr->
addr1);
725 txt =
"STA not found";
734 hostap_event_new_sta(dev, sta);
735 txt =
"STA associated";
739 txt =
"association failed";
753 static void hostap_ap_tx_cb_poll(
struct sk_buff *skb,
int ok,
void *data)
764 sta = ap_get_sta(ap, hdr->
addr1);
770 "%s: STA %pM did not ACK activity poll frame\n",
782 struct ap_data *ap = local->ap;
801 INIT_WORK(&local->ap->add_sta_proc_queue, handle_add_proc_queue);
807 "AP\n", local->
dev->name);
808 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
809 INIT_WORK(&local->ap->wds_oper_queue, handle_wds_oper_queue);
820 "AP\n", local->
dev->name);
832 struct ap_data *ap = local->ap;
834 ap->
proc = local->proc;
838 #ifndef PRISM2_NO_PROCFS_DEBUG
839 create_proc_read_entry(
"ap_debug", 0, ap->
proc,
840 ap_debug_proc_read, ap);
843 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
844 create_proc_read_entry(
"ap_control", 0, ap->
proc,
845 ap_control_proc_read, ap);
846 create_proc_read_entry(
"ap", 0, ap->
proc,
847 prism2_ap_proc_read, ap);
859 "initialized - skip resource freeing\n");
865 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
873 ap_sta_hash_del(ap, sta);
876 hostap_event_expired_sta(sta->
local->
dev, sta);
877 ap_free_sta(ap, sta);
880 #ifndef PRISM2_NO_PROCFS_DEBUG
886 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
910 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
913 static void prism2_send_mgmt(
struct net_device *dev,
917 struct hostap_interface *iface;
922 struct hostap_skb_tx_data *
meta;
925 iface = netdev_priv(dev);
926 local = iface->local;
928 iface = netdev_priv(dev);
932 "cannot send frame\n", dev->
name);
936 skb = dev_alloc_skb(
sizeof(*hdr) + body_len);
971 meta = (
struct hostap_skb_tx_data *) skb->cb;
972 memset(meta, 0,
sizeof(*meta));
973 meta->magic = HOSTAP_SKB_TX_DATA_MAGIC;
975 meta->tx_cb_idx = tx_cb_idx;
978 skb_reset_mac_header(skb);
979 skb_reset_network_header(skb);
985 static int prism2_sta_proc_read(
char *page,
char **start,
off_t off,
986 int count,
int *eof,
void *data)
1001 p +=
sprintf(p,
"%s=%pM\nusers=%d\naid=%d\n"
1002 "flags=0x%04x%s%s%s%s%s%s%s\n"
1003 "capability=0x%02x\nlisten_interval=%d\nsupported_rates=",
1004 sta->
ap ?
"AP" :
"STA",
1021 p +=
sprintf(p,
"\njiffies=%lu\nlast_auth=%lu\nlast_assoc=%lu\n"
1022 "last_rx=%lu\nlast_tx=%lu\nrx_packets=%lu\n"
1024 "rx_bytes=%lu\ntx_bytes=%lu\nbuffer_count=%d\n"
1025 "last_rx: silence=%d dBm signal=%d dBm rate=%d%s Mbps\n"
1026 "tx_rate=%d\ntx[1M]=%d\ntx[2M]=%d\ntx[5.5M]=%d\n"
1028 "rx[1M]=%d\nrx[2M]=%d\nrx[5.5M]=%d\nrx[11M]=%d\n",
1040 p = sta->
crypt->ops->print_stats(p, sta->
crypt->priv);
1041 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
1043 if (sta->
u.
ap.channel >= 0)
1044 p +=
sprintf(p,
"channel=%d\n", sta->
u.
ap.channel);
1046 for (i = 0; i < sta->
u.
ap.ssid_len; i++)
1048 sta->
u.
ap.ssid[i] < 127) ?
1072 sta = ap_get_sta(ap, entry->
addr);
1079 sta->
proc = create_proc_read_entry(
1081 prism2_sta_proc_read, sta);
1087 entry = entry->
next;
1105 skb_queue_head_init(&sta->
tx_buf);
1112 ap_sta_hash_add(ap, sta);
1129 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
1133 sta->
timer.function = ap_handle_timer;
1134 if (!ap->
local->hostapd)
1142 static int ap_tx_rate_ok(
int rateidx,
struct sta_info *sta,
1149 if (local->tx_rate_control != 0 &&
1150 !(local->tx_rate_control & (1 << rateidx)))
1157 static void prism2_check_tx_rates(
struct sta_info *sta)
1175 if (ap_tx_rate_ok(0, sta, sta->
local)) {
1182 if (ap_tx_rate_ok(1, sta, sta->
local)) {
1189 if (ap_tx_rate_ok(2, sta, sta->
local)) {
1196 if (ap_tx_rate_ok(3, sta, sta->
local)) {
1204 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
1206 static void ap_crypt_init(
struct ap_data *ap)
1211 if (ap->
crypt->init) {
1226 "lib80211_crypt_wep.ko\n");
1239 static char * ap_auth_make_challenge(
struct ap_data *ap)
1251 if (tmpbuf ==
NULL) {
1257 ap->
crypt->extra_mpdu_prefix_len +
1258 ap->
crypt->extra_mpdu_postfix_len);
1264 skb_reserve(skb, ap->
crypt->extra_mpdu_prefix_len);
1273 skb_copy_from_linear_data_offset(skb, ap->
crypt->extra_mpdu_prefix_len,
1288 struct ap_data *ap = local->ap;
1304 "(len=%d) from %pM\n", dev->
name, len, hdr->
addr2);
1308 spin_lock_bh(&local->ap->sta_table_lock);
1309 sta = ap_get_sta(local->ap, hdr->
addr2);
1312 spin_unlock_bh(&local->ap->sta_table_lock);
1314 if (sta && sta->
crypt)
1318 if (skb->
len >= hdrlen + 3)
1319 idx = skb->
data[hdrlen + 3] >> 6;
1320 crypt = local->crypt_info.crypt[
idx];
1333 txt =
"authentication denied";
1343 txt =
"unsupported algorithm";
1352 txt =
"invalid challenge len";
1357 txt =
"challenge underflow";
1361 challenge = (
char *) (u + 2);
1365 if (sta && sta->
ap) {
1369 " assuming AP %pM is now STA\n",
1375 txt =
"AP trying to authenticate?";
1383 (auth_transaction == 1 ||
1384 (auth_transaction == 3 && sta !=
NULL &&
1387 txt =
"unknown authentication transaction number";
1397 txt =
"no more room for new STAs";
1402 sta = ap_add_sta(local->ap, hdr->
addr2);
1404 txt =
"ap_add_sta failed";
1422 if (auth_transaction == 1) {
1423 if (sta->
u.
sta.challenge ==
NULL) {
1424 sta->
u.
sta.challenge =
1425 ap_auth_make_challenge(local->ap);
1426 if (sta->
u.
sta.challenge ==
NULL) {
1432 if (sta->
u.
sta.challenge ==
NULL ||
1433 challenge ==
NULL ||
1437 txt =
"challenge response incorrect";
1442 txt =
"challenge OK - authOK";
1486 "trans#=%d stat=%d len=%d fc=%04x) ==> %d (%s)\n",
1500 char body[12], *p, *lpos;
1505 int send_deauth = 0;
1511 if (len < (reassoc ? 10 : 4)) {
1513 "(len=%d, reassoc=%d) from %pM\n",
1518 spin_lock_bh(&local->ap->sta_table_lock);
1519 sta = ap_get_sta(local->ap, hdr->
addr2);
1521 spin_unlock_bh(&local->ap->sta_table_lock);
1522 txt =
"trying to associate before authentication";
1529 spin_unlock_bh(&local->ap->sta_table_lock);
1539 pos++; pos++; pos++;
left -= 6;
1545 unsigned char *u = (
unsigned char *) pos;
1552 if (ileft >
left || ileft > MAX_SSID_LEN) {
1553 txt =
"SSID overflow";
1558 if (ileft !=
strlen(local->essid) ||
1559 memcmp(local->essid, u, ileft) != 0) {
1560 txt =
"not our SSID";
1574 if (ileft >
left || ileft == 0 ||
1576 txt =
"SUPP_RATES len error";
1584 prism2_check_tx_rates(sta);
1592 " with extra data (%d bytes) [",
1601 txt =
"frame underflow";
1608 txt =
"OK, old AID";
1610 spin_lock_bh(&local->ap->sta_table_lock);
1612 if (local->ap->sta_aid[sta->
aid - 1] ==
NULL)
1616 spin_unlock_bh(&local->ap->sta_table_lock);
1618 txt =
"no room for more AIDs";
1620 local->ap->sta_aid[sta->
aid - 1] = sta;
1621 spin_unlock_bh(&local->ap->sta_table_lock);
1622 txt =
"OK, new AID";
1654 *p++ = local->basic_rates &
WLAN_RATE_1M ? 0x82 : 0x02;
1658 *p++ = local->basic_rates &
WLAN_RATE_2M ? 0x84 : 0x04;
1678 body, (
u8 *) pos - (
u8 *) body,
1680 send_deauth ? 0 : local->ap->tx_callback_assoc);
1693 "prev_ap=%pM) => %d(%d) (%s)\n",
1696 reassoc ?
"re" :
"", len,
1698 resp, send_deauth, txt);
1718 printk(
"handle_deauth - too short payload (len=%d)\n", len);
1726 "reason_code=%d\n", dev->
name, hdr->
addr2,
1729 spin_lock_bh(&local->ap->sta_table_lock);
1730 sta = ap_get_sta(local->ap, hdr->
addr2);
1733 hostap_event_expired_sta(local->
dev, sta);
1736 spin_unlock_bh(&local->ap->sta_table_lock);
1738 printk(
"%s: deauthentication from %pM, "
1739 "reason_code=%d, but STA not authenticated\n", dev->
name,
1740 hdr->
addr2, reason_code);
1760 printk(
"handle_disassoc - too short payload (len=%d)\n", len);
1768 "reason_code=%d\n", dev->
name, hdr->
addr2,
1771 spin_lock_bh(&local->ap->sta_table_lock);
1772 sta = ap_get_sta(local->ap, hdr->
addr2);
1775 hostap_event_expired_sta(local->
dev, sta);
1778 spin_unlock_bh(&local->ap->sta_table_lock);
1780 printk(
"%s: disassociation from %pM, "
1781 "reason_code=%d, but STA not authenticated\n",
1788 static void ap_handle_data_nullfunc(
local_info_t *local,
1805 static void ap_handle_dropped_data(
local_info_t *local,
1812 spin_lock_bh(&local->ap->sta_table_lock);
1813 sta = ap_get_sta(local->ap, hdr->
addr2);
1816 spin_unlock_bh(&local->ap->sta_table_lock);
1828 (
char *) &reason,
sizeof(reason), hdr->
addr2, 0);
1841 struct hostap_skb_tx_data *
meta;
1852 meta = (
struct hostap_skb_tx_data *) skb->cb;
1853 meta->flags |= HOSTAP_TX_FLAGS_BUFFERED_FRAME;
1854 if (!skb_queue_empty(&sta->
tx_buf)) {
1856 meta->flags |= HOSTAP_TX_FLAGS_ADD_MOREDATA;
1872 PDEBUG(DEBUG_PS2,
"handle_pspoll: BSSID=%pM, TA=%pM PWRMGT=%d\n",
1877 "handle_pspoll - addr1(BSSID)=%pM not own MAC\n",
1883 if ((aid & (
BIT(15) |
BIT(14))) != (
BIT(15) |
BIT(14))) {
1884 PDEBUG(DEBUG_PS,
" PSPOLL and AID[15:14] not set\n");
1887 aid &= ~(
BIT(15) |
BIT(14));
1889 PDEBUG(DEBUG_PS,
" invalid aid=%d\n", aid);
1892 PDEBUG(DEBUG_PS2,
" aid=%d\n", aid);
1894 spin_lock_bh(&local->ap->sta_table_lock);
1895 sta = ap_get_sta(local->ap, hdr->
addr2);
1898 spin_unlock_bh(&local->ap->sta_table_lock);
1901 PDEBUG(DEBUG_PS,
" STA not found\n");
1904 if (sta->
aid != aid) {
1905 PDEBUG(DEBUG_PS,
" received aid=%i does not match with "
1906 "assoc.aid=%d\n", aid, sta->
aid);
1921 PDEBUG(DEBUG_PS2,
"Sending buffered frame to STA after PS POLL"
1922 " (buffer_count=%d)\n", skb_queue_len(&sta->
tx_buf));
1924 pspoll_send_buffered(local, sta, skb);
1935 if (skb_queue_empty(&sta->
tx_buf)) {
1938 PDEBUG(DEBUG_PS2,
"Re-unsetting TIM for aid %d\n",
1940 hostap_set_tim(local, aid, 0);
1948 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
1950 static void handle_wds_oper_queue(
struct work_struct *work)
1957 spin_lock_bh(&local->lock);
1958 entry = local->ap->wds_oper_entries;
1959 local->ap->wds_oper_entries =
NULL;
1960 spin_unlock_bh(&local->lock);
1974 entry = entry->
next;
1990 unsigned char *supp_rates =
NULL;
1991 int ssid_len = 0, supp_rates_len = 0;
1993 int new_sta = 0,
channel = -1;
1997 if (len < 8 + 2 + 2) {
2007 pos += 4;
left -= 8;
2021 unsigned char *u = (
unsigned char *) pos;
2028 if (ileft >
left || ileft > MAX_SSID_LEN) {
2034 (ileft !=
strlen(local->essid) ||
2035 memcmp(local->essid, u, ileft) != 0)) {
2052 if (ileft >
left || ileft == 0 || ileft > 8) {
2058 supp_rates_len = ileft;
2069 if (ileft >
left || ileft != 1) {
2081 spin_lock_bh(&local->ap->sta_table_lock);
2082 sta = ap_get_sta(local->ap, hdr->
addr2);
2085 spin_unlock_bh(&local->ap->sta_table_lock);
2090 sta = ap_add_sta(local->ap, hdr->
addr2);
2093 "data structure\n");
2096 hostap_event_new_sta(local->
dev, sta);
2102 if (local->ap->autom_ap_wds) {
2109 sta->
u.
ap.ssid_len = ssid_len;
2111 sta->
u.
ap.ssid[ssid_len] =
'\0';
2113 sta->
u.
ap.ssid_len = 0;
2114 sta->
u.
ap.ssid[0] =
'\0';
2128 prism2_check_tx_rates(sta);
2139 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
2152 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
2162 ap_handle_dropped_data(local, hdr);
2172 " not own MAC\n", hdr->
addr1);
2176 if (local->ap->nullfunc_ack &&
2178 ap_handle_data_nullfunc(local, hdr);
2180 ap_handle_dropped_data(local, hdr);
2185 handle_beacon(local, skb, rx_stats);
2191 handle_pspoll(local, hdr, rx_stats);
2195 if (local->hostapd) {
2197 "subtype=0x%02x\n", type, stype);
2201 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
2209 " not own MAC\n", hdr->
addr1);
2215 " not own MAC\n", hdr->
addr3);
2221 handle_assoc(local, skb, rx_stats, 0);
2223 case IEEE80211_STYPE_ASSOC_RESP:
2227 handle_assoc(local, skb, rx_stats, 1);
2236 handle_disassoc(local, skb, rx_stats);
2239 handle_authen(local, skb, rx_stats);
2242 handle_deauth(local, skb, rx_stats);
2260 struct hostap_interface *iface;
2264 iface = netdev_priv(dev);
2265 local = iface->local;
2270 dev->
stats.rx_packets++;
2279 handle_ap_item(local, skb, rx_stats);
2294 if (skb_queue_empty(&sta->
tx_buf))
2297 skb = dev_alloc_skb(16);
2300 "failed\n", local->
dev->name);
2314 "%s: Scheduling buffered packet delivery for STA %pM\n",
2319 memset(&rx_stats, 0,
sizeof(rx_stats));
2328 struct ap_data *ap = local->ap;
2338 if (aplist && !sta->
ap)
2355 if (count >= buf_size)
2369 struct hostap_interface *iface;
2374 char *current_ev =
buffer;
2376 #if !defined(PRISM2_NO_KERNEL_IEEE80211_MGMT)
2380 iface = netdev_priv(dev);
2381 local = iface->local;
2391 memset(&iwe, 0,
sizeof(iwe));
2396 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
2401 memset(&iwe, 0,
sizeof(iwe));
2408 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
2412 memset(&iwe, 0,
sizeof(iwe));
2424 current_ev = iwe_stream_add_event(info, current_ev, end_buf,
2427 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
2429 memset(&iwe, 0,
sizeof(iwe));
2431 iwe.
u.
data.length = sta->
u.
ap.ssid_len;
2432 iwe.
u.
data.flags = 1;
2433 current_ev = iwe_stream_add_point(info, current_ev,
2437 memset(&iwe, 0,
sizeof(iwe));
2444 current_ev = iwe_stream_add_point(info, current_ev,
2448 if (sta->
u.
ap.channel > 0 &&
2450 memset(&iwe, 0,
sizeof(iwe));
2452 iwe.
u.
freq.m = freq_list[sta->
u.
ap.channel - 1]
2455 current_ev = iwe_stream_add_event(
2456 info, current_ev, end_buf, &iwe,
2460 memset(&iwe, 0,
sizeof(iwe));
2462 sprintf(buf,
"beacon_interval=%d",
2465 current_ev = iwe_stream_add_point(info, current_ev,
2466 end_buf, &iwe, buf);
2477 return current_ev -
buffer;
2481 static int prism2_hostapd_add_sta(
struct ap_data *ap,
2487 sta = ap_get_sta(ap, param->
sta_addr);
2493 sta = ap_add_sta(ap, param->
sta_addr);
2499 hostap_event_new_sta(sta->
local->
dev, sta);
2514 prism2_check_tx_rates(sta);
2520 static int prism2_hostapd_remove_sta(
struct ap_data *ap,
2526 sta = ap_get_sta(ap, param->
sta_addr);
2528 ap_sta_hash_del(ap, sta);
2537 hostap_event_expired_sta(sta->
local->
dev, sta);
2538 ap_free_sta(ap, sta);
2544 static int prism2_hostapd_get_info_sta(
struct ap_data *ap,
2550 sta = ap_get_sta(ap, param->
sta_addr);
2566 static int prism2_hostapd_set_flags_sta(
struct ap_data *ap,
2572 sta = ap_get_sta(ap, param->
sta_addr);
2586 static int prism2_hostapd_sta_clear_stats(
struct ap_data *ap,
2593 sta = ap_get_sta(ap, param->
sta_addr);
2613 switch (param->
cmd) {
2618 return prism2_hostapd_add_sta(ap, param);
2620 return prism2_hostapd_remove_sta(ap, param);
2622 return prism2_hostapd_get_info_sta(ap, param);
2624 return prism2_hostapd_set_flags_sta(ap, param);
2626 return prism2_hostapd_sta_clear_stats(ap, param);
2640 struct hostap_interface *iface;
2643 iface = netdev_priv(dev);
2644 local = iface->local;
2652 int old_rate, new_rate;
2654 while (new_rate < sta->tx_max_rate) {
2656 if (ap_tx_rate_ok(new_rate, sta, local)) {
2663 case 0: sta->
tx_rate = 10;
break;
2664 case 1: sta->
tx_rate = 20;
break;
2665 case 2: sta->
tx_rate = 55;
break;
2666 case 3: sta->
tx_rate = 110;
break;
2667 default: sta->
tx_rate = 0;
break;
2687 struct hostap_skb_tx_data *
meta;
2689 meta = (
struct hostap_skb_tx_data *) skb->cb;
2691 if (local->ap ==
NULL || skb->
len < 10 ||
2692 meta->iface->type == HOSTAP_INTERFACE_STA)
2699 if (local->ap->num_sta <= 0)
2705 spin_lock(&local->ap->sta_table_lock);
2706 sta = ap_get_sta(local->ap, hdr->
addr1);
2709 spin_unlock(&local->ap->sta_table_lock);
2712 !(meta->flags & HOSTAP_TX_FLAGS_WDS) &&
2713 meta->iface->type != HOSTAP_INTERFACE_MASTER &&
2714 meta->iface->type != HOSTAP_INTERFACE_AP) {
2723 "STA %pM\n", hdr->
addr1);
2726 local->ap->tx_drop_nonassoc++;
2738 if (!local->fw_tx_rate_control)
2739 local->ap->last_tx_rate = meta->rate =
2740 ap_update_sta_tx_rate(sta, local->
dev);
2748 if (meta->flags & HOSTAP_TX_FLAGS_ADD_MOREDATA) {
2754 if (meta->flags & HOSTAP_TX_FLAGS_BUFFERED_FRAME) {
2761 PDEBUG(DEBUG_PS,
"%s: No more space in STA (%pM)'s"
2768 hostap_set_tim(local, sta->
aid, 1);
2775 set_tim = skb_queue_empty(&sta->
tx_buf);
2782 PDEBUG(DEBUG_PS2,
"Re-setting TIM for aid %d\n",
2784 hostap_set_tim(local, sta->
aid, 1);
2826 struct hostap_skb_tx_data *
meta;
2829 meta = (
struct hostap_skb_tx_data *) skb->cb;
2831 spin_lock(&local->ap->sta_table_lock);
2832 sta = ap_get_sta(local->ap, hdr->
addr1);
2834 spin_unlock(&local->ap->sta_table_lock);
2836 " for this TX error (@%lu)\n",
2851 if (ap_tx_rate_ok(rate, sta, local)) {
2858 case 0: sta->
tx_rate = 10;
break;
2859 case 1: sta->
tx_rate = 20;
break;
2860 case 2: sta->
tx_rate = 55;
break;
2861 case 3: sta->
tx_rate = 110;
break;
2862 default: sta->
tx_rate = 0;
break;
2865 "%s: STA %pM TX rate lowered to %d\n",
2870 spin_unlock(&local->ap->sta_table_lock);
2875 int pwrmgt,
int type,
int stype)
2879 PDEBUG(DEBUG_PS2,
"STA %pM changed to use PS "
2880 "mode (type=0x%02X, stype=0x%02X)\n",
2881 sta->
addr, type >> 2, stype >> 4);
2884 PDEBUG(DEBUG_PS2,
"STA %pM changed to not use "
2885 "PS mode (type=0x%02X, stype=0x%02X)\n",
2886 sta->
addr, type >> 2, stype >> 4);
2889 schedule_packet_send(local, sta);
2901 spin_lock(&local->ap->sta_table_lock);
2902 sta = ap_get_sta(local->ap, hdr->
addr2);
2905 spin_unlock(&local->ap->sta_table_lock);
2912 fc & IEEE80211_FCTL_FTYPE,
2913 fc & IEEE80211_FCTL_STYPE);
2932 if (local->ap ==
NULL)
2941 spin_lock(&local->ap->sta_table_lock);
2942 sta = ap_get_sta(local->ap, hdr->
addr2);
2945 spin_unlock(&local->ap->sta_table_lock);
2953 if (fc & IEEE80211_FCTL_TODS) {
2955 if (local->hostapd) {
2958 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
2961 " from non-associated STA %pM"
2962 " (type=0x%02x, subtype=0x%02x)\n",
2964 type >> 2, stype >> 4);
2971 }
else if (fc & IEEE80211_FCTL_FROMDS) {
2977 "received with own BSSID\n");
2986 if (local->hostapd) {
2989 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
2997 " without ToDS from not associated STA %pM\n",
3015 " with no ToDS flag "
3016 "(type=0x%02x, subtype=0x%02x)\n", dev->
name,
3017 hdr->
addr2, type >> 2, stype >> 4);
3034 fc & IEEE80211_FCTL_TODS) {
3035 if (local->hostapd) {
3038 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT
3068 spin_lock(&local->ap->sta_table_lock);
3069 sta = ap_get_sta(local->ap, hdr->
addr2);
3072 spin_unlock(&local->ap->sta_table_lock);
3078 *crypt = sta->
crypt;
3096 sta = ap_get_sta(ap, sta_addr);
3112 sta = ap_get_sta(ap, sta_addr);
3115 ap->
local->ieee_802_1x == 0))
3133 sta = ap_get_sta(ap, sta_addr);
3139 sta = ap_add_sta(ap, sta_addr);
3173 sta = ap_get_sta(ap, hdr->
addr2);
3179 if (rx_stats->
rate == 10)
3181 else if (rx_stats->
rate == 20)
3183 else if (rx_stats->
rate == 55)
3185 else if (rx_stats->
rate == 110)
3190 return sta ? 0 : -1;
3197 struct ap_data *ap = local->ap;
3204 prism2_check_tx_rates(sta);
3216 sta = ap_get_sta(ap, addr);
3221 if (!sta && permanent)
3222 sta = ap_add_sta(ap, addr);
3230 *crypt = &sta->
crypt;
3238 struct ap_data *ap = local->ap;
3261 spin_lock_bh(&local->lock);
3262 entry->
next = local->ap->wds_oper_entries;
3263 local->ap->wds_oper_entries =
entry;
3264 spin_unlock_bh(&local->lock);
3275 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT