From 83e6bc999053beb4fac9cca316ef40fc42c9d2a8 Mon Sep 17 00:00:00 2001 From: sam Date: Fri, 31 Dec 2004 20:56:32 +0000 Subject: add ieee80211_hdrspace and ieee80211_anyhdrspace to calculate the space for an ieee80211 header taking into account padding requirements --- sys/net80211/ieee80211_var.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'sys/net80211/ieee80211_var.h') diff --git a/sys/net80211/ieee80211_var.h b/sys/net80211/ieee80211_var.h index ad98613..372452f 100644 --- a/sys/net80211/ieee80211_var.h +++ b/sys/net80211/ieee80211_var.h @@ -282,6 +282,36 @@ ieee80211_key_update_end(struct ieee80211com *ic) ic->ic_crypto.cs_key_update_end(ic); } +/* + * XXX these need to be here for IEEE80211_F_DATAPAD + */ + +/* + * Return the space occupied by the 802.11 header and any + * padding required by the driver. This works for a + * management or data frame. + */ +static __inline int +ieee80211_hdrspace(struct ieee80211com *ic, const void *data) +{ + int size = ieee80211_hdrsize(data); + if (ic->ic_flags & IEEE80211_F_DATAPAD) + size = roundup(size, sizeof(u_int32_t)); + return size; +} + +/* + * Like ieee80211_hdrspace, but handles any type of frame. + */ +static __inline int +ieee80211_anyhdrspace(struct ieee80211com *ic, const void *data) +{ + int size = ieee80211_anyhdrsize(data); + if (ic->ic_flags & IEEE80211_F_DATAPAD) + size = roundup(size, sizeof(u_int32_t)); + return size; +} + #define IEEE80211_MSG_DEBUG 0x40000000 /* IFF_DEBUG equivalent */ #define IEEE80211_MSG_DUMPPKTS 0x20000000 /* IFF_LINK2 equivalant */ #define IEEE80211_MSG_CRYPTO 0x10000000 /* crypto work */ -- cgit v1.1