diff options
author | Benjamin Berg <benjamin.berg@intel.com> | 2023-08-27 13:05:22 +0200 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2023-09-11 12:32:16 +0200 |
commit | 5806ef25bc6e6cf0c04005ff25a4585437d567de (patch) | |
tree | 3deb27ae7164700e30721e9ca0da03eed930e461 /net/wireless/util.c | |
parent | wifi: mac80211: add an element parsing unit test (diff) | |
download | linux-5806ef25bc6e6cf0c04005ff25a4585437d567de.tar.xz linux-5806ef25bc6e6cf0c04005ff25a4585437d567de.zip |
wifi: cfg80211: add ieee80211_fragment_element to public API
This function will be used by the kunit tests within cfg80211. As it
is generally useful, move it from mac80211 to cfg80211.
Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230827135854.5af9391659f5.Ie534ed6591ba02be8572d4d7242394f29e3af04b@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/wireless/util.c')
-rw-r--r-- | net/wireless/util.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/net/wireless/util.c b/net/wireless/util.c index fff99fe43fdd..56cbd9979a3f 100644 --- a/net/wireless/util.c +++ b/net/wireless/util.c @@ -1966,6 +1966,35 @@ size_t ieee80211_ie_split_ric(const u8 *ies, size_t ielen, } EXPORT_SYMBOL(ieee80211_ie_split_ric); +void ieee80211_fragment_element(struct sk_buff *skb, u8 *len_pos, u8 frag_id) +{ + unsigned int elem_len; + + if (!len_pos) + return; + + elem_len = skb->data + skb->len - len_pos - 1; + + while (elem_len > 255) { + /* this one is 255 */ + *len_pos = 255; + /* remaining data gets smaller */ + elem_len -= 255; + /* make space for the fragment ID/len in SKB */ + skb_put(skb, 2); + /* shift back the remaining data to place fragment ID/len */ + memmove(len_pos + 255 + 3, len_pos + 255 + 1, elem_len); + /* place the fragment ID */ + len_pos += 255 + 1; + *len_pos = frag_id; + /* and point to fragment length to update later */ + len_pos++; + } + + *len_pos = elem_len; +} +EXPORT_SYMBOL(ieee80211_fragment_element); + bool ieee80211_operating_class_to_band(u8 operating_class, enum nl80211_band *band) { |