1#ifndef _RTNL_H
2#define _RTNL_H
3
4#include <linux/types.h>
5#include <linux/rtnetlink.h>
6
7struct rtnl_handler {
8	struct rtnl_handler *next;
9
10	u_int16_t	nlmsg_type;
11	int		(*handlefn)(struct nlmsghdr *h, void *arg);
12	void		*arg;
13};
14
15struct rtnl_handle {
16	int rtnl_fd;
17	int rtnl_seq;
18	int rtnl_dump;
19	struct sockaddr_nl rtnl_local;
20	struct rtnl_handler *handlers;
21};
22
23/* api for handler plugins */
24int rtnl_handler_register(struct rtnl_handle *rtnl_handle,
25			  struct rtnl_handler *hdlr);
26int rtnl_handler_unregister(struct rtnl_handle *rtnl_handle,
27			    struct rtnl_handler *hdlr);
28int rtnl_parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len);
29int rtnl_dump_type(struct rtnl_handle *rtnl_handle, unsigned int type);
30
31/* api for core program */
32struct rtnl_handle *rtnl_open(void);
33void rtnl_close(struct rtnl_handle *rtnl_handle);
34int rtnl_receive(struct rtnl_handle *rtnl_handle);
35int rtnl_receive_multi(struct rtnl_handle *rtnl_handle);
36
37#endif
38