nexthop.h 821 B

12345678910111213141516171819202122232425262728293031323334
  1. #ifndef __NET_NEXTHOP_H
  2. #define __NET_NEXTHOP_H
  3. #include <linux/rtnetlink.h>
  4. #include <net/netlink.h>
  5. static inline int rtnh_ok(const struct rtnexthop *rtnh, int remaining)
  6. {
  7. return remaining >= sizeof(*rtnh) &&
  8. rtnh->rtnh_len >= sizeof(*rtnh) &&
  9. rtnh->rtnh_len <= remaining;
  10. }
  11. static inline struct rtnexthop *rtnh_next(const struct rtnexthop *rtnh,
  12. int *remaining)
  13. {
  14. int totlen = NLA_ALIGN(rtnh->rtnh_len);
  15. *remaining -= totlen;
  16. return (struct rtnexthop *) ((char *) rtnh + totlen);
  17. }
  18. static inline struct nlattr *rtnh_attrs(const struct rtnexthop *rtnh)
  19. {
  20. return (struct nlattr *) ((char *) rtnh + NLA_ALIGN(sizeof(*rtnh)));
  21. }
  22. static inline int rtnh_attrlen(const struct rtnexthop *rtnh)
  23. {
  24. return rtnh->rtnh_len - NLA_ALIGN(sizeof(*rtnh));
  25. }
  26. #endif