The branch main has been updated by bz:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=339119949660916aa40b1d67dbe002dd7eb0d709

commit 339119949660916aa40b1d67dbe002dd7eb0d709
Author:     Bjoern A. Zeeb <[email protected]>
AuthorDate: 2022-12-31 02:02:01 +0000
Commit:     Bjoern A. Zeeb <[email protected]>
CommitDate: 2022-12-31 02:02:01 +0000

    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
---
 sys/compat/linuxkpi/common/include/net/cfg80211.h | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/sys/compat/linuxkpi/common/include/net/cfg80211.h 
b/sys/compat/linuxkpi/common/include/net/cfg80211.h
index ce2cdb3327f8..55a74227a338 100644
--- a/sys/compat/linuxkpi/common/include/net/cfg80211.h
+++ b/sys/compat/linuxkpi/common/include/net/cfg80211.h
@@ -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

Reply via email to