datapath: Convert upcalls and ODP_EXECUTE to use AF_NETLINK socket layer.
[sliver-openvswitch.git] / datapath / linux-2.6 / compat-2.6 / include / net / genetlink.h
1 #ifndef __NET_GENERIC_NETLINK_WRAPPER_H
2 #define __NET_GENERIC_NETLINK_WRAPPER_H 1
3
4
5 #include <linux/netlink.h>
6 #include_next <net/genetlink.h>
7 #include <net/net_namespace.h>
8
9 #include <linux/version.h>
10 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
11
12 #include <linux/genetlink.h>
13
14 /**
15  * struct genl_multicast_group - generic netlink multicast group
16  * @name: name of the multicast group, names are per-family
17  * @id: multicast group ID, assigned by the core, to use with
18  *        genlmsg_multicast().
19  * @list: list entry for linking
20  * @family: pointer to family, need not be set before registering
21  */
22 struct genl_multicast_group
23 {
24         struct genl_family  *family;    /* private */
25         struct list_head        list;      /* private */
26         char name[GENL_NAMSIZ];
27         u32     id;
28 };
29
30 int genl_register_mc_group(struct genl_family *family,
31                 struct genl_multicast_group *grp);
32 #endif /* linux kernel < 2.6.23 */
33
34
35 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
36 /**
37  * genlmsg_msg_size - length of genetlink message not including padding
38  * @payload: length of message payload
39  */
40 static inline int genlmsg_msg_size(int payload)
41 {
42         return GENL_HDRLEN + payload;
43 }
44
45 /**
46  * genlmsg_total_size - length of genetlink message including padding
47  * @payload: length of message payload
48  */
49 static inline int genlmsg_total_size(int payload)
50 {
51         return NLMSG_ALIGN(genlmsg_msg_size(payload));
52 }
53
54 #define genlmsg_multicast(s, p, g, f) \
55                 genlmsg_multicast_flags((s), (p), (g), (f))
56
57 static inline int genlmsg_multicast_flags(struct sk_buff *skb, u32 pid,
58                 unsigned int group, gfp_t flags)
59 {
60         int err;
61
62         NETLINK_CB(skb).dst_group = group;
63
64         err = netlink_broadcast(genl_sock, skb, pid, group, flags);
65         if (err > 0)
66                 err = 0;
67
68         return err;
69 }
70 #endif /* linux kernel < 2.6.19 */
71
72
73 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
74
75 #define genlmsg_put(skb, p, seq, fam, flg, c) \
76         genlmsg_put((skb), (p), (seq), (fam)->id, (fam)->hdrsize, \
77                         (flg), (c), (fam)->version)
78
79 /**
80  * genlmsg_put_reply - Add generic netlink header to a reply message
81  * @skb: socket buffer holding the message
82  * @info: receiver info
83  * @family: generic netlink family
84  * @flags: netlink message flags
85  * @cmd: generic netlink command
86  *
87  * Returns pointer to user specific header
88  */
89 static inline void *genlmsg_put_reply(struct sk_buff *skb,
90                         struct genl_info *info, struct genl_family *family,
91                         int flags, u8 cmd)
92 {
93         return genlmsg_put(skb, info->snd_pid, info->snd_seq, family,
94                                 flags, cmd);
95 }
96
97 /**
98  * genlmsg_reply - reply to a request
99  * @skb: netlink message to be sent back
100  * @info: receiver information
101  */
102 static inline int genlmsg_reply(struct sk_buff *skb, struct genl_info *info)
103 {
104         return genlmsg_unicast(skb, info->snd_pid);
105 }
106
107 /**
108  * genlmsg_new - Allocate a new generic netlink message
109  * @payload: size of the message payload
110  * @flags: the type of memory to allocate.
111  */
112 static inline struct sk_buff *genlmsg_new(size_t payload, gfp_t flags)
113 {
114         return nlmsg_new(genlmsg_total_size(payload), flags);
115 }
116 #endif /* linux kernel < 2.6.20 */
117
118 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
119 int genl_register_family_with_ops(struct genl_family *family,
120         struct genl_ops *ops, size_t n_ops);
121 #endif
122
123 #endif /* genetlink.h */