3
0

libnetlink.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. #if __GNUC_PREREQ(4,1)
  10. # pragma GCC visibility push(hidden)
  11. #endif
  12. struct rtnl_handle
  13. {
  14. int fd;
  15. struct sockaddr_nl local;
  16. struct sockaddr_nl peer;
  17. uint32_t seq;
  18. uint32_t dump;
  19. };
  20. extern int xrtnl_open(struct rtnl_handle *rth) FAST_FUNC;
  21. extern void rtnl_close(struct rtnl_handle *rth) FAST_FUNC;
  22. extern int xrtnl_wilddump_request(struct rtnl_handle *rth, int fam, int type) FAST_FUNC;
  23. extern int rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, int len) FAST_FUNC;
  24. extern int xrtnl_dump_filter(struct rtnl_handle *rth,
  25. int (*filter)(const struct sockaddr_nl*, struct nlmsghdr *n, void*),
  26. void *arg1) FAST_FUNC;
  27. /* bbox doesn't use parameters no. 3, 4, 6, 7, stub them out */
  28. #define rtnl_talk(rtnl, n, peer, groups, answer, junk, jarg) \
  29. rtnl_talk(rtnl, n, answer)
  30. extern int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
  31. unsigned groups, struct nlmsghdr *answer,
  32. int (*junk)(struct sockaddr_nl *,struct nlmsghdr *n, void *),
  33. void *jarg) FAST_FUNC;
  34. extern int rtnl_send(struct rtnl_handle *rth, char *buf, int) FAST_FUNC;
  35. extern int addattr32(struct nlmsghdr *n, int maxlen, int type, uint32_t data) FAST_FUNC;
  36. extern int addattr_l(struct nlmsghdr *n, int maxlen, int type, void *data, int alen) FAST_FUNC;
  37. extern int rta_addattr32(struct rtattr *rta, int maxlen, int type, uint32_t data) FAST_FUNC;
  38. extern int rta_addattr_l(struct rtattr *rta, int maxlen, int type, void *data, int alen) FAST_FUNC;
  39. extern int parse_rtattr(struct rtattr *tb[], int max, struct rtattr *rta, int len) FAST_FUNC;
  40. #if __GNUC_PREREQ(4,1)
  41. # pragma GCC visibility pop
  42. #endif
  43. #endif /* __LIBNETLINK_H__ */