1 --- a/include/linux/compat-2.6.37.h
2 +++ b/include/linux/compat-2.6.37.h
3 @@ -45,6 +45,68 @@ static inline void skb_checksum_none_ass
5 #define pcmcia_enable_device(link) pcmcia_request_configuration(link, &link->conf)
7 +#include <net/genetlink.h>
9 +struct compat_genl_info {
10 + struct genl_info *info;
14 + struct genlmsghdr *genlhdr;
15 + struct nlattr **attrs;
18 +#define genl_info compat_genl_info
20 +struct compat_genl_ops {
21 + struct genl_ops ops;
26 + const struct nla_policy *policy;
28 + int (*doit)(struct sk_buff *skb, struct genl_info *info);
29 + int (*dumpit)(struct sk_buff *skb, struct netlink_callback *cb);
30 + int (*done)(struct netlink_callback *cb);
32 +#define genl_ops compat_genl_ops
34 +struct compat_genl_family {
35 + struct genl_family family;
37 + struct list_head list;
39 + unsigned int id, hdrsize, version, maxattr;
43 + struct nlattr **attrbuf;
45 + int (*pre_doit)(struct genl_ops *ops, struct sk_buff *skb,
46 + struct genl_info *info);
48 + void (*post_doit)(struct genl_ops *ops, struct sk_buff *skb,
49 + struct genl_info *info);
52 +#define genl_family compat_genl_family
54 +#define genl_register_family_with_ops compat_genl_register_family_with_ops
56 +int genl_register_family_with_ops(struct genl_family *family,
57 + struct genl_ops *ops, size_t n_ops);
59 +#define genl_unregister_family compat_genl_unregister_family
61 +int genl_unregister_family(struct genl_family *family);
63 +#define genl_info_net(_info) genl_info_net((_info)->info)
64 +#define genlmsg_reply(_msg, _info) genlmsg_reply(_msg, (_info)->info)
65 +#define genlmsg_put(_skb, _pid, _seq, _fam, _flags, _cmd) genlmsg_put(_skb, _pid, _seq, &(_fam)->family, _flags, _cmd)
66 +#define genl_register_mc_group(_fam, _grp) genl_register_mc_group(&(_fam)->family, _grp)
67 +#define genl_unregister_mc_group(_fam, _grp) genl_unregister_mc_group(&(_fam)->family, _grp)
69 #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)) */
71 #endif /* LINUX_26_37_COMPAT_H */
72 --- a/compat/compat-2.6.37.c
73 +++ b/compat/compat-2.6.37.c
74 @@ -42,4 +42,116 @@ EXPORT_SYMBOL_GPL(net_ns_type_operations
76 #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)*/
79 +#undef genl_unregister_family
81 +static LIST_HEAD(compat_nl_fam);
83 +static struct genl_ops *genl_get_cmd(u8 cmd, struct genl_family *family)
85 + struct genl_ops *ops;
87 + list_for_each_entry(ops, &family->family.ops_list, ops.ops_list)
88 + if (ops->cmd == cmd)
95 +static int nl_doit_wrapper(struct sk_buff *skb, struct genl_info *info)
97 + struct compat_genl_info compat_info;
98 + struct genl_family *family;
99 + struct genl_ops *ops;
102 + list_for_each_entry(family, &compat_nl_fam, list) {
103 + if (family->id == info->nlhdr->nlmsg_type)
109 + ops = genl_get_cmd(info->genlhdr->cmd, family);
113 + memset(&compat_info.user_ptr, 0, sizeof(compat_info.user_ptr));
114 + compat_info.info = info;
115 +#define __copy(_field) compat_info._field = info->_field
121 + if (family->pre_doit) {
122 + err = family->pre_doit(ops, skb, &compat_info);
127 + err = ops->doit(skb, &compat_info);
129 + if (family->post_doit)
130 + family->post_doit(ops, skb, &compat_info);
135 +int compat_genl_register_family_with_ops(struct genl_family *family,
136 + struct genl_ops *ops, size_t n_ops)
140 +#define __copy(_field) family->family._field = family->_field
145 + strncpy(family->family.name, family->name, sizeof(family->family.name));
146 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32))
151 + ret = genl_register_family(&family->family);
155 + family->attrbuf = family->family.attrbuf;
156 + family->id = family->family.id;
158 + for (i = 0; i < n_ops; i++) {
159 +#define __copy(_field) ops[i].ops._field = ops[i]._field
166 + ops[i].ops.doit = nl_doit_wrapper;
167 + ret = genl_register_ops(&family->family, &ops[i].ops);
171 + list_add(&family->list, &compat_nl_fam);
176 + compat_genl_unregister_family(family);
179 +EXPORT_SYMBOL(compat_genl_register_family_with_ops);
181 +int compat_genl_unregister_family(struct genl_family *family)
184 + err = genl_unregister_family(&family->family);
185 + list_del(&family->list);
188 +EXPORT_SYMBOL(compat_genl_unregister_family);
190 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37) */