Linux Kernel
3.7.1
|
#include <netlink.h>
Data Fields | |
u16 | type |
u16 | len |
struct nla_policy - attribute validation policy : Type of attribute or NLA_UNSPEC : Type specific length of payload
Policies are defined as arrays of this struct, the array must be accessible by attribute type up to the highest identifier to be expected.
Meaning of `len' field: NLA_STRING Maximum length of string NLA_NUL_STRING Maximum length of string (excluding NUL) NLA_FLAG Unused NLA_BINARY Maximum length of attribute payload NLA_NESTED Don't use `len' field – length verification is done by checking len of nested header (or empty) NLA_NESTED_COMPAT Minimum length of structure payload NLA_U8, NLA_U16, NLA_U32, NLA_U64, NLA_S8, NLA_S16, NLA_S32, NLA_S64, NLA_MSECS Leaving the length field zero will verify the given type fits, using it verifies minimum length just like "All other" All other Minimum length of attribute payload
Example: static const struct nla_policy my_policy[ATTR_MAX+1] = { [ATTR_FOO] = { .type = NLA_U16 }, [ATTR_BAR] = { .type = NLA_STRING, .len = BARSIZ }, [ATTR_BAZ] = { .len = sizeof(struct mystruct) }, };