2 * Copyright (C) 2003 Yasuhiro Ohara
4 * This file is part of GNU Zebra.
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
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.
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.
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"
40 #include "ospf6_top.h"
41 #include "ospf6_area.h"
42 #include "ospf6_interface.h"
43 #include "ospf6_neighbor.h"
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"
52 /* global ospf6d variable */
55 static void ospf6_disable (struct ospf6 *o);
58 ospf6_top_lsdb_hook_add (struct ospf6_lsa *lsa)
60 switch (ntohs (lsa->header->type))
62 case OSPF6_LSTYPE_AS_EXTERNAL:
63 ospf6_asbr_lsa_add (lsa);
72 ospf6_top_lsdb_hook_remove (struct ospf6_lsa *lsa)
74 switch (ntohs (lsa->header->type))
76 case OSPF6_LSTYPE_AS_EXTERNAL:
77 ospf6_asbr_lsa_remove (lsa);
86 ospf6_top_route_hook_add (struct ospf6_route *route)
88 ospf6_abr_originate_summary (route);
89 ospf6_zebra_route_update_add (route);
93 ospf6_top_route_hook_remove (struct ospf6_route *route)
95 ospf6_abr_originate_summary (route);
96 ospf6_zebra_route_update_remove (route);
100 ospf6_top_brouter_hook_add (struct ospf6_route *route)
102 ospf6_abr_examin_brouter (ADV_ROUTER_IN_PREFIX (&route->prefix));
103 ospf6_asbr_lsentry_add (route);
104 ospf6_abr_originate_summary (route);
108 ospf6_top_brouter_hook_remove (struct ospf6_route *route)
110 ospf6_abr_examin_brouter (ADV_ROUTER_IN_PREFIX (&route->prefix));
111 ospf6_asbr_lsentry_remove (route);
112 ospf6_abr_originate_summary (route);
115 static struct ospf6 *
120 o = XCALLOC (MTYPE_OSPF6_TOP, sizeof (struct ospf6));
123 quagga_gettime (QUAGGA_CLK_MONOTONIC, &o->starttime);
124 o->area_list = list_new ();
125 o->area_list->cmp = ospf6_area_cmp;
126 o->lsdb = ospf6_lsdb_create (o);
127 o->lsdb_self = ospf6_lsdb_create (o);
128 o->lsdb->hook_add = ospf6_top_lsdb_hook_add;
129 o->lsdb->hook_remove = ospf6_top_lsdb_hook_remove;
131 o->spf_delay = OSPF_SPF_DELAY_DEFAULT;
132 o->spf_holdtime = OSPF_SPF_HOLDTIME_DEFAULT;
133 o->spf_max_holdtime = OSPF_SPF_MAX_HOLDTIME_DEFAULT;
134 o->spf_hold_multiplier = 1;
136 o->route_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, ROUTES);
137 o->route_table->scope = o;
138 o->route_table->hook_add = ospf6_top_route_hook_add;
139 o->route_table->hook_remove = ospf6_top_route_hook_remove;
141 o->brouter_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, BORDER_ROUTERS);
142 o->brouter_table->scope = o;
143 o->brouter_table->hook_add = ospf6_top_brouter_hook_add;
144 o->brouter_table->hook_remove = ospf6_top_brouter_hook_remove;
146 o->external_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, EXTERNAL_ROUTES);
147 o->external_table->scope = o;
149 o->external_id_table = route_table_init ();
151 o->ref_bandwidth = OSPF6_REFERENCE_BANDWIDTH;
153 o->distance_table = route_table_init ();
159 ospf6_delete (struct ospf6 *o)
161 struct listnode *node, *nnode;
162 struct ospf6_area *oa;
164 ospf6_disable (ospf6);
166 for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
167 ospf6_area_delete (oa);
170 list_delete (o->area_list);
172 ospf6_lsdb_delete (o->lsdb);
173 ospf6_lsdb_delete (o->lsdb_self);
175 ospf6_route_table_delete (o->route_table);
176 ospf6_route_table_delete (o->brouter_table);
178 ospf6_route_table_delete (o->external_table);
179 route_table_finish (o->external_id_table);
181 ospf6_distance_reset (o);
182 route_table_finish (o->distance_table);
184 XFREE (MTYPE_OSPF6_TOP, o);
188 __attribute__((unused))
189 ospf6_enable (struct ospf6 *o)
191 struct listnode *node, *nnode;
192 struct ospf6_area *oa;
194 if (CHECK_FLAG (o->flag, OSPF6_DISABLED))
196 UNSET_FLAG (o->flag, OSPF6_DISABLED);
197 for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
198 ospf6_area_enable (oa);
203 ospf6_disable (struct ospf6 *o)
205 struct listnode *node, *nnode;
206 struct ospf6_area *oa;
208 if (! CHECK_FLAG (o->flag, OSPF6_DISABLED))
210 SET_FLAG (o->flag, OSPF6_DISABLED);
212 for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
213 ospf6_area_disable (oa);
215 /* XXX: This also changes persistent settings */
216 ospf6_asbr_redistribute_reset();
218 ospf6_lsdb_remove_all (o->lsdb);
219 ospf6_route_remove_all (o->route_table);
220 ospf6_route_remove_all (o->brouter_table);
222 THREAD_OFF(o->maxage_remover);
223 THREAD_OFF(o->t_spf_calc);
224 THREAD_OFF(o->t_ase_calc);
229 ospf6_maxage_remover (struct thread *thread)
231 struct ospf6 *o = (struct ospf6 *) THREAD_ARG (thread);
232 struct ospf6_area *oa;
233 struct ospf6_interface *oi;
234 struct ospf6_neighbor *on;
235 struct listnode *i, *j, *k;
238 o->maxage_remover = (struct thread *) NULL;
240 for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
242 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
244 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
246 if (on->state != OSPF6_NEIGHBOR_EXCHANGE &&
247 on->state != OSPF6_NEIGHBOR_LOADING)
250 ospf6_maxage_remove (o);
256 for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
258 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
260 if (ospf6_lsdb_maxage_remover (oi->lsdb))
266 if (ospf6_lsdb_maxage_remover (oa->lsdb))
272 if (ospf6_lsdb_maxage_remover (o->lsdb))
279 ospf6_maxage_remove (o);
286 ospf6_maxage_remove (struct ospf6 *o)
288 if (o && ! o->maxage_remover)
289 o->maxage_remover = thread_add_timer (master, ospf6_maxage_remover, o,
290 OSPF_LSA_MAXAGE_REMOVE_DELAY_DEFAULT);
301 ospf6 = ospf6_create ();
303 /* set current ospf point. */
304 vty->node = OSPF6_NODE;
311 DEFUN (no_router_ospf6,
318 vty_out (vty, "OSPFv3 is not configured%s", VNL);
321 ospf6_delete (ospf6);
325 /* return to config node . */
326 vty->node = CONFIG_NODE;
332 /* change Router_ID commands. */
333 DEFUN (ospf6_router_id,
336 "Configure OSPF Router-ID\n"
343 o = (struct ospf6 *) vty->index;
345 ret = inet_pton (AF_INET, argv[0], &router_id);
348 vty_out (vty, "malformed OSPF Router-ID: %s%s", argv[0], VNL);
352 o->router_id_static = router_id;
353 if (o->router_id == 0)
354 o->router_id = router_id;
359 DEFUN (ospf6_log_adjacency_changes,
360 ospf6_log_adjacency_changes_cmd,
361 "log-adjacency-changes",
362 "Log changes in adjacency state\n")
364 struct ospf6 *ospf6 = vty->index;
366 SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES);
370 DEFUN (ospf6_log_adjacency_changes_detail,
371 ospf6_log_adjacency_changes_detail_cmd,
372 "log-adjacency-changes detail",
373 "Log changes in adjacency state\n"
374 "Log all state changes\n")
376 struct ospf6 *ospf6 = vty->index;
378 SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES);
379 SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL);
383 DEFUN (no_ospf6_log_adjacency_changes,
384 no_ospf6_log_adjacency_changes_cmd,
385 "no log-adjacency-changes",
387 "Log changes in adjacency state\n")
389 struct ospf6 *ospf6 = vty->index;
391 UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL);
392 UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES);
396 DEFUN (no_ospf6_log_adjacency_changes_detail,
397 no_ospf6_log_adjacency_changes_detail_cmd,
398 "no log-adjacency-changes detail",
400 "Log changes in adjacency state\n"
401 "Log all state changes\n")
403 struct ospf6 *ospf6 = vty->index;
405 UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL);
409 DEFUN (ospf6_distance,
413 "Define an administrative distance\n"
414 "OSPF6 Administrative distance\n")
418 o = (struct ospf6 *) vty->index;
420 o->distance_all = atoi (argv[0]);
425 DEFUN (no_ospf6_distance,
426 no_ospf6_distance_cmd,
427 "no distance <1-255>",
429 "Define an administrative distance\n"
430 "OSPF6 Administrative distance\n")
434 o = (struct ospf6 *) vty->index;
441 DEFUN (no_ospf6_distance_ospf6,
442 no_ospf6_distance_ospf6_cmd,
445 "Define an administrative distance\n"
446 "OSPF6 Administrative distance\n"
451 o = (struct ospf6 *) vty->index;
453 o->distance_intra = 0;
454 o->distance_inter = 0;
455 o->distance_external = 0;
460 DEFUN (ospf6_distance_ospf6_intra,
461 ospf6_distance_ospf6_intra_cmd,
462 "distance ospf6 intra-area <1-255>",
463 "Define an administrative distance\n"
464 "OSPF6 Administrative distance\n"
465 "Intra-area routes\n"
466 "Distance for intra-area routes\n")
470 o = (struct ospf6 *) vty->index;
472 o->distance_intra = atoi (argv[0]);
477 DEFUN (ospf6_distance_ospf6_intra_inter,
478 ospf6_distance_ospf6_intra_inter_cmd,
479 "distance ospf6 intra-area <1-255> inter-area <1-255>",
480 "Define an administrative distance\n"
481 "OSPF6 Administrative distance\n"
482 "Intra-area routes\n"
483 "Distance for intra-area routes\n"
484 "Inter-area routes\n"
485 "Distance for inter-area routes\n")
489 o = (struct ospf6 *) vty->index;
491 o->distance_intra = atoi (argv[0]);
492 o->distance_inter = atoi (argv[1]);
497 DEFUN (ospf6_distance_ospf6_intra_external,
498 ospf6_distance_ospf6_intra_external_cmd,
499 "distance ospf6 intra-area <1-255> external <1-255>",
500 "Define an administrative distance\n"
501 "OSPF6 Administrative distance\n"
502 "Intra-area routes\n"
503 "Distance for intra-area routes\n"
505 "Distance for external routes\n")
509 o = (struct ospf6 *) vty->index;
511 o->distance_intra = atoi (argv[0]);
512 o->distance_external = atoi (argv[1]);
517 DEFUN (ospf6_distance_ospf6_intra_inter_external,
518 ospf6_distance_ospf6_intra_inter_external_cmd,
519 "distance ospf6 intra-area <1-255> inter-area <1-255> external <1-255>",
520 "Define an administrative distance\n"
521 "OSPF6 Administrative distance\n"
522 "Intra-area routes\n"
523 "Distance for intra-area routes\n"
524 "Inter-area routes\n"
525 "Distance for inter-area routes\n"
527 "Distance for external routes\n")
531 o = (struct ospf6 *) vty->index;
533 o->distance_intra = atoi (argv[0]);
534 o->distance_inter = atoi (argv[1]);
535 o->distance_external = atoi (argv[2]);
540 DEFUN (ospf6_distance_ospf6_intra_external_inter,
541 ospf6_distance_ospf6_intra_external_inter_cmd,
542 "distance ospf6 intra-area <1-255> external <1-255> inter-area <1-255>",
543 "Define an administrative distance\n"
544 "OSPF6 Administrative distance\n"
545 "Intra-area routes\n"
546 "Distance for intra-area routes\n"
548 "Distance for external routes\n"
549 "Inter-area routes\n"
550 "Distance for inter-area routes\n")
554 o = (struct ospf6 *) vty->index;
556 o->distance_intra = atoi (argv[0]);
557 o->distance_external = atoi (argv[1]);
558 o->distance_inter = atoi (argv[2]);
563 DEFUN (ospf6_distance_ospf6_inter,
564 ospf6_distance_ospf6_inter_cmd,
565 "distance ospf6 inter-area <1-255>",
566 "Define an administrative distance\n"
567 "OSPF6 Administrative distance\n"
568 "Inter-area routes\n"
569 "Distance for inter-area routes\n")
573 o = (struct ospf6 *) vty->index;
575 o->distance_inter = atoi (argv[0]);
580 DEFUN (ospf6_distance_ospf6_inter_intra,
581 ospf6_distance_ospf6_inter_intra_cmd,
582 "distance ospf6 inter-area <1-255> intra-area <1-255>",
583 "Define an administrative distance\n"
584 "OSPF6 Administrative distance\n"
585 "Inter-area routes\n"
586 "Distance for inter-area routes\n"
587 "Intra-area routes\n"
588 "Distance for intra-area routes\n")
592 o = (struct ospf6 *) vty->index;
594 o->distance_inter = atoi (argv[0]);
595 o->distance_intra = atoi (argv[1]);
600 DEFUN (ospf6_distance_ospf6_inter_external,
601 ospf6_distance_ospf6_inter_external_cmd,
602 "distance ospf6 inter-area <1-255> external <1-255>",
603 "Define an administrative distance\n"
604 "OSPF6 Administrative distance\n"
605 "Inter-area routes\n"
606 "Distance for inter-area routes\n"
608 "Distance for external routes\n")
612 o = (struct ospf6 *) vty->index;
614 o->distance_inter = atoi (argv[0]);
615 o->distance_external = atoi (argv[1]);
620 DEFUN (ospf6_distance_ospf6_inter_intra_external,
621 ospf6_distance_ospf6_inter_intra_external_cmd,
622 "distance ospf6 inter-area <1-255> intra-area <1-255> external <1-255>",
623 "Define an administrative distance\n"
624 "OSPF6 Administrative distance\n"
625 "Inter-area routes\n"
626 "Distance for inter-area routes\n"
627 "Intra-area routes\n"
628 "Distance for intra-area routes\n"
630 "Distance for external routes\n")
634 o = (struct ospf6 *) vty->index;
636 o->distance_inter = atoi (argv[0]);
637 o->distance_intra = atoi (argv[1]);
638 o->distance_external = atoi (argv[2]);
643 DEFUN (ospf6_distance_ospf6_inter_external_intra,
644 ospf6_distance_ospf6_inter_external_intra_cmd,
645 "distance ospf6 inter-area <1-255> external <1-255> intra-area <1-255>",
646 "Define an administrative distance\n"
647 "OSPF6 Administrative distance\n"
648 "Inter-area routes\n"
649 "Distance for inter-area routes\n"
651 "Distance for external routes\n"
652 "Intra-area routes\n"
653 "Distance for intra-area routes\n")
657 o = (struct ospf6 *) vty->index;
659 o->distance_inter = atoi (argv[0]);
660 o->distance_external = atoi (argv[1]);
661 o->distance_intra = atoi (argv[2]);
666 DEFUN (ospf6_distance_ospf6_external,
667 ospf6_distance_ospf6_external_cmd,
668 "distance ospf6 external <1-255>",
669 "Define an administrative distance\n"
670 "OSPF6 Administrative distance\n"
672 "Distance for external routes\n")
676 o = (struct ospf6 *) vty->index;
678 o->distance_external = atoi (argv[0]);
683 DEFUN (ospf6_distance_ospf6_external_intra,
684 ospf6_distance_ospf6_external_intra_cmd,
685 "distance ospf6 external <1-255> intra-area <1-255>",
686 "Define an administrative distance\n"
687 "OSPF6 Administrative distance\n"
689 "Distance for external routes\n"
690 "Intra-area routes\n"
691 "Distance for intra-area routes\n")
695 o = (struct ospf6 *) vty->index;
697 o->distance_external = atoi (argv[0]);
698 o->distance_intra = atoi (argv[1]);
703 DEFUN (ospf6_distance_ospf6_external_inter,
704 ospf6_distance_ospf6_external_inter_cmd,
705 "distance ospf6 external <1-255> inter-area <1-255>",
706 "Define an administrative distance\n"
707 "OSPF6 Administrative distance\n"
709 "Distance for external routes\n"
710 "Inter-area routes\n"
711 "Distance for inter-area routes\n")
715 o = (struct ospf6 *) vty->index;
717 o->distance_external = atoi (argv[0]);
718 o->distance_inter = atoi (argv[1]);
723 DEFUN (ospf6_distance_ospf6_external_intra_inter,
724 ospf6_distance_ospf6_external_intra_inter_cmd,
725 "distance ospf6 external <1-255> intra-area <1-255> inter-area <1-255>",
726 "Define an administrative distance\n"
727 "OSPF6 Administrative distance\n"
729 "Distance for external routes\n"
730 "Intra-area routes\n"
731 "Distance for intra-area routes\n"
732 "Inter-area routes\n"
733 "Distance for inter-area routes\n")
737 o = (struct ospf6 *) vty->index;
739 o->distance_external = atoi (argv[0]);
740 o->distance_intra = atoi (argv[1]);
741 o->distance_inter = atoi (argv[2]);
746 DEFUN (ospf6_distance_ospf6_external_inter_intra,
747 ospf6_distance_ospf6_external_inter_intra_cmd,
748 "distance ospf6 external <1-255> inter-area <1-255> intra-area <1-255>",
749 "Define an administrative distance\n"
750 "OSPF6 Administrative distance\n"
752 "Distance for external routes\n"
753 "Inter-area routes\n"
754 "Distance for inter-area routes\n"
755 "Intra-area routes\n"
756 "Distance for intra-area routes\n")
760 o = (struct ospf6 *) vty->index;
762 o->distance_external = atoi (argv[0]);
763 o->distance_inter = atoi (argv[1]);
764 o->distance_intra = atoi (argv[2]);
769 DEFUN (ospf6_distance_source,
770 ospf6_distance_source_cmd,
771 "distance <1-255> X:X::X:X/M",
772 "Administrative distance\n"
774 "IP source prefix\n")
778 o = (struct ospf6 *) vty->index;
780 ospf6_distance_set (vty, o, argv[0], argv[1], NULL);
785 DEFUN (no_ospf6_distance_source,
786 no_ospf6_distance_source_cmd,
787 "no distance <1-255> X:X::X:X/M",
789 "Administrative distance\n"
791 "IP source prefix\n")
795 o = (struct ospf6 *) vty->index;
797 /* XXX: distance arg seems to be irrelevant */
798 ospf6_distance_unset (vty, o, argv[1], NULL);
803 DEFUN (ospf6_distance_source_access_list,
804 ospf6_distance_source_access_list_cmd,
805 "distance <1-255> X:X::X:X/M WORD",
806 "Administrative distance\n"
809 "Access list name\n")
813 o = (struct ospf6 *) vty->index;
815 ospf6_distance_set (vty, o, argv[0], argv[1], argv[2]);
820 DEFUN (no_ospf6_distance_source_access_list,
821 no_ospf6_distance_source_access_list_cmd,
822 "no distance <1-255> X:X::X:X/M WORD",
824 "Administrative distance\n"
827 "Access list name\n")
831 o = (struct ospf6 *) vty->index;
833 ospf6_distance_unset (vty, o, argv[1], argv[2]);
838 DEFUN (ospf6_interface_area,
839 ospf6_interface_area_cmd,
840 "interface IFNAME area A.B.C.D",
841 "Enable routing on an IPv6 interface\n"
843 "Specify the OSPF6 area ID\n"
844 "OSPF6 area ID in IPv4 address notation\n"
848 struct ospf6_area *oa;
849 struct ospf6_interface *oi;
850 struct interface *ifp;
853 o = (struct ospf6 *) vty->index;
855 /* find/create ospf6 interface */
856 ifp = if_get_by_name (argv[0]);
857 oi = (struct ospf6_interface *) ifp->info;
859 oi = ospf6_interface_create (ifp);
862 vty_out (vty, "%s already attached to Area %s%s",
863 oi->interface->name, oi->area->name, VNL);
868 if (inet_pton (AF_INET, argv[1], &area_id) != 1)
870 vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL);
874 /* find/create ospf6 area */
875 oa = ospf6_area_lookup (area_id, o);
877 oa = ospf6_area_create (area_id, o);
879 /* attach interface to area */
880 listnode_add (oa->if_list, oi); /* sort ?? */
883 SET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
885 /* ospf6 process is currently disabled, not much more to do */
886 if (CHECK_FLAG (o->flag, OSPF6_DISABLED))
890 ospf6_interface_enable (oi);
892 /* If the router is ABR, originate summary routes */
893 if (ospf6_is_router_abr (o))
894 ospf6_abr_enable_area (oa);
899 DEFUN (no_ospf6_interface_area,
900 no_ospf6_interface_area_cmd,
901 "no interface IFNAME area A.B.C.D",
903 "Disable routing on an IPv6 interface\n"
905 "Specify the OSPF6 area ID\n"
906 "OSPF6 area ID in IPv4 address notation\n"
909 struct ospf6_interface *oi;
910 struct ospf6_area *oa;
911 struct interface *ifp;
914 ifp = if_lookup_by_name (argv[0]);
917 vty_out (vty, "No such interface %s%s", argv[0], VNL);
921 oi = (struct ospf6_interface *) ifp->info;
924 vty_out (vty, "Interface %s not enabled%s", ifp->name, VNL);
929 if (inet_pton (AF_INET, argv[1], &area_id) != 1)
931 vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL);
936 if (oi->area == NULL)
938 vty_out (vty, "No such Area-ID: %s%s", argv[1], VNL);
942 if (oi->area->area_id != area_id)
944 vty_out (vty, "Wrong Area-ID: %s is attached to area %s%s",
945 oi->interface->name, oi->area->name, VNL);
949 thread_execute (master, interface_down, oi, 0);
952 listnode_delete (oi->area->if_list, oi);
953 oi->area = (struct ospf6_area *) NULL;
955 /* Withdraw inter-area routes from this area, if necessary */
956 if (oa->if_list->count == 0)
958 UNSET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
959 ospf6_abr_disable_area (oa);
965 DEFUN (ospf6_stub_router_admin,
966 ospf6_stub_router_admin_cmd,
967 "stub-router administrative",
968 "Make router a stub router\n"
969 "Advertise inability to be a transit router\n"
970 "Administratively applied, for an indefinite period\n")
972 struct listnode *node;
973 struct ospf6_area *oa;
975 if (!CHECK_FLAG (ospf6->flag, OSPF6_STUB_ROUTER))
977 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
979 OSPF6_OPT_CLEAR (oa->options, OSPF6_OPT_V6);
980 OSPF6_OPT_CLEAR (oa->options, OSPF6_OPT_R);
981 OSPF6_ROUTER_LSA_SCHEDULE (oa);
983 SET_FLAG (ospf6->flag, OSPF6_STUB_ROUTER);
989 DEFUN (no_ospf6_stub_router_admin,
990 no_ospf6_stub_router_admin_cmd,
991 "no stub-router administrative",
993 "Make router a stub router\n"
994 "Advertise ability to be a transit router\n"
995 "Administratively applied, for an indefinite period\n")
997 struct listnode *node;
998 struct ospf6_area *oa;
1000 if (CHECK_FLAG (ospf6->flag, OSPF6_STUB_ROUTER))
1002 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
1004 OSPF6_OPT_SET (oa->options, OSPF6_OPT_V6);
1005 OSPF6_OPT_SET (oa->options, OSPF6_OPT_R);
1006 OSPF6_ROUTER_LSA_SCHEDULE (oa);
1008 UNSET_FLAG (ospf6->flag, OSPF6_STUB_ROUTER);
1014 DEFUN (ospf6_stub_router_startup,
1015 ospf6_stub_router_startup_cmd,
1016 "stub-router on-startup <5-86400>",
1017 "Make router a stub router\n"
1018 "Advertise inability to be a transit router\n"
1019 "Automatically advertise as stub-router on startup of OSPF6\n"
1020 "Time (seconds) to advertise self as stub-router\n")
1025 DEFUN (no_ospf6_stub_router_startup,
1026 no_ospf6_stub_router_startup_cmd,
1027 "no stub-router on-startup",
1029 "Make router a stub router\n"
1030 "Advertise inability to be a transit router\n"
1031 "Automatically advertise as stub-router on startup of OSPF6\n"
1032 "Time (seconds) to advertise self as stub-router\n")
1037 DEFUN (ospf6_stub_router_shutdown,
1038 ospf6_stub_router_shutdown_cmd,
1039 "stub-router on-shutdown <5-86400>",
1040 "Make router a stub router\n"
1041 "Advertise inability to be a transit router\n"
1042 "Automatically advertise as stub-router before shutdown\n"
1043 "Time (seconds) to advertise self as stub-router\n")
1048 DEFUN (no_ospf6_stub_router_shutdown,
1049 no_ospf6_stub_router_shutdown_cmd,
1050 "no stub-router on-shutdown",
1052 "Make router a stub router\n"
1053 "Advertise inability to be a transit router\n"
1054 "Automatically advertise as stub-router before shutdown\n"
1055 "Time (seconds) to advertise self as stub-router\n")
1061 ospf6_show (struct vty *vty, struct ospf6 *o)
1064 struct ospf6_area *oa;
1065 char router_id[16], duration[32];
1066 struct timeval now, running, result;
1067 char buf[32], rbuf[32];
1069 /* process id, router id */
1070 inet_ntop (AF_INET, &o->router_id, router_id, sizeof (router_id));
1071 vty_out (vty, " OSPFv3 Routing Process (0) with Router-ID %s%s",
1075 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
1076 timersub (&now, &o->starttime, &running);
1077 timerstring (&running, duration, sizeof (duration));
1078 vty_out (vty, " Running %s%s", duration, VNL);
1080 /* Redistribute configuration */
1083 /* Show SPF parameters */
1084 vty_out(vty, " Initial SPF scheduling delay %d millisec(s)%s"
1085 " Minimum hold time between consecutive SPFs %d millsecond(s)%s"
1086 " Maximum hold time between consecutive SPFs %d millsecond(s)%s"
1087 " Hold time multiplier is currently %d%s",
1089 o->spf_holdtime, VNL,
1090 o->spf_max_holdtime, VNL,
1091 o->spf_hold_multiplier, VNL);
1093 vty_out(vty, " SPF algorithm ");
1094 if (o->ts_spf.tv_sec || o->ts_spf.tv_usec)
1096 timersub(&now, &o->ts_spf, &result);
1097 timerstring(&result, buf, sizeof(buf));
1098 ospf6_spf_reason_string(o->last_spf_reason, rbuf, sizeof(rbuf));
1099 vty_out(vty, "last executed %s ago, reason %s%s", buf, rbuf, VNL);
1100 vty_out (vty, " Last SPF duration %lld sec %lld usec%s",
1101 (long long)o->ts_spf_duration.tv_sec,
1102 (long long)o->ts_spf_duration.tv_usec, VNL);
1105 vty_out(vty, "has not been run$%s", VNL);
1106 threadtimer_string(now, o->t_spf_calc, buf, sizeof(buf));
1107 vty_out (vty, " SPF timer %s%s%s",
1108 (o->t_spf_calc ? "due in " : "is "), buf, VNL);
1110 if (CHECK_FLAG (o->flag, OSPF6_STUB_ROUTER))
1111 vty_out (vty, " Router Is Stub Router%s", VNL);
1114 vty_out (vty, " Number of AS scoped LSAs is %u%s",
1115 o->lsdb->count, VNL);
1118 vty_out (vty, " Number of areas in this router is %u%s",
1119 listcount (o->area_list), VNL);
1121 if (CHECK_FLAG(o->config_flags, OSPF6_LOG_ADJACENCY_CHANGES))
1123 if (CHECK_FLAG(o->config_flags, OSPF6_LOG_ADJACENCY_DETAIL))
1124 vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE);
1126 vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE);
1129 vty_out (vty, "%s",VTY_NEWLINE);
1131 for (ALL_LIST_ELEMENTS_RO (o->area_list, n, oa))
1132 ospf6_area_show (vty, oa);
1135 /* show top level structures */
1136 DEFUN (show_ipv6_ospf6,
1137 show_ipv6_ospf6_cmd,
1143 OSPF6_CMD_CHECK_RUNNING ();
1145 ospf6_show (vty, ospf6);
1149 DEFUN (show_ipv6_ospf6_route,
1150 show_ipv6_ospf6_route_cmd,
1151 "show ipv6 ospf6 route",
1158 OSPF6_CMD_CHECK_RUNNING ();
1160 ospf6_route_table_show (vty, argc, argv, ospf6->route_table);
1164 ALIAS (show_ipv6_ospf6_route,
1165 show_ipv6_ospf6_route_detail_cmd,
1166 "show ipv6 ospf6 route (X:X::X:X|X:X::X:X/M|detail|summary)",
1171 "Specify IPv6 address\n"
1172 "Specify IPv6 prefix\n"
1173 "Detailed information\n"
1174 "Summary of route table\n"
1177 DEFUN (show_ipv6_ospf6_route_match,
1178 show_ipv6_ospf6_route_match_cmd,
1179 "show ipv6 ospf6 route X:X::X:X/M match",
1184 "Specify IPv6 prefix\n"
1185 "Display routes which match the specified route\n"
1188 const char *sargv[CMD_ARGC_MAX];
1191 OSPF6_CMD_CHECK_RUNNING ();
1193 /* copy argv to sargv and then append "match" */
1194 for (i = 0; i < argc; i++)
1197 sargv[sargc++] = "match";
1198 sargv[sargc] = NULL;
1200 ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
1204 DEFUN (show_ipv6_ospf6_route_match_detail,
1205 show_ipv6_ospf6_route_match_detail_cmd,
1206 "show ipv6 ospf6 route X:X::X:X/M match detail",
1211 "Specify IPv6 prefix\n"
1212 "Display routes which match the specified route\n"
1213 "Detailed information\n"
1216 const char *sargv[CMD_ARGC_MAX];
1219 /* copy argv to sargv and then append "match" and "detail" */
1220 for (i = 0; i < argc; i++)
1223 sargv[sargc++] = "match";
1224 sargv[sargc++] = "detail";
1225 sargv[sargc] = NULL;
1227 OSPF6_CMD_CHECK_RUNNING ();
1229 ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
1233 ALIAS (show_ipv6_ospf6_route_match,
1234 show_ipv6_ospf6_route_longer_cmd,
1235 "show ipv6 ospf6 route X:X::X:X/M longer",
1240 "Specify IPv6 prefix\n"
1241 "Display routes longer than the specified route\n"
1244 DEFUN (show_ipv6_ospf6_route_match_detail,
1245 show_ipv6_ospf6_route_longer_detail_cmd,
1246 "show ipv6 ospf6 route X:X::X:X/M longer detail",
1251 "Specify IPv6 prefix\n"
1252 "Display routes longer than the specified route\n"
1253 "Detailed information\n"
1256 ALIAS (show_ipv6_ospf6_route,
1257 show_ipv6_ospf6_route_type_cmd,
1258 "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2)",
1263 "Display Intra-Area routes\n"
1264 "Display Inter-Area routes\n"
1265 "Display Type-1 External routes\n"
1266 "Display Type-2 External routes\n"
1269 DEFUN (show_ipv6_ospf6_route_type_detail,
1270 show_ipv6_ospf6_route_type_detail_cmd,
1271 "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2) detail",
1276 "Display Intra-Area routes\n"
1277 "Display Inter-Area routes\n"
1278 "Display Type-1 External routes\n"
1279 "Display Type-2 External routes\n"
1280 "Detailed information\n"
1283 const char *sargv[CMD_ARGC_MAX];
1286 /* copy argv to sargv and then append "detail" */
1287 for (i = 0; i < argc; i++)
1290 sargv[sargc++] = "detail";
1291 sargv[sargc] = NULL;
1293 OSPF6_CMD_CHECK_RUNNING ();
1295 ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
1300 ospf6_stub_router_config_write (struct vty *vty)
1302 if (CHECK_FLAG (ospf6->flag, OSPF6_STUB_ROUTER))
1304 vty_out (vty, " stub-router administrative%s", VNL);
1310 ospf6_distance_config_write (struct vty *vty)
1312 struct route_node *rn;
1313 struct ospf6_distance *odistance;
1315 if (ospf6->distance_all)
1316 vty_out (vty, " distance %d%s", ospf6->distance_all, VTY_NEWLINE);
1318 if (ospf6->distance_intra
1319 || ospf6->distance_inter
1320 || ospf6->distance_external)
1322 vty_out (vty, " distance ospf6");
1324 if (ospf6->distance_intra)
1325 vty_out (vty, " intra-area %d", ospf6->distance_intra);
1326 if (ospf6->distance_inter)
1327 vty_out (vty, " inter-area %d", ospf6->distance_inter);
1328 if (ospf6->distance_external)
1329 vty_out (vty, " external %d", ospf6->distance_external);
1331 vty_out (vty, "%s", VTY_NEWLINE);
1334 for (rn = route_top (ospf6->distance_table); rn; rn = route_next (rn))
1335 if ((odistance = rn->info) != NULL)
1338 vty_out (vty, " distance %d %s %s%s", odistance->distance,
1339 prefix2str (&rn->p, pstr, sizeof(pstr)),
1340 odistance->access_list ? odistance->access_list : "",
1346 /* OSPF configuration write function. */
1348 config_write_ospf6 (struct vty *vty)
1351 struct listnode *j, *k;
1352 struct ospf6_area *oa;
1353 struct ospf6_interface *oi;
1355 /* OSPFv6 configuration. */
1359 inet_ntop (AF_INET, &ospf6->router_id_static, router_id, sizeof (router_id));
1360 vty_out (vty, "router ospf6%s", VNL);
1361 if (ospf6->router_id_static != 0)
1362 vty_out (vty, " router-id %s%s", router_id, VNL);
1364 /* log-adjacency-changes flag print. */
1365 if (CHECK_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES))
1367 vty_out(vty, " log-adjacency-changes");
1368 if (CHECK_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL))
1369 vty_out(vty, " detail");
1370 vty_out(vty, "%s", VTY_NEWLINE);
1373 if (ospf6->ref_bandwidth != OSPF6_REFERENCE_BANDWIDTH)
1374 vty_out (vty, " auto-cost reference-bandwidth %d%s", ospf6->ref_bandwidth / 1000,
1377 ospf6_stub_router_config_write (vty);
1378 ospf6_redistribute_config_write (vty);
1379 ospf6_area_config_write (vty);
1380 ospf6_spf_config_write (vty);
1381 ospf6_distance_config_write (vty);
1383 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, j, oa))
1385 for (ALL_LIST_ELEMENTS_RO (oa->if_list, k, oi))
1386 vty_out (vty, " interface %s area %s%s",
1387 oi->interface->name, oa->name, VNL);
1389 vty_out (vty, "!%s", VNL);
1393 /* OSPF6 node structure. */
1394 static struct cmd_node ospf6_node =
1397 "%s(config-ospf6)# ",
1401 /* Install ospf related commands. */
1403 ospf6_top_init (void)
1405 /* Install ospf6 top node. */
1406 install_node (&ospf6_node, config_write_ospf6);
1408 install_element (VIEW_NODE, &show_ipv6_ospf6_cmd);
1409 install_element (CONFIG_NODE, &router_ospf6_cmd);
1410 install_element (CONFIG_NODE, &no_router_ospf6_cmd);
1412 install_element (VIEW_NODE, &show_ipv6_ospf6_route_cmd);
1413 install_element (VIEW_NODE, &show_ipv6_ospf6_route_detail_cmd);
1414 install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_cmd);
1415 install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_detail_cmd);
1416 install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_cmd);
1417 install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_detail_cmd);
1418 install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_cmd);
1419 install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_detail_cmd);
1421 install_default (OSPF6_NODE);
1422 install_element (OSPF6_NODE, &ospf6_router_id_cmd);
1423 install_element (OSPF6_NODE, &ospf6_log_adjacency_changes_cmd);
1424 install_element (OSPF6_NODE, &ospf6_log_adjacency_changes_detail_cmd);
1425 install_element (OSPF6_NODE, &no_ospf6_log_adjacency_changes_cmd);
1426 install_element (OSPF6_NODE, &no_ospf6_log_adjacency_changes_detail_cmd);
1427 install_element (OSPF6_NODE, &ospf6_interface_area_cmd);
1428 install_element (OSPF6_NODE, &no_ospf6_interface_area_cmd);
1429 install_element (OSPF6_NODE, &ospf6_stub_router_admin_cmd);
1430 install_element (OSPF6_NODE, &no_ospf6_stub_router_admin_cmd);
1432 install_element (OSPF6_NODE, &ospf6_stub_router_startup_cmd);
1433 install_element (OSPF6_NODE, &no_ospf6_stub_router_startup_cmd);
1434 install_element (OSPF6_NODE, &ospf6_stub_router_shutdown_cmd);
1435 install_element (OSPF6_NODE, &no_ospf6_stub_router_shutdown_cmd);
1438 install_element (OSPF6_NODE, &ospf6_distance_cmd);
1439 install_element (OSPF6_NODE, &no_ospf6_distance_cmd);
1440 install_element (OSPF6_NODE, &no_ospf6_distance_ospf6_cmd);
1441 install_element (OSPF6_NODE, &ospf6_distance_ospf6_intra_cmd);
1442 install_element (OSPF6_NODE, &ospf6_distance_ospf6_intra_inter_cmd);
1443 install_element (OSPF6_NODE, &ospf6_distance_ospf6_intra_external_cmd);
1444 install_element (OSPF6_NODE, &ospf6_distance_ospf6_intra_inter_external_cmd);
1445 install_element (OSPF6_NODE, &ospf6_distance_ospf6_intra_external_inter_cmd);
1446 install_element (OSPF6_NODE, &ospf6_distance_ospf6_inter_cmd);
1447 install_element (OSPF6_NODE, &ospf6_distance_ospf6_inter_intra_cmd);
1448 install_element (OSPF6_NODE, &ospf6_distance_ospf6_inter_external_cmd);
1449 install_element (OSPF6_NODE, &ospf6_distance_ospf6_inter_intra_external_cmd);
1450 install_element (OSPF6_NODE, &ospf6_distance_ospf6_inter_external_intra_cmd);
1451 install_element (OSPF6_NODE, &ospf6_distance_ospf6_external_cmd);
1452 install_element (OSPF6_NODE, &ospf6_distance_ospf6_external_intra_cmd);
1453 install_element (OSPF6_NODE, &ospf6_distance_ospf6_external_inter_cmd);
1454 install_element (OSPF6_NODE, &ospf6_distance_ospf6_external_intra_inter_cmd);
1455 install_element (OSPF6_NODE, &ospf6_distance_ospf6_external_inter_intra_cmd);
1457 install_element (OSPF6_NODE, &ospf6_distance_source_cmd);
1458 install_element (OSPF6_NODE, &no_ospf6_distance_source_cmd);
1459 install_element (OSPF6_NODE, &ospf6_distance_source_access_list_cmd);
1460 install_element (OSPF6_NODE, &no_ospf6_distance_source_access_list_cmd);