"Robert P. J. Day" | 63fc1a9 | 2006-07-02 19:47:05 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
Denis Vlasenko | f81e8db | 2009-04-09 12:35:13 +0000 | [diff] [blame] | 2 | #ifndef LIBNETLINK_H |
| 3 | #define LIBNETLINK_H 1 |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 4 | |
Denis Vlasenko | 218f2f4 | 2007-01-24 22:02:01 +0000 | [diff] [blame] | 5 | #include <linux/types.h> |
| 6 | /* We need linux/types.h because older kernels use __u32 etc |
| 7 | * in linux/[rt]netlink.h. 2.6.19 seems to be ok, though */ |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 8 | #include <linux/netlink.h> |
| 9 | #include <linux/rtnetlink.h> |
| 10 | |
Denis Vlasenko | f81e8db | 2009-04-09 12:35:13 +0000 | [diff] [blame] | 11 | PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN |
Denis Vlasenko | 98636eb | 2008-05-09 17:59:34 +0000 | [diff] [blame] | 12 | |
Denis Vlasenko | a771e7c | 2009-04-21 23:48:38 +0000 | [diff] [blame] | 13 | struct rtnl_handle { |
Denys Vlasenko | fb132e4 | 2010-10-29 11:46:52 +0200 | [diff] [blame] | 14 | int fd; |
| 15 | struct sockaddr_nl local; |
| 16 | struct sockaddr_nl peer; |
| 17 | uint32_t seq; |
| 18 | uint32_t dump; |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 19 | }; |
| 20 | |
Natanael Copa | b78ac5a | 2010-07-23 01:31:24 +0200 | [diff] [blame] | 21 | extern void xrtnl_open(struct rtnl_handle *rth) FAST_FUNC; |
| 22 | #define rtnl_close(rth) (close((rth)->fd)) |
Denis Vlasenko | 0db2c2e | 2008-06-29 06:22:40 +0000 | [diff] [blame] | 23 | extern int xrtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type) FAST_FUNC; |
| 24 | extern int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len) FAST_FUNC; |
Bernhard Reutner-Fischer | b290889 | 2007-04-12 11:34:39 +0000 | [diff] [blame] | 25 | extern int xrtnl_dump_filter(struct rtnl_handle *rth, |
Denys Vlasenko | d5f1b1b | 2009-06-05 12:06:05 +0200 | [diff] [blame] | 26 | int (*filter)(const struct sockaddr_nl*, struct nlmsghdr *n, void*) FAST_FUNC, |
| 27 | void *arg1) FAST_FUNC; |
Denis Vlasenko | 8723a94 | 2007-12-02 06:30:57 +0000 | [diff] [blame] | 28 | |
| 29 | /* bbox doesn't use parameters no. 3, 4, 6, 7, stub them out */ |
| 30 | #define rtnl_talk(rtnl, n, peer, groups, answer, junk, jarg) \ |
| 31 | rtnl_talk(rtnl, n, answer) |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 32 | extern int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer, |
Denys Vlasenko | d5f1b1b | 2009-06-05 12:06:05 +0200 | [diff] [blame] | 33 | unsigned groups, struct nlmsghdr *answer, |
| 34 | int (*junk)(struct sockaddr_nl *,struct nlmsghdr *n, void *), |
| 35 | void *jarg) FAST_FUNC; |
Denis Vlasenko | 8723a94 | 2007-12-02 06:30:57 +0000 | [diff] [blame] | 36 | |
Denis Vlasenko | 0db2c2e | 2008-06-29 06:22:40 +0000 | [diff] [blame] | 37 | extern int rtnl_send(struct rtnl_handle *rth, char *buf, int) FAST_FUNC; |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 38 | |
| 39 | |
Denis Vlasenko | 0db2c2e | 2008-06-29 06:22:40 +0000 | [diff] [blame] | 40 | extern int addattr32(struct nlmsghdr *n, int maxlen, int type, uint32_t data) FAST_FUNC; |
| 41 | extern int addattr_l(struct nlmsghdr *n, int maxlen, int type, void *data, int alen) FAST_FUNC; |
| 42 | extern int rta_addattr32(struct rtattr *rta, int maxlen, int type, uint32_t data) FAST_FUNC; |
| 43 | extern int rta_addattr_l(struct rtattr *rta, int maxlen, int type, void *data, int alen) FAST_FUNC; |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 44 | |
Natanael Copa | b78ac5a | 2010-07-23 01:31:24 +0200 | [diff] [blame] | 45 | extern void parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len) FAST_FUNC; |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 46 | |
Denis Vlasenko | f81e8db | 2009-04-09 12:35:13 +0000 | [diff] [blame] | 47 | POP_SAVED_FUNCTION_VISIBILITY |
Denis Vlasenko | 98636eb | 2008-05-09 17:59:34 +0000 | [diff] [blame] | 48 | |
Denis Vlasenko | f81e8db | 2009-04-09 12:35:13 +0000 | [diff] [blame] | 49 | #endif |