blob: bf8dbc33f7287144e760971af421ddf800a61c1b [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 */
Paul Jakma6ac29a52008-08-15 13:45:30 +010057static void
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
Paul Jakma6ac29a52008-08-15 13:45:30 +010087static void
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
Paul Jakma6ac29a52008-08-15 13:45:30 +0100117static void
hasso508e53e2004-05-18 18:57:06 +0000118ospf6_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 Jakma6ac29a52008-08-15 13:45:30 +0100124static void
hasso508e53e2004-05-18 18:57:06 +0000125ospf6_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
Paul Jakmacf1ce252006-05-15 10:46:07 +0000152 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;
hasso508e53e2004-05-18 18:57:06 +0000156 oa->route_table->hook_add = ospf6_area_route_hook_add;
157 oa->route_table->hook_remove = ospf6_area_route_hook_remove;
paul718e3742002-12-13 20:15:29 +0000158
Paul Jakmacf1ce252006-05-15 10:46:07 +0000159 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;
hasso6452df02004-08-15 05:52:07 +0000165
hasso508e53e2004-05-18 18:57:06 +0000166 /* set default options */
167 OSPF6_OPT_SET (oa->options, OSPF6_OPT_V6);
168 OSPF6_OPT_SET (oa->options, OSPF6_OPT_E);
169 OSPF6_OPT_SET (oa->options, OSPF6_OPT_R);
paul718e3742002-12-13 20:15:29 +0000170
hasso508e53e2004-05-18 18:57:06 +0000171 oa->ospf6 = o;
172 listnode_add_sort (o->area_list, oa);
paul718e3742002-12-13 20:15:29 +0000173
hasso049207c2004-08-04 20:02:13 +0000174 /* import athoer area's routes as inter-area routes */
175 for (route = ospf6_route_head (o->route_table); route;
176 route = ospf6_route_next (route))
hasso6452df02004-08-15 05:52:07 +0000177 ospf6_abr_originate_summary_to_area (route, oa);
hasso049207c2004-08-04 20:02:13 +0000178
hasso508e53e2004-05-18 18:57:06 +0000179 return oa;
paul718e3742002-12-13 20:15:29 +0000180}
181
182void
hasso508e53e2004-05-18 18:57:06 +0000183ospf6_area_delete (struct ospf6_area *oa)
paul718e3742002-12-13 20:15:29 +0000184{
paul1eb8ef22005-04-07 07:30:20 +0000185 struct listnode *n, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000186 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000187
hasso6452df02004-08-15 05:52:07 +0000188 ospf6_route_table_delete (oa->range_table);
189 ospf6_route_table_delete (oa->summary_prefix);
190 ospf6_route_table_delete (oa->summary_router);
hasso049207c2004-08-04 20:02:13 +0000191
paul718e3742002-12-13 20:15:29 +0000192 /* ospf6 interface list */
paul1eb8ef22005-04-07 07:30:20 +0000193 for (ALL_LIST_ELEMENTS (oa->if_list, n, nnode, oi))
paul718e3742002-12-13 20:15:29 +0000194 {
hasso508e53e2004-05-18 18:57:06 +0000195 ospf6_interface_delete (oi);
paul718e3742002-12-13 20:15:29 +0000196 }
hasso508e53e2004-05-18 18:57:06 +0000197 list_delete (oa->if_list);
paul718e3742002-12-13 20:15:29 +0000198
hasso508e53e2004-05-18 18:57:06 +0000199 ospf6_lsdb_delete (oa->lsdb);
hasso6452df02004-08-15 05:52:07 +0000200 ospf6_lsdb_delete (oa->lsdb_self);
201
Tom Goff1d192342010-11-10 13:02:38 -0800202 ospf6_spf_table_finish (oa->spf_table);
hasso508e53e2004-05-18 18:57:06 +0000203 ospf6_route_table_delete (oa->spf_table);
204 ospf6_route_table_delete (oa->route_table);
paul718e3742002-12-13 20:15:29 +0000205
hasso508e53e2004-05-18 18:57:06 +0000206#if 0
207 ospf6_spftree_delete (oa->spf_tree);
208 ospf6_route_table_delete (oa->topology_table);
209#endif /*0*/
paul718e3742002-12-13 20:15:29 +0000210
hasso508e53e2004-05-18 18:57:06 +0000211 THREAD_OFF (oa->thread_spf_calculation);
212 THREAD_OFF (oa->thread_route_calculation);
paul718e3742002-12-13 20:15:29 +0000213
hasso508e53e2004-05-18 18:57:06 +0000214 listnode_delete (oa->ospf6->area_list, oa);
215 oa->ospf6 = NULL;
paul718e3742002-12-13 20:15:29 +0000216
217 /* free area */
hasso508e53e2004-05-18 18:57:06 +0000218 XFREE (MTYPE_OSPF6_AREA, oa);
paul718e3742002-12-13 20:15:29 +0000219}
220
221struct ospf6_area *
hasso508e53e2004-05-18 18:57:06 +0000222ospf6_area_lookup (u_int32_t area_id, struct ospf6 *ospf6)
paul718e3742002-12-13 20:15:29 +0000223{
hasso508e53e2004-05-18 18:57:06 +0000224 struct ospf6_area *oa;
hasso52dc7ee2004-09-23 19:18:23 +0000225 struct listnode *n;
paul718e3742002-12-13 20:15:29 +0000226
paul1eb8ef22005-04-07 07:30:20 +0000227 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, n, oa))
228 if (oa->area_id == area_id)
229 return oa;
paul718e3742002-12-13 20:15:29 +0000230
231 return (struct ospf6_area *) NULL;
232}
233
Paul Jakma6ac29a52008-08-15 13:45:30 +0100234static struct ospf6_area *
hasso6452df02004-08-15 05:52:07 +0000235ospf6_area_get (u_int32_t area_id, struct ospf6 *o)
236{
237 struct ospf6_area *oa;
238 oa = ospf6_area_lookup (area_id, o);
239 if (oa == NULL)
240 oa = ospf6_area_create (area_id, o);
241 return oa;
242}
243
paul718e3742002-12-13 20:15:29 +0000244void
hasso508e53e2004-05-18 18:57:06 +0000245ospf6_area_enable (struct ospf6_area *oa)
paul718e3742002-12-13 20:15:29 +0000246{
paul1eb8ef22005-04-07 07:30:20 +0000247 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000248 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000249
hasso6452df02004-08-15 05:52:07 +0000250 SET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
paul718e3742002-12-13 20:15:29 +0000251
paul1eb8ef22005-04-07 07:30:20 +0000252 for (ALL_LIST_ELEMENTS (oa->if_list, node, nnode, oi))
253 ospf6_interface_enable (oi);
paul718e3742002-12-13 20:15:29 +0000254}
255
256void
hasso508e53e2004-05-18 18:57:06 +0000257ospf6_area_disable (struct ospf6_area *oa)
paul718e3742002-12-13 20:15:29 +0000258{
paul1eb8ef22005-04-07 07:30:20 +0000259 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000260 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000261
hasso6452df02004-08-15 05:52:07 +0000262 UNSET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
hasso508e53e2004-05-18 18:57:06 +0000263
paul1eb8ef22005-04-07 07:30:20 +0000264 for (ALL_LIST_ELEMENTS (oa->if_list, node, nnode, oi))
265 ospf6_interface_disable (oi);
paul718e3742002-12-13 20:15:29 +0000266}
267
hasso508e53e2004-05-18 18:57:06 +0000268
269void
270ospf6_area_show (struct vty *vty, struct ospf6_area *oa)
271{
hasso52dc7ee2004-09-23 19:18:23 +0000272 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +0000273 struct ospf6_interface *oi;
274
hasso049207c2004-08-04 20:02:13 +0000275 vty_out (vty, " Area %s%s", oa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000276 vty_out (vty, " Number of Area scoped LSAs is %u%s",
hasso049207c2004-08-04 20:02:13 +0000277 oa->lsdb->count, VNL);
hasso508e53e2004-05-18 18:57:06 +0000278
279 vty_out (vty, " Interface attached to this area:");
paul1eb8ef22005-04-07 07:30:20 +0000280 for (ALL_LIST_ELEMENTS_RO (oa->if_list, i, oi))
281 vty_out (vty, " %s", oi->interface->name);
282
hasso049207c2004-08-04 20:02:13 +0000283 vty_out (vty, "%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000284}
285
286
hasso049207c2004-08-04 20:02:13 +0000287#define OSPF6_CMD_AREA_LOOKUP(str, oa) \
288{ \
289 u_int32_t area_id = 0; \
290 if (inet_pton (AF_INET, str, &area_id) != 1) \
291 { \
292 vty_out (vty, "Malformed Area-ID: %s%s", str, VNL); \
293 return CMD_SUCCESS; \
294 } \
295 oa = ospf6_area_lookup (area_id, ospf6); \
296 if (oa == NULL) \
297 { \
298 vty_out (vty, "No such Area: %s%s", str, VNL); \
299 return CMD_SUCCESS; \
300 } \
hasso508e53e2004-05-18 18:57:06 +0000301}
302
hasso6452df02004-08-15 05:52:07 +0000303#define OSPF6_CMD_AREA_GET(str, oa) \
304{ \
305 u_int32_t area_id = 0; \
306 if (inet_pton (AF_INET, str, &area_id) != 1) \
307 { \
308 vty_out (vty, "Malformed Area-ID: %s%s", str, VNL); \
309 return CMD_SUCCESS; \
310 } \
311 oa = ospf6_area_get (area_id, ospf6); \
312}
313
314DEFUN (area_range,
315 area_range_cmd,
316 "area A.B.C.D range X:X::X:X/M",
317 "OSPF area parameters\n"
318 OSPF6_AREA_ID_STR
319 "Configured address range\n"
320 "Specify IPv6 prefix\n"
321 )
322{
323 int ret;
324 struct ospf6_area *oa;
325 struct prefix prefix;
326 struct ospf6_route *range;
327
328 OSPF6_CMD_AREA_GET (argv[0], oa);
329 argc--;
330 argv++;
331
332 ret = str2prefix (argv[0], &prefix);
333 if (ret != 1 || prefix.family != AF_INET6)
334 {
335 vty_out (vty, "Malformed argument: %s%s", argv[0], VNL);
336 return CMD_SUCCESS;
337 }
338 argc--;
339 argv++;
340
341 range = ospf6_route_lookup (&prefix, oa->range_table);
342 if (range == NULL)
343 {
344 range = ospf6_route_create ();
345 range->type = OSPF6_DEST_TYPE_RANGE;
346 range->prefix = prefix;
347 }
348
349 if (argc)
350 {
351 if (! strcmp (argv[0], "not-advertise"))
352 SET_FLAG (range->flag, OSPF6_ROUTE_DO_NOT_ADVERTISE);
353 else if (! strcmp (argv[0], "advertise"))
354 UNSET_FLAG (range->flag, OSPF6_ROUTE_DO_NOT_ADVERTISE);
355 }
356
Jon86f9e5a2009-02-11 17:22:03 -0800357 if (range->rnode)
358 {
359 vty_out (vty, "Range already defined: %s%s", argv[-1], VNL);
360 return CMD_WARNING;
361 }
362
hasso6452df02004-08-15 05:52:07 +0000363 ospf6_route_add (range, oa->range_table);
364 return CMD_SUCCESS;
365}
366
367ALIAS (area_range,
368 area_range_advertise_cmd,
369 "area A.B.C.D range X:X::X:X/M (advertise|not-advertise)",
370 "OSPF area parameters\n"
371 OSPF6_AREA_ID_STR
372 "Configured address range\n"
373 "Specify IPv6 prefix\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100374 )
hasso6452df02004-08-15 05:52:07 +0000375
376DEFUN (no_area_range,
377 no_area_range_cmd,
378 "no area A.B.C.D range X:X::X:X/M",
379 "OSPF area parameters\n"
380 OSPF6_AREA_ID_STR
381 "Configured address range\n"
382 "Specify IPv6 prefix\n"
383 )
384{
385 int ret;
386 struct ospf6_area *oa;
387 struct prefix prefix;
388 struct ospf6_route *range;
389
390 OSPF6_CMD_AREA_GET (argv[0], oa);
391 argc--;
392 argv++;
393
394 ret = str2prefix (argv[0], &prefix);
395 if (ret != 1 || prefix.family != AF_INET6)
396 {
397 vty_out (vty, "Malformed argument: %s%s", argv[0], VNL);
398 return CMD_SUCCESS;
399 }
400
401 range = ospf6_route_lookup (&prefix, oa->range_table);
402 if (range == NULL)
403 {
404 vty_out (vty, "Range %s does not exists.%s", argv[0], VNL);
405 return CMD_SUCCESS;
406 }
407
408 ospf6_route_remove (range, oa->range_table);
409 return CMD_SUCCESS;
410}
411
412void
413ospf6_area_config_write (struct vty *vty)
414{
hasso52dc7ee2004-09-23 19:18:23 +0000415 struct listnode *node;
hasso6452df02004-08-15 05:52:07 +0000416 struct ospf6_area *oa;
417 struct ospf6_route *range;
418 char buf[128];
419
paul1eb8ef22005-04-07 07:30:20 +0000420 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
hasso6452df02004-08-15 05:52:07 +0000421 {
hasso6452df02004-08-15 05:52:07 +0000422 for (range = ospf6_route_head (oa->range_table); range;
423 range = ospf6_route_next (range))
424 {
425 prefix2str (&range->prefix, buf, sizeof (buf));
426 vty_out (vty, " area %s range %s%s", oa->name, buf, VNL);
427 }
428 }
429}
430
hasso34956b32005-06-24 08:44:02 +0000431DEFUN (area_filter_list,
432 area_filter_list_cmd,
433 "area A.B.C.D filter-list prefix WORD (in|out)",
434 "OSPFv6 area parameters\n"
435 "OSPFv6 area ID in IP address format\n"
436 "Filter networks between OSPFv6 areas\n"
437 "Filter prefixes between OSPFv6 areas\n"
438 "Name of an IPv6 prefix-list\n"
439 "Filter networks sent to this area\n"
440 "Filter networks sent from this area\n")
441{
442 struct ospf6_area *area;
443 struct prefix_list *plist;
444
445 OSPF6_CMD_AREA_GET (argv[0], area);
446 argc--;
447 argv++;
448
449 plist = prefix_list_lookup (AFI_IP6, argv[1]);
450 if (strncmp (argv[2], "in", 2) == 0)
451 {
452 PREFIX_LIST_IN (area) = plist;
453 if (PREFIX_NAME_IN (area))
454 free (PREFIX_NAME_IN (area));
455
456 PREFIX_NAME_IN (area) = strdup (argv[1]);
457 ospf6_abr_reimport (area);
458 }
459 else
460 {
461 PREFIX_LIST_OUT (area) = plist;
462 if (PREFIX_NAME_OUT (area))
463 free (PREFIX_NAME_OUT (area));
464
465 PREFIX_NAME_OUT (area) = strdup (argv[1]);
466 ospf6_abr_enable_area (area);
467 }
468
469 return CMD_SUCCESS;
470}
471
472DEFUN (no_area_filter_list,
473 no_area_filter_list_cmd,
474 "no area A.B.C.D filter-list prefix WORD (in|out)",
475 NO_STR
476 "OSPFv6 area parameters\n"
477 "OSPFv6 area ID in IP address format\n"
478 "Filter networks between OSPFv6 areas\n"
479 "Filter prefixes between OSPFv6 areas\n"
480 "Name of an IPv6 prefix-list\n"
481 "Filter networks sent to this area\n"
482 "Filter networks sent from this area\n")
483{
484 struct ospf6_area *area;
485 struct prefix_list *plist;
486
487 OSPF6_CMD_AREA_GET (argv[0], area);
488 argc--;
489 argv++;
490
491 plist = prefix_list_lookup (AFI_IP6, argv[1]);
492 if (strncmp (argv[2], "in", 2) == 0)
493 {
494 if (PREFIX_NAME_IN (area))
495 if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
496 return CMD_SUCCESS;
497
498 PREFIX_LIST_IN (area) = NULL;
499 if (PREFIX_NAME_IN (area))
500 free (PREFIX_NAME_IN (area));
501
502 PREFIX_NAME_IN (area) = NULL;
503 ospf6_abr_reimport (area);
504 }
505 else
506 {
507 if (PREFIX_NAME_OUT (area))
508 if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
509 return CMD_SUCCESS;
510
511 PREFIX_LIST_OUT (area) = NULL;
512 if (PREFIX_NAME_OUT (area))
513 free (PREFIX_NAME_OUT (area));
514
515 PREFIX_NAME_OUT (area) = NULL;
516 ospf6_abr_enable_area (area);
517 }
518
519 return CMD_SUCCESS;
520}
521
522DEFUN (area_import_list,
523 area_import_list_cmd,
524 "area A.B.C.D import-list NAME",
525 "OSPFv6 area parameters\n"
526 "OSPFv6 area ID in IP address format\n"
527 "Set the filter for networks from other areas announced to the specified one\n"
528 "Name of the acess-list\n")
529{
530 struct ospf6_area *area;
531 struct access_list *list;
532
533 OSPF6_CMD_AREA_GET(argv[0], area);
534
535 list = access_list_lookup (AFI_IP6, argv[1]);
536
537 IMPORT_LIST (area) = list;
538
539 if (IMPORT_NAME (area))
540 free (IMPORT_NAME (area));
541
542 IMPORT_NAME (area) = strdup (argv[1]);
543 ospf6_abr_reimport (area);
544
545 return CMD_SUCCESS;
546}
547
548DEFUN (no_area_import_list,
549 no_area_import_list_cmd,
550 "no area A.B.C.D import-list NAME",
551 "OSPFv6 area parameters\n"
552 "OSPFv6 area ID in IP address format\n"
553 "Unset the filter for networks announced to other areas\n"
554 "NAme of the access-list\n")
555{
556 struct ospf6_area *area;
557
558 OSPF6_CMD_AREA_GET(argv[0], area);
559
560 IMPORT_LIST (area) = 0;
561
562 if (IMPORT_NAME (area))
563 free (IMPORT_NAME (area));
564
565 IMPORT_NAME (area) = NULL;
566 ospf6_abr_reimport (area);
567
568 return CMD_SUCCESS;
569}
570
571DEFUN (area_export_list,
572 area_export_list_cmd,
573 "area A.B.C.D export-list NAME",
574 "OSPFv6 area parameters\n"
575 "OSPFv6 area ID in IP address format\n"
576 "Set the filter for networks announced to other areas\n"
577 "Name of the acess-list\n")
578{
579 struct ospf6_area *area;
580 struct access_list *list;
581
582 OSPF6_CMD_AREA_GET(argv[0], area);
583
584 list = access_list_lookup (AFI_IP6, argv[1]);
585
586 EXPORT_LIST (area) = list;
587
588 if (EXPORT_NAME (area))
589 free (EXPORT_NAME (area));
590
591 EXPORT_NAME (area) = strdup (argv[1]);
592 ospf6_abr_enable_area (area);
593
594 return CMD_SUCCESS;
595}
596
597DEFUN (no_area_export_list,
598 no_area_export_list_cmd,
599 "no area A.B.C.D export-list NAME",
600 "OSPFv6 area parameters\n"
601 "OSPFv6 area ID in IP address format\n"
602 "Unset the filter for networks announced to other areas\n"
603 "Name of the access-list\n")
604{
605 struct ospf6_area *area;
606
607 OSPF6_CMD_AREA_GET(argv[0], area);
608
609 EXPORT_LIST (area) = 0;
610
611 if (EXPORT_NAME (area))
612 free (EXPORT_NAME (area));
613
614 EXPORT_NAME (area) = NULL;
615 ospf6_abr_enable_area (area);
616
617 return CMD_SUCCESS;
618}
619
hasso508e53e2004-05-18 18:57:06 +0000620DEFUN (show_ipv6_ospf6_spf_tree,
621 show_ipv6_ospf6_spf_tree_cmd,
622 "show ipv6 ospf6 spf tree",
623 SHOW_STR
624 IP6_STR
625 OSPF6_STR
626 "Shortest Path First caculation\n"
627 "Show SPF tree\n")
628{
hasso52dc7ee2004-09-23 19:18:23 +0000629 struct listnode *node;
hasso508e53e2004-05-18 18:57:06 +0000630 struct ospf6_area *oa;
631 struct ospf6_vertex *root;
632 struct ospf6_route *route;
633 struct prefix prefix;
634
635 ospf6_linkstate_prefix (ospf6->router_id, htonl (0), &prefix);
paul1eb8ef22005-04-07 07:30:20 +0000636
637 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
hasso508e53e2004-05-18 18:57:06 +0000638 {
hasso508e53e2004-05-18 18:57:06 +0000639 route = ospf6_route_lookup (&prefix, oa->spf_table);
640 if (route == NULL)
641 {
642 vty_out (vty, "LS entry for root not found in area %s%s",
hasso049207c2004-08-04 20:02:13 +0000643 oa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000644 continue;
645 }
646 root = (struct ospf6_vertex *) route->route_option;
647 ospf6_spf_display_subtree (vty, "", 0, root);
648 }
649
650 return CMD_SUCCESS;
651}
652
653DEFUN (show_ipv6_ospf6_area_spf_tree,
654 show_ipv6_ospf6_area_spf_tree_cmd,
655 "show ipv6 ospf6 area A.B.C.D spf tree",
656 SHOW_STR
657 IP6_STR
658 OSPF6_STR
659 OSPF6_AREA_STR
660 OSPF6_AREA_ID_STR
661 "Shortest Path First caculation\n"
662 "Show SPF tree\n")
663{
664 u_int32_t area_id;
665 struct ospf6_area *oa;
666 struct ospf6_vertex *root;
667 struct ospf6_route *route;
668 struct prefix prefix;
669
670 ospf6_linkstate_prefix (ospf6->router_id, htonl (0), &prefix);
671
672 if (inet_pton (AF_INET, argv[0], &area_id) != 1)
673 {
hasso049207c2004-08-04 20:02:13 +0000674 vty_out (vty, "Malformed Area-ID: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000675 return CMD_SUCCESS;
676 }
677 oa = ospf6_area_lookup (area_id, ospf6);
678 if (oa == NULL)
679 {
hasso049207c2004-08-04 20:02:13 +0000680 vty_out (vty, "No such Area: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000681 return CMD_SUCCESS;
682 }
683
684 route = ospf6_route_lookup (&prefix, oa->spf_table);
685 if (route == NULL)
686 {
687 vty_out (vty, "LS entry for root not found in area %s%s",
hasso049207c2004-08-04 20:02:13 +0000688 oa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000689 return CMD_SUCCESS;
690 }
691 root = (struct ospf6_vertex *) route->route_option;
692 ospf6_spf_display_subtree (vty, "", 0, root);
693
694 return CMD_SUCCESS;
695}
696
hasso508e53e2004-05-18 18:57:06 +0000697DEFUN (show_ipv6_ospf6_simulate_spf_tree_root,
698 show_ipv6_ospf6_simulate_spf_tree_root_cmd,
699 "show ipv6 ospf6 simulate spf-tree A.B.C.D area A.B.C.D",
700 SHOW_STR
701 IP6_STR
702 OSPF6_STR
703 "Shortest Path First caculation\n"
704 "Show SPF tree\n"
705 "Specify root's router-id to calculate another router's SPF tree\n")
706{
707 u_int32_t area_id;
708 struct ospf6_area *oa;
709 struct ospf6_vertex *root;
710 struct ospf6_route *route;
711 struct prefix prefix;
712 u_int32_t router_id;
713 struct ospf6_route_table *spf_table;
714 unsigned char tmp_debug_ospf6_spf = 0;
715
716 inet_pton (AF_INET, argv[0], &router_id);
717 ospf6_linkstate_prefix (router_id, htonl (0), &prefix);
718
719 if (inet_pton (AF_INET, argv[1], &area_id) != 1)
720 {
hasso049207c2004-08-04 20:02:13 +0000721 vty_out (vty, "Malformed Area-ID: %s%s", argv[1], VNL);
hasso508e53e2004-05-18 18:57:06 +0000722 return CMD_SUCCESS;
723 }
724 oa = ospf6_area_lookup (area_id, ospf6);
725 if (oa == NULL)
726 {
hasso049207c2004-08-04 20:02:13 +0000727 vty_out (vty, "No such Area: %s%s", argv[1], VNL);
hasso508e53e2004-05-18 18:57:06 +0000728 return CMD_SUCCESS;
729 }
730
731 tmp_debug_ospf6_spf = conf_debug_ospf6_spf;
732 conf_debug_ospf6_spf = 0;
733
Paul Jakmacf1ce252006-05-15 10:46:07 +0000734 spf_table = OSPF6_ROUTE_TABLE_CREATE (NONE, SPF_RESULTS);
hasso508e53e2004-05-18 18:57:06 +0000735 ospf6_spf_calculation (router_id, spf_table, oa);
736
737 conf_debug_ospf6_spf = tmp_debug_ospf6_spf;
738
739 route = ospf6_route_lookup (&prefix, spf_table);
740 if (route == NULL)
741 {
742 ospf6_spf_table_finish (spf_table);
743 ospf6_route_table_delete (spf_table);
744 return CMD_SUCCESS;
745 }
746 root = (struct ospf6_vertex *) route->route_option;
747 ospf6_spf_display_subtree (vty, "", 0, root);
748
749 ospf6_spf_table_finish (spf_table);
750 ospf6_route_table_delete (spf_table);
751
752 return CMD_SUCCESS;
753}
paul718e3742002-12-13 20:15:29 +0000754
755void
Paul Jakma6ac29a52008-08-15 13:45:30 +0100756ospf6_area_init (void)
paul718e3742002-12-13 20:15:29 +0000757{
hasso508e53e2004-05-18 18:57:06 +0000758 install_element (VIEW_NODE, &show_ipv6_ospf6_spf_tree_cmd);
hasso508e53e2004-05-18 18:57:06 +0000759 install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_tree_cmd);
hasso508e53e2004-05-18 18:57:06 +0000760 install_element (VIEW_NODE, &show_ipv6_ospf6_simulate_spf_tree_root_cmd);
761
762 install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_tree_cmd);
hasso508e53e2004-05-18 18:57:06 +0000763 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_tree_cmd);
hasso508e53e2004-05-18 18:57:06 +0000764 install_element (ENABLE_NODE, &show_ipv6_ospf6_simulate_spf_tree_root_cmd);
hasso6452df02004-08-15 05:52:07 +0000765
766 install_element (OSPF6_NODE, &area_range_cmd);
767 install_element (OSPF6_NODE, &area_range_advertise_cmd);
768 install_element (OSPF6_NODE, &no_area_range_cmd);
hasso34956b32005-06-24 08:44:02 +0000769
770 install_element (OSPF6_NODE, &area_import_list_cmd);
771 install_element (OSPF6_NODE, &no_area_import_list_cmd);
772 install_element (OSPF6_NODE, &area_export_list_cmd);
773 install_element (OSPF6_NODE, &no_area_export_list_cmd);
774
775 install_element (OSPF6_NODE, &area_filter_list_cmd);
776 install_element (OSPF6_NODE, &no_area_filter_list_cmd);
777
paul718e3742002-12-13 20:15:29 +0000778}
hasso049207c2004-08-04 20:02:13 +0000779
hasso6452df02004-08-15 05:52:07 +0000780