"Robert P. J. Day" | 63fc1a9 | 2006-07-02 19:47:05 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 2 | #ifndef __LIBNETLINK_H__ |
| 3 | #define __LIBNETLINK_H__ 1 |
| 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 | 98636eb | 2008-05-09 17:59:34 +0000 | [diff] [blame^] | 11 | |
| 12 | #if __GNUC_PREREQ(4,1) |
| 13 | # pragma GCC visibility push(hidden) |
| 14 | #endif |
| 15 | |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 16 | struct rtnl_handle |
| 17 | { |
| 18 | int fd; |
| 19 | struct sockaddr_nl local; |
| 20 | struct sockaddr_nl peer; |
Denis Vlasenko | 98ee06d | 2006-12-31 18:57:37 +0000 | [diff] [blame] | 21 | uint32_t seq; |
| 22 | uint32_t dump; |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 23 | }; |
| 24 | |
Bernhard Reutner-Fischer | b290889 | 2007-04-12 11:34:39 +0000 | [diff] [blame] | 25 | extern int xrtnl_open(struct rtnl_handle *rth); |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 26 | extern void rtnl_close(struct rtnl_handle *rth); |
Bernhard Reutner-Fischer | b290889 | 2007-04-12 11:34:39 +0000 | [diff] [blame] | 27 | extern int xrtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type); |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 28 | extern int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len); |
Bernhard Reutner-Fischer | b290889 | 2007-04-12 11:34:39 +0000 | [diff] [blame] | 29 | extern int xrtnl_dump_filter(struct rtnl_handle *rth, |
Bernhard Reutner-Fischer | 921f5df | 2006-11-21 15:36:08 +0000 | [diff] [blame] | 30 | int (*filter)(struct sockaddr_nl*, struct nlmsghdr *n, void*), |
Bernhard Reutner-Fischer | b290889 | 2007-04-12 11:34:39 +0000 | [diff] [blame] | 31 | void *arg1); |
Denis Vlasenko | 8723a94 | 2007-12-02 06:30:57 +0000 | [diff] [blame] | 32 | |
| 33 | /* bbox doesn't use parameters no. 3, 4, 6, 7, stub them out */ |
| 34 | #define rtnl_talk(rtnl, n, peer, groups, answer, junk, jarg) \ |
| 35 | rtnl_talk(rtnl, n, answer) |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 36 | extern int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer, |
Bernhard Reutner-Fischer | 921f5df | 2006-11-21 15:36:08 +0000 | [diff] [blame] | 37 | unsigned groups, struct nlmsghdr *answer, |
| 38 | int (*junk)(struct sockaddr_nl *,struct nlmsghdr *n, void *), |
| 39 | void *jarg); |
Denis Vlasenko | 8723a94 | 2007-12-02 06:30:57 +0000 | [diff] [blame] | 40 | |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 41 | extern int rtnl_send(struct rtnl_handle *rth, char *buf, int); |
| 42 | |
| 43 | |
Denis Vlasenko | 98ee06d | 2006-12-31 18:57:37 +0000 | [diff] [blame] | 44 | extern int addattr32(struct nlmsghdr *n, int maxlen, int type, uint32_t data); |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 45 | extern int addattr_l(struct nlmsghdr *n, int maxlen, int type, void *data, int alen); |
Denis Vlasenko | 98ee06d | 2006-12-31 18:57:37 +0000 | [diff] [blame] | 46 | extern int rta_addattr32(struct rtattr *rta, int maxlen, int type, uint32_t data); |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 47 | extern int rta_addattr_l(struct rtattr *rta, int maxlen, int type, void *data, int alen); |
| 48 | |
| 49 | extern int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len); |
| 50 | |
Denis Vlasenko | 98636eb | 2008-05-09 17:59:34 +0000 | [diff] [blame^] | 51 | #if __GNUC_PREREQ(4,1) |
| 52 | # pragma GCC visibility pop |
| 53 | #endif |
| 54 | |
Glenn L McGrath | 9a2d272 | 2002-11-10 01:33:55 +0000 | [diff] [blame] | 55 | #endif /* __LIBNETLINK_H__ */ |