From: Purushottam Kushwaha Date: Tue, 28 Mar 2023 12:09:59 +0000 (+0530) Subject: Add support for conversion to little endian for 24 bits X-Git-Tag: hostap_2_11~1012 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=12154861e24adb08db26aefd884c0f9d650287df;p=thirdparty%2Fhostap.git Add support for conversion to little endian for 24 bits Like le16/le32, add support for conversion to le24. Signed-off-by: Purushottam Kushwaha --- diff --git a/src/utils/common.h b/src/utils/common.h index 435a9a84c..bede21e57 100644 --- a/src/utils/common.h +++ b/src/utils/common.h @@ -244,6 +244,18 @@ static inline void WPA_PUT_BE24(u8 *a, u32 val) a[2] = val & 0xff; } +static inline u32 WPA_GET_LE24(const u8 *a) +{ + return (a[2] << 16) | (a[1] << 8) | a[0]; +} + +static inline void WPA_PUT_LE24(u8 *a, u32 val) +{ + a[2] = (val >> 16) & 0xff; + a[1] = (val >> 8) & 0xff; + a[0] = val & 0xff; +} + static inline u32 WPA_GET_BE32(const u8 *a) { return ((u32) a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3]; diff --git a/src/utils/wpabuf.h b/src/utils/wpabuf.h index eb1db8091..88d72bd68 100644 --- a/src/utils/wpabuf.h +++ b/src/utils/wpabuf.h @@ -127,6 +127,12 @@ static inline void wpabuf_put_le16(struct wpabuf *buf, u16 data) WPA_PUT_LE16(pos, data); } +static inline void wpabuf_put_le24(struct wpabuf *buf, u32 data) +{ + u8 *pos = (u8 *) wpabuf_put(buf, 3); + WPA_PUT_LE24(pos, data); +} + static inline void wpabuf_put_le32(struct wpabuf *buf, u32 data) { u8 *pos = (u8 *) wpabuf_put(buf, 4);