Lines Matching refs:nlh
41 typedef int (*ynl_parse_cb_t)(const struct nlmsghdr *nlh,
142 struct nlmsghdr *nlh = (struct nlmsghdr *)buf; in ynl_nlmsg_put_header() local
144 memset(nlh, 0, sizeof(*nlh)); in ynl_nlmsg_put_header()
145 nlh->nlmsg_len = NLMSG_HDRLEN; in ynl_nlmsg_put_header()
147 return nlh; in ynl_nlmsg_put_header()
150 static inline unsigned int ynl_nlmsg_data_len(const struct nlmsghdr *nlh) in ynl_nlmsg_data_len() argument
152 return nlh->nlmsg_len - NLMSG_HDRLEN; in ynl_nlmsg_data_len()
155 static inline void *ynl_nlmsg_data(const struct nlmsghdr *nlh) in ynl_nlmsg_data() argument
157 return (unsigned char *)nlh + NLMSG_HDRLEN; in ynl_nlmsg_data()
161 ynl_nlmsg_data_offset(const struct nlmsghdr *nlh, unsigned int offset) in ynl_nlmsg_data_offset() argument
163 return (unsigned char *)nlh + NLMSG_HDRLEN + offset; in ynl_nlmsg_data_offset()
166 static inline void *ynl_nlmsg_end_addr(const struct nlmsghdr *nlh) in ynl_nlmsg_end_addr() argument
168 return (char *)nlh + nlh->nlmsg_len; in ynl_nlmsg_end_addr()
172 ynl_nlmsg_put_extra_header(struct nlmsghdr *nlh, unsigned int size) in ynl_nlmsg_put_extra_header() argument
174 void *tail = ynl_nlmsg_end_addr(nlh); in ynl_nlmsg_put_extra_header()
176 nlh->nlmsg_len += NLMSG_ALIGN(size); in ynl_nlmsg_put_extra_header()
202 #define ynl_attr_for_each(attr, nlh, fixed_hdr_sz) \ argument
203 for ((attr) = ynl_attr_first(nlh, (nlh)->nlmsg_len, \
205 (attr) = ynl_attr_next(ynl_nlmsg_end_addr(nlh), attr))
245 __ynl_attr_put_overflow(struct nlmsghdr *nlh, size_t size) in __ynl_attr_put_overflow() argument
250 o = nlh->nlmsg_len + NLA_HDRLEN + NLMSG_ALIGN(size) > nlh->nlmsg_pid; in __ynl_attr_put_overflow()
255 nlh->nlmsg_pid = YNL_MSG_OVERFLOW; in __ynl_attr_put_overflow()
260 ynl_attr_nest_start(struct nlmsghdr *nlh, unsigned int attr_type) in ynl_attr_nest_start() argument
264 if (__ynl_attr_put_overflow(nlh, 0)) in ynl_attr_nest_start()
265 return (struct nlattr *)ynl_nlmsg_end_addr(nlh) - 1; in ynl_attr_nest_start()
267 attr = (struct nlattr *)ynl_nlmsg_end_addr(nlh); in ynl_attr_nest_start()
269 nlh->nlmsg_len += NLA_HDRLEN; in ynl_attr_nest_start()
275 ynl_attr_nest_end(struct nlmsghdr *nlh, struct nlattr *attr) in ynl_attr_nest_end() argument
277 attr->nla_len = (char *)ynl_nlmsg_end_addr(nlh) - (char *)attr; in ynl_attr_nest_end()
281 ynl_attr_put(struct nlmsghdr *nlh, unsigned int attr_type, in ynl_attr_put() argument
286 if (__ynl_attr_put_overflow(nlh, size)) in ynl_attr_put()
289 attr = (struct nlattr *)ynl_nlmsg_end_addr(nlh); in ynl_attr_put()
295 nlh->nlmsg_len += NLMSG_ALIGN(attr->nla_len); in ynl_attr_put()
299 ynl_attr_put_str(struct nlmsghdr *nlh, unsigned int attr_type, const char *str) in ynl_attr_put_str() argument
305 if (__ynl_attr_put_overflow(nlh, len)) in ynl_attr_put_str()
308 attr = (struct nlattr *)ynl_nlmsg_end_addr(nlh); in ynl_attr_put_str()
314 nlh->nlmsg_len += NLMSG_ALIGN(attr->nla_len); in ynl_attr_put_str()
369 ynl_attr_put_s8(struct nlmsghdr *nlh, unsigned int attr_type, __s8 value) in ynl_attr_put_s8() argument
371 ynl_attr_put(nlh, attr_type, &value, sizeof(value)); in ynl_attr_put_s8()
375 ynl_attr_put_s16(struct nlmsghdr *nlh, unsigned int attr_type, __s16 value) in ynl_attr_put_s16() argument
377 ynl_attr_put(nlh, attr_type, &value, sizeof(value)); in ynl_attr_put_s16()
381 ynl_attr_put_s32(struct nlmsghdr *nlh, unsigned int attr_type, __s32 value) in ynl_attr_put_s32() argument
383 ynl_attr_put(nlh, attr_type, &value, sizeof(value)); in ynl_attr_put_s32()
387 ynl_attr_put_s64(struct nlmsghdr *nlh, unsigned int attr_type, __s64 value) in ynl_attr_put_s64() argument
389 ynl_attr_put(nlh, attr_type, &value, sizeof(value)); in ynl_attr_put_s64()
393 ynl_attr_put_u8(struct nlmsghdr *nlh, unsigned int attr_type, __u8 value) in ynl_attr_put_u8() argument
395 ynl_attr_put(nlh, attr_type, &value, sizeof(value)); in ynl_attr_put_u8()
399 ynl_attr_put_u16(struct nlmsghdr *nlh, unsigned int attr_type, __u16 value) in ynl_attr_put_u16() argument
401 ynl_attr_put(nlh, attr_type, &value, sizeof(value)); in ynl_attr_put_u16()
405 ynl_attr_put_u32(struct nlmsghdr *nlh, unsigned int attr_type, __u32 value) in ynl_attr_put_u32() argument
407 ynl_attr_put(nlh, attr_type, &value, sizeof(value)); in ynl_attr_put_u32()
411 ynl_attr_put_u64(struct nlmsghdr *nlh, unsigned int attr_type, __u64 value) in ynl_attr_put_u64() argument
413 ynl_attr_put(nlh, attr_type, &value, sizeof(value)); in ynl_attr_put_u64()
441 ynl_attr_put_uint(struct nlmsghdr *nlh, __u16 type, __u64 data) in ynl_attr_put_uint() argument
444 ynl_attr_put_u32(nlh, type, data); in ynl_attr_put_uint()
446 ynl_attr_put_u64(nlh, type, data); in ynl_attr_put_uint()
450 ynl_attr_put_sint(struct nlmsghdr *nlh, __u16 type, __s64 data) in ynl_attr_put_sint() argument
453 ynl_attr_put_s32(nlh, type, data); in ynl_attr_put_sint()
455 ynl_attr_put_s64(nlh, type, data); in ynl_attr_put_sint()