]>
git.ipfire.org Git - people/ms/mstpd.git/blob - libnetlink.h
1 #ifndef __LIBNETLINK_H__
2 #define __LIBNETLINK_H__
5 #include <linux/netlink.h>
6 #include <linux/rtnetlink.h>
11 struct sockaddr_nl local
;
12 struct sockaddr_nl peer
;
17 int rtnl_open(struct rtnl_handle
*rth
, unsigned subscriptions
);
18 int rtnl_open_byproto(struct rtnl_handle
*rth
, unsigned subscriptions
,
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
);
24 typedef int (*rtnl_filter_t
)(const struct sockaddr_nl
*, struct nlmsghdr
*n
,
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
,
31 int rtnl_send(struct rtnl_handle
*rth
, const char *buf
, int);
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
,
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
);
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
,
46 #define parse_rtattr_nested(tb, max, rta) \
47 (parse_rtattr((tb), (max), RTA_DATA(rta), RTA_PAYLOAD(rta)))
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
);
52 #define NLMSG_TAIL(nmsg) \
53 ((struct rtattr *) (((void *) (nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len)))
55 #endif /* __LIBNETLINK_H__ */