]> git.proxmox.com Git - mirror_frr.git/blob - ospf6d/ospf6_top.c
ospf6d: ospfv3-show-cmds-instance-check-fix.patch
[mirror_frr.git] / ospf6d / ospf6_top.c
1 /*
2 * Copyright (C) 2003 Yasuhiro Ohara
3 *
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
22 #include <zebra.h>
23
24 #include "log.h"
25 #include "memory.h"
26 #include "vty.h"
27 #include "linklist.h"
28 #include "prefix.h"
29 #include "table.h"
30 #include "thread.h"
31 #include "command.h"
32
33 #include "ospf6_proto.h"
34 #include "ospf6_message.h"
35 #include "ospf6_lsa.h"
36 #include "ospf6_lsdb.h"
37 #include "ospf6_route.h"
38 #include "ospf6_zebra.h"
39
40 #include "ospf6_top.h"
41 #include "ospf6_area.h"
42 #include "ospf6_interface.h"
43 #include "ospf6_neighbor.h"
44
45 #include "ospf6_flood.h"
46 #include "ospf6_asbr.h"
47 #include "ospf6_abr.h"
48 #include "ospf6_intra.h"
49 #include "ospf6_spf.h"
50 #include "ospf6d.h"
51
52 /* global ospf6d variable */
53 struct ospf6 *ospf6;
54
55 static void ospf6_disable (struct ospf6 *o);
56
57 static void
58 ospf6_top_lsdb_hook_add (struct ospf6_lsa *lsa)
59 {
60 switch (ntohs (lsa->header->type))
61 {
62 case OSPF6_LSTYPE_AS_EXTERNAL:
63 ospf6_asbr_lsa_add (lsa);
64 break;
65
66 default:
67 break;
68 }
69 }
70
71 static void
72 ospf6_top_lsdb_hook_remove (struct ospf6_lsa *lsa)
73 {
74 switch (ntohs (lsa->header->type))
75 {
76 case OSPF6_LSTYPE_AS_EXTERNAL:
77 ospf6_asbr_lsa_remove (lsa);
78 break;
79
80 default:
81 break;
82 }
83 }
84
85 static void
86 ospf6_top_route_hook_add (struct ospf6_route *route)
87 {
88 ospf6_abr_originate_summary (route);
89 ospf6_zebra_route_update_add (route);
90 }
91
92 static void
93 ospf6_top_route_hook_remove (struct ospf6_route *route)
94 {
95 route->flag |= OSPF6_ROUTE_REMOVE;
96 ospf6_abr_originate_summary (route);
97 ospf6_zebra_route_update_remove (route);
98 }
99
100 static void
101 ospf6_top_brouter_hook_add (struct ospf6_route *route)
102 {
103 ospf6_abr_examin_brouter (ADV_ROUTER_IN_PREFIX (&route->prefix));
104 ospf6_asbr_lsentry_add (route);
105 ospf6_abr_originate_summary (route);
106 }
107
108 static void
109 ospf6_top_brouter_hook_remove (struct ospf6_route *route)
110 {
111 route->flag |= OSPF6_ROUTE_REMOVE;
112 ospf6_abr_examin_brouter (ADV_ROUTER_IN_PREFIX (&route->prefix));
113 ospf6_asbr_lsentry_remove (route);
114 ospf6_abr_originate_summary (route);
115 }
116
117 static struct ospf6 *
118 ospf6_create (void)
119 {
120 struct ospf6 *o;
121
122 o = XCALLOC (MTYPE_OSPF6_TOP, sizeof (struct ospf6));
123
124 /* initialize */
125 quagga_gettime (QUAGGA_CLK_MONOTONIC, &o->starttime);
126 o->area_list = list_new ();
127 o->area_list->cmp = ospf6_area_cmp;
128 o->lsdb = ospf6_lsdb_create (o);
129 o->lsdb_self = ospf6_lsdb_create (o);
130 o->lsdb->hook_add = ospf6_top_lsdb_hook_add;
131 o->lsdb->hook_remove = ospf6_top_lsdb_hook_remove;
132
133 o->spf_delay = OSPF_SPF_DELAY_DEFAULT;
134 o->spf_holdtime = OSPF_SPF_HOLDTIME_DEFAULT;
135 o->spf_max_holdtime = OSPF_SPF_MAX_HOLDTIME_DEFAULT;
136 o->spf_hold_multiplier = 1;
137
138 o->route_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, ROUTES);
139 o->route_table->scope = o;
140 o->route_table->hook_add = ospf6_top_route_hook_add;
141 o->route_table->hook_remove = ospf6_top_route_hook_remove;
142
143 o->brouter_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, BORDER_ROUTERS);
144 o->brouter_table->scope = o;
145 o->brouter_table->hook_add = ospf6_top_brouter_hook_add;
146 o->brouter_table->hook_remove = ospf6_top_brouter_hook_remove;
147
148 o->external_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, EXTERNAL_ROUTES);
149 o->external_table->scope = o;
150
151 o->external_id_table = route_table_init ();
152
153 o->ref_bandwidth = OSPF6_REFERENCE_BANDWIDTH;
154
155 return o;
156 }
157
158 void
159 ospf6_delete (struct ospf6 *o)
160 {
161 struct listnode *node, *nnode;
162 struct ospf6_area *oa;
163
164 ospf6_disable (ospf6);
165
166 for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
167 ospf6_area_delete (oa);
168
169
170 list_delete (o->area_list);
171
172 ospf6_lsdb_delete (o->lsdb);
173 ospf6_lsdb_delete (o->lsdb_self);
174
175 ospf6_route_table_delete (o->route_table);
176 ospf6_route_table_delete (o->brouter_table);
177
178 ospf6_route_table_delete (o->external_table);
179 route_table_finish (o->external_id_table);
180
181 XFREE (MTYPE_OSPF6_TOP, o);
182 }
183
184 static void
185 ospf6_enable (struct ospf6 *o)
186 {
187 struct listnode *node, *nnode;
188 struct ospf6_area *oa;
189
190 if (CHECK_FLAG (o->flag, OSPF6_DISABLED))
191 {
192 UNSET_FLAG (o->flag, OSPF6_DISABLED);
193 for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
194 ospf6_area_enable (oa);
195 }
196 }
197
198 static void
199 ospf6_disable (struct ospf6 *o)
200 {
201 struct listnode *node, *nnode;
202 struct ospf6_area *oa;
203
204 if (! CHECK_FLAG (o->flag, OSPF6_DISABLED))
205 {
206 SET_FLAG (o->flag, OSPF6_DISABLED);
207
208 for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
209 ospf6_area_disable (oa);
210
211 /* XXX: This also changes persistent settings */
212 ospf6_asbr_redistribute_reset();
213
214 ospf6_lsdb_remove_all (o->lsdb);
215 ospf6_route_remove_all (o->route_table);
216 ospf6_route_remove_all (o->brouter_table);
217
218 THREAD_OFF(o->maxage_remover);
219 THREAD_OFF(o->t_spf_calc);
220 THREAD_OFF(o->t_ase_calc);
221 }
222 }
223
224 int
225 ospf6_maxage_remover (struct thread *thread)
226 {
227 struct ospf6 *o = (struct ospf6 *) THREAD_ARG (thread);
228 struct ospf6_area *oa;
229 struct ospf6_interface *oi;
230 struct ospf6_neighbor *on;
231 struct listnode *i, *j, *k;
232 int reschedule = 0;
233
234 o->maxage_remover = (struct thread *) NULL;
235
236 for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
237 {
238 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
239 {
240 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
241 {
242 if (on->state != OSPF6_NEIGHBOR_EXCHANGE &&
243 on->state != OSPF6_NEIGHBOR_LOADING)
244 continue;
245
246 ospf6_maxage_remove (o);
247 return 0;
248 }
249 }
250 }
251
252 for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
253 {
254 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
255 {
256 if (ospf6_lsdb_maxage_remover (oi->lsdb))
257 {
258 reschedule = 1;
259 }
260 }
261
262 if (ospf6_lsdb_maxage_remover (oa->lsdb))
263 {
264 reschedule = 1;
265 }
266 }
267
268 if (ospf6_lsdb_maxage_remover (o->lsdb))
269 {
270 reschedule = 1;
271 }
272
273 if (reschedule)
274 {
275 ospf6_maxage_remove (o);
276 }
277
278 return 0;
279 }
280
281 void
282 ospf6_maxage_remove (struct ospf6 *o)
283 {
284 if (o && ! o->maxage_remover)
285 o->maxage_remover = thread_add_timer (master, ospf6_maxage_remover, o,
286 OSPF_LSA_MAXAGE_REMOVE_DELAY_DEFAULT);
287 }
288
289 /* start ospf6 */
290 DEFUN (router_ospf6,
291 router_ospf6_cmd,
292 "router ospf6",
293 ROUTER_STR
294 OSPF6_STR)
295 {
296 if (ospf6 == NULL)
297 ospf6 = ospf6_create ();
298
299 /* set current ospf point. */
300 vty->node = OSPF6_NODE;
301 vty->index = ospf6;
302
303 return CMD_SUCCESS;
304 }
305
306 /* stop ospf6 */
307 DEFUN (no_router_ospf6,
308 no_router_ospf6_cmd,
309 "no router ospf6",
310 NO_STR
311 OSPF6_ROUTER_STR)
312 {
313 if (ospf6 == NULL)
314 vty_out (vty, "OSPFv3 is not configured%s", VNL);
315 else
316 {
317 ospf6_delete (ospf6);
318 ospf6 = NULL;
319 }
320
321 /* return to config node . */
322 vty->node = CONFIG_NODE;
323 vty->index = NULL;
324
325 return CMD_SUCCESS;
326 }
327
328 /* change Router_ID commands. */
329 DEFUN (ospf6_router_id,
330 ospf6_router_id_cmd,
331 "router-id A.B.C.D",
332 "Configure OSPF Router-ID\n"
333 V4NOTATION_STR)
334 {
335 int ret;
336 u_int32_t router_id;
337 struct ospf6 *o;
338
339 o = (struct ospf6 *) vty->index;
340
341 ret = inet_pton (AF_INET, argv[0], &router_id);
342 if (ret == 0)
343 {
344 vty_out (vty, "malformed OSPF Router-ID: %s%s", argv[0], VNL);
345 return CMD_SUCCESS;
346 }
347
348 o->router_id_static = router_id;
349 if (o->router_id == 0)
350 o->router_id = router_id;
351
352 return CMD_SUCCESS;
353 }
354
355 DEFUN (ospf6_log_adjacency_changes,
356 ospf6_log_adjacency_changes_cmd,
357 "log-adjacency-changes",
358 "Log changes in adjacency state\n")
359 {
360 struct ospf6 *ospf6 = vty->index;
361
362 SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES);
363 return CMD_SUCCESS;
364 }
365
366 DEFUN (ospf6_log_adjacency_changes_detail,
367 ospf6_log_adjacency_changes_detail_cmd,
368 "log-adjacency-changes detail",
369 "Log changes in adjacency state\n"
370 "Log all state changes\n")
371 {
372 struct ospf6 *ospf6 = vty->index;
373
374 SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES);
375 SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL);
376 return CMD_SUCCESS;
377 }
378
379 DEFUN (no_ospf6_log_adjacency_changes,
380 no_ospf6_log_adjacency_changes_cmd,
381 "no log-adjacency-changes",
382 NO_STR
383 "Log changes in adjacency state\n")
384 {
385 struct ospf6 *ospf6 = vty->index;
386
387 UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL);
388 UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES);
389 return CMD_SUCCESS;
390 }
391
392 DEFUN (no_ospf6_log_adjacency_changes_detail,
393 no_ospf6_log_adjacency_changes_detail_cmd,
394 "no log-adjacency-changes detail",
395 NO_STR
396 "Log changes in adjacency state\n"
397 "Log all state changes\n")
398 {
399 struct ospf6 *ospf6 = vty->index;
400
401 UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL);
402 return CMD_SUCCESS;
403 }
404
405 DEFUN (ospf6_interface_area,
406 ospf6_interface_area_cmd,
407 "interface IFNAME area A.B.C.D",
408 "Enable routing on an IPv6 interface\n"
409 IFNAME_STR
410 "Specify the OSPF6 area ID\n"
411 "OSPF6 area ID in IPv4 address notation\n"
412 )
413 {
414 struct ospf6 *o;
415 struct ospf6_area *oa;
416 struct ospf6_interface *oi;
417 struct interface *ifp;
418 u_int32_t area_id;
419
420 o = (struct ospf6 *) vty->index;
421
422 /* find/create ospf6 interface */
423 ifp = if_get_by_name (argv[0]);
424 oi = (struct ospf6_interface *) ifp->info;
425 if (oi == NULL)
426 oi = ospf6_interface_create (ifp);
427 if (oi->area)
428 {
429 vty_out (vty, "%s already attached to Area %s%s",
430 oi->interface->name, oi->area->name, VNL);
431 return CMD_SUCCESS;
432 }
433
434 /* parse Area-ID */
435 if (inet_pton (AF_INET, argv[1], &area_id) != 1)
436 {
437 vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL);
438 return CMD_SUCCESS;
439 }
440
441 /* find/create ospf6 area */
442 oa = ospf6_area_lookup (area_id, o);
443 if (oa == NULL)
444 oa = ospf6_area_create (area_id, o);
445
446 /* attach interface to area */
447 listnode_add (oa->if_list, oi); /* sort ?? */
448 oi->area = oa;
449
450 SET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
451
452 /* ospf6 process is currently disabled, not much more to do */
453 if (CHECK_FLAG (o->flag, OSPF6_DISABLED))
454 return CMD_SUCCESS;
455
456 /* start up */
457 ospf6_interface_enable (oi);
458
459 /* If the router is ABR, originate summary routes */
460 if (ospf6_is_router_abr (o))
461 ospf6_abr_enable_area (oa);
462
463 return CMD_SUCCESS;
464 }
465
466 DEFUN (no_ospf6_interface_area,
467 no_ospf6_interface_area_cmd,
468 "no interface IFNAME area A.B.C.D",
469 NO_STR
470 "Disable routing on an IPv6 interface\n"
471 IFNAME_STR
472 "Specify the OSPF6 area ID\n"
473 "OSPF6 area ID in IPv4 address notation\n"
474 )
475 {
476 struct ospf6 *o;
477 struct ospf6_interface *oi;
478 struct ospf6_area *oa;
479 struct interface *ifp;
480 u_int32_t area_id;
481
482 o = (struct ospf6 *) vty->index;
483
484 ifp = if_lookup_by_name (argv[0]);
485 if (ifp == NULL)
486 {
487 vty_out (vty, "No such interface %s%s", argv[0], VNL);
488 return CMD_SUCCESS;
489 }
490
491 oi = (struct ospf6_interface *) ifp->info;
492 if (oi == NULL)
493 {
494 vty_out (vty, "Interface %s not enabled%s", ifp->name, VNL);
495 return CMD_SUCCESS;
496 }
497
498 /* parse Area-ID */
499 if (inet_pton (AF_INET, argv[1], &area_id) != 1)
500 {
501 vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL);
502 return CMD_SUCCESS;
503 }
504
505 /* Verify Area */
506 if (oi->area == NULL)
507 {
508 vty_out (vty, "No such Area-ID: %s%s", argv[1], VNL);
509 return CMD_SUCCESS;
510 }
511
512 if (oi->area->area_id != area_id)
513 {
514 vty_out (vty, "Wrong Area-ID: %s is attached to area %s%s",
515 oi->interface->name, oi->area->name, VNL);
516 return CMD_SUCCESS;
517 }
518
519 thread_execute (master, interface_down, oi, 0);
520
521 oa = oi->area;
522 listnode_delete (oi->area->if_list, oi);
523 oi->area = (struct ospf6_area *) NULL;
524
525 /* Withdraw inter-area routes from this area, if necessary */
526 if (oa->if_list->count == 0)
527 {
528 UNSET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
529 ospf6_abr_disable_area (oa);
530 }
531
532 return CMD_SUCCESS;
533 }
534
535 DEFUN (ospf6_stub_router_admin,
536 ospf6_stub_router_admin_cmd,
537 "stub-router administrative",
538 "Make router a stub router\n"
539 "Advertise inability to be a transit router\n"
540 "Administratively applied, for an indefinite period\n")
541 {
542 struct listnode *node;
543 struct ospf6_area *oa;
544
545 if (!CHECK_FLAG (ospf6->flag, OSPF6_STUB_ROUTER))
546 {
547 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
548 {
549 OSPF6_OPT_CLEAR (oa->options, OSPF6_OPT_V6);
550 OSPF6_OPT_CLEAR (oa->options, OSPF6_OPT_R);
551 OSPF6_ROUTER_LSA_SCHEDULE (oa);
552 }
553 SET_FLAG (ospf6->flag, OSPF6_STUB_ROUTER);
554 }
555
556 return CMD_SUCCESS;
557 }
558
559 DEFUN (no_ospf6_stub_router_admin,
560 no_ospf6_stub_router_admin_cmd,
561 "no stub-router administrative",
562 NO_STR
563 "Make router a stub router\n"
564 "Advertise ability to be a transit router\n"
565 "Administratively applied, for an indefinite period\n")
566 {
567 struct listnode *node;
568 struct ospf6_area *oa;
569
570 if (CHECK_FLAG (ospf6->flag, OSPF6_STUB_ROUTER))
571 {
572 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
573 {
574 OSPF6_OPT_SET (oa->options, OSPF6_OPT_V6);
575 OSPF6_OPT_SET (oa->options, OSPF6_OPT_R);
576 OSPF6_ROUTER_LSA_SCHEDULE (oa);
577 }
578 UNSET_FLAG (ospf6->flag, OSPF6_STUB_ROUTER);
579 }
580
581 return CMD_SUCCESS;
582 }
583
584 DEFUN (ospf6_stub_router_startup,
585 ospf6_stub_router_startup_cmd,
586 "stub-router on-startup <5-86400>",
587 "Make router a stub router\n"
588 "Advertise inability to be a transit router\n"
589 "Automatically advertise as stub-router on startup of OSPF6\n"
590 "Time (seconds) to advertise self as stub-router\n")
591 {
592 return CMD_SUCCESS;
593 }
594
595 DEFUN (no_ospf6_stub_router_startup,
596 no_ospf6_stub_router_startup_cmd,
597 "no stub-router on-startup",
598 NO_STR
599 "Make router a stub router\n"
600 "Advertise inability to be a transit router\n"
601 "Automatically advertise as stub-router on startup of OSPF6\n"
602 "Time (seconds) to advertise self as stub-router\n")
603 {
604 return CMD_SUCCESS;
605 }
606
607 DEFUN (ospf6_stub_router_shutdown,
608 ospf6_stub_router_shutdown_cmd,
609 "stub-router on-shutdown <5-86400>",
610 "Make router a stub router\n"
611 "Advertise inability to be a transit router\n"
612 "Automatically advertise as stub-router before shutdown\n"
613 "Time (seconds) to advertise self as stub-router\n")
614 {
615 return CMD_SUCCESS;
616 }
617
618 DEFUN (no_ospf6_stub_router_shutdown,
619 no_ospf6_stub_router_shutdown_cmd,
620 "no stub-router on-shutdown",
621 NO_STR
622 "Make router a stub router\n"
623 "Advertise inability to be a transit router\n"
624 "Automatically advertise as stub-router before shutdown\n"
625 "Time (seconds) to advertise self as stub-router\n")
626 {
627 return CMD_SUCCESS;
628 }
629
630 static void
631 ospf6_show (struct vty *vty, struct ospf6 *o)
632 {
633 struct listnode *n;
634 struct ospf6_area *oa;
635 char router_id[16], duration[32];
636 struct timeval now, running, result;
637 char buf[32], rbuf[32];
638
639 /* process id, router id */
640 inet_ntop (AF_INET, &o->router_id, router_id, sizeof (router_id));
641 vty_out (vty, " OSPFv3 Routing Process (0) with Router-ID %s%s",
642 router_id, VNL);
643
644 /* running time */
645 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
646 timersub (&now, &o->starttime, &running);
647 timerstring (&running, duration, sizeof (duration));
648 vty_out (vty, " Running %s%s", duration, VNL);
649
650 /* Redistribute configuration */
651 /* XXX */
652
653 /* Show SPF parameters */
654 vty_out(vty, " Initial SPF scheduling delay %d millisec(s)%s"
655 " Minimum hold time between consecutive SPFs %d millsecond(s)%s"
656 " Maximum hold time between consecutive SPFs %d millsecond(s)%s"
657 " Hold time multiplier is currently %d%s",
658 o->spf_delay, VNL,
659 o->spf_holdtime, VNL,
660 o->spf_max_holdtime, VNL,
661 o->spf_hold_multiplier, VNL);
662
663 vty_out(vty, " SPF algorithm ");
664 if (o->ts_spf.tv_sec || o->ts_spf.tv_usec)
665 {
666 timersub(&now, &o->ts_spf, &result);
667 timerstring(&result, buf, sizeof(buf));
668 ospf6_spf_reason_string(o->last_spf_reason, rbuf, sizeof(rbuf));
669 vty_out(vty, "last executed %s ago, reason %s%s", buf, rbuf, VNL);
670 vty_out (vty, " Last SPF duration %ld sec %ld usec%s",
671 o->ts_spf_duration.tv_sec, o->ts_spf_duration.tv_usec, VNL);
672 }
673 else
674 vty_out(vty, "has not been run$%s", VNL);
675 threadtimer_string(now, o->t_spf_calc, buf, sizeof(buf));
676 vty_out (vty, " SPF timer %s%s%s",
677 (o->t_spf_calc ? "due in " : "is "), buf, VNL);
678
679 if (CHECK_FLAG (o->flag, OSPF6_STUB_ROUTER))
680 vty_out (vty, " Router Is Stub Router%s", VNL);
681
682 /* LSAs */
683 vty_out (vty, " Number of AS scoped LSAs is %u%s",
684 o->lsdb->count, VNL);
685
686 /* Areas */
687 vty_out (vty, " Number of areas in this router is %u%s",
688 listcount (o->area_list), VNL);
689
690 if (CHECK_FLAG(o->config_flags, OSPF6_LOG_ADJACENCY_CHANGES))
691 {
692 if (CHECK_FLAG(o->config_flags, OSPF6_LOG_ADJACENCY_DETAIL))
693 vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE);
694 else
695 vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE);
696 }
697
698 vty_out (vty, "%s",VTY_NEWLINE);
699
700 for (ALL_LIST_ELEMENTS_RO (o->area_list, n, oa))
701 ospf6_area_show (vty, oa);
702 }
703
704 /* show top level structures */
705 DEFUN (show_ipv6_ospf6,
706 show_ipv6_ospf6_cmd,
707 "show ipv6 ospf6",
708 SHOW_STR
709 IP6_STR
710 OSPF6_STR)
711 {
712 OSPF6_CMD_CHECK_RUNNING ();
713
714 ospf6_show (vty, ospf6);
715 return CMD_SUCCESS;
716 }
717
718 DEFUN (show_ipv6_ospf6_route,
719 show_ipv6_ospf6_route_cmd,
720 "show ipv6 ospf6 route",
721 SHOW_STR
722 IP6_STR
723 OSPF6_STR
724 ROUTE_STR
725 )
726 {
727 OSPF6_CMD_CHECK_RUNNING ();
728
729 ospf6_route_table_show (vty, argc, argv, ospf6->route_table);
730 return CMD_SUCCESS;
731 }
732
733 ALIAS (show_ipv6_ospf6_route,
734 show_ipv6_ospf6_route_detail_cmd,
735 "show ipv6 ospf6 route (X:X::X:X|X:X::X:X/M|detail|summary)",
736 SHOW_STR
737 IP6_STR
738 OSPF6_STR
739 ROUTE_STR
740 "Specify IPv6 address\n"
741 "Specify IPv6 prefix\n"
742 "Detailed information\n"
743 "Summary of route table\n"
744 )
745
746 DEFUN (show_ipv6_ospf6_route_match,
747 show_ipv6_ospf6_route_match_cmd,
748 "show ipv6 ospf6 route X:X::X:X/M match",
749 SHOW_STR
750 IP6_STR
751 OSPF6_STR
752 ROUTE_STR
753 "Specify IPv6 prefix\n"
754 "Display routes which match the specified route\n"
755 )
756 {
757 const char *sargv[CMD_ARGC_MAX];
758 int i, sargc;
759
760 OSPF6_CMD_CHECK_RUNNING ();
761
762 /* copy argv to sargv and then append "match" */
763 for (i = 0; i < argc; i++)
764 sargv[i] = argv[i];
765 sargc = argc;
766 sargv[sargc++] = "match";
767 sargv[sargc] = NULL;
768
769 ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
770 return CMD_SUCCESS;
771 }
772
773 DEFUN (show_ipv6_ospf6_route_match_detail,
774 show_ipv6_ospf6_route_match_detail_cmd,
775 "show ipv6 ospf6 route X:X::X:X/M match detail",
776 SHOW_STR
777 IP6_STR
778 OSPF6_STR
779 ROUTE_STR
780 "Specify IPv6 prefix\n"
781 "Display routes which match the specified route\n"
782 "Detailed information\n"
783 )
784 {
785 const char *sargv[CMD_ARGC_MAX];
786 int i, sargc;
787
788 /* copy argv to sargv and then append "match" and "detail" */
789 for (i = 0; i < argc; i++)
790 sargv[i] = argv[i];
791 sargc = argc;
792 sargv[sargc++] = "match";
793 sargv[sargc++] = "detail";
794 sargv[sargc] = NULL;
795
796 OSPF6_CMD_CHECK_RUNNING ();
797
798 ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
799 return CMD_SUCCESS;
800 }
801
802 ALIAS (show_ipv6_ospf6_route_match,
803 show_ipv6_ospf6_route_longer_cmd,
804 "show ipv6 ospf6 route X:X::X:X/M longer",
805 SHOW_STR
806 IP6_STR
807 OSPF6_STR
808 ROUTE_STR
809 "Specify IPv6 prefix\n"
810 "Display routes longer than the specified route\n"
811 )
812
813 DEFUN (show_ipv6_ospf6_route_match_detail,
814 show_ipv6_ospf6_route_longer_detail_cmd,
815 "show ipv6 ospf6 route X:X::X:X/M longer detail",
816 SHOW_STR
817 IP6_STR
818 OSPF6_STR
819 ROUTE_STR
820 "Specify IPv6 prefix\n"
821 "Display routes longer than the specified route\n"
822 "Detailed information\n"
823 );
824
825 ALIAS (show_ipv6_ospf6_route,
826 show_ipv6_ospf6_route_type_cmd,
827 "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2)",
828 SHOW_STR
829 IP6_STR
830 OSPF6_STR
831 ROUTE_STR
832 "Display Intra-Area routes\n"
833 "Display Inter-Area routes\n"
834 "Display Type-1 External routes\n"
835 "Display Type-2 External routes\n"
836 )
837
838 DEFUN (show_ipv6_ospf6_route_type_detail,
839 show_ipv6_ospf6_route_type_detail_cmd,
840 "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2) detail",
841 SHOW_STR
842 IP6_STR
843 OSPF6_STR
844 ROUTE_STR
845 "Display Intra-Area routes\n"
846 "Display Inter-Area routes\n"
847 "Display Type-1 External routes\n"
848 "Display Type-2 External routes\n"
849 "Detailed information\n"
850 )
851 {
852 const char *sargv[CMD_ARGC_MAX];
853 int i, sargc;
854
855 /* copy argv to sargv and then append "detail" */
856 for (i = 0; i < argc; i++)
857 sargv[i] = argv[i];
858 sargc = argc;
859 sargv[sargc++] = "detail";
860 sargv[sargc] = NULL;
861
862 OSPF6_CMD_CHECK_RUNNING ();
863
864 ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
865 return CMD_SUCCESS;
866 }
867
868 static void
869 ospf6_stub_router_config_write (struct vty *vty)
870 {
871 if (CHECK_FLAG (ospf6->flag, OSPF6_STUB_ROUTER))
872 {
873 vty_out (vty, " stub-router administrative%s", VNL);
874 }
875 return;
876 }
877
878 /* OSPF configuration write function. */
879 static int
880 config_write_ospf6 (struct vty *vty)
881 {
882 char router_id[16];
883 struct listnode *j, *k;
884 struct ospf6_area *oa;
885 struct ospf6_interface *oi;
886
887 /* OSPFv6 configuration. */
888 if (ospf6 == NULL)
889 return CMD_SUCCESS;
890
891 inet_ntop (AF_INET, &ospf6->router_id_static, router_id, sizeof (router_id));
892 vty_out (vty, "router ospf6%s", VNL);
893 if (ospf6->router_id_static != 0)
894 vty_out (vty, " router-id %s%s", router_id, VNL);
895
896 /* log-adjacency-changes flag print. */
897 if (CHECK_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES))
898 {
899 vty_out(vty, " log-adjacency-changes");
900 if (CHECK_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL))
901 vty_out(vty, " detail");
902 vty_out(vty, "%s", VTY_NEWLINE);
903 }
904
905 if (ospf6->ref_bandwidth != OSPF6_REFERENCE_BANDWIDTH)
906 vty_out (vty, " auto-cost reference-bandwidth %d%s", ospf6->ref_bandwidth / 1000,
907 VNL);
908
909 ospf6_stub_router_config_write (vty);
910 ospf6_redistribute_config_write (vty);
911 ospf6_area_config_write (vty);
912 ospf6_spf_config_write (vty);
913
914 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, j, oa))
915 {
916 for (ALL_LIST_ELEMENTS_RO (oa->if_list, k, oi))
917 vty_out (vty, " interface %s area %s%s",
918 oi->interface->name, oa->name, VNL);
919 }
920 vty_out (vty, "!%s", VNL);
921 return 0;
922 }
923
924 /* OSPF6 node structure. */
925 static struct cmd_node ospf6_node =
926 {
927 OSPF6_NODE,
928 "%s(config-ospf6)# ",
929 1 /* VTYSH */
930 };
931
932 /* Install ospf related commands. */
933 void
934 ospf6_top_init (void)
935 {
936 /* Install ospf6 top node. */
937 install_node (&ospf6_node, config_write_ospf6);
938
939 install_element (VIEW_NODE, &show_ipv6_ospf6_cmd);
940 install_element (ENABLE_NODE, &show_ipv6_ospf6_cmd);
941 install_element (CONFIG_NODE, &router_ospf6_cmd);
942 install_element (CONFIG_NODE, &no_router_ospf6_cmd);
943
944 install_element (VIEW_NODE, &show_ipv6_ospf6_route_cmd);
945 install_element (VIEW_NODE, &show_ipv6_ospf6_route_detail_cmd);
946 install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_cmd);
947 install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_detail_cmd);
948 install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_cmd);
949 install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_detail_cmd);
950 install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_cmd);
951 install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_detail_cmd);
952 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_cmd);
953 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_detail_cmd);
954 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_match_cmd);
955 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_match_detail_cmd);
956 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_longer_cmd);
957 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_longer_detail_cmd);
958 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_type_cmd);
959 install_element (ENABLE_NODE, &show_ipv6_ospf6_route_type_detail_cmd);
960
961 install_default (OSPF6_NODE);
962 install_element (OSPF6_NODE, &ospf6_router_id_cmd);
963 install_element (OSPF6_NODE, &ospf6_log_adjacency_changes_cmd);
964 install_element (OSPF6_NODE, &ospf6_log_adjacency_changes_detail_cmd);
965 install_element (OSPF6_NODE, &no_ospf6_log_adjacency_changes_cmd);
966 install_element (OSPF6_NODE, &no_ospf6_log_adjacency_changes_detail_cmd);
967 install_element (OSPF6_NODE, &ospf6_interface_area_cmd);
968 install_element (OSPF6_NODE, &no_ospf6_interface_area_cmd);
969 install_element (OSPF6_NODE, &ospf6_stub_router_admin_cmd);
970 install_element (OSPF6_NODE, &no_ospf6_stub_router_admin_cmd);
971 /* For a later time
972 install_element (OSPF6_NODE, &ospf6_stub_router_startup_cmd);
973 install_element (OSPF6_NODE, &no_ospf6_stub_router_startup_cmd);
974 install_element (OSPF6_NODE, &ospf6_stub_router_shutdown_cmd);
975 install_element (OSPF6_NODE, &no_ospf6_stub_router_shutdown_cmd);
976 */
977 }
978
979