On Tue, May 03, 2016 at 02:54:26PM +0200, Sven Eckelmann wrote:
On Tuesday 03 May 2016 14:47:19 Andrew Lunn wrote:
On Tue, May 03, 2016 at 02:26:34PM +0200, Sven Eckelmann wrote:
On Tuesday 03 May 2016 14:20:46 Andrew Lunn wrote: [...]
There does not seem to be a way to say that BATADV_ATTR_VERSION is also an NLA_STRING.
Please check "policy" in the link I gave you.
I did. And i still don't get how you can check the type.
Andrew
struct nla_policy { uint16_t type; uint16_t minlen; uint16_t maxlen; };
there is an entry for type, minlen and maxlen. The type member is to check for the type. Here is an example how to check the type from batctl:
static struct nla_policy info_data_link_policy[IFLA_MAX + 1] = { [IFLA_LINKINFO] = { .type = NLA_NESTED }, [IFLA_LINK] = { .type = NLA_U32 }, }; [...] ret = nlmsg_parse(n, sizeof(struct ifinfomsg), tb, IFLA_MAX, info_data_link_policy);
Ah. Now i get it.
The problem is the overloaded 'type'. An attribute in a message has a header which includes a type. It takes the value e.g. BATADV_ATTR_VERSION. In nla_policy, we again have type, but this time it takes e.g. NLA_U32.
Once you figure out type != type, it all becomes clear...
Andrew