blob: 1e07d8579482cd06bee5498675ff1ab41b103f46 [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 }
Dinesh Dutt3810e062013-08-24 07:54:09 +000070 ospf6_spf_schedule (OSPF6_PROCESS(OSPF6_AREA (lsa->lsdb->data)->ospf6));
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 }
Dinesh Dutt3810e062013-08-24 07:54:09 +0000100 ospf6_spf_schedule (OSPF6_PROCESS(OSPF6_AREA (lsa->lsdb->data)->ospf6));
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 THREAD_OFF (oa->thread_spf_calculation);
207 THREAD_OFF (oa->thread_route_calculation);
paul718e3742002-12-13 20:15:29 +0000208
hasso508e53e2004-05-18 18:57:06 +0000209 listnode_delete (oa->ospf6->area_list, oa);
210 oa->ospf6 = NULL;
paul718e3742002-12-13 20:15:29 +0000211
212 /* free area */
hasso508e53e2004-05-18 18:57:06 +0000213 XFREE (MTYPE_OSPF6_AREA, oa);
paul718e3742002-12-13 20:15:29 +0000214}
215
216struct ospf6_area *
hasso508e53e2004-05-18 18:57:06 +0000217ospf6_area_lookup (u_int32_t area_id, struct ospf6 *ospf6)
paul718e3742002-12-13 20:15:29 +0000218{
hasso508e53e2004-05-18 18:57:06 +0000219 struct ospf6_area *oa;
hasso52dc7ee2004-09-23 19:18:23 +0000220 struct listnode *n;
paul718e3742002-12-13 20:15:29 +0000221
paul1eb8ef22005-04-07 07:30:20 +0000222 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, n, oa))
223 if (oa->area_id == area_id)
224 return oa;
paul718e3742002-12-13 20:15:29 +0000225
226 return (struct ospf6_area *) NULL;
227}
228
Paul Jakma6ac29a52008-08-15 13:45:30 +0100229static struct ospf6_area *
hasso6452df02004-08-15 05:52:07 +0000230ospf6_area_get (u_int32_t area_id, struct ospf6 *o)
231{
232 struct ospf6_area *oa;
233 oa = ospf6_area_lookup (area_id, o);
234 if (oa == NULL)
235 oa = ospf6_area_create (area_id, o);
236 return oa;
237}
238
paul718e3742002-12-13 20:15:29 +0000239void
hasso508e53e2004-05-18 18:57:06 +0000240ospf6_area_enable (struct ospf6_area *oa)
paul718e3742002-12-13 20:15:29 +0000241{
paul1eb8ef22005-04-07 07:30:20 +0000242 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000243 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000244
hasso6452df02004-08-15 05:52:07 +0000245 SET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
paul718e3742002-12-13 20:15:29 +0000246
paul1eb8ef22005-04-07 07:30:20 +0000247 for (ALL_LIST_ELEMENTS (oa->if_list, node, nnode, oi))
248 ospf6_interface_enable (oi);
paul718e3742002-12-13 20:15:29 +0000249}
250
251void
hasso508e53e2004-05-18 18:57:06 +0000252ospf6_area_disable (struct ospf6_area *oa)
paul718e3742002-12-13 20:15:29 +0000253{
paul1eb8ef22005-04-07 07:30:20 +0000254 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000255 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000256
hasso6452df02004-08-15 05:52:07 +0000257 UNSET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
hasso508e53e2004-05-18 18:57:06 +0000258
paul1eb8ef22005-04-07 07:30:20 +0000259 for (ALL_LIST_ELEMENTS (oa->if_list, node, nnode, oi))
260 ospf6_interface_disable (oi);
paul718e3742002-12-13 20:15:29 +0000261}
262
hasso508e53e2004-05-18 18:57:06 +0000263
264void
265ospf6_area_show (struct vty *vty, struct ospf6_area *oa)
266{
hasso52dc7ee2004-09-23 19:18:23 +0000267 struct listnode *i;
hasso508e53e2004-05-18 18:57:06 +0000268 struct ospf6_interface *oi;
269
hasso049207c2004-08-04 20:02:13 +0000270 vty_out (vty, " Area %s%s", oa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000271 vty_out (vty, " Number of Area scoped LSAs is %u%s",
hasso049207c2004-08-04 20:02:13 +0000272 oa->lsdb->count, VNL);
hasso508e53e2004-05-18 18:57:06 +0000273
274 vty_out (vty, " Interface attached to this area:");
paul1eb8ef22005-04-07 07:30:20 +0000275 for (ALL_LIST_ELEMENTS_RO (oa->if_list, i, oi))
276 vty_out (vty, " %s", oi->interface->name);
277
hasso049207c2004-08-04 20:02:13 +0000278 vty_out (vty, "%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000279}
280
281
hasso049207c2004-08-04 20:02:13 +0000282#define OSPF6_CMD_AREA_LOOKUP(str, oa) \
283{ \
284 u_int32_t area_id = 0; \
285 if (inet_pton (AF_INET, str, &area_id) != 1) \
286 { \
287 vty_out (vty, "Malformed Area-ID: %s%s", str, VNL); \
288 return CMD_SUCCESS; \
289 } \
290 oa = ospf6_area_lookup (area_id, ospf6); \
291 if (oa == NULL) \
292 { \
293 vty_out (vty, "No such Area: %s%s", str, VNL); \
294 return CMD_SUCCESS; \
295 } \
hasso508e53e2004-05-18 18:57:06 +0000296}
297
hasso6452df02004-08-15 05:52:07 +0000298#define OSPF6_CMD_AREA_GET(str, oa) \
299{ \
300 u_int32_t area_id = 0; \
301 if (inet_pton (AF_INET, str, &area_id) != 1) \
302 { \
303 vty_out (vty, "Malformed Area-ID: %s%s", str, VNL); \
304 return CMD_SUCCESS; \
305 } \
306 oa = ospf6_area_get (area_id, ospf6); \
307}
308
309DEFUN (area_range,
310 area_range_cmd,
311 "area A.B.C.D range X:X::X:X/M",
312 "OSPF area parameters\n"
313 OSPF6_AREA_ID_STR
314 "Configured address range\n"
315 "Specify IPv6 prefix\n"
316 )
317{
318 int ret;
319 struct ospf6_area *oa;
320 struct prefix prefix;
321 struct ospf6_route *range;
322
323 OSPF6_CMD_AREA_GET (argv[0], oa);
324 argc--;
325 argv++;
326
327 ret = str2prefix (argv[0], &prefix);
328 if (ret != 1 || prefix.family != AF_INET6)
329 {
330 vty_out (vty, "Malformed argument: %s%s", argv[0], VNL);
331 return CMD_SUCCESS;
332 }
333 argc--;
334 argv++;
335
336 range = ospf6_route_lookup (&prefix, oa->range_table);
337 if (range == NULL)
338 {
339 range = ospf6_route_create ();
340 range->type = OSPF6_DEST_TYPE_RANGE;
341 range->prefix = prefix;
342 }
343
344 if (argc)
345 {
346 if (! strcmp (argv[0], "not-advertise"))
347 SET_FLAG (range->flag, OSPF6_ROUTE_DO_NOT_ADVERTISE);
348 else if (! strcmp (argv[0], "advertise"))
349 UNSET_FLAG (range->flag, OSPF6_ROUTE_DO_NOT_ADVERTISE);
350 }
351
Jon86f9e5a2009-02-11 17:22:03 -0800352 if (range->rnode)
353 {
354 vty_out (vty, "Range already defined: %s%s", argv[-1], VNL);
355 return CMD_WARNING;
356 }
357
hasso6452df02004-08-15 05:52:07 +0000358 ospf6_route_add (range, oa->range_table);
359 return CMD_SUCCESS;
360}
361
362ALIAS (area_range,
363 area_range_advertise_cmd,
364 "area A.B.C.D range X:X::X:X/M (advertise|not-advertise)",
365 "OSPF area parameters\n"
366 OSPF6_AREA_ID_STR
367 "Configured address range\n"
368 "Specify IPv6 prefix\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +0100369 )
hasso6452df02004-08-15 05:52:07 +0000370
371DEFUN (no_area_range,
372 no_area_range_cmd,
373 "no area A.B.C.D range X:X::X:X/M",
374 "OSPF area parameters\n"
375 OSPF6_AREA_ID_STR
376 "Configured address range\n"
377 "Specify IPv6 prefix\n"
378 )
379{
380 int ret;
381 struct ospf6_area *oa;
382 struct prefix prefix;
383 struct ospf6_route *range;
384
385 OSPF6_CMD_AREA_GET (argv[0], oa);
386 argc--;
387 argv++;
388
389 ret = str2prefix (argv[0], &prefix);
390 if (ret != 1 || prefix.family != AF_INET6)
391 {
392 vty_out (vty, "Malformed argument: %s%s", argv[0], VNL);
393 return CMD_SUCCESS;
394 }
395
396 range = ospf6_route_lookup (&prefix, oa->range_table);
397 if (range == NULL)
398 {
399 vty_out (vty, "Range %s does not exists.%s", argv[0], VNL);
400 return CMD_SUCCESS;
401 }
402
403 ospf6_route_remove (range, oa->range_table);
Dinesh Dutt8551e6d2013-10-22 17:42:18 -0700404
hasso6452df02004-08-15 05:52:07 +0000405 return CMD_SUCCESS;
406}
407
408void
409ospf6_area_config_write (struct vty *vty)
410{
hasso52dc7ee2004-09-23 19:18:23 +0000411 struct listnode *node;
hasso6452df02004-08-15 05:52:07 +0000412 struct ospf6_area *oa;
413 struct ospf6_route *range;
414 char buf[128];
415
paul1eb8ef22005-04-07 07:30:20 +0000416 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
hasso6452df02004-08-15 05:52:07 +0000417 {
hasso6452df02004-08-15 05:52:07 +0000418 for (range = ospf6_route_head (oa->range_table); range;
419 range = ospf6_route_next (range))
420 {
421 prefix2str (&range->prefix, buf, sizeof (buf));
422 vty_out (vty, " area %s range %s%s", oa->name, buf, VNL);
423 }
Jon Andersson5fdaa042011-09-13 15:47:14 +0400424 if (PREFIX_NAME_IN (oa))
425 vty_out (vty, " area %s filter-list prefix %s in%s",
426 oa->name, PREFIX_NAME_IN (oa), VNL);
427 if (PREFIX_NAME_OUT (oa))
428 vty_out (vty, " area %s filter-list prefix %s out%s",
429 oa->name, PREFIX_NAME_OUT (oa), VNL);
430 if (IMPORT_NAME (oa))
431 vty_out (vty, " area %s import-list %s%s",
432 oa->name, IMPORT_NAME (oa), VNL);
433 if (EXPORT_NAME (oa))
434 vty_out (vty, " area %s export-list %s%s",
435 oa->name, EXPORT_NAME (oa), VNL);
hasso6452df02004-08-15 05:52:07 +0000436 }
437}
438
hasso34956b32005-06-24 08:44:02 +0000439DEFUN (area_filter_list,
440 area_filter_list_cmd,
441 "area A.B.C.D filter-list prefix WORD (in|out)",
442 "OSPFv6 area parameters\n"
443 "OSPFv6 area ID in IP address format\n"
444 "Filter networks between OSPFv6 areas\n"
445 "Filter prefixes between OSPFv6 areas\n"
446 "Name of an IPv6 prefix-list\n"
447 "Filter networks sent to this area\n"
448 "Filter networks sent from this area\n")
449{
450 struct ospf6_area *area;
451 struct prefix_list *plist;
452
453 OSPF6_CMD_AREA_GET (argv[0], area);
454 argc--;
455 argv++;
456
Christian Hammers75d044d2011-09-12 14:23:05 +0400457 plist = prefix_list_lookup (AFI_IP6, argv[0]);
458 if (strncmp (argv[1], "in", 2) == 0)
hasso34956b32005-06-24 08:44:02 +0000459 {
460 PREFIX_LIST_IN (area) = plist;
461 if (PREFIX_NAME_IN (area))
462 free (PREFIX_NAME_IN (area));
463
Christian Hammers75d044d2011-09-12 14:23:05 +0400464 PREFIX_NAME_IN (area) = strdup (argv[0]);
hasso34956b32005-06-24 08:44:02 +0000465 ospf6_abr_reimport (area);
466 }
467 else
468 {
469 PREFIX_LIST_OUT (area) = plist;
470 if (PREFIX_NAME_OUT (area))
471 free (PREFIX_NAME_OUT (area));
472
Christian Hammers75d044d2011-09-12 14:23:05 +0400473 PREFIX_NAME_OUT (area) = strdup (argv[0]);
hasso34956b32005-06-24 08:44:02 +0000474 ospf6_abr_enable_area (area);
475 }
476
477 return CMD_SUCCESS;
478}
479
480DEFUN (no_area_filter_list,
481 no_area_filter_list_cmd,
482 "no area A.B.C.D filter-list prefix WORD (in|out)",
483 NO_STR
484 "OSPFv6 area parameters\n"
485 "OSPFv6 area ID in IP address format\n"
486 "Filter networks between OSPFv6 areas\n"
487 "Filter prefixes between OSPFv6 areas\n"
488 "Name of an IPv6 prefix-list\n"
489 "Filter networks sent to this area\n"
490 "Filter networks sent from this area\n")
491{
492 struct ospf6_area *area;
493 struct prefix_list *plist;
494
495 OSPF6_CMD_AREA_GET (argv[0], area);
496 argc--;
497 argv++;
498
Christian Hammers75d044d2011-09-12 14:23:05 +0400499 plist = prefix_list_lookup (AFI_IP6, argv[0]);
500 if (strncmp (argv[1], "in", 2) == 0)
hasso34956b32005-06-24 08:44:02 +0000501 {
502 if (PREFIX_NAME_IN (area))
Christian Hammers75d044d2011-09-12 14:23:05 +0400503 if (strcmp (PREFIX_NAME_IN (area), argv[0]) != 0)
hasso34956b32005-06-24 08:44:02 +0000504 return CMD_SUCCESS;
505
506 PREFIX_LIST_IN (area) = NULL;
507 if (PREFIX_NAME_IN (area))
508 free (PREFIX_NAME_IN (area));
509
510 PREFIX_NAME_IN (area) = NULL;
511 ospf6_abr_reimport (area);
512 }
513 else
514 {
515 if (PREFIX_NAME_OUT (area))
Christian Hammers75d044d2011-09-12 14:23:05 +0400516 if (strcmp (PREFIX_NAME_OUT (area), argv[0]) != 0)
hasso34956b32005-06-24 08:44:02 +0000517 return CMD_SUCCESS;
518
519 PREFIX_LIST_OUT (area) = NULL;
520 if (PREFIX_NAME_OUT (area))
521 free (PREFIX_NAME_OUT (area));
522
523 PREFIX_NAME_OUT (area) = NULL;
524 ospf6_abr_enable_area (area);
525 }
526
527 return CMD_SUCCESS;
528}
529
530DEFUN (area_import_list,
531 area_import_list_cmd,
532 "area A.B.C.D import-list NAME",
533 "OSPFv6 area parameters\n"
534 "OSPFv6 area ID in IP address format\n"
535 "Set the filter for networks from other areas announced to the specified one\n"
536 "Name of the acess-list\n")
537{
538 struct ospf6_area *area;
539 struct access_list *list;
540
541 OSPF6_CMD_AREA_GET(argv[0], area);
542
543 list = access_list_lookup (AFI_IP6, argv[1]);
544
545 IMPORT_LIST (area) = list;
546
547 if (IMPORT_NAME (area))
548 free (IMPORT_NAME (area));
549
550 IMPORT_NAME (area) = strdup (argv[1]);
551 ospf6_abr_reimport (area);
552
553 return CMD_SUCCESS;
554}
555
556DEFUN (no_area_import_list,
557 no_area_import_list_cmd,
558 "no area A.B.C.D import-list NAME",
559 "OSPFv6 area parameters\n"
560 "OSPFv6 area ID in IP address format\n"
561 "Unset the filter for networks announced to other areas\n"
562 "NAme of the access-list\n")
563{
564 struct ospf6_area *area;
565
566 OSPF6_CMD_AREA_GET(argv[0], area);
567
568 IMPORT_LIST (area) = 0;
569
570 if (IMPORT_NAME (area))
571 free (IMPORT_NAME (area));
572
573 IMPORT_NAME (area) = NULL;
574 ospf6_abr_reimport (area);
575
576 return CMD_SUCCESS;
577}
578
579DEFUN (area_export_list,
580 area_export_list_cmd,
581 "area A.B.C.D export-list NAME",
582 "OSPFv6 area parameters\n"
583 "OSPFv6 area ID in IP address format\n"
584 "Set the filter for networks announced to other areas\n"
585 "Name of the acess-list\n")
586{
587 struct ospf6_area *area;
588 struct access_list *list;
589
590 OSPF6_CMD_AREA_GET(argv[0], area);
591
592 list = access_list_lookup (AFI_IP6, argv[1]);
593
594 EXPORT_LIST (area) = list;
595
596 if (EXPORT_NAME (area))
597 free (EXPORT_NAME (area));
598
599 EXPORT_NAME (area) = strdup (argv[1]);
600 ospf6_abr_enable_area (area);
601
602 return CMD_SUCCESS;
603}
604
605DEFUN (no_area_export_list,
606 no_area_export_list_cmd,
607 "no area A.B.C.D export-list NAME",
608 "OSPFv6 area parameters\n"
609 "OSPFv6 area ID in IP address format\n"
610 "Unset the filter for networks announced to other areas\n"
611 "Name of the access-list\n")
612{
613 struct ospf6_area *area;
614
615 OSPF6_CMD_AREA_GET(argv[0], area);
616
617 EXPORT_LIST (area) = 0;
618
619 if (EXPORT_NAME (area))
620 free (EXPORT_NAME (area));
621
622 EXPORT_NAME (area) = NULL;
623 ospf6_abr_enable_area (area);
624
625 return CMD_SUCCESS;
626}
627
hasso508e53e2004-05-18 18:57:06 +0000628DEFUN (show_ipv6_ospf6_spf_tree,
629 show_ipv6_ospf6_spf_tree_cmd,
630 "show ipv6 ospf6 spf tree",
631 SHOW_STR
632 IP6_STR
633 OSPF6_STR
634 "Shortest Path First caculation\n"
635 "Show SPF tree\n")
636{
hasso52dc7ee2004-09-23 19:18:23 +0000637 struct listnode *node;
hasso508e53e2004-05-18 18:57:06 +0000638 struct ospf6_area *oa;
639 struct ospf6_vertex *root;
640 struct ospf6_route *route;
641 struct prefix prefix;
642
643 ospf6_linkstate_prefix (ospf6->router_id, htonl (0), &prefix);
paul1eb8ef22005-04-07 07:30:20 +0000644
645 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
hasso508e53e2004-05-18 18:57:06 +0000646 {
hasso508e53e2004-05-18 18:57:06 +0000647 route = ospf6_route_lookup (&prefix, oa->spf_table);
648 if (route == NULL)
649 {
650 vty_out (vty, "LS entry for root not found in area %s%s",
hasso049207c2004-08-04 20:02:13 +0000651 oa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000652 continue;
653 }
654 root = (struct ospf6_vertex *) route->route_option;
655 ospf6_spf_display_subtree (vty, "", 0, root);
656 }
657
658 return CMD_SUCCESS;
659}
660
661DEFUN (show_ipv6_ospf6_area_spf_tree,
662 show_ipv6_ospf6_area_spf_tree_cmd,
663 "show ipv6 ospf6 area A.B.C.D spf tree",
664 SHOW_STR
665 IP6_STR
666 OSPF6_STR
667 OSPF6_AREA_STR
668 OSPF6_AREA_ID_STR
669 "Shortest Path First caculation\n"
670 "Show SPF tree\n")
671{
672 u_int32_t area_id;
673 struct ospf6_area *oa;
674 struct ospf6_vertex *root;
675 struct ospf6_route *route;
676 struct prefix prefix;
677
678 ospf6_linkstate_prefix (ospf6->router_id, htonl (0), &prefix);
679
680 if (inet_pton (AF_INET, argv[0], &area_id) != 1)
681 {
hasso049207c2004-08-04 20:02:13 +0000682 vty_out (vty, "Malformed Area-ID: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000683 return CMD_SUCCESS;
684 }
685 oa = ospf6_area_lookup (area_id, ospf6);
686 if (oa == NULL)
687 {
hasso049207c2004-08-04 20:02:13 +0000688 vty_out (vty, "No such Area: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000689 return CMD_SUCCESS;
690 }
691
692 route = ospf6_route_lookup (&prefix, oa->spf_table);
693 if (route == NULL)
694 {
695 vty_out (vty, "LS entry for root not found in area %s%s",
hasso049207c2004-08-04 20:02:13 +0000696 oa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000697 return CMD_SUCCESS;
698 }
699 root = (struct ospf6_vertex *) route->route_option;
700 ospf6_spf_display_subtree (vty, "", 0, root);
701
702 return CMD_SUCCESS;
703}
704
hasso508e53e2004-05-18 18:57:06 +0000705DEFUN (show_ipv6_ospf6_simulate_spf_tree_root,
706 show_ipv6_ospf6_simulate_spf_tree_root_cmd,
707 "show ipv6 ospf6 simulate spf-tree A.B.C.D area A.B.C.D",
708 SHOW_STR
709 IP6_STR
710 OSPF6_STR
711 "Shortest Path First caculation\n"
712 "Show SPF tree\n"
713 "Specify root's router-id to calculate another router's SPF tree\n")
714{
715 u_int32_t area_id;
716 struct ospf6_area *oa;
717 struct ospf6_vertex *root;
718 struct ospf6_route *route;
719 struct prefix prefix;
720 u_int32_t router_id;
721 struct ospf6_route_table *spf_table;
722 unsigned char tmp_debug_ospf6_spf = 0;
723
724 inet_pton (AF_INET, argv[0], &router_id);
725 ospf6_linkstate_prefix (router_id, htonl (0), &prefix);
726
727 if (inet_pton (AF_INET, argv[1], &area_id) != 1)
728 {
hasso049207c2004-08-04 20:02:13 +0000729 vty_out (vty, "Malformed Area-ID: %s%s", argv[1], VNL);
hasso508e53e2004-05-18 18:57:06 +0000730 return CMD_SUCCESS;
731 }
732 oa = ospf6_area_lookup (area_id, ospf6);
733 if (oa == NULL)
734 {
hasso049207c2004-08-04 20:02:13 +0000735 vty_out (vty, "No such Area: %s%s", argv[1], VNL);
hasso508e53e2004-05-18 18:57:06 +0000736 return CMD_SUCCESS;
737 }
738
739 tmp_debug_ospf6_spf = conf_debug_ospf6_spf;
740 conf_debug_ospf6_spf = 0;
741
Paul Jakmacf1ce252006-05-15 10:46:07 +0000742 spf_table = OSPF6_ROUTE_TABLE_CREATE (NONE, SPF_RESULTS);
hasso508e53e2004-05-18 18:57:06 +0000743 ospf6_spf_calculation (router_id, spf_table, oa);
744
745 conf_debug_ospf6_spf = tmp_debug_ospf6_spf;
746
747 route = ospf6_route_lookup (&prefix, spf_table);
748 if (route == NULL)
749 {
750 ospf6_spf_table_finish (spf_table);
751 ospf6_route_table_delete (spf_table);
752 return CMD_SUCCESS;
753 }
754 root = (struct ospf6_vertex *) route->route_option;
755 ospf6_spf_display_subtree (vty, "", 0, root);
756
757 ospf6_spf_table_finish (spf_table);
758 ospf6_route_table_delete (spf_table);
759
760 return CMD_SUCCESS;
761}
paul718e3742002-12-13 20:15:29 +0000762
763void
Paul Jakma6ac29a52008-08-15 13:45:30 +0100764ospf6_area_init (void)
paul718e3742002-12-13 20:15:29 +0000765{
hasso508e53e2004-05-18 18:57:06 +0000766 install_element (VIEW_NODE, &show_ipv6_ospf6_spf_tree_cmd);
hasso508e53e2004-05-18 18:57:06 +0000767 install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_tree_cmd);
hasso508e53e2004-05-18 18:57:06 +0000768 install_element (VIEW_NODE, &show_ipv6_ospf6_simulate_spf_tree_root_cmd);
769
770 install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_tree_cmd);
hasso508e53e2004-05-18 18:57:06 +0000771 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_tree_cmd);
hasso508e53e2004-05-18 18:57:06 +0000772 install_element (ENABLE_NODE, &show_ipv6_ospf6_simulate_spf_tree_root_cmd);
hasso6452df02004-08-15 05:52:07 +0000773
774 install_element (OSPF6_NODE, &area_range_cmd);
775 install_element (OSPF6_NODE, &area_range_advertise_cmd);
776 install_element (OSPF6_NODE, &no_area_range_cmd);
hasso34956b32005-06-24 08:44:02 +0000777
778 install_element (OSPF6_NODE, &area_import_list_cmd);
779 install_element (OSPF6_NODE, &no_area_import_list_cmd);
780 install_element (OSPF6_NODE, &area_export_list_cmd);
781 install_element (OSPF6_NODE, &no_area_export_list_cmd);
782
783 install_element (OSPF6_NODE, &area_filter_list_cmd);
784 install_element (OSPF6_NODE, &no_area_filter_list_cmd);
785
paul718e3742002-12-13 20:15:29 +0000786}
hasso049207c2004-08-04 20:02:13 +0000787
hasso6452df02004-08-15 05:52:07 +0000788