summaryrefslogtreecommitdiffstats
path: root/src/rtnl.h
blob: bf018d472336a3fd755e77945325d9b652dc9f54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef _RTNL_H
#define _RTNL_H

#include <linux/types.h>
#include <linux/rtnetlink.h>

struct rtnl_handler {
	struct rtnl_handler *next;

	u_int16_t	nlmsg_type;
	int		(*handlefn)(struct nlmsghdr *h, void *arg);
	void		*arg;
};

struct rtnl_handle {
	int rtnl_fd;
	int rtnl_seq;
	int rtnl_dump;
	struct sockaddr_nl rtnl_local;
	struct rtnl_handler *handlers;
};

/* api for handler plugins */
int rtnl_handler_register(struct rtnl_handle *rtnl_handle, 
			  struct rtnl_handler *hdlr);
int rtnl_handler_unregister(struct rtnl_handle *rtnl_handle,
			    struct rtnl_handler *hdlr);
int rtnl_parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len);
int rtnl_dump_type(struct rtnl_handle *rtnl_handle, unsigned int type);

/* api for core program */
struct rtnl_handle *rtnl_open(void);
void rtnl_close(struct rtnl_handle *rtnl_handle);
int rtnl_receive(struct rtnl_handle *rtnl_handle);

#endif