NLA_S8 is used by newer hostapd versions.

Signed-off-by: Nick Hainke <vinc...@systemli.org>
---
 attr.c                 |  1 +
 include/netlink/attr.h | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/attr.c b/attr.c
index eae91e5..abde67f 100644
--- a/attr.c
+++ b/attr.c
@@ -437,6 +437,7 @@ static uint16_t nla_attr_minlen[NLA_TYPE_MAX+1] = {
        [NLA_U32]       = sizeof(uint32_t),
        [NLA_U64]       = sizeof(uint64_t),
        [NLA_STRING]    = 1,
+       [NLA_S8]        = sizeof(int8_t),
 };
 
 static int validate_nla(struct nlattr *nla, int maxtype,
diff --git a/include/netlink/attr.h b/include/netlink/attr.h
index 3e3047f..3a5d53d 100644
--- a/include/netlink/attr.h
+++ b/include/netlink/attr.h
@@ -45,6 +45,7 @@ enum {
        NLA_FLAG,       /**< Flag */
        NLA_MSECS,      /**< Micro seconds (64bit) */
        NLA_NESTED,     /**< Nested attributes */
+       NLA_S8,
        __NLA_TYPE_MAX,
 };
 
@@ -248,6 +249,31 @@ static inline int nla_put_addr(struct nl_msg *msg, int 
attrtype, struct nl_addr
  * @name Integer Attributes
  */
 
+/**
+ * Add 8 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_s8(struct nl_msg *msg, int attrtype, int8_t value)
+{
+       return nla_put(msg, attrtype, sizeof(int8_t), &value);
+}
+
+/**
+ * Return value of 8 bit signed integer attribute.
+ * @arg nla             8 bit integer attribute
+ *
+ * @return Payload as 8 bit integer.
+ */
+static inline int8_t nla_get_s8(const struct nlattr *nla)
+{
+       return *(const int8_t *) nla_data(nla);
+}
+
 /**
  * Add 8 bit integer attribute to netlink message.
  * @arg msg            Netlink message.
@@ -638,6 +664,15 @@ static inline size_t nla_strlcpy(char *dst, const struct 
nlattr *nla, size_t dst
                NLA_PUT(msg, attrtype, sizeof(type), &__tmp); \
        } 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.
-- 
2.40.0


_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to