1 #ifndef __LINUX_NETLINK_WRAPPER_H
2 #define __LINUX_NETLINK_WRAPPER_H 1
4 #include_next <linux/netlink.h>
6 #define NETLINK_GENERIC 16
9 #define NLMSG_HDRLEN ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))
10 #define NLMSG_LENGTH(len) ((len)+NLMSG_ALIGN(NLMSG_HDRLEN))
12 #define NLMSG_MIN_TYPE 0x10 /* < 0x10: reserved control messages */
15 NETLINK_UNCONNECTED = 0,
20 * <------- NLA_HDRLEN ------> <-- NLA_ALIGN(payload)-->
21 * +---------------------+- - -+- - - - - - - - - -+- - -+
22 * | Header | Pad | Payload | Pad |
23 * | (struct nlattr) | ing | | ing |
24 * +---------------------+- - -+- - - - - - - - - -+- - -+
25 * <-------------- nlattr->nla_len -------------->
35 #define NLA_ALIGN(len) (((len) + NLA_ALIGNTO - 1) & ~(NLA_ALIGNTO - 1))
36 #define NLA_HDRLEN ((int) NLA_ALIGN(sizeof(struct nlattr)))
40 #include <linux/capability.h>
41 #include <linux/skbuff.h>
43 static inline struct nlmsghdr *nlmsg_hdr(const struct sk_buff *skb)
45 return (struct nlmsghdr *)skb->data;
48 #define __nlmsg_put __rpl_nlmsg_put
49 static __inline__ struct nlmsghdr *
50 __nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len, int flags)
53 int size = NLMSG_LENGTH(len);
55 nlh = (struct nlmsghdr*)skb_put(skb, NLMSG_ALIGN(size));
56 nlh->nlmsg_type = type;
57 nlh->nlmsg_len = size;
58 nlh->nlmsg_flags = flags;
61 memset(NLMSG_DATA(nlh) + len, 0, NLMSG_ALIGN(size) - size);
65 #define NLMSG_DEFAULT_SIZE (NLMSG_GOODSIZE - NLMSG_HDRLEN)
68 #define NLMSG_NEW(skb, pid, seq, type, len, flags) \
69 ({ if (skb_tailroom(skb) < (int)NLMSG_SPACE(len)) \
71 __nlmsg_put(skb, pid, seq, type, len, flags); })
75 #define NLMSG_PUT(skb, pid, seq, type, len) \
76 NLMSG_NEW(skb, pid, seq, type, len, 0)