blob: 7ec430961f37fb6ac3979b9f983984fb9c65ffd6 [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
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
paul718e3742002-12-13 20:15:29 +000033#include "ospf6_proto.h"
hasso508e53e2004-05-18 18:57:06 +000034#include "ospf6_message.h"
paul718e3742002-12-13 20:15:29 +000035#include "ospf6_lsa.h"
36#include "ospf6_lsdb.h"
paul718e3742002-12-13 20:15:29 +000037#include "ospf6_route.h"
38#include "ospf6_zebra.h"
39
hasso508e53e2004-05-18 18:57:06 +000040#include "ospf6_top.h"
41#include "ospf6_area.h"
42#include "ospf6_interface.h"
43#include "ospf6_neighbor.h"
paul718e3742002-12-13 20:15:29 +000044
hasso6452df02004-08-15 05:52:07 +000045#include "ospf6_flood.h"
hasso508e53e2004-05-18 18:57:06 +000046#include "ospf6_asbr.h"
hasso049207c2004-08-04 20:02:13 +000047#include "ospf6_abr.h"
hasso6452df02004-08-15 05:52:07 +000048#include "ospf6_intra.h"
Dinesh Dutt3810e062013-08-24 07:54:09 +000049#include "ospf6_spf.h"
hasso049207c2004-08-04 20:02:13 +000050#include "ospf6d.h"
paul718e3742002-12-13 20:15:29 +000051
52/* global ospf6d variable */
53struct ospf6 *ospf6;
54
Tom Goffae2254a2010-11-10 13:01:41 -080055static void ospf6_disable (struct ospf6 *o);
56
Paul Jakma6ac29a52008-08-15 13:45:30 +010057static void
hasso508e53e2004-05-18 18:57:06 +000058ospf6_top_lsdb_hook_add (struct ospf6_lsa *lsa)
paul718e3742002-12-13 20:15:29 +000059{
hasso508e53e2004-05-18 18:57:06 +000060 switch (ntohs (lsa->header->type))
paul718e3742002-12-13 20:15:29 +000061 {
hasso508e53e2004-05-18 18:57:06 +000062 case OSPF6_LSTYPE_AS_EXTERNAL:
63 ospf6_asbr_lsa_add (lsa);
64 break;
65
66 default:
hasso508e53e2004-05-18 18:57:06 +000067 break;
paul718e3742002-12-13 20:15:29 +000068 }
69}
70
Paul Jakma6ac29a52008-08-15 13:45:30 +010071static void
hasso508e53e2004-05-18 18:57:06 +000072ospf6_top_lsdb_hook_remove (struct ospf6_lsa *lsa)
paul718e3742002-12-13 20:15:29 +000073{
hasso508e53e2004-05-18 18:57:06 +000074 switch (ntohs (lsa->header->type))
paul718e3742002-12-13 20:15:29 +000075 {
hasso508e53e2004-05-18 18:57:06 +000076 case OSPF6_LSTYPE_AS_EXTERNAL:
77 ospf6_asbr_lsa_remove (lsa);
78 break;
79
80 default:
hasso508e53e2004-05-18 18:57:06 +000081 break;
paul718e3742002-12-13 20:15:29 +000082 }
83}
84
Paul Jakma6ac29a52008-08-15 13:45:30 +010085static void
hasso049207c2004-08-04 20:02:13 +000086ospf6_top_route_hook_add (struct ospf6_route *route)
87{
hasso6452df02004-08-15 05:52:07 +000088 ospf6_abr_originate_summary (route);
hasso049207c2004-08-04 20:02:13 +000089 ospf6_zebra_route_update_add (route);
90}
91
Paul Jakma6ac29a52008-08-15 13:45:30 +010092static void
hasso049207c2004-08-04 20:02:13 +000093ospf6_top_route_hook_remove (struct ospf6_route *route)
94{
hasso6452df02004-08-15 05:52:07 +000095 ospf6_abr_originate_summary (route);
hasso049207c2004-08-04 20:02:13 +000096 ospf6_zebra_route_update_remove (route);
97}
98
Paul Jakma6ac29a52008-08-15 13:45:30 +010099static void
hasso6452df02004-08-15 05:52:07 +0000100ospf6_top_brouter_hook_add (struct ospf6_route *route)
101{
hassoccb59b12004-08-25 09:10:37 +0000102 ospf6_abr_examin_brouter (ADV_ROUTER_IN_PREFIX (&route->prefix));
hasso6452df02004-08-15 05:52:07 +0000103 ospf6_asbr_lsentry_add (route);
hassoccb59b12004-08-25 09:10:37 +0000104 ospf6_abr_originate_summary (route);
hasso6452df02004-08-15 05:52:07 +0000105}
106
Paul Jakma6ac29a52008-08-15 13:45:30 +0100107static void
hasso6452df02004-08-15 05:52:07 +0000108ospf6_top_brouter_hook_remove (struct ospf6_route *route)
109{
hassoccb59b12004-08-25 09:10:37 +0000110 ospf6_abr_examin_brouter (ADV_ROUTER_IN_PREFIX (&route->prefix));
hasso6452df02004-08-15 05:52:07 +0000111 ospf6_asbr_lsentry_remove (route);
hassoccb59b12004-08-25 09:10:37 +0000112 ospf6_abr_originate_summary (route);
hasso6452df02004-08-15 05:52:07 +0000113}
114
Paul Jakma6ac29a52008-08-15 13:45:30 +0100115static struct ospf6 *
116ospf6_create (void)
paul718e3742002-12-13 20:15:29 +0000117{
hasso508e53e2004-05-18 18:57:06 +0000118 struct ospf6 *o;
paul718e3742002-12-13 20:15:29 +0000119
Stephen Hemminger393deb92008-08-18 14:13:29 -0700120 o = XCALLOC (MTYPE_OSPF6_TOP, sizeof (struct ospf6));
hasso508e53e2004-05-18 18:57:06 +0000121
122 /* initialize */
Takashi Sogabe86f72dc2009-06-22 13:07:02 +0900123 quagga_gettime (QUAGGA_CLK_MONOTONIC, &o->starttime);
hasso508e53e2004-05-18 18:57:06 +0000124 o->area_list = list_new ();
125 o->area_list->cmp = ospf6_area_cmp;
hasso6452df02004-08-15 05:52:07 +0000126 o->lsdb = ospf6_lsdb_create (o);
127 o->lsdb_self = ospf6_lsdb_create (o);
hasso508e53e2004-05-18 18:57:06 +0000128 o->lsdb->hook_add = ospf6_top_lsdb_hook_add;
129 o->lsdb->hook_remove = ospf6_top_lsdb_hook_remove;
130
Dinesh Dutt3810e062013-08-24 07:54:09 +0000131 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;
135
Paul Jakmacf1ce252006-05-15 10:46:07 +0000136 o->route_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, ROUTES);
137 o->route_table->scope = o;
hasso049207c2004-08-04 20:02:13 +0000138 o->route_table->hook_add = ospf6_top_route_hook_add;
139 o->route_table->hook_remove = ospf6_top_route_hook_remove;
hasso508e53e2004-05-18 18:57:06 +0000140
Paul Jakmacf1ce252006-05-15 10:46:07 +0000141 o->brouter_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, BORDER_ROUTERS);
142 o->brouter_table->scope = o;
hasso6452df02004-08-15 05:52:07 +0000143 o->brouter_table->hook_add = ospf6_top_brouter_hook_add;
144 o->brouter_table->hook_remove = ospf6_top_brouter_hook_remove;
hasso049207c2004-08-04 20:02:13 +0000145
Paul Jakmacf1ce252006-05-15 10:46:07 +0000146 o->external_table = OSPF6_ROUTE_TABLE_CREATE (GLOBAL, EXTERNAL_ROUTES);
147 o->external_table->scope = o;
148
hasso508e53e2004-05-18 18:57:06 +0000149 o->external_id_table = route_table_init ();
150
Vincent Bernatfd500682012-10-24 14:45:54 +0000151 o->ref_bandwidth = OSPF6_REFERENCE_BANDWIDTH;
152
Roman Hoog Antinkd8f7f862014-03-05 09:13:43 +0100153 o->distance_table = route_table_init ();
154
hasso508e53e2004-05-18 18:57:06 +0000155 return o;
156}
157
Tom Goffae2254a2010-11-10 13:01:41 -0800158void
hasso508e53e2004-05-18 18:57:06 +0000159ospf6_delete (struct ospf6 *o)
160{
paul1eb8ef22005-04-07 07:30:20 +0000161 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000162 struct ospf6_area *oa;
163
Tom Goffae2254a2010-11-10 13:01:41 -0800164 ospf6_disable (ospf6);
165
paul1eb8ef22005-04-07 07:30:20 +0000166 for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
167 ospf6_area_delete (oa);
Christian Franked9628722013-03-08 21:47:35 +0100168
169
Tom Goffae2254a2010-11-10 13:01:41 -0800170 list_delete (o->area_list);
hasso508e53e2004-05-18 18:57:06 +0000171
172 ospf6_lsdb_delete (o->lsdb);
hasso6452df02004-08-15 05:52:07 +0000173 ospf6_lsdb_delete (o->lsdb_self);
hasso508e53e2004-05-18 18:57:06 +0000174
175 ospf6_route_table_delete (o->route_table);
hasso049207c2004-08-04 20:02:13 +0000176 ospf6_route_table_delete (o->brouter_table);
hasso508e53e2004-05-18 18:57:06 +0000177
178 ospf6_route_table_delete (o->external_table);
179 route_table_finish (o->external_id_table);
180
Roman Hoog Antinkd8f7f862014-03-05 09:13:43 +0100181 ospf6_distance_reset (o);
182 route_table_finish (o->distance_table);
183
hasso508e53e2004-05-18 18:57:06 +0000184 XFREE (MTYPE_OSPF6_TOP, o);
185}
186
Paul Jakma6ac29a52008-08-15 13:45:30 +0100187static void
Paul Jakma7aa9dce2014-09-19 14:42:23 +0100188__attribute__((unused))
hasso508e53e2004-05-18 18:57:06 +0000189ospf6_enable (struct ospf6 *o)
190{
paul1eb8ef22005-04-07 07:30:20 +0000191 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000192 struct ospf6_area *oa;
193
194 if (CHECK_FLAG (o->flag, OSPF6_DISABLED))
195 {
196 UNSET_FLAG (o->flag, OSPF6_DISABLED);
paul1eb8ef22005-04-07 07:30:20 +0000197 for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
198 ospf6_area_enable (oa);
paul718e3742002-12-13 20:15:29 +0000199 }
200}
201
Paul Jakma6ac29a52008-08-15 13:45:30 +0100202static void
hasso508e53e2004-05-18 18:57:06 +0000203ospf6_disable (struct ospf6 *o)
paul718e3742002-12-13 20:15:29 +0000204{
paul1eb8ef22005-04-07 07:30:20 +0000205 struct listnode *node, *nnode;
hasso508e53e2004-05-18 18:57:06 +0000206 struct ospf6_area *oa;
paul718e3742002-12-13 20:15:29 +0000207
hasso508e53e2004-05-18 18:57:06 +0000208 if (! CHECK_FLAG (o->flag, OSPF6_DISABLED))
209 {
210 SET_FLAG (o->flag, OSPF6_DISABLED);
paul1eb8ef22005-04-07 07:30:20 +0000211
212 for (ALL_LIST_ELEMENTS (o->area_list, node, nnode, oa))
213 ospf6_area_disable (oa);
paul718e3742002-12-13 20:15:29 +0000214
Christian Franked9628722013-03-08 21:47:35 +0100215 /* XXX: This also changes persistent settings */
216 ospf6_asbr_redistribute_reset();
217
hasso508e53e2004-05-18 18:57:06 +0000218 ospf6_lsdb_remove_all (o->lsdb);
219 ospf6_route_remove_all (o->route_table);
hasso6452df02004-08-15 05:52:07 +0000220 ospf6_route_remove_all (o->brouter_table);
Christian Franked9628722013-03-08 21:47:35 +0100221
222 THREAD_OFF(o->maxage_remover);
223 THREAD_OFF(o->t_spf_calc);
224 THREAD_OFF(o->t_ase_calc);
hasso508e53e2004-05-18 18:57:06 +0000225 }
226}
paul718e3742002-12-13 20:15:29 +0000227
Paul Jakma7aa9dce2014-09-19 14:42:23 +0100228static int
hasso508e53e2004-05-18 18:57:06 +0000229ospf6_maxage_remover (struct thread *thread)
230{
231 struct ospf6 *o = (struct ospf6 *) THREAD_ARG (thread);
232 struct ospf6_area *oa;
233 struct ospf6_interface *oi;
234 struct ospf6_neighbor *on;
hasso52dc7ee2004-09-23 19:18:23 +0000235 struct listnode *i, *j, *k;
Dinesh Dutt2449fcd2013-08-24 07:54:17 +0000236 int reschedule = 0;
hasso508e53e2004-05-18 18:57:06 +0000237
238 o->maxage_remover = (struct thread *) NULL;
hasso508e53e2004-05-18 18:57:06 +0000239
paul1eb8ef22005-04-07 07:30:20 +0000240 for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
hasso508e53e2004-05-18 18:57:06 +0000241 {
paul1eb8ef22005-04-07 07:30:20 +0000242 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
hasso508e53e2004-05-18 18:57:06 +0000243 {
paul1eb8ef22005-04-07 07:30:20 +0000244 for (ALL_LIST_ELEMENTS_RO (oi->neighbor_list, k, on))
hasso508e53e2004-05-18 18:57:06 +0000245 {
hasso508e53e2004-05-18 18:57:06 +0000246 if (on->state != OSPF6_NEIGHBOR_EXCHANGE &&
247 on->state != OSPF6_NEIGHBOR_LOADING)
Dinesh Dutt2449fcd2013-08-24 07:54:17 +0000248 continue;
hasso508e53e2004-05-18 18:57:06 +0000249
Dinesh Dutt2449fcd2013-08-24 07:54:17 +0000250 ospf6_maxage_remove (o);
hasso508e53e2004-05-18 18:57:06 +0000251 return 0;
252 }
253 }
254 }
255
paul1eb8ef22005-04-07 07:30:20 +0000256 for (ALL_LIST_ELEMENTS_RO (o->area_list, i, oa))
hasso508e53e2004-05-18 18:57:06 +0000257 {
paul1eb8ef22005-04-07 07:30:20 +0000258 for (ALL_LIST_ELEMENTS_RO (oa->if_list, j, oi))
Dinesh Dutt2449fcd2013-08-24 07:54:17 +0000259 {
260 if (ospf6_lsdb_maxage_remover (oi->lsdb))
261 {
262 reschedule = 1;
263 }
264 }
paul1eb8ef22005-04-07 07:30:20 +0000265
Dinesh Dutt2449fcd2013-08-24 07:54:17 +0000266 if (ospf6_lsdb_maxage_remover (oa->lsdb))
267 {
268 reschedule = 1;
269 }
hasso508e53e2004-05-18 18:57:06 +0000270 }
Dinesh Dutt2449fcd2013-08-24 07:54:17 +0000271
272 if (ospf6_lsdb_maxage_remover (o->lsdb))
273 {
274 reschedule = 1;
275 }
276
277 if (reschedule)
278 {
279 ospf6_maxage_remove (o);
280 }
hasso508e53e2004-05-18 18:57:06 +0000281
paul718e3742002-12-13 20:15:29 +0000282 return 0;
283}
284
285void
hasso508e53e2004-05-18 18:57:06 +0000286ospf6_maxage_remove (struct ospf6 *o)
paul718e3742002-12-13 20:15:29 +0000287{
hasso508e53e2004-05-18 18:57:06 +0000288 if (o && ! o->maxage_remover)
Dinesh Dutt2449fcd2013-08-24 07:54:17 +0000289 o->maxage_remover = thread_add_timer (master, ospf6_maxage_remover, o,
290 OSPF_LSA_MAXAGE_REMOVE_DELAY_DEFAULT);
hasso508e53e2004-05-18 18:57:06 +0000291}
paul718e3742002-12-13 20:15:29 +0000292
hasso508e53e2004-05-18 18:57:06 +0000293/* start ospf6 */
294DEFUN (router_ospf6,
295 router_ospf6_cmd,
296 "router ospf6",
297 ROUTER_STR
298 OSPF6_STR)
299{
300 if (ospf6 == NULL)
301 ospf6 = ospf6_create ();
hasso508e53e2004-05-18 18:57:06 +0000302
303 /* set current ospf point. */
304 vty->node = OSPF6_NODE;
305 vty->index = ospf6;
306
307 return CMD_SUCCESS;
308}
309
310/* stop ospf6 */
311DEFUN (no_router_ospf6,
312 no_router_ospf6_cmd,
313 "no router ospf6",
314 NO_STR
315 OSPF6_ROUTER_STR)
316{
Christian Franked9628722013-03-08 21:47:35 +0100317 if (ospf6 == NULL)
318 vty_out (vty, "OSPFv3 is not configured%s", VNL);
hasso508e53e2004-05-18 18:57:06 +0000319 else
Christian Franked9628722013-03-08 21:47:35 +0100320 {
321 ospf6_delete (ospf6);
322 ospf6 = NULL;
323 }
hasso508e53e2004-05-18 18:57:06 +0000324
325 /* return to config node . */
326 vty->node = CONFIG_NODE;
327 vty->index = NULL;
328
329 return CMD_SUCCESS;
330}
331
332/* change Router_ID commands. */
333DEFUN (ospf6_router_id,
334 ospf6_router_id_cmd,
335 "router-id A.B.C.D",
336 "Configure OSPF Router-ID\n"
337 V4NOTATION_STR)
338{
339 int ret;
340 u_int32_t router_id;
341 struct ospf6 *o;
342
343 o = (struct ospf6 *) vty->index;
344
345 ret = inet_pton (AF_INET, argv[0], &router_id);
346 if (ret == 0)
347 {
hasso049207c2004-08-04 20:02:13 +0000348 vty_out (vty, "malformed OSPF Router-ID: %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000349 return CMD_SUCCESS;
350 }
351
hassoc8a440e2004-10-11 17:02:40 +0000352 o->router_id_static = router_id;
353 if (o->router_id == 0)
354 o->router_id = router_id;
355
hasso508e53e2004-05-18 18:57:06 +0000356 return CMD_SUCCESS;
357}
358
Dinesh Dutt3d35ca42013-08-26 03:40:16 +0000359DEFUN (ospf6_log_adjacency_changes,
360 ospf6_log_adjacency_changes_cmd,
361 "log-adjacency-changes",
362 "Log changes in adjacency state\n")
363{
364 struct ospf6 *ospf6 = vty->index;
365
366 SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES);
367 return CMD_SUCCESS;
368}
369
370DEFUN (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")
375{
376 struct ospf6 *ospf6 = vty->index;
377
378 SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES);
379 SET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL);
380 return CMD_SUCCESS;
381}
382
383DEFUN (no_ospf6_log_adjacency_changes,
384 no_ospf6_log_adjacency_changes_cmd,
385 "no log-adjacency-changes",
386 NO_STR
387 "Log changes in adjacency state\n")
388{
389 struct ospf6 *ospf6 = vty->index;
390
391 UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL);
392 UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES);
393 return CMD_SUCCESS;
394}
395
396DEFUN (no_ospf6_log_adjacency_changes_detail,
397 no_ospf6_log_adjacency_changes_detail_cmd,
398 "no log-adjacency-changes detail",
399 NO_STR
400 "Log changes in adjacency state\n"
401 "Log all state changes\n")
402{
403 struct ospf6 *ospf6 = vty->index;
404
405 UNSET_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL);
406 return CMD_SUCCESS;
407}
408
Roman Hoog Antinkd8f7f862014-03-05 09:13:43 +0100409DEFUN (ospf6_distance,
410 ospf6_distance_cmd,
411 "distance <1-255>",
412 NO_STR
413 "Define an administrative distance\n"
414 "OSPF6 Administrative distance\n")
415{
416 struct ospf6 *o;
417
418 o = (struct ospf6 *) vty->index;
419
420 o->distance_all = atoi (argv[0]);
421
422 return CMD_SUCCESS;
423}
424
425DEFUN (no_ospf6_distance,
426 no_ospf6_distance_cmd,
427 "no distance <1-255>",
428 NO_STR
429 "Define an administrative distance\n"
430 "OSPF6 Administrative distance\n")
431{
432 struct ospf6 *o;
433
434 o = (struct ospf6 *) vty->index;
435
436 o->distance_all = 0;
437
438 return CMD_SUCCESS;
439}
440
441DEFUN (no_ospf6_distance_ospf6,
442 no_ospf6_distance_ospf6_cmd,
443 "no distance ospf6",
444 NO_STR
445 "Define an administrative distance\n"
446 "OSPF6 Administrative distance\n"
447 "OSPF6 Distance\n")
448{
449 struct ospf6 *o;
450
451 o = (struct ospf6 *) vty->index;
452
453 o->distance_intra = 0;
454 o->distance_inter = 0;
455 o->distance_external = 0;
456
457 return CMD_SUCCESS;
458}
459
460DEFUN (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")
467{
468 struct ospf6 *o;
469
470 o = (struct ospf6 *) vty->index;
471
472 o->distance_intra = atoi (argv[0]);
473
474 return CMD_SUCCESS;
475}
476
477DEFUN (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")
486{
487 struct ospf6 *o;
488
489 o = (struct ospf6 *) vty->index;
490
491 o->distance_intra = atoi (argv[0]);
492 o->distance_inter = atoi (argv[1]);
493
494 return CMD_SUCCESS;
495}
496
497DEFUN (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"
504 "External routes\n"
505 "Distance for external routes\n")
506{
507 struct ospf6 *o;
508
509 o = (struct ospf6 *) vty->index;
510
511 o->distance_intra = atoi (argv[0]);
512 o->distance_external = atoi (argv[1]);
513
514 return CMD_SUCCESS;
515}
516
517DEFUN (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"
526 "External routes\n"
527 "Distance for external routes\n")
528{
529 struct ospf6 *o;
530
531 o = (struct ospf6 *) vty->index;
532
533 o->distance_intra = atoi (argv[0]);
534 o->distance_inter = atoi (argv[1]);
535 o->distance_external = atoi (argv[2]);
536
537 return CMD_SUCCESS;
538}
539
540DEFUN (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"
547 "External routes\n"
548 "Distance for external routes\n"
549 "Inter-area routes\n"
550 "Distance for inter-area routes\n")
551{
552 struct ospf6 *o;
553
554 o = (struct ospf6 *) vty->index;
555
556 o->distance_intra = atoi (argv[0]);
557 o->distance_external = atoi (argv[1]);
558 o->distance_inter = atoi (argv[2]);
559
560 return CMD_SUCCESS;
561}
562
563DEFUN (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")
570{
571 struct ospf6 *o;
572
573 o = (struct ospf6 *) vty->index;
574
575 o->distance_inter = atoi (argv[0]);
576
577 return CMD_SUCCESS;
578}
579
580DEFUN (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")
589{
590 struct ospf6 *o;
591
592 o = (struct ospf6 *) vty->index;
593
594 o->distance_inter = atoi (argv[0]);
595 o->distance_intra = atoi (argv[1]);
596
597 return CMD_SUCCESS;
598}
599
600DEFUN (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"
607 "External routes\n"
608 "Distance for external routes\n")
609{
610 struct ospf6 *o;
611
612 o = (struct ospf6 *) vty->index;
613
614 o->distance_inter = atoi (argv[0]);
615 o->distance_external = atoi (argv[1]);
616
617 return CMD_SUCCESS;
618}
619
620DEFUN (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"
629 "External routes\n"
630 "Distance for external routes\n")
631{
632 struct ospf6 *o;
633
634 o = (struct ospf6 *) vty->index;
635
636 o->distance_inter = atoi (argv[0]);
637 o->distance_intra = atoi (argv[1]);
638 o->distance_external = atoi (argv[2]);
639
640 return CMD_SUCCESS;
641}
642
643DEFUN (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"
650 "External routes\n"
651 "Distance for external routes\n"
652 "Intra-area routes\n"
653 "Distance for intra-area routes\n")
654{
655 struct ospf6 *o;
656
657 o = (struct ospf6 *) vty->index;
658
659 o->distance_inter = atoi (argv[0]);
660 o->distance_external = atoi (argv[1]);
661 o->distance_intra = atoi (argv[2]);
662
663 return CMD_SUCCESS;
664}
665
666DEFUN (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"
671 "External routes\n"
672 "Distance for external routes\n")
673{
674 struct ospf6 *o;
675
676 o = (struct ospf6 *) vty->index;
677
678 o->distance_external = atoi (argv[0]);
679
680 return CMD_SUCCESS;
681}
682
683DEFUN (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"
688 "External routes\n"
689 "Distance for external routes\n"
690 "Intra-area routes\n"
691 "Distance for intra-area routes\n")
692{
693 struct ospf6 *o;
694
695 o = (struct ospf6 *) vty->index;
696
697 o->distance_external = atoi (argv[0]);
698 o->distance_intra = atoi (argv[1]);
699
700 return CMD_SUCCESS;
701}
702
703DEFUN (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"
708 "External routes\n"
709 "Distance for external routes\n"
710 "Inter-area routes\n"
711 "Distance for inter-area routes\n")
712{
713 struct ospf6 *o;
714
715 o = (struct ospf6 *) vty->index;
716
717 o->distance_external = atoi (argv[0]);
718 o->distance_inter = atoi (argv[1]);
719
720 return CMD_SUCCESS;
721}
722
723DEFUN (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"
728 "External routes\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")
734{
735 struct ospf6 *o;
736
737 o = (struct ospf6 *) vty->index;
738
739 o->distance_external = atoi (argv[0]);
740 o->distance_intra = atoi (argv[1]);
741 o->distance_inter = atoi (argv[2]);
742
743 return CMD_SUCCESS;
744}
745
746DEFUN (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"
751 "External routes\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")
757{
758 struct ospf6 *o;
759
760 o = (struct ospf6 *) vty->index;
761
762 o->distance_external = atoi (argv[0]);
763 o->distance_inter = atoi (argv[1]);
764 o->distance_intra = atoi (argv[2]);
765
766 return CMD_SUCCESS;
767}
768
769DEFUN (ospf6_distance_source,
770 ospf6_distance_source_cmd,
771 "distance <1-255> X:X::X:X/M",
772 "Administrative distance\n"
773 "Distance value\n"
774 "IP source prefix\n")
775{
776 struct ospf6 *o;
777
778 o = (struct ospf6 *) vty->index;
779
780 ospf6_distance_set (vty, o, argv[0], argv[1], NULL);
781
782 return CMD_SUCCESS;
783}
784
785DEFUN (no_ospf6_distance_source,
786 no_ospf6_distance_source_cmd,
787 "no distance <1-255> X:X::X:X/M",
788 NO_STR
789 "Administrative distance\n"
790 "Distance value\n"
791 "IP source prefix\n")
792{
793 struct ospf6 *o;
794
795 o = (struct ospf6 *) vty->index;
796
797 /* XXX: distance arg seems to be irrelevant */
798 ospf6_distance_unset (vty, o, argv[1], NULL);
799
800 return CMD_SUCCESS;
801}
802
803DEFUN (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"
807 "Distance value\n"
808 "IP source prefix\n"
809 "Access list name\n")
810{
811 struct ospf6 *o;
812
813 o = (struct ospf6 *) vty->index;
814
815 ospf6_distance_set (vty, o, argv[0], argv[1], argv[2]);
816
817 return CMD_SUCCESS;
818}
819
820DEFUN (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",
823 NO_STR
824 "Administrative distance\n"
825 "Distance value\n"
826 "IP source prefix\n"
827 "Access list name\n")
828{
829 struct ospf6 *o;
830
831 o = (struct ospf6 *) vty->index;
832
833 ospf6_distance_unset (vty, o, argv[1], argv[2]);
834
835 return CMD_SUCCESS;
836}
837
hasso508e53e2004-05-18 18:57:06 +0000838DEFUN (ospf6_interface_area,
839 ospf6_interface_area_cmd,
840 "interface IFNAME area A.B.C.D",
841 "Enable routing on an IPv6 interface\n"
842 IFNAME_STR
843 "Specify the OSPF6 area ID\n"
844 "OSPF6 area ID in IPv4 address notation\n"
845 )
846{
847 struct ospf6 *o;
hasso3b687352004-08-19 06:56:53 +0000848 struct ospf6_area *oa;
hasso508e53e2004-05-18 18:57:06 +0000849 struct ospf6_interface *oi;
850 struct interface *ifp;
851 u_int32_t area_id;
852
853 o = (struct ospf6 *) vty->index;
854
855 /* find/create ospf6 interface */
856 ifp = if_get_by_name (argv[0]);
857 oi = (struct ospf6_interface *) ifp->info;
858 if (oi == NULL)
859 oi = ospf6_interface_create (ifp);
860 if (oi->area)
861 {
862 vty_out (vty, "%s already attached to Area %s%s",
hasso049207c2004-08-04 20:02:13 +0000863 oi->interface->name, oi->area->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000864 return CMD_SUCCESS;
865 }
866
867 /* parse Area-ID */
868 if (inet_pton (AF_INET, argv[1], &area_id) != 1)
869 {
hasso049207c2004-08-04 20:02:13 +0000870 vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL);
hasso508e53e2004-05-18 18:57:06 +0000871 return CMD_SUCCESS;
872 }
873
874 /* find/create ospf6 area */
875 oa = ospf6_area_lookup (area_id, o);
876 if (oa == NULL)
877 oa = ospf6_area_create (area_id, o);
878
879 /* attach interface to area */
880 listnode_add (oa->if_list, oi); /* sort ?? */
881 oi->area = oa;
882
hasso6452df02004-08-15 05:52:07 +0000883 SET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
884
Christian Franked9628722013-03-08 21:47:35 +0100885 /* ospf6 process is currently disabled, not much more to do */
886 if (CHECK_FLAG (o->flag, OSPF6_DISABLED))
887 return CMD_SUCCESS;
888
hasso508e53e2004-05-18 18:57:06 +0000889 /* start up */
Christian Franked9628722013-03-08 21:47:35 +0100890 ospf6_interface_enable (oi);
hasso6452df02004-08-15 05:52:07 +0000891
hasso3b687352004-08-19 06:56:53 +0000892 /* If the router is ABR, originate summary routes */
893 if (ospf6_is_router_abr (o))
894 ospf6_abr_enable_area (oa);
hasso6452df02004-08-15 05:52:07 +0000895
hasso508e53e2004-05-18 18:57:06 +0000896 return CMD_SUCCESS;
897}
898
899DEFUN (no_ospf6_interface_area,
900 no_ospf6_interface_area_cmd,
901 "no interface IFNAME area A.B.C.D",
902 NO_STR
903 "Disable routing on an IPv6 interface\n"
904 IFNAME_STR
905 "Specify the OSPF6 area ID\n"
906 "OSPF6 area ID in IPv4 address notation\n"
907 )
908{
hasso508e53e2004-05-18 18:57:06 +0000909 struct ospf6_interface *oi;
hasso3b687352004-08-19 06:56:53 +0000910 struct ospf6_area *oa;
hasso508e53e2004-05-18 18:57:06 +0000911 struct interface *ifp;
912 u_int32_t area_id;
913
hasso508e53e2004-05-18 18:57:06 +0000914 ifp = if_lookup_by_name (argv[0]);
915 if (ifp == NULL)
916 {
hasso049207c2004-08-04 20:02:13 +0000917 vty_out (vty, "No such interface %s%s", argv[0], VNL);
hasso508e53e2004-05-18 18:57:06 +0000918 return CMD_SUCCESS;
919 }
920
921 oi = (struct ospf6_interface *) ifp->info;
922 if (oi == NULL)
923 {
hasso049207c2004-08-04 20:02:13 +0000924 vty_out (vty, "Interface %s not enabled%s", ifp->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000925 return CMD_SUCCESS;
926 }
927
928 /* parse Area-ID */
929 if (inet_pton (AF_INET, argv[1], &area_id) != 1)
930 {
hasso049207c2004-08-04 20:02:13 +0000931 vty_out (vty, "Invalid Area-ID: %s%s", argv[1], VNL);
hasso508e53e2004-05-18 18:57:06 +0000932 return CMD_SUCCESS;
933 }
934
Jon56abbb82009-02-11 17:30:44 -0800935 /* Verify Area */
936 if (oi->area == NULL)
937 {
938 vty_out (vty, "No such Area-ID: %s%s", argv[1], VNL);
939 return CMD_SUCCESS;
940 }
941
hasso508e53e2004-05-18 18:57:06 +0000942 if (oi->area->area_id != area_id)
943 {
944 vty_out (vty, "Wrong Area-ID: %s is attached to area %s%s",
hasso049207c2004-08-04 20:02:13 +0000945 oi->interface->name, oi->area->name, VNL);
hasso508e53e2004-05-18 18:57:06 +0000946 return CMD_SUCCESS;
947 }
948
949 thread_execute (master, interface_down, oi, 0);
950
hasso6452df02004-08-15 05:52:07 +0000951 oa = oi->area;
hasso508e53e2004-05-18 18:57:06 +0000952 listnode_delete (oi->area->if_list, oi);
953 oi->area = (struct ospf6_area *) NULL;
954
hasso6452df02004-08-15 05:52:07 +0000955 /* Withdraw inter-area routes from this area, if necessary */
956 if (oa->if_list->count == 0)
957 {
958 UNSET_FLAG (oa->flag, OSPF6_AREA_ENABLE);
hasso3b687352004-08-19 06:56:53 +0000959 ospf6_abr_disable_area (oa);
hasso6452df02004-08-15 05:52:07 +0000960 }
961
hasso508e53e2004-05-18 18:57:06 +0000962 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +0000963}
964
Dinesh Duttf41b4a02013-08-24 08:00:37 +0000965DEFUN (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")
971{
972 struct listnode *node;
973 struct ospf6_area *oa;
974
975 if (!CHECK_FLAG (ospf6->flag, OSPF6_STUB_ROUTER))
976 {
977 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
978 {
979 OSPF6_OPT_CLEAR (oa->options, OSPF6_OPT_V6);
980 OSPF6_OPT_CLEAR (oa->options, OSPF6_OPT_R);
981 OSPF6_ROUTER_LSA_SCHEDULE (oa);
982 }
983 SET_FLAG (ospf6->flag, OSPF6_STUB_ROUTER);
984 }
985
986 return CMD_SUCCESS;
987}
988
989DEFUN (no_ospf6_stub_router_admin,
990 no_ospf6_stub_router_admin_cmd,
991 "no stub-router administrative",
992 NO_STR
993 "Make router a stub router\n"
994 "Advertise ability to be a transit router\n"
995 "Administratively applied, for an indefinite period\n")
996{
997 struct listnode *node;
998 struct ospf6_area *oa;
999
1000 if (CHECK_FLAG (ospf6->flag, OSPF6_STUB_ROUTER))
1001 {
1002 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, node, oa))
1003 {
1004 OSPF6_OPT_SET (oa->options, OSPF6_OPT_V6);
1005 OSPF6_OPT_SET (oa->options, OSPF6_OPT_R);
1006 OSPF6_ROUTER_LSA_SCHEDULE (oa);
1007 }
1008 UNSET_FLAG (ospf6->flag, OSPF6_STUB_ROUTER);
1009 }
1010
1011 return CMD_SUCCESS;
1012}
1013
1014DEFUN (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")
1021{
1022 return CMD_SUCCESS;
1023}
1024
1025DEFUN (no_ospf6_stub_router_startup,
1026 no_ospf6_stub_router_startup_cmd,
1027 "no stub-router on-startup",
1028 NO_STR
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")
1033{
1034 return CMD_SUCCESS;
1035}
1036
1037DEFUN (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")
1044{
1045 return CMD_SUCCESS;
1046}
1047
1048DEFUN (no_ospf6_stub_router_shutdown,
1049 no_ospf6_stub_router_shutdown_cmd,
1050 "no stub-router on-shutdown",
1051 NO_STR
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")
1056{
1057 return CMD_SUCCESS;
1058}
1059
Paul Jakma6ac29a52008-08-15 13:45:30 +01001060static void
hasso508e53e2004-05-18 18:57:06 +00001061ospf6_show (struct vty *vty, struct ospf6 *o)
paul718e3742002-12-13 20:15:29 +00001062{
hasso52dc7ee2004-09-23 19:18:23 +00001063 struct listnode *n;
hasso508e53e2004-05-18 18:57:06 +00001064 struct ospf6_area *oa;
1065 char router_id[16], duration[32];
Dinesh Dutta0edf672013-08-26 03:40:23 +00001066 struct timeval now, running, result;
1067 char buf[32], rbuf[32];
paul718e3742002-12-13 20:15:29 +00001068
1069 /* process id, router id */
hasso508e53e2004-05-18 18:57:06 +00001070 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",
hasso049207c2004-08-04 20:02:13 +00001072 router_id, VNL);
paul718e3742002-12-13 20:15:29 +00001073
1074 /* running time */
Takashi Sogabe86f72dc2009-06-22 13:07:02 +09001075 quagga_gettime (QUAGGA_CLK_MONOTONIC, &now);
hasso508e53e2004-05-18 18:57:06 +00001076 timersub (&now, &o->starttime, &running);
1077 timerstring (&running, duration, sizeof (duration));
hasso049207c2004-08-04 20:02:13 +00001078 vty_out (vty, " Running %s%s", duration, VNL);
paul718e3742002-12-13 20:15:29 +00001079
hasso508e53e2004-05-18 18:57:06 +00001080 /* Redistribute configuration */
1081 /* XXX */
paul718e3742002-12-13 20:15:29 +00001082
Dinesh Dutta0edf672013-08-26 03:40:23 +00001083 /* 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",
1088 o->spf_delay, VNL,
1089 o->spf_holdtime, VNL,
1090 o->spf_max_holdtime, VNL,
1091 o->spf_hold_multiplier, VNL);
1092
1093 vty_out(vty, " SPF algorithm ");
1094 if (o->ts_spf.tv_sec || o->ts_spf.tv_usec)
1095 {
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);
David Lamparteref008d22015-03-03 08:48:11 +01001100 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);
Dinesh Dutta0edf672013-08-26 03:40:23 +00001103 }
1104 else
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);
1109
Dinesh Duttf41b4a02013-08-24 08:00:37 +00001110 if (CHECK_FLAG (o->flag, OSPF6_STUB_ROUTER))
1111 vty_out (vty, " Router Is Stub Router%s", VNL);
1112
paul718e3742002-12-13 20:15:29 +00001113 /* LSAs */
1114 vty_out (vty, " Number of AS scoped LSAs is %u%s",
hasso049207c2004-08-04 20:02:13 +00001115 o->lsdb->count, VNL);
paul718e3742002-12-13 20:15:29 +00001116
1117 /* Areas */
1118 vty_out (vty, " Number of areas in this router is %u%s",
hasso049207c2004-08-04 20:02:13 +00001119 listcount (o->area_list), VNL);
paul1eb8ef22005-04-07 07:30:20 +00001120
Dinesh Dutt3d35ca42013-08-26 03:40:16 +00001121 if (CHECK_FLAG(o->config_flags, OSPF6_LOG_ADJACENCY_CHANGES))
1122 {
1123 if (CHECK_FLAG(o->config_flags, OSPF6_LOG_ADJACENCY_DETAIL))
1124 vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE);
1125 else
1126 vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE);
1127 }
1128
1129 vty_out (vty, "%s",VTY_NEWLINE);
1130
paul1eb8ef22005-04-07 07:30:20 +00001131 for (ALL_LIST_ELEMENTS_RO (o->area_list, n, oa))
1132 ospf6_area_show (vty, oa);
paul718e3742002-12-13 20:15:29 +00001133}
1134
hasso508e53e2004-05-18 18:57:06 +00001135/* show top level structures */
1136DEFUN (show_ipv6_ospf6,
1137 show_ipv6_ospf6_cmd,
1138 "show ipv6 ospf6",
1139 SHOW_STR
1140 IP6_STR
1141 OSPF6_STR)
paul718e3742002-12-13 20:15:29 +00001142{
hasso508e53e2004-05-18 18:57:06 +00001143 OSPF6_CMD_CHECK_RUNNING ();
paul718e3742002-12-13 20:15:29 +00001144
hasso508e53e2004-05-18 18:57:06 +00001145 ospf6_show (vty, ospf6);
1146 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00001147}
1148
1149DEFUN (show_ipv6_ospf6_route,
1150 show_ipv6_ospf6_route_cmd,
1151 "show ipv6 ospf6 route",
1152 SHOW_STR
1153 IP6_STR
1154 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001155 ROUTE_STR
paul718e3742002-12-13 20:15:29 +00001156 )
1157{
Vipin Kumarf972dec2015-05-19 18:03:41 -07001158 OSPF6_CMD_CHECK_RUNNING ();
1159
hasso508e53e2004-05-18 18:57:06 +00001160 ospf6_route_table_show (vty, argc, argv, ospf6->route_table);
1161 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00001162}
1163
1164ALIAS (show_ipv6_ospf6_route,
hasso508e53e2004-05-18 18:57:06 +00001165 show_ipv6_ospf6_route_detail_cmd,
hasso4846ef62004-09-03 06:04:00 +00001166 "show ipv6 ospf6 route (X:X::X:X|X:X::X:X/M|detail|summary)",
paul718e3742002-12-13 20:15:29 +00001167 SHOW_STR
1168 IP6_STR
1169 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001170 ROUTE_STR
1171 "Specify IPv6 address\n"
1172 "Specify IPv6 prefix\n"
1173 "Detailed information\n"
1174 "Summary of route table\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +01001175 )
paul718e3742002-12-13 20:15:29 +00001176
hasso508e53e2004-05-18 18:57:06 +00001177DEFUN (show_ipv6_ospf6_route_match,
1178 show_ipv6_ospf6_route_match_cmd,
hasso4846ef62004-09-03 06:04:00 +00001179 "show ipv6 ospf6 route X:X::X:X/M match",
paul718e3742002-12-13 20:15:29 +00001180 SHOW_STR
1181 IP6_STR
1182 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001183 ROUTE_STR
1184 "Specify IPv6 prefix\n"
1185 "Display routes which match the specified route\n"
paul718e3742002-12-13 20:15:29 +00001186 )
1187{
paul0c083ee2004-10-10 12:54:58 +00001188 const char *sargv[CMD_ARGC_MAX];
hasso508e53e2004-05-18 18:57:06 +00001189 int i, sargc;
1190
Vipin Kumarf972dec2015-05-19 18:03:41 -07001191 OSPF6_CMD_CHECK_RUNNING ();
1192
hasso508e53e2004-05-18 18:57:06 +00001193 /* copy argv to sargv and then append "match" */
1194 for (i = 0; i < argc; i++)
1195 sargv[i] = argv[i];
1196 sargc = argc;
1197 sargv[sargc++] = "match";
1198 sargv[sargc] = NULL;
1199
1200 ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
1201 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00001202}
1203
hasso508e53e2004-05-18 18:57:06 +00001204DEFUN (show_ipv6_ospf6_route_match_detail,
1205 show_ipv6_ospf6_route_match_detail_cmd,
hasso4846ef62004-09-03 06:04:00 +00001206 "show ipv6 ospf6 route X:X::X:X/M match detail",
paul718e3742002-12-13 20:15:29 +00001207 SHOW_STR
1208 IP6_STR
1209 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001210 ROUTE_STR
1211 "Specify IPv6 prefix\n"
1212 "Display routes which match the specified route\n"
paul718e3742002-12-13 20:15:29 +00001213 "Detailed information\n"
1214 )
hasso508e53e2004-05-18 18:57:06 +00001215{
paul0c083ee2004-10-10 12:54:58 +00001216 const char *sargv[CMD_ARGC_MAX];
hasso508e53e2004-05-18 18:57:06 +00001217 int i, sargc;
paul718e3742002-12-13 20:15:29 +00001218
hasso508e53e2004-05-18 18:57:06 +00001219 /* copy argv to sargv and then append "match" and "detail" */
1220 for (i = 0; i < argc; i++)
1221 sargv[i] = argv[i];
1222 sargc = argc;
1223 sargv[sargc++] = "match";
1224 sargv[sargc++] = "detail";
1225 sargv[sargc] = NULL;
paul718e3742002-12-13 20:15:29 +00001226
Vipin Kumarf972dec2015-05-19 18:03:41 -07001227 OSPF6_CMD_CHECK_RUNNING ();
1228
hasso508e53e2004-05-18 18:57:06 +00001229 ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
1230 return CMD_SUCCESS;
1231}
1232
Paul Jakmacb4b8842006-05-15 10:39:30 +00001233ALIAS (show_ipv6_ospf6_route_match,
1234 show_ipv6_ospf6_route_longer_cmd,
1235 "show ipv6 ospf6 route X:X::X:X/M longer",
1236 SHOW_STR
1237 IP6_STR
1238 OSPF6_STR
1239 ROUTE_STR
1240 "Specify IPv6 prefix\n"
1241 "Display routes longer than the specified route\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +01001242 )
Paul Jakmacb4b8842006-05-15 10:39:30 +00001243
1244DEFUN (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",
1247 SHOW_STR
1248 IP6_STR
1249 OSPF6_STR
1250 ROUTE_STR
1251 "Specify IPv6 prefix\n"
1252 "Display routes longer than the specified route\n"
1253 "Detailed information\n"
1254 );
1255
hasso4846ef62004-09-03 06:04:00 +00001256ALIAS (show_ipv6_ospf6_route,
1257 show_ipv6_ospf6_route_type_cmd,
1258 "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2)",
1259 SHOW_STR
1260 IP6_STR
1261 OSPF6_STR
1262 ROUTE_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +04001263 "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"
Paul Jakma6ac29a52008-08-15 13:45:30 +01001267 )
hasso4846ef62004-09-03 06:04:00 +00001268
1269DEFUN (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",
1272 SHOW_STR
1273 IP6_STR
1274 OSPF6_STR
1275 ROUTE_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +04001276 "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"
hasso4846ef62004-09-03 06:04:00 +00001280 "Detailed information\n"
1281 )
1282{
paul0c083ee2004-10-10 12:54:58 +00001283 const char *sargv[CMD_ARGC_MAX];
hasso4846ef62004-09-03 06:04:00 +00001284 int i, sargc;
1285
1286 /* copy argv to sargv and then append "detail" */
1287 for (i = 0; i < argc; i++)
1288 sargv[i] = argv[i];
1289 sargc = argc;
1290 sargv[sargc++] = "detail";
1291 sargv[sargc] = NULL;
1292
Vipin Kumarf972dec2015-05-19 18:03:41 -07001293 OSPF6_CMD_CHECK_RUNNING ();
1294
hasso4846ef62004-09-03 06:04:00 +00001295 ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
1296 return CMD_SUCCESS;
1297}
hasso508e53e2004-05-18 18:57:06 +00001298
Dinesh Duttf41b4a02013-08-24 08:00:37 +00001299static void
1300ospf6_stub_router_config_write (struct vty *vty)
1301{
1302 if (CHECK_FLAG (ospf6->flag, OSPF6_STUB_ROUTER))
1303 {
1304 vty_out (vty, " stub-router administrative%s", VNL);
1305 }
1306 return;
1307}
1308
Roman Hoog Antinkd8f7f862014-03-05 09:13:43 +01001309static int
1310ospf6_distance_config_write (struct vty *vty)
1311{
1312 struct route_node *rn;
1313 struct ospf6_distance *odistance;
1314
1315 if (ospf6->distance_all)
1316 vty_out (vty, " distance %d%s", ospf6->distance_all, VTY_NEWLINE);
1317
1318 if (ospf6->distance_intra
1319 || ospf6->distance_inter
1320 || ospf6->distance_external)
1321 {
1322 vty_out (vty, " distance ospf6");
1323
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);
1330
1331 vty_out (vty, "%s", VTY_NEWLINE);
1332 }
1333
1334 for (rn = route_top (ospf6->distance_table); rn; rn = route_next (rn))
1335 if ((odistance = rn->info) != NULL)
1336 {
1337 char pstr[128];
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 : "",
1341 VTY_NEWLINE);
1342 }
1343 return 0;
1344}
1345
hasso508e53e2004-05-18 18:57:06 +00001346/* OSPF configuration write function. */
Paul Jakma6ac29a52008-08-15 13:45:30 +01001347static int
hasso508e53e2004-05-18 18:57:06 +00001348config_write_ospf6 (struct vty *vty)
1349{
1350 char router_id[16];
hasso52dc7ee2004-09-23 19:18:23 +00001351 struct listnode *j, *k;
hasso508e53e2004-05-18 18:57:06 +00001352 struct ospf6_area *oa;
1353 struct ospf6_interface *oi;
1354
1355 /* OSPFv6 configuration. */
1356 if (ospf6 == NULL)
1357 return CMD_SUCCESS;
hasso508e53e2004-05-18 18:57:06 +00001358
hassoc8a440e2004-10-11 17:02:40 +00001359 inet_ntop (AF_INET, &ospf6->router_id_static, router_id, sizeof (router_id));
hasso049207c2004-08-04 20:02:13 +00001360 vty_out (vty, "router ospf6%s", VNL);
hassoc8a440e2004-10-11 17:02:40 +00001361 if (ospf6->router_id_static != 0)
1362 vty_out (vty, " router-id %s%s", router_id, VNL);
hasso508e53e2004-05-18 18:57:06 +00001363
Dinesh Dutt3d35ca42013-08-26 03:40:16 +00001364 /* log-adjacency-changes flag print. */
1365 if (CHECK_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES))
1366 {
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);
1371 }
1372
Vincent Bernatfd500682012-10-24 14:45:54 +00001373 if (ospf6->ref_bandwidth != OSPF6_REFERENCE_BANDWIDTH)
1374 vty_out (vty, " auto-cost reference-bandwidth %d%s", ospf6->ref_bandwidth / 1000,
1375 VNL);
1376
Dinesh Duttf41b4a02013-08-24 08:00:37 +00001377 ospf6_stub_router_config_write (vty);
hasso508e53e2004-05-18 18:57:06 +00001378 ospf6_redistribute_config_write (vty);
hasso6452df02004-08-15 05:52:07 +00001379 ospf6_area_config_write (vty);
Dinesh Dutt3810e062013-08-24 07:54:09 +00001380 ospf6_spf_config_write (vty);
Roman Hoog Antinkd8f7f862014-03-05 09:13:43 +01001381 ospf6_distance_config_write (vty);
hasso508e53e2004-05-18 18:57:06 +00001382
paul1eb8ef22005-04-07 07:30:20 +00001383 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, j, oa))
hasso508e53e2004-05-18 18:57:06 +00001384 {
paul1eb8ef22005-04-07 07:30:20 +00001385 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);
hasso508e53e2004-05-18 18:57:06 +00001388 }
hasso049207c2004-08-04 20:02:13 +00001389 vty_out (vty, "!%s", VNL);
hasso508e53e2004-05-18 18:57:06 +00001390 return 0;
1391}
1392
1393/* OSPF6 node structure. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08001394static struct cmd_node ospf6_node =
hasso508e53e2004-05-18 18:57:06 +00001395{
1396 OSPF6_NODE,
1397 "%s(config-ospf6)# ",
hasso69b4a812004-08-26 18:10:36 +00001398 1 /* VTYSH */
hasso508e53e2004-05-18 18:57:06 +00001399};
1400
1401/* Install ospf related commands. */
paul718e3742002-12-13 20:15:29 +00001402void
Paul Jakma6ac29a52008-08-15 13:45:30 +01001403ospf6_top_init (void)
paul718e3742002-12-13 20:15:29 +00001404{
hasso508e53e2004-05-18 18:57:06 +00001405 /* Install ospf6 top node. */
1406 install_node (&ospf6_node, config_write_ospf6);
1407
1408 install_element (VIEW_NODE, &show_ipv6_ospf6_cmd);
hasso508e53e2004-05-18 18:57:06 +00001409 install_element (CONFIG_NODE, &router_ospf6_cmd);
Jon6c19d262009-02-11 17:19:07 -08001410 install_element (CONFIG_NODE, &no_router_ospf6_cmd);
hasso508e53e2004-05-18 18:57:06 +00001411
paul718e3742002-12-13 20:15:29 +00001412 install_element (VIEW_NODE, &show_ipv6_ospf6_route_cmd);
hasso508e53e2004-05-18 18:57:06 +00001413 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);
Paul Jakmacb4b8842006-05-15 10:39:30 +00001416 install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_cmd);
1417 install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_detail_cmd);
hasso4846ef62004-09-03 06:04:00 +00001418 install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_cmd);
1419 install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_detail_cmd);
hasso508e53e2004-05-18 18:57:06 +00001420
1421 install_default (OSPF6_NODE);
1422 install_element (OSPF6_NODE, &ospf6_router_id_cmd);
Dinesh Dutt3d35ca42013-08-26 03:40:16 +00001423 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);
hasso508e53e2004-05-18 18:57:06 +00001427 install_element (OSPF6_NODE, &ospf6_interface_area_cmd);
1428 install_element (OSPF6_NODE, &no_ospf6_interface_area_cmd);
Dinesh Duttf41b4a02013-08-24 08:00:37 +00001429 install_element (OSPF6_NODE, &ospf6_stub_router_admin_cmd);
1430 install_element (OSPF6_NODE, &no_ospf6_stub_router_admin_cmd);
1431 /* For a later time
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);
1436 */
Roman Hoog Antinkd8f7f862014-03-05 09:13:43 +01001437
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);
1456
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);
paul718e3742002-12-13 20:15:29 +00001461}
1462
hasso508e53e2004-05-18 18:57:06 +00001463