table.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Routing Table
  3. * Copyright (C) 1998 Kunihiro Ishiguro
  4. *
  5. * This file is part of GNU Zebra.
  6. *
  7. * GNU Zebra is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by the
  9. * Free Software Foundation; either version 2, or (at your option) any
  10. * later version.
  11. *
  12. * GNU Zebra is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with GNU Zebra; see the file COPYING. If not, write to the Free
  19. * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  20. * 02111-1307, USA.
  21. */
  22. #ifndef _ZEBRA_TABLE_H
  23. #define _ZEBRA_TABLE_H
  24. /* Routing table top structure. */
  25. struct route_table
  26. {
  27. struct route_node *top;
  28. };
  29. /* Each routing entry. */
  30. struct route_node
  31. {
  32. /* Actual prefix of this radix. */
  33. struct prefix p;
  34. /* Tree link. */
  35. struct route_table *table;
  36. struct route_node *parent;
  37. struct route_node *link[2];
  38. #define l_left link[0]
  39. #define l_right link[1]
  40. /* Lock of this radix */
  41. unsigned int lock;
  42. /* Each node of route. */
  43. void *info;
  44. /* Aggregation. */
  45. void *aggregate;
  46. };
  47. /* Prototypes. */
  48. extern struct route_table *route_table_init (void);
  49. extern void route_table_finish (struct route_table *);
  50. extern void route_unlock_node (struct route_node *node);
  51. extern void route_node_delete (struct route_node *node);
  52. extern struct route_node *route_top (struct route_table *);
  53. extern struct route_node *route_next (struct route_node *);
  54. extern struct route_node *route_next_until (struct route_node *,
  55. struct route_node *);
  56. extern struct route_node *route_node_get (struct route_table *,
  57. struct prefix *);
  58. extern struct route_node *route_node_lookup (struct route_table *,
  59. struct prefix *);
  60. extern struct route_node *route_lock_node (struct route_node *node);
  61. extern struct route_node *route_node_match (const struct route_table *,
  62. const struct prefix *);
  63. extern struct route_node *route_node_match_ipv4 (const struct route_table *,
  64. const struct in_addr *);
  65. #ifdef HAVE_IPV6
  66. extern struct route_node *route_node_match_ipv6 (const struct route_table *,
  67. const struct in6_addr *);
  68. #endif /* HAVE_IPV6 */
  69. #endif /* _ZEBRA_TABLE_H */