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 route
->flag
|= OSPF6_ROUTE_REMOVE
;
96 ospf6_abr_originate_summary (route
);
97 ospf6_zebra_route_update_remove (route
);
101 ospf6_top_brouter_hook_add (struct ospf6_route
*route
)
103 ospf6_abr_examin_brouter (ADV_ROUTER_IN_PREFIX (&route
->prefix
));
104 ospf6_asbr_lsentry_add (route
);
105 ospf6_abr_originate_summary (route
);
109 ospf6_top_brouter_hook_remove (struct ospf6_route
*route
)
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
);
117 static struct ospf6
*
122 o
= XCALLOC (MTYPE_OSPF6_TOP
, sizeof (struct ospf6
));
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
;
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;
138 /* LSA timers value init */
139 o
->lsa_minarrival
= OSPF_MIN_LS_ARRIVAL
;
141 o
->route_table
= OSPF6_ROUTE_TABLE_CREATE (GLOBAL
, ROUTES
);
142 o
->route_table
->scope
= o
;
143 o
->route_table
->hook_add
= ospf6_top_route_hook_add
;
144 o
->route_table
->hook_remove
= ospf6_top_route_hook_remove
;
146 o
->brouter_table
= OSPF6_ROUTE_TABLE_CREATE (GLOBAL
, BORDER_ROUTERS
);
147 o
->brouter_table
->scope
= o
;
148 o
->brouter_table
->hook_add
= ospf6_top_brouter_hook_add
;
149 o
->brouter_table
->hook_remove
= ospf6_top_brouter_hook_remove
;
151 o
->external_table
= OSPF6_ROUTE_TABLE_CREATE (GLOBAL
, EXTERNAL_ROUTES
);
152 o
->external_table
->scope
= o
;
154 o
->external_id_table
= route_table_init ();
156 o
->ref_bandwidth
= OSPF6_REFERENCE_BANDWIDTH
;
158 o
->distance_table
= route_table_init ();
160 /* Enable "log-adjacency-changes" */
161 SET_FLAG(o
->config_flags
, OSPF6_LOG_ADJACENCY_CHANGES
);
167 ospf6_delete (struct ospf6
*o
)
169 struct listnode
*node
, *nnode
;
170 struct ospf6_area
*oa
;
172 ospf6_disable (ospf6
);
174 for (ALL_LIST_ELEMENTS (o
->area_list
, node
, nnode
, oa
))
175 ospf6_area_delete (oa
);
178 list_delete (o
->area_list
);
180 ospf6_lsdb_delete (o
->lsdb
);
181 ospf6_lsdb_delete (o
->lsdb_self
);
183 ospf6_route_table_delete (o
->route_table
);
184 ospf6_route_table_delete (o
->brouter_table
);
186 ospf6_route_table_delete (o
->external_table
);
187 route_table_finish (o
->external_id_table
);
189 ospf6_distance_reset (o
);
190 route_table_finish (o
->distance_table
);
192 XFREE (MTYPE_OSPF6_TOP
, o
);
196 ospf6_disable (struct ospf6
*o
)
198 struct listnode
*node
, *nnode
;
199 struct ospf6_area
*oa
;
201 if (! CHECK_FLAG (o
->flag
, OSPF6_DISABLED
))
203 SET_FLAG (o
->flag
, OSPF6_DISABLED
);
205 for (ALL_LIST_ELEMENTS (o
->area_list
, node
, nnode
, oa
))
206 ospf6_area_disable (oa
);
208 /* XXX: This also changes persistent settings */
209 ospf6_asbr_redistribute_reset();
211 ospf6_lsdb_remove_all (o
->lsdb
);
212 ospf6_route_remove_all (o
->route_table
);
213 ospf6_route_remove_all (o
->brouter_table
);
215 THREAD_OFF(o
->maxage_remover
);
216 THREAD_OFF(o
->t_spf_calc
);
217 THREAD_OFF(o
->t_ase_calc
);
222 ospf6_maxage_remover (struct thread
*thread
)
224 struct ospf6
*o
= (struct ospf6
*) THREAD_ARG (thread
);
225 struct ospf6_area
*oa
;
226 struct ospf6_interface
*oi
;
227 struct ospf6_neighbor
*on
;
228 struct listnode
*i
, *j
, *k
;
231 o
->maxage_remover
= (struct thread
*) NULL
;
233 for (ALL_LIST_ELEMENTS_RO (o
->area_list
, i
, oa
))
235 for (ALL_LIST_ELEMENTS_RO (oa
->if_list
, j
, oi
))
237 for (ALL_LIST_ELEMENTS_RO (oi
->neighbor_list
, k
, on
))
239 if (on
->state
!= OSPF6_NEIGHBOR_EXCHANGE
&&
240 on
->state
!= OSPF6_NEIGHBOR_LOADING
)
243 ospf6_maxage_remove (o
);
249 for (ALL_LIST_ELEMENTS_RO (o
->area_list
, i
, oa
))
251 for (ALL_LIST_ELEMENTS_RO (oa
->if_list
, j
, oi
))
253 if (ospf6_lsdb_maxage_remover (oi
->lsdb
))
259 if (ospf6_lsdb_maxage_remover (oa
->lsdb
))
265 if (ospf6_lsdb_maxage_remover (o
->lsdb
))
272 ospf6_maxage_remove (o
);
279 ospf6_maxage_remove (struct ospf6
*o
)
281 if (o
&& ! o
->maxage_remover
)
282 o
->maxage_remover
= thread_add_timer (master
, ospf6_maxage_remover
, o
,
283 OSPF_LSA_MAXAGE_REMOVE_DELAY_DEFAULT
);
294 ospf6
= ospf6_create ();
296 /* set current ospf point. */
297 vty
->node
= OSPF6_NODE
;
304 DEFUN (no_router_ospf6
,
311 /* return to config node . */
312 vty
->node
= CONFIG_NODE
;
318 /* change Router_ID commands. */
319 DEFUN (ospf6_router_id
,
322 "Configure OSPF Router-ID\n"
330 o
= (struct ospf6
*) vty
->index
;
332 ret
= inet_pton (AF_INET
, argv
[idx_ipv4
]->arg
, &router_id
);
335 vty_out (vty
, "malformed OSPF Router-ID: %s%s", argv
[idx_ipv4
]->arg
, VNL
);
339 o
->router_id_static
= router_id
;
340 if (o
->router_id
== 0)
341 o
->router_id
= router_id
;
346 DEFUN (ospf6_log_adjacency_changes
,
347 ospf6_log_adjacency_changes_cmd
,
348 "log-adjacency-changes",
349 "Log changes in adjacency state\n")
351 struct ospf6
*ospf6
= vty
->index
;
353 SET_FLAG(ospf6
->config_flags
, OSPF6_LOG_ADJACENCY_CHANGES
);
354 UNSET_FLAG(ospf6
->config_flags
, OSPF6_LOG_ADJACENCY_DETAIL
);
358 DEFUN (ospf6_log_adjacency_changes_detail
,
359 ospf6_log_adjacency_changes_detail_cmd
,
360 "log-adjacency-changes detail",
361 "Log changes in adjacency state\n"
362 "Log all state changes\n")
364 struct ospf6
*ospf6
= vty
->index
;
366 SET_FLAG(ospf6
->config_flags
, OSPF6_LOG_ADJACENCY_CHANGES
);
367 SET_FLAG(ospf6
->config_flags
, OSPF6_LOG_ADJACENCY_DETAIL
);
371 DEFUN (no_ospf6_log_adjacency_changes
,
372 no_ospf6_log_adjacency_changes_cmd
,
373 "no log-adjacency-changes",
375 "Log changes in adjacency state\n")
377 struct ospf6
*ospf6
= vty
->index
;
379 UNSET_FLAG(ospf6
->config_flags
, OSPF6_LOG_ADJACENCY_DETAIL
);
380 UNSET_FLAG(ospf6
->config_flags
, OSPF6_LOG_ADJACENCY_CHANGES
);
384 DEFUN (no_ospf6_log_adjacency_changes_detail
,
385 no_ospf6_log_adjacency_changes_detail_cmd
,
386 "no log-adjacency-changes detail",
388 "Log changes in adjacency state\n"
389 "Log all state changes\n")
391 struct ospf6
*ospf6
= vty
->index
;
393 UNSET_FLAG(ospf6
->config_flags
, OSPF6_LOG_ADJACENCY_DETAIL
);
394 UNSET_FLAG(ospf6
->config_flags
, OSPF6_LOG_ADJACENCY_CHANGES
);
398 DEFUN (ospf6_timers_lsa
,
399 ospf6_timers_lsa_cmd
,
400 "timers lsa min-arrival (0-600000)",
401 "Adjust routing timers\n"
403 "Minimum delay in receiving new version of a LSA\n"
404 "Delay in milliseconds\n")
407 unsigned int minarrival
;
408 struct ospf6
*ospf
= vty
->index
;
413 VTY_GET_INTEGER ("LSA min-arrival", minarrival
, argv
[idx_number
]->arg
);
414 ospf
->lsa_minarrival
= minarrival
;
419 DEFUN (no_ospf6_timers_lsa
,
420 no_ospf6_timers_lsa_cmd
,
421 "no timers lsa min-arrival [(0-600000)]",
423 "Adjust routing timers\n"
425 "Minimum delay in receiving new version of a LSA\n"
426 "Delay in milliseconds\n")
429 unsigned int minarrival
;
430 struct ospf6
*ospf
= vty
->index
;
437 VTY_GET_INTEGER ("LSA min-arrival", minarrival
, argv
[idx_number
]->arg
);
439 if (ospf
->lsa_minarrival
!= minarrival
||
440 minarrival
== OSPF_MIN_LS_ARRIVAL
)
444 ospf
->lsa_minarrival
= OSPF_MIN_LS_ARRIVAL
;
450 DEFUN (ospf6_distance
,
453 "Administrative distance\n"
454 "OSPF6 Administrative distance\n")
456 struct ospf6
*o
= vty
->index
;
458 o
->distance_all
= atoi (argv
[1]->arg
);
463 DEFUN (no_ospf6_distance
,
464 no_ospf6_distance_cmd
,
465 "no distance (1-255)",
467 "Administrative distance\n"
468 "OSPF6 Administrative distance\n")
470 struct ospf6
*o
= vty
->index
;
477 DEFUN (ospf6_distance_ospf6
,
478 ospf6_distance_ospf6_cmd
,
479 "distance ospf6 <intra-area (1-255)|inter-area (1-255)|external (1-255)> <intra-area (1-255)|inter-area (1-255)|external (1-255)> <intra-area (1-255)|inter-area (1-255)|external (1-255)>",
480 "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"
487 "Distance for external routes\n"
488 "Intra-area routes\n"
489 "Distance for intra-area routes\n"
490 "Inter-area routes\n"
491 "Distance for inter-area routes\n"
493 "Distance for external routes\n"
494 "Intra-area routes\n"
495 "Distance for intra-area routes\n"
496 "Inter-area routes\n"
497 "Distance for inter-area routes\n"
499 "Distance for external routes\n")
501 struct ospf6
*o
= vty
->index
;
503 char *intra
, *inter
, *external
;
504 intra
= inter
= external
= NULL
;
507 if (argv_find (argv
, argc
, "intra-area", &idx
))
508 intra
= argv
[++idx
]->arg
;
509 if (argv_find (argv
, argc
, "intra-area", &idx
))
511 vty_out (vty
, "%% Cannot specify intra-area distance twice%s", VTY_NEWLINE
);
516 if (argv_find (argv
, argc
, "inter-area", &idx
))
517 inter
= argv
[++idx
]->arg
;
518 if (argv_find (argv
, argc
, "inter-area", &idx
))
520 vty_out (vty
, "%% Cannot specify inter-area distance twice%s", VTY_NEWLINE
);
525 if (argv_find (argv
, argc
, "external", &idx
))
526 external
= argv
[++idx
]->arg
;
527 if (argv_find (argv
, argc
, "external", &idx
))
529 vty_out (vty
, "%% Cannot specify external distance twice%s", VTY_NEWLINE
);
535 o
->distance_intra
= atoi (intra
);
538 o
->distance_inter
= atoi (inter
);
541 o
->distance_external
= atoi (external
);
546 DEFUN (no_ospf6_distance_ospf6
,
547 no_ospf6_distance_ospf6_cmd
,
548 "no distance ospf6 [<intra-area (1-255)|inter-area (1-255)|external (1-255)> <intra-area (1-255)|inter-area (1-255)|external (1-255)> <intra-area (1-255)|inter-area (1-255)|external (1-255)>]",
550 "Administrative distance\n"
552 "Intra-area routes\n"
553 "Distance for intra-area routes\n"
554 "Inter-area routes\n"
555 "Distance for inter-area routes\n"
557 "Distance for external routes\n"
558 "Intra-area routes\n"
559 "Distance for intra-area routes\n"
560 "Inter-area routes\n"
561 "Distance for inter-area routes\n"
563 "Distance for external routes\n"
564 "Intra-area routes\n"
565 "Distance for intra-area routes\n"
566 "Inter-area routes\n"
567 "Distance for inter-area routes\n"
569 "Distance for external routes\n")
571 struct ospf6
*o
= vty
->index
;
573 char *intra
, *inter
, *external
;
574 intra
= inter
= external
= NULL
;
578 /* If no arguments are given, clear all distance information */
579 o
->distance_intra
= 0;
580 o
->distance_inter
= 0;
581 o
->distance_external
= 0;
586 if (argv_find (argv
, argc
, "intra-area", &idx
))
587 intra
= argv
[++idx
]->arg
;
588 if (argv_find (argv
, argc
, "intra-area", &idx
))
590 vty_out (vty
, "%% Cannot specify intra-area distance twice%s", VTY_NEWLINE
);
595 if (argv_find (argv
, argc
, "inter-area", &idx
))
596 inter
= argv
[++idx
]->arg
;
597 if (argv_find (argv
, argc
, "inter-area", &idx
))
599 vty_out (vty
, "%% Cannot specify inter-area distance twice%s", VTY_NEWLINE
);
604 if (argv_find (argv
, argc
, "external", &idx
))
605 external
= argv
[++idx
]->arg
;
606 if (argv_find (argv
, argc
, "external", &idx
))
608 vty_out (vty
, "%% Cannot specify external distance twice%s", VTY_NEWLINE
);
611 if (argc
< 3) /* should not happen */
615 o
->distance_intra
= 0;
618 o
->distance_inter
= 0;
621 o
->distance_external
= 0;
627 DEFUN (ospf6_distance_source
,
628 ospf6_distance_source_cmd
,
629 "distance (1-255) X:X::X:X/M [WORD]",
630 "Administrative distance\n"
633 "Access list name\n")
635 struct ospf6
*o
= vty
->index
;
636 char *alname
= (argc
== 4) ? argv
[3]->arg
: NULL
;
637 ospf6_distance_set (vty
, o
, argv
[1]->arg
, argv
[2]->arg
, alname
);
642 DEFUN (no_ospf6_distance_source
,
643 no_ospf6_distance_source_cmd
,
644 "no distance (1-255) X:X::X:X/M [WORD]",
646 "Administrative distance\n"
649 "Access list name\n")
651 struct ospf6
*o
= vty
->index
;
652 char *alname
= (argc
== 5) ? argv
[4]->arg
: NULL
;
653 ospf6_distance_unset (vty
, o
, argv
[2]->arg
, argv
[3]->arg
, alname
);
659 DEFUN (ospf6_interface_area
,
660 ospf6_interface_area_cmd
,
661 "interface IFNAME area A.B.C.D",
662 "Enable routing on an IPv6 interface\n"
664 "Specify the OSPF6 area ID\n"
665 "OSPF6 area ID in IPv4 address notation\n"
671 struct ospf6_area
*oa
;
672 struct ospf6_interface
*oi
;
673 struct interface
*ifp
;
676 o
= (struct ospf6
*) vty
->index
;
678 /* find/create ospf6 interface */
679 ifp
= if_get_by_name (argv
[idx_ifname
]->arg
);
680 oi
= (struct ospf6_interface
*) ifp
->info
;
682 oi
= ospf6_interface_create (ifp
);
685 vty_out (vty
, "%s already attached to Area %s%s",
686 oi
->interface
->name
, oi
->area
->name
, VNL
);
691 if (inet_pton (AF_INET
, argv
[idx_ipv4
]->arg
, &area_id
) != 1)
693 vty_out (vty
, "Invalid Area-ID: %s%s", argv
[idx_ipv4
]->arg
, VNL
);
697 /* find/create ospf6 area */
698 oa
= ospf6_area_lookup (area_id
, o
);
700 oa
= ospf6_area_create (area_id
, o
);
702 /* attach interface to area */
703 listnode_add (oa
->if_list
, oi
); /* sort ?? */
706 SET_FLAG (oa
->flag
, OSPF6_AREA_ENABLE
);
708 /* ospf6 process is currently disabled, not much more to do */
709 if (CHECK_FLAG (o
->flag
, OSPF6_DISABLED
))
713 ospf6_interface_enable (oi
);
715 /* If the router is ABR, originate summary routes */
716 if (ospf6_is_router_abr (o
))
717 ospf6_abr_enable_area (oa
);
722 DEFUN (no_ospf6_interface_area
,
723 no_ospf6_interface_area_cmd
,
724 "no interface IFNAME area A.B.C.D",
726 "Disable routing on an IPv6 interface\n"
728 "Specify the OSPF6 area ID\n"
729 "OSPF6 area ID in IPv4 address notation\n"
734 struct ospf6_interface
*oi
;
735 struct ospf6_area
*oa
;
736 struct interface
*ifp
;
739 ifp
= if_lookup_by_name (argv
[idx_ifname
]->arg
);
742 vty_out (vty
, "No such interface %s%s", argv
[idx_ifname
]->arg
, VNL
);
746 oi
= (struct ospf6_interface
*) ifp
->info
;
749 vty_out (vty
, "Interface %s not enabled%s", ifp
->name
, VNL
);
754 if (inet_pton (AF_INET
, argv
[idx_ipv4
]->arg
, &area_id
) != 1)
756 vty_out (vty
, "Invalid Area-ID: %s%s", argv
[idx_ipv4
]->arg
, VNL
);
761 if (oi
->area
== NULL
)
763 vty_out (vty
, "No such Area-ID: %s%s", argv
[idx_ipv4
]->arg
, VNL
);
767 if (oi
->area
->area_id
!= area_id
)
769 vty_out (vty
, "Wrong Area-ID: %s is attached to area %s%s",
770 oi
->interface
->name
, oi
->area
->name
, VNL
);
774 thread_execute (master
, interface_down
, oi
, 0);
777 listnode_delete (oi
->area
->if_list
, oi
);
778 oi
->area
= (struct ospf6_area
*) NULL
;
780 /* Withdraw inter-area routes from this area, if necessary */
781 if (oa
->if_list
->count
== 0)
783 UNSET_FLAG (oa
->flag
, OSPF6_AREA_ENABLE
);
784 ospf6_abr_disable_area (oa
);
790 DEFUN (ospf6_stub_router_admin
,
791 ospf6_stub_router_admin_cmd
,
792 "stub-router administrative",
793 "Make router a stub router\n"
794 "Advertise inability to be a transit router\n"
795 "Administratively applied, for an indefinite period\n")
797 struct listnode
*node
;
798 struct ospf6_area
*oa
;
800 if (!CHECK_FLAG (ospf6
->flag
, OSPF6_STUB_ROUTER
))
802 for (ALL_LIST_ELEMENTS_RO (ospf6
->area_list
, node
, oa
))
804 OSPF6_OPT_CLEAR (oa
->options
, OSPF6_OPT_V6
);
805 OSPF6_OPT_CLEAR (oa
->options
, OSPF6_OPT_R
);
806 OSPF6_ROUTER_LSA_SCHEDULE (oa
);
808 SET_FLAG (ospf6
->flag
, OSPF6_STUB_ROUTER
);
814 DEFUN (no_ospf6_stub_router_admin
,
815 no_ospf6_stub_router_admin_cmd
,
816 "no stub-router administrative",
818 "Make router a stub router\n"
819 "Advertise ability to be a transit router\n"
820 "Administratively applied, for an indefinite period\n")
822 struct listnode
*node
;
823 struct ospf6_area
*oa
;
825 if (CHECK_FLAG (ospf6
->flag
, OSPF6_STUB_ROUTER
))
827 for (ALL_LIST_ELEMENTS_RO (ospf6
->area_list
, node
, oa
))
829 OSPF6_OPT_SET (oa
->options
, OSPF6_OPT_V6
);
830 OSPF6_OPT_SET (oa
->options
, OSPF6_OPT_R
);
831 OSPF6_ROUTER_LSA_SCHEDULE (oa
);
833 UNSET_FLAG (ospf6
->flag
, OSPF6_STUB_ROUTER
);
840 DEFUN (ospf6_stub_router_startup
,
841 ospf6_stub_router_startup_cmd
,
842 "stub-router on-startup (5-86400)",
843 "Make router a stub router\n"
844 "Advertise inability to be a transit router\n"
845 "Automatically advertise as stub-router on startup of OSPF6\n"
846 "Time (seconds) to advertise self as stub-router\n")
851 DEFUN (no_ospf6_stub_router_startup
,
852 no_ospf6_stub_router_startup_cmd
,
853 "no stub-router on-startup",
855 "Make router a stub router\n"
856 "Advertise inability to be a transit router\n"
857 "Automatically advertise as stub-router on startup of OSPF6\n"
858 "Time (seconds) to advertise self as stub-router\n")
863 DEFUN (ospf6_stub_router_shutdown
,
864 ospf6_stub_router_shutdown_cmd
,
865 "stub-router on-shutdown (5-86400)",
866 "Make router a stub router\n"
867 "Advertise inability to be a transit router\n"
868 "Automatically advertise as stub-router before shutdown\n"
869 "Time (seconds) to advertise self as stub-router\n")
874 DEFUN (no_ospf6_stub_router_shutdown
,
875 no_ospf6_stub_router_shutdown_cmd
,
876 "no stub-router on-shutdown",
878 "Make router a stub router\n"
879 "Advertise inability to be a transit router\n"
880 "Automatically advertise as stub-router before shutdown\n"
881 "Time (seconds) to advertise self as stub-router\n")
888 ospf6_show (struct vty
*vty
, struct ospf6
*o
)
891 struct ospf6_area
*oa
;
892 char router_id
[16], duration
[32];
893 struct timeval now
, running
, result
;
894 char buf
[32], rbuf
[32];
896 /* process id, router id */
897 inet_ntop (AF_INET
, &o
->router_id
, router_id
, sizeof (router_id
));
898 vty_out (vty
, " OSPFv3 Routing Process (0) with Router-ID %s%s",
902 quagga_gettime (QUAGGA_CLK_MONOTONIC
, &now
);
903 timersub (&now
, &o
->starttime
, &running
);
904 timerstring (&running
, duration
, sizeof (duration
));
905 vty_out (vty
, " Running %s%s", duration
, VNL
);
907 /* Redistribute configuration */
910 vty_out (vty
, " LSA minimum arrival %d msecs%s", o
->lsa_minarrival
,
913 /* Show SPF parameters */
914 vty_out(vty
, " Initial SPF scheduling delay %d millisec(s)%s"
915 " Minimum hold time between consecutive SPFs %d millsecond(s)%s"
916 " Maximum hold time between consecutive SPFs %d millsecond(s)%s"
917 " Hold time multiplier is currently %d%s",
919 o
->spf_holdtime
, VNL
,
920 o
->spf_max_holdtime
, VNL
,
921 o
->spf_hold_multiplier
, VNL
);
923 vty_out(vty
, " SPF algorithm ");
924 if (o
->ts_spf
.tv_sec
|| o
->ts_spf
.tv_usec
)
926 timersub(&now
, &o
->ts_spf
, &result
);
927 timerstring(&result
, buf
, sizeof(buf
));
928 ospf6_spf_reason_string(o
->last_spf_reason
, rbuf
, sizeof(rbuf
));
929 vty_out(vty
, "last executed %s ago, reason %s%s", buf
, rbuf
, VNL
);
930 vty_out (vty
, " Last SPF duration %lld sec %lld usec%s",
931 (long long)o
->ts_spf_duration
.tv_sec
,
932 (long long)o
->ts_spf_duration
.tv_usec
, VNL
);
935 vty_out(vty
, "has not been run$%s", VNL
);
936 threadtimer_string(now
, o
->t_spf_calc
, buf
, sizeof(buf
));
937 vty_out (vty
, " SPF timer %s%s%s",
938 (o
->t_spf_calc
? "due in " : "is "), buf
, VNL
);
940 if (CHECK_FLAG (o
->flag
, OSPF6_STUB_ROUTER
))
941 vty_out (vty
, " Router Is Stub Router%s", VNL
);
944 vty_out (vty
, " Number of AS scoped LSAs is %u%s",
945 o
->lsdb
->count
, VNL
);
948 vty_out (vty
, " Number of areas in this router is %u%s",
949 listcount (o
->area_list
), VNL
);
951 if (CHECK_FLAG(o
->config_flags
, OSPF6_LOG_ADJACENCY_CHANGES
))
953 if (CHECK_FLAG(o
->config_flags
, OSPF6_LOG_ADJACENCY_DETAIL
))
954 vty_out(vty
, " All adjacency changes are logged%s",VTY_NEWLINE
);
956 vty_out(vty
, " Adjacency changes are logged%s",VTY_NEWLINE
);
959 vty_out (vty
, "%s",VTY_NEWLINE
);
961 for (ALL_LIST_ELEMENTS_RO (o
->area_list
, n
, oa
))
962 ospf6_area_show (vty
, oa
);
965 /* show top level structures */
966 DEFUN (show_ipv6_ospf6
,
973 OSPF6_CMD_CHECK_RUNNING ();
975 ospf6_show (vty
, ospf6
);
979 DEFUN (show_ipv6_ospf6_route
,
980 show_ipv6_ospf6_route_cmd
,
981 "show ipv6 ospf6 route [<intra-area|inter-area|external-1|external-2|X:X::X:X|X:X::X:X/M|detail|summary>]",
986 "Display Intra-Area routes\n"
987 "Display Inter-Area routes\n"
988 "Display Type-1 External routes\n"
989 "Display Type-2 External routes\n"
990 "Specify IPv6 address\n"
991 "Specify IPv6 prefix\n"
992 "Detailed information\n"
993 "Summary of route table\n")
995 OSPF6_CMD_CHECK_RUNNING ();
997 ospf6_route_table_show (vty
, 4, argc
, argv
, ospf6
->route_table
);
1001 DEFUN (show_ipv6_ospf6_route_match
,
1002 show_ipv6_ospf6_route_match_cmd
,
1003 "show ipv6 ospf6 route X:X::X:X/M <match|longer>",
1008 "Specify IPv6 prefix\n"
1009 "Display routes which match the specified route\n"
1010 "Display routes longer than the specified route\n")
1012 OSPF6_CMD_CHECK_RUNNING ();
1014 ospf6_route_table_show (vty
, 4, argc
, argv
, ospf6
->route_table
);
1018 DEFUN (show_ipv6_ospf6_route_match_detail
,
1019 show_ipv6_ospf6_route_match_detail_cmd
,
1020 "show ipv6 ospf6 route X:X::X:X/M match detail",
1025 "Specify IPv6 prefix\n"
1026 "Display routes which match the specified route\n"
1027 "Detailed information\n"
1030 OSPF6_CMD_CHECK_RUNNING ();
1032 ospf6_route_table_show (vty
, 4, argc
, argv
, ospf6
->route_table
);
1038 DEFUN (show_ipv6_ospf6_route_type_detail
,
1039 show_ipv6_ospf6_route_type_detail_cmd
,
1040 "show ipv6 ospf6 route <intra-area|inter-area|external-1|external-2> detail",
1045 "Display Intra-Area routes\n"
1046 "Display Inter-Area routes\n"
1047 "Display Type-1 External routes\n"
1048 "Display Type-2 External routes\n"
1049 "Detailed information\n"
1052 OSPF6_CMD_CHECK_RUNNING ();
1054 ospf6_route_table_show (vty
, 4, argc
, argv
, ospf6
->route_table
);
1059 ospf6_stub_router_config_write (struct vty
*vty
)
1061 if (CHECK_FLAG (ospf6
->flag
, OSPF6_STUB_ROUTER
))
1063 vty_out (vty
, " stub-router administrative%s", VNL
);
1069 ospf6_distance_config_write (struct vty
*vty
)
1071 struct route_node
*rn
;
1072 struct ospf6_distance
*odistance
;
1074 if (ospf6
->distance_all
)
1075 vty_out (vty
, " distance %u%s", ospf6
->distance_all
, VTY_NEWLINE
);
1077 if (ospf6
->distance_intra
1078 || ospf6
->distance_inter
1079 || ospf6
->distance_external
)
1081 vty_out (vty
, " distance ospf6");
1083 if (ospf6
->distance_intra
)
1084 vty_out (vty
, " intra-area %u", ospf6
->distance_intra
);
1085 if (ospf6
->distance_inter
)
1086 vty_out (vty
, " inter-area %u", ospf6
->distance_inter
);
1087 if (ospf6
->distance_external
)
1088 vty_out (vty
, " external %u", ospf6
->distance_external
);
1090 vty_out (vty
, "%s", VTY_NEWLINE
);
1093 for (rn
= route_top (ospf6
->distance_table
); rn
; rn
= route_next (rn
))
1094 if ((odistance
= rn
->info
) != NULL
)
1096 char buf
[PREFIX_STRLEN
];
1098 vty_out (vty
, " distance %u %s %s%s", odistance
->distance
,
1099 prefix2str (&rn
->p
, buf
, sizeof (buf
)),
1100 odistance
->access_list
? odistance
->access_list
: "",
1106 /* OSPF configuration write function. */
1108 config_write_ospf6 (struct vty
*vty
)
1111 struct listnode
*j
, *k
;
1112 struct ospf6_area
*oa
;
1113 struct ospf6_interface
*oi
;
1115 /* OSPFv3 configuration. */
1119 inet_ntop (AF_INET
, &ospf6
->router_id_static
, router_id
, sizeof (router_id
));
1120 vty_out (vty
, "router ospf6%s", VNL
);
1121 if (ospf6
->router_id_static
!= 0)
1122 vty_out (vty
, " router-id %s%s", router_id
, VNL
);
1124 /* log-adjacency-changes flag print. */
1125 if (CHECK_FLAG(ospf6
->config_flags
, OSPF6_LOG_ADJACENCY_CHANGES
))
1127 if (CHECK_FLAG(ospf6
->config_flags
, OSPF6_LOG_ADJACENCY_DETAIL
))
1128 vty_out(vty
, " log-adjacency-changes detail%s", VTY_NEWLINE
);
1132 vty_out(vty
, " no log-adjacency-changes%s", VTY_NEWLINE
);
1135 if (ospf6
->ref_bandwidth
!= OSPF6_REFERENCE_BANDWIDTH
)
1136 vty_out (vty
, " auto-cost reference-bandwidth %d%s", ospf6
->ref_bandwidth
,
1139 /* LSA timers print. */
1140 if (ospf6
->lsa_minarrival
!= OSPF_MIN_LS_ARRIVAL
)
1141 vty_out (vty
, " timers lsa min-arrival %d%s", ospf6
->lsa_minarrival
,
1144 ospf6_stub_router_config_write (vty
);
1145 ospf6_redistribute_config_write (vty
);
1146 ospf6_area_config_write (vty
);
1147 ospf6_spf_config_write (vty
);
1148 ospf6_distance_config_write (vty
);
1150 for (ALL_LIST_ELEMENTS_RO (ospf6
->area_list
, j
, oa
))
1152 for (ALL_LIST_ELEMENTS_RO (oa
->if_list
, k
, oi
))
1153 vty_out (vty
, " interface %s area %s%s",
1154 oi
->interface
->name
, oa
->name
, VNL
);
1156 vty_out (vty
, "!%s", VNL
);
1160 /* OSPF6 node structure. */
1161 static struct cmd_node ospf6_node
=
1164 "%s(config-ospf6)# ",
1168 /* Install ospf related commands. */
1170 ospf6_top_init (void)
1172 /* Install ospf6 top node. */
1173 install_node (&ospf6_node
, config_write_ospf6
);
1175 install_element (VIEW_NODE
, &show_ipv6_ospf6_cmd
);
1176 install_element (CONFIG_NODE
, &router_ospf6_cmd
);
1177 install_element (CONFIG_NODE
, &no_router_ospf6_cmd
);
1179 install_element (VIEW_NODE
, &show_ipv6_ospf6_route_cmd
);
1180 install_element (VIEW_NODE
, &show_ipv6_ospf6_route_match_cmd
);
1181 install_element (VIEW_NODE
, &show_ipv6_ospf6_route_match_detail_cmd
);
1182 install_element (VIEW_NODE
, &show_ipv6_ospf6_route_type_detail_cmd
);
1184 install_default (OSPF6_NODE
);
1185 install_element (OSPF6_NODE
, &ospf6_router_id_cmd
);
1186 install_element (OSPF6_NODE
, &ospf6_log_adjacency_changes_cmd
);
1187 install_element (OSPF6_NODE
, &ospf6_log_adjacency_changes_detail_cmd
);
1188 install_element (OSPF6_NODE
, &no_ospf6_log_adjacency_changes_cmd
);
1189 install_element (OSPF6_NODE
, &no_ospf6_log_adjacency_changes_detail_cmd
);
1191 /* LSA timers commands */
1192 install_element (OSPF6_NODE
, &ospf6_timers_lsa_cmd
);
1193 install_element (OSPF6_NODE
, &no_ospf6_timers_lsa_cmd
);
1195 install_element (OSPF6_NODE
, &ospf6_interface_area_cmd
);
1196 install_element (OSPF6_NODE
, &no_ospf6_interface_area_cmd
);
1197 install_element (OSPF6_NODE
, &ospf6_stub_router_admin_cmd
);
1198 install_element (OSPF6_NODE
, &no_ospf6_stub_router_admin_cmd
);
1199 /* For a later time */
1201 install_element (OSPF6_NODE
, &ospf6_stub_router_startup_cmd
);
1202 install_element (OSPF6_NODE
, &no_ospf6_stub_router_startup_cmd
);
1203 install_element (OSPF6_NODE
, &ospf6_stub_router_shutdown_cmd
);
1204 install_element (OSPF6_NODE
, &no_ospf6_stub_router_shutdown_cmd
);
1207 install_element (OSPF6_NODE
, &ospf6_distance_cmd
);
1208 install_element (OSPF6_NODE
, &no_ospf6_distance_cmd
);
1209 install_element (OSPF6_NODE
, &ospf6_distance_ospf6_cmd
);
1210 install_element (OSPF6_NODE
, &no_ospf6_distance_ospf6_cmd
);
1212 install_element (OSPF6_NODE
, &ospf6_distance_source_cmd
);
1213 install_element (OSPF6_NODE
, &no_ospf6_distance_source_cmd
);