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>
8 #include <linux/version.h>
9 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
11 #include <linux/genetlink.h>
14 * struct genl_multicast_group - generic netlink multicast group
15 * @name: name of the multicast group, names are per-family
16 * @id: multicast group ID, assigned by the core, to use with
17 * genlmsg_multicast().
18 * @list: list entry for linking
19 * @family: pointer to family, need not be set before registering
21 struct genl_multicast_group
23 struct genl_family *family; /* private */
24 struct list_head list; /* private */
25 char name[GENL_NAMSIZ];
29 int genl_register_mc_group(struct genl_family *family,
30 struct genl_multicast_group *grp);
31 #endif /* linux kernel < 2.6.23 */
34 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
36 * genlmsg_msg_size - length of genetlink message not including padding
37 * @payload: length of message payload
39 static inline int genlmsg_msg_size(int payload)
41 return GENL_HDRLEN + payload;
45 * genlmsg_total_size - length of genetlink message including padding
46 * @payload: length of message payload
48 static inline int genlmsg_total_size(int payload)
50 return NLMSG_ALIGN(genlmsg_msg_size(payload));
53 #define genlmsg_multicast(s, p, g, f) \
54 genlmsg_multicast_flags((s), (p), (g), (f))
56 static inline int genlmsg_multicast_flags(struct sk_buff *skb, u32 pid,
57 unsigned int group, gfp_t flags)
61 NETLINK_CB(skb).dst_group = group;
63 err = netlink_broadcast(genl_sock, skb, pid, group, flags);
69 #endif /* linux kernel < 2.6.19 */
72 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
74 #define genlmsg_put(skb, p, seq, fam, flg, c) \
75 genlmsg_put((skb), (p), (seq), (fam)->id, (fam)->hdrsize, \
76 (flg), (c), (fam)->version)
79 * genlmsg_put_reply - Add generic netlink header to a reply message
80 * @skb: socket buffer holding the message
81 * @info: receiver info
82 * @family: generic netlink family
83 * @flags: netlink message flags
84 * @cmd: generic netlink command
86 * Returns pointer to user specific header
88 static inline void *genlmsg_put_reply(struct sk_buff *skb,
89 struct genl_info *info, struct genl_family *family,
92 return genlmsg_put(skb, info->snd_pid, info->snd_seq, family,
97 * genlmsg_reply - reply to a request
98 * @skb: netlink message to be sent back
99 * @info: receiver information
101 static inline int genlmsg_reply(struct sk_buff *skb, struct genl_info *info)
103 return genlmsg_unicast(skb, info->snd_pid);
107 * genlmsg_new - Allocate a new generic netlink message
108 * @payload: size of the message payload
109 * @flags: the type of memory to allocate.
111 static inline struct sk_buff *genlmsg_new(size_t payload, gfp_t flags)
113 return nlmsg_new(genlmsg_total_size(payload), flags);
115 #endif /* linux kernel < 2.6.20 */
117 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
118 int genl_register_family_with_ops(struct genl_family *family,
119 struct genl_ops *ops, size_t n_ops);
122 #endif /* genetlink.h */