1 #ifndef __LINUX_NETLINK_WRAPPER_H
2 #define __LINUX_NETLINK_WRAPPER_H 1
4 #include <linux/skbuff.h>
6 #include_next <linux/netlink.h>
8 #define NETLINK_GENERIC 16
11 #define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))
12 #define NLMSG_LENGTH(len) ((len)+NLMSG_ALIGN(NLMSG_HDRLEN))
14 #define NLMSG_MIN_TYPE 0x10 /* < 0x10: reserved control messages */
17 NETLINK_UNCONNECTED = 0,
22 * <------- NLA_HDRLEN ------> <-- NLA_ALIGN(payload)-->
23 * +---------------------+- - -+- - - - - - - - - -+- - -+
24 * | Header | Pad | Payload | Pad |
25 * | (struct nlattr) | ing | | ing |
26 * +---------------------+- - -+- - - - - - - - - -+- - -+
27 * <-------------- nlattr->nla_len -------------->
37 #define NLA_ALIGN(len) (((len) + NLA_ALIGNTO - 1) & ~(NLA_ALIGNTO - 1))
38 #define NLA_HDRLEN ((int) NLA_ALIGN(sizeof(struct nlattr)))
42 #include <linux/capability.h>
43 #include <linux/skbuff.h>
45 static inline struct nlmsghdr *nlmsg_hdr(const struct sk_buff *skb)
47 return (struct nlmsghdr *)skb->data;
50 #define __nlmsg_put __rpl_nlmsg_put
51 static __inline__ struct nlmsghdr *
52 __nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len, int flags)
55 int size = NLMSG_LENGTH(len);
57 nlh = (struct nlmsghdr*)skb_put(skb, NLMSG_ALIGN(size));
58 nlh->nlmsg_type = type;
59 nlh->nlmsg_len = size;
60 nlh->nlmsg_flags = flags;
63 memset(NLMSG_DATA(nlh) + len, 0, NLMSG_ALIGN(size) - size);
67 #define NLMSG_DEFAULT_SIZE (NLMSG_GOODSIZE - NLMSG_HDRLEN)
70 #define NLMSG_NEW(skb, pid, seq, type, len, flags) \
71 ({ if (skb_tailroom(skb) < (int)NLMSG_SPACE(len)) \
73 __nlmsg_put(skb, pid, seq, type, len, flags); })
77 #define NLMSG_PUT(skb, pid, seq, type, len) \
78 NLMSG_NEW(skb, pid, seq, type, len, 0)