aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2015-03-31 09:36:22 -0400
committerJohannes Berg <johannes.berg@intel.com>2015-04-07 07:56:41 -0400
commit29464ccc78f1e8f77b8c37ddbe95af46d13c2ec2 (patch)
treef5cc33762959fb5346b111e4123160a928691e90
parentba8c3d6f16a1f9305c23ac1d2fd3992508c5ac03 (diff)
cfg80211: move IE split utilities here from mac80211
As the next patch will require the IE splitting utility functions in cfg80211, move them there from mac80211. Signed-off-by: Johannes Berg <johannes.berg@intel.com>
-rw-r--r--include/net/cfg80211.h58
-rw-r--r--include/net/mac80211.h28
-rw-r--r--net/mac80211/ieee80211_i.h4
-rw-r--r--net/mac80211/util.c40
-rw-r--r--net/wireless/util.c41
5 files changed, 99 insertions, 72 deletions
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 441306436569..f8d6813cd5b2 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -5001,6 +5001,64 @@ int cfg80211_get_p2p_attr(const u8 *ies, unsigned int len,
5001 u8 *buf, unsigned int bufsize); 5001 u8 *buf, unsigned int bufsize);
5002 5002
5003/** 5003/**
5004 * ieee80211_ie_split_ric - split an IE buffer according to ordering (with RIC)
5005 * @ies: the IE buffer
5006 * @ielen: the length of the IE buffer
5007 * @ids: an array with element IDs that are allowed before
5008 * the split
5009 * @n_ids: the size of the element ID array
5010 * @after_ric: array IE types that come after the RIC element
5011 * @n_after_ric: size of the @after_ric array
5012 * @offset: offset where to start splitting in the buffer
5013 *
5014 * This function splits an IE buffer by updating the @offset
5015 * variable to point to the location where the buffer should be
5016 * split.
5017 *
5018 * It assumes that the given IE buffer is well-formed, this
5019 * has to be guaranteed by the caller!
5020 *
5021 * It also assumes that the IEs in the buffer are ordered
5022 * correctly, if not the result of using this function will not
5023 * be ordered correctly either, i.e. it does no reordering.
5024 *
5025 * The function returns the offset where the next part of the
5026 * buffer starts, which may be @ielen if the entire (remainder)
5027 * of the buffer should be used.
5028 */
5029size_t ieee80211_ie_split_ric(const u8 *ies, size_t ielen,
5030 const u8 *ids, int n_ids,
5031 const u8 *after_ric, int n_after_ric,
5032 size_t offset);
5033
5034/**
5035 * ieee80211_ie_split - split an IE buffer according to ordering
5036 * @ies: the IE buffer
5037 * @ielen: the length of the IE buffer
5038 * @ids: an array with element IDs that are allowed before
5039 * the split
5040 * @n_ids: the size of the element ID array
5041 * @offset: offset where to start splitting in the buffer
5042 *
5043 * This function splits an IE buffer by updating the @offset
5044 * variable to point to the location where the buffer should be
5045 * split.
5046 *
5047 * It assumes that the given IE buffer is well-formed, this
5048 * has to be guaranteed by the caller!
5049 *
5050 * It also assumes that the IEs in the buffer are ordered
5051 * correctly, if not the result of using this function will not
5052 * be ordered correctly either, i.e. it does no reordering.
5053 *
5054 * The function returns the offset where the next part of the
5055 * buffer starts, which may be @ielen if the entire (remainder)
5056 * of the buffer should be used.
5057 */
5058size_t ieee80211_ie_split(const u8 *ies, size_t ielen,
5059 const u8 *ids, int n_ids, size_t offset);
5060
5061/**
5004 * cfg80211_report_wowlan_wakeup - report wakeup from WoWLAN 5062 * cfg80211_report_wowlan_wakeup - report wakeup from WoWLAN
5005 * @wdev: the wireless device reporting the wakeup 5063 * @wdev: the wireless device reporting the wakeup
5006 * @wakeup: the wakeup report 5064 * @wakeup: the wakeup report
diff --git a/include/net/mac80211.h b/include/net/mac80211.h
index 3578da96b41a..b4bef1152c05 100644
--- a/include/net/mac80211.h
+++ b/include/net/mac80211.h
@@ -5380,34 +5380,6 @@ int ieee80211_reserve_tid(struct ieee80211_sta *sta, u8 tid);
5380void ieee80211_unreserve_tid(struct ieee80211_sta *sta, u8 tid); 5380void ieee80211_unreserve_tid(struct ieee80211_sta *sta, u8 tid);
5381 5381
5382/** 5382/**
5383 * ieee80211_ie_split - split an IE buffer according to ordering
5384 *
5385 * @ies: the IE buffer
5386 * @ielen: the length of the IE buffer
5387 * @ids: an array with element IDs that are allowed before
5388 * the split
5389 * @n_ids: the size of the element ID array
5390 * @offset: offset where to start splitting in the buffer
5391 *
5392 * This function splits an IE buffer by updating the @offset
5393 * variable to point to the location where the buffer should be
5394 * split.
5395 *
5396 * It assumes that the given IE buffer is well-formed, this
5397 * has to be guaranteed by the caller!
5398 *
5399 * It also assumes that the IEs in the buffer are ordered
5400 * correctly, if not the result of using this function will not
5401 * be ordered correctly either, i.e. it does no reordering.
5402 *
5403 * The function returns the offset where the next part of the
5404 * buffer starts, which may be @ielen if the entire (remainder)
5405 * of the buffer should be used.
5406 */
5407size_t ieee80211_ie_split(const u8 *ies, size_t ielen,
5408 const u8 *ids, int n_ids, size_t offset);
5409
5410/**
5411 * ieee80211_tx_dequeue - dequeue a packet from a software tx queue 5383 * ieee80211_tx_dequeue - dequeue a packet from a software tx queue
5412 * 5384 *
5413 * @hw: pointer as obtained from ieee80211_alloc_hw() 5385 * @hw: pointer as obtained from ieee80211_alloc_hw()
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 04b32f3e0395..ab46ab4a7249 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -1965,10 +1965,6 @@ int __ieee80211_request_smps_ap(struct ieee80211_sub_if_data *sdata,
1965void ieee80211_recalc_smps(struct ieee80211_sub_if_data *sdata); 1965void ieee80211_recalc_smps(struct ieee80211_sub_if_data *sdata);
1966void ieee80211_recalc_min_chandef(struct ieee80211_sub_if_data *sdata); 1966void ieee80211_recalc_min_chandef(struct ieee80211_sub_if_data *sdata);
1967 1967
1968size_t ieee80211_ie_split_ric(const u8 *ies, size_t ielen,
1969 const u8 *ids, int n_ids,
1970 const u8 *after_ric, int n_after_ric,
1971 size_t offset);
1972size_t ieee80211_ie_split_vendor(const u8 *ies, size_t ielen, size_t offset); 1968size_t ieee80211_ie_split_vendor(const u8 *ies, size_t ielen, size_t offset);
1973u8 *ieee80211_ie_build_ht_cap(u8 *pos, struct ieee80211_sta_ht_cap *ht_cap, 1969u8 *ieee80211_ie_build_ht_cap(u8 *pos, struct ieee80211_sta_ht_cap *ht_cap,
1974 u16 cap); 1970 u16 cap);
diff --git a/net/mac80211/util.c b/net/mac80211/util.c
index 482b85c19a36..79412f16b61d 100644
--- a/net/mac80211/util.c
+++ b/net/mac80211/util.c
@@ -2194,46 +2194,6 @@ void ieee80211_recalc_min_chandef(struct ieee80211_sub_if_data *sdata)
2194 mutex_unlock(&local->chanctx_mtx); 2194 mutex_unlock(&local->chanctx_mtx);
2195} 2195}
2196 2196
2197static bool ieee80211_id_in_list(const u8 *ids, int n_ids, u8 id)
2198{
2199 int i;
2200
2201 for (i = 0; i < n_ids; i++)
2202 if (ids[i] == id)
2203 return true;
2204 return false;
2205}
2206
2207size_t ieee80211_ie_split_ric(const u8 *ies, size_t ielen,
2208 const u8 *ids, int n_ids,
2209 const u8 *after_ric, int n_after_ric,
2210 size_t offset)
2211{
2212 size_t pos = offset;
2213
2214 while (pos < ielen && ieee80211_id_in_list(ids, n_ids, ies[pos])) {
2215 if (ies[pos] == WLAN_EID_RIC_DATA && n_after_ric) {
2216 pos += 2 + ies[pos + 1];
2217
2218 while (pos < ielen &&
2219 !ieee80211_id_in_list(after_ric, n_after_ric,
2220 ies[pos]))
2221 pos += 2 + ies[pos + 1];
2222 } else {
2223 pos += 2 + ies[pos + 1];
2224 }
2225 }
2226
2227 return pos;
2228}
2229
2230size_t ieee80211_ie_split(const u8 *ies, size_t ielen,
2231 const u8 *ids, int n_ids, size_t offset)
2232{
2233 return ieee80211_ie_split_ric(ies, ielen, ids, n_ids, NULL, 0, offset);
2234}
2235EXPORT_SYMBOL(ieee80211_ie_split);
2236
2237size_t ieee80211_ie_split_vendor(const u8 *ies, size_t ielen, size_t offset) 2197size_t ieee80211_ie_split_vendor(const u8 *ies, size_t ielen, size_t offset)
2238{ 2198{
2239 size_t pos = offset; 2199 size_t pos = offset;
diff --git a/net/wireless/util.c b/net/wireless/util.c
index f218b151530a..70051ab52f4f 100644
--- a/net/wireless/util.c
+++ b/net/wireless/util.c
@@ -1290,6 +1290,47 @@ int cfg80211_get_p2p_attr(const u8 *ies, unsigned int len,
1290} 1290}
1291EXPORT_SYMBOL(cfg80211_get_p2p_attr); 1291EXPORT_SYMBOL(cfg80211_get_p2p_attr);
1292 1292
1293static bool ieee80211_id_in_list(const u8 *ids, int n_ids, u8 id)
1294{
1295 int i;
1296
1297 for (i = 0; i < n_ids; i++)
1298 if (ids[i] == id)
1299 return true;
1300 return false;
1301}
1302
1303size_t ieee80211_ie_split_ric(const u8 *ies, size_t ielen,
1304 const u8 *ids, int n_ids,
1305 const u8 *after_ric, int n_after_ric,
1306 size_t offset)
1307{
1308 size_t pos = offset;
1309
1310 while (pos < ielen && ieee80211_id_in_list(ids, n_ids, ies[pos])) {
1311 if (ies[pos] == WLAN_EID_RIC_DATA && n_after_ric) {
1312 pos += 2 + ies[pos + 1];
1313
1314 while (pos < ielen &&
1315 !ieee80211_id_in_list(after_ric, n_after_ric,
1316 ies[pos]))
1317 pos += 2 + ies[pos + 1];
1318 } else {
1319 pos += 2 + ies[pos + 1];
1320 }
1321 }
1322
1323 return pos;
1324}
1325EXPORT_SYMBOL(ieee80211_ie_split_ric);
1326
1327size_t ieee80211_ie_split(const u8 *ies, size_t ielen,
1328 const u8 *ids, int n_ids, size_t offset)
1329{
1330 return ieee80211_ie_split_ric(ies, ielen, ids, n_ids, NULL, 0, offset);
1331}
1332EXPORT_SYMBOL(ieee80211_ie_split);
1333
1293bool ieee80211_operating_class_to_band(u8 operating_class, 1334bool ieee80211_operating_class_to_band(u8 operating_class,
1294 enum ieee80211_band *band) 1335 enum ieee80211_band *band)
1295{ 1336{