]> git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/rtnl.c
github: Update for main branch
[mirror_lxc.git] / src / lxc / rtnl.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2
3 #include "config.h"
4
5 #include <errno.h>
6 #include <linux/netlink.h>
7 #include <linux/rtnetlink.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <sys/socket.h>
12 #include <unistd.h>
13
14 #include "nl.h"
15 #include "rtnl.h"
16
17 int rtnetlink_open(struct rtnl_handler *handler)
18 {
19 return netlink_open(&handler->nlh, NETLINK_ROUTE);
20 }
21
22 void rtnetlink_close(struct rtnl_handler *handler)
23 {
24 netlink_close(&handler->nlh);
25 }
26
27 #pragma GCC diagnostic push
28 #pragma GCC diagnostic ignored "-Wcast-align"
29
30 int rtnetlink_rcv(struct rtnl_handler *handler, struct rtnlmsg *rtnlmsg)
31 {
32 return netlink_rcv(&handler->nlh, (struct nlmsg *)&rtnlmsg->nlmsghdr);
33 }
34
35 int rtnetlink_send(struct rtnl_handler *handler, struct rtnlmsg *rtnlmsg)
36 {
37
38 return netlink_send(&handler->nlh, (struct nlmsg *)&rtnlmsg->nlmsghdr);
39 }
40
41 int rtnetlink_transaction(struct rtnl_handler *handler, struct rtnlmsg *request,
42 struct rtnlmsg *answer)
43 {
44 return netlink_transaction(&handler->nlh,
45 (struct nlmsg *)&request->nlmsghdr,
46 (struct nlmsg *)&answer->nlmsghdr);
47 }
48
49 #pragma GCC diagnostic pop
50
51 struct rtnlmsg *rtnlmsg_alloc(size_t size)
52 {
53 /*
54 size_t len;
55
56 len = NLMSG_LENGTH(NLMSG_ALIGN(sizeof(struct rtnlmsghdr))) + size;
57 return (struct rtnlmsg *)nlmsg_alloc(len);
58 */
59
60 return NULL;
61 }
62
63 void rtnlmsg_free(struct rtnlmsg *rtnlmsg) { free(rtnlmsg); }