]> git.ipfire.org Git - people/ms/mstpd.git/blob - libnetlink.h
driver hooks for creating/deleting new MSTI
[people/ms/mstpd.git] / libnetlink.h
1 #ifndef __LIBNETLINK_H__
2 #define __LIBNETLINK_H__
3
4 #include <asm/types.h>
5 #include <linux/netlink.h>
6 #include <linux/rtnetlink.h>
7
8 struct rtnl_handle
9 {
10 int fd;
11 struct sockaddr_nl local;
12 struct sockaddr_nl peer;
13 __u32 seq;
14 __u32 dump;
15 };
16
17 int rtnl_open(struct rtnl_handle *rth, unsigned subscriptions);
18 int rtnl_open_byproto(struct rtnl_handle *rth, unsigned subscriptions,
19 int protocol);
20 void rtnl_close(struct rtnl_handle *rth);
21 int rtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type);
22 int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len);
23
24 typedef int (*rtnl_filter_t)(const struct sockaddr_nl *, struct nlmsghdr *n,
25 void *);
26 int rtnl_dump_filter(struct rtnl_handle *rth, rtnl_filter_t filter,
27 void *arg1, rtnl_filter_t junk, void *arg2);
28 int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
29 unsigned groups, struct nlmsghdr *answer, rtnl_filter_t junk,
30 void *jarg);
31 int rtnl_send(struct rtnl_handle *rth, const char *buf, int);
32
33 int addattr8(struct nlmsghdr *n, int maxlen, int type, __u8 data);
34 int addattr32(struct nlmsghdr *n, int maxlen, int type, __u32 data);
35 int addattr_l(struct nlmsghdr *n, int maxlen, int type, const void *data,
36 int alen);
37 int addraw_l(struct nlmsghdr *n, int maxlen, const void *data, int len);
38 int rta_addattr32(struct rtattr *rta, int maxlen, int type, __u32 data);
39 int rta_addattr_l(struct rtattr *rta, int maxlen, int type,
40 const void *data, int alen);
41
42 int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len);
43 int parse_rtattr_byindex(struct rtattr *tb[], int max, struct rtattr *rta,
44 int len);
45
46 #define parse_rtattr_nested(tb, max, rta) \
47 (parse_rtattr((tb), (max), RTA_DATA(rta), RTA_PAYLOAD(rta)))
48
49 int rtnl_listen(struct rtnl_handle *, rtnl_filter_t handler, void *jarg);
50 int rtnl_from_file(FILE *, rtnl_filter_t handler, void *jarg);
51
52 #define NLMSG_TAIL(nmsg) \
53 ((struct rtattr *) (((void *) (nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len)))
54
55 #endif /* __LIBNETLINK_H__ */