LinuxKPI: 802.11: implement ieee80211_get_hdrlen_from_skb()

Implement ieee80211_get_hdrlen_from_skb() doing basic sanity checks
on lengths (minimal length or skb data length vs. header length).

Sponsored by:	The FreeBSD Foundation
MFC after:	10 days
This commit is contained in:
Bjoern A. Zeeb 2022-12-31 02:02:01 +00:00
parent 13d87d92e4
commit 3391199496

View file

@ -1720,12 +1720,23 @@ ieee80211_get_channel(struct wiphy *wiphy, uint32_t freq)
return (linuxkpi_ieee80211_get_channel(wiphy, freq));
}
static __inline size_t
static inline size_t
ieee80211_get_hdrlen_from_skb(struct sk_buff *skb)
{
const struct ieee80211_hdr *hdr;
size_t len;
TODO();
return (-1);
if (skb->len < 10) /* sizeof(ieee80211_frame_[ack,cts]) */
return (0);
hdr = (const struct ieee80211_hdr *)skb->data;
len = ieee80211_hdrlen(hdr->frame_control);
/* If larger than what is in the skb return. */
if (len > skb->len)
return (0);
return (len);
}
static __inline bool