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>
13 /*----------------------------------------------------------------------------
14 * In 2.6.23, registering of multicast groups was added. Our compatability
15 * layer just supports registering a single group, since that's all we
20 * struct genl_multicast_group - generic netlink multicast group
21 * @name: name of the multicast group, names are per-family
22 * @id: multicast group ID, assigned by the core, to use with
23 * genlmsg_multicast().
24 * @list: list entry for linking
25 * @family: pointer to family, need not be set before registering
27 struct genl_multicast_group
29 struct genl_family *family; /* private */
30 struct list_head list; /* private */
31 char name[GENL_NAMSIZ];
35 int genl_register_mc_group(struct genl_family *family,
36 struct genl_multicast_group *grp);
37 #endif /* linux kernel < 2.6.23 */
40 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
42 * genlmsg_msg_size - length of genetlink message not including padding
43 * @payload: length of message payload
45 static inline int genlmsg_msg_size(int payload)
47 return GENL_HDRLEN + payload;
51 * genlmsg_total_size - length of genetlink message including padding
52 * @payload: length of message payload
54 static inline int genlmsg_total_size(int payload)
56 return NLMSG_ALIGN(genlmsg_msg_size(payload));
59 #define genlmsg_multicast(s, p, g, f) \
60 genlmsg_multicast_flags((s), (p), (g), (f))
62 static inline int genlmsg_multicast_flags(struct sk_buff *skb, u32 pid,
63 unsigned int group, gfp_t flags)
67 NETLINK_CB(skb).dst_group = group;
69 err = netlink_broadcast(genl_sock, skb, pid, group, flags);
75 #endif /* linux kernel < 2.6.19 */
78 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)
80 #define genlmsg_put(skb, p, seq, fam, flg, c) \
81 genlmsg_put((skb), (p), (seq), (fam)->id, (fam)->hdrsize, \
82 (flg), (c), (fam)->version)
85 * genlmsg_put_reply - Add generic netlink header to a reply message
86 * @skb: socket buffer holding the message
87 * @info: receiver info
88 * @family: generic netlink family
89 * @flags: netlink message flags
90 * @cmd: generic netlink command
92 * Returns pointer to user specific header
94 static inline void *genlmsg_put_reply(struct sk_buff *skb,
95 struct genl_info *info, struct genl_family *family,
98 return genlmsg_put(skb, info->snd_pid, info->snd_seq, family,
103 * genlmsg_reply - reply to a request
104 * @skb: netlink message to be sent back
105 * @info: receiver information
107 static inline int genlmsg_reply(struct sk_buff *skb, struct genl_info *info)
109 return genlmsg_unicast(skb, info->snd_pid);
113 * genlmsg_new - Allocate a new generic netlink message
114 * @payload: size of the message payload
115 * @flags: the type of memory to allocate.
117 static inline struct sk_buff *genlmsg_new(size_t payload, gfp_t flags)
119 return nlmsg_new(genlmsg_total_size(payload), flags);
121 #endif /* linux kernel < 2.6.20 */
123 #endif /* genetlink.h */