diff options
author | Thomas Haller <thaller@redhat.com> | 2015-08-14 15:32:36 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-08-17 21:01:57 (GMT) |
commit | 7bb956501ccd58ed3bbffc59de996f056e178683 (patch) | |
tree | af3a3fa3b9623692310a3b6b30c19c124c468304 | |
parent | 8818a571e72c51bcda309d89bfaf93a2f5524d68 (diff) | |
download | libnl-7bb956501ccd58ed3bbffc59de996f056e178683.zip libnl-7bb956501ccd58ed3bbffc59de996f056e178683.tar.gz libnl-7bb956501ccd58ed3bbffc59de996f056e178683.tar.bz2 |
lib/attr: add nla utility functions for s32
Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r-- | include/netlink/attr.h | 11 | ||||
-rw-r--r-- | lib/attr.c | 25 | ||||
-rw-r--r-- | libnl-3.sym | 6 |
3 files changed, 42 insertions, 0 deletions
diff --git a/include/netlink/attr.h b/include/netlink/attr.h index b84b62e..fd8e299 100644 --- a/include/netlink/attr.h +++ b/include/netlink/attr.h @@ -103,6 +103,8 @@ extern uint8_t nla_get_u8(const struct nlattr *); extern int nla_put_u8(struct nl_msg *, int, uint8_t); extern uint16_t nla_get_u16(const struct nlattr *); extern int nla_put_u16(struct nl_msg *, int, uint16_t); +extern int32_t nla_get_s32(const struct nlattr *); +extern int nla_put_s32(struct nl_msg *, int, int32_t); extern uint32_t nla_get_u32(const struct nlattr *); extern int nla_put_u32(struct nl_msg *, int, uint32_t); extern uint64_t nla_get_u64(const struct nlattr *); @@ -188,6 +190,15 @@ extern int nla_is_nested(const struct nlattr *); * @arg attrtype Attribute type. * @arg value Numeric value. */ +#define NLA_PUT_S32(msg, attrtype, value) \ + NLA_PUT_TYPE(msg, int32_t, attrtype, value) + +/** + * Add 32 bit integer attribute to netlink message. + * @arg msg Netlink message. + * @arg attrtype Attribute type. + * @arg value Numeric value. + */ #define NLA_PUT_U32(msg, attrtype, value) \ NLA_PUT_TYPE(msg, uint32_t, attrtype, value) @@ -610,6 +610,31 @@ uint16_t nla_get_u16(const struct nlattr *nla) * @see nla_put * @return 0 on success or a negative error code. */ +int nla_put_s32(struct nl_msg *msg, int attrtype, int32_t value) +{ + return nla_put(msg, attrtype, sizeof(int32_t), &value); +} + +/** + * Return payload of 32 bit integer attribute. + * @arg nla 32 bit integer attribute. + * + * @return Payload as 32 bit integer. + */ +int32_t nla_get_s32(const struct nlattr *nla) +{ + return *(const int32_t *) nla_data(nla); +} + +/** + * Add 32 bit integer attribute to netlink message. + * @arg msg Netlink message. + * @arg attrtype Attribute type. + * @arg value Numeric value to store as payload. + * + * @see nla_put + * @return 0 on success or a negative error code. + */ int nla_put_u32(struct nl_msg *msg, int attrtype, uint32_t value) { return nla_put(msg, attrtype, sizeof(uint32_t), &value); diff --git a/libnl-3.sym b/libnl-3.sym index 621bfe0..a467ab2 100644 --- a/libnl-3.sym +++ b/libnl-3.sym @@ -334,3 +334,9 @@ libnl_3_2_26 { global: nl_socket_set_fd; } libnl_3; + +libnl_3_2_27 { +global: + nla_get_s32; + nla_put_s32; +} libnl_3_2_26; |