blob: 145a88e5a60cb9cbe77bc8a9d25285d63d36ff7d [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{
hasso508e53e2004-05-18 18:57:06 +00001158 ospf6_route_table_show (vty, argc, argv, ospf6->route_table);
1159 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00001160}
1161
1162ALIAS (show_ipv6_ospf6_route,
hasso508e53e2004-05-18 18:57:06 +00001163 show_ipv6_ospf6_route_detail_cmd,
hasso4846ef62004-09-03 06:04:00 +00001164 "show ipv6 ospf6 route (X:X::X:X|X:X::X:X/M|detail|summary)",
paul718e3742002-12-13 20:15:29 +00001165 SHOW_STR
1166 IP6_STR
1167 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001168 ROUTE_STR
1169 "Specify IPv6 address\n"
1170 "Specify IPv6 prefix\n"
1171 "Detailed information\n"
1172 "Summary of route table\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +01001173 )
paul718e3742002-12-13 20:15:29 +00001174
hasso508e53e2004-05-18 18:57:06 +00001175DEFUN (show_ipv6_ospf6_route_match,
1176 show_ipv6_ospf6_route_match_cmd,
hasso4846ef62004-09-03 06:04:00 +00001177 "show ipv6 ospf6 route X:X::X:X/M match",
paul718e3742002-12-13 20:15:29 +00001178 SHOW_STR
1179 IP6_STR
1180 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001181 ROUTE_STR
1182 "Specify IPv6 prefix\n"
1183 "Display routes which match the specified route\n"
paul718e3742002-12-13 20:15:29 +00001184 )
1185{
paul0c083ee2004-10-10 12:54:58 +00001186 const char *sargv[CMD_ARGC_MAX];
hasso508e53e2004-05-18 18:57:06 +00001187 int i, sargc;
1188
1189 /* copy argv to sargv and then append "match" */
1190 for (i = 0; i < argc; i++)
1191 sargv[i] = argv[i];
1192 sargc = argc;
1193 sargv[sargc++] = "match";
1194 sargv[sargc] = NULL;
1195
1196 ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
1197 return CMD_SUCCESS;
paul718e3742002-12-13 20:15:29 +00001198}
1199
hasso508e53e2004-05-18 18:57:06 +00001200DEFUN (show_ipv6_ospf6_route_match_detail,
1201 show_ipv6_ospf6_route_match_detail_cmd,
hasso4846ef62004-09-03 06:04:00 +00001202 "show ipv6 ospf6 route X:X::X:X/M match detail",
paul718e3742002-12-13 20:15:29 +00001203 SHOW_STR
1204 IP6_STR
1205 OSPF6_STR
hasso508e53e2004-05-18 18:57:06 +00001206 ROUTE_STR
1207 "Specify IPv6 prefix\n"
1208 "Display routes which match the specified route\n"
paul718e3742002-12-13 20:15:29 +00001209 "Detailed information\n"
1210 )
hasso508e53e2004-05-18 18:57:06 +00001211{
paul0c083ee2004-10-10 12:54:58 +00001212 const char *sargv[CMD_ARGC_MAX];
hasso508e53e2004-05-18 18:57:06 +00001213 int i, sargc;
paul718e3742002-12-13 20:15:29 +00001214
hasso508e53e2004-05-18 18:57:06 +00001215 /* copy argv to sargv and then append "match" and "detail" */
1216 for (i = 0; i < argc; i++)
1217 sargv[i] = argv[i];
1218 sargc = argc;
1219 sargv[sargc++] = "match";
1220 sargv[sargc++] = "detail";
1221 sargv[sargc] = NULL;
paul718e3742002-12-13 20:15:29 +00001222
hasso508e53e2004-05-18 18:57:06 +00001223 ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
1224 return CMD_SUCCESS;
1225}
1226
Paul Jakmacb4b8842006-05-15 10:39:30 +00001227ALIAS (show_ipv6_ospf6_route_match,
1228 show_ipv6_ospf6_route_longer_cmd,
1229 "show ipv6 ospf6 route X:X::X:X/M longer",
1230 SHOW_STR
1231 IP6_STR
1232 OSPF6_STR
1233 ROUTE_STR
1234 "Specify IPv6 prefix\n"
1235 "Display routes longer than the specified route\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +01001236 )
Paul Jakmacb4b8842006-05-15 10:39:30 +00001237
1238DEFUN (show_ipv6_ospf6_route_match_detail,
1239 show_ipv6_ospf6_route_longer_detail_cmd,
1240 "show ipv6 ospf6 route X:X::X:X/M longer detail",
1241 SHOW_STR
1242 IP6_STR
1243 OSPF6_STR
1244 ROUTE_STR
1245 "Specify IPv6 prefix\n"
1246 "Display routes longer than the specified route\n"
1247 "Detailed information\n"
1248 );
1249
hasso4846ef62004-09-03 06:04:00 +00001250ALIAS (show_ipv6_ospf6_route,
1251 show_ipv6_ospf6_route_type_cmd,
1252 "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2)",
1253 SHOW_STR
1254 IP6_STR
1255 OSPF6_STR
1256 ROUTE_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +04001257 "Display Intra-Area routes\n"
1258 "Display Inter-Area routes\n"
1259 "Display Type-1 External routes\n"
1260 "Display Type-2 External routes\n"
Paul Jakma6ac29a52008-08-15 13:45:30 +01001261 )
hasso4846ef62004-09-03 06:04:00 +00001262
1263DEFUN (show_ipv6_ospf6_route_type_detail,
1264 show_ipv6_ospf6_route_type_detail_cmd,
1265 "show ipv6 ospf6 route (intra-area|inter-area|external-1|external-2) detail",
1266 SHOW_STR
1267 IP6_STR
1268 OSPF6_STR
1269 ROUTE_STR
Denis Ovsienkoea402192011-08-19 16:27:16 +04001270 "Display Intra-Area routes\n"
1271 "Display Inter-Area routes\n"
1272 "Display Type-1 External routes\n"
1273 "Display Type-2 External routes\n"
hasso4846ef62004-09-03 06:04:00 +00001274 "Detailed information\n"
1275 )
1276{
paul0c083ee2004-10-10 12:54:58 +00001277 const char *sargv[CMD_ARGC_MAX];
hasso4846ef62004-09-03 06:04:00 +00001278 int i, sargc;
1279
1280 /* copy argv to sargv and then append "detail" */
1281 for (i = 0; i < argc; i++)
1282 sargv[i] = argv[i];
1283 sargc = argc;
1284 sargv[sargc++] = "detail";
1285 sargv[sargc] = NULL;
1286
1287 ospf6_route_table_show (vty, sargc, sargv, ospf6->route_table);
1288 return CMD_SUCCESS;
1289}
hasso508e53e2004-05-18 18:57:06 +00001290
Dinesh Duttf41b4a02013-08-24 08:00:37 +00001291static void
1292ospf6_stub_router_config_write (struct vty *vty)
1293{
1294 if (CHECK_FLAG (ospf6->flag, OSPF6_STUB_ROUTER))
1295 {
1296 vty_out (vty, " stub-router administrative%s", VNL);
1297 }
1298 return;
1299}
1300
Roman Hoog Antinkd8f7f862014-03-05 09:13:43 +01001301static int
1302ospf6_distance_config_write (struct vty *vty)
1303{
1304 struct route_node *rn;
1305 struct ospf6_distance *odistance;
1306
1307 if (ospf6->distance_all)
1308 vty_out (vty, " distance %d%s", ospf6->distance_all, VTY_NEWLINE);
1309
1310 if (ospf6->distance_intra
1311 || ospf6->distance_inter
1312 || ospf6->distance_external)
1313 {
1314 vty_out (vty, " distance ospf6");
1315
1316 if (ospf6->distance_intra)
1317 vty_out (vty, " intra-area %d", ospf6->distance_intra);
1318 if (ospf6->distance_inter)
1319 vty_out (vty, " inter-area %d", ospf6->distance_inter);
1320 if (ospf6->distance_external)
1321 vty_out (vty, " external %d", ospf6->distance_external);
1322
1323 vty_out (vty, "%s", VTY_NEWLINE);
1324 }
1325
1326 for (rn = route_top (ospf6->distance_table); rn; rn = route_next (rn))
1327 if ((odistance = rn->info) != NULL)
1328 {
1329 char pstr[128];
1330 vty_out (vty, " distance %d %s %s%s", odistance->distance,
1331 prefix2str (&rn->p, pstr, sizeof(pstr)),
1332 odistance->access_list ? odistance->access_list : "",
1333 VTY_NEWLINE);
1334 }
1335 return 0;
1336}
1337
hasso508e53e2004-05-18 18:57:06 +00001338/* OSPF configuration write function. */
Paul Jakma6ac29a52008-08-15 13:45:30 +01001339static int
hasso508e53e2004-05-18 18:57:06 +00001340config_write_ospf6 (struct vty *vty)
1341{
1342 char router_id[16];
hasso52dc7ee2004-09-23 19:18:23 +00001343 struct listnode *j, *k;
hasso508e53e2004-05-18 18:57:06 +00001344 struct ospf6_area *oa;
1345 struct ospf6_interface *oi;
1346
1347 /* OSPFv6 configuration. */
1348 if (ospf6 == NULL)
1349 return CMD_SUCCESS;
hasso508e53e2004-05-18 18:57:06 +00001350
hassoc8a440e2004-10-11 17:02:40 +00001351 inet_ntop (AF_INET, &ospf6->router_id_static, router_id, sizeof (router_id));
hasso049207c2004-08-04 20:02:13 +00001352 vty_out (vty, "router ospf6%s", VNL);
hassoc8a440e2004-10-11 17:02:40 +00001353 if (ospf6->router_id_static != 0)
1354 vty_out (vty, " router-id %s%s", router_id, VNL);
hasso508e53e2004-05-18 18:57:06 +00001355
Dinesh Dutt3d35ca42013-08-26 03:40:16 +00001356 /* log-adjacency-changes flag print. */
1357 if (CHECK_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_CHANGES))
1358 {
1359 vty_out(vty, " log-adjacency-changes");
1360 if (CHECK_FLAG(ospf6->config_flags, OSPF6_LOG_ADJACENCY_DETAIL))
1361 vty_out(vty, " detail");
1362 vty_out(vty, "%s", VTY_NEWLINE);
1363 }
1364
Vincent Bernatfd500682012-10-24 14:45:54 +00001365 if (ospf6->ref_bandwidth != OSPF6_REFERENCE_BANDWIDTH)
1366 vty_out (vty, " auto-cost reference-bandwidth %d%s", ospf6->ref_bandwidth / 1000,
1367 VNL);
1368
Dinesh Duttf41b4a02013-08-24 08:00:37 +00001369 ospf6_stub_router_config_write (vty);
hasso508e53e2004-05-18 18:57:06 +00001370 ospf6_redistribute_config_write (vty);
hasso6452df02004-08-15 05:52:07 +00001371 ospf6_area_config_write (vty);
Dinesh Dutt3810e062013-08-24 07:54:09 +00001372 ospf6_spf_config_write (vty);
Roman Hoog Antinkd8f7f862014-03-05 09:13:43 +01001373 ospf6_distance_config_write (vty);
hasso508e53e2004-05-18 18:57:06 +00001374
paul1eb8ef22005-04-07 07:30:20 +00001375 for (ALL_LIST_ELEMENTS_RO (ospf6->area_list, j, oa))
hasso508e53e2004-05-18 18:57:06 +00001376 {
paul1eb8ef22005-04-07 07:30:20 +00001377 for (ALL_LIST_ELEMENTS_RO (oa->if_list, k, oi))
1378 vty_out (vty, " interface %s area %s%s",
1379 oi->interface->name, oa->name, VNL);
hasso508e53e2004-05-18 18:57:06 +00001380 }
hasso049207c2004-08-04 20:02:13 +00001381 vty_out (vty, "!%s", VNL);
hasso508e53e2004-05-18 18:57:06 +00001382 return 0;
1383}
1384
1385/* OSPF6 node structure. */
Stephen Hemminger7fc626d2008-12-01 11:10:34 -08001386static struct cmd_node ospf6_node =
hasso508e53e2004-05-18 18:57:06 +00001387{
1388 OSPF6_NODE,
1389 "%s(config-ospf6)# ",
hasso69b4a812004-08-26 18:10:36 +00001390 1 /* VTYSH */
hasso508e53e2004-05-18 18:57:06 +00001391};
1392
1393/* Install ospf related commands. */
paul718e3742002-12-13 20:15:29 +00001394void
Paul Jakma6ac29a52008-08-15 13:45:30 +01001395ospf6_top_init (void)
paul718e3742002-12-13 20:15:29 +00001396{
hasso508e53e2004-05-18 18:57:06 +00001397 /* Install ospf6 top node. */
1398 install_node (&ospf6_node, config_write_ospf6);
1399
1400 install_element (VIEW_NODE, &show_ipv6_ospf6_cmd);
hasso508e53e2004-05-18 18:57:06 +00001401 install_element (CONFIG_NODE, &router_ospf6_cmd);
Jon6c19d262009-02-11 17:19:07 -08001402 install_element (CONFIG_NODE, &no_router_ospf6_cmd);
hasso508e53e2004-05-18 18:57:06 +00001403
paul718e3742002-12-13 20:15:29 +00001404 install_element (VIEW_NODE, &show_ipv6_ospf6_route_cmd);
hasso508e53e2004-05-18 18:57:06 +00001405 install_element (VIEW_NODE, &show_ipv6_ospf6_route_detail_cmd);
1406 install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_cmd);
1407 install_element (VIEW_NODE, &show_ipv6_ospf6_route_match_detail_cmd);
Paul Jakmacb4b8842006-05-15 10:39:30 +00001408 install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_cmd);
1409 install_element (VIEW_NODE, &show_ipv6_ospf6_route_longer_detail_cmd);
hasso4846ef62004-09-03 06:04:00 +00001410 install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_cmd);
1411 install_element (VIEW_NODE, &show_ipv6_ospf6_route_type_detail_cmd);
hasso508e53e2004-05-18 18:57:06 +00001412
1413 install_default (OSPF6_NODE);
1414 install_element (OSPF6_NODE, &ospf6_router_id_cmd);
Dinesh Dutt3d35ca42013-08-26 03:40:16 +00001415 install_element (OSPF6_NODE, &ospf6_log_adjacency_changes_cmd);
1416 install_element (OSPF6_NODE, &ospf6_log_adjacency_changes_detail_cmd);
1417 install_element (OSPF6_NODE, &no_ospf6_log_adjacency_changes_cmd);
1418 install_element (OSPF6_NODE, &no_ospf6_log_adjacency_changes_detail_cmd);
hasso508e53e2004-05-18 18:57:06 +00001419 install_element (OSPF6_NODE, &ospf6_interface_area_cmd);
1420 install_element (OSPF6_NODE, &no_ospf6_interface_area_cmd);
Dinesh Duttf41b4a02013-08-24 08:00:37 +00001421 install_element (OSPF6_NODE, &ospf6_stub_router_admin_cmd);
1422 install_element (OSPF6_NODE, &no_ospf6_stub_router_admin_cmd);
1423 /* For a later time
1424 install_element (OSPF6_NODE, &ospf6_stub_router_startup_cmd);
1425 install_element (OSPF6_NODE, &no_ospf6_stub_router_startup_cmd);
1426 install_element (OSPF6_NODE, &ospf6_stub_router_shutdown_cmd);
1427 install_element (OSPF6_NODE, &no_ospf6_stub_router_shutdown_cmd);
1428 */
Roman Hoog Antinkd8f7f862014-03-05 09:13:43 +01001429
1430 install_element (OSPF6_NODE, &ospf6_distance_cmd);
1431 install_element (OSPF6_NODE, &no_ospf6_distance_cmd);
1432 install_element (OSPF6_NODE, &no_ospf6_distance_ospf6_cmd);
1433 install_element (OSPF6_NODE, &ospf6_distance_ospf6_intra_cmd);
1434 install_element (OSPF6_NODE, &ospf6_distance_ospf6_intra_inter_cmd);
1435 install_element (OSPF6_NODE, &ospf6_distance_ospf6_intra_external_cmd);
1436 install_element (OSPF6_NODE, &ospf6_distance_ospf6_intra_inter_external_cmd);
1437 install_element (OSPF6_NODE, &ospf6_distance_ospf6_intra_external_inter_cmd);
1438 install_element (OSPF6_NODE, &ospf6_distance_ospf6_inter_cmd);
1439 install_element (OSPF6_NODE, &ospf6_distance_ospf6_inter_intra_cmd);
1440 install_element (OSPF6_NODE, &ospf6_distance_ospf6_inter_external_cmd);
1441 install_element (OSPF6_NODE, &ospf6_distance_ospf6_inter_intra_external_cmd);
1442 install_element (OSPF6_NODE, &ospf6_distance_ospf6_inter_external_intra_cmd);
1443 install_element (OSPF6_NODE, &ospf6_distance_ospf6_external_cmd);
1444 install_element (OSPF6_NODE, &ospf6_distance_ospf6_external_intra_cmd);
1445 install_element (OSPF6_NODE, &ospf6_distance_ospf6_external_inter_cmd);
1446 install_element (OSPF6_NODE, &ospf6_distance_ospf6_external_intra_inter_cmd);
1447 install_element (OSPF6_NODE, &ospf6_distance_ospf6_external_inter_intra_cmd);
1448
1449 install_element (OSPF6_NODE, &ospf6_distance_source_cmd);
1450 install_element (OSPF6_NODE, &no_ospf6_distance_source_cmd);
1451 install_element (OSPF6_NODE, &ospf6_distance_source_access_list_cmd);
1452 install_element (OSPF6_NODE, &no_ospf6_distance_source_access_list_cmd);
paul718e3742002-12-13 20:15:29 +00001453}
1454
hasso508e53e2004-05-18 18:57:06 +00001455