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