1 #ifndef __NET_GENERIC_NETLINK_WRAPPER_H
2 #define __NET_GENERIC_NETLINK_WRAPPER_H 1
5 #include <linux/netlink.h>
6 #include_next <net/genetlink.h>
7 #include <net/net_namespace.h>
9 #include <linux/version.h>
10 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
12 #include <linux/genetlink.h>
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
22 struct genl_multicast_group
24 struct genl_family *family; /* private */
25 struct list_head list; /* private */
26 char name[GENL_NAMSIZ];
30 int genl_register_mc_group(struct genl_family *family,
31 struct genl_multicast_group *grp);
32 #endif /* linux kernel < 2.6.23 */
35 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
37 * genlmsg_msg_size - length of genetlink message not including padding
38 * @payload: length of message payload
40 static inline int genlmsg_msg_size(int payload)
42 return GENL_HDRLEN + payload;
46 * genlmsg_total_size - length of genetlink message including padding
47 * @payload: length of message payload
49 static inline int genlmsg_total_size(int payload)
51 return NLMSG_ALIGN(genlmsg_msg_size(payload));
54 #define genlmsg_multicast(s, p, g, f) \
55 genlmsg_multicast_flags((s), (p), (g), (f))
57 static inline int genlmsg_multicast_flags(struct sk_buff *skb, u32 pid,
58 unsigned int group, gfp_t flags)
62 NETLINK_CB(skb).dst_group = group;
64 err = netlink_broadcast(genl_sock, skb, pid, group, flags);
70 #endif /* linux kernel < 2.6.19 */
73 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
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)
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
87 * Returns pointer to user specific header
89 static inline void *genlmsg_put_reply(struct sk_buff *skb,
90 struct genl_info *info, struct genl_family *family,
93 return genlmsg_put(skb, info->snd_pid, info->snd_seq, family,
98 * genlmsg_reply - reply to a request
99 * @skb: netlink message to be sent back
100 * @info: receiver information
102 static inline int genlmsg_reply(struct sk_buff *skb, struct genl_info *info)
104 return genlmsg_unicast(skb, info->snd_pid);
108 * genlmsg_new - Allocate a new generic netlink message
109 * @payload: size of the message payload
110 * @flags: the type of memory to allocate.
112 static inline struct sk_buff *genlmsg_new(size_t payload, gfp_t flags)
114 return nlmsg_new(genlmsg_total_size(payload), flags);
116 #endif /* linux kernel < 2.6.20 */
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);
123 #endif /* genetlink.h */