diff options
author | Hauke Mehrtens <hauke@hauke-m.de> | 2021-11-21 00:08:55 +0100 |
---|---|---|
committer | rofl0r <rofl0r@users.noreply.github.com> | 2022-09-16 01:33:00 +0000 |
commit | 7e2d06db22c521d0c6cdd06d18d94c9258087c5e (patch) | |
tree | 7f506a29e2e10d2df0cd52a8992d0193e37d4b0f /include | |
parent | aae09e27c30ee63c4a555e4f7fdf06448b4eced4 (diff) | |
download | libnl-tiny-7e2d06db22c521d0c6cdd06d18d94c9258087c5e.tar.gz |
attr.h: Add NLA_PUT_S32
This function is used by iw 5.16.
These new headers were copied from the mainline libnl.
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Diffstat (limited to 'include')
-rw-r--r-- | include/netlink/attr.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/include/netlink/attr.h b/include/netlink/attr.h index 3b56a82..bcfbf07 100644 --- a/include/netlink/attr.h +++ b/include/netlink/attr.h @@ -299,6 +299,31 @@ static inline uint16_t nla_get_u16(struct nlattr *nla) } /** + * Add 32 bit signed 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. + */ +static inline 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 signed integer attribute. + * @arg nla 32 bit integer attribute. + * + * @return Payload as 32 bit integer. + */ +static inline int32_t nla_get_s32(struct nlattr *nla) +{ + return *(int32_t *) nla_data(nla); +} + +/** * Add 32 bit integer attribute to netlink message. * @arg msg Netlink message. * @arg attrtype Attribute type. @@ -632,6 +657,15 @@ static inline size_t nla_strlcpy(char *dst, const struct nlattr *nla, size_t dst NLA_PUT_TYPE(msg, uint16_t, attrtype, value) /** + * Add 32 bit signed integer attribute to netlink message. + * @arg msg Netlink message. + * @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. |