[PATCH v4 01/10] netlink: introduce a dummy netlink attributes parser

Dmitry V. Levin ldv at altlinux.org
Wed Jun 21 13:12:32 UTC 2017


On Wed, Jun 21, 2017 at 04:01:19PM +0300, Dmitry V. Levin wrote:
[...]
> So far I have no better ideas than to introduce a local header,
> e.g. netlink.h, containing, besides an include guard, something like this:
> 
> #include <sys/socket.h>
> #include <linux/netlink.h>
> 
> #undef NLMSG_HDRLEN
> #define NLMSG_HDRLEN ((unsigned int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))
> 
> #ifndef NLA_ALIGN
> # define NLA_ALIGN(len) (((len) + 3) & ~3)
> #endif
> 
> #undef NLA_HDRLEN
> #define NLA_HDRLEN ((unsigned int) NLA_ALIGN(sizeof(struct nlattr)))
> 
> #ifndef NLA_TYPE_MASK
> # define NLA_F_NESTED		(1 << 15)
> # define NLA_F_NET_BYTEORDER	(1 << 14)
> # define NLA_TYPE_MASK		~(NLA_F_NESTED | NLA_F_NET_BYTEORDER)
> #endif

While we are here, a fallback definition for NLMSG_MIN_TYPE seems to be
needed as well, this constant was introduced along with NLMSG_HDRLEN.


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20170621/49b8ff81/attachment.bin>


More information about the Strace-devel mailing list