Added missing header file.
[openvswitch] / datapath / linux-2.4 / compat-2.4 / include / linux / netlink.h
1 #ifndef __LINUX_NETLINK_WRAPPER_H
2 #define __LINUX_NETLINK_WRAPPER_H 1
3
4 #include <linux/skbuff.h>
5
6 #include_next <linux/netlink.h>
7
8 #define NETLINK_GENERIC                16
9
10 #undef NLMSG_LENGTH
11 #define NLMSG_HDRLEN    ((int) NLMSG_ALIGN(sizeof(struct nlmsghdr)))
12 #define NLMSG_LENGTH(len) ((len)+NLMSG_ALIGN(NLMSG_HDRLEN))
13
14 #define NLMSG_MIN_TYPE         0x10    /* < 0x10: reserved control messages */
15
16 enum {
17        NETLINK_UNCONNECTED = 0,
18        NETLINK_CONNECTED,
19 };
20
21 /*
22  *  <------- NLA_HDRLEN ------> <-- NLA_ALIGN(payload)-->
23  * +---------------------+- - -+- - - - - - - - - -+- - -+
24  * |        Header       | Pad |     Payload       | Pad |
25  * |   (struct nlattr)   | ing |                   | ing |
26  * +---------------------+- - -+- - - - - - - - - -+- - -+
27  *  <-------------- nlattr->nla_len -------------->
28  */
29
30 struct nlattr
31 {
32        __u16           nla_len;
33        __u16           nla_type;
34 };
35
36 #define NLA_ALIGNTO            4
37 #define NLA_ALIGN(len)         (((len) + NLA_ALIGNTO - 1) & ~(NLA_ALIGNTO - 1))
38 #define NLA_HDRLEN             ((int) NLA_ALIGN(sizeof(struct nlattr)))
39
40 #ifdef __KERNEL__
41
42 #include <linux/capability.h>
43 #include <linux/skbuff.h>
44
45 static inline struct nlmsghdr *nlmsg_hdr(const struct sk_buff *skb)
46 {
47        return (struct nlmsghdr *)skb->data;
48 }
49
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)
53 {
54         struct nlmsghdr *nlh;
55         int size = NLMSG_LENGTH(len);
56
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;
61         nlh->nlmsg_pid = pid;
62         nlh->nlmsg_seq = seq;
63         memset(NLMSG_DATA(nlh) + len, 0, NLMSG_ALIGN(size) - size);
64         return nlh;
65 }
66
67 #define NLMSG_DEFAULT_SIZE (NLMSG_GOODSIZE - NLMSG_HDRLEN)
68
69 #undef NLMSG_NEW
70 #define NLMSG_NEW(skb, pid, seq, type, len, flags) \
71 ({      if (skb_tailroom(skb) < (int)NLMSG_SPACE(len)) \
72                 goto nlmsg_failure; \
73         __nlmsg_put(skb, pid, seq, type, len, flags); })
74 #endif
75
76 #undef NLMSG_PUT
77 #define NLMSG_PUT(skb, pid, seq, type, len) \
78         NLMSG_NEW(skb, pid, seq, type, len, 0)
79
80 #endif