blob: ef283cd169a535ffc03932c02a5dab305a7a61e2 [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
paul718e3742002-12-13 20:15:29 +000034#include "ospf6d.h"
hasso508e53e2004-05-18 18:57:06 +000035#include "ospf6_proto.h"
36#include "ospf6_lsa.h"
37#include "ospf6_lsdb.h"
38#include "ospf6_route.h"
39#include "ospf6_spf.h"
40#include "ospf6_top.h"
41#include "ospf6_area.h"
42#include "ospf6_interface.h"
43#include "ospf6_intra.h"
paul718e3742002-12-13 20:15:29 +000044
hasso508e53e2004-05-18 18:57:06 +000045int
46ospf6_area_cmp (void *va, void *vb)
paul718e3742002-12-13 20:15:29 +000047{
hasso508e53e2004-05-18 18:57:06 +000048 struct ospf6_area *oa = (struct ospf6_area *) va;
49 struct ospf6_area *ob = (struct ospf6_area *) vb;
50 return (ntohl (oa->area_id) - ntohl (ob->area_id));
paul718e3742002-12-13 20:15:29 +000051}
52
53int
54ospf6_area_is_stub (struct ospf6_area *o6a)
55{
56 if (OSPF6_OPT_ISSET (o6a->options, OSPF6_OPT_E))
57 return 0;
58 return 1;
59}
60
hasso508e53e2004-05-18 18:57:06 +000061/* schedule routing table recalculation */
paul718e3742002-12-13 20:15:29 +000062void
hasso508e53e2004-05-18 18:57:06 +000063ospf6_area_lsdb_hook_add (struct ospf6_lsa *lsa)
paul718e3742002-12-13 20:15:29 +000064{
hasso508e53e2004-05-18 18:57:06 +000065 struct ospf6_area *oa;
paul718e3742002-12-13 20:15:29 +000066
hasso508e53e2004-05-18 18:57:06 +000067 oa = (struct ospf6_area *) lsa->scope;
68 switch (ntohs (lsa->header->type))
paul718e3742002-12-13 20:15:29 +000069 {
hasso508e53e2004-05-18 18:57:06 +000070 case OSPF6_LSTYPE_ROUTER:
71 case OSPF6_LSTYPE_NETWORK:
72 ospf6_spf_schedule (oa);
73 break;
paul718e3742002-12-13 20:15:29 +000074
hasso508e53e2004-05-18 18:57:06 +000075 case OSPF6_LSTYPE_INTRA_PREFIX:
76 ospf6_intra_prefix_lsa_add (lsa);
77 break;
78
79 case OSPF6_LSTYPE_INTER_PREFIX:
80 case OSPF6_LSTYPE_INTER_ROUTER:
81 break;
82
83 default:
84 if (IS_OSPF6_DEBUG_LSA (RECV))
85 zlog_info ("Unknown LSA in Area %s's lsdb", oa->name);
86 break;
87 }
paul718e3742002-12-13 20:15:29 +000088}
89
90void
hasso508e53e2004-05-18 18:57:06 +000091ospf6_area_lsdb_hook_remove (struct ospf6_lsa *lsa)
paul718e3742002-12-13 20:15:29 +000092{
hasso508e53e2004-05-18 18:57:06 +000093 struct ospf6_area *oa;
paul718e3742002-12-13 20:15:29 +000094
hasso508e53e2004-05-18 18:57:06 +000095 oa = (struct ospf6_area *) lsa->scope;
96 switch (ntohs (lsa->header->type))
paul718e3742002-12-13 20:15:29 +000097 {
hasso508e53e2004-05-18 18:57:06 +000098 case OSPF6_LSTYPE_ROUTER:
99 case OSPF6_LSTYPE_NETWORK:
100 ospf6_spf_schedule (oa);
101 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:
109 break;
110
111 default:
112 if (IS_OSPF6_DEBUG_LSA (RECV))
113 zlog_info ("Unknown LSA in Area %s's lsdb", oa->name);
114 break;
115 }
116}
117
118void
119ospf6_area_route_hook_add (struct ospf6_route *route)
120{
121 struct ospf6_route *copy = ospf6_route_copy (route);
122 ospf6_route_add (copy, ospf6->route_table);
123}
124
125void
126ospf6_area_route_hook_remove (struct ospf6_route *route)
127{
128 struct ospf6_route *copy;
129
130 copy = ospf6_route_lookup_identical (route, ospf6->route_table);
131 if (copy)
132 ospf6_route_remove (copy, ospf6->route_table);
paul718e3742002-12-13 20:15:29 +0000133}
134
135/* Make new area structure */
136struct ospf6_area *
hasso508e53e2004-05-18 18:57:06 +0000137ospf6_area_create (u_int32_t area_id, struct ospf6 *o)
paul718e3742002-12-13 20:15:29 +0000138{
hasso508e53e2004-05-18 18:57:06 +0000139 struct ospf6_area *oa;
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
hasso508e53e2004-05-18 18:57:06 +0000147 oa->lsdb = ospf6_lsdb_create ();
148 oa->lsdb->hook_add = ospf6_area_lsdb_hook_add;
149 oa->lsdb->hook_remove = ospf6_area_lsdb_hook_remove;
paul718e3742002-12-13 20:15:29 +0000150
hasso508e53e2004-05-18 18:57:06 +0000151 oa->spf_table = ospf6_route_table_create ();
152 oa->route_table = ospf6_route_table_create ();
153 oa->route_table->hook_add = ospf6_area_route_hook_add;
154 oa->route_table->hook_remove = ospf6_area_route_hook_remove;
paul718e3742002-12-13 20:15:29 +0000155
hasso508e53e2004-05-18 18:57:06 +0000156 /* set default options */
157 OSPF6_OPT_SET (oa->options, OSPF6_OPT_V6);
158 OSPF6_OPT_SET (oa->options, OSPF6_OPT_E);
159 OSPF6_OPT_SET (oa->options, OSPF6_OPT_R);
paul718e3742002-12-13 20:15:29 +0000160
hasso508e53e2004-05-18 18:57:06 +0000161 oa->ospf6 = o;
162 listnode_add_sort (o->area_list, oa);
paul718e3742002-12-13 20:15:29 +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
173 /* ospf6 interface list */
hasso508e53e2004-05-18 18:57:06 +0000174 for (n = listhead (oa->if_list); n; nextnode (n))
paul718e3742002-12-13 20:15:29 +0000175 {
hasso508e53e2004-05-18 18:57:06 +0000176 oi = (struct ospf6_interface *) getdata (n);
177 ospf6_interface_delete (oi);
paul718e3742002-12-13 20:15:29 +0000178 }
hasso508e53e2004-05-18 18:57:06 +0000179 list_delete (oa->if_list);
paul718e3742002-12-13 20:15:29 +0000180
hasso508e53e2004-05-18 18:57:06 +0000181 ospf6_lsdb_delete (oa->lsdb);
182 ospf6_route_table_delete (oa->spf_table);
183 ospf6_route_table_delete (oa->route_table);
paul718e3742002-12-13 20:15:29 +0000184
hasso508e53e2004-05-18 18:57:06 +0000185#if 0
186 ospf6_spftree_delete (oa->spf_tree);
187 ospf6_route_table_delete (oa->topology_table);
188#endif /*0*/
paul718e3742002-12-13 20:15:29 +0000189
hasso508e53e2004-05-18 18:57:06 +0000190 THREAD_OFF (oa->thread_spf_calculation);
191 THREAD_OFF (oa->thread_route_calculation);
paul718e3742002-12-13 20:15:29 +0000192
hasso508e53e2004-05-18 18:57:06 +0000193 listnode_delete (oa->ospf6->area_list, oa);
194 oa->ospf6 = NULL;
paul718e3742002-12-13 20:15:29 +0000195
196 /* free area */
hasso508e53e2004-05-18 18:57:06 +0000197 XFREE (MTYPE_OSPF6_AREA, oa);
paul718e3742002-12-13 20:15:29 +0000198}
199
200struct ospf6_area *
hasso508e53e2004-05-18 18:57:06 +0000201ospf6_area_lookup (u_int32_t area_id, struct ospf6 *ospf6)
paul718e3742002-12-13 20:15:29 +0000202{
hasso508e53e2004-05-18 18:57:06 +0000203 struct ospf6_area *oa;
paul718e3742002-12-13 20:15:29 +0000204 listnode n;
205
hasso508e53e2004-05-18 18:57:06 +0000206 for (n = listhead (ospf6->area_list); n; nextnode (n))
paul718e3742002-12-13 20:15:29 +0000207 {
hasso508e53e2004-05-18 18:57:06 +0000208 oa = (struct ospf6_area *) getdata (n);
209 if (oa->area_id == area_id)
210 return oa;
paul718e3742002-12-13 20:15:29 +0000211 }
212
213 return (struct ospf6_area *) NULL;
214}
215
216void
hasso508e53e2004-05-18 18:57:06 +0000217ospf6_area_enable (struct ospf6_area *oa)
paul718e3742002-12-13 20:15:29 +0000218{
219 listnode i;
hasso508e53e2004-05-18 18:57:06 +0000220 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000221
hasso508e53e2004-05-18 18:57:06 +0000222 UNSET_FLAG (oa->flag, OSPF6_AREA_DISABLE);
paul718e3742002-12-13 20:15:29 +0000223
hasso508e53e2004-05-18 18:57:06 +0000224 for (i = listhead (oa->if_list); i; nextnode (i))
paul718e3742002-12-13 20:15:29 +0000225 {
hasso508e53e2004-05-18 18:57:06 +0000226 oi = (struct ospf6_interface *) getdata (i);
227 ospf6_interface_enable (oi);
paul718e3742002-12-13 20:15:29 +0000228 }
229}
230
231void
hasso508e53e2004-05-18 18:57:06 +0000232ospf6_area_disable (struct ospf6_area *oa)
paul718e3742002-12-13 20:15:29 +0000233{
hasso508e53e2004-05-18 18:57:06 +0000234 listnode i;
235 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000236
hasso508e53e2004-05-18 18:57:06 +0000237 SET_FLAG (oa->flag, OSPF6_AREA_DISABLE);
238
239 for (i = listhead (oa->if_list); i; nextnode (i))
240 {
241 oi = (struct ospf6_interface *) getdata (i);
242 ospf6_interface_disable (oi);
243 }
paul718e3742002-12-13 20:15:29 +0000244}
245
hasso508e53e2004-05-18 18:57:06 +0000246
247void
248ospf6_area_show (struct vty *vty, struct ospf6_area *oa)
249{
250 listnode i;
251 struct ospf6_interface *oi;
252
253 vty_out (vty, " Area %s%s", oa->name, VTY_NEWLINE);
254 vty_out (vty, " Number of Area scoped LSAs is %u%s",
255 oa->lsdb->count, VTY_NEWLINE);
256
257 vty_out (vty, " Interface attached to this area:");
258 for (i = listhead (oa->if_list); i; nextnode (i))
259 {
260 oi = (struct ospf6_interface *) getdata (i);
261 vty_out (vty, " %s", oi->interface->name);
262 }
263 vty_out (vty, "%s", VTY_NEWLINE);
264}
265
266
267#define OSPF6_CMD_AREA_LOOKUP(str, oa) \
268{ \
269 u_int32_t area_id = 0; \
270 if (inet_pton (AF_INET, str, &area_id) != 1) \
271 { \
272 vty_out (vty, "Malformed Area-ID: %s%s", str, VTY_NEWLINE); \
273 return CMD_SUCCESS; \
274 } \
275 oa = ospf6_area_lookup (area_id, ospf6); \
276 if (oa == NULL) \
277 { \
278 vty_out (vty, "No such Area: %s%s", str, VTY_NEWLINE); \
279 return CMD_SUCCESS; \
280 } \
281}
282
283DEFUN (show_ipv6_ospf6_area_route_intra,
284 show_ipv6_ospf6_area_route_intra_cmd,
285 "show ipv6 ospf6 area A.B.C.D route intra-area",
paul718e3742002-12-13 20:15:29 +0000286 SHOW_STR
287 IP6_STR
288 OSPF6_STR
289 OSPF6_AREA_STR
290 OSPF6_AREA_ID_STR
291 ROUTE_STR
hasso508e53e2004-05-18 18:57:06 +0000292 "Display Intra-Area routes\n"
paul718e3742002-12-13 20:15:29 +0000293 )
294{
hasso508e53e2004-05-18 18:57:06 +0000295 struct ospf6_area *oa;
296 OSPF6_CMD_AREA_LOOKUP (argv[0], oa);
297 argc--;
298 argv++;
299 return ospf6_route_table_show (vty, argc, argv, oa->route_table);
paul718e3742002-12-13 20:15:29 +0000300}
301
hasso508e53e2004-05-18 18:57:06 +0000302ALIAS (show_ipv6_ospf6_area_route_intra,
303 show_ipv6_ospf6_area_route_intra_detail_cmd,
304 "show ipv6 ospf6 area A.B.C.D route intra-area (X::X|X::X/M|detail)",
paul718e3742002-12-13 20:15:29 +0000305 SHOW_STR
306 IP6_STR
307 OSPF6_STR
308 OSPF6_AREA_STR
309 OSPF6_AREA_ID_STR
310 ROUTE_STR
hasso508e53e2004-05-18 18:57:06 +0000311 "Display Intra-Area routes\n"
paul718e3742002-12-13 20:15:29 +0000312 "Specify IPv6 address\n"
hasso508e53e2004-05-18 18:57:06 +0000313 "Specify IPv6 prefix\n"
314 "Detailed information\n"
315 );
316
317DEFUN (show_ipv6_ospf6_area_route_intra_match,
318 show_ipv6_ospf6_area_route_intra_match_cmd,
319 "show ipv6 ospf6 area A.B.C.D route intra-area X::X/M match",
320 SHOW_STR
321 IP6_STR
322 OSPF6_STR
323 ROUTE_STR
324 "Display Intra-Area routes\n"
325 OSPF6_AREA_STR
326 OSPF6_AREA_ID_STR
327 "Specify IPv6 prefix\n"
328 "Display routes which match the specified route\n"
329 )
330{
331 char *sargv[CMD_ARGC_MAX];
332 int i, sargc;
333 struct ospf6_area *oa;
334
335 OSPF6_CMD_AREA_LOOKUP (argv[0], oa);
336 argc--;
337 argv++;
338
339 /* copy argv to sargv and then append "match" */
340 for (i = 0; i < argc; i++)
341 sargv[i] = argv[i];
342 sargc = argc;
343 sargv[sargc++] = "match";
344 sargv[sargc] = NULL;
345
346 return ospf6_route_table_show (vty, sargc, sargv, oa->route_table);
347}
348
349DEFUN (show_ipv6_ospf6_area_route_intra_match_detail,
350 show_ipv6_ospf6_area_route_intra_match_detail_cmd,
351 "show ipv6 ospf6 area A.B.C.D route intra-area X::X/M match detail",
352 SHOW_STR
353 IP6_STR
354 OSPF6_STR
355 OSPF6_AREA_STR
356 OSPF6_AREA_ID_STR
357 ROUTE_STR
358 "Display Intra-Area routes\n"
359 "Specify IPv6 prefix\n"
360 "Display routes which match the specified route\n"
paul718e3742002-12-13 20:15:29 +0000361 "Detailed information\n"
362 )
hasso508e53e2004-05-18 18:57:06 +0000363{
364 char *sargv[CMD_ARGC_MAX];
365 int i, sargc;
366 struct ospf6_area *oa;
367
368 OSPF6_CMD_AREA_LOOKUP (argv[0], oa);
369 argc--;
370 argv++;
371
372 /* copy argv to sargv and then append "match" and "detail" */
373 for (i = 0; i < argc; i++)
374 sargv[i] = argv[i];
375 sargc = argc;
376 sargv[sargc++] = "match";
377 sargv[sargc++] = "detail";
378 sargv[sargc] = NULL;
379
380 return ospf6_route_table_show (vty, sargc, sargv, oa->route_table);
381}
382
383DEFUN (show_ipv6_ospf6_route_intra,
384 show_ipv6_ospf6_route_intra_cmd,
385 "show ipv6 ospf6 route intra-area",
386 SHOW_STR
387 IP6_STR
388 OSPF6_STR
389 ROUTE_STR
390 "Display Intra-Area routes\n"
391 )
392{
393 listnode node;
394 struct ospf6_area *oa;
395
396 for (node = listhead (ospf6->area_list); node; nextnode (node))
397 {
398 oa = (struct ospf6_area *) getdata (node);
399 vty_out (vty, "Area %s%s", oa->name, VTY_NEWLINE);
400 ospf6_route_table_show (vty, argc, argv, oa->route_table);
401 }
402
403 return CMD_SUCCESS;
404}
405
406ALIAS (show_ipv6_ospf6_route_intra,
407 show_ipv6_ospf6_route_intra_detail_cmd,
408 "show ipv6 ospf6 route intra-area (X::X|X::X/M|detail|summary)",
409 SHOW_STR
410 IP6_STR
411 OSPF6_STR
412 ROUTE_STR
413 "Display Intra-Area routes\n"
414 "Specify IPv6 address\n"
415 "Specify IPv6 prefix\n"
416 "Detailed information\n"
417 "Summary of route table\n"
418 );
419
420DEFUN (show_ipv6_ospf6_route_intra_match,
421 show_ipv6_ospf6_route_intra_match_cmd,
422 "show ipv6 ospf6 route intra-area X::X/M match",
423 SHOW_STR
424 IP6_STR
425 OSPF6_STR
426 ROUTE_STR
427 "Display Intra-Area routes\n"
428 "Specify IPv6 prefix\n"
429 "Display routes which match the specified route\n"
430 )
431{
432 char *sargv[CMD_ARGC_MAX];
433 int i, sargc;
434 listnode node;
435 struct ospf6_area *oa;
436
437 /* copy argv to sargv and then append "match" */
438 for (i = 0; i < argc; i++)
439 sargv[i] = argv[i];
440 sargc = argc;
441 sargv[sargc++] = "match";
442 sargv[sargc] = NULL;
443
444 for (node = listhead (ospf6->area_list); node; nextnode (node))
445 {
446 oa = (struct ospf6_area *) getdata (node);
447 ospf6_route_table_show (vty, sargc, sargv, oa->route_table);
448 }
449
450 return CMD_SUCCESS;
451}
452
453DEFUN (show_ipv6_ospf6_route_intra_match_detail,
454 show_ipv6_ospf6_route_intra_match_detail_cmd,
455 "show ipv6 ospf6 route intra-area X::X/M match detail",
456 SHOW_STR
457 IP6_STR
458 OSPF6_STR
459 ROUTE_STR
460 "Display Intra-Area routes\n"
461 "Specify IPv6 prefix\n"
462 "Display routes which match the specified route\n"
463 "Detailed information\n"
464 )
465{
466 char *sargv[CMD_ARGC_MAX];
467 int i, sargc;
468 listnode node;
469 struct ospf6_area *oa;
470
471 /* copy argv to sargv and then append "match" and "detail" */
472 for (i = 0; i < argc; i++)
473 sargv[i] = argv[i];
474 sargc = argc;
475 sargv[sargc++] = "match";
476 sargv[sargc++] = "detail";
477 sargv[sargc] = NULL;
478
479 for (node = listhead (ospf6->area_list); node; nextnode (node))
480 {
481 oa = (struct ospf6_area *) getdata (node);
482 ospf6_route_table_show (vty, sargc, sargv, oa->route_table);
483 }
484
485 return CMD_SUCCESS;
486}
487
488DEFUN (show_ipv6_ospf6_spf_tree,
489 show_ipv6_ospf6_spf_tree_cmd,
490 "show ipv6 ospf6 spf tree",
491 SHOW_STR
492 IP6_STR
493 OSPF6_STR
494 "Shortest Path First caculation\n"
495 "Show SPF tree\n")
496{
497 listnode node;
498 struct ospf6_area *oa;
499 struct ospf6_vertex *root;
500 struct ospf6_route *route;
501 struct prefix prefix;
502
503 ospf6_linkstate_prefix (ospf6->router_id, htonl (0), &prefix);
504 for (node = listhead (ospf6->area_list); node; nextnode (node))
505 {
506 oa = (struct ospf6_area *) getdata (node);
507 route = ospf6_route_lookup (&prefix, oa->spf_table);
508 if (route == NULL)
509 {
510 vty_out (vty, "LS entry for root not found in area %s%s",
511 oa->name, VTY_NEWLINE);
512 continue;
513 }
514 root = (struct ospf6_vertex *) route->route_option;
515 ospf6_spf_display_subtree (vty, "", 0, root);
516 }
517
518 return CMD_SUCCESS;
519}
520
521DEFUN (show_ipv6_ospf6_area_spf_tree,
522 show_ipv6_ospf6_area_spf_tree_cmd,
523 "show ipv6 ospf6 area A.B.C.D spf tree",
524 SHOW_STR
525 IP6_STR
526 OSPF6_STR
527 OSPF6_AREA_STR
528 OSPF6_AREA_ID_STR
529 "Shortest Path First caculation\n"
530 "Show SPF tree\n")
531{
532 u_int32_t area_id;
533 struct ospf6_area *oa;
534 struct ospf6_vertex *root;
535 struct ospf6_route *route;
536 struct prefix prefix;
537
538 ospf6_linkstate_prefix (ospf6->router_id, htonl (0), &prefix);
539
540 if (inet_pton (AF_INET, argv[0], &area_id) != 1)
541 {
542 vty_out (vty, "Malformed Area-ID: %s%s", argv[0], VTY_NEWLINE);
543 return CMD_SUCCESS;
544 }
545 oa = ospf6_area_lookup (area_id, ospf6);
546 if (oa == NULL)
547 {
548 vty_out (vty, "No such Area: %s%s", argv[0], VTY_NEWLINE);
549 return CMD_SUCCESS;
550 }
551
552 route = ospf6_route_lookup (&prefix, oa->spf_table);
553 if (route == NULL)
554 {
555 vty_out (vty, "LS entry for root not found in area %s%s",
556 oa->name, VTY_NEWLINE);
557 return CMD_SUCCESS;
558 }
559 root = (struct ospf6_vertex *) route->route_option;
560 ospf6_spf_display_subtree (vty, "", 0, root);
561
562 return CMD_SUCCESS;
563}
564
565DEFUN (show_ipv6_ospf6_area_spf_table,
566 show_ipv6_ospf6_area_spf_table_cmd,
567 "show ipv6 ospf6 area A.B.C.D spf table",
568 SHOW_STR
569 IP6_STR
570 OSPF6_STR
571 OSPF6_AREA_STR
572 OSPF6_AREA_ID_STR
573 "Shortest Path First caculation\n"
574 "Show table contains SPF result\n"
575 )
576{
577 u_int32_t area_id;
578 struct ospf6_area *oa;
579
580 if (inet_pton (AF_INET, argv[0], &area_id) != 1)
581 {
582 vty_out (vty, "Malformed Area-ID: %s%s", argv[0], VTY_NEWLINE);
583 return CMD_SUCCESS;
584 }
585 oa = ospf6_area_lookup (area_id, ospf6);
586 if (oa == NULL)
587 {
588 vty_out (vty, "No such Area: %s%s", argv[0], VTY_NEWLINE);
589 return CMD_SUCCESS;
590 }
591
592 argc--;
593 argv++;
594
595 ospf6_lsentry_table_show (vty, argc, argv, oa->spf_table);
596 return CMD_SUCCESS;
597}
598
599ALIAS (show_ipv6_ospf6_area_spf_table,
600 show_ipv6_ospf6_area_spf_table_1_cmd,
601 "show ipv6 ospf6 area A.B.C.D spf table (A.B.C.D|A.B.C.D/M|detail)",
602 SHOW_STR
603 IP6_STR
604 OSPF6_STR
605 OSPF6_AREA_STR
606 OSPF6_AREA_ID_STR
607 "Shortest Path First caculation\n"
608 "Show table contains SPF result\n"
609 "Specify Router-ID\n"
610 "Display multiple entry by specifying match-prefix of Router-ID\n"
611 "Display Detail\n"
612 );
613
614ALIAS (show_ipv6_ospf6_area_spf_table,
615 show_ipv6_ospf6_area_spf_table_2_cmd,
616 "show ipv6 ospf6 area A.B.C.D spf table (A.B.C.D|*) (A.B.C.D|A.B.C.D/M|detail)",
617 SHOW_STR
618 IP6_STR
619 OSPF6_STR
620 OSPF6_AREA_STR
621 OSPF6_AREA_ID_STR
622 "Shortest Path First caculation\n"
623 "Show table contains SPF result\n"
624 "Specify Router-ID\n"
625 "Wildcard Router-ID\n"
626 "Specify Link State ID\n"
627 "Display multiple entry by specifying match-prefix of Link State ID\n"
628 "Display Detail\n"
629 );
630
631DEFUN (show_ipv6_ospf6_area_spf_table_3,
632 show_ipv6_ospf6_area_spf_table_3_cmd,
633 "show ipv6 ospf6 area A.B.C.D spf table (A.B.C.D|*) A.B.C.D/M detail",
634 SHOW_STR
635 IP6_STR
636 OSPF6_STR
637 OSPF6_AREA_STR
638 OSPF6_AREA_ID_STR
639 "Shortest Path First caculation\n"
640 "Show table contains SPF result\n"
641 "Specify Router-ID\n"
642 "Wildcard Router-ID\n"
643 "Display multiple entry by specifying match-prefix of Link State ID\n"
644 "Display Detail\n"
645 )
646{
647 u_int32_t area_id;
648 struct ospf6_area *oa;
649 char *sargv[CMD_ARGC_MAX];
650 int i, sargc;
651
652 if (inet_pton (AF_INET, argv[0], &area_id) != 1)
653 {
654 vty_out (vty, "Malformed Area-ID: %s%s", argv[0], VTY_NEWLINE);
655 return CMD_SUCCESS;
656 }
657 oa = ospf6_area_lookup (area_id, ospf6);
658 if (oa == NULL)
659 {
660 vty_out (vty, "No such Area: %s%s", argv[0], VTY_NEWLINE);
661 return CMD_SUCCESS;
662 }
663
664 argc--;
665 argv++;
666
667 /* copy argv to sargv and then append "detail" */
668 for (i = 0; i < argc; i++)
669 sargv[i] = argv[i];
670 sargc = argc;
671 sargv[sargc++] = "detail";
672 sargv[sargc] = NULL;
673
674 ospf6_lsentry_table_show (vty, sargc, sargv, oa->spf_table);
675 return CMD_SUCCESS;
676}
677
678DEFUN (show_ipv6_ospf6_spf_table,
679 show_ipv6_ospf6_spf_table_cmd,
680 "show ipv6 ospf6 spf table",
681 SHOW_STR
682 IP6_STR
683 OSPF6_STR
684 "Shortest Path First caculation\n"
685 "Show table contains SPF result\n"
686 )
687{
688 listnode node;
689 struct ospf6_area *oa;
690
691 for (node = listhead (ospf6->area_list); node; nextnode (node))
692 {
693 oa = (struct ospf6_area *) getdata (node);
694 ospf6_lsentry_table_show (vty, argc, argv, oa->spf_table);
695 }
696
697 return CMD_SUCCESS;
698}
699
700ALIAS (show_ipv6_ospf6_spf_table,
701 show_ipv6_ospf6_spf_table_1_cmd,
702 "show ipv6 ospf6 spf table (A.B.C.D|A.B.C.D/M|detail)",
703 SHOW_STR
704 IP6_STR
705 OSPF6_STR
706 "Shortest Path First caculation\n"
707 "Show table contains SPF result\n"
708 "Specify Router-ID\n"
709 "Display multiple entry by specifying match-prefix of Router-ID\n"
710 "Display Detail\n"
711 );
712
713ALIAS (show_ipv6_ospf6_spf_table,
714 show_ipv6_ospf6_spf_table_2_cmd,
715 "show ipv6 ospf6 spf table (A.B.C.D|A.B.C.D/M|*) (A.B.C.D|A.B.C.D/M|detail)",
716 SHOW_STR
717 IP6_STR
718 OSPF6_STR
719 "Shortest Path First caculation\n"
720 "Show table contains SPF result\n"
721 "Specify Router-ID\n"
722 "Display multiple entry by specifying match-prefix of Router-ID\n"
723 "Wildcard Router-ID\n"
724 "Specify Link State ID\n"
725 "Display multiple entry by specifying match-prefix of Link State ID\n"
726 "Display Detail\n"
727 );
728
729DEFUN (show_ipv6_ospf6_spf_table_3,
730 show_ipv6_ospf6_spf_table_3_cmd,
731 "show ipv6 ospf6 spf table (A.B.C.D|*) A.B.C.D/M detail",
732 SHOW_STR
733 IP6_STR
734 OSPF6_STR
735 "Shortest Path First caculation\n"
736 "Show table contains SPF result\n"
737 "Specify Router-ID\n"
738 "Wildcard Router-ID\n"
739 "Display multiple entry by specifying match-prefix of Link State ID\n"
740 "Display Detail\n"
741 )
742{
743 listnode node;
744 struct ospf6_area *oa;
745 char *sargv[CMD_ARGC_MAX];
746 int i, sargc;
747
748 /* copy argv to sargv and then append "detail" */
749 for (i = 0; i < argc; i++)
750 sargv[i] = argv[i];
751 sargc = argc;
752 sargv[sargc++] = "detail";
753 sargv[sargc] = NULL;
754
755 for (node = listhead (ospf6->area_list); node; nextnode (node))
756 {
757 oa = (struct ospf6_area *) getdata (node);
758 ospf6_lsentry_table_show (vty, sargc, sargv, oa->spf_table);
759 }
760
761 return CMD_SUCCESS;
762}
763
764DEFUN (show_ipv6_ospf6_simulate_spf_tree_root,
765 show_ipv6_ospf6_simulate_spf_tree_root_cmd,
766 "show ipv6 ospf6 simulate spf-tree A.B.C.D area A.B.C.D",
767 SHOW_STR
768 IP6_STR
769 OSPF6_STR
770 "Shortest Path First caculation\n"
771 "Show SPF tree\n"
772 "Specify root's router-id to calculate another router's SPF tree\n")
773{
774 u_int32_t area_id;
775 struct ospf6_area *oa;
776 struct ospf6_vertex *root;
777 struct ospf6_route *route;
778 struct prefix prefix;
779 u_int32_t router_id;
780 struct ospf6_route_table *spf_table;
781 unsigned char tmp_debug_ospf6_spf = 0;
782
783 inet_pton (AF_INET, argv[0], &router_id);
784 ospf6_linkstate_prefix (router_id, htonl (0), &prefix);
785
786 if (inet_pton (AF_INET, argv[1], &area_id) != 1)
787 {
788 vty_out (vty, "Malformed Area-ID: %s%s", argv[1], VTY_NEWLINE);
789 return CMD_SUCCESS;
790 }
791 oa = ospf6_area_lookup (area_id, ospf6);
792 if (oa == NULL)
793 {
794 vty_out (vty, "No such Area: %s%s", argv[1], VTY_NEWLINE);
795 return CMD_SUCCESS;
796 }
797
798 tmp_debug_ospf6_spf = conf_debug_ospf6_spf;
799 conf_debug_ospf6_spf = 0;
800
801 spf_table = ospf6_route_table_create ();
802 ospf6_spf_calculation (router_id, spf_table, oa);
803
804 conf_debug_ospf6_spf = tmp_debug_ospf6_spf;
805
806 route = ospf6_route_lookup (&prefix, spf_table);
807 if (route == NULL)
808 {
809 ospf6_spf_table_finish (spf_table);
810 ospf6_route_table_delete (spf_table);
811 return CMD_SUCCESS;
812 }
813 root = (struct ospf6_vertex *) route->route_option;
814 ospf6_spf_display_subtree (vty, "", 0, root);
815
816 ospf6_spf_table_finish (spf_table);
817 ospf6_route_table_delete (spf_table);
818
819 return CMD_SUCCESS;
820}
paul718e3742002-12-13 20:15:29 +0000821
822void
823ospf6_area_init ()
824{
hasso508e53e2004-05-18 18:57:06 +0000825 install_element (VIEW_NODE, &show_ipv6_ospf6_spf_tree_cmd);
826 install_element (VIEW_NODE, &show_ipv6_ospf6_spf_table_cmd);
827 install_element (VIEW_NODE, &show_ipv6_ospf6_spf_table_1_cmd);
828 install_element (VIEW_NODE, &show_ipv6_ospf6_spf_table_2_cmd);
829 install_element (VIEW_NODE, &show_ipv6_ospf6_spf_table_3_cmd);
830 install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_tree_cmd);
831 install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_table_cmd);
832 install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_table_1_cmd);
833 install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_table_2_cmd);
834 install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_table_3_cmd);
paul718e3742002-12-13 20:15:29 +0000835
hasso508e53e2004-05-18 18:57:06 +0000836 install_element (VIEW_NODE, &show_ipv6_ospf6_route_intra_cmd);
837 install_element (VIEW_NODE, &show_ipv6_ospf6_route_intra_detail_cmd);
838 install_element (VIEW_NODE, &show_ipv6_ospf6_route_intra_match_cmd);
839 install_element (VIEW_NODE, &show_ipv6_ospf6_route_intra_match_detail_cmd);
840 install_element (VIEW_NODE, &show_ipv6_ospf6_area_route_intra_cmd);
841 install_element (VIEW_NODE, &show_ipv6_ospf6_area_route_intra_detail_cmd);
842 install_element (VIEW_NODE, &show_ipv6_ospf6_area_route_intra_match_cmd);
843 install_element (VIEW_NODE, &show_ipv6_ospf6_area_route_intra_match_detail_cmd);
844
845 install_element (VIEW_NODE, &show_ipv6_ospf6_simulate_spf_tree_root_cmd);
846
847 install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_tree_cmd);
848 install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_table_cmd);
849 install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_table_1_cmd);
850 install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_table_2_cmd);
851 install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_table_3_cmd);
852 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_tree_cmd);
853 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_table_cmd);
854 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_table_1_cmd);
855 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_table_2_cmd);
856 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_table_3_cmd);
857
858 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_intra_cmd);
859 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_intra_detail_cmd);
860 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_intra_match_cmd);
861 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_intra_match_detail_cmd);
862 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_route_intra_cmd);
863 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_route_intra_detail_cmd);
864 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_route_intra_match_cmd);
865 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_route_intra_match_detail_cmd);
866
867 install_element (ENABLE_NODE, &show_ipv6_ospf6_simulate_spf_tree_root_cmd);
paul718e3742002-12-13 20:15:29 +0000868}