libnetlink.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /* vi: set sw=4 ts=4: */
  2. #ifndef __LIBNETLINK_H__
  3. #define __LIBNETLINK_H__ 1
  4. #include <linux/types.h>
  5. /* We need linux/types.h because older kernels use __u32 etc
  6. * in linux/[rt]netlink.h. 2.6.19 seems to be ok, though */
  7. #include <linux/netlink.h>
  8. #include <linux/rtnetlink.h>
  9. struct rtnl_handle
  10. {
  11. int fd;
  12. struct sockaddr_nl local;
  13. struct sockaddr_nl peer;
  14. uint32_t seq;
  15. uint32_t dump;
  16. };
  17. extern int rtnl_open(struct rtnl_handle *rth, unsigned subscriptions);
  18. extern void rtnl_close(struct rtnl_handle *rth);
  19. extern int rtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type);
  20. extern int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len);
  21. extern int rtnl_dump_filter(struct rtnl_handle *rth,
  22. int (*filter)(struct sockaddr_nl*, struct nlmsghdr *n, void*),
  23. void *arg1,
  24. int (*junk)(struct sockaddr_nl *, struct nlmsghdr *n, void *),
  25. void *arg2);
  26. extern int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
  27. unsigned groups, struct nlmsghdr *answer,
  28. int (*junk)(struct sockaddr_nl *,struct nlmsghdr *n, void *),
  29. void *jarg);
  30. extern int rtnl_send(struct rtnl_handle *rth, char *buf, int);
  31. extern int addattr32(struct nlmsghdr *n, int maxlen, int type, uint32_t data);
  32. extern int addattr_l(struct nlmsghdr *n, int maxlen, int type, void *data, int alen);
  33. extern int rta_addattr32(struct rtattr *rta, int maxlen, int type, uint32_t data);
  34. extern int rta_addattr_l(struct rtattr *rta, int maxlen, int type, void *data, int alen);
  35. extern int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len);
  36. #endif /* __LIBNETLINK_H__ */