paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 1 | /* |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 2 | * Copyright (C) 2003 Yasuhiro Ohara |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 3 | * |
| 4 | * This file is part of GNU Zebra. |
| 5 | * |
| 6 | * GNU Zebra is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License as published by the |
| 8 | * Free Software Foundation; either version 2, or (at your option) any |
| 9 | * later version. |
| 10 | * |
| 11 | * GNU Zebra is distributed in the hope that it will be useful, but |
| 12 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with GNU Zebra; see the file COPYING. If not, write to the |
| 18 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 19 | * Boston, MA 02111-1307, USA. |
| 20 | */ |
| 21 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 22 | #include <zebra.h> |
| 23 | |
| 24 | #include "log.h" |
| 25 | #include "memory.h" |
| 26 | #include "linklist.h" |
| 27 | #include "thread.h" |
| 28 | #include "vty.h" |
| 29 | #include "command.h" |
| 30 | #include "if.h" |
| 31 | #include "prefix.h" |
| 32 | #include "table.h" |
hasso | 34956b3 | 2005-06-24 08:44:02 +0000 | [diff] [blame] | 33 | #include "plist.h" |
| 34 | #include "filter.h" |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 35 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 36 | #include "ospf6_proto.h" |
| 37 | #include "ospf6_lsa.h" |
| 38 | #include "ospf6_lsdb.h" |
| 39 | #include "ospf6_route.h" |
| 40 | #include "ospf6_spf.h" |
| 41 | #include "ospf6_top.h" |
| 42 | #include "ospf6_area.h" |
| 43 | #include "ospf6_interface.h" |
| 44 | #include "ospf6_intra.h" |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 45 | #include "ospf6_abr.h" |
| 46 | #include "ospf6d.h" |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 47 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 48 | int |
| 49 | ospf6_area_cmp (void *va, void *vb) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 50 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 51 | struct ospf6_area *oa = (struct ospf6_area *) va; |
| 52 | struct ospf6_area *ob = (struct ospf6_area *) vb; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 53 | return (ntohl (oa->area_id) < ntohl (ob->area_id) ? -1 : 1); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 54 | } |
| 55 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 56 | /* schedule routing table recalculation */ |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 57 | static void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 58 | ospf6_area_lsdb_hook_add (struct ospf6_lsa *lsa) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 59 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 60 | switch (ntohs (lsa->header->type)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 61 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 62 | case OSPF6_LSTYPE_ROUTER: |
| 63 | case OSPF6_LSTYPE_NETWORK: |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 64 | if (IS_OSPF6_DEBUG_EXAMIN_TYPE (lsa->header->type)) |
| 65 | { |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 66 | zlog_debug ("Examin %s", lsa->name); |
| 67 | zlog_debug ("Schedule SPF Calculation for %s", |
| 68 | OSPF6_AREA (lsa->lsdb->data)->name); |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 69 | } |
Dinesh Dutt | 3810e06 | 2013-08-24 07:54:09 +0000 | [diff] [blame] | 70 | ospf6_spf_schedule (OSPF6_PROCESS(OSPF6_AREA (lsa->lsdb->data)->ospf6)); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 71 | break; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 72 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 73 | case OSPF6_LSTYPE_INTRA_PREFIX: |
| 74 | ospf6_intra_prefix_lsa_add (lsa); |
| 75 | break; |
| 76 | |
| 77 | case OSPF6_LSTYPE_INTER_PREFIX: |
| 78 | case OSPF6_LSTYPE_INTER_ROUTER: |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 79 | ospf6_abr_examin_summary (lsa, (struct ospf6_area *) lsa->lsdb->data); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 80 | break; |
| 81 | |
| 82 | default: |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 83 | break; |
| 84 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 85 | } |
| 86 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 87 | static void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 88 | ospf6_area_lsdb_hook_remove (struct ospf6_lsa *lsa) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 89 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 90 | switch (ntohs (lsa->header->type)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 91 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 92 | case OSPF6_LSTYPE_ROUTER: |
| 93 | case OSPF6_LSTYPE_NETWORK: |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 94 | if (IS_OSPF6_DEBUG_EXAMIN_TYPE (lsa->header->type)) |
| 95 | { |
hasso | c6487d6 | 2004-12-24 06:00:11 +0000 | [diff] [blame] | 96 | zlog_debug ("LSA disappearing: %s", lsa->name); |
| 97 | zlog_debug ("Schedule SPF Calculation for %s", |
hasso | 1e05838 | 2004-09-01 21:36:14 +0000 | [diff] [blame] | 98 | OSPF6_AREA (lsa->lsdb->data)->name); |
| 99 | } |
Dinesh Dutt | 3810e06 | 2013-08-24 07:54:09 +0000 | [diff] [blame] | 100 | ospf6_spf_schedule (OSPF6_PROCESS(OSPF6_AREA (lsa->lsdb->data)->ospf6)); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 101 | break; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 102 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 103 | case OSPF6_LSTYPE_INTRA_PREFIX: |
| 104 | ospf6_intra_prefix_lsa_remove (lsa); |
| 105 | break; |
| 106 | |
| 107 | case OSPF6_LSTYPE_INTER_PREFIX: |
| 108 | case OSPF6_LSTYPE_INTER_ROUTER: |
hasso | ccb59b1 | 2004-08-25 09:10:37 +0000 | [diff] [blame] | 109 | ospf6_abr_examin_summary (lsa, (struct ospf6_area *) lsa->lsdb->data); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 110 | break; |
| 111 | |
| 112 | default: |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 113 | break; |
| 114 | } |
| 115 | } |
| 116 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 117 | static void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 118 | ospf6_area_route_hook_add (struct ospf6_route *route) |
| 119 | { |
| 120 | struct ospf6_route *copy = ospf6_route_copy (route); |
| 121 | ospf6_route_add (copy, ospf6->route_table); |
| 122 | } |
| 123 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 124 | static void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 125 | ospf6_area_route_hook_remove (struct ospf6_route *route) |
| 126 | { |
| 127 | struct ospf6_route *copy; |
| 128 | |
| 129 | copy = ospf6_route_lookup_identical (route, ospf6->route_table); |
| 130 | if (copy) |
| 131 | ospf6_route_remove (copy, ospf6->route_table); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | /* Make new area structure */ |
| 135 | struct ospf6_area * |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 136 | ospf6_area_create (u_int32_t area_id, struct ospf6 *o) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 137 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 138 | struct ospf6_area *oa; |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 139 | struct ospf6_route *route; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 140 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 141 | oa = XCALLOC (MTYPE_OSPF6_AREA, sizeof (struct ospf6_area)); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 142 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 143 | inet_ntop (AF_INET, &area_id, oa->name, sizeof (oa->name)); |
| 144 | oa->area_id = area_id; |
| 145 | oa->if_list = list_new (); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 146 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 147 | oa->lsdb = ospf6_lsdb_create (oa); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 148 | oa->lsdb->hook_add = ospf6_area_lsdb_hook_add; |
| 149 | oa->lsdb->hook_remove = ospf6_area_lsdb_hook_remove; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 150 | oa->lsdb_self = ospf6_lsdb_create (oa); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 151 | |
Paul Jakma | cf1ce25 | 2006-05-15 10:46:07 +0000 | [diff] [blame] | 152 | oa->spf_table = OSPF6_ROUTE_TABLE_CREATE (AREA, SPF_RESULTS); |
| 153 | oa->spf_table->scope = oa; |
| 154 | oa->route_table = OSPF6_ROUTE_TABLE_CREATE (AREA, ROUTES); |
| 155 | oa->route_table->scope = oa; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 156 | oa->route_table->hook_add = ospf6_area_route_hook_add; |
| 157 | oa->route_table->hook_remove = ospf6_area_route_hook_remove; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 158 | |
Paul Jakma | cf1ce25 | 2006-05-15 10:46:07 +0000 | [diff] [blame] | 159 | oa->range_table = OSPF6_ROUTE_TABLE_CREATE (AREA, PREFIX_RANGES); |
| 160 | oa->range_table->scope = oa; |
| 161 | oa->summary_prefix = OSPF6_ROUTE_TABLE_CREATE (AREA, SUMMARY_PREFIXES); |
| 162 | oa->summary_prefix->scope = oa; |
| 163 | oa->summary_router = OSPF6_ROUTE_TABLE_CREATE (AREA, SUMMARY_ROUTERS); |
| 164 | oa->summary_router->scope = oa; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 165 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 166 | /* set default options */ |
Dinesh Dutt | f41b4a0 | 2013-08-24 08:00:37 +0000 | [diff] [blame] | 167 | if (CHECK_FLAG (o->flag, OSPF6_STUB_ROUTER)) |
| 168 | { |
| 169 | OSPF6_OPT_CLEAR (oa->options, OSPF6_OPT_V6); |
| 170 | OSPF6_OPT_CLEAR (oa->options, OSPF6_OPT_R); |
| 171 | } |
| 172 | else |
| 173 | { |
| 174 | OSPF6_OPT_SET (oa->options, OSPF6_OPT_V6); |
| 175 | OSPF6_OPT_SET (oa->options, OSPF6_OPT_R); |
| 176 | } |
| 177 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 178 | OSPF6_OPT_SET (oa->options, OSPF6_OPT_E); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 179 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 180 | oa->ospf6 = o; |
| 181 | listnode_add_sort (o->area_list, oa); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 182 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 183 | /* import athoer area's routes as inter-area routes */ |
| 184 | for (route = ospf6_route_head (o->route_table); route; |
| 185 | route = ospf6_route_next (route)) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 186 | ospf6_abr_originate_summary_to_area (route, oa); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 187 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 188 | return oa; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 189 | } |
| 190 | |
| 191 | void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 192 | ospf6_area_delete (struct ospf6_area *oa) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 193 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 194 | struct listnode *n, *nnode; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 195 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 196 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 197 | ospf6_route_table_delete (oa->range_table); |
| 198 | ospf6_route_table_delete (oa->summary_prefix); |
| 199 | ospf6_route_table_delete (oa->summary_router); |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 200 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 201 | /* ospf6 interface list */ |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 202 | for (ALL_LIST_ELEMENTS (oa->if_list, n, nnode, oi)) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 203 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 204 | ospf6_interface_delete (oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 205 | } |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 206 | list_delete (oa->if_list); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 207 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 208 | ospf6_lsdb_delete (oa->lsdb); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 209 | ospf6_lsdb_delete (oa->lsdb_self); |
| 210 | |
Tom Goff | 1d19234 | 2010-11-10 13:02:38 -0800 | [diff] [blame] | 211 | ospf6_spf_table_finish (oa->spf_table); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 212 | ospf6_route_table_delete (oa->spf_table); |
| 213 | ospf6_route_table_delete (oa->route_table); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 214 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 215 | THREAD_OFF (oa->thread_spf_calculation); |
| 216 | THREAD_OFF (oa->thread_route_calculation); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 217 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 218 | listnode_delete (oa->ospf6->area_list, oa); |
| 219 | oa->ospf6 = NULL; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 220 | |
| 221 | /* free area */ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 222 | XFREE (MTYPE_OSPF6_AREA, oa); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | struct ospf6_area * |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 226 | ospf6_area_lookup (u_int32_t area_id, struct ospf6 *ospf6) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 227 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 228 | struct ospf6_area *oa; |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 229 | struct listnode *n; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 230 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 231 | for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, n, oa)) |
| 232 | if (oa->area_id == area_id) |
| 233 | return oa; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 234 | |
| 235 | return (struct ospf6_area *) NULL; |
| 236 | } |
| 237 | |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 238 | static struct ospf6_area * |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 239 | ospf6_area_get (u_int32_t area_id, struct ospf6 *o) |
| 240 | { |
| 241 | struct ospf6_area *oa; |
| 242 | oa = ospf6_area_lookup (area_id, o); |
| 243 | if (oa == NULL) |
| 244 | oa = ospf6_area_create (area_id, o); |
| 245 | return oa; |
| 246 | } |
| 247 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 248 | void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 249 | ospf6_area_enable (struct ospf6_area *oa) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 250 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 251 | struct listnode *node, *nnode; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 252 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 253 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 254 | SET_FLAG (oa->flag, OSPF6_AREA_ENABLE); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 255 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 256 | for (ALL_LIST_ELEMENTS (oa->if_list, node, nnode, oi)) |
| 257 | ospf6_interface_enable (oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | void |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 261 | ospf6_area_disable (struct ospf6_area *oa) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 262 | { |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 263 | struct listnode *node, *nnode; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 264 | struct ospf6_interface *oi; |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 265 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 266 | UNSET_FLAG (oa->flag, OSPF6_AREA_ENABLE); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 267 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 268 | for (ALL_LIST_ELEMENTS (oa->if_list, node, nnode, oi)) |
| 269 | ospf6_interface_disable (oi); |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 270 | } |
| 271 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 272 | |
| 273 | void |
| 274 | ospf6_area_show (struct vty *vty, struct ospf6_area *oa) |
| 275 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 276 | struct listnode *i; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 277 | struct ospf6_interface *oi; |
| 278 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 279 | vty_out (vty, " Area %s%s", oa->name, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 280 | vty_out (vty, " Number of Area scoped LSAs is %u%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 281 | oa->lsdb->count, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 282 | |
| 283 | vty_out (vty, " Interface attached to this area:"); |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 284 | for (ALL_LIST_ELEMENTS_RO (oa->if_list, i, oi)) |
| 285 | vty_out (vty, " %s", oi->interface->name); |
| 286 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 287 | vty_out (vty, "%s", VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 291 | #define OSPF6_CMD_AREA_LOOKUP(str, oa) \ |
| 292 | { \ |
| 293 | u_int32_t area_id = 0; \ |
| 294 | if (inet_pton (AF_INET, str, &area_id) != 1) \ |
| 295 | { \ |
| 296 | vty_out (vty, "Malformed Area-ID: %s%s", str, VNL); \ |
| 297 | return CMD_SUCCESS; \ |
| 298 | } \ |
| 299 | oa = ospf6_area_lookup (area_id, ospf6); \ |
| 300 | if (oa == NULL) \ |
| 301 | { \ |
| 302 | vty_out (vty, "No such Area: %s%s", str, VNL); \ |
| 303 | return CMD_SUCCESS; \ |
| 304 | } \ |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 305 | } |
| 306 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 307 | #define OSPF6_CMD_AREA_GET(str, oa) \ |
| 308 | { \ |
| 309 | u_int32_t area_id = 0; \ |
| 310 | if (inet_pton (AF_INET, str, &area_id) != 1) \ |
| 311 | { \ |
| 312 | vty_out (vty, "Malformed Area-ID: %s%s", str, VNL); \ |
| 313 | return CMD_SUCCESS; \ |
| 314 | } \ |
| 315 | oa = ospf6_area_get (area_id, ospf6); \ |
| 316 | } |
| 317 | |
| 318 | DEFUN (area_range, |
| 319 | area_range_cmd, |
| 320 | "area A.B.C.D range X:X::X:X/M", |
| 321 | "OSPF area parameters\n" |
| 322 | OSPF6_AREA_ID_STR |
| 323 | "Configured address range\n" |
| 324 | "Specify IPv6 prefix\n" |
| 325 | ) |
| 326 | { |
| 327 | int ret; |
| 328 | struct ospf6_area *oa; |
| 329 | struct prefix prefix; |
| 330 | struct ospf6_route *range; |
| 331 | |
| 332 | OSPF6_CMD_AREA_GET (argv[0], oa); |
| 333 | argc--; |
| 334 | argv++; |
| 335 | |
| 336 | ret = str2prefix (argv[0], &prefix); |
| 337 | if (ret != 1 || prefix.family != AF_INET6) |
| 338 | { |
| 339 | vty_out (vty, "Malformed argument: %s%s", argv[0], VNL); |
| 340 | return CMD_SUCCESS; |
| 341 | } |
| 342 | argc--; |
| 343 | argv++; |
| 344 | |
| 345 | range = ospf6_route_lookup (&prefix, oa->range_table); |
| 346 | if (range == NULL) |
| 347 | { |
| 348 | range = ospf6_route_create (); |
| 349 | range->type = OSPF6_DEST_TYPE_RANGE; |
| 350 | range->prefix = prefix; |
| 351 | } |
| 352 | |
| 353 | if (argc) |
| 354 | { |
| 355 | if (! strcmp (argv[0], "not-advertise")) |
| 356 | SET_FLAG (range->flag, OSPF6_ROUTE_DO_NOT_ADVERTISE); |
| 357 | else if (! strcmp (argv[0], "advertise")) |
| 358 | UNSET_FLAG (range->flag, OSPF6_ROUTE_DO_NOT_ADVERTISE); |
| 359 | } |
| 360 | |
Jon | 86f9e5a | 2009-02-11 17:22:03 -0800 | [diff] [blame] | 361 | if (range->rnode) |
| 362 | { |
| 363 | vty_out (vty, "Range already defined: %s%s", argv[-1], VNL); |
| 364 | return CMD_WARNING; |
| 365 | } |
| 366 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 367 | ospf6_route_add (range, oa->range_table); |
| 368 | return CMD_SUCCESS; |
| 369 | } |
| 370 | |
| 371 | ALIAS (area_range, |
| 372 | area_range_advertise_cmd, |
| 373 | "area A.B.C.D range X:X::X:X/M (advertise|not-advertise)", |
| 374 | "OSPF area parameters\n" |
| 375 | OSPF6_AREA_ID_STR |
| 376 | "Configured address range\n" |
| 377 | "Specify IPv6 prefix\n" |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 378 | ) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 379 | |
| 380 | DEFUN (no_area_range, |
| 381 | no_area_range_cmd, |
| 382 | "no area A.B.C.D range X:X::X:X/M", |
| 383 | "OSPF area parameters\n" |
| 384 | OSPF6_AREA_ID_STR |
| 385 | "Configured address range\n" |
| 386 | "Specify IPv6 prefix\n" |
| 387 | ) |
| 388 | { |
| 389 | int ret; |
| 390 | struct ospf6_area *oa; |
| 391 | struct prefix prefix; |
| 392 | struct ospf6_route *range; |
| 393 | |
| 394 | OSPF6_CMD_AREA_GET (argv[0], oa); |
| 395 | argc--; |
| 396 | argv++; |
| 397 | |
| 398 | ret = str2prefix (argv[0], &prefix); |
| 399 | if (ret != 1 || prefix.family != AF_INET6) |
| 400 | { |
| 401 | vty_out (vty, "Malformed argument: %s%s", argv[0], VNL); |
| 402 | return CMD_SUCCESS; |
| 403 | } |
| 404 | |
| 405 | range = ospf6_route_lookup (&prefix, oa->range_table); |
| 406 | if (range == NULL) |
| 407 | { |
| 408 | vty_out (vty, "Range %s does not exists.%s", argv[0], VNL); |
| 409 | return CMD_SUCCESS; |
| 410 | } |
| 411 | |
| 412 | ospf6_route_remove (range, oa->range_table); |
Dinesh Dutt | 8551e6d | 2013-10-22 17:42:18 -0700 | [diff] [blame] | 413 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 414 | return CMD_SUCCESS; |
| 415 | } |
| 416 | |
| 417 | void |
| 418 | ospf6_area_config_write (struct vty *vty) |
| 419 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 420 | struct listnode *node; |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 421 | struct ospf6_area *oa; |
| 422 | struct ospf6_route *range; |
| 423 | char buf[128]; |
| 424 | |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 425 | for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa)) |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 426 | { |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 427 | for (range = ospf6_route_head (oa->range_table); range; |
| 428 | range = ospf6_route_next (range)) |
| 429 | { |
| 430 | prefix2str (&range->prefix, buf, sizeof (buf)); |
| 431 | vty_out (vty, " area %s range %s%s", oa->name, buf, VNL); |
| 432 | } |
Jon Andersson | 5fdaa04 | 2011-09-13 15:47:14 +0400 | [diff] [blame] | 433 | if (PREFIX_NAME_IN (oa)) |
| 434 | vty_out (vty, " area %s filter-list prefix %s in%s", |
| 435 | oa->name, PREFIX_NAME_IN (oa), VNL); |
| 436 | if (PREFIX_NAME_OUT (oa)) |
| 437 | vty_out (vty, " area %s filter-list prefix %s out%s", |
| 438 | oa->name, PREFIX_NAME_OUT (oa), VNL); |
| 439 | if (IMPORT_NAME (oa)) |
| 440 | vty_out (vty, " area %s import-list %s%s", |
| 441 | oa->name, IMPORT_NAME (oa), VNL); |
| 442 | if (EXPORT_NAME (oa)) |
| 443 | vty_out (vty, " area %s export-list %s%s", |
| 444 | oa->name, EXPORT_NAME (oa), VNL); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 445 | } |
| 446 | } |
| 447 | |
hasso | 34956b3 | 2005-06-24 08:44:02 +0000 | [diff] [blame] | 448 | DEFUN (area_filter_list, |
| 449 | area_filter_list_cmd, |
| 450 | "area A.B.C.D filter-list prefix WORD (in|out)", |
| 451 | "OSPFv6 area parameters\n" |
| 452 | "OSPFv6 area ID in IP address format\n" |
| 453 | "Filter networks between OSPFv6 areas\n" |
| 454 | "Filter prefixes between OSPFv6 areas\n" |
| 455 | "Name of an IPv6 prefix-list\n" |
| 456 | "Filter networks sent to this area\n" |
| 457 | "Filter networks sent from this area\n") |
| 458 | { |
| 459 | struct ospf6_area *area; |
| 460 | struct prefix_list *plist; |
| 461 | |
| 462 | OSPF6_CMD_AREA_GET (argv[0], area); |
| 463 | argc--; |
| 464 | argv++; |
| 465 | |
Christian Hammers | 75d044d | 2011-09-12 14:23:05 +0400 | [diff] [blame] | 466 | plist = prefix_list_lookup (AFI_IP6, argv[0]); |
| 467 | if (strncmp (argv[1], "in", 2) == 0) |
hasso | 34956b3 | 2005-06-24 08:44:02 +0000 | [diff] [blame] | 468 | { |
| 469 | PREFIX_LIST_IN (area) = plist; |
| 470 | if (PREFIX_NAME_IN (area)) |
| 471 | free (PREFIX_NAME_IN (area)); |
| 472 | |
Christian Hammers | 75d044d | 2011-09-12 14:23:05 +0400 | [diff] [blame] | 473 | PREFIX_NAME_IN (area) = strdup (argv[0]); |
hasso | 34956b3 | 2005-06-24 08:44:02 +0000 | [diff] [blame] | 474 | ospf6_abr_reimport (area); |
| 475 | } |
| 476 | else |
| 477 | { |
| 478 | PREFIX_LIST_OUT (area) = plist; |
| 479 | if (PREFIX_NAME_OUT (area)) |
| 480 | free (PREFIX_NAME_OUT (area)); |
| 481 | |
Christian Hammers | 75d044d | 2011-09-12 14:23:05 +0400 | [diff] [blame] | 482 | PREFIX_NAME_OUT (area) = strdup (argv[0]); |
hasso | 34956b3 | 2005-06-24 08:44:02 +0000 | [diff] [blame] | 483 | ospf6_abr_enable_area (area); |
| 484 | } |
| 485 | |
| 486 | return CMD_SUCCESS; |
| 487 | } |
| 488 | |
| 489 | DEFUN (no_area_filter_list, |
| 490 | no_area_filter_list_cmd, |
| 491 | "no area A.B.C.D filter-list prefix WORD (in|out)", |
| 492 | NO_STR |
| 493 | "OSPFv6 area parameters\n" |
| 494 | "OSPFv6 area ID in IP address format\n" |
| 495 | "Filter networks between OSPFv6 areas\n" |
| 496 | "Filter prefixes between OSPFv6 areas\n" |
| 497 | "Name of an IPv6 prefix-list\n" |
| 498 | "Filter networks sent to this area\n" |
| 499 | "Filter networks sent from this area\n") |
| 500 | { |
| 501 | struct ospf6_area *area; |
| 502 | struct prefix_list *plist; |
| 503 | |
| 504 | OSPF6_CMD_AREA_GET (argv[0], area); |
| 505 | argc--; |
| 506 | argv++; |
| 507 | |
Christian Hammers | 75d044d | 2011-09-12 14:23:05 +0400 | [diff] [blame] | 508 | plist = prefix_list_lookup (AFI_IP6, argv[0]); |
| 509 | if (strncmp (argv[1], "in", 2) == 0) |
hasso | 34956b3 | 2005-06-24 08:44:02 +0000 | [diff] [blame] | 510 | { |
| 511 | if (PREFIX_NAME_IN (area)) |
Christian Hammers | 75d044d | 2011-09-12 14:23:05 +0400 | [diff] [blame] | 512 | if (strcmp (PREFIX_NAME_IN (area), argv[0]) != 0) |
hasso | 34956b3 | 2005-06-24 08:44:02 +0000 | [diff] [blame] | 513 | return CMD_SUCCESS; |
| 514 | |
| 515 | PREFIX_LIST_IN (area) = NULL; |
| 516 | if (PREFIX_NAME_IN (area)) |
| 517 | free (PREFIX_NAME_IN (area)); |
| 518 | |
| 519 | PREFIX_NAME_IN (area) = NULL; |
| 520 | ospf6_abr_reimport (area); |
| 521 | } |
| 522 | else |
| 523 | { |
| 524 | if (PREFIX_NAME_OUT (area)) |
Christian Hammers | 75d044d | 2011-09-12 14:23:05 +0400 | [diff] [blame] | 525 | if (strcmp (PREFIX_NAME_OUT (area), argv[0]) != 0) |
hasso | 34956b3 | 2005-06-24 08:44:02 +0000 | [diff] [blame] | 526 | return CMD_SUCCESS; |
| 527 | |
| 528 | PREFIX_LIST_OUT (area) = NULL; |
| 529 | if (PREFIX_NAME_OUT (area)) |
| 530 | free (PREFIX_NAME_OUT (area)); |
| 531 | |
| 532 | PREFIX_NAME_OUT (area) = NULL; |
| 533 | ospf6_abr_enable_area (area); |
| 534 | } |
| 535 | |
| 536 | return CMD_SUCCESS; |
| 537 | } |
| 538 | |
| 539 | DEFUN (area_import_list, |
| 540 | area_import_list_cmd, |
| 541 | "area A.B.C.D import-list NAME", |
| 542 | "OSPFv6 area parameters\n" |
| 543 | "OSPFv6 area ID in IP address format\n" |
| 544 | "Set the filter for networks from other areas announced to the specified one\n" |
| 545 | "Name of the acess-list\n") |
| 546 | { |
| 547 | struct ospf6_area *area; |
| 548 | struct access_list *list; |
| 549 | |
| 550 | OSPF6_CMD_AREA_GET(argv[0], area); |
| 551 | |
| 552 | list = access_list_lookup (AFI_IP6, argv[1]); |
| 553 | |
| 554 | IMPORT_LIST (area) = list; |
| 555 | |
| 556 | if (IMPORT_NAME (area)) |
| 557 | free (IMPORT_NAME (area)); |
| 558 | |
| 559 | IMPORT_NAME (area) = strdup (argv[1]); |
| 560 | ospf6_abr_reimport (area); |
| 561 | |
| 562 | return CMD_SUCCESS; |
| 563 | } |
| 564 | |
| 565 | DEFUN (no_area_import_list, |
| 566 | no_area_import_list_cmd, |
| 567 | "no area A.B.C.D import-list NAME", |
| 568 | "OSPFv6 area parameters\n" |
| 569 | "OSPFv6 area ID in IP address format\n" |
| 570 | "Unset the filter for networks announced to other areas\n" |
| 571 | "NAme of the access-list\n") |
| 572 | { |
| 573 | struct ospf6_area *area; |
| 574 | |
| 575 | OSPF6_CMD_AREA_GET(argv[0], area); |
| 576 | |
| 577 | IMPORT_LIST (area) = 0; |
| 578 | |
| 579 | if (IMPORT_NAME (area)) |
| 580 | free (IMPORT_NAME (area)); |
| 581 | |
| 582 | IMPORT_NAME (area) = NULL; |
| 583 | ospf6_abr_reimport (area); |
| 584 | |
| 585 | return CMD_SUCCESS; |
| 586 | } |
| 587 | |
| 588 | DEFUN (area_export_list, |
| 589 | area_export_list_cmd, |
| 590 | "area A.B.C.D export-list NAME", |
| 591 | "OSPFv6 area parameters\n" |
| 592 | "OSPFv6 area ID in IP address format\n" |
| 593 | "Set the filter for networks announced to other areas\n" |
| 594 | "Name of the acess-list\n") |
| 595 | { |
| 596 | struct ospf6_area *area; |
| 597 | struct access_list *list; |
| 598 | |
| 599 | OSPF6_CMD_AREA_GET(argv[0], area); |
| 600 | |
| 601 | list = access_list_lookup (AFI_IP6, argv[1]); |
| 602 | |
| 603 | EXPORT_LIST (area) = list; |
| 604 | |
| 605 | if (EXPORT_NAME (area)) |
| 606 | free (EXPORT_NAME (area)); |
| 607 | |
| 608 | EXPORT_NAME (area) = strdup (argv[1]); |
| 609 | ospf6_abr_enable_area (area); |
| 610 | |
| 611 | return CMD_SUCCESS; |
| 612 | } |
| 613 | |
| 614 | DEFUN (no_area_export_list, |
| 615 | no_area_export_list_cmd, |
| 616 | "no area A.B.C.D export-list NAME", |
| 617 | "OSPFv6 area parameters\n" |
| 618 | "OSPFv6 area ID in IP address format\n" |
| 619 | "Unset the filter for networks announced to other areas\n" |
| 620 | "Name of the access-list\n") |
| 621 | { |
| 622 | struct ospf6_area *area; |
| 623 | |
| 624 | OSPF6_CMD_AREA_GET(argv[0], area); |
| 625 | |
| 626 | EXPORT_LIST (area) = 0; |
| 627 | |
| 628 | if (EXPORT_NAME (area)) |
| 629 | free (EXPORT_NAME (area)); |
| 630 | |
| 631 | EXPORT_NAME (area) = NULL; |
| 632 | ospf6_abr_enable_area (area); |
| 633 | |
| 634 | return CMD_SUCCESS; |
| 635 | } |
| 636 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 637 | DEFUN (show_ipv6_ospf6_spf_tree, |
| 638 | show_ipv6_ospf6_spf_tree_cmd, |
| 639 | "show ipv6 ospf6 spf tree", |
| 640 | SHOW_STR |
| 641 | IP6_STR |
| 642 | OSPF6_STR |
| 643 | "Shortest Path First caculation\n" |
| 644 | "Show SPF tree\n") |
| 645 | { |
hasso | 52dc7ee | 2004-09-23 19:18:23 +0000 | [diff] [blame] | 646 | struct listnode *node; |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 647 | struct ospf6_area *oa; |
| 648 | struct ospf6_vertex *root; |
| 649 | struct ospf6_route *route; |
| 650 | struct prefix prefix; |
| 651 | |
| 652 | ospf6_linkstate_prefix (ospf6->router_id, htonl (0), &prefix); |
paul | 1eb8ef2 | 2005-04-07 07:30:20 +0000 | [diff] [blame] | 653 | |
| 654 | for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa)) |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 655 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 656 | route = ospf6_route_lookup (&prefix, oa->spf_table); |
| 657 | if (route == NULL) |
| 658 | { |
| 659 | vty_out (vty, "LS entry for root not found in area %s%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 660 | oa->name, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 661 | continue; |
| 662 | } |
| 663 | root = (struct ospf6_vertex *) route->route_option; |
| 664 | ospf6_spf_display_subtree (vty, "", 0, root); |
| 665 | } |
| 666 | |
| 667 | return CMD_SUCCESS; |
| 668 | } |
| 669 | |
| 670 | DEFUN (show_ipv6_ospf6_area_spf_tree, |
| 671 | show_ipv6_ospf6_area_spf_tree_cmd, |
| 672 | "show ipv6 ospf6 area A.B.C.D spf tree", |
| 673 | SHOW_STR |
| 674 | IP6_STR |
| 675 | OSPF6_STR |
| 676 | OSPF6_AREA_STR |
| 677 | OSPF6_AREA_ID_STR |
| 678 | "Shortest Path First caculation\n" |
| 679 | "Show SPF tree\n") |
| 680 | { |
| 681 | u_int32_t area_id; |
| 682 | struct ospf6_area *oa; |
| 683 | struct ospf6_vertex *root; |
| 684 | struct ospf6_route *route; |
| 685 | struct prefix prefix; |
| 686 | |
| 687 | ospf6_linkstate_prefix (ospf6->router_id, htonl (0), &prefix); |
| 688 | |
| 689 | if (inet_pton (AF_INET, argv[0], &area_id) != 1) |
| 690 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 691 | vty_out (vty, "Malformed Area-ID: %s%s", argv[0], VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 692 | return CMD_SUCCESS; |
| 693 | } |
| 694 | oa = ospf6_area_lookup (area_id, ospf6); |
| 695 | if (oa == NULL) |
| 696 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 697 | vty_out (vty, "No such Area: %s%s", argv[0], VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 698 | return CMD_SUCCESS; |
| 699 | } |
| 700 | |
| 701 | route = ospf6_route_lookup (&prefix, oa->spf_table); |
| 702 | if (route == NULL) |
| 703 | { |
| 704 | vty_out (vty, "LS entry for root not found in area %s%s", |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 705 | oa->name, VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 706 | return CMD_SUCCESS; |
| 707 | } |
| 708 | root = (struct ospf6_vertex *) route->route_option; |
| 709 | ospf6_spf_display_subtree (vty, "", 0, root); |
| 710 | |
| 711 | return CMD_SUCCESS; |
| 712 | } |
| 713 | |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 714 | DEFUN (show_ipv6_ospf6_simulate_spf_tree_root, |
| 715 | show_ipv6_ospf6_simulate_spf_tree_root_cmd, |
| 716 | "show ipv6 ospf6 simulate spf-tree A.B.C.D area A.B.C.D", |
| 717 | SHOW_STR |
| 718 | IP6_STR |
| 719 | OSPF6_STR |
| 720 | "Shortest Path First caculation\n" |
| 721 | "Show SPF tree\n" |
| 722 | "Specify root's router-id to calculate another router's SPF tree\n") |
| 723 | { |
| 724 | u_int32_t area_id; |
| 725 | struct ospf6_area *oa; |
| 726 | struct ospf6_vertex *root; |
| 727 | struct ospf6_route *route; |
| 728 | struct prefix prefix; |
| 729 | u_int32_t router_id; |
| 730 | struct ospf6_route_table *spf_table; |
| 731 | unsigned char tmp_debug_ospf6_spf = 0; |
| 732 | |
| 733 | inet_pton (AF_INET, argv[0], &router_id); |
| 734 | ospf6_linkstate_prefix (router_id, htonl (0), &prefix); |
| 735 | |
| 736 | if (inet_pton (AF_INET, argv[1], &area_id) != 1) |
| 737 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 738 | vty_out (vty, "Malformed Area-ID: %s%s", argv[1], VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 739 | return CMD_SUCCESS; |
| 740 | } |
| 741 | oa = ospf6_area_lookup (area_id, ospf6); |
| 742 | if (oa == NULL) |
| 743 | { |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 744 | vty_out (vty, "No such Area: %s%s", argv[1], VNL); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 745 | return CMD_SUCCESS; |
| 746 | } |
| 747 | |
| 748 | tmp_debug_ospf6_spf = conf_debug_ospf6_spf; |
| 749 | conf_debug_ospf6_spf = 0; |
| 750 | |
Paul Jakma | cf1ce25 | 2006-05-15 10:46:07 +0000 | [diff] [blame] | 751 | spf_table = OSPF6_ROUTE_TABLE_CREATE (NONE, SPF_RESULTS); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 752 | ospf6_spf_calculation (router_id, spf_table, oa); |
| 753 | |
| 754 | conf_debug_ospf6_spf = tmp_debug_ospf6_spf; |
| 755 | |
| 756 | route = ospf6_route_lookup (&prefix, spf_table); |
| 757 | if (route == NULL) |
| 758 | { |
| 759 | ospf6_spf_table_finish (spf_table); |
| 760 | ospf6_route_table_delete (spf_table); |
| 761 | return CMD_SUCCESS; |
| 762 | } |
| 763 | root = (struct ospf6_vertex *) route->route_option; |
| 764 | ospf6_spf_display_subtree (vty, "", 0, root); |
| 765 | |
| 766 | ospf6_spf_table_finish (spf_table); |
| 767 | ospf6_route_table_delete (spf_table); |
| 768 | |
| 769 | return CMD_SUCCESS; |
| 770 | } |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 771 | |
| 772 | void |
Paul Jakma | 6ac29a5 | 2008-08-15 13:45:30 +0100 | [diff] [blame] | 773 | ospf6_area_init (void) |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 774 | { |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 775 | install_element (VIEW_NODE, &show_ipv6_ospf6_spf_tree_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 776 | install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_tree_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 777 | install_element (VIEW_NODE, &show_ipv6_ospf6_simulate_spf_tree_root_cmd); |
| 778 | |
| 779 | install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_tree_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 780 | install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_tree_cmd); |
hasso | 508e53e | 2004-05-18 18:57:06 +0000 | [diff] [blame] | 781 | install_element (ENABLE_NODE, &show_ipv6_ospf6_simulate_spf_tree_root_cmd); |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 782 | |
| 783 | install_element (OSPF6_NODE, &area_range_cmd); |
| 784 | install_element (OSPF6_NODE, &area_range_advertise_cmd); |
| 785 | install_element (OSPF6_NODE, &no_area_range_cmd); |
hasso | 34956b3 | 2005-06-24 08:44:02 +0000 | [diff] [blame] | 786 | |
| 787 | install_element (OSPF6_NODE, &area_import_list_cmd); |
| 788 | install_element (OSPF6_NODE, &no_area_import_list_cmd); |
| 789 | install_element (OSPF6_NODE, &area_export_list_cmd); |
| 790 | install_element (OSPF6_NODE, &no_area_export_list_cmd); |
| 791 | |
| 792 | install_element (OSPF6_NODE, &area_filter_list_cmd); |
| 793 | install_element (OSPF6_NODE, &no_area_filter_list_cmd); |
| 794 | |
paul | 718e374 | 2002-12-13 20:15:29 +0000 | [diff] [blame] | 795 | } |
hasso | 049207c | 2004-08-04 20:02:13 +0000 | [diff] [blame] | 796 | |
hasso | 6452df0 | 2004-08-15 05:52:07 +0000 | [diff] [blame] | 797 | |