Commit af8cdcd8 authored by Johannes Berg's avatar Johannes Berg Committed by John W. Linville

mac80211: convert to cfg80211 IBSS API

This converts mac80211 to the new cfg80211 IBSS API, the
wext handling functions are called where appropriate.
Signed-off-by: default avatarJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 04a773ad
...@@ -1283,6 +1283,21 @@ static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev, ...@@ -1283,6 +1283,21 @@ static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
return ieee80211_sta_disassociate(sdata, req->reason_code); return ieee80211_sta_disassociate(sdata, req->reason_code);
} }
static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
struct cfg80211_ibss_params *params)
{
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
return ieee80211_ibss_join(sdata, params);
}
static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
{
struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
return ieee80211_ibss_leave(sdata);
}
struct cfg80211_ops mac80211_config_ops = { struct cfg80211_ops mac80211_config_ops = {
.add_virtual_intf = ieee80211_add_iface, .add_virtual_intf = ieee80211_add_iface,
.del_virtual_intf = ieee80211_del_iface, .del_virtual_intf = ieee80211_del_iface,
...@@ -1319,4 +1334,6 @@ struct cfg80211_ops mac80211_config_ops = { ...@@ -1319,4 +1334,6 @@ struct cfg80211_ops mac80211_config_ops = {
.assoc = ieee80211_assoc, .assoc = ieee80211_assoc,
.deauth = ieee80211_deauth, .deauth = ieee80211_deauth,
.disassoc = ieee80211_disassoc, .disassoc = ieee80211_disassoc,
.join_ibss = ieee80211_join_ibss,
.leave_ibss = ieee80211_leave_ibss,
}; };
...@@ -59,74 +59,59 @@ static void ieee80211_rx_mgmt_auth_ibss(struct ieee80211_sub_if_data *sdata, ...@@ -59,74 +59,59 @@ static void ieee80211_rx_mgmt_auth_ibss(struct ieee80211_sub_if_data *sdata,
sdata->u.ibss.bssid, 0); sdata->u.ibss.bssid, 0);
} }
static int __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, static void __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
const u8 *bssid, const int beacon_int, const u8 *bssid, const int beacon_int,
const int freq, struct ieee80211_channel *chan,
const size_t supp_rates_len, const size_t supp_rates_len,
const u8 *supp_rates, const u8 *supp_rates,
const u16 capability, u64 tsf) const u16 capability, u64 tsf)
{ {
struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
struct ieee80211_local *local = sdata->local; struct ieee80211_local *local = sdata->local;
int res = 0, rates, i, j; int rates, i, j;
struct sk_buff *skb; struct sk_buff *skb;
struct ieee80211_mgmt *mgmt; struct ieee80211_mgmt *mgmt;
u8 *pos; u8 *pos;
struct ieee80211_supported_band *sband; struct ieee80211_supported_band *sband;
union iwreq_data wrqu;
if (local->ops->reset_tsf) { if (local->ops->reset_tsf) {
/* Reset own TSF to allow time synchronization work. */ /* Reset own TSF to allow time synchronization work. */
local->ops->reset_tsf(local_to_hw(local)); local->ops->reset_tsf(local_to_hw(local));
} }
if ((ifibss->flags & IEEE80211_IBSS_PREV_BSSID_SET) && skb = ifibss->skb;
memcmp(ifibss->bssid, bssid, ETH_ALEN) == 0) rcu_assign_pointer(ifibss->presp, NULL);
return res; synchronize_rcu();
skb->data = skb->head;
skb->len = 0;
skb_reset_tail_pointer(skb);
skb_reserve(skb, sdata->local->hw.extra_tx_headroom);
skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400); if (memcmp(ifibss->bssid, bssid, ETH_ALEN))
if (!skb) { sta_info_flush(sdata->local, sdata);
printk(KERN_DEBUG "%s: failed to allocate buffer for probe "
"response\n", sdata->dev->name);
return -ENOMEM;
}
if (!(ifibss->flags & IEEE80211_IBSS_PREV_BSSID_SET)) {
/* Remove possible STA entries from other IBSS networks. */
sta_info_flush_delayed(sdata);
}
memcpy(ifibss->bssid, bssid, ETH_ALEN); memcpy(ifibss->bssid, bssid, ETH_ALEN);
res = ieee80211_if_config(sdata, IEEE80211_IFCC_BSSID);
if (res)
return res;
local->hw.conf.beacon_int = beacon_int >= 10 ? beacon_int : 10; local->hw.conf.beacon_int = beacon_int >= 10 ? beacon_int : 10;
sdata->drop_unencrypted = capability & sdata->drop_unencrypted = capability & WLAN_CAPABILITY_PRIVACY ? 1 : 0;
WLAN_CAPABILITY_PRIVACY ? 1 : 0;
res = ieee80211_set_freq(sdata, freq);
if (res) ieee80211_if_config(sdata, IEEE80211_IFCC_BSSID);
return res;
sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; local->oper_channel = chan;
local->oper_channel_type = NL80211_CHAN_NO_HT;
ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
sband = local->hw.wiphy->bands[chan->band];
/* Build IBSS probe response */ /* Build IBSS probe response */
mgmt = (void *) skb_put(skb, 24 + sizeof(mgmt->u.beacon));
skb_reserve(skb, local->hw.extra_tx_headroom);
mgmt = (struct ieee80211_mgmt *)
skb_put(skb, 24 + sizeof(mgmt->u.beacon));
memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon)); memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon));
mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
IEEE80211_STYPE_PROBE_RESP); IEEE80211_STYPE_PROBE_RESP);
memset(mgmt->da, 0xff, ETH_ALEN); memset(mgmt->da, 0xff, ETH_ALEN);
memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN);
memcpy(mgmt->bssid, ifibss->bssid, ETH_ALEN); memcpy(mgmt->bssid, ifibss->bssid, ETH_ALEN);
mgmt->u.beacon.beacon_int = mgmt->u.beacon.beacon_int = cpu_to_le16(local->hw.conf.beacon_int);
cpu_to_le16(local->hw.conf.beacon_int);
mgmt->u.beacon.timestamp = cpu_to_le64(tsf); mgmt->u.beacon.timestamp = cpu_to_le64(tsf);
mgmt->u.beacon.capab_info = cpu_to_le16(capability); mgmt->u.beacon.capab_info = cpu_to_le16(capability);
...@@ -147,7 +132,7 @@ static int __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, ...@@ -147,7 +132,7 @@ static int __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
pos = skb_put(skb, 2 + 1); pos = skb_put(skb, 2 + 1);
*pos++ = WLAN_EID_DS_PARAMS; *pos++ = WLAN_EID_DS_PARAMS;
*pos++ = 1; *pos++ = 1;
*pos++ = ieee80211_frequency_to_channel(freq); *pos++ = ieee80211_frequency_to_channel(chan->center_freq);
} }
pos = skb_put(skb, 2 + 2); pos = skb_put(skb, 2 + 2);
...@@ -165,12 +150,15 @@ static int __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, ...@@ -165,12 +150,15 @@ static int __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
memcpy(pos, &supp_rates[8], rates); memcpy(pos, &supp_rates[8], rates);
} }
ifibss->probe_resp = skb; if (ifibss->ie_len)
memcpy(skb_put(skb, ifibss->ie_len),
ifibss->ie, ifibss->ie_len);
rcu_assign_pointer(ifibss->presp, skb);
ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON | ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON |
IEEE80211_IFCC_BEACON_ENABLED); IEEE80211_IFCC_BEACON_ENABLED);
rates = 0; rates = 0;
for (i = 0; i < supp_rates_len; i++) { for (i = 0; i < supp_rates_len; i++) {
int bitrate = (supp_rates[i] & 0x7f) * 5; int bitrate = (supp_rates[i] & 0x7f) * 5;
...@@ -181,27 +169,24 @@ static int __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, ...@@ -181,27 +169,24 @@ static int __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
ieee80211_sta_def_wmm_params(sdata, supp_rates_len, supp_rates); ieee80211_sta_def_wmm_params(sdata, supp_rates_len, supp_rates);
ifibss->flags |= IEEE80211_IBSS_PREV_BSSID_SET;
ifibss->state = IEEE80211_IBSS_MLME_JOINED; ifibss->state = IEEE80211_IBSS_MLME_JOINED;
mod_timer(&ifibss->timer, jiffies + IEEE80211_IBSS_MERGE_INTERVAL); mod_timer(&ifibss->timer,
round_jiffies(jiffies + IEEE80211_IBSS_MERGE_INTERVAL));
memset(&wrqu, 0, sizeof(wrqu)); cfg80211_inform_bss_frame(local->hw.wiphy, local->hw.conf.channel,
memcpy(wrqu.ap_addr.sa_data, bssid, ETH_ALEN); mgmt, skb->len, 0, GFP_KERNEL);
wireless_send_event(sdata->dev, SIOCGIWAP, &wrqu, NULL); cfg80211_ibss_joined(sdata->dev, ifibss->bssid, GFP_KERNEL);
return res;
} }
static int ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, static void ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
struct ieee80211_bss *bss) struct ieee80211_bss *bss)
{ {
return __ieee80211_sta_join_ibss(sdata, __ieee80211_sta_join_ibss(sdata, bss->cbss.bssid,
bss->cbss.bssid, bss->cbss.beacon_interval,
bss->cbss.beacon_interval, bss->cbss.channel,
bss->cbss.channel->center_freq, bss->supp_rates_len, bss->supp_rates,
bss->supp_rates_len, bss->supp_rates, bss->cbss.capability,
bss->cbss.capability, bss->cbss.tsf);
bss->cbss.tsf);
} }
static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
...@@ -277,7 +262,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, ...@@ -277,7 +262,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
goto put_bss; goto put_bss;
/* we use a fixed BSSID */ /* we use a fixed BSSID */
if (sdata->u.ibss.flags & IEEE80211_IBSS_BSSID_SET) if (sdata->u.ibss.bssid)
goto put_bss; goto put_bss;
/* not an IBSS */ /* not an IBSS */
...@@ -369,13 +354,14 @@ struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, ...@@ -369,13 +354,14 @@ struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,
struct sta_info *sta; struct sta_info *sta;
int band = local->hw.conf.channel->band; int band = local->hw.conf.channel->band;
/* TODO: Could consider removing the least recently used entry and /*
* allow new one to be added. */ * XXX: Consider removing the least recently used entry and
* allow new one to be added.
*/
if (local->num_sta >= IEEE80211_IBSS_MAX_STA_ENTRIES) { if (local->num_sta >= IEEE80211_IBSS_MAX_STA_ENTRIES) {
if (net_ratelimit()) { if (net_ratelimit())
printk(KERN_DEBUG "%s: No room for a new IBSS STA " printk(KERN_DEBUG "%s: No room for a new IBSS STA entry %pM\n",
"entry %pM\n", sdata->dev->name, addr); sdata->dev->name, addr);
}
return NULL; return NULL;
} }
...@@ -432,14 +418,15 @@ static void ieee80211_sta_merge_ibss(struct ieee80211_sub_if_data *sdata) ...@@ -432,14 +418,15 @@ static void ieee80211_sta_merge_ibss(struct ieee80211_sub_if_data *sdata)
{ {
struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
mod_timer(&ifibss->timer, jiffies + IEEE80211_IBSS_MERGE_INTERVAL); mod_timer(&ifibss->timer,
round_jiffies(jiffies + IEEE80211_IBSS_MERGE_INTERVAL));
ieee80211_sta_expire(sdata, IEEE80211_IBSS_INACTIVITY_LIMIT); ieee80211_sta_expire(sdata, IEEE80211_IBSS_INACTIVITY_LIMIT);
if (ieee80211_sta_active_ibss(sdata)) if (ieee80211_sta_active_ibss(sdata))
return; return;
if ((ifibss->flags & IEEE80211_IBSS_BSSID_SET) && if (ifibss->fixed_channel)
(!(ifibss->flags & IEEE80211_IBSS_AUTO_CHANNEL_SEL)))
return; return;
printk(KERN_DEBUG "%s: No active IBSS STAs - trying to scan for other " printk(KERN_DEBUG "%s: No active IBSS STAs - trying to scan for other "
...@@ -455,7 +442,7 @@ static void ieee80211_sta_merge_ibss(struct ieee80211_sub_if_data *sdata) ...@@ -455,7 +442,7 @@ static void ieee80211_sta_merge_ibss(struct ieee80211_sub_if_data *sdata)
ieee80211_request_scan(sdata, &sdata->local->int_scan_req); ieee80211_request_scan(sdata, &sdata->local->int_scan_req);
} }
static int ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata) static void ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata)
{ {
struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
struct ieee80211_local *local = sdata->local; struct ieee80211_local *local = sdata->local;
...@@ -466,7 +453,7 @@ static int ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata) ...@@ -466,7 +453,7 @@ static int ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata)
u16 capability; u16 capability;
int i; int i;
if (ifibss->flags & IEEE80211_IBSS_BSSID_SET) { if (ifibss->fixed_bssid) {
memcpy(bssid, ifibss->bssid, ETH_ALEN); memcpy(bssid, ifibss->bssid, ETH_ALEN);
} else { } else {
/* Generate random, not broadcast, locally administered BSSID. Mix in /* Generate random, not broadcast, locally administered BSSID. Mix in
...@@ -482,7 +469,7 @@ static int ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata) ...@@ -482,7 +469,7 @@ static int ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata)
printk(KERN_DEBUG "%s: Creating new IBSS network, BSSID %pM\n", printk(KERN_DEBUG "%s: Creating new IBSS network, BSSID %pM\n",
sdata->dev->name, bssid); sdata->dev->name, bssid);
sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; sband = local->hw.wiphy->bands[ifibss->channel->band];
if (local->hw.conf.beacon_int == 0) if (local->hw.conf.beacon_int == 0)
local->hw.conf.beacon_int = 100; local->hw.conf.beacon_int = 100;
...@@ -500,24 +487,20 @@ static int ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata) ...@@ -500,24 +487,20 @@ static int ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata)
*pos++ = (u8) (rate / 5); *pos++ = (u8) (rate / 5);
} }
return __ieee80211_sta_join_ibss(sdata, __ieee80211_sta_join_ibss(sdata, bssid, local->hw.conf.beacon_int,
bssid, local->hw.conf.beacon_int, ifibss->channel, sband->n_bitrates,
local->hw.conf.channel->center_freq, supp_rates, capability, 0);
sband->n_bitrates, supp_rates,
capability, 0);
} }
static int ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata) static void ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata)
{ {
struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
struct ieee80211_local *local = sdata->local; struct ieee80211_local *local = sdata->local;
struct ieee80211_bss *bss; struct ieee80211_bss *bss;
struct ieee80211_channel *chan = NULL;
const u8 *bssid = NULL; const u8 *bssid = NULL;
int active_ibss; int active_ibss;
if (ifibss->ssid_len == 0)
return -EINVAL;
active_ibss = ieee80211_sta_active_ibss(sdata); active_ibss = ieee80211_sta_active_ibss(sdata);
#ifdef CONFIG_MAC80211_IBSS_DEBUG #ifdef CONFIG_MAC80211_IBSS_DEBUG
printk(KERN_DEBUG "%s: sta_find_ibss (active_ibss=%d)\n", printk(KERN_DEBUG "%s: sta_find_ibss (active_ibss=%d)\n",
...@@ -525,11 +508,15 @@ static int ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata) ...@@ -525,11 +508,15 @@ static int ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata)
#endif /* CONFIG_MAC80211_IBSS_DEBUG */ #endif /* CONFIG_MAC80211_IBSS_DEBUG */
if (active_ibss) if (active_ibss)
return 0; return;
if (ifibss->flags & IEEE80211_IBSS_BSSID_SET) if (ifibss->fixed_bssid)
bssid = ifibss->bssid;
if (ifibss->fixed_channel)
chan = ifibss->channel;
if (!is_zero_ether_addr(ifibss->bssid))
bssid = ifibss->bssid; bssid = ifibss->bssid;
bss = (void *)cfg80211_get_bss(local->hw.wiphy, NULL, bssid, bss = (void *)cfg80211_get_bss(local->hw.wiphy, chan, bssid,
ifibss->ssid, ifibss->ssid_len, ifibss->ssid, ifibss->ssid_len,
WLAN_CAPABILITY_IBSS, WLAN_CAPABILITY_IBSS,
WLAN_CAPABILITY_IBSS); WLAN_CAPABILITY_IBSS);
...@@ -540,18 +527,14 @@ static int ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata) ...@@ -540,18 +527,14 @@ static int ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata)
"%pM\n", bss->cbss.bssid, ifibss->bssid); "%pM\n", bss->cbss.bssid, ifibss->bssid);
#endif /* CONFIG_MAC80211_IBSS_DEBUG */ #endif /* CONFIG_MAC80211_IBSS_DEBUG */
if (bss && if (bss && memcmp(ifibss->bssid, bss->cbss.bssid, ETH_ALEN)) {
(!(ifibss->flags & IEEE80211_IBSS_PREV_BSSID_SET) ||
memcmp(ifibss->bssid, bss->cbss.bssid, ETH_ALEN))) {
int ret;
printk(KERN_DEBUG "%s: Selected IBSS BSSID %pM" printk(KERN_DEBUG "%s: Selected IBSS BSSID %pM"
" based on configured SSID\n", " based on configured SSID\n",
sdata->dev->name, bss->cbss.bssid); sdata->dev->name, bss->cbss.bssid);
ret = ieee80211_sta_join_ibss(sdata, bss); ieee80211_sta_join_ibss(sdata, bss);
ieee80211_rx_bss_put(local, bss); ieee80211_rx_bss_put(local, bss);
return ret; return;
} else if (bss) } else if (bss)
ieee80211_rx_bss_put(local, bss); ieee80211_rx_bss_put(local, bss);
...@@ -562,29 +545,31 @@ static int ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata) ...@@ -562,29 +545,31 @@ static int ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata)
/* Selected IBSS not found in current scan results - try to scan */ /* Selected IBSS not found in current scan results - try to scan */
if (ifibss->state == IEEE80211_IBSS_MLME_JOINED && if (ifibss->state == IEEE80211_IBSS_MLME_JOINED &&
!ieee80211_sta_active_ibss(sdata)) { !ieee80211_sta_active_ibss(sdata)) {
mod_timer(&ifibss->timer, jiffies + mod_timer(&ifibss->timer,
IEEE80211_IBSS_MERGE_INTERVAL); round_jiffies(jiffies + IEEE80211_IBSS_MERGE_INTERVAL));
} else if (time_after(jiffies, local->last_scan_completed + } else if (time_after(jiffies, ifibss->last_scan_completed +
IEEE80211_SCAN_INTERVAL)) { IEEE80211_SCAN_INTERVAL)) {
printk(KERN_DEBUG "%s: Trigger new scan to find an IBSS to " printk(KERN_DEBUG "%s: Trigger new scan to find an IBSS to "
"join\n", sdata->dev->name); "join\n", sdata->dev->name);
/* XXX maybe racy? */ /* XXX maybe racy? */
if (local->scan_req) if (local->scan_req)
return -EBUSY; return;
memcpy(local->int_scan_req.ssids[0].ssid, memcpy(local->int_scan_req.ssids[0].ssid,
ifibss->ssid, IEEE80211_MAX_SSID_LEN); ifibss->ssid, IEEE80211_MAX_SSID_LEN);
local->int_scan_req.ssids[0].ssid_len = ifibss->ssid_len; local->int_scan_req.ssids[0].ssid_len =
return ieee80211_request_scan(sdata, &local->int_scan_req); ifibss->ssid_len;
ieee80211_request_scan(sdata, &local->int_scan_req);
} else if (ifibss->state != IEEE80211_IBSS_MLME_JOINED) { } else if (ifibss->state != IEEE80211_IBSS_MLME_JOINED) {
int interval = IEEE80211_SCAN_INTERVAL; int interval = IEEE80211_SCAN_INTERVAL;
if (time_after(jiffies, ifibss->ibss_join_req + if (time_after(jiffies, ifibss->ibss_join_req +
IEEE80211_IBSS_JOIN_TIMEOUT)) { IEEE80211_IBSS_JOIN_TIMEOUT)) {
if (!(local->oper_channel->flags & if (!(local->oper_channel->flags & IEEE80211_CHAN_NO_IBSS)) {
IEEE80211_CHAN_NO_IBSS)) ieee80211_sta_create_ibss(sdata);
return ieee80211_sta_create_ibss(sdata); return;
}
printk(KERN_DEBUG "%s: IBSS not allowed on" printk(KERN_DEBUG "%s: IBSS not allowed on"
" %d MHz\n", sdata->dev->name, " %d MHz\n", sdata->dev->name,
local->hw.conf.channel->center_freq); local->hw.conf.channel->center_freq);
...@@ -595,11 +580,9 @@ static int ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata) ...@@ -595,11 +580,9 @@ static int ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata)
} }
ifibss->state = IEEE80211_IBSS_MLME_SEARCH; ifibss->state = IEEE80211_IBSS_MLME_SEARCH;
mod_timer(&ifibss->timer, jiffies + interval); mod_timer(&ifibss->timer,
return 0; round_jiffies(jiffies + interval));
} }
return 0;
} }
static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata, static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata,
...@@ -614,7 +597,7 @@ static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata, ...@@ -614,7 +597,7 @@ static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata,
u8 *pos, *end; u8 *pos, *end;
if (ifibss->state != IEEE80211_IBSS_MLME_JOINED || if (ifibss->state != IEEE80211_IBSS_MLME_JOINED ||
len < 24 + 2 || !ifibss->probe_resp) len < 24 + 2 || !ifibss->presp)
return; return;
if (local->ops->tx_last_beacon) if (local->ops->tx_last_beacon)
...@@ -649,13 +632,13 @@ static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata, ...@@ -649,13 +632,13 @@ static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata,
} }
if (pos[1] != 0 && if (pos[1] != 0 &&
(pos[1] != ifibss->ssid_len || (pos[1] != ifibss->ssid_len ||
memcmp(pos + 2, ifibss->ssid, ifibss->ssid_len) != 0)) { !memcmp(pos + 2, ifibss->ssid, ifibss->ssid_len))) {
/* Ignore ProbeReq for foreign SSID */ /* Ignore ProbeReq for foreign SSID */
return; return;
} }
/* Reply with ProbeResp */ /* Reply with ProbeResp */
skb = skb_copy(ifibss->probe_resp, GFP_KERNEL); skb = skb_copy(ifibss->presp, GFP_KERNEL);
if (!skb) if (!skb)
return; return;
...@@ -794,89 +777,21 @@ void ieee80211_ibss_setup_sdata(struct ieee80211_sub_if_data *sdata) ...@@ -794,89 +777,21 @@ void ieee80211_ibss_setup_sdata(struct ieee80211_sub_if_data *sdata)
setup_timer(&ifibss->timer, ieee80211_ibss_timer, setup_timer(&ifibss->timer, ieee80211_ibss_timer,
(unsigned long) sdata); (unsigned long) sdata);
skb_queue_head_init(&ifibss->skb_queue); skb_queue_head_init(&ifibss->skb_queue);
ifibss->flags |= IEEE80211_IBSS_AUTO_BSSID_SEL |
IEEE80211_IBSS_AUTO_CHANNEL_SEL;
}
int ieee80211_ibss_commit(struct ieee80211_sub_if_data *sdata)
{
struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
ifibss->flags &= ~IEEE80211_IBSS_PREV_BSSID_SET;
if (ifibss->ssid_len)
ifibss->flags |= IEEE80211_IBSS_SSID_SET;
else
ifibss->flags &= ~IEEE80211_IBSS_SSID_SET;
ifibss->ibss_join_req = jiffies;
ifibss->state = IEEE80211_IBSS_MLME_SEARCH;
set_bit(IEEE80211_IBSS_REQ_RUN, &ifibss->request);
return 0;
}
int ieee80211_ibss_set_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size_t len)
{
struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
if (len > IEEE80211_MAX_SSID_LEN)
return -EINVAL;
if (ifibss->ssid_len != len || memcmp(ifibss->ssid, ssid, len) != 0) {
memset(ifibss->ssid, 0, sizeof(ifibss->ssid));
memcpy(ifibss->ssid, ssid, len);
ifibss->ssid_len = len;
}
return ieee80211_ibss_commit(sdata);
}
int ieee80211_ibss_get_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size_t *len)
{
struct ieee80211_if_ibss *ifibss = &sdata->u.ibss;
memcpy(ssid, ifibss->ssid, ifibss->ssid_len);
*len = ifibss->ssid_len;
return 0;
}
int ieee80211_ibss_set_bssid(struct ieee80211_sub_if_data *sdata, u8 *bssid)