1 #ifndef __LIBNETLINK_H__
2 #define __LIBNETLINK_H__
6 #include <linux/netlink.h>
7 #include <linux/rtnetlink.h>
13 struct sockaddr_nl local
;
14 struct sockaddr_nl peer
;
19 int rtnl_open(struct rtnl_handle
*rth
, unsigned subscriptions
);
20 int rtnl_open_byproto(struct rtnl_handle
*rth
, unsigned subscriptions
,
22 void rtnl_close(struct rtnl_handle
*rth
);
23 int rtnl_wilddump_request(struct rtnl_handle
*rth
, int fam
, int type
);
24 int rtnl_dump_request(struct rtnl_handle
*rth
, int type
, void *req
, int len
);
26 typedef int (*rtnl_filter_t
)(const struct sockaddr_nl
*, struct nlmsghdr
*n
,
28 int rtnl_dump_filter(struct rtnl_handle
*rth
, rtnl_filter_t filter
,
29 void *arg1
, rtnl_filter_t junk
, void *arg2
);
30 int rtnl_talk(struct rtnl_handle
*rtnl
, struct nlmsghdr
*n
, pid_t peer
,
31 unsigned groups
, struct nlmsghdr
*answer
, rtnl_filter_t junk
,
33 int rtnl_send(struct rtnl_handle
*rth
, const char *buf
, int);
35 int addattr8(struct nlmsghdr
*n
, int maxlen
, int type
, __u8 data
);
36 int addattr32(struct nlmsghdr
*n
, int maxlen
, int type
, __u32 data
);
37 int addattr_l(struct nlmsghdr
*n
, int maxlen
, int type
, const void *data
,
39 int addraw_l(struct nlmsghdr
*n
, int maxlen
, const void *data
, int len
);
40 int rta_addattr8(struct rtattr
*rta
, int maxlen
, int type
, __u8 data
);
41 int rta_addattr16(struct rtattr
*rta
, int maxlen
, int type
, __u16 data
);
42 int rta_addattr32(struct rtattr
*rta
, int maxlen
, int type
, __u32 data
);
43 int rta_addattr64(struct rtattr
*rta
, int maxlen
, int type
, __u64 data
);
44 int rta_addattr_l(struct rtattr
*rta
, int maxlen
, int type
,
45 const void *data
, int alen
);
47 int parse_rtattr(struct rtattr
*tb
[], int max
, struct rtattr
*rta
, int len
);
48 int parse_rtattr_byindex(struct rtattr
*tb
[], int max
, struct rtattr
*rta
,
51 struct rtattr
*rta_nest(struct rtattr
*rta
, int maxlen
, int type
);
52 int rta_nest_end(struct rtattr
*rta
, struct rtattr
*nest
);
54 #define RTA_TAIL(rta) \
55 ((struct rtattr *) (((void *) (rta)) + \
56 RTA_ALIGN((rta)->rta_len)))
58 #define parse_rtattr_nested(tb, max, rta) \
59 (parse_rtattr((tb), (max), RTA_DATA(rta), RTA_PAYLOAD(rta)))
61 int rtnl_listen(struct rtnl_handle
*, rtnl_filter_t handler
, void *jarg
);
62 int rtnl_from_file(FILE *, rtnl_filter_t handler
, void *jarg
);
64 #define NLMSG_TAIL(nmsg) \
65 ((struct rtattr *) (((void *) (nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len)))
67 #endif /* __LIBNETLINK_H__ */