ospf_route.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /*
  2. * OSPF routing table.
  3. * Copyright (C) 1999, 2000 Toshiaki Takada
  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_OSPF_ROUTE_H
  23. #define _ZEBRA_OSPF_ROUTE_H
  24. #define OSPF_DESTINATION_ROUTER 1
  25. #define OSPF_DESTINATION_NETWORK 2
  26. #define OSPF_DESTINATION_DISCARD 3
  27. #define OSPF_PATH_MIN 0
  28. #define OSPF_PATH_INTRA_AREA 1
  29. #define OSPF_PATH_INTER_AREA 2
  30. #define OSPF_PATH_TYPE1_EXTERNAL 3
  31. #define OSPF_PATH_TYPE2_EXTERNAL 4
  32. #define OSPF_PATH_MAX 5
  33. /* OSPF Path. */
  34. struct ospf_path
  35. {
  36. struct in_addr nexthop;
  37. struct in_addr adv_router;
  38. unsigned int ifindex;
  39. };
  40. /* Below is the structure linked to every
  41. route node. Note that for Network routing
  42. entries a single ospf_route is kept, while
  43. for ABRs and ASBRs (Router routing entries),
  44. we link an instance of ospf_router_route
  45. where a list of paths is maintained, so
  46. nr->info is a (struct ospf_route *) for OSPF_DESTINATION_NETWORK
  47. but
  48. nr->info is a (struct ospf_router_route *) for OSPF_DESTINATION_ROUTER
  49. */
  50. struct route_standard
  51. {
  52. /* Link Sate Origin. */
  53. struct lsa_header *origin;
  54. /* Associated Area. */
  55. struct in_addr area_id; /* The area the route belongs to */
  56. /* Area Type */
  57. int external_routing;
  58. /* Optional Capability. */
  59. u_char options; /* Get from LSA header. */
  60. /* */
  61. u_char flags; /* From router-LSA */
  62. };
  63. struct route_external
  64. {
  65. /* Link State Origin. */
  66. struct ospf_lsa *origin;
  67. /* Link State Cost Type2. */
  68. u_int32_t type2_cost;
  69. /* Tag value. */
  70. u_int32_t tag;
  71. /* ASBR route. */
  72. struct ospf_route *asbr;
  73. };
  74. struct ospf_route
  75. {
  76. /* Create time. */
  77. time_t ctime;
  78. /* Modified time. */
  79. time_t mtime;
  80. /* Destination Type. */
  81. u_char type;
  82. /* Destination ID. */ /* i.e. Link State ID. */
  83. struct in_addr id;
  84. /* Address Mask. */
  85. struct in_addr mask; /* Only valid for networks. */
  86. /* Path Type. */
  87. u_char path_type;
  88. /* List of Paths. */
  89. struct list *paths;
  90. /* Link State Cost. */
  91. u_int32_t cost; /* i.e. metric. */
  92. /* Route specific info. */
  93. union
  94. {
  95. struct route_standard std;
  96. struct route_external ext;
  97. } u;
  98. };
  99. extern struct ospf_path *ospf_path_new (void);
  100. extern void ospf_path_free (struct ospf_path *);
  101. extern struct ospf_path *ospf_path_lookup (struct list *, struct ospf_path *);
  102. extern struct ospf_route *ospf_route_new (void);
  103. extern void ospf_route_free (struct ospf_route *);
  104. extern void ospf_route_delete (struct route_table *);
  105. extern void ospf_route_table_free (struct route_table *);
  106. extern void ospf_route_install (struct ospf *, struct route_table *);
  107. extern void ospf_route_table_dump (struct route_table *);
  108. extern void ospf_intra_add_router (struct route_table *, struct vertex *,
  109. struct ospf_area *);
  110. extern void ospf_intra_add_transit (struct route_table *, struct vertex *,
  111. struct ospf_area *);
  112. extern void ospf_intra_add_stub (struct route_table *,
  113. struct router_lsa_link *, struct vertex *,
  114. struct ospf_area *,
  115. int parent_is_root, int);
  116. extern int ospf_route_cmp (struct ospf *, struct ospf_route *,
  117. struct ospf_route *);
  118. extern void ospf_route_copy_nexthops (struct ospf_route *, struct list *);
  119. extern void ospf_route_copy_nexthops_from_vertex (struct ospf_route *,
  120. struct vertex *);
  121. extern void ospf_route_subst (struct route_node *, struct ospf_route *,
  122. struct ospf_route *);
  123. extern void ospf_route_add (struct route_table *, struct prefix_ipv4 *,
  124. struct ospf_route *, struct ospf_route *);
  125. extern void ospf_route_subst_nexthops (struct ospf_route *, struct list *);
  126. extern void ospf_prune_unreachable_networks (struct route_table *);
  127. extern void ospf_prune_unreachable_routers (struct route_table *);
  128. extern int ospf_add_discard_route (struct route_table *, struct ospf_area *,
  129. struct prefix_ipv4 *);
  130. extern void ospf_delete_discard_route (struct route_table *, struct prefix_ipv4 *);
  131. extern int ospf_route_match_same (struct route_table *, struct prefix_ipv4 *,
  132. struct ospf_route *);
  133. #endif /* _ZEBRA_OSPF_ROUTE_H */