rtable.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* $OpenBSD: rtable.h,v 1.1 2015/07/18 15:51:16 mpi Exp $ */
  2. /*
  3. * Copyright (c) 2014-2015 Martin Pieuchot
  4. *
  5. * Permission to use, copy, modify, and distribute this software for any
  6. * purpose with or without fee is hereby granted, provided that the above
  7. * copyright notice and this permission notice appear in all copies.
  8. *
  9. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  10. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  11. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  12. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  13. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  14. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  15. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  16. */
  17. #ifndef _NET_RTABLE_H_
  18. #define _NET_RTABLE_H_
  19. /*
  20. * Traditional BSD routing table implementation based on a radix tree.
  21. */
  22. #include <net/radix.h>
  23. #ifndef SMALL_KERNEL
  24. #include <net/radix_mpath.h>
  25. #endif
  26. #define rt_key(rt) (((struct sockaddr *)(rt)->rt_nodes[0].rn_key))
  27. #define rt_mask(rt) (((struct sockaddr *)(rt)->rt_nodes[0].rn_mask))
  28. #define RT_ACTIVE(rt) ((rt)->rt_nodes[0].rn_flags & RNF_ACTIVE)
  29. #define RT_ROOT(rt) ((rt)->rt_nodes[0].rn_flags & RNF_ROOT)
  30. void rtable_init(void);
  31. int rtable_attach(void **, int);
  32. struct rtentry *rtable_lookup(unsigned int, struct sockaddr *,
  33. struct sockaddr *);
  34. struct rtentry *rtable_match(unsigned int, struct sockaddr *);
  35. int rtable_insert(unsigned int, struct sockaddr *,
  36. struct sockaddr *, uint8_t, struct rtentry *);
  37. int rtable_delete(unsigned int, struct sockaddr *,
  38. struct sockaddr *, uint8_t, struct rtentry *);
  39. int rtable_setid(void **, unsigned int, sa_family_t);
  40. void *rtable_get(unsigned int, sa_family_t);
  41. int rtable_walk(unsigned int, sa_family_t,
  42. int (*)(struct rtentry *, void *, unsigned int), void *);
  43. int rtable_mpath_capable(unsigned int, sa_family_t);
  44. struct rtentry *rtable_mpath_match(unsigned int, struct rtentry *,
  45. struct sockaddr *, uint8_t);
  46. int rtable_mpath_conflict(unsigned int, struct sockaddr *,
  47. struct sockaddr *, struct sockaddr *, uint8_t, int);
  48. struct rtentry *rtable_mpath_select(struct rtentry *, uint32_t *);
  49. void rtable_mpath_reprio(struct rtentry *, uint8_t);
  50. #endif /* _NET_RTABLE_H_ */