summaryrefslogtreecommitdiffstats
path: root/include/libgenl.h
blob: 97281cc1103f747087c81e4c295afe057e2c7266 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __LIBGENL_H__
#define __LIBGENL_H__

#include "libnetlink.h"

#define GENL_REQUEST(_req, _bufsiz, _family, _hdrsiz, _ver, _cmd, _flags) \
struct {								\
	struct nlmsghdr		n;					\
	struct genlmsghdr	g;					\
	char			buf[NLMSG_ALIGN(_hdrsiz) + (_bufsiz)];	\
} _req = {								\
	.n = {								\
		.nlmsg_type = (_family),				\
		.nlmsg_flags = (_flags),				\
		.nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN + (_hdrsiz)),	\
	},								\
	.g = {								\
		.cmd = (_cmd),						\
		.version = (_ver),					\
	},								\
}

int genl_add_mcast_grp(struct rtnl_handle *grth, __u16 genl_family, const char *group);
int genl_resolve_family(struct rtnl_handle *grth, const char *family);
int genl_init_handle(struct rtnl_handle *grth, const char *family,
		     int *genl_family);

#endif /* __LIBGENL_H__ */