Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 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> |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License version 2 as |
| 12 | * published by the Free Software Foundation. |
| 13 | */ |
| 14 | |
| 15 | #include <linux/delay.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 16 | #include <linux/slab.h> |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 17 | #include <linux/if_ether.h> |
| 18 | #include <linux/skbuff.h> |
| 19 | #include <linux/if_arp.h> |
| 20 | #include <linux/etherdevice.h> |
| 21 | #include <linux/rtnetlink.h> |
| 22 | #include <net/mac80211.h> |
| 23 | #include <asm/unaligned.h> |
| 24 | |
| 25 | #include "ieee80211_i.h" |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 26 | #include "driver-ops.h" |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 27 | #include "rate.h" |
| 28 | |
| 29 | #define IEEE80211_SCAN_INTERVAL (2 * HZ) |
| 30 | #define IEEE80211_SCAN_INTERVAL_SLOW (15 * HZ) |
| 31 | #define IEEE80211_IBSS_JOIN_TIMEOUT (7 * HZ) |
| 32 | |
| 33 | #define IEEE80211_IBSS_MERGE_INTERVAL (30 * HZ) |
Alina Friedrichsen | 4a332a3 | 2009-02-22 18:19:33 +0100 | [diff] [blame] | 34 | #define IEEE80211_IBSS_MERGE_DELAY 0x400000 |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 35 | #define IEEE80211_IBSS_INACTIVITY_LIMIT (60 * HZ) |
| 36 | |
| 37 | #define IEEE80211_IBSS_MAX_STA_ENTRIES 128 |
| 38 | |
| 39 | |
| 40 | static void ieee80211_rx_mgmt_auth_ibss(struct ieee80211_sub_if_data *sdata, |
| 41 | struct ieee80211_mgmt *mgmt, |
| 42 | size_t len) |
| 43 | { |
| 44 | u16 auth_alg, auth_transaction, status_code; |
| 45 | |
| 46 | if (len < 24 + 6) |
| 47 | return; |
| 48 | |
| 49 | auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg); |
| 50 | auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction); |
| 51 | status_code = le16_to_cpu(mgmt->u.auth.status_code); |
| 52 | |
| 53 | /* |
| 54 | * IEEE 802.11 standard does not require authentication in IBSS |
| 55 | * networks and most implementations do not seem to use it. |
| 56 | * However, try to reply to authentication attempts if someone |
| 57 | * has actually implemented this. |
| 58 | */ |
| 59 | if (auth_alg == WLAN_AUTH_OPEN && auth_transaction == 1) |
| 60 | ieee80211_send_auth(sdata, 2, WLAN_AUTH_OPEN, NULL, 0, |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 61 | sdata->u.ibss.bssid, NULL, 0, 0); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 62 | } |
| 63 | |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 64 | static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, |
| 65 | const u8 *bssid, const int beacon_int, |
| 66 | struct ieee80211_channel *chan, |
Johannes Berg | b59066a | 2009-05-12 21:18:38 +0200 | [diff] [blame] | 67 | const u32 basic_rates, |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 68 | const u16 capability, u64 tsf) |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 69 | { |
| 70 | struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; |
| 71 | struct ieee80211_local *local = sdata->local; |
Johannes Berg | b59066a | 2009-05-12 21:18:38 +0200 | [diff] [blame] | 72 | int rates, i; |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 73 | struct sk_buff *skb; |
| 74 | struct ieee80211_mgmt *mgmt; |
| 75 | u8 *pos; |
| 76 | struct ieee80211_supported_band *sband; |
Johannes Berg | f446d10 | 2009-10-28 15:12:32 +0100 | [diff] [blame] | 77 | struct cfg80211_bss *bss; |
Johannes Berg | 57c4d7b | 2009-04-23 16:10:04 +0200 | [diff] [blame] | 78 | u32 bss_change; |
Johannes Berg | b59066a | 2009-05-12 21:18:38 +0200 | [diff] [blame] | 79 | u8 supp_rates[IEEE80211_MAX_SUPP_RATES]; |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 80 | |
| 81 | /* Reset own TSF to allow time synchronization work. */ |
| 82 | drv_reset_tsf(local); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 83 | |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 84 | skb = ifibss->skb; |
| 85 | rcu_assign_pointer(ifibss->presp, NULL); |
| 86 | synchronize_rcu(); |
| 87 | skb->data = skb->head; |
| 88 | skb->len = 0; |
| 89 | skb_reset_tail_pointer(skb); |
| 90 | skb_reserve(skb, sdata->local->hw.extra_tx_headroom); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 91 | |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 92 | if (memcmp(ifibss->bssid, bssid, ETH_ALEN)) |
| 93 | sta_info_flush(sdata->local, sdata); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 94 | |
| 95 | memcpy(ifibss->bssid, bssid, ETH_ALEN); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 96 | |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 97 | sdata->drop_unencrypted = capability & WLAN_CAPABILITY_PRIVACY ? 1 : 0; |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 98 | |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 99 | local->oper_channel = chan; |
| 100 | local->oper_channel_type = NL80211_CHAN_NO_HT; |
| 101 | ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL); |
Johannes Berg | 57c4d7b | 2009-04-23 16:10:04 +0200 | [diff] [blame] | 102 | |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 103 | sband = local->hw.wiphy->bands[chan->band]; |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 104 | |
Johannes Berg | b59066a | 2009-05-12 21:18:38 +0200 | [diff] [blame] | 105 | /* build supported rates array */ |
| 106 | pos = supp_rates; |
| 107 | for (i = 0; i < sband->n_bitrates; i++) { |
| 108 | int rate = sband->bitrates[i].bitrate; |
| 109 | u8 basic = 0; |
| 110 | if (basic_rates & BIT(i)) |
| 111 | basic = 0x80; |
| 112 | *pos++ = basic | (u8) (rate / 5); |
| 113 | } |
| 114 | |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 115 | /* Build IBSS probe response */ |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 116 | mgmt = (void *) skb_put(skb, 24 + sizeof(mgmt->u.beacon)); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 117 | memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon)); |
| 118 | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | |
| 119 | IEEE80211_STYPE_PROBE_RESP); |
| 120 | memset(mgmt->da, 0xff, ETH_ALEN); |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 121 | memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 122 | memcpy(mgmt->bssid, ifibss->bssid, ETH_ALEN); |
Johannes Berg | 57c4d7b | 2009-04-23 16:10:04 +0200 | [diff] [blame] | 123 | mgmt->u.beacon.beacon_int = cpu_to_le16(beacon_int); |
Sujith | 707c1b4 | 2009-03-03 10:15:10 +0530 | [diff] [blame] | 124 | mgmt->u.beacon.timestamp = cpu_to_le64(tsf); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 125 | mgmt->u.beacon.capab_info = cpu_to_le16(capability); |
| 126 | |
| 127 | pos = skb_put(skb, 2 + ifibss->ssid_len); |
| 128 | *pos++ = WLAN_EID_SSID; |
| 129 | *pos++ = ifibss->ssid_len; |
| 130 | memcpy(pos, ifibss->ssid, ifibss->ssid_len); |
| 131 | |
Johannes Berg | b59066a | 2009-05-12 21:18:38 +0200 | [diff] [blame] | 132 | rates = sband->n_bitrates; |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 133 | if (rates > 8) |
| 134 | rates = 8; |
| 135 | pos = skb_put(skb, 2 + rates); |
| 136 | *pos++ = WLAN_EID_SUPP_RATES; |
| 137 | *pos++ = rates; |
| 138 | memcpy(pos, supp_rates, rates); |
| 139 | |
| 140 | if (sband->band == IEEE80211_BAND_2GHZ) { |
| 141 | pos = skb_put(skb, 2 + 1); |
| 142 | *pos++ = WLAN_EID_DS_PARAMS; |
| 143 | *pos++ = 1; |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 144 | *pos++ = ieee80211_frequency_to_channel(chan->center_freq); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | pos = skb_put(skb, 2 + 2); |
| 148 | *pos++ = WLAN_EID_IBSS_PARAMS; |
| 149 | *pos++ = 2; |
| 150 | /* FIX: set ATIM window based on scan results */ |
| 151 | *pos++ = 0; |
| 152 | *pos++ = 0; |
| 153 | |
Johannes Berg | b59066a | 2009-05-12 21:18:38 +0200 | [diff] [blame] | 154 | if (sband->n_bitrates > 8) { |
| 155 | rates = sband->n_bitrates - 8; |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 156 | pos = skb_put(skb, 2 + rates); |
| 157 | *pos++ = WLAN_EID_EXT_SUPP_RATES; |
| 158 | *pos++ = rates; |
| 159 | memcpy(pos, &supp_rates[8], rates); |
| 160 | } |
| 161 | |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 162 | if (ifibss->ie_len) |
| 163 | memcpy(skb_put(skb, ifibss->ie_len), |
| 164 | ifibss->ie, ifibss->ie_len); |
| 165 | |
| 166 | rcu_assign_pointer(ifibss->presp, skb); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 167 | |
Johannes Berg | 2d0ddec | 2009-04-23 16:13:26 +0200 | [diff] [blame] | 168 | sdata->vif.bss_conf.beacon_int = beacon_int; |
| 169 | bss_change = BSS_CHANGED_BEACON_INT; |
| 170 | bss_change |= ieee80211_reset_erp_info(sdata); |
| 171 | bss_change |= BSS_CHANGED_BSSID; |
| 172 | bss_change |= BSS_CHANGED_BEACON; |
| 173 | bss_change |= BSS_CHANGED_BEACON_ENABLED; |
| 174 | ieee80211_bss_info_change_notify(sdata, bss_change); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 175 | |
Johannes Berg | b59066a | 2009-05-12 21:18:38 +0200 | [diff] [blame] | 176 | ieee80211_sta_def_wmm_params(sdata, sband->n_bitrates, supp_rates); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 177 | |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 178 | ifibss->state = IEEE80211_IBSS_MLME_JOINED; |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 179 | mod_timer(&ifibss->timer, |
| 180 | round_jiffies(jiffies + IEEE80211_IBSS_MERGE_INTERVAL)); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 181 | |
Johannes Berg | f446d10 | 2009-10-28 15:12:32 +0100 | [diff] [blame] | 182 | bss = cfg80211_inform_bss_frame(local->hw.wiphy, local->hw.conf.channel, |
| 183 | mgmt, skb->len, 0, GFP_KERNEL); |
| 184 | cfg80211_put_bss(bss); |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 185 | cfg80211_ibss_joined(sdata->dev, ifibss->bssid, GFP_KERNEL); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 186 | } |
| 187 | |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 188 | static void ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, |
| 189 | struct ieee80211_bss *bss) |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 190 | { |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 191 | struct cfg80211_bss *cbss = |
| 192 | container_of((void *)bss, struct cfg80211_bss, priv); |
Johannes Berg | b59066a | 2009-05-12 21:18:38 +0200 | [diff] [blame] | 193 | struct ieee80211_supported_band *sband; |
| 194 | u32 basic_rates; |
| 195 | int i, j; |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 196 | u16 beacon_int = cbss->beacon_interval; |
Johannes Berg | 57c4d7b | 2009-04-23 16:10:04 +0200 | [diff] [blame] | 197 | |
| 198 | if (beacon_int < 10) |
| 199 | beacon_int = 10; |
| 200 | |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 201 | sband = sdata->local->hw.wiphy->bands[cbss->channel->band]; |
Johannes Berg | b59066a | 2009-05-12 21:18:38 +0200 | [diff] [blame] | 202 | |
| 203 | basic_rates = 0; |
| 204 | |
| 205 | for (i = 0; i < bss->supp_rates_len; i++) { |
| 206 | int rate = (bss->supp_rates[i] & 0x7f) * 5; |
| 207 | bool is_basic = !!(bss->supp_rates[i] & 0x80); |
| 208 | |
| 209 | for (j = 0; j < sband->n_bitrates; j++) { |
| 210 | if (sband->bitrates[j].bitrate == rate) { |
| 211 | if (is_basic) |
| 212 | basic_rates |= BIT(j); |
| 213 | break; |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 218 | __ieee80211_sta_join_ibss(sdata, cbss->bssid, |
Johannes Berg | 57c4d7b | 2009-04-23 16:10:04 +0200 | [diff] [blame] | 219 | beacon_int, |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 220 | cbss->channel, |
Johannes Berg | b59066a | 2009-05-12 21:18:38 +0200 | [diff] [blame] | 221 | basic_rates, |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 222 | cbss->capability, |
| 223 | cbss->tsf); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, |
| 227 | struct ieee80211_mgmt *mgmt, |
| 228 | size_t len, |
| 229 | struct ieee80211_rx_status *rx_status, |
| 230 | struct ieee802_11_elems *elems, |
| 231 | bool beacon) |
| 232 | { |
| 233 | struct ieee80211_local *local = sdata->local; |
| 234 | int freq; |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 235 | struct cfg80211_bss *cbss; |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 236 | struct ieee80211_bss *bss; |
| 237 | struct sta_info *sta; |
| 238 | struct ieee80211_channel *channel; |
| 239 | u64 beacon_timestamp, rx_timestamp; |
| 240 | u32 supp_rates = 0; |
| 241 | enum ieee80211_band band = rx_status->band; |
| 242 | |
| 243 | if (elems->ds_params && elems->ds_params_len == 1) |
| 244 | freq = ieee80211_channel_to_frequency(elems->ds_params[0]); |
| 245 | else |
| 246 | freq = rx_status->freq; |
| 247 | |
| 248 | channel = ieee80211_get_channel(local->hw.wiphy, freq); |
| 249 | |
| 250 | if (!channel || channel->flags & IEEE80211_CHAN_DISABLED) |
| 251 | return; |
| 252 | |
| 253 | if (sdata->vif.type == NL80211_IFTYPE_ADHOC && elems->supp_rates && |
| 254 | memcmp(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN) == 0) { |
| 255 | supp_rates = ieee80211_sta_get_rates(local, elems, band); |
| 256 | |
| 257 | rcu_read_lock(); |
| 258 | |
Johannes Berg | abe6063 | 2009-11-25 17:46:18 +0100 | [diff] [blame] | 259 | sta = sta_info_get(sdata, mgmt->sa); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 260 | if (sta) { |
| 261 | u32 prev_rates; |
| 262 | |
| 263 | prev_rates = sta->sta.supp_rates[band]; |
| 264 | /* make sure mandatory rates are always added */ |
| 265 | sta->sta.supp_rates[band] = supp_rates | |
| 266 | ieee80211_mandatory_rates(local, band); |
| 267 | |
| 268 | #ifdef CONFIG_MAC80211_IBSS_DEBUG |
| 269 | if (sta->sta.supp_rates[band] != prev_rates) |
| 270 | printk(KERN_DEBUG "%s: updated supp_rates set " |
| 271 | "for %pM based on beacon info (0x%llx | " |
| 272 | "0x%llx -> 0x%llx)\n", |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 273 | sdata->name, |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 274 | sta->sta.addr, |
| 275 | (unsigned long long) prev_rates, |
| 276 | (unsigned long long) supp_rates, |
| 277 | (unsigned long long) sta->sta.supp_rates[band]); |
| 278 | #endif |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 279 | rcu_read_unlock(); |
| 280 | } else { |
| 281 | rcu_read_unlock(); |
| 282 | ieee80211_ibss_add_sta(sdata, mgmt->bssid, mgmt->sa, |
| 283 | supp_rates, GFP_KERNEL); |
| 284 | } |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 285 | } |
| 286 | |
| 287 | bss = ieee80211_bss_info_update(local, rx_status, mgmt, len, elems, |
| 288 | channel, beacon); |
| 289 | if (!bss) |
| 290 | return; |
| 291 | |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 292 | cbss = container_of((void *)bss, struct cfg80211_bss, priv); |
| 293 | |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 294 | /* was just updated in ieee80211_bss_info_update */ |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 295 | beacon_timestamp = cbss->tsf; |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 296 | |
| 297 | /* check if we need to merge IBSS */ |
| 298 | |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 299 | /* we use a fixed BSSID */ |
Benoit Papillault | a98bfec | 2010-01-17 22:45:24 +0100 | [diff] [blame] | 300 | if (sdata->u.ibss.fixed_bssid) |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 301 | goto put_bss; |
| 302 | |
| 303 | /* not an IBSS */ |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 304 | if (!(cbss->capability & WLAN_CAPABILITY_IBSS)) |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 305 | goto put_bss; |
| 306 | |
| 307 | /* different channel */ |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 308 | if (cbss->channel != local->oper_channel) |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 309 | goto put_bss; |
| 310 | |
| 311 | /* different SSID */ |
| 312 | if (elems->ssid_len != sdata->u.ibss.ssid_len || |
| 313 | memcmp(elems->ssid, sdata->u.ibss.ssid, |
| 314 | sdata->u.ibss.ssid_len)) |
| 315 | goto put_bss; |
| 316 | |
Alina Friedrichsen | 34e8f08 | 2009-02-22 00:07:28 +0100 | [diff] [blame] | 317 | /* same BSSID */ |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 318 | if (memcmp(cbss->bssid, sdata->u.ibss.bssid, ETH_ALEN) == 0) |
Alina Friedrichsen | 34e8f08 | 2009-02-22 00:07:28 +0100 | [diff] [blame] | 319 | goto put_bss; |
| 320 | |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 321 | if (rx_status->flag & RX_FLAG_TSFT) { |
| 322 | /* |
| 323 | * For correct IBSS merging we need mactime; since mactime is |
| 324 | * defined as the time the first data symbol of the frame hits |
| 325 | * the PHY, and the timestamp of the beacon is defined as "the |
| 326 | * time that the data symbol containing the first bit of the |
| 327 | * timestamp is transmitted to the PHY plus the transmitting |
| 328 | * STA's delays through its local PHY from the MAC-PHY |
| 329 | * interface to its interface with the WM" (802.11 11.1.2) |
| 330 | * - equals the time this bit arrives at the receiver - we have |
| 331 | * to take into account the offset between the two. |
| 332 | * |
| 333 | * E.g. at 1 MBit that means mactime is 192 usec earlier |
| 334 | * (=24 bytes * 8 usecs/byte) than the beacon timestamp. |
| 335 | */ |
| 336 | int rate; |
| 337 | |
| 338 | if (rx_status->flag & RX_FLAG_HT) |
| 339 | rate = 65; /* TODO: HT rates */ |
| 340 | else |
| 341 | rate = local->hw.wiphy->bands[band]-> |
| 342 | bitrates[rx_status->rate_idx].bitrate; |
| 343 | |
| 344 | rx_timestamp = rx_status->mactime + (24 * 8 * 10 / rate); |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 345 | } else { |
| 346 | /* |
| 347 | * second best option: get current TSF |
| 348 | * (will return -1 if not supported) |
| 349 | */ |
| 350 | rx_timestamp = drv_get_tsf(local); |
| 351 | } |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 352 | |
| 353 | #ifdef CONFIG_MAC80211_IBSS_DEBUG |
| 354 | printk(KERN_DEBUG "RX beacon SA=%pM BSSID=" |
| 355 | "%pM TSF=0x%llx BCN=0x%llx diff=%lld @%lu\n", |
| 356 | mgmt->sa, mgmt->bssid, |
| 357 | (unsigned long long)rx_timestamp, |
| 358 | (unsigned long long)beacon_timestamp, |
| 359 | (unsigned long long)(rx_timestamp - beacon_timestamp), |
| 360 | jiffies); |
| 361 | #endif |
| 362 | |
Alina Friedrichsen | 4a332a3 | 2009-02-22 18:19:33 +0100 | [diff] [blame] | 363 | /* give slow hardware some time to do the TSF sync */ |
| 364 | if (rx_timestamp < IEEE80211_IBSS_MERGE_DELAY) |
| 365 | goto put_bss; |
| 366 | |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 367 | if (beacon_timestamp > rx_timestamp) { |
| 368 | #ifdef CONFIG_MAC80211_IBSS_DEBUG |
| 369 | printk(KERN_DEBUG "%s: beacon TSF higher than " |
| 370 | "local TSF - IBSS merge with BSSID %pM\n", |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 371 | sdata->name, mgmt->bssid); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 372 | #endif |
| 373 | ieee80211_sta_join_ibss(sdata, bss); |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 374 | ieee80211_ibss_add_sta(sdata, mgmt->bssid, mgmt->sa, |
| 375 | supp_rates, GFP_KERNEL); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 376 | } |
| 377 | |
| 378 | put_bss: |
| 379 | ieee80211_rx_bss_put(local, bss); |
| 380 | } |
| 381 | |
| 382 | /* |
| 383 | * Add a new IBSS station, will also be called by the RX code when, |
| 384 | * in IBSS mode, receiving a frame from a yet-unknown station, hence |
| 385 | * must be callable in atomic context. |
| 386 | */ |
| 387 | struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 388 | u8 *bssid,u8 *addr, u32 supp_rates, |
| 389 | gfp_t gfp) |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 390 | { |
Felix Fietkau | 2e10d33 | 2009-12-20 19:07:09 +0100 | [diff] [blame] | 391 | struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 392 | struct ieee80211_local *local = sdata->local; |
| 393 | struct sta_info *sta; |
| 394 | int band = local->hw.conf.channel->band; |
| 395 | |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 396 | /* |
| 397 | * XXX: Consider removing the least recently used entry and |
| 398 | * allow new one to be added. |
| 399 | */ |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 400 | if (local->num_sta >= IEEE80211_IBSS_MAX_STA_ENTRIES) { |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 401 | if (net_ratelimit()) |
| 402 | printk(KERN_DEBUG "%s: No room for a new IBSS STA entry %pM\n", |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 403 | sdata->name, addr); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 404 | return NULL; |
| 405 | } |
| 406 | |
Felix Fietkau | 2e10d33 | 2009-12-20 19:07:09 +0100 | [diff] [blame] | 407 | if (ifibss->state == IEEE80211_IBSS_MLME_SEARCH) |
| 408 | return NULL; |
| 409 | |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 410 | if (compare_ether_addr(bssid, sdata->u.ibss.bssid)) |
| 411 | return NULL; |
| 412 | |
| 413 | #ifdef CONFIG_MAC80211_VERBOSE_DEBUG |
| 414 | printk(KERN_DEBUG "%s: Adding new IBSS station %pM (dev=%s)\n", |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 415 | wiphy_name(local->hw.wiphy), addr, sdata->name); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 416 | #endif |
| 417 | |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 418 | sta = sta_info_alloc(sdata, addr, gfp); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 419 | if (!sta) |
| 420 | return NULL; |
| 421 | |
| 422 | set_sta_flags(sta, WLAN_STA_AUTHORIZED); |
| 423 | |
| 424 | /* make sure mandatory rates are always added */ |
| 425 | sta->sta.supp_rates[band] = supp_rates | |
| 426 | ieee80211_mandatory_rates(local, band); |
| 427 | |
| 428 | rate_control_rate_init(sta); |
| 429 | |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 430 | /* If it fails, maybe we raced another insertion? */ |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 431 | if (sta_info_insert(sta)) |
Johannes Berg | 34e8950 | 2010-02-03 13:59:58 +0100 | [diff] [blame] | 432 | return sta_info_get(sdata, addr); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 433 | return sta; |
| 434 | } |
| 435 | |
| 436 | static int ieee80211_sta_active_ibss(struct ieee80211_sub_if_data *sdata) |
| 437 | { |
| 438 | struct ieee80211_local *local = sdata->local; |
| 439 | int active = 0; |
| 440 | struct sta_info *sta; |
| 441 | |
| 442 | rcu_read_lock(); |
| 443 | |
| 444 | list_for_each_entry_rcu(sta, &local->sta_list, list) { |
| 445 | if (sta->sdata == sdata && |
| 446 | time_after(sta->last_rx + IEEE80211_IBSS_MERGE_INTERVAL, |
| 447 | jiffies)) { |
| 448 | active++; |
| 449 | break; |
| 450 | } |
| 451 | } |
| 452 | |
| 453 | rcu_read_unlock(); |
| 454 | |
| 455 | return active; |
| 456 | } |
| 457 | |
Benoit Papillault | ce9058a | 2010-01-17 22:45:23 +0100 | [diff] [blame] | 458 | /* |
| 459 | * This function is called with state == IEEE80211_IBSS_MLME_JOINED |
| 460 | */ |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 461 | |
| 462 | static void ieee80211_sta_merge_ibss(struct ieee80211_sub_if_data *sdata) |
| 463 | { |
| 464 | struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; |
| 465 | |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 466 | mod_timer(&ifibss->timer, |
| 467 | round_jiffies(jiffies + IEEE80211_IBSS_MERGE_INTERVAL)); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 468 | |
| 469 | ieee80211_sta_expire(sdata, IEEE80211_IBSS_INACTIVITY_LIMIT); |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 470 | |
Sujith | 450aae3 | 2009-11-02 12:33:23 +0530 | [diff] [blame] | 471 | if (time_before(jiffies, ifibss->last_scan_completed + |
| 472 | IEEE80211_IBSS_MERGE_INTERVAL)) |
| 473 | return; |
| 474 | |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 475 | if (ieee80211_sta_active_ibss(sdata)) |
| 476 | return; |
| 477 | |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 478 | if (ifibss->fixed_channel) |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 479 | return; |
| 480 | |
| 481 | printk(KERN_DEBUG "%s: No active IBSS STAs - trying to scan for other " |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 482 | "IBSS networks with same SSID (merge)\n", sdata->name); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 483 | |
Johannes Berg | f3b8525 | 2009-04-23 16:01:47 +0200 | [diff] [blame] | 484 | ieee80211_request_internal_scan(sdata, ifibss->ssid, ifibss->ssid_len); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 485 | } |
| 486 | |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 487 | static void ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata) |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 488 | { |
| 489 | struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; |
| 490 | struct ieee80211_local *local = sdata->local; |
| 491 | struct ieee80211_supported_band *sband; |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 492 | u8 bssid[ETH_ALEN]; |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 493 | u16 capability; |
| 494 | int i; |
| 495 | |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 496 | if (ifibss->fixed_bssid) { |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 497 | memcpy(bssid, ifibss->bssid, ETH_ALEN); |
| 498 | } else { |
| 499 | /* Generate random, not broadcast, locally administered BSSID. Mix in |
| 500 | * own MAC address to make sure that devices that do not have proper |
| 501 | * random number generator get different BSSID. */ |
| 502 | get_random_bytes(bssid, ETH_ALEN); |
| 503 | for (i = 0; i < ETH_ALEN; i++) |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 504 | bssid[i] ^= sdata->vif.addr[i]; |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 505 | bssid[0] &= ~0x01; |
| 506 | bssid[0] |= 0x02; |
| 507 | } |
| 508 | |
| 509 | printk(KERN_DEBUG "%s: Creating new IBSS network, BSSID %pM\n", |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 510 | sdata->name, bssid); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 511 | |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 512 | sband = local->hw.wiphy->bands[ifibss->channel->band]; |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 513 | |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 514 | capability = WLAN_CAPABILITY_IBSS; |
| 515 | |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 516 | if (ifibss->privacy) |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 517 | capability |= WLAN_CAPABILITY_PRIVACY; |
| 518 | else |
| 519 | sdata->drop_unencrypted = 0; |
| 520 | |
Johannes Berg | 57c4d7b | 2009-04-23 16:10:04 +0200 | [diff] [blame] | 521 | __ieee80211_sta_join_ibss(sdata, bssid, sdata->vif.bss_conf.beacon_int, |
Johannes Berg | b59066a | 2009-05-12 21:18:38 +0200 | [diff] [blame] | 522 | ifibss->channel, 3, /* first two are basic */ |
| 523 | capability, 0); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 524 | } |
| 525 | |
Benoit Papillault | ce9058a | 2010-01-17 22:45:23 +0100 | [diff] [blame] | 526 | /* |
| 527 | * This function is called with state == IEEE80211_IBSS_MLME_SEARCH |
| 528 | */ |
| 529 | |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 530 | static void ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata) |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 531 | { |
| 532 | struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; |
| 533 | struct ieee80211_local *local = sdata->local; |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 534 | struct cfg80211_bss *cbss; |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 535 | struct ieee80211_channel *chan = NULL; |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 536 | const u8 *bssid = NULL; |
| 537 | int active_ibss; |
Johannes Berg | e0d6188 | 2009-05-12 20:47:32 +0200 | [diff] [blame] | 538 | u16 capability; |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 539 | |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 540 | active_ibss = ieee80211_sta_active_ibss(sdata); |
| 541 | #ifdef CONFIG_MAC80211_IBSS_DEBUG |
| 542 | printk(KERN_DEBUG "%s: sta_find_ibss (active_ibss=%d)\n", |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 543 | sdata->name, active_ibss); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 544 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ |
| 545 | |
| 546 | if (active_ibss) |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 547 | return; |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 548 | |
Johannes Berg | e0d6188 | 2009-05-12 20:47:32 +0200 | [diff] [blame] | 549 | capability = WLAN_CAPABILITY_IBSS; |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 550 | if (ifibss->privacy) |
Johannes Berg | e0d6188 | 2009-05-12 20:47:32 +0200 | [diff] [blame] | 551 | capability |= WLAN_CAPABILITY_PRIVACY; |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 552 | if (ifibss->fixed_bssid) |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 553 | bssid = ifibss->bssid; |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 554 | if (ifibss->fixed_channel) |
| 555 | chan = ifibss->channel; |
| 556 | if (!is_zero_ether_addr(ifibss->bssid)) |
| 557 | bssid = ifibss->bssid; |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 558 | cbss = cfg80211_get_bss(local->hw.wiphy, chan, bssid, |
| 559 | ifibss->ssid, ifibss->ssid_len, |
| 560 | WLAN_CAPABILITY_IBSS | WLAN_CAPABILITY_PRIVACY, |
| 561 | capability); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 562 | |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 563 | if (cbss) { |
| 564 | struct ieee80211_bss *bss; |
| 565 | |
| 566 | bss = (void *)cbss->priv; |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 567 | #ifdef CONFIG_MAC80211_IBSS_DEBUG |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 568 | printk(KERN_DEBUG " sta_find_ibss: selected %pM current " |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 569 | "%pM\n", cbss->bssid, ifibss->bssid); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 570 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ |
| 571 | |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 572 | printk(KERN_DEBUG "%s: Selected IBSS BSSID %pM" |
| 573 | " based on configured SSID\n", |
Johannes Berg | 0c1ad2c | 2009-12-23 13:15:39 +0100 | [diff] [blame] | 574 | sdata->name, cbss->bssid); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 575 | |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 576 | ieee80211_sta_join_ibss(sdata, bss); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 577 | ieee80211_rx_bss_put(local, bss); |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 578 | return; |
Reinette Chatre | d419b9f | 2009-10-19 14:55:37 -0700 | [diff] [blame] | 579 | } |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 580 | |
| 581 | #ifdef CONFIG_MAC80211_IBSS_DEBUG |
| 582 | printk(KERN_DEBUG " did not try to join ibss\n"); |
| 583 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ |
| 584 | |
| 585 | /* Selected IBSS not found in current scan results - try to scan */ |
Benoit Papillault | ce9058a | 2010-01-17 22:45:23 +0100 | [diff] [blame] | 586 | if (time_after(jiffies, ifibss->last_scan_completed + |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 587 | IEEE80211_SCAN_INTERVAL)) { |
| 588 | printk(KERN_DEBUG "%s: Trigger new scan to find an IBSS to " |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 589 | "join\n", sdata->name); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 590 | |
Johannes Berg | f3b8525 | 2009-04-23 16:01:47 +0200 | [diff] [blame] | 591 | ieee80211_request_internal_scan(sdata, ifibss->ssid, |
| 592 | ifibss->ssid_len); |
Benoit Papillault | ce9058a | 2010-01-17 22:45:23 +0100 | [diff] [blame] | 593 | } else { |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 594 | int interval = IEEE80211_SCAN_INTERVAL; |
| 595 | |
| 596 | if (time_after(jiffies, ifibss->ibss_join_req + |
| 597 | IEEE80211_IBSS_JOIN_TIMEOUT)) { |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 598 | if (!(local->oper_channel->flags & IEEE80211_CHAN_NO_IBSS)) { |
| 599 | ieee80211_sta_create_ibss(sdata); |
| 600 | return; |
| 601 | } |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 602 | printk(KERN_DEBUG "%s: IBSS not allowed on" |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 603 | " %d MHz\n", sdata->name, |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 604 | local->hw.conf.channel->center_freq); |
| 605 | |
| 606 | /* No IBSS found - decrease scan interval and continue |
| 607 | * scanning. */ |
| 608 | interval = IEEE80211_SCAN_INTERVAL_SLOW; |
| 609 | } |
| 610 | |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 611 | mod_timer(&ifibss->timer, |
| 612 | round_jiffies(jiffies + interval)); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 613 | } |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 614 | } |
| 615 | |
| 616 | static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata, |
| 617 | struct ieee80211_mgmt *mgmt, |
| 618 | size_t len) |
| 619 | { |
| 620 | struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; |
| 621 | struct ieee80211_local *local = sdata->local; |
| 622 | int tx_last_beacon; |
| 623 | struct sk_buff *skb; |
| 624 | struct ieee80211_mgmt *resp; |
| 625 | u8 *pos, *end; |
| 626 | |
| 627 | if (ifibss->state != IEEE80211_IBSS_MLME_JOINED || |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 628 | len < 24 + 2 || !ifibss->presp) |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 629 | return; |
| 630 | |
Johannes Berg | 2448798 | 2009-04-23 18:52:52 +0200 | [diff] [blame] | 631 | tx_last_beacon = drv_tx_last_beacon(local); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 632 | |
| 633 | #ifdef CONFIG_MAC80211_IBSS_DEBUG |
| 634 | printk(KERN_DEBUG "%s: RX ProbeReq SA=%pM DA=%pM BSSID=%pM" |
| 635 | " (tx_last_beacon=%d)\n", |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 636 | sdata->name, mgmt->sa, mgmt->da, |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 637 | mgmt->bssid, tx_last_beacon); |
| 638 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ |
| 639 | |
| 640 | if (!tx_last_beacon) |
| 641 | return; |
| 642 | |
| 643 | if (memcmp(mgmt->bssid, ifibss->bssid, ETH_ALEN) != 0 && |
| 644 | memcmp(mgmt->bssid, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) != 0) |
| 645 | return; |
| 646 | |
| 647 | end = ((u8 *) mgmt) + len; |
| 648 | pos = mgmt->u.probe_req.variable; |
| 649 | if (pos[0] != WLAN_EID_SSID || |
| 650 | pos + 2 + pos[1] > end) { |
| 651 | #ifdef CONFIG_MAC80211_IBSS_DEBUG |
| 652 | printk(KERN_DEBUG "%s: Invalid SSID IE in ProbeReq " |
| 653 | "from %pM\n", |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 654 | sdata->name, mgmt->sa); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 655 | #endif |
| 656 | return; |
| 657 | } |
| 658 | if (pos[1] != 0 && |
| 659 | (pos[1] != ifibss->ssid_len || |
Benoit Papillault | 0da780c | 2010-02-05 01:21:03 +0100 | [diff] [blame] | 660 | memcmp(pos + 2, ifibss->ssid, ifibss->ssid_len))) { |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 661 | /* Ignore ProbeReq for foreign SSID */ |
| 662 | return; |
| 663 | } |
| 664 | |
| 665 | /* Reply with ProbeResp */ |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 666 | skb = skb_copy(ifibss->presp, GFP_KERNEL); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 667 | if (!skb) |
| 668 | return; |
| 669 | |
| 670 | resp = (struct ieee80211_mgmt *) skb->data; |
| 671 | memcpy(resp->da, mgmt->sa, ETH_ALEN); |
| 672 | #ifdef CONFIG_MAC80211_IBSS_DEBUG |
| 673 | printk(KERN_DEBUG "%s: Sending ProbeResp to %pM\n", |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 674 | sdata->name, resp->da); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 675 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ |
Johannes Berg | 62ae67b | 2009-11-18 18:42:05 +0100 | [diff] [blame] | 676 | IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT; |
| 677 | ieee80211_tx_skb(sdata, skb); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 678 | } |
| 679 | |
| 680 | static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata, |
| 681 | struct ieee80211_mgmt *mgmt, |
| 682 | size_t len, |
| 683 | struct ieee80211_rx_status *rx_status) |
| 684 | { |
| 685 | size_t baselen; |
| 686 | struct ieee802_11_elems elems; |
| 687 | |
Johannes Berg | 47846c9 | 2009-11-25 17:46:19 +0100 | [diff] [blame] | 688 | if (memcmp(mgmt->da, sdata->vif.addr, ETH_ALEN)) |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 689 | return; /* ignore ProbeResp to foreign address */ |
| 690 | |
| 691 | baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt; |
| 692 | if (baselen > len) |
| 693 | return; |
| 694 | |
| 695 | ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen, |
| 696 | &elems); |
| 697 | |
| 698 | ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, false); |
| 699 | } |
| 700 | |
| 701 | static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, |
| 702 | struct ieee80211_mgmt *mgmt, |
| 703 | size_t len, |
| 704 | struct ieee80211_rx_status *rx_status) |
| 705 | { |
| 706 | size_t baselen; |
| 707 | struct ieee802_11_elems elems; |
| 708 | |
| 709 | /* Process beacon from the current BSS */ |
| 710 | baselen = (u8 *) mgmt->u.beacon.variable - (u8 *) mgmt; |
| 711 | if (baselen > len) |
| 712 | return; |
| 713 | |
| 714 | ieee802_11_parse_elems(mgmt->u.beacon.variable, len - baselen, &elems); |
| 715 | |
| 716 | ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, true); |
| 717 | } |
| 718 | |
| 719 | static void ieee80211_ibss_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, |
| 720 | struct sk_buff *skb) |
| 721 | { |
| 722 | struct ieee80211_rx_status *rx_status; |
| 723 | struct ieee80211_mgmt *mgmt; |
| 724 | u16 fc; |
| 725 | |
Johannes Berg | f1d58c2 | 2009-06-17 13:13:00 +0200 | [diff] [blame] | 726 | rx_status = IEEE80211_SKB_RXCB(skb); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 727 | mgmt = (struct ieee80211_mgmt *) skb->data; |
| 728 | fc = le16_to_cpu(mgmt->frame_control); |
| 729 | |
| 730 | switch (fc & IEEE80211_FCTL_STYPE) { |
| 731 | case IEEE80211_STYPE_PROBE_REQ: |
| 732 | ieee80211_rx_mgmt_probe_req(sdata, mgmt, skb->len); |
| 733 | break; |
| 734 | case IEEE80211_STYPE_PROBE_RESP: |
| 735 | ieee80211_rx_mgmt_probe_resp(sdata, mgmt, skb->len, |
| 736 | rx_status); |
| 737 | break; |
| 738 | case IEEE80211_STYPE_BEACON: |
| 739 | ieee80211_rx_mgmt_beacon(sdata, mgmt, skb->len, |
| 740 | rx_status); |
| 741 | break; |
| 742 | case IEEE80211_STYPE_AUTH: |
| 743 | ieee80211_rx_mgmt_auth_ibss(sdata, mgmt, skb->len); |
| 744 | break; |
| 745 | } |
| 746 | |
| 747 | kfree_skb(skb); |
| 748 | } |
| 749 | |
| 750 | static void ieee80211_ibss_work(struct work_struct *work) |
| 751 | { |
| 752 | struct ieee80211_sub_if_data *sdata = |
| 753 | container_of(work, struct ieee80211_sub_if_data, u.ibss.work); |
| 754 | struct ieee80211_local *local = sdata->local; |
| 755 | struct ieee80211_if_ibss *ifibss; |
| 756 | struct sk_buff *skb; |
| 757 | |
Johannes Berg | 5bb644a | 2009-05-17 11:40:42 +0200 | [diff] [blame] | 758 | if (WARN_ON(local->suspended)) |
| 759 | return; |
| 760 | |
Johannes Berg | 9607e6b | 2009-12-23 13:15:31 +0100 | [diff] [blame] | 761 | if (!ieee80211_sdata_running(sdata)) |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 762 | return; |
| 763 | |
Helmut Schaa | fbe9c42 | 2009-07-23 12:14:04 +0200 | [diff] [blame] | 764 | if (local->scanning) |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 765 | return; |
| 766 | |
| 767 | if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_ADHOC)) |
| 768 | return; |
| 769 | ifibss = &sdata->u.ibss; |
| 770 | |
| 771 | while ((skb = skb_dequeue(&ifibss->skb_queue))) |
| 772 | ieee80211_ibss_rx_queued_mgmt(sdata, skb); |
| 773 | |
| 774 | if (!test_and_clear_bit(IEEE80211_IBSS_REQ_RUN, &ifibss->request)) |
| 775 | return; |
| 776 | |
| 777 | switch (ifibss->state) { |
| 778 | case IEEE80211_IBSS_MLME_SEARCH: |
| 779 | ieee80211_sta_find_ibss(sdata); |
| 780 | break; |
| 781 | case IEEE80211_IBSS_MLME_JOINED: |
| 782 | ieee80211_sta_merge_ibss(sdata); |
| 783 | break; |
| 784 | default: |
| 785 | WARN_ON(1); |
| 786 | break; |
| 787 | } |
| 788 | } |
| 789 | |
| 790 | static void ieee80211_ibss_timer(unsigned long data) |
| 791 | { |
| 792 | struct ieee80211_sub_if_data *sdata = |
| 793 | (struct ieee80211_sub_if_data *) data; |
| 794 | struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; |
| 795 | struct ieee80211_local *local = sdata->local; |
| 796 | |
Johannes Berg | 5bb644a | 2009-05-17 11:40:42 +0200 | [diff] [blame] | 797 | if (local->quiescing) { |
| 798 | ifibss->timer_running = true; |
| 799 | return; |
| 800 | } |
| 801 | |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 802 | set_bit(IEEE80211_IBSS_REQ_RUN, &ifibss->request); |
Luis R. Rodriguez | 42935ec | 2009-07-29 20:08:07 -0400 | [diff] [blame] | 803 | ieee80211_queue_work(&local->hw, &ifibss->work); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 804 | } |
| 805 | |
Johannes Berg | 5bb644a | 2009-05-17 11:40:42 +0200 | [diff] [blame] | 806 | #ifdef CONFIG_PM |
| 807 | void ieee80211_ibss_quiesce(struct ieee80211_sub_if_data *sdata) |
| 808 | { |
| 809 | struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; |
| 810 | |
| 811 | cancel_work_sync(&ifibss->work); |
| 812 | if (del_timer_sync(&ifibss->timer)) |
| 813 | ifibss->timer_running = true; |
| 814 | } |
| 815 | |
| 816 | void ieee80211_ibss_restart(struct ieee80211_sub_if_data *sdata) |
| 817 | { |
| 818 | struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; |
| 819 | |
| 820 | if (ifibss->timer_running) { |
| 821 | add_timer(&ifibss->timer); |
| 822 | ifibss->timer_running = false; |
| 823 | } |
| 824 | } |
| 825 | #endif |
| 826 | |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 827 | void ieee80211_ibss_setup_sdata(struct ieee80211_sub_if_data *sdata) |
| 828 | { |
| 829 | struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; |
| 830 | |
| 831 | INIT_WORK(&ifibss->work, ieee80211_ibss_work); |
| 832 | setup_timer(&ifibss->timer, ieee80211_ibss_timer, |
| 833 | (unsigned long) sdata); |
| 834 | skb_queue_head_init(&ifibss->skb_queue); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 835 | } |
| 836 | |
| 837 | /* scan finished notification */ |
| 838 | void ieee80211_ibss_notify_scan_completed(struct ieee80211_local *local) |
| 839 | { |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 840 | struct ieee80211_sub_if_data *sdata; |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 841 | |
Johannes Berg | 29b4a4f | 2009-04-21 00:30:49 +0200 | [diff] [blame] | 842 | mutex_lock(&local->iflist_mtx); |
| 843 | list_for_each_entry(sdata, &local->interfaces, list) { |
Johannes Berg | 9607e6b | 2009-12-23 13:15:31 +0100 | [diff] [blame] | 844 | if (!ieee80211_sdata_running(sdata)) |
Johannes Berg | 0e41f71 | 2009-04-23 11:48:56 +0200 | [diff] [blame] | 845 | continue; |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 846 | if (sdata->vif.type != NL80211_IFTYPE_ADHOC) |
| 847 | continue; |
Johannes Berg | 0e41f71 | 2009-04-23 11:48:56 +0200 | [diff] [blame] | 848 | if (!sdata->u.ibss.ssid_len) |
| 849 | continue; |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 850 | sdata->u.ibss.last_scan_completed = jiffies; |
Johannes Berg | 51f98f1 | 2009-10-11 11:47:57 +0200 | [diff] [blame] | 851 | mod_timer(&sdata->u.ibss.timer, 0); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 852 | } |
Johannes Berg | 29b4a4f | 2009-04-21 00:30:49 +0200 | [diff] [blame] | 853 | mutex_unlock(&local->iflist_mtx); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 854 | } |
| 855 | |
| 856 | ieee80211_rx_result |
Johannes Berg | f1d58c2 | 2009-06-17 13:13:00 +0200 | [diff] [blame] | 857 | ieee80211_ibss_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb) |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 858 | { |
| 859 | struct ieee80211_local *local = sdata->local; |
| 860 | struct ieee80211_mgmt *mgmt; |
| 861 | u16 fc; |
| 862 | |
| 863 | if (skb->len < 24) |
| 864 | return RX_DROP_MONITOR; |
| 865 | |
| 866 | mgmt = (struct ieee80211_mgmt *) skb->data; |
| 867 | fc = le16_to_cpu(mgmt->frame_control); |
| 868 | |
| 869 | switch (fc & IEEE80211_FCTL_STYPE) { |
| 870 | case IEEE80211_STYPE_PROBE_RESP: |
| 871 | case IEEE80211_STYPE_BEACON: |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 872 | case IEEE80211_STYPE_PROBE_REQ: |
| 873 | case IEEE80211_STYPE_AUTH: |
| 874 | skb_queue_tail(&sdata->u.ibss.skb_queue, skb); |
Luis R. Rodriguez | 42935ec | 2009-07-29 20:08:07 -0400 | [diff] [blame] | 875 | ieee80211_queue_work(&local->hw, &sdata->u.ibss.work); |
Johannes Berg | 4690029 | 2009-02-15 12:44:28 +0100 | [diff] [blame] | 876 | return RX_QUEUED; |
| 877 | } |
| 878 | |
| 879 | return RX_DROP_MONITOR; |
| 880 | } |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 881 | |
| 882 | int ieee80211_ibss_join(struct ieee80211_sub_if_data *sdata, |
| 883 | struct cfg80211_ibss_params *params) |
| 884 | { |
| 885 | struct sk_buff *skb; |
| 886 | |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 887 | if (params->bssid) { |
| 888 | memcpy(sdata->u.ibss.bssid, params->bssid, ETH_ALEN); |
| 889 | sdata->u.ibss.fixed_bssid = true; |
| 890 | } else |
| 891 | sdata->u.ibss.fixed_bssid = false; |
| 892 | |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 893 | sdata->u.ibss.privacy = params->privacy; |
| 894 | |
Johannes Berg | 57c4d7b | 2009-04-23 16:10:04 +0200 | [diff] [blame] | 895 | sdata->vif.bss_conf.beacon_int = params->beacon_interval; |
| 896 | |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 897 | sdata->u.ibss.channel = params->channel; |
| 898 | sdata->u.ibss.fixed_channel = params->channel_fixed; |
| 899 | |
| 900 | if (params->ie) { |
| 901 | sdata->u.ibss.ie = kmemdup(params->ie, params->ie_len, |
| 902 | GFP_KERNEL); |
| 903 | if (sdata->u.ibss.ie) |
| 904 | sdata->u.ibss.ie_len = params->ie_len; |
| 905 | } |
| 906 | |
| 907 | skb = dev_alloc_skb(sdata->local->hw.extra_tx_headroom + |
| 908 | 36 /* bitrates */ + |
| 909 | 34 /* SSID */ + |
| 910 | 3 /* DS params */ + |
| 911 | 4 /* IBSS params */ + |
| 912 | params->ie_len); |
| 913 | if (!skb) |
| 914 | return -ENOMEM; |
| 915 | |
| 916 | sdata->u.ibss.skb = skb; |
| 917 | sdata->u.ibss.state = IEEE80211_IBSS_MLME_SEARCH; |
| 918 | sdata->u.ibss.ibss_join_req = jiffies; |
| 919 | |
Johannes Berg | 0e41f71 | 2009-04-23 11:48:56 +0200 | [diff] [blame] | 920 | memcpy(sdata->u.ibss.ssid, params->ssid, IEEE80211_MAX_SSID_LEN); |
| 921 | |
| 922 | /* |
| 923 | * The ssid_len setting below is used to see whether |
| 924 | * we are active, and we need all other settings |
| 925 | * before that may get visible. |
| 926 | */ |
| 927 | mb(); |
| 928 | |
| 929 | sdata->u.ibss.ssid_len = params->ssid_len; |
| 930 | |
Johannes Berg | 5cff20e | 2009-04-29 12:26:17 +0200 | [diff] [blame] | 931 | ieee80211_recalc_idle(sdata->local); |
| 932 | |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 933 | set_bit(IEEE80211_IBSS_REQ_RUN, &sdata->u.ibss.request); |
Luis R. Rodriguez | 42935ec | 2009-07-29 20:08:07 -0400 | [diff] [blame] | 934 | ieee80211_queue_work(&sdata->local->hw, &sdata->u.ibss.work); |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 935 | |
| 936 | return 0; |
| 937 | } |
| 938 | |
| 939 | int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata) |
| 940 | { |
| 941 | struct sk_buff *skb; |
| 942 | |
| 943 | del_timer_sync(&sdata->u.ibss.timer); |
| 944 | clear_bit(IEEE80211_IBSS_REQ_RUN, &sdata->u.ibss.request); |
| 945 | cancel_work_sync(&sdata->u.ibss.work); |
| 946 | clear_bit(IEEE80211_IBSS_REQ_RUN, &sdata->u.ibss.request); |
| 947 | |
| 948 | sta_info_flush(sdata->local, sdata); |
| 949 | |
| 950 | /* remove beacon */ |
| 951 | kfree(sdata->u.ibss.ie); |
| 952 | skb = sdata->u.ibss.presp; |
| 953 | rcu_assign_pointer(sdata->u.ibss.presp, NULL); |
Johannes Berg | 2d0ddec | 2009-04-23 16:13:26 +0200 | [diff] [blame] | 954 | ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED); |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 955 | synchronize_rcu(); |
| 956 | kfree_skb(skb); |
| 957 | |
| 958 | skb_queue_purge(&sdata->u.ibss.skb_queue); |
| 959 | memset(sdata->u.ibss.bssid, 0, ETH_ALEN); |
Johannes Berg | 5cff20e | 2009-04-29 12:26:17 +0200 | [diff] [blame] | 960 | sdata->u.ibss.ssid_len = 0; |
| 961 | |
| 962 | ieee80211_recalc_idle(sdata->local); |
Johannes Berg | af8cdcd | 2009-04-19 21:25:43 +0200 | [diff] [blame] | 963 | |
| 964 | return 0; |
| 965 | } |