]>
Commit | Line | Data |
---|---|---|
cc73685d | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
d38dd64a | 2 | |
1160ce89 CB |
3 | #include "config.h" |
4 | ||
0ad19a3f | 5 | #include <errno.h> |
0ad19a3f | 6 | #include <linux/netlink.h> |
7 | #include <linux/rtnetlink.h> | |
d38dd64a CB |
8 | #include <stdio.h> |
9 | #include <stdlib.h> | |
10 | #include <string.h> | |
11 | #include <sys/socket.h> | |
12 | #include <unistd.h> | |
f549edcc GK |
13 | |
14 | #include "nl.h" | |
15 | #include "rtnl.h" | |
0ad19a3f | 16 | |
6822ba9b | 17 | int rtnetlink_open(struct rtnl_handler *handler) |
0ad19a3f | 18 | { |
19 | return netlink_open(&handler->nlh, NETLINK_ROUTE); | |
20 | } | |
21 | ||
6822ba9b | 22 | void rtnetlink_close(struct rtnl_handler *handler) |
0ad19a3f | 23 | { |
d16bda44 | 24 | netlink_close(&handler->nlh); |
0ad19a3f | 25 | } |
26 | ||
6ce39620 CB |
27 | #pragma GCC diagnostic push |
28 | #pragma GCC diagnostic ignored "-Wcast-align" | |
29 | ||
6822ba9b | 30 | int rtnetlink_rcv(struct rtnl_handler *handler, struct rtnlmsg *rtnlmsg) |
0ad19a3f | 31 | { |
32 | return netlink_rcv(&handler->nlh, (struct nlmsg *)&rtnlmsg->nlmsghdr); | |
33 | } | |
34 | ||
6822ba9b | 35 | int rtnetlink_send(struct rtnl_handler *handler, struct rtnlmsg *rtnlmsg) |
0ad19a3f | 36 | { |
37 | ||
38 | return netlink_send(&handler->nlh, (struct nlmsg *)&rtnlmsg->nlmsghdr); | |
39 | } | |
40 | ||
6822ba9b CB |
41 | int rtnetlink_transaction(struct rtnl_handler *handler, struct rtnlmsg *request, |
42 | struct rtnlmsg *answer) | |
0ad19a3f | 43 | { |
736da9d0 CB |
44 | return netlink_transaction(&handler->nlh, |
45 | (struct nlmsg *)&request->nlmsghdr, | |
0ad19a3f | 46 | (struct nlmsg *)&answer->nlmsghdr); |
47 | } | |
48 | ||
6ce39620 CB |
49 | #pragma GCC diagnostic pop |
50 | ||
6822ba9b | 51 | struct rtnlmsg *rtnlmsg_alloc(size_t size) |
0ad19a3f | 52 | { |
736da9d0 CB |
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 | ||
0ad19a3f | 60 | return NULL; |
61 | } | |
62 | ||
6822ba9b | 63 | void rtnlmsg_free(struct rtnlmsg *rtnlmsg) { free(rtnlmsg); } |