hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Area Border Router function. |
| 3 | * Copyright (C) 2004 Yasuhiro Ohara |
| 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 |
| 19 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 20 | * Boston, MA 02111-1307, USA. |
| 21 | */ |
| 22 | |
| 23 | #include <zebra.h> |
| 24 | |
| 25 | #include "log.h" |
| 26 | #include "prefix.h" |
| 27 | #include "table.h" |
| 28 | #include "vty.h" |
| 29 | #include "linklist.h" |
| 30 | #include "command.h" |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 31 | #include "thread.h" |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 32 | |
| 33 | #include "ospf6_proto.h" |
| 34 | #include "ospf6_route.h" |
| 35 | #include "ospf6_lsa.h" |
| 36 | #include "ospf6_route.h" |
| 37 | #include "ospf6_lsdb.h" |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 38 | #include "ospf6_message.h" |
| 39 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 40 | #include "ospf6_top.h" |
| 41 | #include "ospf6_area.h" |
| 42 | #include "ospf6_interface.h" |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 43 | #include "ospf6_neighbor.h" |
| 44 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 45 | #include "ospf6_flood.h" |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 46 | #include "ospf6_intra.h" |
| 47 | #include "ospf6_abr.h" |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 48 | #include "ospf6d.h" |
| 49 | |
| 50 | unsigned char conf_debug_ospf6_abr; |
| 51 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 52 | int |
| 53 | ospf6_is_router_abr (struct ospf6 *o) |
| 54 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 55 | struct listnode *node; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 56 | struct ospf6_area *oa; |
| 57 | int area_count = 0; |
| 58 | |
| 59 | for (node = listhead (o->area_list); node; nextnode (node)) |
| 60 | { |
| 61 | oa = OSPF6_AREA (getdata (node)); |
| 62 | if (IS_AREA_ENABLED (oa)) |
| 63 | area_count++; |
| 64 | } |
| 65 | |
| 66 | if (area_count > 1) |
| 67 | return 1; |
| 68 | return 0; |
| 69 | } |
| 70 | |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 71 | void |
| 72 | ospf6_abr_enable_area (struct ospf6_area *area) |
| 73 | { |
| 74 | struct ospf6_area *oa; |
| 75 | struct ospf6_route *ro; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 76 | struct listnode *node; |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 77 | |
| 78 | for (node = listhead (area->ospf6->area_list); node; nextnode (node)) |
| 79 | { |
| 80 | oa = OSPF6_AREA (getdata (node)); |
| 81 | |
| 82 | /* update B bit for each area */ |
| 83 | OSPF6_ROUTER_LSA_SCHEDULE (oa); |
| 84 | |
| 85 | /* install other area's configured address range */ |
| 86 | if (oa != area) |
| 87 | { |
| 88 | for (ro = ospf6_route_head (oa->range_table); ro; |
| 89 | ro = ospf6_route_next (ro)) |
hasso | 4846ef6 | 2004-09-03 06:04:00 +0000 | [diff] [blame] | 90 | { |
| 91 | if (CHECK_FLAG (ro->flag, OSPF6_ROUTE_ACTIVE_SUMMARY)) |
| 92 | ospf6_abr_originate_summary_to_area (ro, area); |
| 93 | } |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 94 | } |
| 95 | } |
| 96 | |
| 97 | /* install calculated routes to border routers */ |
| 98 | for (ro = ospf6_route_head (area->ospf6->brouter_table); ro; |
| 99 | ro = ospf6_route_next (ro)) |
| 100 | ospf6_abr_originate_summary_to_area (ro, area); |
| 101 | |
| 102 | /* install calculated routes to network (may be rejected by ranges) */ |
| 103 | for (ro = ospf6_route_head (area->ospf6->route_table); ro; |
| 104 | ro = ospf6_route_next (ro)) |
| 105 | ospf6_abr_originate_summary_to_area (ro, area); |
| 106 | } |
| 107 | |
| 108 | void |
| 109 | ospf6_abr_disable_area (struct ospf6_area *area) |
| 110 | { |
| 111 | struct ospf6_area *oa; |
| 112 | struct ospf6_route *ro; |
| 113 | struct ospf6_lsa *old; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 114 | struct listnode *node; |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 115 | |
| 116 | /* Withdraw all summary prefixes previously originated */ |
| 117 | for (ro = ospf6_route_head (area->summary_prefix); ro; |
| 118 | ro = ospf6_route_next (ro)) |
| 119 | { |
| 120 | old = ospf6_lsdb_lookup (ro->path.origin.type, ro->path.origin.id, |
| 121 | area->ospf6->router_id, area->lsdb); |
| 122 | if (old) |
| 123 | ospf6_lsa_purge (old); |
| 124 | ospf6_route_remove (ro, area->summary_prefix); |
| 125 | } |
| 126 | |
| 127 | /* Withdraw all summary router-routes previously originated */ |
| 128 | for (ro = ospf6_route_head (area->summary_router); ro; |
| 129 | ro = ospf6_route_next (ro)) |
| 130 | { |
| 131 | old = ospf6_lsdb_lookup (ro->path.origin.type, ro->path.origin.id, |
| 132 | area->ospf6->router_id, area->lsdb); |
| 133 | if (old) |
| 134 | ospf6_lsa_purge (old); |
| 135 | ospf6_route_remove (ro, area->summary_router); |
| 136 | } |
| 137 | |
| 138 | /* Schedule Router-LSA for each area (ABR status may change) */ |
| 139 | for (node = listhead (area->ospf6->area_list); node; nextnode (node)) |
| 140 | { |
| 141 | oa = OSPF6_AREA (getdata (node)); |
| 142 | |
| 143 | /* update B bit for each area */ |
| 144 | OSPF6_ROUTER_LSA_SCHEDULE (oa); |
| 145 | } |
| 146 | } |
| 147 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 148 | /* RFC 2328 12.4.3. Summary-LSAs */ |
| 149 | void |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 150 | ospf6_abr_originate_summary_to_area (struct ospf6_route *route, |
| 151 | struct ospf6_area *area) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 152 | { |
| 153 | struct ospf6_lsa *lsa, *old = NULL; |
| 154 | struct ospf6_interface *oi; |
| 155 | struct ospf6_route *summary, *range = NULL; |
| 156 | struct ospf6_area *route_area; |
| 157 | char buffer[OSPF6_MAX_LSASIZE]; |
| 158 | struct ospf6_lsa_header *lsa_header; |
| 159 | caddr_t p; |
| 160 | struct ospf6_inter_prefix_lsa *prefix_lsa; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 161 | struct ospf6_inter_router_lsa *router_lsa; |
| 162 | struct ospf6_route_table *summary_table = NULL; |
| 163 | u_int16_t type; |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 164 | char buf[64]; |
| 165 | int is_debug = 0; |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 166 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 167 | if (route->type == OSPF6_DEST_TYPE_ROUTER) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 168 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 169 | if (IS_OSPF6_DEBUG_ABR || IS_OSPF6_DEBUG_ORIGINATE (INTER_ROUTER)) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 170 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 171 | is_debug++; |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 172 | inet_ntop (AF_INET, &(ADV_ROUTER_IN_PREFIX (&route->prefix)), |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 173 | buf, sizeof (buf)); |
| 174 | zlog_info ("Originating summary in area %s for ASBR %s", |
| 175 | area->name, buf); |
| 176 | } |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 177 | summary_table = area->summary_router; |
| 178 | } |
| 179 | else |
| 180 | { |
| 181 | if (IS_OSPF6_DEBUG_ABR || IS_OSPF6_DEBUG_ORIGINATE (INTER_PREFIX)) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 182 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 183 | is_debug++; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 184 | prefix2str (&route->prefix, buf, sizeof (buf)); |
| 185 | zlog_info ("Originating summary in area %s for %s", |
| 186 | area->name, buf); |
| 187 | } |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 188 | summary_table = area->summary_prefix; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 189 | } |
| 190 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 191 | summary = ospf6_route_lookup (&route->prefix, summary_table); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 192 | if (summary) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 193 | old = ospf6_lsdb_lookup (summary->path.origin.type, |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 194 | summary->path.origin.id, |
| 195 | area->ospf6->router_id, area->lsdb); |
| 196 | |
| 197 | /* if this route has just removed, remove corresponding LSA */ |
| 198 | if (CHECK_FLAG (route->flag, OSPF6_ROUTE_REMOVE)) |
| 199 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 200 | if (is_debug) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 201 | zlog_info ("The route has just removed, purge previous LSA"); |
| 202 | if (summary) |
| 203 | ospf6_route_remove (summary, summary_table); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 204 | if (old) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 205 | ospf6_lsa_purge (old); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 206 | return; |
| 207 | } |
| 208 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 209 | /* Only destination type network, range or ASBR are considered */ |
| 210 | if (route->type != OSPF6_DEST_TYPE_NETWORK && |
| 211 | route->type != OSPF6_DEST_TYPE_RANGE && |
| 212 | (route->type != OSPF6_DEST_TYPE_ROUTER || |
| 213 | ! CHECK_FLAG (route->path.router_bits, OSPF6_ROUTER_BIT_E))) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 214 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 215 | if (is_debug) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 216 | zlog_info ("Route type is none of network, range nor ASBR, withdraw"); |
| 217 | if (summary) |
| 218 | ospf6_route_remove (summary, summary_table); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 219 | if (old) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 220 | ospf6_lsa_purge (old); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 221 | return; |
| 222 | } |
| 223 | |
| 224 | /* AS External routes are never considered */ |
| 225 | if (route->path.type == OSPF6_PATH_TYPE_EXTERNAL1 || |
| 226 | route->path.type == OSPF6_PATH_TYPE_EXTERNAL2) |
| 227 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 228 | if (is_debug) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 229 | zlog_info ("Path type is external, withdraw"); |
| 230 | if (summary) |
| 231 | ospf6_route_remove (summary, summary_table); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 232 | if (old) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 233 | ospf6_lsa_purge (old); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 234 | return; |
| 235 | } |
| 236 | |
| 237 | /* do not generate if the path's area is the same as target area */ |
| 238 | if (route->path.area_id == area->area_id) |
| 239 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 240 | if (is_debug) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 241 | zlog_info ("The route is in the area itself, ignore"); |
| 242 | if (summary) |
| 243 | ospf6_route_remove (summary, summary_table); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 244 | if (old) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 245 | ospf6_lsa_purge (old); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 246 | return; |
| 247 | } |
| 248 | |
| 249 | /* do not generate if the nexthops belongs to the target area */ |
| 250 | oi = ospf6_interface_lookup_by_ifindex (route->nexthop[0].ifindex); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 251 | if (oi && oi->area && oi->area == area) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 252 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 253 | if (is_debug) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 254 | zlog_info ("The route's nexthop is in the same area, ignore"); |
| 255 | if (summary) |
| 256 | ospf6_route_remove (summary, summary_table); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 257 | if (old) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 258 | ospf6_lsa_purge (old); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 259 | return; |
| 260 | } |
| 261 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 262 | /* do not generate if the route cost is greater or equal to LSInfinity */ |
| 263 | if (route->path.cost >= LS_INFINITY) |
| 264 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 265 | if (is_debug) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 266 | zlog_info ("The cost exceeds LSInfinity, withdraw"); |
| 267 | if (summary) |
| 268 | ospf6_route_remove (summary, summary_table); |
| 269 | if (old) |
| 270 | ospf6_lsa_purge (old); |
| 271 | return; |
| 272 | } |
| 273 | |
| 274 | /* if this is a route to ASBR */ |
| 275 | if (route->type == OSPF6_DEST_TYPE_ROUTER) |
| 276 | { |
| 277 | /* Only the prefered best path is considered */ |
| 278 | if (! CHECK_FLAG (route->flag, OSPF6_ROUTE_BEST)) |
| 279 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 280 | if (is_debug) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 281 | zlog_info ("This is the secondary path to the ASBR, ignore"); |
| 282 | if (summary) |
| 283 | ospf6_route_remove (summary, summary_table); |
| 284 | if (old) |
| 285 | ospf6_lsa_purge (old); |
| 286 | return; |
| 287 | } |
| 288 | |
| 289 | /* Do not generate if the area is stub */ |
| 290 | /* XXX */ |
| 291 | } |
| 292 | |
| 293 | /* if this is an intra-area route, this may be suppressed by aggregation */ |
| 294 | if (route->type == OSPF6_DEST_TYPE_NETWORK && |
| 295 | route->path.type == OSPF6_PATH_TYPE_INTRA) |
| 296 | { |
| 297 | /* search for configured address range for the route's area */ |
| 298 | route_area = ospf6_area_lookup (route->path.area_id, area->ospf6); |
| 299 | assert (route_area); |
| 300 | range = ospf6_route_lookup_bestmatch (&route->prefix, |
| 301 | route_area->range_table); |
| 302 | |
| 303 | /* ranges are ignored when originate backbone routes to transit area. |
| 304 | Otherwise, if ranges are configured, the route is suppressed. */ |
| 305 | if (range && ! CHECK_FLAG (range->flag, OSPF6_ROUTE_REMOVE) && |
| 306 | (route->path.area_id != BACKBONE_AREA_ID || |
| 307 | ! IS_AREA_TRANSIT (area))) |
| 308 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 309 | if (is_debug) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 310 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 311 | prefix2str (&range->prefix, buf, sizeof (buf)); |
| 312 | zlog_info ("Suppressed by range %s of area %s", |
| 313 | buf, route_area->name); |
| 314 | } |
| 315 | |
| 316 | if (summary) |
| 317 | ospf6_route_remove (summary, summary_table); |
| 318 | if (old) |
| 319 | ospf6_lsa_purge (old); |
| 320 | return; |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | /* If this is a configured address range */ |
| 325 | if (route->type == OSPF6_DEST_TYPE_RANGE) |
| 326 | { |
| 327 | /* If DoNotAdvertise is set */ |
| 328 | if (CHECK_FLAG (route->flag, OSPF6_ROUTE_DO_NOT_ADVERTISE)) |
| 329 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 330 | if (is_debug) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 331 | zlog_info ("This is the range with DoNotAdvertise set. ignore"); |
| 332 | if (summary) |
| 333 | ospf6_route_remove (summary, summary_table); |
| 334 | if (old) |
| 335 | ospf6_lsa_purge (old); |
| 336 | return; |
| 337 | } |
| 338 | |
| 339 | /* Whether the route have active longer prefix */ |
| 340 | if (! CHECK_FLAG (route->flag, OSPF6_ROUTE_ACTIVE_SUMMARY)) |
| 341 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 342 | if (is_debug) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 343 | zlog_info ("The range is not active. withdraw"); |
| 344 | if (summary) |
| 345 | ospf6_route_remove (summary, summary_table); |
| 346 | if (old) |
| 347 | ospf6_lsa_purge (old); |
| 348 | return; |
| 349 | } |
| 350 | } |
| 351 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 352 | /* the route is going to be originated. store it in area's summary_table */ |
| 353 | if (summary == NULL) |
| 354 | { |
| 355 | summary = ospf6_route_copy (route); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 356 | if (route->type == OSPF6_DEST_TYPE_NETWORK || |
| 357 | route->type == OSPF6_DEST_TYPE_RANGE) |
| 358 | summary->path.origin.type = htons (OSPF6_LSTYPE_INTER_PREFIX); |
| 359 | else |
| 360 | summary->path.origin.type = htons (OSPF6_LSTYPE_INTER_ROUTER); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 361 | summary->path.origin.adv_router = area->ospf6->router_id; |
| 362 | summary->path.origin.id = |
| 363 | ospf6_new_ls_id (summary->path.origin.type, |
| 364 | summary->path.origin.adv_router, area->lsdb); |
hasso | 9428f2d | 2004-09-13 14:01:12 +0000 | [diff] [blame] | 365 | summary = ospf6_route_add (summary, summary_table); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 366 | } |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 367 | else |
| 368 | { |
| 369 | summary->type = route->type; |
| 370 | gettimeofday (&summary->changed, NULL); |
| 371 | } |
| 372 | |
| 373 | summary->path.router_bits = route->path.router_bits; |
| 374 | summary->path.options[0] = route->path.options[0]; |
| 375 | summary->path.options[1] = route->path.options[1]; |
| 376 | summary->path.options[2] = route->path.options[2]; |
| 377 | summary->path.prefix_options = route->path.prefix_options; |
| 378 | summary->path.area_id = area->area_id; |
| 379 | summary->path.type = OSPF6_PATH_TYPE_INTER; |
| 380 | summary->path.cost = route->path.cost; |
| 381 | summary->nexthop[0] = route->nexthop[0]; |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 382 | |
| 383 | /* prepare buffer */ |
| 384 | memset (buffer, 0, sizeof (buffer)); |
| 385 | lsa_header = (struct ospf6_lsa_header *) buffer; |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 386 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 387 | if (route->type == OSPF6_DEST_TYPE_ROUTER) |
| 388 | { |
| 389 | router_lsa = (struct ospf6_inter_router_lsa *) |
| 390 | ((caddr_t) lsa_header + sizeof (struct ospf6_lsa_header)); |
| 391 | p = (caddr_t) router_lsa + sizeof (struct ospf6_inter_router_lsa); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 392 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 393 | /* Fill Inter-Area-Router-LSA */ |
| 394 | router_lsa->options[0] = route->path.options[0]; |
| 395 | router_lsa->options[1] = route->path.options[1]; |
| 396 | router_lsa->options[2] = route->path.options[2]; |
| 397 | OSPF6_ABR_SUMMARY_METRIC_SET (router_lsa, route->path.cost); |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 398 | router_lsa->router_id = ADV_ROUTER_IN_PREFIX (&route->prefix); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 399 | type = htons (OSPF6_LSTYPE_INTER_ROUTER); |
| 400 | } |
| 401 | else |
| 402 | { |
| 403 | prefix_lsa = (struct ospf6_inter_prefix_lsa *) |
| 404 | ((caddr_t) lsa_header + sizeof (struct ospf6_lsa_header)); |
| 405 | p = (caddr_t) prefix_lsa + sizeof (struct ospf6_inter_prefix_lsa); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 406 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 407 | /* Fill Inter-Area-Prefix-LSA */ |
| 408 | OSPF6_ABR_SUMMARY_METRIC_SET (prefix_lsa, route->path.cost); |
| 409 | prefix_lsa->prefix.prefix_length = route->prefix.prefixlen; |
| 410 | prefix_lsa->prefix.prefix_options = route->path.prefix_options; |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 411 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 412 | /* set Prefix */ |
| 413 | memcpy (p, &route->prefix.u.prefix6, |
| 414 | OSPF6_PREFIX_SPACE (route->prefix.prefixlen)); |
| 415 | ospf6_prefix_apply_mask (&prefix_lsa->prefix); |
| 416 | p += OSPF6_PREFIX_SPACE (route->prefix.prefixlen); |
| 417 | type = htons (OSPF6_LSTYPE_INTER_PREFIX); |
| 418 | } |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 419 | |
| 420 | /* Fill LSA Header */ |
| 421 | lsa_header->age = 0; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 422 | lsa_header->type = type; |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 423 | lsa_header->id = summary->path.origin.id; |
| 424 | lsa_header->adv_router = area->ospf6->router_id; |
| 425 | lsa_header->seqnum = |
| 426 | ospf6_new_ls_seqnum (lsa_header->type, lsa_header->id, |
| 427 | lsa_header->adv_router, area->lsdb); |
| 428 | lsa_header->length = htons ((caddr_t) p - (caddr_t) lsa_header); |
| 429 | |
| 430 | /* LSA checksum */ |
| 431 | ospf6_lsa_checksum (lsa_header); |
| 432 | |
| 433 | /* create LSA */ |
| 434 | lsa = ospf6_lsa_create (lsa_header); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 435 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 436 | /* Originate */ |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 437 | ospf6_lsa_originate_area (lsa, area); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 438 | } |
| 439 | |
| 440 | void |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 441 | ospf6_abr_range_update (struct ospf6_route *range) |
| 442 | { |
| 443 | u_int32_t cost = 0; |
| 444 | struct ospf6_route *ro; |
| 445 | |
| 446 | assert (range->type == OSPF6_DEST_TYPE_RANGE); |
| 447 | |
| 448 | /* update range's cost and active flag */ |
| 449 | for (ro = ospf6_route_match_head (&range->prefix, ospf6->route_table); |
| 450 | ro; ro = ospf6_route_match_next (&range->prefix, ro)) |
| 451 | { |
| 452 | if (ro->path.area_id == range->path.area_id && |
| 453 | ! CHECK_FLAG (ro->flag, OSPF6_ROUTE_REMOVE)) |
| 454 | cost = MAX (cost, ro->path.cost); |
| 455 | } |
| 456 | |
| 457 | if (range->path.cost != cost) |
| 458 | { |
| 459 | range->path.cost = cost; |
| 460 | |
| 461 | if (range->path.cost) |
| 462 | SET_FLAG (range->flag, OSPF6_ROUTE_ACTIVE_SUMMARY); |
| 463 | else |
| 464 | UNSET_FLAG (range->flag, OSPF6_ROUTE_ACTIVE_SUMMARY); |
| 465 | |
| 466 | ospf6_abr_originate_summary (range); |
| 467 | } |
| 468 | } |
| 469 | |
| 470 | void |
| 471 | ospf6_abr_originate_summary (struct ospf6_route *route) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 472 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 473 | struct listnode *node; |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 474 | struct ospf6_area *oa; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 475 | struct ospf6_route *range = NULL; |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 476 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 477 | if (route->type == OSPF6_DEST_TYPE_NETWORK) |
| 478 | { |
| 479 | oa = ospf6_area_lookup (route->path.area_id, ospf6); |
| 480 | range = ospf6_route_lookup_bestmatch (&route->prefix, oa->range_table); |
| 481 | if (range) |
| 482 | ospf6_abr_range_update (range); |
| 483 | } |
| 484 | |
| 485 | for (node = listhead (ospf6->area_list); node; nextnode (node)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 486 | { |
| 487 | oa = (struct ospf6_area *) getdata (node); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 488 | ospf6_abr_originate_summary_to_area (route, oa); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 489 | } |
| 490 | } |
| 491 | |
| 492 | /* RFC 2328 16.2. Calculating the inter-area routes */ |
| 493 | void |
| 494 | ospf6_abr_examin_summary (struct ospf6_lsa *lsa, struct ospf6_area *oa) |
| 495 | { |
| 496 | struct prefix prefix, abr_prefix; |
| 497 | struct ospf6_route_table *table = NULL; |
| 498 | struct ospf6_route *range, *route, *old = NULL; |
| 499 | struct ospf6_route *abr_entry; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 500 | u_char type = 0; |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 501 | char options[3] = {0, 0, 0}; |
| 502 | u_int8_t prefix_options = 0; |
| 503 | u_int32_t cost = 0; |
hasso | 63069ad | 2004-09-02 13:01:01 +0000 | [diff] [blame] | 504 | u_char router_bits = 0; |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 505 | int i; |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 506 | char buf[64]; |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 507 | int is_debug = 0; |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 508 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 509 | if (lsa->header->type == htons (OSPF6_LSTYPE_INTER_PREFIX)) |
| 510 | { |
| 511 | struct ospf6_inter_prefix_lsa *prefix_lsa; |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 512 | |
| 513 | if (IS_OSPF6_DEBUG_EXAMIN (INTER_PREFIX)) |
| 514 | { |
| 515 | is_debug++; |
| 516 | zlog_info ("Examin %s in area %s", lsa->name, oa->name); |
| 517 | } |
| 518 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 519 | prefix_lsa = (struct ospf6_inter_prefix_lsa *) |
| 520 | OSPF6_LSA_HEADER_END (lsa->header); |
| 521 | prefix.family = AF_INET6; |
| 522 | prefix.prefixlen = prefix_lsa->prefix.prefix_length; |
| 523 | ospf6_prefix_in6_addr (&prefix.u.prefix6, &prefix_lsa->prefix); |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 524 | prefix2str (&prefix, buf, sizeof (buf)); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 525 | table = oa->ospf6->route_table; |
| 526 | type = OSPF6_DEST_TYPE_NETWORK; |
| 527 | prefix_options = prefix_lsa->prefix.prefix_options; |
| 528 | cost = OSPF6_ABR_SUMMARY_METRIC (prefix_lsa); |
| 529 | } |
| 530 | else if (lsa->header->type == htons (OSPF6_LSTYPE_INTER_ROUTER)) |
| 531 | { |
| 532 | struct ospf6_inter_router_lsa *router_lsa; |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 533 | |
| 534 | if (IS_OSPF6_DEBUG_EXAMIN (INTER_ROUTER)) |
| 535 | { |
| 536 | is_debug++; |
| 537 | zlog_info ("Examin %s in area %s", lsa->name, oa->name); |
| 538 | } |
| 539 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 540 | router_lsa = (struct ospf6_inter_router_lsa *) |
| 541 | OSPF6_LSA_HEADER_END (lsa->header); |
| 542 | ospf6_linkstate_prefix (router_lsa->router_id, htonl (0), &prefix); |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 543 | inet_ntop (AF_INET, &router_lsa->router_id, buf, sizeof (buf)); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 544 | table = oa->ospf6->brouter_table; |
| 545 | type = OSPF6_DEST_TYPE_ROUTER; |
| 546 | options[0] = router_lsa->options[0]; |
| 547 | options[1] = router_lsa->options[1]; |
| 548 | options[2] = router_lsa->options[2]; |
| 549 | cost = OSPF6_ABR_SUMMARY_METRIC (router_lsa); |
hasso | 63069ad | 2004-09-02 13:01:01 +0000 | [diff] [blame] | 550 | SET_FLAG (router_bits, OSPF6_ROUTER_BIT_E); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 551 | } |
| 552 | else |
| 553 | assert (0); |
| 554 | |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 555 | /* Find existing route */ |
| 556 | route = ospf6_route_lookup (&prefix, table); |
| 557 | if (route) |
| 558 | ospf6_route_lock (route); |
| 559 | while (route && ospf6_route_is_prefix (&prefix, route)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 560 | { |
| 561 | if (route->path.area_id == oa->area_id && |
| 562 | route->path.origin.type == lsa->header->type && |
| 563 | route->path.origin.id == lsa->header->id && |
| 564 | route->path.origin.adv_router == lsa->header->adv_router) |
| 565 | old = route; |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 566 | route = ospf6_route_next (route); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 567 | } |
| 568 | |
| 569 | /* (1) if cost == LSInfinity or if the LSA is MaxAge */ |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 570 | if (cost == LS_INFINITY) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 571 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 572 | if (is_debug) |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 573 | zlog_info ("cost is LS_INFINITY, ignore"); |
| 574 | if (old) |
hasso | 63069ad | 2004-09-02 13:01:01 +0000 | [diff] [blame] | 575 | ospf6_route_remove (old, table); |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 576 | return; |
| 577 | } |
| 578 | if (OSPF6_LSA_IS_MAXAGE (lsa)) |
| 579 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 580 | if (is_debug) |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 581 | zlog_info ("LSA is MaxAge, ignore"); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 582 | if (old) |
hasso | 63069ad | 2004-09-02 13:01:01 +0000 | [diff] [blame] | 583 | ospf6_route_remove (old, table); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 584 | return; |
| 585 | } |
| 586 | |
| 587 | /* (2) if the LSA is self-originated, ignore */ |
| 588 | if (lsa->header->adv_router == oa->ospf6->router_id) |
| 589 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 590 | if (is_debug) |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 591 | zlog_info ("LSA is self-originated, ignore"); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 592 | if (old) |
hasso | 63069ad | 2004-09-02 13:01:01 +0000 | [diff] [blame] | 593 | ospf6_route_remove (old, table); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 594 | return; |
| 595 | } |
| 596 | |
| 597 | /* (3) if the prefix is equal to an active configured address range */ |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 598 | if (lsa->header->type == htons (OSPF6_LSTYPE_INTER_PREFIX)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 599 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 600 | range = ospf6_route_lookup (&prefix, oa->range_table); |
| 601 | if (range) |
| 602 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 603 | if (is_debug) |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 604 | zlog_info ("Prefix is equal to address range, ignore"); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 605 | if (old) |
hasso | 63069ad | 2004-09-02 13:01:01 +0000 | [diff] [blame] | 606 | ospf6_route_remove (old, table); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 607 | return; |
| 608 | } |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 609 | } |
| 610 | |
| 611 | /* (4) if the routing table entry for the ABR does not exist */ |
| 612 | ospf6_linkstate_prefix (lsa->header->adv_router, htonl (0), &abr_prefix); |
| 613 | abr_entry = ospf6_route_lookup (&abr_prefix, oa->ospf6->brouter_table); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 614 | if (abr_entry == NULL || abr_entry->path.area_id != oa->area_id || |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 615 | CHECK_FLAG (abr_entry->flag, OSPF6_ROUTE_REMOVE) || |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 616 | ! CHECK_FLAG (abr_entry->path.router_bits, OSPF6_ROUTER_BIT_B)) |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 617 | { |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 618 | if (is_debug) |
hasso | 3b68735 | 2004-08-19 06:56:53 +0000 | [diff] [blame] | 619 | zlog_info ("ABR router entry does not exist, ignore"); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 620 | if (old) |
hasso | 63069ad | 2004-09-02 13:01:01 +0000 | [diff] [blame] | 621 | ospf6_route_remove (old, table); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 622 | return; |
| 623 | } |
| 624 | |
| 625 | /* (5),(6),(7) the path preference is handled by the sorting |
| 626 | in the routing table. Always install the path by substituting |
| 627 | old route (if any). */ |
| 628 | if (old) |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 629 | route = ospf6_route_copy (old); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 630 | else |
| 631 | route = ospf6_route_create (); |
| 632 | |
| 633 | route->type = type; |
| 634 | route->prefix = prefix; |
| 635 | route->path.origin.type = lsa->header->type; |
| 636 | route->path.origin.id = lsa->header->id; |
| 637 | route->path.origin.adv_router = lsa->header->adv_router; |
hasso | 63069ad | 2004-09-02 13:01:01 +0000 | [diff] [blame] | 638 | route->path.router_bits = router_bits; |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 639 | route->path.options[0] = options[0]; |
| 640 | route->path.options[1] = options[1]; |
| 641 | route->path.options[2] = options[2]; |
| 642 | route->path.prefix_options = prefix_options; |
| 643 | route->path.area_id = oa->area_id; |
| 644 | route->path.type = OSPF6_PATH_TYPE_INTER; |
| 645 | route->path.cost = abr_entry->path.cost + cost; |
| 646 | for (i = 0; i < OSPF6_MULTI_PATH_LIMIT; i++) |
| 647 | route->nexthop[i] = abr_entry->nexthop[i]; |
| 648 | |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 649 | if (is_debug) |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 650 | zlog_info ("Install route: %s", buf); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 651 | ospf6_route_add (route, table); |
| 652 | } |
| 653 | |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 654 | void |
| 655 | ospf6_abr_examin_brouter (u_int32_t router_id) |
| 656 | { |
| 657 | struct ospf6_lsa *lsa; |
| 658 | struct ospf6_area *oa; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 659 | struct listnode *node; |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 660 | u_int16_t type; |
| 661 | |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 662 | type = htons (OSPF6_LSTYPE_INTER_ROUTER); |
| 663 | for (node = listhead (ospf6->area_list); node; nextnode (node)) |
| 664 | { |
| 665 | oa = OSPF6_AREA (getdata (node)); |
| 666 | for (lsa = ospf6_lsdb_type_router_head (type, router_id, oa->lsdb); lsa; |
| 667 | lsa = ospf6_lsdb_type_router_next (type, router_id, lsa)) |
| 668 | ospf6_abr_examin_summary (lsa, oa); |
| 669 | } |
| 670 | |
| 671 | type = htons (OSPF6_LSTYPE_INTER_PREFIX); |
| 672 | for (node = listhead (ospf6->area_list); node; nextnode (node)) |
| 673 | { |
| 674 | oa = OSPF6_AREA (getdata (node)); |
| 675 | for (lsa = ospf6_lsdb_type_router_head (type, router_id, oa->lsdb); lsa; |
| 676 | lsa = ospf6_lsdb_type_router_next (type, router_id, lsa)) |
| 677 | ospf6_abr_examin_summary (lsa, oa); |
| 678 | } |
| 679 | } |
| 680 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 681 | |
| 682 | /* Display functions */ |
| 683 | int |
| 684 | ospf6_inter_area_prefix_lsa_show (struct vty *vty, struct ospf6_lsa *lsa) |
| 685 | { |
| 686 | struct ospf6_inter_prefix_lsa *prefix_lsa; |
| 687 | struct in6_addr in6; |
| 688 | char buf[64]; |
| 689 | |
| 690 | prefix_lsa = (struct ospf6_inter_prefix_lsa *) |
| 691 | OSPF6_LSA_HEADER_END (lsa->header); |
| 692 | |
| 693 | vty_out (vty, " Metric: %lu%s", |
| 694 | (u_long) OSPF6_ABR_SUMMARY_METRIC (prefix_lsa), VNL); |
| 695 | |
| 696 | ospf6_prefix_options_printbuf (prefix_lsa->prefix.prefix_options, |
| 697 | buf, sizeof (buf)); |
| 698 | vty_out (vty, " Prefix Options: %s%s", buf, VNL); |
| 699 | |
| 700 | ospf6_prefix_in6_addr (&in6, &prefix_lsa->prefix); |
| 701 | inet_ntop (AF_INET6, &in6, buf, sizeof (buf)); |
| 702 | vty_out (vty, " Prefix: %s/%d%s", buf, |
| 703 | prefix_lsa->prefix.prefix_length, VNL); |
| 704 | |
| 705 | return 0; |
| 706 | } |
| 707 | |
| 708 | int |
| 709 | ospf6_inter_area_router_lsa_show (struct vty *vty, struct ospf6_lsa *lsa) |
| 710 | { |
| 711 | struct ospf6_inter_router_lsa *router_lsa; |
| 712 | char buf[64]; |
| 713 | |
| 714 | router_lsa = (struct ospf6_inter_router_lsa *) |
| 715 | OSPF6_LSA_HEADER_END (lsa->header); |
| 716 | |
| 717 | ospf6_options_printbuf (router_lsa->options, buf, sizeof (buf)); |
| 718 | vty_out (vty, " Options: %s%s", buf, VNL); |
| 719 | vty_out (vty, " Metric: %lu%s", |
| 720 | (u_long) OSPF6_ABR_SUMMARY_METRIC (router_lsa), VNL); |
| 721 | inet_ntop (AF_INET, &router_lsa->router_id, buf, sizeof (buf)); |
| 722 | vty_out (vty, " Destination Router ID: %s%s", buf, VNL); |
| 723 | |
| 724 | return 0; |
| 725 | } |
| 726 | |
| 727 | /* Debug commands */ |
| 728 | DEFUN (debug_ospf6_abr, |
| 729 | debug_ospf6_abr_cmd, |
| 730 | "debug ospf6 abr", |
| 731 | DEBUG_STR |
| 732 | OSPF6_STR |
| 733 | "Debug OSPFv3 ABR function\n" |
| 734 | ) |
| 735 | { |
| 736 | OSPF6_DEBUG_ABR_ON (); |
| 737 | return CMD_SUCCESS; |
| 738 | } |
| 739 | |
| 740 | DEFUN (no_debug_ospf6_abr, |
| 741 | no_debug_ospf6_abr_cmd, |
| 742 | "no debug ospf6 abr", |
| 743 | NO_STR |
| 744 | DEBUG_STR |
| 745 | OSPF6_STR |
| 746 | "Debug OSPFv3 ABR function\n" |
| 747 | ) |
| 748 | { |
| 749 | OSPF6_DEBUG_ABR_OFF (); |
| 750 | return CMD_SUCCESS; |
| 751 | } |
| 752 | |
| 753 | int |
| 754 | config_write_ospf6_debug_abr (struct vty *vty) |
| 755 | { |
| 756 | if (IS_OSPF6_DEBUG_ABR) |
| 757 | vty_out (vty, "debug ospf6 abr%s", VNL); |
| 758 | return 0; |
| 759 | } |
| 760 | |
| 761 | void |
| 762 | install_element_ospf6_debug_abr () |
| 763 | { |
| 764 | install_element (ENABLE_NODE, &debug_ospf6_abr_cmd); |
| 765 | install_element (ENABLE_NODE, &no_debug_ospf6_abr_cmd); |
| 766 | install_element (CONFIG_NODE, &debug_ospf6_abr_cmd); |
| 767 | install_element (CONFIG_NODE, &no_debug_ospf6_abr_cmd); |
| 768 | } |
| 769 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 770 | struct ospf6_lsa_handler inter_prefix_handler = |
| 771 | { |
| 772 | OSPF6_LSTYPE_INTER_PREFIX, |
| 773 | "Inter-Prefix", |
| 774 | ospf6_inter_area_prefix_lsa_show |
| 775 | }; |
| 776 | |
| 777 | struct ospf6_lsa_handler inter_router_handler = |
| 778 | { |
| 779 | OSPF6_LSTYPE_INTER_ROUTER, |
| 780 | "Inter-Router", |
| 781 | ospf6_inter_area_router_lsa_show |
| 782 | }; |
| 783 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 784 | void |
| 785 | ospf6_abr_init () |
| 786 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 787 | ospf6_install_lsa_handler (&inter_prefix_handler); |
| 788 | ospf6_install_lsa_handler (&inter_router_handler); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 789 | } |
| 790 | |
| 791 | |