]> granicus.if.org Git - libnl/commitdiff
attr: Provide nla_is_nested() function
authorThomas Graf <tgraf@suug.ch>
Tue, 5 Feb 2013 21:31:31 +0000 (22:31 +0100)
committerThomas Graf <tgraf@suug.ch>
Tue, 5 Feb 2013 21:31:31 +0000 (22:31 +0100)
Signed-off-by: Thomas Graf <tgraf@suug.ch>
include/netlink/attr.h
lib/attr.c

index 4d321131a9df11bd369ba5a328120161c4472e31..69ecb08da2de6cd753805c98d0086f0408844408 100644 (file)
@@ -6,7 +6,7 @@
  *     License as published by the Free Software Foundation version 2.1
  *     of the License.
  *
- * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ * Copyright (c) 2003-2013 Thomas Graf <tgraf@suug.ch>
  */
 
 #ifndef NETLINK_ATTR_H_
@@ -126,6 +126,7 @@ extern struct nlattr *      nla_nest_start(struct nl_msg *, int);
 extern int             nla_nest_end(struct nl_msg *, struct nlattr *);
 extern int             nla_parse_nested(struct nlattr **, int, struct nlattr *,
                                         struct nla_policy *);
+extern int             nla_is_nested(struct nlattr *);
 
 /**
  * @name Attribute Construction (Exception Based)
index 10ea682d2c648f0b305f59522e0a82fb652fdc63..26bece3d4a599dad4d0ae63db1e79f2c040a396f 100644 (file)
@@ -6,7 +6,7 @@
  *     License as published by the Free Software Foundation version 2.1
  *     of the License.
  *
- * Copyright (c) 2003-2008 Thomas Graf <tgraf@suug.ch>
+ * Copyright (c) 2003-2013 Thomas Graf <tgraf@suug.ch>
  */
 
 #include <netlink-private/netlink.h>
@@ -868,6 +868,17 @@ int nla_parse_nested(struct nlattr *tb[], int maxtype, struct nlattr *nla,
        return nla_parse(tb, maxtype, nla_data(nla), nla_len(nla), policy);
 }
 
+/**
+ * Return true if attribute has NLA_F_NESTED flag set
+ * @arg attr           Netlink attribute
+ *
+ * @return True if attribute has NLA_F_NESTED flag set, oterhwise False.
+ */
+int nla_is_nested(struct nlattr *attr)
+{
+       return !!(nla_type(attr) & NLA_F_NESTED);
+}
+
 /** @} */
 
 /** @} */