]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Add support for conversion to little endian for 24 bits
authorPurushottam Kushwaha <quic_pkushwah@quicinc.com>
Tue, 28 Mar 2023 12:09:59 +0000 (17:39 +0530)
committerJouni Malinen <j@w1.fi>
Mon, 28 Aug 2023 10:58:13 +0000 (13:58 +0300)
Like le16/le32, add support for conversion to le24.

Signed-off-by: Purushottam Kushwaha <quic_pkushwah@quicinc.com>
src/utils/common.h
src/utils/wpabuf.h

index 435a9a84cac4d2e828bfda8462a189724484dc67..bede21e5717715fd4389bbbd3236fd1215abc0a3 100644 (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];
index eb1db80912a06b651b567ee207d33e4813c4b478..88d72bd685e5c86cd319a3a806052002b177a898 100644 (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);