blob: 04cbb0a37ba28a71b41f889b8d6901d2794beb20 [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;
51 return (ntohl (oa->area_id) - ntohl (ob->area_id));
paul718e3742002-12-13 20:15:29 +000052}
53
54int
55ospf6_area_is_stub (struct ospf6_area *o6a)
56{
57 if (OSPF6_OPT_ISSET (o6a->options, OSPF6_OPT_E))
58 return 0;
59 return 1;
60}
61
hasso508e53e2004-05-18 18:57:06 +000062/* schedule routing table recalculation */
paul718e3742002-12-13 20:15:29 +000063void
hasso508e53e2004-05-18 18:57:06 +000064ospf6_area_lsdb_hook_add (struct ospf6_lsa *lsa)
paul718e3742002-12-13 20:15:29 +000065{
hasso508e53e2004-05-18 18:57:06 +000066 struct ospf6_area *oa;
paul718e3742002-12-13 20:15:29 +000067
hasso508e53e2004-05-18 18:57:06 +000068 oa = (struct ospf6_area *) lsa->scope;
69 switch (ntohs (lsa->header->type))
paul718e3742002-12-13 20:15:29 +000070 {
hasso508e53e2004-05-18 18:57:06 +000071 case OSPF6_LSTYPE_ROUTER:
72 case OSPF6_LSTYPE_NETWORK:
73 ospf6_spf_schedule (oa);
74 break;
paul718e3742002-12-13 20:15:29 +000075
hasso508e53e2004-05-18 18:57:06 +000076 case OSPF6_LSTYPE_INTRA_PREFIX:
77 ospf6_intra_prefix_lsa_add (lsa);
78 break;
79
80 case OSPF6_LSTYPE_INTER_PREFIX:
81 case OSPF6_LSTYPE_INTER_ROUTER:
82 break;
83
84 default:
85 if (IS_OSPF6_DEBUG_LSA (RECV))
86 zlog_info ("Unknown LSA in Area %s's lsdb", oa->name);
87 break;
88 }
paul718e3742002-12-13 20:15:29 +000089}
90
91void
hasso508e53e2004-05-18 18:57:06 +000092ospf6_area_lsdb_hook_remove (struct ospf6_lsa *lsa)
paul718e3742002-12-13 20:15:29 +000093{
hasso508e53e2004-05-18 18:57:06 +000094 struct ospf6_area *oa;
paul718e3742002-12-13 20:15:29 +000095
hasso508e53e2004-05-18 18:57:06 +000096 oa = (struct ospf6_area *) lsa->scope;
97 switch (ntohs (lsa->header->type))
paul718e3742002-12-13 20:15:29 +000098 {
hasso508e53e2004-05-18 18:57:06 +000099 case OSPF6_LSTYPE_ROUTER:
100 case OSPF6_LSTYPE_NETWORK:
101 ospf6_spf_schedule (oa);
102 break;
paul718e3742002-12-13 20:15:29 +0000103
hasso508e53e2004-05-18 18:57:06 +0000104 case OSPF6_LSTYPE_INTRA_PREFIX:
105 ospf6_intra_prefix_lsa_remove (lsa);
106 break;
107
108 case OSPF6_LSTYPE_INTER_PREFIX:
109 case OSPF6_LSTYPE_INTER_ROUTER:
110 break;
111
112 default:
113 if (IS_OSPF6_DEBUG_LSA (RECV))
114 zlog_info ("Unknown LSA in Area %s's lsdb", oa->name);
115 break;
116 }
117}
118
119void
120ospf6_area_route_hook_add (struct ospf6_route *route)
121{
122 struct ospf6_route *copy = ospf6_route_copy (route);
123 ospf6_route_add (copy, ospf6->route_table);
124}
125
126void
127ospf6_area_route_hook_remove (struct ospf6_route *route)
128{
129 struct ospf6_route *copy;
130
131 copy = ospf6_route_lookup_identical (route, ospf6->route_table);
132 if (copy)
133 ospf6_route_remove (copy, ospf6->route_table);
paul718e3742002-12-13 20:15:29 +0000134}
135
136/* Make new area structure */
137struct ospf6_area *
hasso508e53e2004-05-18 18:57:06 +0000138ospf6_area_create (u_int32_t area_id, struct ospf6 *o)
paul718e3742002-12-13 20:15:29 +0000139{
hasso508e53e2004-05-18 18:57:06 +0000140 struct ospf6_area *oa;
hasso049207c2004-08-04 20:02:13 +0000141 struct ospf6_route *route;
paul718e3742002-12-13 20:15:29 +0000142
hasso508e53e2004-05-18 18:57:06 +0000143 oa = XCALLOC (MTYPE_OSPF6_AREA, sizeof (struct ospf6_area));
paul718e3742002-12-13 20:15:29 +0000144
hasso508e53e2004-05-18 18:57:06 +0000145 inet_ntop (AF_INET, &area_id, oa->name, sizeof (oa->name));
146 oa->area_id = area_id;
147 oa->if_list = list_new ();
paul718e3742002-12-13 20:15:29 +0000148
hasso049207c2004-08-04 20:02:13 +0000149 oa->summary_table = ospf6_route_table_create ();
150
hasso508e53e2004-05-18 18:57:06 +0000151 oa->lsdb = ospf6_lsdb_create ();
152 oa->lsdb->hook_add = ospf6_area_lsdb_hook_add;
153 oa->lsdb->hook_remove = ospf6_area_lsdb_hook_remove;
paul718e3742002-12-13 20:15:29 +0000154
hasso508e53e2004-05-18 18:57:06 +0000155 oa->spf_table = ospf6_route_table_create ();
156 oa->route_table = ospf6_route_table_create ();
157 oa->route_table->hook_add = ospf6_area_route_hook_add;
158 oa->route_table->hook_remove = ospf6_area_route_hook_remove;
paul718e3742002-12-13 20:15:29 +0000159
hasso508e53e2004-05-18 18:57:06 +0000160 /* set default options */
161 OSPF6_OPT_SET (oa->options, OSPF6_OPT_V6);
162 OSPF6_OPT_SET (oa->options, OSPF6_OPT_E);
163 OSPF6_OPT_SET (oa->options, OSPF6_OPT_R);
paul718e3742002-12-13 20:15:29 +0000164
hasso508e53e2004-05-18 18:57:06 +0000165 oa->ospf6 = o;
166 listnode_add_sort (o->area_list, oa);
paul718e3742002-12-13 20:15:29 +0000167
hasso049207c2004-08-04 20:02:13 +0000168 /* import athoer area's routes as inter-area routes */
169 for (route = ospf6_route_head (o->route_table); route;
170 route = ospf6_route_next (route))
171 ospf6_abr_originate_prefix_to_area (route, oa);
172
hasso508e53e2004-05-18 18:57:06 +0000173 return oa;
paul718e3742002-12-13 20:15:29 +0000174}
175
176void
hasso508e53e2004-05-18 18:57:06 +0000177ospf6_area_delete (struct ospf6_area *oa)
paul718e3742002-12-13 20:15:29 +0000178{
179 listnode n;
hasso508e53e2004-05-18 18:57:06 +0000180 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000181
hasso049207c2004-08-04 20:02:13 +0000182 ospf6_route_table_delete (oa->summary_table);
183
paul718e3742002-12-13 20:15:29 +0000184 /* ospf6 interface list */
hasso508e53e2004-05-18 18:57:06 +0000185 for (n = listhead (oa->if_list); n; nextnode (n))
paul718e3742002-12-13 20:15:29 +0000186 {
hasso508e53e2004-05-18 18:57:06 +0000187 oi = (struct ospf6_interface *) getdata (n);
188 ospf6_interface_delete (oi);
paul718e3742002-12-13 20:15:29 +0000189 }
hasso508e53e2004-05-18 18:57:06 +0000190 list_delete (oa->if_list);
paul718e3742002-12-13 20:15:29 +0000191
hasso508e53e2004-05-18 18:57:06 +0000192 ospf6_lsdb_delete (oa->lsdb);
193 ospf6_route_table_delete (oa->spf_table);
194 ospf6_route_table_delete (oa->route_table);
paul718e3742002-12-13 20:15:29 +0000195
hasso508e53e2004-05-18 18:57:06 +0000196#if 0
197 ospf6_spftree_delete (oa->spf_tree);
198 ospf6_route_table_delete (oa->topology_table);
199#endif /*0*/
paul718e3742002-12-13 20:15:29 +0000200
hasso508e53e2004-05-18 18:57:06 +0000201 THREAD_OFF (oa->thread_spf_calculation);
202 THREAD_OFF (oa->thread_route_calculation);
paul718e3742002-12-13 20:15:29 +0000203
hasso508e53e2004-05-18 18:57:06 +0000204 listnode_delete (oa->ospf6->area_list, oa);
205 oa->ospf6 = NULL;
paul718e3742002-12-13 20:15:29 +0000206
207 /* free area */
hasso508e53e2004-05-18 18:57:06 +0000208 XFREE (MTYPE_OSPF6_AREA, oa);
paul718e3742002-12-13 20:15:29 +0000209}
210
211struct ospf6_area *
hasso508e53e2004-05-18 18:57:06 +0000212ospf6_area_lookup (u_int32_t area_id, struct ospf6 *ospf6)
paul718e3742002-12-13 20:15:29 +0000213{
hasso508e53e2004-05-18 18:57:06 +0000214 struct ospf6_area *oa;
paul718e3742002-12-13 20:15:29 +0000215 listnode n;
216
hasso508e53e2004-05-18 18:57:06 +0000217 for (n = listhead (ospf6->area_list); n; nextnode (n))
paul718e3742002-12-13 20:15:29 +0000218 {
hasso508e53e2004-05-18 18:57:06 +0000219 oa = (struct ospf6_area *) getdata (n);
220 if (oa->area_id == area_id)
221 return oa;
paul718e3742002-12-13 20:15:29 +0000222 }
223
224 return (struct ospf6_area *) NULL;
225}
226
227void
hasso508e53e2004-05-18 18:57:06 +0000228ospf6_area_enable (struct ospf6_area *oa)
paul718e3742002-12-13 20:15:29 +0000229{
230 listnode i;
hasso508e53e2004-05-18 18:57:06 +0000231 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000232
hasso508e53e2004-05-18 18:57:06 +0000233 UNSET_FLAG (oa->flag, OSPF6_AREA_DISABLE);
paul718e3742002-12-13 20:15:29 +0000234
hasso508e53e2004-05-18 18:57:06 +0000235 for (i = listhead (oa->if_list); i; nextnode (i))
paul718e3742002-12-13 20:15:29 +0000236 {
hasso508e53e2004-05-18 18:57:06 +0000237 oi = (struct ospf6_interface *) getdata (i);
238 ospf6_interface_enable (oi);
paul718e3742002-12-13 20:15:29 +0000239 }
240}
241
242void
hasso508e53e2004-05-18 18:57:06 +0000243ospf6_area_disable (struct ospf6_area *oa)
paul718e3742002-12-13 20:15:29 +0000244{
hasso508e53e2004-05-18 18:57:06 +0000245 listnode i;
246 struct ospf6_interface *oi;
paul718e3742002-12-13 20:15:29 +0000247
hasso508e53e2004-05-18 18:57:06 +0000248 SET_FLAG (oa->flag, OSPF6_AREA_DISABLE);
249
250 for (i = listhead (oa->if_list); i; nextnode (i))
251 {
252 oi = (struct ospf6_interface *) getdata (i);
253 ospf6_interface_disable (oi);
254 }
paul718e3742002-12-13 20:15:29 +0000255}
256
hasso508e53e2004-05-18 18:57:06 +0000257
258void
259ospf6_area_show (struct vty *vty, struct ospf6_area *oa)
260{
261 listnode i;
262 struct ospf6_interface *oi;
263
hasso049207c2004-08-04 20:02:13 +0000264 vty_out (vty, " Area %s%s", oa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000265 vty_out (vty, " Number of Area scoped LSAs is %u%s",
hasso049207c2004-08-04 20:02:13 +0000266 oa->lsdb->count, VNL);
hasso508e53e2004-05-18 18:57:06 +0000267
268 vty_out (vty, " Interface attached to this area:");
269 for (i = listhead (oa->if_list); i; nextnode (i))
270 {
271 oi = (struct ospf6_interface *) getdata (i);
272 vty_out (vty, " %s", oi->interface->name);
273 }
hasso049207c2004-08-04 20:02:13 +0000274 vty_out (vty, "%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000275}
276
277
hasso049207c2004-08-04 20:02:13 +0000278#define OSPF6_CMD_AREA_LOOKUP(str, oa) \
279{ \
280 u_int32_t area_id = 0; \
281 if (inet_pton (AF_INET, str, &area_id) != 1) \
282 { \
283 vty_out (vty, "Malformed Area-ID: %s%s", str, VNL); \
284 return CMD_SUCCESS; \
285 } \
286 oa = ospf6_area_lookup (area_id, ospf6); \
287 if (oa == NULL) \
288 { \
289 vty_out (vty, "No such Area: %s%s", str, VNL); \
290 return CMD_SUCCESS; \
291 } \
hasso508e53e2004-05-18 18:57:06 +0000292}
293
294DEFUN (show_ipv6_ospf6_area_route_intra,
295 show_ipv6_ospf6_area_route_intra_cmd,
296 "show ipv6 ospf6 area A.B.C.D route intra-area",
paul718e3742002-12-13 20:15:29 +0000297 SHOW_STR
298 IP6_STR
299 OSPF6_STR
300 OSPF6_AREA_STR
301 OSPF6_AREA_ID_STR
302 ROUTE_STR
hasso508e53e2004-05-18 18:57:06 +0000303 "Display Intra-Area routes\n"
paul718e3742002-12-13 20:15:29 +0000304 )
305{
hasso508e53e2004-05-18 18:57:06 +0000306 struct ospf6_area *oa;
307 OSPF6_CMD_AREA_LOOKUP (argv[0], oa);
308 argc--;
309 argv++;
310 return ospf6_route_table_show (vty, argc, argv, oa->route_table);
paul718e3742002-12-13 20:15:29 +0000311}
312
hasso508e53e2004-05-18 18:57:06 +0000313ALIAS (show_ipv6_ospf6_area_route_intra,
314 show_ipv6_ospf6_area_route_intra_detail_cmd,
315 "show ipv6 ospf6 area A.B.C.D route intra-area (X::X|X::X/M|detail)",
paul718e3742002-12-13 20:15:29 +0000316 SHOW_STR
317 IP6_STR
318 OSPF6_STR
319 OSPF6_AREA_STR
320 OSPF6_AREA_ID_STR
321 ROUTE_STR
hasso508e53e2004-05-18 18:57:06 +0000322 "Display Intra-Area routes\n"
paul718e3742002-12-13 20:15:29 +0000323 "Specify IPv6 address\n"
hasso508e53e2004-05-18 18:57:06 +0000324 "Specify IPv6 prefix\n"
325 "Detailed information\n"
326 );
327
328DEFUN (show_ipv6_ospf6_area_route_intra_match,
329 show_ipv6_ospf6_area_route_intra_match_cmd,
330 "show ipv6 ospf6 area A.B.C.D route intra-area X::X/M match",
331 SHOW_STR
332 IP6_STR
333 OSPF6_STR
334 ROUTE_STR
335 "Display Intra-Area routes\n"
336 OSPF6_AREA_STR
337 OSPF6_AREA_ID_STR
338 "Specify IPv6 prefix\n"
339 "Display routes which match the specified route\n"
340 )
341{
342 char *sargv[CMD_ARGC_MAX];
343 int i, sargc;
344 struct ospf6_area *oa;
345
346 OSPF6_CMD_AREA_LOOKUP (argv[0], oa);
347 argc--;
348 argv++;
349
350 /* copy argv to sargv and then append "match" */
351 for (i = 0; i < argc; i++)
352 sargv[i] = argv[i];
353 sargc = argc;
354 sargv[sargc++] = "match";
355 sargv[sargc] = NULL;
356
357 return ospf6_route_table_show (vty, sargc, sargv, oa->route_table);
358}
359
360DEFUN (show_ipv6_ospf6_area_route_intra_match_detail,
361 show_ipv6_ospf6_area_route_intra_match_detail_cmd,
362 "show ipv6 ospf6 area A.B.C.D route intra-area X::X/M match detail",
363 SHOW_STR
364 IP6_STR
365 OSPF6_STR
366 OSPF6_AREA_STR
367 OSPF6_AREA_ID_STR
368 ROUTE_STR
369 "Display Intra-Area routes\n"
370 "Specify IPv6 prefix\n"
371 "Display routes which match the specified route\n"
paul718e3742002-12-13 20:15:29 +0000372 "Detailed information\n"
373 )
hasso508e53e2004-05-18 18:57:06 +0000374{
375 char *sargv[CMD_ARGC_MAX];
376 int i, sargc;
377 struct ospf6_area *oa;
378
379 OSPF6_CMD_AREA_LOOKUP (argv[0], oa);
380 argc--;
381 argv++;
382
383 /* copy argv to sargv and then append "match" and "detail" */
384 for (i = 0; i < argc; i++)
385 sargv[i] = argv[i];
386 sargc = argc;
387 sargv[sargc++] = "match";
388 sargv[sargc++] = "detail";
389 sargv[sargc] = NULL;
390
391 return ospf6_route_table_show (vty, sargc, sargv, oa->route_table);
392}
393
394DEFUN (show_ipv6_ospf6_route_intra,
395 show_ipv6_ospf6_route_intra_cmd,
396 "show ipv6 ospf6 route intra-area",
397 SHOW_STR
398 IP6_STR
399 OSPF6_STR
400 ROUTE_STR
401 "Display Intra-Area routes\n"
402 )
403{
404 listnode node;
405 struct ospf6_area *oa;
406
407 for (node = listhead (ospf6->area_list); node; nextnode (node))
408 {
409 oa = (struct ospf6_area *) getdata (node);
hasso049207c2004-08-04 20:02:13 +0000410 vty_out (vty, "Area %s%s", oa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000411 ospf6_route_table_show (vty, argc, argv, oa->route_table);
412 }
413
414 return CMD_SUCCESS;
415}
416
417ALIAS (show_ipv6_ospf6_route_intra,
418 show_ipv6_ospf6_route_intra_detail_cmd,
419 "show ipv6 ospf6 route intra-area (X::X|X::X/M|detail|summary)",
420 SHOW_STR
421 IP6_STR
422 OSPF6_STR
423 ROUTE_STR
424 "Display Intra-Area routes\n"
425 "Specify IPv6 address\n"
426 "Specify IPv6 prefix\n"
427 "Detailed information\n"
428 "Summary of route table\n"
429 );
430
431DEFUN (show_ipv6_ospf6_route_intra_match,
432 show_ipv6_ospf6_route_intra_match_cmd,
433 "show ipv6 ospf6 route intra-area X::X/M match",
434 SHOW_STR
435 IP6_STR
436 OSPF6_STR
437 ROUTE_STR
438 "Display Intra-Area routes\n"
439 "Specify IPv6 prefix\n"
440 "Display routes which match the specified route\n"
441 )
442{
443 char *sargv[CMD_ARGC_MAX];
444 int i, sargc;
445 listnode node;
446 struct ospf6_area *oa;
447
448 /* copy argv to sargv and then append "match" */
449 for (i = 0; i < argc; i++)
450 sargv[i] = argv[i];
451 sargc = argc;
452 sargv[sargc++] = "match";
453 sargv[sargc] = NULL;
454
455 for (node = listhead (ospf6->area_list); node; nextnode (node))
456 {
457 oa = (struct ospf6_area *) getdata (node);
458 ospf6_route_table_show (vty, sargc, sargv, oa->route_table);
459 }
460
461 return CMD_SUCCESS;
462}
463
464DEFUN (show_ipv6_ospf6_route_intra_match_detail,
465 show_ipv6_ospf6_route_intra_match_detail_cmd,
466 "show ipv6 ospf6 route intra-area X::X/M match detail",
467 SHOW_STR
468 IP6_STR
469 OSPF6_STR
470 ROUTE_STR
471 "Display Intra-Area routes\n"
472 "Specify IPv6 prefix\n"
473 "Display routes which match the specified route\n"
474 "Detailed information\n"
475 )
476{
477 char *sargv[CMD_ARGC_MAX];
478 int i, sargc;
479 listnode node;
480 struct ospf6_area *oa;
481
482 /* copy argv to sargv and then append "match" and "detail" */
483 for (i = 0; i < argc; i++)
484 sargv[i] = argv[i];
485 sargc = argc;
486 sargv[sargc++] = "match";
487 sargv[sargc++] = "detail";
488 sargv[sargc] = NULL;
489
490 for (node = listhead (ospf6->area_list); node; nextnode (node))
491 {
492 oa = (struct ospf6_area *) getdata (node);
493 ospf6_route_table_show (vty, sargc, sargv, oa->route_table);
494 }
495
496 return CMD_SUCCESS;
497}
498
499DEFUN (show_ipv6_ospf6_spf_tree,
500 show_ipv6_ospf6_spf_tree_cmd,
501 "show ipv6 ospf6 spf tree",
502 SHOW_STR
503 IP6_STR
504 OSPF6_STR
505 "Shortest Path First caculation\n"
506 "Show SPF tree\n")
507{
508 listnode node;
509 struct ospf6_area *oa;
510 struct ospf6_vertex *root;
511 struct ospf6_route *route;
512 struct prefix prefix;
513
514 ospf6_linkstate_prefix (ospf6->router_id, htonl (0), &prefix);
515 for (node = listhead (ospf6->area_list); node; nextnode (node))
516 {
517 oa = (struct ospf6_area *) getdata (node);
518 route = ospf6_route_lookup (&prefix, oa->spf_table);
519 if (route == NULL)
520 {
521 vty_out (vty, "LS entry for root not found in area %s%s",
hasso049207c2004-08-04 20:02:13 +0000522 oa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000523 continue;
524 }
525 root = (struct ospf6_vertex *) route->route_option;
526 ospf6_spf_display_subtree (vty, "", 0, root);
527 }
528
529 return CMD_SUCCESS;
530}
531
532DEFUN (show_ipv6_ospf6_area_spf_tree,
533 show_ipv6_ospf6_area_spf_tree_cmd,
534 "show ipv6 ospf6 area A.B.C.D spf tree",
535 SHOW_STR
536 IP6_STR
537 OSPF6_STR
538 OSPF6_AREA_STR
539 OSPF6_AREA_ID_STR
540 "Shortest Path First caculation\n"
541 "Show SPF tree\n")
542{
543 u_int32_t area_id;
544 struct ospf6_area *oa;
545 struct ospf6_vertex *root;
546 struct ospf6_route *route;
547 struct prefix prefix;
548
549 ospf6_linkstate_prefix (ospf6->router_id, htonl (0), &prefix);
550
551 if (inet_pton (AF_INET, argv[0], &area_id) != 1)
552 {
hasso049207c2004-08-04 20:02:13 +0000553 vty_out (vty, "Malformed Area-ID: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000554 return CMD_SUCCESS;
555 }
556 oa = ospf6_area_lookup (area_id, ospf6);
557 if (oa == NULL)
558 {
hasso049207c2004-08-04 20:02:13 +0000559 vty_out (vty, "No such Area: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000560 return CMD_SUCCESS;
561 }
562
563 route = ospf6_route_lookup (&prefix, oa->spf_table);
564 if (route == NULL)
565 {
566 vty_out (vty, "LS entry for root not found in area %s%s",
hasso049207c2004-08-04 20:02:13 +0000567 oa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000568 return CMD_SUCCESS;
569 }
570 root = (struct ospf6_vertex *) route->route_option;
571 ospf6_spf_display_subtree (vty, "", 0, root);
572
573 return CMD_SUCCESS;
574}
575
576DEFUN (show_ipv6_ospf6_area_spf_table,
577 show_ipv6_ospf6_area_spf_table_cmd,
578 "show ipv6 ospf6 area A.B.C.D spf table",
579 SHOW_STR
580 IP6_STR
581 OSPF6_STR
582 OSPF6_AREA_STR
583 OSPF6_AREA_ID_STR
584 "Shortest Path First caculation\n"
585 "Show table contains SPF result\n"
586 )
587{
588 u_int32_t area_id;
589 struct ospf6_area *oa;
590
591 if (inet_pton (AF_INET, argv[0], &area_id) != 1)
592 {
hasso049207c2004-08-04 20:02:13 +0000593 vty_out (vty, "Malformed Area-ID: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000594 return CMD_SUCCESS;
595 }
596 oa = ospf6_area_lookup (area_id, ospf6);
597 if (oa == NULL)
598 {
hasso049207c2004-08-04 20:02:13 +0000599 vty_out (vty, "No such Area: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000600 return CMD_SUCCESS;
601 }
602
603 argc--;
604 argv++;
605
606 ospf6_lsentry_table_show (vty, argc, argv, oa->spf_table);
607 return CMD_SUCCESS;
608}
609
610ALIAS (show_ipv6_ospf6_area_spf_table,
611 show_ipv6_ospf6_area_spf_table_1_cmd,
612 "show ipv6 ospf6 area A.B.C.D spf table (A.B.C.D|A.B.C.D/M|detail)",
613 SHOW_STR
614 IP6_STR
615 OSPF6_STR
616 OSPF6_AREA_STR
617 OSPF6_AREA_ID_STR
618 "Shortest Path First caculation\n"
619 "Show table contains SPF result\n"
620 "Specify Router-ID\n"
621 "Display multiple entry by specifying match-prefix of Router-ID\n"
622 "Display Detail\n"
623 );
624
625ALIAS (show_ipv6_ospf6_area_spf_table,
626 show_ipv6_ospf6_area_spf_table_2_cmd,
627 "show ipv6 ospf6 area A.B.C.D spf table (A.B.C.D|*) (A.B.C.D|A.B.C.D/M|detail)",
628 SHOW_STR
629 IP6_STR
630 OSPF6_STR
631 OSPF6_AREA_STR
632 OSPF6_AREA_ID_STR
633 "Shortest Path First caculation\n"
634 "Show table contains SPF result\n"
635 "Specify Router-ID\n"
636 "Wildcard Router-ID\n"
637 "Specify Link State ID\n"
638 "Display multiple entry by specifying match-prefix of Link State ID\n"
639 "Display Detail\n"
640 );
641
642DEFUN (show_ipv6_ospf6_area_spf_table_3,
643 show_ipv6_ospf6_area_spf_table_3_cmd,
644 "show ipv6 ospf6 area A.B.C.D spf table (A.B.C.D|*) A.B.C.D/M detail",
645 SHOW_STR
646 IP6_STR
647 OSPF6_STR
648 OSPF6_AREA_STR
649 OSPF6_AREA_ID_STR
650 "Shortest Path First caculation\n"
651 "Show table contains SPF result\n"
652 "Specify Router-ID\n"
653 "Wildcard Router-ID\n"
654 "Display multiple entry by specifying match-prefix of Link State ID\n"
655 "Display Detail\n"
656 )
657{
658 u_int32_t area_id;
659 struct ospf6_area *oa;
660 char *sargv[CMD_ARGC_MAX];
661 int i, sargc;
662
663 if (inet_pton (AF_INET, argv[0], &area_id) != 1)
664 {
hasso049207c2004-08-04 20:02:13 +0000665 vty_out (vty, "Malformed Area-ID: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000666 return CMD_SUCCESS;
667 }
668 oa = ospf6_area_lookup (area_id, ospf6);
669 if (oa == NULL)
670 {
hasso049207c2004-08-04 20:02:13 +0000671 vty_out (vty, "No such Area: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000672 return CMD_SUCCESS;
673 }
674
675 argc--;
676 argv++;
677
678 /* copy argv to sargv and then append "detail" */
679 for (i = 0; i < argc; i++)
680 sargv[i] = argv[i];
681 sargc = argc;
682 sargv[sargc++] = "detail";
683 sargv[sargc] = NULL;
684
685 ospf6_lsentry_table_show (vty, sargc, sargv, oa->spf_table);
686 return CMD_SUCCESS;
687}
688
689DEFUN (show_ipv6_ospf6_spf_table,
690 show_ipv6_ospf6_spf_table_cmd,
691 "show ipv6 ospf6 spf table",
692 SHOW_STR
693 IP6_STR
694 OSPF6_STR
695 "Shortest Path First caculation\n"
696 "Show table contains SPF result\n"
697 )
698{
699 listnode node;
700 struct ospf6_area *oa;
701
702 for (node = listhead (ospf6->area_list); node; nextnode (node))
703 {
704 oa = (struct ospf6_area *) getdata (node);
705 ospf6_lsentry_table_show (vty, argc, argv, oa->spf_table);
706 }
707
708 return CMD_SUCCESS;
709}
710
711ALIAS (show_ipv6_ospf6_spf_table,
712 show_ipv6_ospf6_spf_table_1_cmd,
713 "show ipv6 ospf6 spf table (A.B.C.D|A.B.C.D/M|detail)",
714 SHOW_STR
715 IP6_STR
716 OSPF6_STR
717 "Shortest Path First caculation\n"
718 "Show table contains SPF result\n"
719 "Specify Router-ID\n"
720 "Display multiple entry by specifying match-prefix of Router-ID\n"
721 "Display Detail\n"
722 );
723
724ALIAS (show_ipv6_ospf6_spf_table,
725 show_ipv6_ospf6_spf_table_2_cmd,
726 "show ipv6 ospf6 spf table (A.B.C.D|A.B.C.D/M|*) (A.B.C.D|A.B.C.D/M|detail)",
727 SHOW_STR
728 IP6_STR
729 OSPF6_STR
730 "Shortest Path First caculation\n"
731 "Show table contains SPF result\n"
732 "Specify Router-ID\n"
733 "Display multiple entry by specifying match-prefix of Router-ID\n"
734 "Wildcard Router-ID\n"
735 "Specify Link State ID\n"
736 "Display multiple entry by specifying match-prefix of Link State ID\n"
737 "Display Detail\n"
738 );
739
740DEFUN (show_ipv6_ospf6_spf_table_3,
741 show_ipv6_ospf6_spf_table_3_cmd,
742 "show ipv6 ospf6 spf table (A.B.C.D|*) A.B.C.D/M detail",
743 SHOW_STR
744 IP6_STR
745 OSPF6_STR
746 "Shortest Path First caculation\n"
747 "Show table contains SPF result\n"
748 "Specify Router-ID\n"
749 "Wildcard Router-ID\n"
750 "Display multiple entry by specifying match-prefix of Link State ID\n"
751 "Display Detail\n"
752 )
753{
754 listnode node;
755 struct ospf6_area *oa;
756 char *sargv[CMD_ARGC_MAX];
757 int i, sargc;
758
759 /* copy argv to sargv and then append "detail" */
760 for (i = 0; i < argc; i++)
761 sargv[i] = argv[i];
762 sargc = argc;
763 sargv[sargc++] = "detail";
764 sargv[sargc] = NULL;
765
766 for (node = listhead (ospf6->area_list); node; nextnode (node))
767 {
768 oa = (struct ospf6_area *) getdata (node);
769 ospf6_lsentry_table_show (vty, sargc, sargv, oa->spf_table);
770 }
771
772 return CMD_SUCCESS;
773}
774
775DEFUN (show_ipv6_ospf6_simulate_spf_tree_root,
776 show_ipv6_ospf6_simulate_spf_tree_root_cmd,
777 "show ipv6 ospf6 simulate spf-tree A.B.C.D area A.B.C.D",
778 SHOW_STR
779 IP6_STR
780 OSPF6_STR
781 "Shortest Path First caculation\n"
782 "Show SPF tree\n"
783 "Specify root's router-id to calculate another router's SPF tree\n")
784{
785 u_int32_t area_id;
786 struct ospf6_area *oa;
787 struct ospf6_vertex *root;
788 struct ospf6_route *route;
789 struct prefix prefix;
790 u_int32_t router_id;
791 struct ospf6_route_table *spf_table;
792 unsigned char tmp_debug_ospf6_spf = 0;
793
794 inet_pton (AF_INET, argv[0], &router_id);
795 ospf6_linkstate_prefix (router_id, htonl (0), &prefix);
796
797 if (inet_pton (AF_INET, argv[1], &area_id) != 1)
798 {
hasso049207c2004-08-04 20:02:13 +0000799 vty_out (vty, "Malformed Area-ID: %s%s", argv[1], VNL);
hasso508e53e2004-05-18 18:57:06 +0000800 return CMD_SUCCESS;
801 }
802 oa = ospf6_area_lookup (area_id, ospf6);
803 if (oa == NULL)
804 {
hasso049207c2004-08-04 20:02:13 +0000805 vty_out (vty, "No such Area: %s%s", argv[1], VNL);
hasso508e53e2004-05-18 18:57:06 +0000806 return CMD_SUCCESS;
807 }
808
809 tmp_debug_ospf6_spf = conf_debug_ospf6_spf;
810 conf_debug_ospf6_spf = 0;
811
812 spf_table = ospf6_route_table_create ();
813 ospf6_spf_calculation (router_id, spf_table, oa);
814
815 conf_debug_ospf6_spf = tmp_debug_ospf6_spf;
816
817 route = ospf6_route_lookup (&prefix, spf_table);
818 if (route == NULL)
819 {
820 ospf6_spf_table_finish (spf_table);
821 ospf6_route_table_delete (spf_table);
822 return CMD_SUCCESS;
823 }
824 root = (struct ospf6_vertex *) route->route_option;
825 ospf6_spf_display_subtree (vty, "", 0, root);
826
827 ospf6_spf_table_finish (spf_table);
828 ospf6_route_table_delete (spf_table);
829
830 return CMD_SUCCESS;
831}
paul718e3742002-12-13 20:15:29 +0000832
833void
834ospf6_area_init ()
835{
hasso508e53e2004-05-18 18:57:06 +0000836 install_element (VIEW_NODE, &show_ipv6_ospf6_spf_tree_cmd);
837 install_element (VIEW_NODE, &show_ipv6_ospf6_spf_table_cmd);
838 install_element (VIEW_NODE, &show_ipv6_ospf6_spf_table_1_cmd);
839 install_element (VIEW_NODE, &show_ipv6_ospf6_spf_table_2_cmd);
840 install_element (VIEW_NODE, &show_ipv6_ospf6_spf_table_3_cmd);
841 install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_tree_cmd);
842 install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_table_cmd);
843 install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_table_1_cmd);
844 install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_table_2_cmd);
845 install_element (VIEW_NODE, &show_ipv6_ospf6_area_spf_table_3_cmd);
paul718e3742002-12-13 20:15:29 +0000846
hasso508e53e2004-05-18 18:57:06 +0000847 install_element (VIEW_NODE, &show_ipv6_ospf6_route_intra_cmd);
848 install_element (VIEW_NODE, &show_ipv6_ospf6_route_intra_detail_cmd);
849 install_element (VIEW_NODE, &show_ipv6_ospf6_route_intra_match_cmd);
850 install_element (VIEW_NODE, &show_ipv6_ospf6_route_intra_match_detail_cmd);
851 install_element (VIEW_NODE, &show_ipv6_ospf6_area_route_intra_cmd);
852 install_element (VIEW_NODE, &show_ipv6_ospf6_area_route_intra_detail_cmd);
853 install_element (VIEW_NODE, &show_ipv6_ospf6_area_route_intra_match_cmd);
854 install_element (VIEW_NODE, &show_ipv6_ospf6_area_route_intra_match_detail_cmd);
855
856 install_element (VIEW_NODE, &show_ipv6_ospf6_simulate_spf_tree_root_cmd);
857
858 install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_tree_cmd);
859 install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_table_cmd);
860 install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_table_1_cmd);
861 install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_table_2_cmd);
862 install_element (ENABLE_NODE, &show_ipv6_ospf6_spf_table_3_cmd);
863 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_tree_cmd);
864 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_table_cmd);
865 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_table_1_cmd);
866 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_table_2_cmd);
867 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_spf_table_3_cmd);
868
869 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_intra_cmd);
870 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_intra_detail_cmd);
871 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_intra_match_cmd);
872 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_intra_match_detail_cmd);
873 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_route_intra_cmd);
874 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_route_intra_detail_cmd);
875 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_route_intra_match_cmd);
876 install_element (ENABLE_NODE, &show_ipv6_ospf6_area_route_intra_match_detail_cmd);
877
878 install_element (ENABLE_NODE, &show_ipv6_ospf6_simulate_spf_tree_root_cmd);
paul718e3742002-12-13 20:15:29 +0000879}
hasso049207c2004-08-04 20:02:13 +0000880