blob: 51bee2d670ece11ecf431b217070a905b7b9bfc6 [file] [log] [blame]
"Robert P. J. Day"63fc1a92006-07-02 19:47:05 +00001/* vi: set sw=4 ts=4: */
Denis Vlasenkof81e8db2009-04-09 12:35:13 +00002#ifndef LIBNETLINK_H
3#define LIBNETLINK_H 1
Glenn L McGrath9a2d2722002-11-10 01:33:55 +00004
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 Vlasenkof81e8db2009-04-09 12:35:13 +000011PUSH_AND_SET_FUNCTION_VISIBILITY_TO_HIDDEN
Denis Vlasenko98636eb2008-05-09 17:59:34 +000012
Denis Vlasenkoa771e7c2009-04-21 23:48:38 +000013struct rtnl_handle {
Denys Vlasenkofb132e42010-10-29 11:46:52 +020014 int fd;
15 struct sockaddr_nl local;
16 struct sockaddr_nl peer;
17 uint32_t seq;
18 uint32_t dump;
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000019};
20
Natanael Copab78ac5a2010-07-23 01:31:24 +020021extern void xrtnl_open(struct rtnl_handle *rth) FAST_FUNC;
22#define rtnl_close(rth) (close((rth)->fd))
Denis Vlasenko0db2c2e2008-06-29 06:22:40 +000023extern int 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;
Bernhard Reutner-Fischerb2908892007-04-12 11:34:39 +000025extern int xrtnl_dump_filter(struct rtnl_handle *rth,
Denys Vlasenkod5f1b1b2009-06-05 12:06:05 +020026 int (*filter)(const struct sockaddr_nl*, struct nlmsghdr *n, void*) FAST_FUNC,
27 void *arg1) FAST_FUNC;
Denis Vlasenko8723a942007-12-02 06:30:57 +000028
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 McGrath9a2d2722002-11-10 01:33:55 +000032extern int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
Denys Vlasenkod5f1b1b2009-06-05 12:06:05 +020033 unsigned groups, struct nlmsghdr *answer,
34 int (*junk)(struct sockaddr_nl *,struct nlmsghdr *n, void *),
35 void *jarg) FAST_FUNC;
Denis Vlasenko8723a942007-12-02 06:30:57 +000036
Denis Vlasenko0db2c2e2008-06-29 06:22:40 +000037extern int rtnl_send(struct rtnl_handle *rth, char *buf, int) FAST_FUNC;
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000038
39
Denis Vlasenko0db2c2e2008-06-29 06:22:40 +000040extern int addattr32(struct nlmsghdr *n, int maxlen, int type, uint32_t data) FAST_FUNC;
41extern int addattr_l(struct nlmsghdr *n, int maxlen, int type, void *data, int alen) FAST_FUNC;
42extern int rta_addattr32(struct rtattr *rta, int maxlen, int type, uint32_t data) FAST_FUNC;
43extern 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 +000044
Natanael Copab78ac5a2010-07-23 01:31:24 +020045extern void parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len) FAST_FUNC;
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000046
Denis Vlasenkof81e8db2009-04-09 12:35:13 +000047POP_SAVED_FUNCTION_VISIBILITY
Denis Vlasenko98636eb2008-05-09 17:59:34 +000048
Denis Vlasenkof81e8db2009-04-09 12:35:13 +000049#endif