1
2#ifndef LIBNETLINK_H
3#define LIBNETLINK_H 1
4
5#include <linux/types.h>
6
7
8#include <linux/netlink.h>
9#include <linux/rtnetlink.h>
10
11PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
12
13struct rtnl_handle {
14 int fd;
15 struct sockaddr_nl local;
16 struct sockaddr_nl peer;
17 uint32_t seq;
18 uint32_t dump;
19};
20
21extern void xrtnl_open(struct rtnl_handle *rth) FAST_FUNC;
22#define rtnl_close(rth) (close((rth)->fd))
23extern void xrtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type) FAST_FUNC;
24extern int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len) FAST_FUNC;
25extern int xrtnl_dump_filter(struct rtnl_handle *rth,
26 int (*filter)(const struct sockaddr_nl*, struct nlmsghdr *n, void*) FAST_FUNC,
27 void *arg1) FAST_FUNC;
28
29
30#define rtnl_talk(rtnl, n, peer, groups, answer, junk, jarg) \
31 rtnl_talk(rtnl, n, answer)
32extern int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
33 unsigned groups, struct nlmsghdr *answer,
34 int (*junk)(struct sockaddr_nl *,struct nlmsghdr *n, void *),
35 void *jarg) FAST_FUNC;
36
37int rtnl_send_check(struct rtnl_handle *rth, const void *buf, int len) FAST_FUNC;
38
39static ALWAYS_INLINE void rtnl_send(struct rtnl_handle *rth, const void *buf, int len)
40{
41
42
43
44
45
46
47
48
49
50
51 xwrite(rth->fd, buf, len);
52
53}
54
55extern int addattr32(struct nlmsghdr *n, int maxlen, int type, uint32_t data) FAST_FUNC;
56extern int addattr_l(struct nlmsghdr *n, int maxlen, int type, void *data, int alen) FAST_FUNC;
57extern int rta_addattr32(struct rtattr *rta, int maxlen, int type, uint32_t data) FAST_FUNC;
58extern int rta_addattr_l(struct rtattr *rta, int maxlen, int type, void *data, int alen) FAST_FUNC;
59
60extern void parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len) FAST_FUNC;
61
62POP_SAVED_FUNCTION_VISIBILITY
63
64#endif
65