31 #define BLOB_COOKIE 0x01234567
46 #define BLOB_ATTR_ID_MASK 0x7f000000
47 #define BLOB_ATTR_ID_SHIFT 24
48 #define BLOB_ATTR_LEN_MASK 0x00ffffff
49 #define BLOB_ATTR_ALIGN 4
50 #define BLOB_ATTR_EXTENDED 0x80000000
77 return (
void *) attr->
data;
83 static inline unsigned int
125 static inline uint8_t
128 return *((uint8_t *) attr->
data);
131 static inline uint16_t
134 uint16_t *tmp = (uint16_t*)attr->
data;
138 static inline uint32_t
141 uint32_t *tmp = (uint32_t*)attr->
data;
145 static inline uint64_t
148 uint32_t *ptr = (uint32_t *)
blob_data(attr);
149 uint64_t tmp = ((uint64_t)
be32_to_cpu(ptr[0])) << 32;
160 static inline int16_t
166 static inline int32_t
172 static inline int64_t
178 static inline const char *
209 return blob_put(buf,
id, str, strlen(str) + 1);
215 return blob_put(buf,
id, &val,
sizeof(val));
222 return blob_put(buf,
id, &val,
sizeof(val));
229 return blob_put(buf,
id, &val,
sizeof(val));
236 return blob_put(buf,
id, &val,
sizeof(val));
239 #define blob_put_int8 blob_put_u8
240 #define blob_put_int16 blob_put_u16
241 #define blob_put_int32 blob_put_u32
242 #define blob_put_int64 blob_put_u64
244 #define __blob_for_each_attr(pos, attr, rem) \
245 for (pos = (struct blob_attr *) attr; \
246 rem >= sizeof(struct blob_attr) && (blob_pad_len(pos) <= rem) && \
247 (blob_pad_len(pos) >= sizeof(struct blob_attr)); \
248 rem -= blob_pad_len(pos), pos = blob_next(pos))
251 #define blob_for_each_attr(pos, attr, rem) \
252 for (rem = attr ? blob_len(attr) : 0, \
253 pos = (struct blob_attr *) (attr ? blob_data(attr) : NULL); \
254 rem >= sizeof(struct blob_attr) && (blob_pad_len(pos) <= rem) && \
255 (blob_pad_len(pos) >= sizeof(struct blob_attr)); \
256 rem -= blob_pad_len(pos), pos = blob_next(pos))
258 #define blob_for_each_attr_len(pos, attr, attr_len, rem) \
259 for (rem = attr ? blob_len(attr) : 0, \
260 pos = (struct blob_attr *) (attr ? blob_data(attr) : NULL); \
261 rem >= sizeof(struct blob_attr) && rem < attr_len && (blob_pad_len(pos) <= rem) && \
262 (blob_pad_len(pos) >= sizeof(struct blob_attr)); \
263 rem -= blob_pad_len(pos), pos = blob_next(pos))
static struct blob_attr * blob_put_u8(struct blob_buf *buf, int id, uint8_t val)
void blob_set_raw_len(struct blob_attr *attr, unsigned int len)
static const char * blob_get_string(const struct blob_attr *attr)
static struct blob_attr * blob_put_string(struct blob_buf *buf, int id, const char *str)
static uint32_t blob_get_u32(const struct blob_attr *attr)
static size_t blob_raw_len(const struct blob_attr *attr)
static size_t blob_pad_len(const struct blob_attr *attr)
struct blob_attr * blob_put(struct blob_buf *buf, int id, const void *ptr, unsigned int len)
static uint8_t blob_get_u8(const struct blob_attr *attr)
bool blob_attr_equal(const struct blob_attr *a1, const struct blob_attr *a2)
#define BLOB_ATTR_ID_MASK
void blob_buf_free(struct blob_buf *buf)
static struct blob_attr * blob_next(const struct blob_attr *attr)
static int64_t blob_get_int64(const struct blob_attr *attr)
static bool blob_is_extended(const struct blob_attr *attr)
struct blob_attr * blob_new(struct blob_buf *buf, int id, int payload)
bool blob_check_type(const void *ptr, unsigned int len, int type)
void * blob_nest_start(struct blob_buf *buf, int id)
#define BLOB_ATTR_ID_SHIFT
static uint16_t blob_get_u16(const struct blob_attr *attr)
static int8_t blob_get_int8(const struct blob_attr *attr)
int blob_parse(struct blob_attr *attr, struct blob_attr **data, const struct blob_attr_info *info, int max)
static struct blob_attr * blob_put_u16(struct blob_buf *buf, int id, uint16_t val)
static struct blob_attr * blob_put_u64(struct blob_buf *buf, int id, uint64_t val)
static size_t blob_len(const struct blob_attr *attr)
int blob_parse_untrusted(struct blob_attr *attr, size_t attr_len, struct blob_attr **data, const struct blob_attr_info *info, int max)
void blob_nest_end(struct blob_buf *buf, void *cookie)
static struct blob_attr * blob_put_u32(struct blob_buf *buf, int id, uint32_t val)
static int32_t blob_get_int32(const struct blob_attr *attr)
bool blob_buf_grow(struct blob_buf *buf, int required)
static void * blob_data(const struct blob_attr *attr)
void blob_fill_pad(struct blob_attr *attr)
static unsigned int blob_id(const struct blob_attr *attr)
#define BLOB_ATTR_EXTENDED
struct blob_attr * blob_memdup(struct blob_attr *attr)
static int16_t blob_get_int16(const struct blob_attr *attr)
static uint64_t blob_get_u64(const struct blob_attr *attr)
struct blob_attr * blob_put_raw(struct blob_buf *buf, const void *ptr, unsigned int len)
int blob_buf_init(struct blob_buf *buf, int id)
#define BLOB_ATTR_LEN_MASK
bool(* validate)(const struct blob_attr_info *, struct blob_attr *)
bool(* grow)(struct blob_buf *buf, int minlen)