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