9 #define WPABUF_FLAG_EXT_DATA BIT(0)
25 int wpabuf_resize(
struct wpabuf **buf,
size_t add_len);
27 struct wpabuf * wpabuf_alloc_ext_data(u8 *data,
size_t len);
28 struct wpabuf * wpabuf_alloc_copy(
const void *data,
size_t len);
31 void wpabuf_clear_free(
struct wpabuf *buf);
32 void * wpabuf_put(
struct wpabuf *buf,
size_t len);
35 void wpabuf_printf(
struct wpabuf *buf,
char *fmt, ...) PRINTF_FORMAT(2, 3);
43 static inline
size_t wpabuf_size(const struct
wpabuf *buf)
53 static inline size_t wpabuf_len(
const struct wpabuf *buf)
63 static inline size_t wpabuf_tailroom(
const struct wpabuf *buf)
65 return buf->size - buf->used;
73 static inline const void * wpabuf_head(
const struct wpabuf *buf)
78 static inline const u8 * wpabuf_head_u8(
const struct wpabuf *buf)
80 return wpabuf_head(buf);
88 static inline void * wpabuf_mhead(
struct wpabuf *buf)
93 static inline u8 * wpabuf_mhead_u8(
struct wpabuf *buf)
95 return wpabuf_mhead(buf);
98 static inline void wpabuf_put_u8(
struct wpabuf *buf, u8 data)
100 u8 *pos = wpabuf_put(buf, 1);
104 static inline void wpabuf_put_le16(
struct wpabuf *buf, u16 data)
106 u8 *pos = wpabuf_put(buf, 2);
107 WPA_PUT_LE16(pos, data);
110 static inline void wpabuf_put_le32(
struct wpabuf *buf, u32 data)
112 u8 *pos = wpabuf_put(buf, 4);
113 WPA_PUT_LE32(pos, data);
116 static inline void wpabuf_put_be16(
struct wpabuf *buf, u16 data)
118 u8 *pos = wpabuf_put(buf, 2);
119 WPA_PUT_BE16(pos, data);
122 static inline void wpabuf_put_be24(
struct wpabuf *buf, u32 data)
124 u8 *pos = wpabuf_put(buf, 3);
125 WPA_PUT_BE24(pos, data);
128 static inline void wpabuf_put_be32(
struct wpabuf *buf, u32 data)
130 u8 *pos = wpabuf_put(buf, 4);
131 WPA_PUT_BE32(pos, data);
134 static inline void wpabuf_put_data(
struct wpabuf *buf,
const void *data,
138 os_memcpy(wpabuf_put(buf, len), data, len);
141 static inline void wpabuf_put_buf(
struct wpabuf *dst,
144 wpabuf_put_data(dst, wpabuf_head(src), wpabuf_len(src));
147 static inline void wpabuf_set(
struct wpabuf *buf,
const void *data,
size_t len)
149 buf->buf = (u8 *) data;
150 buf->flags = WPABUF_FLAG_EXT_DATA;
151 buf->size = buf->used = len;
154 static inline void wpabuf_put_str(
struct wpabuf *dst,
const char *str)
156 wpabuf_put_data(dst, str, os_strlen(str));
struct wpabuf * wpabuf_concat(struct wpabuf *a, struct wpabuf *b)
Concatenate two buffers into a newly allocated one.
Definition: wpabuf.c:233
struct wpabuf * wpabuf_alloc(size_t len)
Allocate a wpabuf of the given size.
Definition: wpabuf.c:109
void wpabuf_free(struct wpabuf *buf)
Free a wpabuf.
Definition: wpabuf.c:178
struct wpabuf * wpabuf_zeropad(struct wpabuf *buf, size_t len)
Pad buffer with 0x00 octets (prefix) to specified length.
Definition: wpabuf.c:273