blob: e149f52bf69e6bfeaf52bd293213875cad34cff3 [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
11struct rtnl_handle
12{
13 int fd;
14 struct sockaddr_nl local;
15 struct sockaddr_nl peer;
Denis Vlasenko98ee06d2006-12-31 18:57:37 +000016 uint32_t seq;
17 uint32_t dump;
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000018};
19
Bernhard Reutner-Fischerb2908892007-04-12 11:34:39 +000020extern int xrtnl_open(struct rtnl_handle *rth);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000021extern void rtnl_close(struct rtnl_handle *rth);
Bernhard Reutner-Fischerb2908892007-04-12 11:34:39 +000022extern int xrtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000023extern int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len);
Bernhard Reutner-Fischerb2908892007-04-12 11:34:39 +000024extern int xrtnl_dump_filter(struct rtnl_handle *rth,
Bernhard Reutner-Fischer921f5df2006-11-21 15:36:08 +000025 int (*filter)(struct sockaddr_nl*, struct nlmsghdr *n, void*),
Bernhard Reutner-Fischerb2908892007-04-12 11:34:39 +000026 void *arg1);
Denis Vlasenko8723a942007-12-02 06:30:57 +000027
28/* bbox doesn't use parameters no. 3, 4, 6, 7, stub them out */
29#define rtnl_talk(rtnl, n, peer, groups, answer, junk, jarg) \
30 rtnl_talk(rtnl, n, answer)
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000031extern int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
Bernhard Reutner-Fischer921f5df2006-11-21 15:36:08 +000032 unsigned groups, struct nlmsghdr *answer,
33 int (*junk)(struct sockaddr_nl *,struct nlmsghdr *n, void *),
34 void *jarg);
Denis Vlasenko8723a942007-12-02 06:30:57 +000035
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000036extern int rtnl_send(struct rtnl_handle *rth, char *buf, int);
37
38
Denis Vlasenko98ee06d2006-12-31 18:57:37 +000039extern int addattr32(struct nlmsghdr *n, int maxlen, int type, uint32_t data);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000040extern int addattr_l(struct nlmsghdr *n, int maxlen, int type, void *data, int alen);
Denis Vlasenko98ee06d2006-12-31 18:57:37 +000041extern int rta_addattr32(struct rtattr *rta, int maxlen, int type, uint32_t data);
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000042extern int rta_addattr_l(struct rtattr *rta, int maxlen, int type, void *data, int alen);
43
44extern int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len);
45
Glenn L McGrath9a2d2722002-11-10 01:33:55 +000046#endif /* __LIBNETLINK_H__ */