blob: 079153b9224d86e8aabda26afc3c4af40f5a2f47 [file] [log] [blame]
"Robert P. J. Day"63fc1a92006-07-02 19:47:05 +00001/* vi: set sw=4 ts=4: */
Glenn L McGrath9a2d2722002-11-10 01:33:55 +00002#ifndef __LIBNETLINK_H__
3#define __LIBNETLINK_H__ 1
4
Denis Vlasenko218f2f42007-01-24 22:02:01 +00005#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 McGrath9a2d2722002-11-10 01:33:55 +00008#include <linux/netlink.h>
9#include <linux/rtnetlink.h>
10
Denis Vlasenko98636eb2008-05-09 17:59:34 +000011
12#if __GNUC_PREREQ(4,1)
13# pragma GCC visibility push(hidden)
14#endif
15
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000016struct rtnl_handle
17{
18 int fd;
19 struct sockaddr_nl local;
20 struct sockaddr_nl peer;
Denis Vlasenko98ee06d2006-12-31 18:57:37 +000021 uint32_t seq;
22 uint32_t dump;
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000023};
24
Denis Vlasenko0db2c2e2008-06-29 06:22:40 +000025extern int xrtnl_open(struct rtnl_handle *rth) FAST_FUNC;
26extern void rtnl_close(struct rtnl_handle *rth) FAST_FUNC;
27extern int xrtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type) FAST_FUNC;
28extern int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len) FAST_FUNC;
Bernhard Reutner-Fischerb2908892007-04-12 11:34:39 +000029extern int xrtnl_dump_filter(struct rtnl_handle *rth,
Bernhard Reutner-Fischer9de46222008-06-12 15:54:49 +000030 int (*filter)(const struct sockaddr_nl*, struct nlmsghdr *n, void*),
Denis Vlasenko0db2c2e2008-06-29 06:22:40 +000031 void *arg1) FAST_FUNC;
Denis Vlasenko8723a942007-12-02 06:30:57 +000032
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 McGrath9a2d2722002-11-10 01:33:55 +000036extern int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
Bernhard Reutner-Fischer921f5df2006-11-21 15:36:08 +000037 unsigned groups, struct nlmsghdr *answer,
38 int (*junk)(struct sockaddr_nl *,struct nlmsghdr *n, void *),
Denis Vlasenko0db2c2e2008-06-29 06:22:40 +000039 void *jarg) FAST_FUNC;
Denis Vlasenko8723a942007-12-02 06:30:57 +000040
Denis Vlasenko0db2c2e2008-06-29 06:22:40 +000041extern int rtnl_send(struct rtnl_handle *rth, char *buf, int) FAST_FUNC;
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000042
43
Denis Vlasenko0db2c2e2008-06-29 06:22:40 +000044extern int addattr32(struct nlmsghdr *n, int maxlen, int type, uint32_t data) FAST_FUNC;
45extern int addattr_l(struct nlmsghdr *n, int maxlen, int type, void *data, int alen) FAST_FUNC;
46extern int rta_addattr32(struct rtattr *rta, int maxlen, int type, uint32_t data) FAST_FUNC;
47extern int rta_addattr_l(struct rtattr *rta, int maxlen, int type, void *data, int alen) FAST_FUNC;
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000048
Denis Vlasenko0db2c2e2008-06-29 06:22:40 +000049extern int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len) FAST_FUNC;
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000050
Denis Vlasenko98636eb2008-05-09 17:59:34 +000051#if __GNUC_PREREQ(4,1)
52# pragma GCC visibility pop
53#endif
54
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000055#endif /* __LIBNETLINK_H__ */