blob: 9368defe8bc0092160f365fe283910f4e95defbc [file] [log] [blame]
paul718e3742002-12-13 20:15:29 +00001/*
hasso508e53e2004-05-18 18:57:06 +00002 * Copyright (C) 2003 Yasuhiro Ohara
paul718e3742002-12-13 20:15:29 +00003 *
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
hasso508e53e2004-05-18 18:57:06 +000022#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"
hasso34956b32005-06-24 08:44:02 +000033#include "plist.h"
34#include "filter.h"
hasso508e53e2004-05-18 18:57:06 +000035
hasso508e53e2004-05-18 18:57:06 +000036#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"
hasso049207c2004-08-04 20:02:13 +000045#include "ospf6_abr.h"
46#include "ospf6d.h"
paul718e3742002-12-13 20:15:29 +000047
hasso508e53e2004-05-18 18:57:06 +000048int
49ospf6_area_cmp (void *va, void *vb)
paul718e3742002-12-13 20:15:29 +000050{
hasso508e53e2004-05-18 18:57:06 +000051 struct ospf6_area *oa = (struct ospf6_area *) va;
52 struct ospf6_area *ob = (struct ospf6_area *) vb;
hasso6452df02004-08-15 05:52:07 +000053 return (ntohl (oa->area_id) < ntohl (ob->area_id) ? -1 : 1);
paul718e3742002-12-13 20:15:29 +000054}
55
hasso508e53e2004-05-18 18:57:06 +000056/* schedule routing table recalculation */
paul718e3742002-12-13 20:15:29 +000057void
hasso508e53e2004-05-18 18:57:06 +000058ospf6_area_lsdb_hook_add (struct ospf6_lsa *lsa)
paul718e3742002-12-13 20:15:29 +000059{
hasso508e53e2004-05-18 18:57:06 +000060 switch (ntohs (lsa->header->type))
paul718e3742002-12-13 20:15:29 +000061 {
hasso508e53e2004-05-18 18:57:06 +000062 case OSPF6_LSTYPE_ROUTER:
63 case OSPF6_LSTYPE_NETWORK:
hasso1e058382004-09-01 21:36:14 +000064 if (IS_OSPF6_DEBUG_EXAMIN_TYPE (lsa->header->type))
65 {
hassoc6487d62004-12-24 06:00:11 +000066 zlog_debug ("Examin %s", lsa->name);
67 zlog_debug ("Schedule SPF Calculation for %s",
68 OSPF6_AREA (lsa->lsdb->data)->name);
hasso1e058382004-09-01 21:36:14 +000069 }
hasso6452df02004-08-15 05:52:07 +000070 ospf6_spf_schedule (OSPF6_AREA (lsa->lsdb->data));
hasso508e53e2004-05-18 18:57:06 +000071 break;
paul718e3742002-12-13 20:15:29 +000072
hasso508e53e2004-05-18 18:57:06 +000073 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:
hassoccb59b12004-08-25 09:10:37 +000079 ospf6_abr_examin_summary (lsa, (struct ospf6_area *) lsa->lsdb->data);
hasso508e53e2004-05-18 18:57:06 +000080 break;
81
82 default:
hasso508e53e2004-05-18 18:57:06 +000083 break;
84 }
paul718e3742002-12-13 20:15:29 +000085}
86
87void
hasso508e53e2004-05-18 18:57:06 +000088ospf6_area_lsdb_hook_remove (struct ospf6_lsa *lsa)
paul718e3742002-12-13 20:15:29 +000089{
hasso508e53e2004-05-18 18:57:06 +000090 switch (ntohs (lsa->header->type))
paul718e3742002-12-13 20:15:29 +000091 {
hasso508e53e2004-05-18 18:57:06 +000092 case OSPF6_LSTYPE_ROUTER:
93 case OSPF6_LSTYPE_NETWORK:
hasso1e058382004-09-01 21:36:14 +000094 if (IS_OSPF6_DEBUG_EXAMIN_TYPE (lsa->header->type))
95 {
hassoc6487d62004-12-24 06:00:11 +000096 zlog_debug ("LSA disappearing: %s", lsa->name);
97 zlog_debug ("Schedule SPF Calculation for %s",
hasso1e058382004-09-01 21:36:14 +000098 OSPF6_AREA (lsa->lsdb->data)->name);
99 }
hasso6452df02004-08-15 05:52:07 +0000100 ospf6_spf_schedule (OSPF6_AREA (lsa->lsdb->data));
hasso508e53e2004-05-18 18:57:06 +0000101 break;
paul718e3742002-12-13 20:15:29 +0000102
hasso508e53e2004-05-18 18:57:06 +0000103 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:
hassoccb59b12004-08-25 09:10:37 +0000109 ospf6_abr_examin_summary (lsa, (struct ospf6_area *) lsa->lsdb->data);
hasso508e53e2004-05-18 18:57:06 +0000110 break;
111
112 default:
hasso508e53e2004-05-18 18:57:06 +0000113 break;
114 }
115}
116
117void
118ospf6_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
124void
125ospf6_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);
paul718e3742002-12-13 20:15:29 +0000132}
133
134/* Make new area structure */
135struct ospf6_area *
hasso508e53e2004-05-18 18:57:06 +0000136ospf6_area_create (u_int32_t area_id, struct ospf6 *o)
paul718e3742002-12-13 20:15:29 +0000137{
hasso508e53e2004-05-18 18:57:06 +0000138 struct ospf6_area *oa;
hasso049207c2004-08-04 20:02:13 +0000139 struct ospf6_route *route;
paul718e3742002-12-13 20:15:29 +0000140
hasso508e53e2004-05-18 18:57:06 +0000141 oa = XCALLOC (MTYPE_OSPF6_AREA, sizeof (struct ospf6_area));
paul718e3742002-12-13 20:15:29 +0000142
hasso508e53e2004-05-18 18:57:06 +0000143 inet_ntop (AF_INET, &area_id, oa->name, sizeof (oa->name));
144 oa->area_id = area_id;
145 oa->if_list = list_new ();
paul718e3742002-12-13 20:15:29 +0000146
hasso6452df02004-08-15 05:52:07 +0000147 oa->lsdb = ospf6_lsdb_create (oa);
hasso508e53e2004-05-18 18:57:06 +0000148 oa->lsdb->hook_add = ospf6_area_lsdb_hook_add;
149 oa->lsdb->hook_remove = ospf6_area_lsdb_hook_remove;
hasso6452df02004-08-15 05:52:07 +0000150 oa->lsdb_self = ospf6_lsdb_create (oa);
paul718e3742002-12-13 20:15:29 +0000151
hasso508e53e2004-05-18 18:57:06 +0000152 oa->spf_table = ospf6_route_table_create ();
153 oa->route_table = ospf6_route_table_create ();
154 oa->route_table->hook_add = ospf6_area_route_hook_add;
155 oa->route_table->hook_remove = ospf6_area_route_hook_remove;
paul718e3742002-12-13 20:15:29 +0000156
hasso6452df02004-08-15 05:52:07 +0000157 oa->range_table = ospf6_route_table_create ();
158 oa->summary_prefix = ospf6_route_table_create ();
159 oa->summary_router = ospf6_route_table_create ();
160
hasso508e53e2004-05-18 18:57:06 +0000161 /* set default options */
162 OSPF6_OPT_SET (oa->options, OSPF6_OPT_V6);
163 OSPF6_OPT_SET (oa->options, OSPF6_OPT_E);
164 OSPF6_OPT_SET (oa->options, OSPF6_OPT_R);
paul718e3742002-12-13 20:15:29 +0000165
hasso508e53e2004-05-18 18:57:06 +0000166 oa->ospf6 = o;
167 listnode_add_sort (o->area_list, oa);
paul718e3742002-12-13 20:15:29 +0000168
hasso049207c2004-08-04 20:02:13 +0000169 /* import athoer area's routes as inter-area routes */
170 for (route = ospf6_route_head (o->route_table); route;
171 route = ospf6_route_next (route))
hasso6452df02004-08-15 05:52:07 +0000172 ospf6_abr_originate_summary_to_area (route, oa);
hasso049207c2004-08-04 20:02:13 +0000173
hasso508e53e2004-05-18 18:57:06 +0000174 return oa;
paul718e3742002-12-13 20:15:29 +0000175}
176
177void
hasso508e53e2004-05-18 18:57:06 +0000178ospf6_area_delete (struct ospf6_area *oa)
paul718e3742002-12-13 20:15:29 +0000179{
paul1eb8ef22005-04-07 07:30:20 +0000180 struct listnode *n, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000181 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000182
hasso6452df02004-08-15 05:52:07 +0000183 ospf6_route_table_delete (oa->range_table);
184 ospf6_route_table_delete (oa->summary_prefix);
185 ospf6_route_table_delete (oa->summary_router);
hasso049207c2004-08-04 20:02:13 +0000186
paul718e3742002-12-13 20:15:29 +0000187 /* ospf6 interface list */
paul1eb8ef22005-04-07 07:30:20 +0000188 for (ALL_LIST_ELEMENTS (oa->if_list, n, nnode, oi))
paul718e3742002-12-13 20:15:29 +0000189 {
hasso508e53e2004-05-18 18:57:06 +0000190 ospf6_interface_delete (oi);
paul718e3742002-12-13 20:15:29 +0000191 }
hasso508e53e2004-05-18 18:57:06 +0000192 list_delete (oa->if_list);
paul718e3742002-12-13 20:15:29 +0000193
hasso508e53e2004-05-18 18:57:06 +0000194 ospf6_lsdb_delete (oa->lsdb);
hasso6452df02004-08-15 05:52:07 +0000195 ospf6_lsdb_delete (oa->lsdb_self);
196
hasso508e53e2004-05-18 18:57:06 +0000197 ospf6_route_table_delete (oa->spf_table);
198 ospf6_route_table_delete (oa->route_table);
paul718e3742002-12-13 20:15:29 +0000199
hasso508e53e2004-05-18 18:57:06 +0000200#if 0
201 ospf6_spftree_delete (oa->spf_tree);
202 ospf6_route_table_delete (oa->topology_table);
203#endif /*0*/
paul718e3742002-12-13 20:15:29 +0000204
hasso508e53e2004-05-18 18:57:06 +0000205 THREAD_OFF (oa->thread_spf_calculation);
206 THREAD_OFF (oa->thread_route_calculation);
paul718e3742002-12-13 20:15:29 +0000207
hasso508e53e2004-05-18 18:57:06 +0000208 listnode_delete (oa->ospf6->area_list, oa);
209 oa->ospf6 = NULL;
paul718e3742002-12-13 20:15:29 +0000210
211 /* free area */
hasso508e53e2004-05-18 18:57:06 +0000212 XFREE (MTYPE_OSPF6_AREA, oa);
paul718e3742002-12-13 20:15:29 +0000213}
214
215struct ospf6_area *
hasso508e53e2004-05-18 18:57:06 +0000216ospf6_area_lookup (u_int32_t area_id, struct ospf6 *ospf6)
paul718e3742002-12-13 20:15:29 +0000217{
hasso508e53e2004-05-18 18:57:06 +0000218 struct ospf6_area *oa;
hasso52dc7ee2004-09-23 19:18:23 +0000219 struct listnode *n;
paul718e3742002-12-13 20:15:29 +0000220
paul1eb8ef22005-04-07 07:30:20 +0000221 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, n, oa))
222 if (oa->area_id == area_id)
223 return oa;
paul718e3742002-12-13 20:15:29 +0000224
225 return (struct ospf6_area *) NULL;
226}
227
hasso6452df02004-08-15 05:52:07 +0000228struct ospf6_area *
229ospf6_area_get (u_int32_t area_id, struct ospf6 *o)
230{
231 struct ospf6_area *oa;
232 oa = ospf6_area_lookup (area_id, o);
233 if (oa == NULL)
234 oa = ospf6_area_create (area_id, o);
235 return oa;
236}
237
paul718e3742002-12-13 20:15:29 +0000238void
hasso508e53e2004-05-18 18:57:06 +0000239ospf6_area_enable (struct ospf6_area *oa)
paul718e3742002-12-13 20:15:29 +0000240{
paul1eb8ef22005-04-07 07:30:20 +0000241 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000242 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000243
hasso6452df02004-08-15 05:52:07 +0000244 SET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
paul718e3742002-12-13 20:15:29 +0000245
paul1eb8ef22005-04-07 07:30:20 +0000246 for (ALL_LIST_ELEMENTS (oa->if_list, node, nnode, oi))
247 ospf6_interface_enable (oi);
paul718e3742002-12-13 20:15:29 +0000248}
249
250void
hasso508e53e2004-05-18 18:57:06 +0000251ospf6_area_disable (struct ospf6_area *oa)
paul718e3742002-12-13 20:15:29 +0000252{
paul1eb8ef22005-04-07 07:30:20 +0000253 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000254 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000255
hasso6452df02004-08-15 05:52:07 +0000256 UNSET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
hasso508e53e2004-05-18 18:57:06 +0000257
paul1eb8ef22005-04-07 07:30:20 +0000258 for (ALL_LIST_ELEMENTS (oa->if_list, node, nnode, oi))
259 ospf6_interface_disable (oi);
paul718e3742002-12-13 20:15:29 +0000260}
261
hasso508e53e2004-05-18 18:57:06 +0000262
263void
264ospf6_area_show (struct vty *vty, struct ospf6_area *oa)
265{
hasso52dc7ee2004-09-23 19:18:23 +0000266 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +0000267 struct ospf6_interface *oi;
268
hasso049207c2004-08-04 20:02:13 +0000269 vty_out (vty, " Area %s%s", oa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000270 vty_out (vty, " Number of Area scoped LSAs is %u%s",
hasso049207c2004-08-04 20:02:13 +0000271 oa->lsdb->count, VNL);
hasso508e53e2004-05-18 18:57:06 +0000272
273 vty_out (vty, " Interface attached to this area:");
paul1eb8ef22005-04-07 07:30:20 +0000274 for (ALL_LIST_ELEMENTS_RO (oa->if_list, i, oi))
275 vty_out (vty, " %s", oi->interface->name);
276
hasso049207c2004-08-04 20:02:13 +0000277 vty_out (vty, "%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000278}
279
280
hasso049207c2004-08-04 20:02:13 +0000281#define OSPF6_CMD_AREA_LOOKUP(str, oa) \
282{ \
283 u_int32_t area_id = 0; \
284 if (inet_pton (AF_INET, str, &area_id) != 1) \
285 { \
286 vty_out (vty, "Malformed Area-ID: %s%s", str, VNL); \
287 return CMD_SUCCESS; \
288 } \
289 oa = ospf6_area_lookup (area_id, ospf6); \
290 if (oa == NULL) \
291 { \
292 vty_out (vty, "No such Area: %s%s", str, VNL); \
293 return CMD_SUCCESS; \
294 } \
hasso508e53e2004-05-18 18:57:06 +0000295}
296
hasso6452df02004-08-15 05:52:07 +0000297#define OSPF6_CMD_AREA_GET(str, oa) \
298{ \
299 u_int32_t area_id = 0; \
300 if (inet_pton (AF_INET, str, &area_id) != 1) \
301 { \
302 vty_out (vty, "Malformed Area-ID: %s%s", str, VNL); \
303 return CMD_SUCCESS; \
304 } \
305 oa = ospf6_area_get (area_id, ospf6); \
306}
307
308DEFUN (area_range,
309 area_range_cmd,
310 "area A.B.C.D range X:X::X:X/M",
311 "OSPF area parameters\n"
312 OSPF6_AREA_ID_STR
313 "Configured address range\n"
314 "Specify IPv6 prefix\n"
315 )
316{
317 int ret;
318 struct ospf6_area *oa;
319 struct prefix prefix;
320 struct ospf6_route *range;
321
322 OSPF6_CMD_AREA_GET (argv[0], oa);
323 argc--;
324 argv++;
325
326 ret = str2prefix (argv[0], &prefix);
327 if (ret != 1 || prefix.family != AF_INET6)
328 {
329 vty_out (vty, "Malformed argument: %s%s", argv[0], VNL);
330 return CMD_SUCCESS;
331 }
332 argc--;
333 argv++;
334
335 range = ospf6_route_lookup (&prefix, oa->range_table);
336 if (range == NULL)
337 {
338 range = ospf6_route_create ();
339 range->type = OSPF6_DEST_TYPE_RANGE;
340 range->prefix = prefix;
341 }
342
343 if (argc)
344 {
345 if (! strcmp (argv[0], "not-advertise"))
346 SET_FLAG (range->flag, OSPF6_ROUTE_DO_NOT_ADVERTISE);
347 else if (! strcmp (argv[0], "advertise"))
348 UNSET_FLAG (range->flag, OSPF6_ROUTE_DO_NOT_ADVERTISE);
349 }
350
351 ospf6_route_add (range, oa->range_table);
352 return CMD_SUCCESS;
353}
354
355ALIAS (area_range,
356 area_range_advertise_cmd,
357 "area A.B.C.D range X:X::X:X/M (advertise|not-advertise)",
358 "OSPF area parameters\n"
359 OSPF6_AREA_ID_STR
360 "Configured address range\n"
361 "Specify IPv6 prefix\n"
362 );
363
364DEFUN (no_area_range,
365 no_area_range_cmd,
366 "no area A.B.C.D range X:X::X:X/M",
367 "OSPF area parameters\n"
368 OSPF6_AREA_ID_STR
369 "Configured address range\n"
370 "Specify IPv6 prefix\n"
371 )
372{
373 int ret;
374 struct ospf6_area *oa;
375 struct prefix prefix;
376 struct ospf6_route *range;
377
378 OSPF6_CMD_AREA_GET (argv[0], oa);
379 argc--;
380 argv++;
381
382 ret = str2prefix (argv[0], &prefix);
383 if (ret != 1 || prefix.family != AF_INET6)
384 {
385 vty_out (vty, "Malformed argument: %s%s", argv[0], VNL);
386 return CMD_SUCCESS;
387 }
388
389 range = ospf6_route_lookup (&prefix, oa->range_table);
390 if (range == NULL)
391 {
392 vty_out (vty, "Range %s does not exists.%s", argv[0], VNL);
393 return CMD_SUCCESS;
394 }
395
396 ospf6_route_remove (range, oa->range_table);
397 return CMD_SUCCESS;
398}
399
400void
401ospf6_area_config_write (struct vty *vty)
402{
hasso52dc7ee2004-09-23 19:18:23 +0000403 struct listnode *node;
hasso6452df02004-08-15 05:52:07 +0000404 struct ospf6_area *oa;
405 struct ospf6_route *range;
406 char buf[128];
407
paul1eb8ef22005-04-07 07:30:20 +0000408 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
hasso6452df02004-08-15 05:52:07 +0000409 {
hasso6452df02004-08-15 05:52:07 +0000410 for (range = ospf6_route_head (oa->range_table); range;
411 range = ospf6_route_next (range))
412 {
413 prefix2str (&range->prefix, buf, sizeof (buf));
414 vty_out (vty, " area %s range %s%s", oa->name, buf, VNL);
415 }
416 }
417}
418
hasso34956b32005-06-24 08:44:02 +0000419DEFUN (area_filter_list,
420 area_filter_list_cmd,
421 "area A.B.C.D filter-list prefix WORD (in|out)",
422 "OSPFv6 area parameters\n"
423 "OSPFv6 area ID in IP address format\n"
424 "Filter networks between OSPFv6 areas\n"
425 "Filter prefixes between OSPFv6 areas\n"
426 "Name of an IPv6 prefix-list\n"
427 "Filter networks sent to this area\n"
428 "Filter networks sent from this area\n")
429{
430 struct ospf6_area *area;
431 struct prefix_list *plist;
432
433 OSPF6_CMD_AREA_GET (argv[0], area);
434 argc--;
435 argv++;
436
437 plist = prefix_list_lookup (AFI_IP6, argv[1]);
438 if (strncmp (argv[2], "in", 2) == 0)
439 {
440 PREFIX_LIST_IN (area) = plist;
441 if (PREFIX_NAME_IN (area))
442 free (PREFIX_NAME_IN (area));
443
444 PREFIX_NAME_IN (area) = strdup (argv[1]);
445 ospf6_abr_reimport (area);
446 }
447 else
448 {
449 PREFIX_LIST_OUT (area) = plist;
450 if (PREFIX_NAME_OUT (area))
451 free (PREFIX_NAME_OUT (area));
452
453 PREFIX_NAME_OUT (area) = strdup (argv[1]);
454 ospf6_abr_enable_area (area);
455 }
456
457 return CMD_SUCCESS;
458}
459
460DEFUN (no_area_filter_list,
461 no_area_filter_list_cmd,
462 "no area A.B.C.D filter-list prefix WORD (in|out)",
463 NO_STR
464 "OSPFv6 area parameters\n"
465 "OSPFv6 area ID in IP address format\n"
466 "Filter networks between OSPFv6 areas\n"
467 "Filter prefixes between OSPFv6 areas\n"
468 "Name of an IPv6 prefix-list\n"
469 "Filter networks sent to this area\n"
470 "Filter networks sent from this area\n")
471{
472 struct ospf6_area *area;
473 struct prefix_list *plist;
474
475 OSPF6_CMD_AREA_GET (argv[0], area);
476 argc--;
477 argv++;
478
479 plist = prefix_list_lookup (AFI_IP6, argv[1]);
480 if (strncmp (argv[2], "in", 2) == 0)
481 {
482 if (PREFIX_NAME_IN (area))
483 if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
484 return CMD_SUCCESS;
485
486 PREFIX_LIST_IN (area) = NULL;
487 if (PREFIX_NAME_IN (area))
488 free (PREFIX_NAME_IN (area));
489
490 PREFIX_NAME_IN (area) = NULL;
491 ospf6_abr_reimport (area);
492 }
493 else
494 {
495 if (PREFIX_NAME_OUT (area))
496 if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
497 return CMD_SUCCESS;
498
499 PREFIX_LIST_OUT (area) = NULL;
500 if (PREFIX_NAME_OUT (area))
501 free (PREFIX_NAME_OUT (area));
502
503 PREFIX_NAME_OUT (area) = NULL;
504 ospf6_abr_enable_area (area);
505 }
506
507 return CMD_SUCCESS;
508}
509
510DEFUN (area_import_list,
511 area_import_list_cmd,
512 "area A.B.C.D import-list NAME",
513 "OSPFv6 area parameters\n"
514 "OSPFv6 area ID in IP address format\n"
515 "Set the filter for networks from other areas announced to the specified one\n"
516 "Name of the acess-list\n")
517{
518 struct ospf6_area *area;
519 struct access_list *list;
520
521 OSPF6_CMD_AREA_GET(argv[0], area);
522
523 list = access_list_lookup (AFI_IP6, argv[1]);
524
525 IMPORT_LIST (area) = list;
526
527 if (IMPORT_NAME (area))
528 free (IMPORT_NAME (area));
529
530 IMPORT_NAME (area) = strdup (argv[1]);
531 ospf6_abr_reimport (area);
532
533 return CMD_SUCCESS;
534}
535
536DEFUN (no_area_import_list,
537 no_area_import_list_cmd,
538 "no area A.B.C.D import-list NAME",
539 "OSPFv6 area parameters\n"
540 "OSPFv6 area ID in IP address format\n"
541 "Unset the filter for networks announced to other areas\n"
542 "NAme of the access-list\n")
543{
544 struct ospf6_area *area;
545
546 OSPF6_CMD_AREA_GET(argv[0], area);
547
548 IMPORT_LIST (area) = 0;
549
550 if (IMPORT_NAME (area))
551 free (IMPORT_NAME (area));
552
553 IMPORT_NAME (area) = NULL;
554 ospf6_abr_reimport (area);
555
556 return CMD_SUCCESS;
557}
558
559DEFUN (area_export_list,
560 area_export_list_cmd,
561 "area A.B.C.D export-list NAME",
562 "OSPFv6 area parameters\n"
563 "OSPFv6 area ID in IP address format\n"
564 "Set the filter for networks announced to other areas\n"
565 "Name of the acess-list\n")
566{
567 struct ospf6_area *area;
568 struct access_list *list;
569
570 OSPF6_CMD_AREA_GET(argv[0], area);
571
572 list = access_list_lookup (AFI_IP6, argv[1]);
573
574 EXPORT_LIST (area) = list;
575
576 if (EXPORT_NAME (area))
577 free (EXPORT_NAME (area));
578
579 EXPORT_NAME (area) = strdup (argv[1]);
580 ospf6_abr_enable_area (area);
581
582 return CMD_SUCCESS;
583}
584
585DEFUN (no_area_export_list,
586 no_area_export_list_cmd,
587 "no area A.B.C.D export-list NAME",
588 "OSPFv6 area parameters\n"
589 "OSPFv6 area ID in IP address format\n"
590 "Unset the filter for networks announced to other areas\n"
591 "Name of the access-list\n")
592{
593 struct ospf6_area *area;
594
595 OSPF6_CMD_AREA_GET(argv[0], area);
596
597 EXPORT_LIST (area) = 0;
598
599 if (EXPORT_NAME (area))
600 free (EXPORT_NAME (area));
601
602 EXPORT_NAME (area) = NULL;
603 ospf6_abr_enable_area (area);
604
605 return CMD_SUCCESS;
606}
607
hasso508e53e2004-05-18 18:57:06 +0000608DEFUN (show_ipv6_ospf6_spf_tree,
609 show_ipv6_ospf6_spf_tree_cmd,
610 "show ipv6 ospf6 spf tree",
611 SHOW_STR
612 IP6_STR
613 OSPF6_STR
614 "Shortest Path First caculation\n"
615 "Show SPF tree\n")
616{
hasso52dc7ee2004-09-23 19:18:23 +0000617 struct listnode *node;
hasso508e53e2004-05-18 18:57:06 +0000618 struct ospf6_area *oa;
619 struct ospf6_vertex *root;
620 struct ospf6_route *route;
621 struct prefix prefix;
622
623 ospf6_linkstate_prefix (ospf6->router_id, htonl (0), &prefix);
paul1eb8ef22005-04-07 07:30:20 +0000624
625 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
hasso508e53e2004-05-18 18:57:06 +0000626 {
hasso508e53e2004-05-18 18:57:06 +0000627 route = ospf6_route_lookup (&prefix, oa->spf_table);
628 if (route == NULL)
629 {
630 vty_out (vty, "LS entry for root not found in area %s%s",
hasso049207c2004-08-04 20:02:13 +0000631 oa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000632 continue;
633 }
634 root = (struct ospf6_vertex *) route->route_option;
635 ospf6_spf_display_subtree (vty, "", 0, root);
636 }
637
638 return CMD_SUCCESS;
639}
640
641DEFUN (show_ipv6_ospf6_area_spf_tree,
642 show_ipv6_ospf6_area_spf_tree_cmd,
643 "show ipv6 ospf6 area A.B.C.D spf tree",
644 SHOW_STR
645 IP6_STR
646 OSPF6_STR
647 OSPF6_AREA_STR
648 OSPF6_AREA_ID_STR
649 "Shortest Path First caculation\n"
650 "Show SPF tree\n")
651{
652 u_int32_t area_id;
653 struct ospf6_area *oa;
654 struct ospf6_vertex *root;
655 struct ospf6_route *route;
656 struct prefix prefix;
657
658 ospf6_linkstate_prefix (ospf6->router_id, htonl (0), &prefix);
659
660 if (inet_pton (AF_INET, argv[0], &area_id) != 1)
661 {
hasso049207c2004-08-04 20:02:13 +0000662 vty_out (vty, "Malformed Area-ID: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000663 return CMD_SUCCESS;
664 }
665 oa = ospf6_area_lookup (area_id, ospf6);
666 if (oa == NULL)
667 {
hasso049207c2004-08-04 20:02:13 +0000668 vty_out (vty, "No such Area: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000669 return CMD_SUCCESS;
670 }
671
672 route = ospf6_route_lookup (&prefix, oa->spf_table);
673 if (route == NULL)
674 {
675 vty_out (vty, "LS entry for root not found in area %s%s",
hasso049207c2004-08-04 20:02:13 +0000676 oa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000677 return CMD_SUCCESS;
678 }
679 root = (struct ospf6_vertex *) route->route_option;
680 ospf6_spf_display_subtree (vty, "", 0, root);
681
682 return CMD_SUCCESS;
683}
684
hasso508e53e2004-05-18 18:57:06 +0000685DEFUN (show_ipv6_ospf6_simulate_spf_tree_root,
686 show_ipv6_ospf6_simulate_spf_tree_root_cmd,
687 "show ipv6 ospf6 simulate spf-tree A.B.C.D area A.B.C.D",
688 SHOW_STR
689 IP6_STR
690 OSPF6_STR
691 "Shortest Path First caculation\n"
692 "Show SPF tree\n"
693 "Specify root's router-id to calculate another router's SPF tree\n")
694{
695 u_int32_t area_id;
696 struct ospf6_area *oa;
697 struct ospf6_vertex *root;
698 struct ospf6_route *route;
699 struct prefix prefix;
700 u_int32_t router_id;
701 struct ospf6_route_table *spf_table;
702 unsigned char tmp_debug_ospf6_spf = 0;
703
704 inet_pton (AF_INET, argv[0], &router_id);
705 ospf6_linkstate_prefix (router_id, htonl (0), &prefix);
706
707 if (inet_pton (AF_INET, argv[1], &area_id) != 1)
708 {
hasso049207c2004-08-04 20:02:13 +0000709 vty_out (vty, "Malformed Area-ID: %s%s", argv[1], VNL);
hasso508e53e2004-05-18 18:57:06 +0000710 return CMD_SUCCESS;
711 }
712 oa = ospf6_area_lookup (area_id, ospf6);
713 if (oa == NULL)
714 {
hasso049207c2004-08-04 20:02:13 +0000715 vty_out (vty, "No such Area: %s%s", argv[1], VNL);
hasso508e53e2004-05-18 18:57:06 +0000716 return CMD_SUCCESS;
717 }
718
719 tmp_debug_ospf6_spf = conf_debug_ospf6_spf;
720 conf_debug_ospf6_spf = 0;
721
722 spf_table = ospf6_route_table_create ();
723 ospf6_spf_calculation (router_id, spf_table, oa);
724
725 conf_debug_ospf6_spf = tmp_debug_ospf6_spf;
726
727 route = ospf6_route_lookup (&prefix, spf_table);
728 if (route == NULL)
729 {
730 ospf6_spf_table_finish (spf_table);
731 ospf6_route_table_delete (spf_table);
732 return CMD_SUCCESS;
733 }
734 root = (struct ospf6_vertex *) route->route_option;
735 ospf6_spf_display_subtree (vty, "", 0, root);
736
737 ospf6_spf_table_finish (spf_table);
738 ospf6_route_table_delete (spf_table);
739
740 return CMD_SUCCESS;
741}
paul718e3742002-12-13 20:15:29 +0000742
743void
744ospf6_area_init ()
745{
hasso508e53e2004-05-18 18:57:06 +0000746 install_element (VIEW_NODE, &show_ipv6_ospf6_spf_tree_cmd);
hasso508e53e2004-05-18 18:57:06 +0000747 install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_tree_cmd);
hasso508e53e2004-05-18 18:57:06 +0000748 install_element (VIEW_NODE, &show_ipv6_ospf6_simulate_spf_tree_root_cmd);
749
750 install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_tree_cmd);
hasso508e53e2004-05-18 18:57:06 +0000751 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_tree_cmd);
hasso508e53e2004-05-18 18:57:06 +0000752 install_element (ENABLE_NODE, &show_ipv6_ospf6_simulate_spf_tree_root_cmd);
hasso6452df02004-08-15 05:52:07 +0000753
754 install_element (OSPF6_NODE, &area_range_cmd);
755 install_element (OSPF6_NODE, &area_range_advertise_cmd);
756 install_element (OSPF6_NODE, &no_area_range_cmd);
hasso34956b32005-06-24 08:44:02 +0000757
758 install_element (OSPF6_NODE, &area_import_list_cmd);
759 install_element (OSPF6_NODE, &no_area_import_list_cmd);
760 install_element (OSPF6_NODE, &area_export_list_cmd);
761 install_element (OSPF6_NODE, &no_area_export_list_cmd);
762
763 install_element (OSPF6_NODE, &area_filter_list_cmd);
764 install_element (OSPF6_NODE, &no_area_filter_list_cmd);
765
paul718e3742002-12-13 20:15:29 +0000766}
hasso049207c2004-08-04 20:02:13 +0000767
hasso6452df02004-08-15 05:52:07 +0000768