summaryrefslogtreecommitdiffstats
path: root/include/netlink
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-10-05 14:52:07 (GMT)
committerThomas Haller <thaller@redhat.com>2015-10-05 14:52:41 (GMT)
commit6263a11bfcd033a88583faa719d3911850f0c4f5 (patch)
tree4f81ecd3204d02cec9672d1693800a74061d67cc /include/netlink
parent2a8a7c31e6accf1a22caebace8da4c03028d5500 (diff)
downloadlibnl-6263a11bfcd033a88583faa719d3911850f0c4f5.zip
libnl-6263a11bfcd033a88583faa719d3911850f0c4f5.tar.gz
libnl-6263a11bfcd033a88583faa719d3911850f0c4f5.tar.bz2
lib/attr: add nla utility functions for signed integers
Commit 7bb956501ccd58ed3bbffc59de996f056e178683 added nla functions for s32. We preferibly add all signed integer operations at the same time. Thus, also add s8, s16, and s64. Also, previously the NLA_TYPE_MAX enum was not extended to have NLA_S32. Fix that too. Reported-By: Jiri Pirko <jiri@resnulli.us> Fixes: 7bb956501ccd58ed3bbffc59de996f056e178683 Signed-off-by: Thomas Haller <thaller@redhat.com>
Diffstat (limited to 'include/netlink')
-rw-r--r--include/netlink/attr.h42
1 files changed, 41 insertions, 1 deletions
diff --git a/include/netlink/attr.h b/include/netlink/attr.h
index fd8e299..ee159aa 100644
--- a/include/netlink/attr.h
+++ b/include/netlink/attr.h
@@ -44,6 +44,13 @@ enum {
NLA_FLAG, /**< Flag */
NLA_MSECS, /**< Micro seconds (64bit) */
NLA_NESTED, /**< Nested attributes */
+ NLA_NESTED_COMPAT,
+ NLA_NUL_STRING,
+ NLA_BINARY,
+ NLA_S8,
+ NLA_S16,
+ NLA_S32,
+ NLA_S64,
__NLA_TYPE_MAX,
};
@@ -99,14 +106,20 @@ extern int nla_put_data(struct nl_msg *, int,
extern int nla_put_addr(struct nl_msg *, int, struct nl_addr *);
/* Integer attribute */
+extern int8_t nla_get_s8(const struct nlattr *);
+extern int nla_put_s8(struct nl_msg *, int, int8_t);
extern uint8_t nla_get_u8(const struct nlattr *);
extern int nla_put_u8(struct nl_msg *, int, uint8_t);
+extern int16_t nla_get_s16(const struct nlattr *);
+extern int nla_put_s16(struct nl_msg *, int, int16_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 int64_t nla_get_s64(const struct nlattr *);
+extern int nla_put_s64(struct nl_msg *, int, int64_t);
extern uint64_t nla_get_u64(const struct nlattr *);
extern int nla_put_u64(struct nl_msg *, int, uint64_t);
@@ -167,6 +180,15 @@ extern int nla_is_nested(const struct nlattr *);
} while(0)
/**
+ * Add 8 bit signed integer attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg value Numeric value.
+ */
+#define NLA_PUT_S8(msg, attrtype, value) \
+ NLA_PUT_TYPE(msg, int8_t, attrtype, value)
+
+/**
* Add 8 bit integer attribute to netlink message.
* @arg msg Netlink message.
* @arg attrtype Attribute type.
@@ -176,6 +198,15 @@ extern int nla_is_nested(const struct nlattr *);
NLA_PUT_TYPE(msg, uint8_t, attrtype, value)
/**
+ * Add 16 bit signed integer attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg value Numeric value.
+ */
+#define NLA_PUT_S16(msg, attrtype, value) \
+ NLA_PUT_TYPE(msg, int16_t, attrtype, value)
+
+/**
* Add 16 bit integer attribute to netlink message.
* @arg msg Netlink message.
* @arg attrtype Attribute type.
@@ -185,7 +216,7 @@ extern int nla_is_nested(const struct nlattr *);
NLA_PUT_TYPE(msg, uint16_t, attrtype, value)
/**
- * Add 32 bit integer attribute to netlink message.
+ * Add 32 bit signed integer attribute to netlink message.
* @arg msg Netlink message.
* @arg attrtype Attribute type.
* @arg value Numeric value.
@@ -203,6 +234,15 @@ extern int nla_is_nested(const struct nlattr *);
NLA_PUT_TYPE(msg, uint32_t, attrtype, value)
/**
+ * Add 64 bit signed integer attribute to netlink message.
+ * @arg msg Netlink message.
+ * @arg attrtype Attribute type.
+ * @arg value Numeric value.
+ */
+#define NLA_PUT_S64(msg, attrtype, value) \
+ NLA_PUT_TYPE(msg, int64_t, attrtype, value)
+
+/**
* Add 64 bit integer attribute to netlink message.
* @arg msg Netlink message.
* @arg attrtype Attribute type.