ibss.c (e7d9facf0bab6d919342fea17c8cc0f65f8a0fe9) ibss.c (55de908ab292c03f1eb280f51170ddb9c6b57e31)
1/*
2 * IBSS mode implementation
3 * Copyright 2003-2008, Jouni Malinen <j@w1.fi>
4 * Copyright 2004, Instant802 Networks, Inc.
5 * Copyright 2005, Devicescape Software, Inc.
6 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
7 * Copyright 2007, Michael Wu <flamingice@sourmilk.net>
8 * Copyright 2009, Johannes Berg <johannes@sipsolutions.net>

--- 12 unchanged lines hidden (view full) ---

21#include <linux/rtnetlink.h>
22#include <net/mac80211.h>
23
24#include "ieee80211_i.h"
25#include "driver-ops.h"
26#include "rate.h"
27
28#define IEEE80211_SCAN_INTERVAL (2 * HZ)
1/*
2 * IBSS mode implementation
3 * Copyright 2003-2008, Jouni Malinen <j@w1.fi>
4 * Copyright 2004, Instant802 Networks, Inc.
5 * Copyright 2005, Devicescape Software, Inc.
6 * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz>
7 * Copyright 2007, Michael Wu <flamingice@sourmilk.net>
8 * Copyright 2009, Johannes Berg <johannes@sipsolutions.net>

--- 12 unchanged lines hidden (view full) ---

21#include <linux/rtnetlink.h>
22#include <net/mac80211.h>
23
24#include "ieee80211_i.h"
25#include "driver-ops.h"
26#include "rate.h"
27
28#define IEEE80211_SCAN_INTERVAL (2 * HZ)
29#define IEEE80211_SCAN_INTERVAL_SLOW (15 * HZ)
30#define IEEE80211_IBSS_JOIN_TIMEOUT (7 * HZ)
31
32#define IEEE80211_IBSS_MERGE_INTERVAL (30 * HZ)
33#define IEEE80211_IBSS_INACTIVITY_LIMIT (60 * HZ)
34
35#define IEEE80211_IBSS_MAX_STA_ENTRIES 128
36
37

--- 33 unchanged lines hidden (view full) ---

71
72 /* if merging, indicate to driver that we leave the old IBSS */
73 if (sdata->vif.bss_conf.ibss_joined) {
74 sdata->vif.bss_conf.ibss_joined = false;
75 netif_carrier_off(sdata->dev);
76 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_IBSS);
77 }
78
29#define IEEE80211_IBSS_JOIN_TIMEOUT (7 * HZ)
30
31#define IEEE80211_IBSS_MERGE_INTERVAL (30 * HZ)
32#define IEEE80211_IBSS_INACTIVITY_LIMIT (60 * HZ)
33
34#define IEEE80211_IBSS_MAX_STA_ENTRIES 128
35
36

--- 33 unchanged lines hidden (view full) ---

70
71 /* if merging, indicate to driver that we leave the old IBSS */
72 if (sdata->vif.bss_conf.ibss_joined) {
73 sdata->vif.bss_conf.ibss_joined = false;
74 netif_carrier_off(sdata->dev);
75 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_IBSS);
76 }
77
79 memcpy(ifibss->bssid, bssid, ETH_ALEN);
80
81 sdata->drop_unencrypted = capability & WLAN_CAPABILITY_PRIVACY ? 1 : 0;
82
78 sdata->drop_unencrypted = capability & WLAN_CAPABILITY_PRIVACY ? 1 : 0;
79
83 local->oper_channel = chan;
84 channel_type = ifibss->channel_type;
85 if (!cfg80211_can_beacon_sec_chan(local->hw.wiphy, chan, channel_type))
86 channel_type = NL80211_CHAN_HT20;
80 channel_type = ifibss->channel_type;
81 if (!cfg80211_can_beacon_sec_chan(local->hw.wiphy, chan, channel_type))
82 channel_type = NL80211_CHAN_HT20;
87 if (!ieee80211_set_channel_type(local, sdata, channel_type)) {
88 /* can only fail due to HT40+/- mismatch */
89 channel_type = NL80211_CHAN_HT20;
90 WARN_ON(!ieee80211_set_channel_type(local, sdata,
91 NL80211_CHAN_HT20));
83
84 ieee80211_vif_release_channel(sdata);
85 if (ieee80211_vif_use_channel(sdata, chan, channel_type,
86 ifibss->fixed_channel ?
87 IEEE80211_CHANCTX_SHARED :
88 IEEE80211_CHANCTX_EXCLUSIVE)) {
89 sdata_info(sdata, "Failed to join IBSS, no channel context\n");
90 return;
92 }
91 }
93 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
94
92
93 memcpy(ifibss->bssid, bssid, ETH_ALEN);
94
95 sband = local->hw.wiphy->bands[chan->band];
96
97 /* build supported rates array */
98 pos = supp_rates;
99 for (i = 0; i < sband->n_bitrates; i++) {
100 int rate = sband->bitrates[i].bitrate;
101 u8 basic = 0;
102 if (basic_rates & BIT(i))

--- 186 unchanged lines hidden (view full) ---

289ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,
290 const u8 *bssid, const u8 *addr,
291 u32 supp_rates, bool auth)
292 __acquires(RCU)
293{
294 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
295 struct ieee80211_local *local = sdata->local;
296 struct sta_info *sta;
95 sband = local->hw.wiphy->bands[chan->band];
96
97 /* build supported rates array */
98 pos = supp_rates;
99 for (i = 0; i < sband->n_bitrates; i++) {
100 int rate = sband->bitrates[i].bitrate;
101 u8 basic = 0;
102 if (basic_rates & BIT(i))

--- 186 unchanged lines hidden (view full) ---

289ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,
290 const u8 *bssid, const u8 *addr,
291 u32 supp_rates, bool auth)
292 __acquires(RCU)
293{
294 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
295 struct ieee80211_local *local = sdata->local;
296 struct sta_info *sta;
297 int band = local->oper_channel->band;
297 struct ieee80211_chanctx_conf *chanctx_conf;
298 int band;
298
299 /*
300 * XXX: Consider removing the least recently used entry and
301 * allow new one to be added.
302 */
303 if (local->num_sta >= IEEE80211_IBSS_MAX_STA_ENTRIES) {
304 net_info_ratelimited("%s: No room for a new IBSS STA entry %pM\n",
305 sdata->name, addr);

--- 6 unchanged lines hidden (view full) ---

312 return NULL;
313 }
314
315 if (!ether_addr_equal(bssid, sdata->u.ibss.bssid)) {
316 rcu_read_lock();
317 return NULL;
318 }
319
299
300 /*
301 * XXX: Consider removing the least recently used entry and
302 * allow new one to be added.
303 */
304 if (local->num_sta >= IEEE80211_IBSS_MAX_STA_ENTRIES) {
305 net_info_ratelimited("%s: No room for a new IBSS STA entry %pM\n",
306 sdata->name, addr);

--- 6 unchanged lines hidden (view full) ---

313 return NULL;
314 }
315
316 if (!ether_addr_equal(bssid, sdata->u.ibss.bssid)) {
317 rcu_read_lock();
318 return NULL;
319 }
320
321 rcu_read_lock();
322 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
323 if (WARN_ON_ONCE(!chanctx_conf))
324 return NULL;
325 band = chanctx_conf->channel->band;
326 rcu_read_unlock();
327
320 sta = sta_info_alloc(sdata, addr, GFP_KERNEL);
321 if (!sta) {
322 rcu_read_lock();
323 return NULL;
324 }
325
326 sta->last_rx = jiffies;
327

--- 184 unchanged lines hidden (view full) ---

512 if (sdata->u.ibss.fixed_bssid)
513 goto put_bss;
514
515 /* not an IBSS */
516 if (!(cbss->capability & WLAN_CAPABILITY_IBSS))
517 goto put_bss;
518
519 /* different channel */
328 sta = sta_info_alloc(sdata, addr, GFP_KERNEL);
329 if (!sta) {
330 rcu_read_lock();
331 return NULL;
332 }
333
334 sta->last_rx = jiffies;
335

--- 184 unchanged lines hidden (view full) ---

520 if (sdata->u.ibss.fixed_bssid)
521 goto put_bss;
522
523 /* not an IBSS */
524 if (!(cbss->capability & WLAN_CAPABILITY_IBSS))
525 goto put_bss;
526
527 /* different channel */
520 if (cbss->channel != local->oper_channel)
528 if (sdata->u.ibss.fixed_channel &&
529 sdata->u.ibss.channel != cbss->channel)
521 goto put_bss;
522
523 /* different SSID */
524 if (elems->ssid_len != sdata->u.ibss.ssid_len ||
525 memcmp(elems->ssid, sdata->u.ibss.ssid,
526 sdata->u.ibss.ssid_len))
527 goto put_bss;
528

--- 58 unchanged lines hidden (view full) ---

587
588void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,
589 const u8 *bssid, const u8 *addr,
590 u32 supp_rates)
591{
592 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
593 struct ieee80211_local *local = sdata->local;
594 struct sta_info *sta;
530 goto put_bss;
531
532 /* different SSID */
533 if (elems->ssid_len != sdata->u.ibss.ssid_len ||
534 memcmp(elems->ssid, sdata->u.ibss.ssid,
535 sdata->u.ibss.ssid_len))
536 goto put_bss;
537

--- 58 unchanged lines hidden (view full) ---

596
597void ieee80211_ibss_rx_no_sta(struct ieee80211_sub_if_data *sdata,
598 const u8 *bssid, const u8 *addr,
599 u32 supp_rates)
600{
601 struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
602 struct ieee80211_local *local = sdata->local;
603 struct sta_info *sta;
595 int band = local->oper_channel->band;
604 struct ieee80211_chanctx_conf *chanctx_conf;
605 int band;
596
597 /*
598 * XXX: Consider removing the least recently used entry and
599 * allow new one to be added.
600 */
601 if (local->num_sta >= IEEE80211_IBSS_MAX_STA_ENTRIES) {
602 net_info_ratelimited("%s: No room for a new IBSS STA entry %pM\n",
603 sdata->name, addr);
604 return;
605 }
606
607 if (ifibss->state == IEEE80211_IBSS_MLME_SEARCH)
608 return;
609
610 if (!ether_addr_equal(bssid, sdata->u.ibss.bssid))
611 return;
612
606
607 /*
608 * XXX: Consider removing the least recently used entry and
609 * allow new one to be added.
610 */
611 if (local->num_sta >= IEEE80211_IBSS_MAX_STA_ENTRIES) {
612 net_info_ratelimited("%s: No room for a new IBSS STA entry %pM\n",
613 sdata->name, addr);
614 return;
615 }
616
617 if (ifibss->state == IEEE80211_IBSS_MLME_SEARCH)
618 return;
619
620 if (!ether_addr_equal(bssid, sdata->u.ibss.bssid))
621 return;
622
623 rcu_read_lock();
624 chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
625 if (WARN_ON_ONCE(!chanctx_conf)) {
626 rcu_read_unlock();
627 return;
628 }
629 band = chanctx_conf->channel->band;
630 rcu_read_unlock();
631
613 sta = sta_info_alloc(sdata, addr, GFP_ATOMIC);
614 if (!sta)
615 return;
616
617 sta->last_rx = jiffies;
618
619 /* make sure mandatory rates are always added */
620 sta->sta.supp_rates[band] = supp_rates |

--- 158 unchanged lines hidden (view full) ---

779
780 ieee80211_request_internal_scan(sdata,
781 ifibss->ssid, ifibss->ssid_len,
782 ifibss->fixed_channel ? ifibss->channel : NULL);
783 } else {
784 int interval = IEEE80211_SCAN_INTERVAL;
785
786 if (time_after(jiffies, ifibss->ibss_join_req +
632 sta = sta_info_alloc(sdata, addr, GFP_ATOMIC);
633 if (!sta)
634 return;
635
636 sta->last_rx = jiffies;
637
638 /* make sure mandatory rates are always added */
639 sta->sta.supp_rates[band] = supp_rates |

--- 158 unchanged lines hidden (view full) ---

798
799 ieee80211_request_internal_scan(sdata,
800 ifibss->ssid, ifibss->ssid_len,
801 ifibss->fixed_channel ? ifibss->channel : NULL);
802 } else {
803 int interval = IEEE80211_SCAN_INTERVAL;
804
805 if (time_after(jiffies, ifibss->ibss_join_req +
787 IEEE80211_IBSS_JOIN_TIMEOUT)) {
788 if (!(local->oper_channel->flags & IEEE80211_CHAN_NO_IBSS)) {
789 ieee80211_sta_create_ibss(sdata);
790 return;
791 }
792 sdata_info(sdata, "IBSS not allowed on %d MHz\n",
793 local->oper_channel->center_freq);
806 IEEE80211_IBSS_JOIN_TIMEOUT))
807 ieee80211_sta_create_ibss(sdata);
794
808
795 /* No IBSS found - decrease scan interval and continue
796 * scanning. */
797 interval = IEEE80211_SCAN_INTERVAL_SLOW;
798 }
799
800 mod_timer(&ifibss->timer,
801 round_jiffies(jiffies + interval));
802 }
803}
804
805static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata,
806 struct sk_buff *req)
807{

--- 273 unchanged lines hidden (view full) ---

1081 sizeof(params->mcast_rate));
1082
1083 sdata->vif.bss_conf.beacon_int = params->beacon_interval;
1084
1085 sdata->u.ibss.channel = params->channel;
1086 sdata->u.ibss.channel_type = params->channel_type;
1087 sdata->u.ibss.fixed_channel = params->channel_fixed;
1088
809 mod_timer(&ifibss->timer,
810 round_jiffies(jiffies + interval));
811 }
812}
813
814static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata,
815 struct sk_buff *req)
816{

--- 273 unchanged lines hidden (view full) ---

1090 sizeof(params->mcast_rate));
1091
1092 sdata->vif.bss_conf.beacon_int = params->beacon_interval;
1093
1094 sdata->u.ibss.channel = params->channel;
1095 sdata->u.ibss.channel_type = params->channel_type;
1096 sdata->u.ibss.fixed_channel = params->channel_fixed;
1097
1089 /* fix ourselves to that channel now already */
1090 if (params->channel_fixed) {
1091 sdata->local->oper_channel = params->channel;
1092 if (!ieee80211_set_channel_type(sdata->local, sdata,
1093 params->channel_type)) {
1094 mutex_unlock(&sdata->u.ibss.mtx);
1095 kfree_skb(skb);
1096 return -EINVAL;
1097 }
1098 }
1099
1100 if (params->ie) {
1101 sdata->u.ibss.ie = kmemdup(params->ie, params->ie_len,
1102 GFP_KERNEL);
1103 if (sdata->u.ibss.ie)
1104 sdata->u.ibss.ie_len = params->ie_len;
1105 }
1106
1107 sdata->u.ibss.skb = skb;

--- 109 unchanged lines hidden ---
1098 if (params->ie) {
1099 sdata->u.ibss.ie = kmemdup(params->ie, params->ie_len,
1100 GFP_KERNEL);
1101 if (sdata->u.ibss.ie)
1102 sdata->u.ibss.ie_len = params->ie_len;
1103 }
1104
1105 sdata->u.ibss.skb = skb;

--- 109 unchanged lines hidden ---