Lines Matching refs:attr
102 int ynl_attr_validate(struct ynl_parse_arg *yarg, const struct nlattr *attr);
182 static inline unsigned int ynl_attr_type(const struct nlattr *attr) in ynl_attr_type() argument
184 return attr->nla_type & NLA_TYPE_MASK; in ynl_attr_type()
187 static inline unsigned int ynl_attr_data_len(const struct nlattr *attr) in ynl_attr_data_len() argument
189 return attr->nla_len - NLA_HDRLEN; in ynl_attr_data_len()
192 static inline void *ynl_attr_data(const struct nlattr *attr) in ynl_attr_data() argument
194 return (unsigned char *)attr + NLA_HDRLEN; in ynl_attr_data()
197 static inline void *ynl_attr_data_end(const struct nlattr *attr) in ynl_attr_data_end() argument
199 return (char *)ynl_attr_data(attr) + ynl_attr_data_len(attr); in ynl_attr_data_end()
202 #define ynl_attr_for_each(attr, nlh, fixed_hdr_sz) \ argument
203 for ((attr) = ynl_attr_first(nlh, (nlh)->nlmsg_len, \
204 NLMSG_HDRLEN + fixed_hdr_sz); attr; \
205 (attr) = ynl_attr_next(ynl_nlmsg_end_addr(nlh), attr))
207 #define ynl_attr_for_each_nested(attr, outer) \ argument
208 for ((attr) = ynl_attr_first(outer, outer->nla_len, \
209 sizeof(struct nlattr)); attr; \
210 (attr) = ynl_attr_next(ynl_attr_data_end(outer), attr))
212 #define ynl_attr_for_each_payload(start, len, attr) \ argument
213 for ((attr) = ynl_attr_first(start, len, 0); attr; \
214 (attr) = ynl_attr_next(start + len, attr))
217 ynl_attr_if_good(const void *end, struct nlattr *attr) in ynl_attr_if_good() argument
219 if (attr + 1 > (const struct nlattr *)end) in ynl_attr_if_good()
221 if (ynl_attr_data_end(attr) > end) in ynl_attr_if_good()
223 return attr; in ynl_attr_if_good()
229 struct nlattr *attr; in ynl_attr_next() local
231 attr = (struct nlattr *)((char *)prev + NLA_ALIGN(prev->nla_len)); in ynl_attr_next()
232 return ynl_attr_if_good(end, attr); in ynl_attr_next()
238 struct nlattr *attr; in ynl_attr_first() local
240 attr = (struct nlattr *)((char *)start + NLMSG_ALIGN(skip)); in ynl_attr_first()
241 return ynl_attr_if_good((char *)start + len, attr); in ynl_attr_first()
262 struct nlattr *attr; in ynl_attr_nest_start() local
267 attr = (struct nlattr *)ynl_nlmsg_end_addr(nlh); in ynl_attr_nest_start()
268 attr->nla_type = attr_type | NLA_F_NESTED; in ynl_attr_nest_start()
271 return attr; 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()
284 struct nlattr *attr; in ynl_attr_put() local
289 attr = (struct nlattr *)ynl_nlmsg_end_addr(nlh); in ynl_attr_put()
290 attr->nla_type = attr_type; in ynl_attr_put()
291 attr->nla_len = NLA_HDRLEN + size; in ynl_attr_put()
293 memcpy(ynl_attr_data(attr), value, size); in ynl_attr_put()
295 nlh->nlmsg_len += NLMSG_ALIGN(attr->nla_len); in ynl_attr_put()
301 struct nlattr *attr; in ynl_attr_put_str() local
308 attr = (struct nlattr *)ynl_nlmsg_end_addr(nlh); in ynl_attr_put_str()
309 attr->nla_type = attr_type; in ynl_attr_put_str()
311 strcpy((char *)ynl_attr_data(attr), str); in ynl_attr_put_str()
312 attr->nla_len = NLA_HDRLEN + NLA_ALIGN(len); in ynl_attr_put_str()
314 nlh->nlmsg_len += NLMSG_ALIGN(attr->nla_len); in ynl_attr_put_str()
317 static inline const char *ynl_attr_get_str(const struct nlattr *attr) in ynl_attr_get_str() argument
319 return (const char *)ynl_attr_data(attr); in ynl_attr_get_str()
322 static inline __s8 ynl_attr_get_s8(const struct nlattr *attr) in ynl_attr_get_s8() argument
324 return *(__s8 *)ynl_attr_data(attr); in ynl_attr_get_s8()
327 static inline __s16 ynl_attr_get_s16(const struct nlattr *attr) in ynl_attr_get_s16() argument
329 return *(__s16 *)ynl_attr_data(attr); in ynl_attr_get_s16()
332 static inline __s32 ynl_attr_get_s32(const struct nlattr *attr) in ynl_attr_get_s32() argument
334 return *(__s32 *)ynl_attr_data(attr); in ynl_attr_get_s32()
337 static inline __s64 ynl_attr_get_s64(const struct nlattr *attr) in ynl_attr_get_s64() argument
341 memcpy(&tmp, (unsigned char *)(attr + 1), sizeof(tmp)); in ynl_attr_get_s64()
345 static inline __u8 ynl_attr_get_u8(const struct nlattr *attr) in ynl_attr_get_u8() argument
347 return *(__u8 *)ynl_attr_data(attr); in ynl_attr_get_u8()
350 static inline __u16 ynl_attr_get_u16(const struct nlattr *attr) in ynl_attr_get_u16() argument
352 return *(__u16 *)ynl_attr_data(attr); in ynl_attr_get_u16()
355 static inline __u32 ynl_attr_get_u32(const struct nlattr *attr) in ynl_attr_get_u32() argument
357 return *(__u32 *)ynl_attr_data(attr); in ynl_attr_get_u32()
360 static inline __u64 ynl_attr_get_u64(const struct nlattr *attr) in ynl_attr_get_u64() argument
364 memcpy(&tmp, (unsigned char *)(attr + 1), sizeof(tmp)); in ynl_attr_get_u64()
416 static inline __u64 ynl_attr_get_uint(const struct nlattr *attr) in ynl_attr_get_uint() argument
418 switch (ynl_attr_data_len(attr)) { in ynl_attr_get_uint()
420 return ynl_attr_get_u32(attr); in ynl_attr_get_uint()
422 return ynl_attr_get_u64(attr); in ynl_attr_get_uint()
428 static inline __s64 ynl_attr_get_sint(const struct nlattr *attr) in ynl_attr_get_sint() argument
430 switch (ynl_attr_data_len(attr)) { in ynl_attr_get_sint()
432 return ynl_attr_get_s32(attr); in ynl_attr_get_sint()
434 return ynl_attr_get_s64(attr); in ynl_attr_get_sint()