diff options
Diffstat (limited to 'tools/net/ynl/lib/ynl.h')
-rw-r--r-- | tools/net/ynl/lib/ynl.h | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/tools/net/ynl/lib/ynl.h b/tools/net/ynl/lib/ynl.h index 9eafa3552c..e974378e3b 100644 --- a/tools/net/ynl/lib/ynl.h +++ b/tools/net/ynl/lib/ynl.h @@ -133,7 +133,9 @@ enum ynl_policy_type { YNL_PT_U16, YNL_PT_U32, YNL_PT_U64, + YNL_PT_UINT, YNL_PT_NUL_STR, + YNL_PT_BITFIELD32, }; struct ynl_policy_attr { @@ -156,7 +158,7 @@ struct ynl_parse_arg { struct ynl_dump_list_type { struct ynl_dump_list_type *next; - unsigned char data[] __attribute__ ((aligned (8))); + unsigned char data[] __attribute__((aligned(8))); }; extern struct ynl_dump_list_type *YNL_LIST_END; @@ -186,7 +188,7 @@ struct ynl_ntf_base_type { __u8 cmd; struct ynl_ntf_base_type *next; void (*free)(struct ynl_ntf_base_type *ntf); - unsigned char data[] __attribute__ ((aligned (8))); + unsigned char data[] __attribute__((aligned(8))); }; extern mnl_cb_t ynl_cb_array[NLMSG_MIN_TYPE]; @@ -234,4 +236,20 @@ int ynl_exec_dump(struct ynl_sock *ys, struct nlmsghdr *req_nlh, void ynl_error_unknown_notification(struct ynl_sock *ys, __u8 cmd); int ynl_error_parse(struct ynl_parse_arg *yarg, const char *msg); +#ifndef MNL_HAS_AUTO_SCALARS +static inline uint64_t mnl_attr_get_uint(const struct nlattr *attr) +{ + if (mnl_attr_get_len(attr) == 4) + return mnl_attr_get_u32(attr); + return mnl_attr_get_u64(attr); +} + +static inline void +mnl_attr_put_uint(struct nlmsghdr *nlh, uint16_t type, uint64_t data) +{ + if ((uint32_t)data == (uint64_t)data) + return mnl_attr_put_u32(nlh, type, data); + return mnl_attr_put_u64(nlh, type, data); +} +#endif #endif |