summaryrefslogtreecommitdiffstats
path: root/lib/attr.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-08-14 17:32:36 +0200
committerThomas Haller <thaller@redhat.com>2015-08-17 23:01:57 +0200
commit7bb956501ccd58ed3bbffc59de996f056e178683 (patch)
treeaf3a3fa3b9623692310a3b6b30c19c124c468304 /lib/attr.c
parent8818a571e72c51bcda309d89bfaf93a2f5524d68 (diff)
downloadplatform_external_libnl-7bb956501ccd58ed3bbffc59de996f056e178683.tar.gz
platform_external_libnl-7bb956501ccd58ed3bbffc59de996f056e178683.tar.bz2
platform_external_libnl-7bb956501ccd58ed3bbffc59de996f056e178683.zip
lib/attr: add nla utility functions for s32
Signed-off-by: Thomas Haller <thaller@redhat.com>
Diffstat (limited to 'lib/attr.c')
-rw-r--r--lib/attr.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/attr.c b/lib/attr.c
index 838d0a9..86284ee 100644
--- a/lib/attr.c
+++ b/lib/attr.c
@@ -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);