1#include "../src/utils.h"
2
3int main(int argc, char *argv[])
4{
5	struct nl_sock *sock;
6	struct nl_msg *msg;
7	void *hdr;
8	int err;
9
10	sock = nlt_alloc_socket();
11	nlt_connect(sock, NETLINK_GENERIC);
12
13	msg = nlmsg_alloc();
14	if (msg == NULL)
15		fatal(NLE_NOMEM, "Unable to allocate netlink message");
16
17	hdr = genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, GENL_ID_CTRL,
18			  0, 0, CTRL_CMD_GETFAMILY, 1);
19	if (hdr == NULL)
20		fatal(ENOMEM, "Unable to write genl header");
21
22	if ((err = nla_put_u32(msg, CTRL_ATTR_FAMILY_ID, GENL_ID_CTRL)) < 0)
23		fatal(err, "Unable to add attribute: %s", nl_geterror(err));
24
25	if ((err = nl_send_auto_complete(sock, msg)) < 0)
26		fatal(err, "Unable to send message: %s", nl_geterror(err));
27
28	if ((err = nl_recvmsgs_default(sock)) < 0)
29		fatal(err, "Unable to receive message: %s", nl_geterror(err));
30
31	nlmsg_free(msg);
32	nl_close(sock);
33	nl_socket_free(sock);
34
35	return 0;
36}
37