1 #ifndef __LIBNETLINK_H__
2 #define __LIBNETLINK_H__ 1
5 /* needed by netlink.h, should be in there */
7 #include <linux/netlink.h>
8 #include <linux/rtnetlink.h>
13 struct sockaddr_nl local;
14 struct sockaddr_nl peer;
19 extern int rtnl_open(struct rtnl_handle *rth, unsigned subscriptions);
20 extern int rtnl_open_byproto(struct rtnl_handle *rth, unsigned subscriptions, int protocol);
21 extern void rtnl_close(struct rtnl_handle *rth);
22 extern int rtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type);
23 extern int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len);
25 typedef int (*rtnl_filter_t)(const struct sockaddr_nl *,
26 struct nlmsghdr *n, void *);
27 extern int rtnl_dump_filter(struct rtnl_handle *rth, rtnl_filter_t filter,
31 extern int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
32 unsigned groups, struct nlmsghdr *answer,
35 extern int rtnl_send(struct rtnl_handle *rth, const char *buf, int);
38 extern int addattr32(struct nlmsghdr *n, int maxlen, int type, __u32 data);
39 extern int addattr_l(struct nlmsghdr *n, int maxlen, int type, const void *data, int alen);
40 extern int addraw_l(struct nlmsghdr *n, int maxlen, const void *data, int len);
41 extern int rta_addattr32(struct rtattr *rta, int maxlen, int type, __u32 data);
42 extern int rta_addattr_l(struct rtattr *rta, int maxlen, int type, const void *data, int alen);
44 extern int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len);
45 extern int parse_rtattr_byindex(struct rtattr *tb[], int max, struct rtattr *rta, int len);
47 #define parse_rtattr_nested(tb, max, rta) \
48 (parse_rtattr((tb), (max), RTA_DATA(rta), RTA_PAYLOAD(rta)))
50 extern int rtnl_listen(struct rtnl_handle *, rtnl_filter_t handler,
52 extern int rtnl_from_file(FILE *, rtnl_filter_t handler,
55 #define NLMSG_TAIL(nmsg) \
56 ((struct rtattr *) (((void *) (nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len)))
60 ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg))))
63 #define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifaddrmsg))
68 ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifinfomsg))))
71 #define IFLA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifinfomsg))
76 ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ndmsg))))
79 #define NDA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ndmsg))
84 ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ndtmsg))))
87 #define NDTA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ndtmsg))
90 #endif /* __LIBNETLINK_H__ */