1 #ifndef __NET_GENERIC_NETLINK_WRAPPER_H
2 #define __NET_GENERIC_NETLINK_WRAPPER_H 1
4 #include <linux/version.h>
5 #include <linux/netlink.h>
6 #include <net/net_namespace.h>
7 #include_next <net/genetlink.h>
10 * 15e473046cb6e5d18a4d0057e61d76315230382b renames pid to portid
11 * the affected structures are
12 * netlink_skb_parms::pid -> portid
13 * genl_info::snd_pid -> snd_portid
15 #if LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)
16 #define snd_portid snd_pid
20 #ifndef HAVE_GENL_NOTIFY_TAKES_FAMILY
21 struct rpl_genl_family {
22 struct genl_family compat_family;
25 char name[GENL_NAMSIZ];
30 int (*pre_doit)(const struct genl_ops *ops,
32 struct genl_info *info);
33 void (*post_doit)(const struct genl_ops *ops,
35 struct genl_info *info);
36 struct nlattr ** attrbuf; /* private */
37 const struct genl_ops * ops; /* private */
38 const struct genl_multicast_group *mcgrps; /* private */
39 unsigned int n_ops; /* private */
40 unsigned int n_mcgrps; /* private */
41 unsigned int mcgrp_offset; /* private */
42 struct list_head family_list; /* private */
43 struct module *module;
46 #define genl_family rpl_genl_family
47 static inline void *rpl_genlmsg_put(struct sk_buff *skb, u32 portid, u32 seq,
48 struct genl_family *family, int flags, u8 cmd)
50 return genlmsg_put(skb, portid, seq, &family->compat_family, flags, cmd);
53 #define genlmsg_put rpl_genlmsg_put
55 static inline int rpl_genl_unregister_family(struct genl_family *family)
57 return genl_unregister_family(&family->compat_family);
59 #define genl_unregister_family rpl_genl_unregister_family
61 #define genl_set_err rpl_genl_set_err
62 static inline int genl_set_err(struct genl_family *family, struct net *net,
63 u32 portid, u32 group, int code)
65 #ifdef HAVE_VOID_NETLINK_SET_ERR
66 netlink_set_err(net->genl_sock, portid, group, code);
69 return netlink_set_err(net->genl_sock, portid, group, code);
73 #define genlmsg_multicast_netns rpl_genlmsg_multicast_netns
74 static inline int genlmsg_multicast_netns(struct genl_family *family,
75 struct net *net, struct sk_buff *skb,
76 u32 portid, unsigned int group, gfp_t flags)
78 return nlmsg_multicast(net->genl_sock, skb, portid, group, flags);
82 #define __genl_register_family rpl___genl_register_family
83 int rpl___genl_register_family(struct genl_family *family);
85 #define genl_register_family rpl_genl_register_family
86 static inline int rpl_genl_register_family(struct genl_family *family)
88 family->module = THIS_MODULE;
89 return rpl___genl_register_family(family);
93 #ifdef HAVE_GENL_NOTIFY_TAKES_NET
94 #define genl_notify rpl_genl_notify
95 void rpl_genl_notify(struct genl_family *family, struct sk_buff *skb,
96 struct genl_info *info , u32 group, gfp_t flags);
99 #ifndef HAVE_GENL_HAS_LISTENERS
100 static inline int genl_has_listeners(struct genl_family *family,
101 struct net *net, unsigned int group)
103 #ifdef HAVE_MCGRP_OFFSET
104 if (WARN_ON_ONCE(group >= family->n_mcgrps))
106 group = family->mcgrp_offset + group;
108 return netlink_has_listeners(net->genl_sock, group);
112 #ifndef HAVE_GENL_HAS_LISTENERS_TAKES_NET
113 static inline int rpl_genl_has_listeners(struct genl_family *family,
114 struct net *net, unsigned int group)
116 #ifdef HAVE_GENL_NOTIFY_TAKES_FAMILY
117 return genl_has_listeners(family, net->genl_sock, group);
119 return genl_has_listeners(&family->compat_family, net->genl_sock, group);
123 #define genl_has_listeners rpl_genl_has_listeners
126 #endif /* HAVE_GENL_HAS_LISTENERS */
128 #ifndef HAVE_GENLMSG_PARSE
129 static inline int genlmsg_parse(const struct nlmsghdr *nlh,
130 const struct genl_family *family,
131 struct nlattr *tb[], int maxtype,
132 const struct nla_policy *policy)
134 return nlmsg_parse(nlh, family->hdrsize + GENL_HDRLEN, tb, maxtype,
139 #endif /* genetlink.h */