Add support for conversion to little endian for 24 bits

Like le16/le32, add support for conversion to le24.

Signed-off-by: Purushottam Kushwaha <quic_pkushwah@quicinc.com>
This commit is contained in:
Purushottam Kushwaha 2023-03-28 17:39:59 +05:30 committed by Jouni Malinen
parent 609864d6a8
commit 12154861e2
2 changed files with 18 additions and 0 deletions

View file

@ -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];

View file

@ -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);