blob: fc2103ca65fce8d5c608d96f6f02dc190d05a43c [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"
33
hasso508e53e2004-05-18 18:57:06 +000034#include "ospf6_proto.h"
35#include "ospf6_lsa.h"
36#include "ospf6_lsdb.h"
37#include "ospf6_route.h"
38#include "ospf6_spf.h"
39#include "ospf6_top.h"
40#include "ospf6_area.h"
41#include "ospf6_interface.h"
42#include "ospf6_intra.h"
hasso049207c2004-08-04 20:02:13 +000043#include "ospf6_abr.h"
44#include "ospf6d.h"
paul718e3742002-12-13 20:15:29 +000045
hasso508e53e2004-05-18 18:57:06 +000046int
47ospf6_area_cmp (void *va, void *vb)
paul718e3742002-12-13 20:15:29 +000048{
hasso508e53e2004-05-18 18:57:06 +000049 struct ospf6_area *oa = (struct ospf6_area *) va;
50 struct ospf6_area *ob = (struct ospf6_area *) vb;
hasso6452df02004-08-15 05:52:07 +000051 return (ntohl (oa->area_id) < ntohl (ob->area_id) ? -1 : 1);
paul718e3742002-12-13 20:15:29 +000052}
53
hasso508e53e2004-05-18 18:57:06 +000054/* schedule routing table recalculation */
paul718e3742002-12-13 20:15:29 +000055void
hasso508e53e2004-05-18 18:57:06 +000056ospf6_area_lsdb_hook_add (struct ospf6_lsa *lsa)
paul718e3742002-12-13 20:15:29 +000057{
hasso508e53e2004-05-18 18:57:06 +000058 switch (ntohs (lsa->header->type))
paul718e3742002-12-13 20:15:29 +000059 {
hasso508e53e2004-05-18 18:57:06 +000060 case OSPF6_LSTYPE_ROUTER:
61 case OSPF6_LSTYPE_NETWORK:
hasso6452df02004-08-15 05:52:07 +000062 ospf6_spf_schedule (OSPF6_AREA (lsa->lsdb->data));
hasso508e53e2004-05-18 18:57:06 +000063 break;
paul718e3742002-12-13 20:15:29 +000064
hasso508e53e2004-05-18 18:57:06 +000065 case OSPF6_LSTYPE_INTRA_PREFIX:
66 ospf6_intra_prefix_lsa_add (lsa);
67 break;
68
69 case OSPF6_LSTYPE_INTER_PREFIX:
70 case OSPF6_LSTYPE_INTER_ROUTER:
71 break;
72
73 default:
74 if (IS_OSPF6_DEBUG_LSA (RECV))
hasso6452df02004-08-15 05:52:07 +000075 zlog_info ("Unknown LSA in Area %s's lsdb",
76 OSPF6_AREA (lsa->lsdb->data)->name);
hasso508e53e2004-05-18 18:57:06 +000077 break;
78 }
paul718e3742002-12-13 20:15:29 +000079}
80
81void
hasso508e53e2004-05-18 18:57:06 +000082ospf6_area_lsdb_hook_remove (struct ospf6_lsa *lsa)
paul718e3742002-12-13 20:15:29 +000083{
hasso508e53e2004-05-18 18:57:06 +000084 switch (ntohs (lsa->header->type))
paul718e3742002-12-13 20:15:29 +000085 {
hasso508e53e2004-05-18 18:57:06 +000086 case OSPF6_LSTYPE_ROUTER:
87 case OSPF6_LSTYPE_NETWORK:
hasso6452df02004-08-15 05:52:07 +000088 ospf6_spf_schedule (OSPF6_AREA (lsa->lsdb->data));
hasso508e53e2004-05-18 18:57:06 +000089 break;
paul718e3742002-12-13 20:15:29 +000090
hasso508e53e2004-05-18 18:57:06 +000091 case OSPF6_LSTYPE_INTRA_PREFIX:
92 ospf6_intra_prefix_lsa_remove (lsa);
93 break;
94
95 case OSPF6_LSTYPE_INTER_PREFIX:
96 case OSPF6_LSTYPE_INTER_ROUTER:
97 break;
98
99 default:
100 if (IS_OSPF6_DEBUG_LSA (RECV))
hasso6452df02004-08-15 05:52:07 +0000101 zlog_info ("Unknown LSA in Area %s's lsdb",
102 OSPF6_AREA (lsa->lsdb->data)->name);
hasso508e53e2004-05-18 18:57:06 +0000103 break;
104 }
105}
106
107void
108ospf6_area_route_hook_add (struct ospf6_route *route)
109{
110 struct ospf6_route *copy = ospf6_route_copy (route);
111 ospf6_route_add (copy, ospf6->route_table);
112}
113
114void
115ospf6_area_route_hook_remove (struct ospf6_route *route)
116{
117 struct ospf6_route *copy;
118
119 copy = ospf6_route_lookup_identical (route, ospf6->route_table);
120 if (copy)
121 ospf6_route_remove (copy, ospf6->route_table);
paul718e3742002-12-13 20:15:29 +0000122}
123
124/* Make new area structure */
125struct ospf6_area *
hasso508e53e2004-05-18 18:57:06 +0000126ospf6_area_create (u_int32_t area_id, struct ospf6 *o)
paul718e3742002-12-13 20:15:29 +0000127{
hasso508e53e2004-05-18 18:57:06 +0000128 struct ospf6_area *oa;
hasso049207c2004-08-04 20:02:13 +0000129 struct ospf6_route *route;
paul718e3742002-12-13 20:15:29 +0000130
hasso508e53e2004-05-18 18:57:06 +0000131 oa = XCALLOC (MTYPE_OSPF6_AREA, sizeof (struct ospf6_area));
paul718e3742002-12-13 20:15:29 +0000132
hasso508e53e2004-05-18 18:57:06 +0000133 inet_ntop (AF_INET, &area_id, oa->name, sizeof (oa->name));
134 oa->area_id = area_id;
135 oa->if_list = list_new ();
paul718e3742002-12-13 20:15:29 +0000136
hasso6452df02004-08-15 05:52:07 +0000137 oa->lsdb = ospf6_lsdb_create (oa);
hasso508e53e2004-05-18 18:57:06 +0000138 oa->lsdb->hook_add = ospf6_area_lsdb_hook_add;
139 oa->lsdb->hook_remove = ospf6_area_lsdb_hook_remove;
hasso6452df02004-08-15 05:52:07 +0000140 oa->lsdb_self = ospf6_lsdb_create (oa);
paul718e3742002-12-13 20:15:29 +0000141
hasso508e53e2004-05-18 18:57:06 +0000142 oa->spf_table = ospf6_route_table_create ();
143 oa->route_table = ospf6_route_table_create ();
144 oa->route_table->hook_add = ospf6_area_route_hook_add;
145 oa->route_table->hook_remove = ospf6_area_route_hook_remove;
paul718e3742002-12-13 20:15:29 +0000146
hasso6452df02004-08-15 05:52:07 +0000147 oa->range_table = ospf6_route_table_create ();
148 oa->summary_prefix = ospf6_route_table_create ();
149 oa->summary_router = ospf6_route_table_create ();
150
hasso508e53e2004-05-18 18:57:06 +0000151 /* set default options */
152 OSPF6_OPT_SET (oa->options, OSPF6_OPT_V6);
153 OSPF6_OPT_SET (oa->options, OSPF6_OPT_E);
154 OSPF6_OPT_SET (oa->options, OSPF6_OPT_R);
paul718e3742002-12-13 20:15:29 +0000155
hasso508e53e2004-05-18 18:57:06 +0000156 oa->ospf6 = o;
157 listnode_add_sort (o->area_list, oa);
paul718e3742002-12-13 20:15:29 +0000158
hasso049207c2004-08-04 20:02:13 +0000159 /* import athoer area's routes as inter-area routes */
160 for (route = ospf6_route_head (o->route_table); route;
161 route = ospf6_route_next (route))
hasso6452df02004-08-15 05:52:07 +0000162 ospf6_abr_originate_summary_to_area (route, oa);
hasso049207c2004-08-04 20:02:13 +0000163
hasso508e53e2004-05-18 18:57:06 +0000164 return oa;
paul718e3742002-12-13 20:15:29 +0000165}
166
167void
hasso508e53e2004-05-18 18:57:06 +0000168ospf6_area_delete (struct ospf6_area *oa)
paul718e3742002-12-13 20:15:29 +0000169{
170 listnode n;
hasso508e53e2004-05-18 18:57:06 +0000171 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000172
hasso6452df02004-08-15 05:52:07 +0000173 ospf6_route_table_delete (oa->range_table);
174 ospf6_route_table_delete (oa->summary_prefix);
175 ospf6_route_table_delete (oa->summary_router);
hasso049207c2004-08-04 20:02:13 +0000176
paul718e3742002-12-13 20:15:29 +0000177 /* ospf6 interface list */
hasso508e53e2004-05-18 18:57:06 +0000178 for (n = listhead (oa->if_list); n; nextnode (n))
paul718e3742002-12-13 20:15:29 +0000179 {
hasso508e53e2004-05-18 18:57:06 +0000180 oi = (struct ospf6_interface *) getdata (n);
181 ospf6_interface_delete (oi);
paul718e3742002-12-13 20:15:29 +0000182 }
hasso508e53e2004-05-18 18:57:06 +0000183 list_delete (oa->if_list);
paul718e3742002-12-13 20:15:29 +0000184
hasso508e53e2004-05-18 18:57:06 +0000185 ospf6_lsdb_delete (oa->lsdb);
hasso6452df02004-08-15 05:52:07 +0000186 ospf6_lsdb_delete (oa->lsdb_self);
187
hasso508e53e2004-05-18 18:57:06 +0000188 ospf6_route_table_delete (oa->spf_table);
189 ospf6_route_table_delete (oa->route_table);
paul718e3742002-12-13 20:15:29 +0000190
hasso508e53e2004-05-18 18:57:06 +0000191#if 0
192 ospf6_spftree_delete (oa->spf_tree);
193 ospf6_route_table_delete (oa->topology_table);
194#endif /*0*/
paul718e3742002-12-13 20:15:29 +0000195
hasso508e53e2004-05-18 18:57:06 +0000196 THREAD_OFF (oa->thread_spf_calculation);
197 THREAD_OFF (oa->thread_route_calculation);
paul718e3742002-12-13 20:15:29 +0000198
hasso508e53e2004-05-18 18:57:06 +0000199 listnode_delete (oa->ospf6->area_list, oa);
200 oa->ospf6 = NULL;
paul718e3742002-12-13 20:15:29 +0000201
202 /* free area */
hasso508e53e2004-05-18 18:57:06 +0000203 XFREE (MTYPE_OSPF6_AREA, oa);
paul718e3742002-12-13 20:15:29 +0000204}
205
206struct ospf6_area *
hasso508e53e2004-05-18 18:57:06 +0000207ospf6_area_lookup (u_int32_t area_id, struct ospf6 *ospf6)
paul718e3742002-12-13 20:15:29 +0000208{
hasso508e53e2004-05-18 18:57:06 +0000209 struct ospf6_area *oa;
paul718e3742002-12-13 20:15:29 +0000210 listnode n;
211
hasso508e53e2004-05-18 18:57:06 +0000212 for (n = listhead (ospf6->area_list); n; nextnode (n))
paul718e3742002-12-13 20:15:29 +0000213 {
hasso508e53e2004-05-18 18:57:06 +0000214 oa = (struct ospf6_area *) getdata (n);
215 if (oa->area_id == area_id)
216 return oa;
paul718e3742002-12-13 20:15:29 +0000217 }
218
219 return (struct ospf6_area *) NULL;
220}
221
hasso6452df02004-08-15 05:52:07 +0000222struct ospf6_area *
223ospf6_area_get (u_int32_t area_id, struct ospf6 *o)
224{
225 struct ospf6_area *oa;
226 oa = ospf6_area_lookup (area_id, o);
227 if (oa == NULL)
228 oa = ospf6_area_create (area_id, o);
229 return oa;
230}
231
paul718e3742002-12-13 20:15:29 +0000232void
hasso508e53e2004-05-18 18:57:06 +0000233ospf6_area_enable (struct ospf6_area *oa)
paul718e3742002-12-13 20:15:29 +0000234{
235 listnode i;
hasso508e53e2004-05-18 18:57:06 +0000236 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000237
hasso6452df02004-08-15 05:52:07 +0000238 SET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
paul718e3742002-12-13 20:15:29 +0000239
hasso508e53e2004-05-18 18:57:06 +0000240 for (i = listhead (oa->if_list); i; nextnode (i))
paul718e3742002-12-13 20:15:29 +0000241 {
hasso508e53e2004-05-18 18:57:06 +0000242 oi = (struct ospf6_interface *) getdata (i);
243 ospf6_interface_enable (oi);
paul718e3742002-12-13 20:15:29 +0000244 }
245}
246
247void
hasso508e53e2004-05-18 18:57:06 +0000248ospf6_area_disable (struct ospf6_area *oa)
paul718e3742002-12-13 20:15:29 +0000249{
hasso508e53e2004-05-18 18:57:06 +0000250 listnode i;
251 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000252
hasso6452df02004-08-15 05:52:07 +0000253 UNSET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
hasso508e53e2004-05-18 18:57:06 +0000254
255 for (i = listhead (oa->if_list); i; nextnode (i))
256 {
257 oi = (struct ospf6_interface *) getdata (i);
258 ospf6_interface_disable (oi);
259 }
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{
266 listnode i;
267 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:");
274 for (i = listhead (oa->if_list); i; nextnode (i))
275 {
276 oi = (struct ospf6_interface *) getdata (i);
277 vty_out (vty, " %s", oi->interface->name);
278 }
hasso049207c2004-08-04 20:02:13 +0000279 vty_out (vty, "%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000280}
281
282
hasso049207c2004-08-04 20:02:13 +0000283#define OSPF6_CMD_AREA_LOOKUP(str, oa) \
284{ \
285 u_int32_t area_id = 0; \
286 if (inet_pton (AF_INET, str, &area_id) != 1) \
287 { \
288 vty_out (vty, "Malformed Area-ID: %s%s", str, VNL); \
289 return CMD_SUCCESS; \
290 } \
291 oa = ospf6_area_lookup (area_id, ospf6); \
292 if (oa == NULL) \
293 { \
294 vty_out (vty, "No such Area: %s%s", str, VNL); \
295 return CMD_SUCCESS; \
296 } \
hasso508e53e2004-05-18 18:57:06 +0000297}
298
hasso6452df02004-08-15 05:52:07 +0000299#define OSPF6_CMD_AREA_GET(str, oa) \
300{ \
301 u_int32_t area_id = 0; \
302 if (inet_pton (AF_INET, str, &area_id) != 1) \
303 { \
304 vty_out (vty, "Malformed Area-ID: %s%s", str, VNL); \
305 return CMD_SUCCESS; \
306 } \
307 oa = ospf6_area_get (area_id, ospf6); \
308}
309
310DEFUN (area_range,
311 area_range_cmd,
312 "area A.B.C.D range X:X::X:X/M",
313 "OSPF area parameters\n"
314 OSPF6_AREA_ID_STR
315 "Configured address range\n"
316 "Specify IPv6 prefix\n"
317 )
318{
319 int ret;
320 struct ospf6_area *oa;
321 struct prefix prefix;
322 struct ospf6_route *range;
323
324 OSPF6_CMD_AREA_GET (argv[0], oa);
325 argc--;
326 argv++;
327
328 ret = str2prefix (argv[0], &prefix);
329 if (ret != 1 || prefix.family != AF_INET6)
330 {
331 vty_out (vty, "Malformed argument: %s%s", argv[0], VNL);
332 return CMD_SUCCESS;
333 }
334 argc--;
335 argv++;
336
337 range = ospf6_route_lookup (&prefix, oa->range_table);
338 if (range == NULL)
339 {
340 range = ospf6_route_create ();
341 range->type = OSPF6_DEST_TYPE_RANGE;
342 range->prefix = prefix;
343 }
344
345 if (argc)
346 {
347 if (! strcmp (argv[0], "not-advertise"))
348 SET_FLAG (range->flag, OSPF6_ROUTE_DO_NOT_ADVERTISE);
349 else if (! strcmp (argv[0], "advertise"))
350 UNSET_FLAG (range->flag, OSPF6_ROUTE_DO_NOT_ADVERTISE);
351 }
352
353 ospf6_route_add (range, oa->range_table);
354 return CMD_SUCCESS;
355}
356
357ALIAS (area_range,
358 area_range_advertise_cmd,
359 "area A.B.C.D range X:X::X:X/M (advertise|not-advertise)",
360 "OSPF area parameters\n"
361 OSPF6_AREA_ID_STR
362 "Configured address range\n"
363 "Specify IPv6 prefix\n"
364 );
365
366DEFUN (no_area_range,
367 no_area_range_cmd,
368 "no area A.B.C.D range X:X::X:X/M",
369 "OSPF area parameters\n"
370 OSPF6_AREA_ID_STR
371 "Configured address range\n"
372 "Specify IPv6 prefix\n"
373 )
374{
375 int ret;
376 struct ospf6_area *oa;
377 struct prefix prefix;
378 struct ospf6_route *range;
379
380 OSPF6_CMD_AREA_GET (argv[0], oa);
381 argc--;
382 argv++;
383
384 ret = str2prefix (argv[0], &prefix);
385 if (ret != 1 || prefix.family != AF_INET6)
386 {
387 vty_out (vty, "Malformed argument: %s%s", argv[0], VNL);
388 return CMD_SUCCESS;
389 }
390
391 range = ospf6_route_lookup (&prefix, oa->range_table);
392 if (range == NULL)
393 {
394 vty_out (vty, "Range %s does not exists.%s", argv[0], VNL);
395 return CMD_SUCCESS;
396 }
397
398 ospf6_route_remove (range, oa->range_table);
399 return CMD_SUCCESS;
400}
401
402void
403ospf6_area_config_write (struct vty *vty)
404{
405 listnode node;
406 struct ospf6_area *oa;
407 struct ospf6_route *range;
408 char buf[128];
409
410 for (node = listhead (ospf6->area_list); node; nextnode (node))
411 {
412 oa = OSPF6_AREA (getdata (node));
413
414 for (range = ospf6_route_head (oa->range_table); range;
415 range = ospf6_route_next (range))
416 {
417 prefix2str (&range->prefix, buf, sizeof (buf));
418 vty_out (vty, " area %s range %s%s", oa->name, buf, VNL);
419 }
420 }
421}
422
hasso508e53e2004-05-18 18:57:06 +0000423DEFUN (show_ipv6_ospf6_area_route_intra,
424 show_ipv6_ospf6_area_route_intra_cmd,
425 "show ipv6 ospf6 area A.B.C.D route intra-area",
paul718e3742002-12-13 20:15:29 +0000426 SHOW_STR
427 IP6_STR
428 OSPF6_STR
429 OSPF6_AREA_STR
430 OSPF6_AREA_ID_STR
431 ROUTE_STR
hasso508e53e2004-05-18 18:57:06 +0000432 "Display Intra-Area routes\n"
paul718e3742002-12-13 20:15:29 +0000433 )
434{
hasso508e53e2004-05-18 18:57:06 +0000435 struct ospf6_area *oa;
436 OSPF6_CMD_AREA_LOOKUP (argv[0], oa);
437 argc--;
438 argv++;
439 return ospf6_route_table_show (vty, argc, argv, oa->route_table);
paul718e3742002-12-13 20:15:29 +0000440}
441
hasso508e53e2004-05-18 18:57:06 +0000442ALIAS (show_ipv6_ospf6_area_route_intra,
443 show_ipv6_ospf6_area_route_intra_detail_cmd,
444 "show ipv6 ospf6 area A.B.C.D route intra-area (X::X|X::X/M|detail)",
paul718e3742002-12-13 20:15:29 +0000445 SHOW_STR
446 IP6_STR
447 OSPF6_STR
448 OSPF6_AREA_STR
449 OSPF6_AREA_ID_STR
450 ROUTE_STR
hasso508e53e2004-05-18 18:57:06 +0000451 "Display Intra-Area routes\n"
paul718e3742002-12-13 20:15:29 +0000452 "Specify IPv6 address\n"
hasso508e53e2004-05-18 18:57:06 +0000453 "Specify IPv6 prefix\n"
454 "Detailed information\n"
455 );
456
457DEFUN (show_ipv6_ospf6_area_route_intra_match,
458 show_ipv6_ospf6_area_route_intra_match_cmd,
459 "show ipv6 ospf6 area A.B.C.D route intra-area X::X/M match",
460 SHOW_STR
461 IP6_STR
462 OSPF6_STR
463 ROUTE_STR
464 "Display Intra-Area routes\n"
465 OSPF6_AREA_STR
466 OSPF6_AREA_ID_STR
467 "Specify IPv6 prefix\n"
468 "Display routes which match the specified route\n"
469 )
470{
471 char *sargv[CMD_ARGC_MAX];
472 int i, sargc;
473 struct ospf6_area *oa;
474
475 OSPF6_CMD_AREA_LOOKUP (argv[0], oa);
476 argc--;
477 argv++;
478
479 /* copy argv to sargv and then append "match" */
480 for (i = 0; i < argc; i++)
481 sargv[i] = argv[i];
482 sargc = argc;
483 sargv[sargc++] = "match";
484 sargv[sargc] = NULL;
485
486 return ospf6_route_table_show (vty, sargc, sargv, oa->route_table);
487}
488
489DEFUN (show_ipv6_ospf6_area_route_intra_match_detail,
490 show_ipv6_ospf6_area_route_intra_match_detail_cmd,
491 "show ipv6 ospf6 area A.B.C.D route intra-area X::X/M match detail",
492 SHOW_STR
493 IP6_STR
494 OSPF6_STR
495 OSPF6_AREA_STR
496 OSPF6_AREA_ID_STR
497 ROUTE_STR
498 "Display Intra-Area routes\n"
499 "Specify IPv6 prefix\n"
500 "Display routes which match the specified route\n"
paul718e3742002-12-13 20:15:29 +0000501 "Detailed information\n"
502 )
hasso508e53e2004-05-18 18:57:06 +0000503{
504 char *sargv[CMD_ARGC_MAX];
505 int i, sargc;
506 struct ospf6_area *oa;
507
508 OSPF6_CMD_AREA_LOOKUP (argv[0], oa);
509 argc--;
510 argv++;
511
512 /* copy argv to sargv and then append "match" and "detail" */
513 for (i = 0; i < argc; i++)
514 sargv[i] = argv[i];
515 sargc = argc;
516 sargv[sargc++] = "match";
517 sargv[sargc++] = "detail";
518 sargv[sargc] = NULL;
519
520 return ospf6_route_table_show (vty, sargc, sargv, oa->route_table);
521}
522
523DEFUN (show_ipv6_ospf6_route_intra,
524 show_ipv6_ospf6_route_intra_cmd,
525 "show ipv6 ospf6 route intra-area",
526 SHOW_STR
527 IP6_STR
528 OSPF6_STR
529 ROUTE_STR
530 "Display Intra-Area routes\n"
531 )
532{
533 listnode node;
534 struct ospf6_area *oa;
535
536 for (node = listhead (ospf6->area_list); node; nextnode (node))
537 {
538 oa = (struct ospf6_area *) getdata (node);
hasso049207c2004-08-04 20:02:13 +0000539 vty_out (vty, "Area %s%s", oa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000540 ospf6_route_table_show (vty, argc, argv, oa->route_table);
541 }
542
543 return CMD_SUCCESS;
544}
545
546ALIAS (show_ipv6_ospf6_route_intra,
547 show_ipv6_ospf6_route_intra_detail_cmd,
548 "show ipv6 ospf6 route intra-area (X::X|X::X/M|detail|summary)",
549 SHOW_STR
550 IP6_STR
551 OSPF6_STR
552 ROUTE_STR
553 "Display Intra-Area routes\n"
554 "Specify IPv6 address\n"
555 "Specify IPv6 prefix\n"
556 "Detailed information\n"
557 "Summary of route table\n"
558 );
559
560DEFUN (show_ipv6_ospf6_route_intra_match,
561 show_ipv6_ospf6_route_intra_match_cmd,
562 "show ipv6 ospf6 route intra-area X::X/M match",
563 SHOW_STR
564 IP6_STR
565 OSPF6_STR
566 ROUTE_STR
567 "Display Intra-Area routes\n"
568 "Specify IPv6 prefix\n"
569 "Display routes which match the specified route\n"
570 )
571{
572 char *sargv[CMD_ARGC_MAX];
573 int i, sargc;
574 listnode node;
575 struct ospf6_area *oa;
576
577 /* copy argv to sargv and then append "match" */
578 for (i = 0; i < argc; i++)
579 sargv[i] = argv[i];
580 sargc = argc;
581 sargv[sargc++] = "match";
582 sargv[sargc] = NULL;
583
584 for (node = listhead (ospf6->area_list); node; nextnode (node))
585 {
586 oa = (struct ospf6_area *) getdata (node);
587 ospf6_route_table_show (vty, sargc, sargv, oa->route_table);
588 }
589
590 return CMD_SUCCESS;
591}
592
593DEFUN (show_ipv6_ospf6_route_intra_match_detail,
594 show_ipv6_ospf6_route_intra_match_detail_cmd,
595 "show ipv6 ospf6 route intra-area X::X/M match detail",
596 SHOW_STR
597 IP6_STR
598 OSPF6_STR
599 ROUTE_STR
600 "Display Intra-Area routes\n"
601 "Specify IPv6 prefix\n"
602 "Display routes which match the specified route\n"
603 "Detailed information\n"
604 )
605{
606 char *sargv[CMD_ARGC_MAX];
607 int i, sargc;
608 listnode node;
609 struct ospf6_area *oa;
610
611 /* copy argv to sargv and then append "match" and "detail" */
612 for (i = 0; i < argc; i++)
613 sargv[i] = argv[i];
614 sargc = argc;
615 sargv[sargc++] = "match";
616 sargv[sargc++] = "detail";
617 sargv[sargc] = NULL;
618
619 for (node = listhead (ospf6->area_list); node; nextnode (node))
620 {
621 oa = (struct ospf6_area *) getdata (node);
622 ospf6_route_table_show (vty, sargc, sargv, oa->route_table);
623 }
624
625 return CMD_SUCCESS;
626}
627
628DEFUN (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{
637 listnode node;
638 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);
644 for (node = listhead (ospf6->area_list); node; nextnode (node))
645 {
646 oa = (struct ospf6_area *) getdata (node);
647 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
705DEFUN (show_ipv6_ospf6_area_spf_table,
706 show_ipv6_ospf6_area_spf_table_cmd,
707 "show ipv6 ospf6 area A.B.C.D spf table",
708 SHOW_STR
709 IP6_STR
710 OSPF6_STR
711 OSPF6_AREA_STR
712 OSPF6_AREA_ID_STR
713 "Shortest Path First caculation\n"
714 "Show table contains SPF result\n"
715 )
716{
717 u_int32_t area_id;
718 struct ospf6_area *oa;
719
720 if (inet_pton (AF_INET, argv[0], &area_id) != 1)
721 {
hasso049207c2004-08-04 20:02:13 +0000722 vty_out (vty, "Malformed Area-ID: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000723 return CMD_SUCCESS;
724 }
725 oa = ospf6_area_lookup (area_id, ospf6);
726 if (oa == NULL)
727 {
hasso049207c2004-08-04 20:02:13 +0000728 vty_out (vty, "No such Area: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000729 return CMD_SUCCESS;
730 }
731
732 argc--;
733 argv++;
734
735 ospf6_lsentry_table_show (vty, argc, argv, oa->spf_table);
736 return CMD_SUCCESS;
737}
738
739ALIAS (show_ipv6_ospf6_area_spf_table,
740 show_ipv6_ospf6_area_spf_table_1_cmd,
741 "show ipv6 ospf6 area A.B.C.D spf table (A.B.C.D|A.B.C.D/M|detail)",
742 SHOW_STR
743 IP6_STR
744 OSPF6_STR
745 OSPF6_AREA_STR
746 OSPF6_AREA_ID_STR
747 "Shortest Path First caculation\n"
748 "Show table contains SPF result\n"
749 "Specify Router-ID\n"
750 "Display multiple entry by specifying match-prefix of Router-ID\n"
751 "Display Detail\n"
752 );
753
754ALIAS (show_ipv6_ospf6_area_spf_table,
755 show_ipv6_ospf6_area_spf_table_2_cmd,
756 "show ipv6 ospf6 area A.B.C.D spf table (A.B.C.D|*) (A.B.C.D|A.B.C.D/M|detail)",
757 SHOW_STR
758 IP6_STR
759 OSPF6_STR
760 OSPF6_AREA_STR
761 OSPF6_AREA_ID_STR
762 "Shortest Path First caculation\n"
763 "Show table contains SPF result\n"
764 "Specify Router-ID\n"
765 "Wildcard Router-ID\n"
766 "Specify Link State ID\n"
767 "Display multiple entry by specifying match-prefix of Link State ID\n"
768 "Display Detail\n"
769 );
770
771DEFUN (show_ipv6_ospf6_area_spf_table_3,
772 show_ipv6_ospf6_area_spf_table_3_cmd,
773 "show ipv6 ospf6 area A.B.C.D spf table (A.B.C.D|*) A.B.C.D/M detail",
774 SHOW_STR
775 IP6_STR
776 OSPF6_STR
777 OSPF6_AREA_STR
778 OSPF6_AREA_ID_STR
779 "Shortest Path First caculation\n"
780 "Show table contains SPF result\n"
781 "Specify Router-ID\n"
782 "Wildcard Router-ID\n"
783 "Display multiple entry by specifying match-prefix of Link State ID\n"
784 "Display Detail\n"
785 )
786{
787 u_int32_t area_id;
788 struct ospf6_area *oa;
789 char *sargv[CMD_ARGC_MAX];
790 int i, sargc;
791
792 if (inet_pton (AF_INET, argv[0], &area_id) != 1)
793 {
hasso049207c2004-08-04 20:02:13 +0000794 vty_out (vty, "Malformed Area-ID: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000795 return CMD_SUCCESS;
796 }
797 oa = ospf6_area_lookup (area_id, ospf6);
798 if (oa == NULL)
799 {
hasso049207c2004-08-04 20:02:13 +0000800 vty_out (vty, "No such Area: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000801 return CMD_SUCCESS;
802 }
803
804 argc--;
805 argv++;
806
807 /* copy argv to sargv and then append "detail" */
808 for (i = 0; i < argc; i++)
809 sargv[i] = argv[i];
810 sargc = argc;
811 sargv[sargc++] = "detail";
812 sargv[sargc] = NULL;
813
814 ospf6_lsentry_table_show (vty, sargc, sargv, oa->spf_table);
815 return CMD_SUCCESS;
816}
817
818DEFUN (show_ipv6_ospf6_spf_table,
819 show_ipv6_ospf6_spf_table_cmd,
820 "show ipv6 ospf6 spf table",
821 SHOW_STR
822 IP6_STR
823 OSPF6_STR
824 "Shortest Path First caculation\n"
825 "Show table contains SPF result\n"
826 )
827{
828 listnode node;
829 struct ospf6_area *oa;
830
831 for (node = listhead (ospf6->area_list); node; nextnode (node))
832 {
833 oa = (struct ospf6_area *) getdata (node);
834 ospf6_lsentry_table_show (vty, argc, argv, oa->spf_table);
835 }
836
837 return CMD_SUCCESS;
838}
839
840ALIAS (show_ipv6_ospf6_spf_table,
841 show_ipv6_ospf6_spf_table_1_cmd,
842 "show ipv6 ospf6 spf table (A.B.C.D|A.B.C.D/M|detail)",
843 SHOW_STR
844 IP6_STR
845 OSPF6_STR
846 "Shortest Path First caculation\n"
847 "Show table contains SPF result\n"
848 "Specify Router-ID\n"
849 "Display multiple entry by specifying match-prefix of Router-ID\n"
850 "Display Detail\n"
851 );
852
853ALIAS (show_ipv6_ospf6_spf_table,
854 show_ipv6_ospf6_spf_table_2_cmd,
855 "show ipv6 ospf6 spf table (A.B.C.D|A.B.C.D/M|*) (A.B.C.D|A.B.C.D/M|detail)",
856 SHOW_STR
857 IP6_STR
858 OSPF6_STR
859 "Shortest Path First caculation\n"
860 "Show table contains SPF result\n"
861 "Specify Router-ID\n"
862 "Display multiple entry by specifying match-prefix of Router-ID\n"
863 "Wildcard Router-ID\n"
864 "Specify Link State ID\n"
865 "Display multiple entry by specifying match-prefix of Link State ID\n"
866 "Display Detail\n"
867 );
868
869DEFUN (show_ipv6_ospf6_spf_table_3,
870 show_ipv6_ospf6_spf_table_3_cmd,
871 "show ipv6 ospf6 spf table (A.B.C.D|*) A.B.C.D/M detail",
872 SHOW_STR
873 IP6_STR
874 OSPF6_STR
875 "Shortest Path First caculation\n"
876 "Show table contains SPF result\n"
877 "Specify Router-ID\n"
878 "Wildcard Router-ID\n"
879 "Display multiple entry by specifying match-prefix of Link State ID\n"
880 "Display Detail\n"
881 )
882{
883 listnode node;
884 struct ospf6_area *oa;
885 char *sargv[CMD_ARGC_MAX];
886 int i, sargc;
887
888 /* copy argv to sargv and then append "detail" */
889 for (i = 0; i < argc; i++)
890 sargv[i] = argv[i];
891 sargc = argc;
892 sargv[sargc++] = "detail";
893 sargv[sargc] = NULL;
894
895 for (node = listhead (ospf6->area_list); node; nextnode (node))
896 {
897 oa = (struct ospf6_area *) getdata (node);
898 ospf6_lsentry_table_show (vty, sargc, sargv, oa->spf_table);
899 }
900
901 return CMD_SUCCESS;
902}
903
904DEFUN (show_ipv6_ospf6_simulate_spf_tree_root,
905 show_ipv6_ospf6_simulate_spf_tree_root_cmd,
906 "show ipv6 ospf6 simulate spf-tree A.B.C.D area A.B.C.D",
907 SHOW_STR
908 IP6_STR
909 OSPF6_STR
910 "Shortest Path First caculation\n"
911 "Show SPF tree\n"
912 "Specify root's router-id to calculate another router's SPF tree\n")
913{
914 u_int32_t area_id;
915 struct ospf6_area *oa;
916 struct ospf6_vertex *root;
917 struct ospf6_route *route;
918 struct prefix prefix;
919 u_int32_t router_id;
920 struct ospf6_route_table *spf_table;
921 unsigned char tmp_debug_ospf6_spf = 0;
922
923 inet_pton (AF_INET, argv[0], &router_id);
924 ospf6_linkstate_prefix (router_id, htonl (0), &prefix);
925
926 if (inet_pton (AF_INET, argv[1], &area_id) != 1)
927 {
hasso049207c2004-08-04 20:02:13 +0000928 vty_out (vty, "Malformed Area-ID: %s%s", argv[1], VNL);
hasso508e53e2004-05-18 18:57:06 +0000929 return CMD_SUCCESS;
930 }
931 oa = ospf6_area_lookup (area_id, ospf6);
932 if (oa == NULL)
933 {
hasso049207c2004-08-04 20:02:13 +0000934 vty_out (vty, "No such Area: %s%s", argv[1], VNL);
hasso508e53e2004-05-18 18:57:06 +0000935 return CMD_SUCCESS;
936 }
937
938 tmp_debug_ospf6_spf = conf_debug_ospf6_spf;
939 conf_debug_ospf6_spf = 0;
940
941 spf_table = ospf6_route_table_create ();
942 ospf6_spf_calculation (router_id, spf_table, oa);
943
944 conf_debug_ospf6_spf = tmp_debug_ospf6_spf;
945
946 route = ospf6_route_lookup (&prefix, spf_table);
947 if (route == NULL)
948 {
949 ospf6_spf_table_finish (spf_table);
950 ospf6_route_table_delete (spf_table);
951 return CMD_SUCCESS;
952 }
953 root = (struct ospf6_vertex *) route->route_option;
954 ospf6_spf_display_subtree (vty, "", 0, root);
955
956 ospf6_spf_table_finish (spf_table);
957 ospf6_route_table_delete (spf_table);
958
959 return CMD_SUCCESS;
960}
paul718e3742002-12-13 20:15:29 +0000961
962void
963ospf6_area_init ()
964{
hasso508e53e2004-05-18 18:57:06 +0000965 install_element (VIEW_NODE, &show_ipv6_ospf6_spf_tree_cmd);
966 install_element (VIEW_NODE, &show_ipv6_ospf6_spf_table_cmd);
967 install_element (VIEW_NODE, &show_ipv6_ospf6_spf_table_1_cmd);
968 install_element (VIEW_NODE, &show_ipv6_ospf6_spf_table_2_cmd);
969 install_element (VIEW_NODE, &show_ipv6_ospf6_spf_table_3_cmd);
970 install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_tree_cmd);
971 install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_table_cmd);
972 install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_table_1_cmd);
973 install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_table_2_cmd);
974 install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_table_3_cmd);
paul718e3742002-12-13 20:15:29 +0000975
hasso508e53e2004-05-18 18:57:06 +0000976 install_element (VIEW_NODE, &show_ipv6_ospf6_route_intra_cmd);
977 install_element (VIEW_NODE, &show_ipv6_ospf6_route_intra_detail_cmd);
978 install_element (VIEW_NODE, &show_ipv6_ospf6_route_intra_match_cmd);
979 install_element (VIEW_NODE, &show_ipv6_ospf6_route_intra_match_detail_cmd);
980 install_element (VIEW_NODE, &show_ipv6_ospf6_area_route_intra_cmd);
981 install_element (VIEW_NODE, &show_ipv6_ospf6_area_route_intra_detail_cmd);
982 install_element (VIEW_NODE, &show_ipv6_ospf6_area_route_intra_match_cmd);
983 install_element (VIEW_NODE, &show_ipv6_ospf6_area_route_intra_match_detail_cmd);
984
985 install_element (VIEW_NODE, &show_ipv6_ospf6_simulate_spf_tree_root_cmd);
986
987 install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_tree_cmd);
988 install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_table_cmd);
989 install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_table_1_cmd);
990 install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_table_2_cmd);
991 install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_table_3_cmd);
992 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_tree_cmd);
993 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_table_cmd);
994 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_table_1_cmd);
995 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_table_2_cmd);
996 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_table_3_cmd);
997
998 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_intra_cmd);
999 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_intra_detail_cmd);
1000 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_intra_match_cmd);
1001 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_intra_match_detail_cmd);
1002 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_route_intra_cmd);
1003 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_route_intra_detail_cmd);
1004 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_route_intra_match_cmd);
1005 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_route_intra_match_detail_cmd);
1006
1007 install_element (ENABLE_NODE, &show_ipv6_ospf6_simulate_spf_tree_root_cmd);
hasso6452df02004-08-15 05:52:07 +00001008
1009 install_element (OSPF6_NODE, &area_range_cmd);
1010 install_element (OSPF6_NODE, &area_range_advertise_cmd);
1011 install_element (OSPF6_NODE, &no_area_range_cmd);
paul718e3742002-12-13 20:15:29 +00001012}
hasso049207c2004-08-04 20:02:13 +00001013
hasso6452df02004-08-15 05:52:07 +00001014