From 9f8548b5513a9e9aba52b417c4e36e817d68781f Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Tue, 5 Feb 2013 22:31:31 +0100 Subject: [PATCH] attr: Provide nla_is_nested() function Signed-off-by: Thomas Graf --- include/netlink/attr.h | 3 ++- lib/attr.c | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/netlink/attr.h b/include/netlink/attr.h index 4d32113..69ecb08 100644 --- a/include/netlink/attr.h +++ b/include/netlink/attr.h @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2008 Thomas Graf + * Copyright (c) 2003-2013 Thomas Graf */ #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) diff --git a/lib/attr.c b/lib/attr.c index 10ea682..26bece3 100644 --- a/lib/attr.c +++ b/lib/attr.c @@ -6,7 +6,7 @@ * License as published by the Free Software Foundation version 2.1 * of the License. * - * Copyright (c) 2003-2008 Thomas Graf + * Copyright (c) 2003-2013 Thomas Graf */ #include @@ -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); +} + /** @} */ /** @} */