aboutsummaryrefslogtreecommitdiffstats
path: root/net/mac80211/util.c
diff options
context:
space:
mode:
authorArik Nemtsov <arik@wizery.com>2011-09-28 07:12:51 -0400
committerJohn W. Linville <linville@tuxdriver.com>2011-09-30 15:57:06 -0400
commit768db3438b4b48a33d073093bb364e624409cab7 (patch)
tree72e2d33d14484d46c16a2880df9c5d633ce7683c /net/mac80211/util.c
parent109086ce0b0f94760bdb0e8e2566ff8a2d673639 (diff)
mac80211: standardize adding supported rates IEs
Relocate the mesh implementation of adding the (extended) supported rates IE to util.c, anticipating its use by other parts of mac80211. Signed-off-by: Arik Nemtsov <arik@wizery.com> Cc: Kalyan C Gaddam <chakkal@iit.edu> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/mac80211/util.c')
-rw-r--r--net/mac80211/util.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 2c9dc360dc6d..9d4f14621bb0 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -1364,3 +1364,60 @@ void ieee80211_disable_rssi_reports(struct ieee80211_vif *vif)
1364 _ieee80211_enable_rssi_reports(sdata, 0, 0); 1364 _ieee80211_enable_rssi_reports(sdata, 0, 0);
1365} 1365}
1366EXPORT_SYMBOL(ieee80211_disable_rssi_reports); 1366EXPORT_SYMBOL(ieee80211_disable_rssi_reports);
1367
1368int ieee80211_add_srates_ie(struct ieee80211_vif *vif, struct sk_buff *skb)
1369{
1370 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
1371 struct ieee80211_local *local = sdata->local;
1372 struct ieee80211_supported_band *sband;
1373 int rate;
1374 u8 i, rates, *pos;
1375
1376 sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
1377 rates = sband->n_bitrates;
1378 if (rates > 8)
1379 rates = 8;
1380
1381 if (skb_tailroom(skb) < rates + 2)
1382 return -ENOMEM;
1383
1384 pos = skb_put(skb, rates + 2);
1385 *pos++ = WLAN_EID_SUPP_RATES;
1386 *pos++ = rates;
1387 for (i = 0; i < rates; i++) {
1388 rate = sband->bitrates[i].bitrate;
1389 *pos++ = (u8) (rate / 5);
1390 }
1391
1392 return 0;
1393}
1394
1395int ieee80211_add_ext_srates_ie(struct ieee80211_vif *vif, struct sk_buff *skb)
1396{
1397 struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
1398 struct ieee80211_local *local = sdata->local;
1399 struct ieee80211_supported_band *sband;
1400 int rate;
1401 u8 i, exrates, *pos;
1402
1403 sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
1404 exrates = sband->n_bitrates;
1405 if (exrates > 8)
1406 exrates -= 8;
1407 else
1408 exrates = 0;
1409
1410 if (skb_tailroom(skb) < exrates + 2)
1411 return -ENOMEM;
1412
1413 if (exrates) {
1414 pos = skb_put(skb, exrates + 2);
1415 *pos++ = WLAN_EID_EXT_SUPP_RATES;
1416 *pos++ = exrates;
1417 for (i = 8; i < sband->n_bitrates; i++) {
1418 rate = sband->bitrates[i].bitrate;
1419 *pos++ = (u8) (rate / 5);
1420 }
1421 }
1422 return 0;
1423}