]>
git.proxmox.com Git - mirror_lxc.git/blob - src/lxc/rtnl.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
6 #include <linux/netlink.h>
7 #include <linux/rtnetlink.h>
11 #include <sys/socket.h>
17 int rtnetlink_open(struct rtnl_handler
*handler
)
19 return netlink_open(&handler
->nlh
, NETLINK_ROUTE
);
22 void rtnetlink_close(struct rtnl_handler
*handler
)
24 netlink_close(&handler
->nlh
);
27 #pragma GCC diagnostic push
28 #pragma GCC diagnostic ignored "-Wcast-align"
30 int rtnetlink_rcv(struct rtnl_handler
*handler
, struct rtnlmsg
*rtnlmsg
)
32 return netlink_rcv(&handler
->nlh
, (struct nlmsg
*)&rtnlmsg
->nlmsghdr
);
35 int rtnetlink_send(struct rtnl_handler
*handler
, struct rtnlmsg
*rtnlmsg
)
38 return netlink_send(&handler
->nlh
, (struct nlmsg
*)&rtnlmsg
->nlmsghdr
);
41 int rtnetlink_transaction(struct rtnl_handler
*handler
, struct rtnlmsg
*request
,
42 struct rtnlmsg
*answer
)
44 return netlink_transaction(&handler
->nlh
,
45 (struct nlmsg
*)&request
->nlmsghdr
,
46 (struct nlmsg
*)&answer
->nlmsghdr
);
49 #pragma GCC diagnostic pop
51 struct rtnlmsg
*rtnlmsg_alloc(size_t size
)
56 len = NLMSG_LENGTH(NLMSG_ALIGN(sizeof(struct rtnlmsghdr))) + size;
57 return (struct rtnlmsg *)nlmsg_alloc(len);
63 void rtnlmsg_free(struct rtnlmsg
*rtnlmsg
) { free(rtnlmsg
); }