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