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 #define genl_notify rpl_genl_notify
48 void rpl_genl_notify(struct genl_family *family,
49 struct sk_buff *skb, struct net *net, u32 portid, u32 group,
50 struct nlmsghdr *nlh, gfp_t flags);
52 static inline void *rpl_genlmsg_put(struct sk_buff *skb, u32 portid, u32 seq,
53 struct genl_family *family, int flags, u8 cmd)
55 return genlmsg_put(skb, portid, seq, &family->compat_family, flags, cmd);
58 #define genlmsg_put rpl_genlmsg_put
60 static inline int rpl_genl_unregister_family(struct genl_family *family)
62 return genl_unregister_family(&family->compat_family);
64 #define genl_unregister_family rpl_genl_unregister_family
66 #define genl_set_err rpl_genl_set_err
67 static inline int genl_set_err(struct genl_family *family, struct net *net,
68 u32 portid, u32 group, int code)
70 #ifdef HAVE_VOID_NETLINK_SET_ERR
71 netlink_set_err(net->genl_sock, portid, group, code);
74 return netlink_set_err(net->genl_sock, portid, group, code);
78 #define genlmsg_multicast_netns rpl_genlmsg_multicast_netns
79 static inline int genlmsg_multicast_netns(struct genl_family *family,
80 struct net *net, struct sk_buff *skb,
81 u32 portid, unsigned int group, gfp_t flags)
83 return nlmsg_multicast(net->genl_sock, skb, portid, group, flags);
87 #define __genl_register_family rpl___genl_register_family
88 int rpl___genl_register_family(struct genl_family *family);
90 #define genl_register_family rpl_genl_register_family
91 static inline int rpl_genl_register_family(struct genl_family *family)
93 family->module = THIS_MODULE;
94 return rpl___genl_register_family(family);
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 */