3 #include <net/genetlink.h>
4 #include <linux/version.h>
6 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
7 #include <linux/mutex.h>
9 static DEFINE_MUTEX(mc_group_mutex);
11 int genl_register_mc_group(struct genl_family *family,
12 struct genl_multicast_group *grp)
14 static int next_group = GENL_FIRST_MCGROUP;
16 mutex_lock(&mc_group_mutex);
20 if (++next_group > GENL_LAST_MCGROUP)
21 next_group = GENL_FIRST_MCGROUP;
22 mutex_unlock(&mc_group_mutex);
26 #endif /* kernel < 2.6.23 */
28 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
30 * genl_register_family_with_ops - register a generic netlink family
31 * @family: generic netlink family
32 * @ops: operations to be registered
33 * @n_ops: number of elements to register
35 * Registers the specified family and operations from the specified table.
36 * Only one family may be registered with the same family name or identifier.
38 * The family id may equal GENL_ID_GENERATE causing an unique id to
39 * be automatically generated and assigned.
41 * Either a doit or dumpit callback must be specified for every registered
42 * operation or the function will fail. Only one operation structure per
43 * command identifier may be registered.
45 * See include/net/genetlink.h for more documenation on the operations
48 * This is equivalent to calling genl_register_family() followed by
49 * genl_register_ops() for every operation entry in the table taking
50 * care to unregister the family on error path.
52 * Return 0 on success or a negative error code.
54 int genl_register_family_with_ops(struct genl_family *family,
55 struct genl_ops *ops, size_t n_ops)
59 err = genl_register_family(family);
63 for (i = 0; i < n_ops; ++i, ++ops) {
64 err = genl_register_ops(family, ops);
70 genl_unregister_family(family);