]> git.proxmox.com Git - mirror_frr.git/blame - ospfd/ospf_vty.c
*: track version & "defaults" in configs
[mirror_frr.git] / ospfd / ospf_vty.c
CommitLineData
718e3744 1/* OSPF VTY interface.
ba682537 2 * Copyright (C) 2005 6WIND <alain.ritoux@6wind.com>
718e3744 3 * Copyright (C) 2000 Toshiaki Takada
4 *
5 * This file is part of GNU Zebra.
6 *
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
10 * later version.
11 *
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 * 02111-1307, USA.
21 */
22
23#include <zebra.h>
91756b38 24#include <lib/json.h>
7ec4159b 25#include <string.h>
718e3744 26
27#include "memory.h"
28#include "thread.h"
29#include "prefix.h"
30#include "table.h"
31#include "vty.h"
32#include "command.h"
33#include "plist.h"
34#include "log.h"
35#include "zclient.h"
8efe88ea 36#include "defaults.h"
718e3744 37
38#include "ospfd/ospfd.h"
39#include "ospfd/ospf_asbr.h"
40#include "ospfd/ospf_lsa.h"
41#include "ospfd/ospf_lsdb.h"
42#include "ospfd/ospf_ism.h"
43#include "ospfd/ospf_interface.h"
44#include "ospfd/ospf_nsm.h"
45#include "ospfd/ospf_neighbor.h"
46#include "ospfd/ospf_flood.h"
47#include "ospfd/ospf_abr.h"
48#include "ospfd/ospf_spf.h"
49#include "ospfd/ospf_route.h"
50#include "ospfd/ospf_zebra.h"
51/*#include "ospfd/ospf_routemap.h" */
52#include "ospfd/ospf_vty.h"
53#include "ospfd/ospf_dump.h"
7f342629 54#include "ospfd/ospf_bfd.h"
718e3744 55
30a2231a 56static const char *ospf_network_type_str[] =
718e3744 57{
58 "Null",
59 "POINTOPOINT",
60 "BROADCAST",
61 "NBMA",
62 "POINTOMULTIPOINT",
63 "VIRTUALLINK",
64 "LOOPBACK"
65};
66
718e3744 67/* Utility functions. */
16f1b9ee 68int
6c835671 69ospf_str2area_id (const char *str, struct in_addr *area_id, int *format)
718e3744 70{
71 char *endptr = NULL;
72 unsigned long ret;
73
74 /* match "A.B.C.D". */
75 if (strchr (str, '.') != NULL)
76 {
77 ret = inet_aton (str, area_id);
78 if (!ret)
79 return -1;
80 *format = OSPF_AREA_ID_FORMAT_ADDRESS;
81 }
82 /* match "<0-4294967295>". */
83 else
84 {
664711c1
UW
85 if (*str == '-')
86 return -1;
87 errno = 0;
718e3744 88 ret = strtoul (str, &endptr, 10);
664711c1 89 if (*endptr != '\0' || errno || ret > UINT32_MAX)
718e3744 90 return -1;
91
92 area_id->s_addr = htonl (ret);
93 *format = OSPF_AREA_ID_FORMAT_DECIMAL;
94 }
95
96 return 0;
97}
98
6b0655a2 99
4dadc291 100static int
6c835671 101str2metric (const char *str, int *metric)
718e3744 102{
103 /* Sanity check. */
104 if (str == NULL)
105 return 0;
106
107 *metric = strtol (str, NULL, 10);
108 if (*metric < 0 && *metric > 16777214)
109 {
110 /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */
111 return 0;
112 }
113
114 return 1;
115}
116
4dadc291 117static int
6c835671 118str2metric_type (const char *str, int *metric_type)
718e3744 119{
120 /* Sanity check. */
121 if (str == NULL)
122 return 0;
123
124 if (strncmp (str, "1", 1) == 0)
125 *metric_type = EXTERNAL_METRIC_TYPE_1;
126 else if (strncmp (str, "2", 1) == 0)
127 *metric_type = EXTERNAL_METRIC_TYPE_2;
128 else
129 return 0;
130
131 return 1;
132}
133
134int
135ospf_oi_count (struct interface *ifp)
136{
137 struct route_node *rn;
138 int i = 0;
139
140 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
141 if (rn->info)
142 i++;
143
144 return i;
145}
146
6b0655a2 147
718e3744 148DEFUN (router_ospf,
149 router_ospf_cmd,
150 "router ospf",
151 "Enable a routing process\n"
152 "Start OSPF configuration\n")
153{
7c8ff89e
DS
154 struct ospf *ospf;
155 u_short instance = 0;
156
157 ospf = ospf_lookup();
158 if (!ospf)
159 {
160 vty_out (vty, "There isn't active ospf instance %s", VTY_NEWLINE);
161 return CMD_WARNING;
162 }
163
718e3744 164 vty->node = OSPF_NODE;
7c8ff89e
DS
165
166 if (argc)
167 VTY_GET_INTEGER ("Instance", instance, argv[0]);
168
169 /* The following logic to set the vty->index is in place to be able
170 to ignore the commands which dont belong to this instance. */
171 if (ospf->instance != instance)
172 vty->index = NULL;
173 else
0bad4851
DS
174 {
175 if (IS_DEBUG_OSPF_EVENT)
176 zlog_debug ("Config command 'router ospf %d' received", instance);
177 ospf->oi_running = 1;
178 vty->index = ospf;
179 ospf_router_id_update (ospf);
180 }
718e3744 181
182 return CMD_SUCCESS;
183}
184
7c8ff89e
DS
185ALIAS (router_ospf,
186 router_ospf_instance_cmd,
187 "router ospf <1-65535>",
188 "Enable a routing process\n"
189 "Start OSPF configuration\n"
190 "Instance ID\n")
191
718e3744 192DEFUN (no_router_ospf,
193 no_router_ospf_cmd,
194 "no router ospf",
195 NO_STR
196 "Enable a routing process\n"
197 "Start OSPF configuration\n")
198{
020709f9 199 struct ospf *ospf;
7c8ff89e 200 u_short instance = 0;
020709f9 201
7c8ff89e
DS
202 if (argc)
203 VTY_GET_INTEGER ("Instance", instance, argv[0]);
204
205 if ((ospf = ospf_lookup_instance (instance)) == NULL)
206 return CMD_SUCCESS;
718e3744 207
020709f9 208 ospf_finish (ospf);
718e3744 209
210 return CMD_SUCCESS;
211}
212
7c8ff89e
DS
213ALIAS (no_router_ospf,
214 no_router_ospf_instance_cmd,
215 "no router ospf <1-65535>",
216 NO_STR
217 "Enable a routing process\n"
218 "Start OSPF configuration\n"
219 "Instance ID\n")
220
718e3744 221DEFUN (ospf_router_id,
222 ospf_router_id_cmd,
223 "ospf router-id A.B.C.D",
224 "OSPF specific commands\n"
225 "router-id for the OSPF process\n"
226 "OSPF router-id in IP address format\n")
227{
68980084 228 struct ospf *ospf = vty->index;
2c19a6ec
DS
229 struct listnode *node;
230 struct ospf_area *area;
718e3744 231 struct in_addr router_id;
68980084 232 int ret;
718e3744 233
7c8ff89e
DS
234 if (!ospf)
235 return CMD_SUCCESS;
236
718e3744 237 ret = inet_aton (argv[0], &router_id);
238 if (!ret)
239 {
240 vty_out (vty, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE);
241 return CMD_WARNING;
242 }
243
68980084 244 ospf->router_id_static = router_id;
2c19a6ec
DS
245
246 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
247 if (area->full_nbrs)
248 {
249 vty_out (vty, "For this router-id change to take effect,"
250 " save config and restart ospfd%s", VTY_NEWLINE);
251 return CMD_SUCCESS;
252 }
253
b29800a6 254 ospf_router_id_update (ospf);
255
718e3744 256 return CMD_SUCCESS;
257}
258
747e489c
DW
259ALIAS_HIDDEN (ospf_router_id,
260 ospf_router_id_old_cmd,
261 "router-id A.B.C.D",
262 "router-id for the OSPF process\n"
263 "OSPF router-id in IP address format\n")
264
718e3744 265DEFUN (no_ospf_router_id,
266 no_ospf_router_id_cmd,
267 "no ospf router-id",
268 NO_STR
269 "OSPF specific commands\n"
270 "router-id for the OSPF process\n")
271{
68980084 272 struct ospf *ospf = vty->index;
2c19a6ec
DS
273 struct listnode *node;
274 struct ospf_area *area;
68980084 275
7c8ff89e
DS
276 if (!ospf)
277 return CMD_SUCCESS;
278
68980084 279 ospf->router_id_static.s_addr = 0;
718e3744 280
2c19a6ec
DS
281 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
282 if (area->full_nbrs)
283 {
284 vty_out (vty, "For this router-id change to take effect,"
285 " save config and restart ospfd%s", VTY_NEWLINE);
286 return CMD_SUCCESS;
287 }
288
68980084 289 ospf_router_id_update (ospf);
718e3744 290
291 return CMD_SUCCESS;
292}
293
294ALIAS (no_ospf_router_id,
12fde75b
DW
295 no_ospf_router_id_val_cmd,
296 "no ospf router-id A.B.C.D",
718e3744 297 NO_STR
12fde75b
DW
298 "OSPF specific commands\n"
299 "router-id for the OSPF process\n"
300 "OSPF router-id in IP address format\n")
718e3744 301
7ffa8fa2 302static void
43540886 303ospf_passive_interface_default (struct ospf *ospf, u_char newval)
7ffa8fa2
PJ
304{
305 struct listnode *ln;
306 struct interface *ifp;
307 struct ospf_interface *oi;
308
43540886
AS
309 ospf->passive_interface_default = newval;
310
7ffa8fa2
PJ
311 for (ALL_LIST_ELEMENTS_RO (om->iflist, ln, ifp))
312 {
313 if (ifp &&
314 OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface))
315 UNSET_IF_PARAM (IF_DEF_PARAMS (ifp), passive_interface);
316 }
317 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, ln, oi))
318 {
319 if (OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface))
320 UNSET_IF_PARAM (oi->params, passive_interface);
43540886
AS
321 /* update multicast memberships */
322 ospf_if_set_multicast(oi);
7ffa8fa2
PJ
323 }
324}
325
326static void
f842f166
PJ
327ospf_passive_interface_update_addr (struct ospf *ospf, struct interface *ifp,
328 struct ospf_if_params *params, u_char value,
329 struct in_addr addr)
7ffa8fa2
PJ
330{
331 u_char dflt;
332
333 params->passive_interface = value;
334 if (params != IF_DEF_PARAMS (ifp))
335 {
336 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface))
337 dflt = IF_DEF_PARAMS (ifp)->passive_interface;
338 else
339 dflt = ospf->passive_interface_default;
340
341 if (value != dflt)
342 SET_IF_PARAM (params, passive_interface);
343 else
344 UNSET_IF_PARAM (params, passive_interface);
345
346 ospf_free_if_params (ifp, addr);
347 ospf_if_update_params (ifp, addr);
348 }
f842f166
PJ
349}
350
351static void
352ospf_passive_interface_update (struct ospf *ospf, struct interface *ifp,
353 struct ospf_if_params *params, u_char value)
354{
355 params->passive_interface = value;
356 if (params == IF_DEF_PARAMS (ifp))
7ffa8fa2
PJ
357 {
358 if (value != ospf->passive_interface_default)
359 SET_IF_PARAM (params, passive_interface);
360 else
361 UNSET_IF_PARAM (params, passive_interface);
362 }
363}
364
a2c62831 365DEFUN (ospf_passive_interface,
366 ospf_passive_interface_addr_cmd,
718e3744 367 "passive-interface IFNAME A.B.C.D",
368 "Suppress routing updates on an interface\n"
369 "Interface's name\n")
370{
7ffa8fa2 371 struct interface *ifp;
cb2af5d0 372 struct in_addr addr = { .s_addr = INADDR_ANY };
7ffa8fa2
PJ
373 int ret;
374 struct ospf_if_params *params;
375 struct route_node *rn;
376 struct ospf *ospf = vty->index;
718e3744 377
7c8ff89e
DS
378 if (!ospf)
379 return CMD_SUCCESS;
380
43540886
AS
381 if (argc == 0)
382 {
383 ospf_passive_interface_default (ospf, OSPF_IF_PASSIVE);
384 return CMD_SUCCESS;
385 }
386
7ffa8fa2 387 ifp = if_get_by_name (argv[0]);
718e3744 388
389 params = IF_DEF_PARAMS (ifp);
390
43540886 391 if (argc == 2)
718e3744 392 {
43540886
AS
393 ret = inet_aton(argv[1], &addr);
394 if (!ret)
395 {
396 vty_out (vty, "Please specify interface address by A.B.C.D%s",
397 VTY_NEWLINE);
398 return CMD_WARNING;
399 }
400
401 params = ospf_get_if_params (ifp, addr);
402 ospf_if_update_params (ifp, addr);
f842f166
PJ
403 ospf_passive_interface_update_addr (ospf, ifp, params,
404 OSPF_IF_PASSIVE, addr);
7ffa8fa2 405 }
f842f166
PJ
406
407 ospf_passive_interface_update (ospf, ifp, params, OSPF_IF_PASSIVE);
43540886 408
ba6454ec 409 /* XXX We should call ospf_if_set_multicast on exactly those
410 * interfaces for which the passive property changed. It is too much
411 * work to determine this set, so we do this for every interface.
412 * This is safe and reasonable because ospf_if_set_multicast uses a
413 * record of joined groups to avoid systems calls if the desired
414 * memberships match the current memership.
415 */
7ffa8fa2 416
ba6454ec 417 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
418 {
419 struct ospf_interface *oi = rn->info;
420
421 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_PASSIVE))
43540886 422 ospf_if_set_multicast(oi);
ba6454ec 423 }
424 /*
425 * XXX It is not clear what state transitions the interface needs to
426 * undergo when going from active to passive. Fixing this will
427 * require precise identification of interfaces having such a
428 * transition.
429 */
430
718e3744 431 return CMD_SUCCESS;
432}
433
a2c62831 434ALIAS (ospf_passive_interface,
435 ospf_passive_interface_cmd,
718e3744 436 "passive-interface IFNAME",
437 "Suppress routing updates on an interface\n"
438 "Interface's name\n")
439
7ffa8fa2
PJ
440ALIAS (ospf_passive_interface,
441 ospf_passive_interface_default_cmd,
442 "passive-interface default",
443 "Suppress routing updates on an interface\n"
444 "Suppress routing updates on interfaces by default\n")
445
a2c62831 446DEFUN (no_ospf_passive_interface,
447 no_ospf_passive_interface_addr_cmd,
718e3744 448 "no passive-interface IFNAME A.B.C.D",
449 NO_STR
450 "Allow routing updates on an interface\n"
451 "Interface's name\n")
452{
453 struct interface *ifp;
cb2af5d0 454 struct in_addr addr = { .s_addr = INADDR_ANY };
718e3744 455 struct ospf_if_params *params;
456 int ret;
ba6454ec 457 struct route_node *rn;
7ffa8fa2 458 struct ospf *ospf = vty->index;
43540886 459
7c8ff89e
DS
460 if (!ospf)
461 return CMD_SUCCESS;
462
43540886
AS
463 if (argc == 0)
464 {
465 ospf_passive_interface_default (ospf, OSPF_IF_ACTIVE);
466 return CMD_SUCCESS;
467 }
718e3744 468
6e72cb6a 469 ifp = if_get_by_name (argv[0]);
718e3744 470
471 params = IF_DEF_PARAMS (ifp);
472
43540886 473 if (argc == 2)
718e3744 474 {
43540886
AS
475 ret = inet_aton(argv[1], &addr);
476 if (!ret)
477 {
478 vty_out (vty, "Please specify interface address by A.B.C.D%s",
479 VTY_NEWLINE);
480 return CMD_WARNING;
481 }
482
483 params = ospf_lookup_if_params (ifp, addr);
484 if (params == NULL)
485 return CMD_SUCCESS;
f842f166
PJ
486 ospf_passive_interface_update_addr (ospf, ifp, params, OSPF_IF_ACTIVE,
487 addr);
718e3744 488 }
f842f166
PJ
489 ospf_passive_interface_update (ospf, ifp, params, OSPF_IF_ACTIVE);
490
ba6454ec 491 /* XXX We should call ospf_if_set_multicast on exactly those
492 * interfaces for which the passive property changed. It is too much
493 * work to determine this set, so we do this for every interface.
494 * This is safe and reasonable because ospf_if_set_multicast uses a
495 * record of joined groups to avoid systems calls if the desired
496 * memberships match the current memership.
497 */
498 for (rn = route_top(IF_OIFS(ifp)); rn; rn = route_next (rn))
499 {
500 struct ospf_interface *oi = rn->info;
501
502 if (oi && (OSPF_IF_PARAM(oi, passive_interface) == OSPF_IF_ACTIVE))
503 ospf_if_set_multicast(oi);
504 }
505
718e3744 506 return CMD_SUCCESS;
507}
508
a2c62831 509ALIAS (no_ospf_passive_interface,
510 no_ospf_passive_interface_cmd,
718e3744 511 "no passive-interface IFNAME",
512 NO_STR
513 "Allow routing updates on an interface\n"
514 "Interface's name\n")
515
7ffa8fa2
PJ
516ALIAS (no_ospf_passive_interface,
517 no_ospf_passive_interface_default_cmd,
518 "no passive-interface default",
519 NO_STR
520 "Allow routing updates on an interface\n"
521 "Allow routing updates on interfaces by default\n")
522
a2c62831 523DEFUN (ospf_network_area,
524 ospf_network_area_cmd,
718e3744 525 "network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
526 "Enable routing on an IP network\n"
527 "OSPF network prefix\n"
528 "Set the OSPF area ID\n"
529 "OSPF area ID in IP address format\n"
530 "OSPF area ID as a decimal value\n")
531{
532 struct ospf *ospf= vty->index;
533 struct prefix_ipv4 p;
534 struct in_addr area_id;
535 int ret, format;
536
7c8ff89e
DS
537 if (!ospf)
538 return CMD_SUCCESS;
539
540 if (ospf->instance)
541 {
542 vty_out (vty, "The network command is not supported in multi-instance ospf%s",
543 VTY_NEWLINE);
544 return CMD_WARNING;
545 }
546
953cde65
JT
547 if (ospf->if_ospf_cli_count > 0)
548 {
549 vty_out (vty, "Please remove all ip ospf area x.x.x.x commands first.%s",
550 VTY_NEWLINE);
551 return CMD_WARNING;
552 }
553
718e3744 554 /* Get network prefix and Area ID. */
555 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
556 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
557
558 ret = ospf_network_set (ospf, &p, area_id);
559 if (ret == 0)
560 {
561 vty_out (vty, "There is already same network statement.%s", VTY_NEWLINE);
562 return CMD_WARNING;
563 }
564
565 return CMD_SUCCESS;
566}
567
a2c62831 568DEFUN (no_ospf_network_area,
569 no_ospf_network_area_cmd,
718e3744 570 "no network A.B.C.D/M area (A.B.C.D|<0-4294967295>)",
571 NO_STR
572 "Enable routing on an IP network\n"
573 "OSPF network prefix\n"
574 "Set the OSPF area ID\n"
575 "OSPF area ID in IP address format\n"
576 "OSPF area ID as a decimal value\n")
577{
578 struct ospf *ospf = (struct ospf *) vty->index;
579 struct prefix_ipv4 p;
580 struct in_addr area_id;
581 int ret, format;
582
7c8ff89e
DS
583 if (!ospf)
584 return CMD_SUCCESS;
585
586 if (ospf->instance)
587 {
588 vty_out (vty, "The network command is not supported in multi-instance ospf%s",
589 VTY_NEWLINE);
590 return CMD_WARNING;
591 }
592
718e3744 593 /* Get network prefix and Area ID. */
594 VTY_GET_IPV4_PREFIX ("network prefix", p, argv[0]);
595 VTY_GET_OSPF_AREA_ID (area_id, format, argv[1]);
596
597 ret = ospf_network_unset (ospf, &p, area_id);
598 if (ret == 0)
599 {
600 vty_out (vty, "Can't find specified network area configuration.%s",
601 VTY_NEWLINE);
602 return CMD_WARNING;
603 }
604
605 return CMD_SUCCESS;
606}
607
6b0655a2 608
a2c62831 609DEFUN (ospf_area_range,
610 ospf_area_range_cmd,
718e3744 611 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
612 "OSPF area parameters\n"
613 "OSPF area ID in IP address format\n"
614 "OSPF area ID as a decimal value\n"
615 "Summarize routes matching address/mask (border routers only)\n"
616 "Area range prefix\n")
617{
618 struct ospf *ospf = vty->index;
619 struct prefix_ipv4 p;
620 struct in_addr area_id;
621 int format;
622 u_int32_t cost;
623
7c8ff89e
DS
624 if (!ospf)
625 return CMD_SUCCESS;
626
718e3744 627 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
628 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
629
630 ospf_area_range_set (ospf, area_id, &p, OSPF_AREA_RANGE_ADVERTISE);
631 if (argc > 2)
632 {
4dadc291 633 VTY_GET_INTEGER ("range cost", cost, argv[2]);
718e3744 634 ospf_area_range_cost_set (ospf, area_id, &p, cost);
635 }
636
637 return CMD_SUCCESS;
638}
639
a2c62831 640ALIAS (ospf_area_range,
641 ospf_area_range_advertise_cmd,
718e3744 642 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise",
643 "OSPF area parameters\n"
644 "OSPF area ID in IP address format\n"
645 "OSPF area ID as a decimal value\n"
646 "OSPF area range for route advertise (default)\n"
647 "Area range prefix\n"
648 "Advertise this range (default)\n")
649
a2c62831 650ALIAS (ospf_area_range,
651 ospf_area_range_cost_cmd,
718e3744 652 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
653 "OSPF area parameters\n"
654 "OSPF area ID in IP address format\n"
655 "OSPF area ID as a decimal value\n"
656 "Summarize routes matching address/mask (border routers only)\n"
657 "Area range prefix\n"
658 "User specified metric for this range\n"
659 "Advertised metric for this range\n")
660
a2c62831 661ALIAS (ospf_area_range,
662 ospf_area_range_advertise_cost_cmd,
718e3744 663 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
664 "OSPF area parameters\n"
665 "OSPF area ID in IP address format\n"
666 "OSPF area ID as a decimal value\n"
667 "Summarize routes matching address/mask (border routers only)\n"
668 "Area range prefix\n"
669 "Advertise this range (default)\n"
670 "User specified metric for this range\n"
671 "Advertised metric for this range\n")
672
a2c62831 673DEFUN (ospf_area_range_not_advertise,
674 ospf_area_range_not_advertise_cmd,
718e3744 675 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M not-advertise",
676 "OSPF area parameters\n"
677 "OSPF area ID in IP address format\n"
678 "OSPF area ID as a decimal value\n"
679 "Summarize routes matching address/mask (border routers only)\n"
680 "Area range prefix\n"
681 "DoNotAdvertise this range\n")
682{
683 struct ospf *ospf = vty->index;
684 struct prefix_ipv4 p;
685 struct in_addr area_id;
686 int format;
687
7c8ff89e
DS
688 if (!ospf)
689 return CMD_SUCCESS;
690
718e3744 691 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
692 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
693
694 ospf_area_range_set (ospf, area_id, &p, 0);
695
696 return CMD_SUCCESS;
697}
698
a2c62831 699DEFUN (no_ospf_area_range,
700 no_ospf_area_range_cmd,
718e3744 701 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M",
702 NO_STR
703 "OSPF area parameters\n"
704 "OSPF area ID in IP address format\n"
705 "OSPF area ID as a decimal value\n"
706 "Summarize routes matching address/mask (border routers only)\n"
707 "Area range prefix\n")
708{
709 struct ospf *ospf = vty->index;
710 struct prefix_ipv4 p;
711 struct in_addr area_id;
712 int format;
713
7c8ff89e
DS
714 if (!ospf)
715 return CMD_SUCCESS;
716
718e3744 717 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
718 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
719
720 ospf_area_range_unset (ospf, area_id, &p);
721
722 return CMD_SUCCESS;
723}
724
a2c62831 725ALIAS (no_ospf_area_range,
726 no_ospf_area_range_advertise_cmd,
718e3744 727 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M (advertise|not-advertise)",
728 NO_STR
729 "OSPF area parameters\n"
730 "OSPF area ID in IP address format\n"
731 "OSPF area ID as a decimal value\n"
732 "Summarize routes matching address/mask (border routers only)\n"
733 "Area range prefix\n"
734 "Advertise this range (default)\n"
735 "DoNotAdvertise this range\n")
736
a2c62831 737ALIAS (no_ospf_area_range,
738 no_ospf_area_range_cost_cmd,
718e3744 739 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M cost <0-16777215>",
740 NO_STR
741 "OSPF area parameters\n"
742 "OSPF area ID in IP address format\n"
743 "OSPF area ID as a decimal value\n"
744 "Summarize routes matching address/mask (border routers only)\n"
745 "Area range prefix\n"
746 "User specified metric for this range\n"
747 "Advertised metric for this range\n")
748
a2c62831 749ALIAS (no_ospf_area_range,
750 no_ospf_area_range_advertise_cost_cmd,
718e3744 751 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M advertise cost <0-16777215>",
752 NO_STR
753 "OSPF area parameters\n"
754 "OSPF area ID in IP address format\n"
755 "OSPF area ID as a decimal value\n"
756 "Summarize routes matching address/mask (border routers only)\n"
757 "Area range prefix\n"
758 "Advertise this range (default)\n"
759 "User specified metric for this range\n"
760 "Advertised metric for this range\n")
6b0655a2 761
a2c62831 762DEFUN (ospf_area_range_substitute,
763 ospf_area_range_substitute_cmd,
718e3744 764 "area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
765 "OSPF area parameters\n"
766 "OSPF area ID in IP address format\n"
767 "OSPF area ID as a decimal value\n"
768 "Summarize routes matching address/mask (border routers only)\n"
769 "Area range prefix\n"
770 "Announce area range as another prefix\n"
771 "Network prefix to be announced instead of range\n")
772{
773 struct ospf *ospf = vty->index;
774 struct prefix_ipv4 p, s;
775 struct in_addr area_id;
776 int format;
777
7c8ff89e
DS
778 if (!ospf)
779 return CMD_SUCCESS;
780
718e3744 781 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
782 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
783 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
784
785 ospf_area_range_substitute_set (ospf, area_id, &p, &s);
786
787 return CMD_SUCCESS;
788}
789
a2c62831 790DEFUN (no_ospf_area_range_substitute,
791 no_ospf_area_range_substitute_cmd,
718e3744 792 "no area (A.B.C.D|<0-4294967295>) range A.B.C.D/M substitute A.B.C.D/M",
793 NO_STR
794 "OSPF area parameters\n"
795 "OSPF area ID in IP address format\n"
796 "OSPF area ID as a decimal value\n"
797 "Summarize routes matching address/mask (border routers only)\n"
798 "Area range prefix\n"
799 "Announce area range as another prefix\n"
800 "Network prefix to be announced instead of range\n")
801{
802 struct ospf *ospf = vty->index;
803 struct prefix_ipv4 p, s;
804 struct in_addr area_id;
805 int format;
806
7c8ff89e
DS
807 if (!ospf)
808 return CMD_SUCCESS;
809
718e3744 810 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
811 VTY_GET_IPV4_PREFIX ("area range", p, argv[1]);
812 VTY_GET_IPV4_PREFIX ("substituted network prefix", s, argv[2]);
813
814 ospf_area_range_substitute_unset (ospf, area_id, &p);
815
816 return CMD_SUCCESS;
817}
818
6b0655a2 819
718e3744 820/* Command Handler Logic in VLink stuff is delicate!!
821
822 ALTER AT YOUR OWN RISK!!!!
823
824 Various dummy values are used to represent 'NoChange' state for
825 VLink configuration NOT being changed by a VLink command, and
826 special syntax is used within the command strings so that the
827 typed in command verbs can be seen in the configuration command
828 bacckend handler. This is to drastically reduce the verbeage
829 required to coe up with a reasonably compatible Cisco VLink command
830
831 - Matthew Grant <grantma@anathoth.gen.nz>
832 Wed, 21 Feb 2001 15:13:52 +1300
833 */
834
835
836/* Configuration data for virtual links
837 */
838struct ospf_vl_config_data {
839 struct vty *vty; /* vty stuff */
840 struct in_addr area_id; /* area ID from command line */
841 int format; /* command line area ID format */
842 struct in_addr vl_peer; /* command line vl_peer */
843 int auth_type; /* Authehntication type, if given */
844 char *auth_key; /* simple password if present */
845 int crypto_key_id; /* Cryptographic key ID */
846 char *md5_key; /* MD5 authentication key */
847 int hello_interval; /* Obvious what these are... */
848 int retransmit_interval;
849 int transmit_delay;
850 int dead_interval;
851};
852
4dadc291 853static void
718e3744 854ospf_vl_config_data_init (struct ospf_vl_config_data *vl_config,
855 struct vty *vty)
856{
857 memset (vl_config, 0, sizeof (struct ospf_vl_config_data));
858 vl_config->auth_type = OSPF_AUTH_CMD_NOTSEEN;
859 vl_config->vty = vty;
860}
861
4dadc291 862static struct ospf_vl_data *
68980084 863ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
718e3744 864{
865 struct ospf_area *area;
866 struct ospf_vl_data *vl_data;
867 struct vty *vty;
868 struct in_addr area_id;
869
870 vty = vl_config->vty;
871 area_id = vl_config->area_id;
872
873 if (area_id.s_addr == OSPF_AREA_BACKBONE)
874 {
875 vty_out (vty,
876 "Configuring VLs over the backbone is not allowed%s",
877 VTY_NEWLINE);
878 return NULL;
879 }
68980084 880 area = ospf_area_get (ospf, area_id, vl_config->format);
718e3744 881
882 if (area->external_routing != OSPF_AREA_DEFAULT)
883 {
884 if (vl_config->format == OSPF_AREA_ID_FORMAT_ADDRESS)
885 vty_out (vty, "Area %s is %s%s",
886 inet_ntoa (area_id),
718e3744 887 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
718e3744 888 VTY_NEWLINE);
889 else
890 vty_out (vty, "Area %ld is %s%s",
891 (u_long)ntohl (area_id.s_addr),
718e3744 892 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
718e3744 893 VTY_NEWLINE);
894 return NULL;
895 }
896
9c27ef9b 897 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL)
718e3744 898 {
899 vl_data = ospf_vl_data_new (area, vl_config->vl_peer);
900 if (vl_data->vl_oi == NULL)
901 {
68980084 902 vl_data->vl_oi = ospf_vl_new (ospf, vl_data);
903 ospf_vl_add (ospf, vl_data);
d3a9c768 904 ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE);
718e3744 905 }
906 }
907 return vl_data;
908}
909
910
4dadc291 911static int
718e3744 912ospf_vl_set_security (struct ospf_vl_data *vl_data,
913 struct ospf_vl_config_data *vl_config)
914{
915 struct crypt_key *ck;
916 struct vty *vty;
917 struct interface *ifp = vl_data->vl_oi->ifp;
918
919 vty = vl_config->vty;
920
921 if (vl_config->auth_type != OSPF_AUTH_CMD_NOTSEEN)
922 {
923 SET_IF_PARAM (IF_DEF_PARAMS (ifp), auth_type);
924 IF_DEF_PARAMS (ifp)->auth_type = vl_config->auth_type;
925 }
926
927 if (vl_config->auth_key)
928 {
929 memset(IF_DEF_PARAMS (ifp)->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE+1);
c9e52be3 930 strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key,
718e3744 931 OSPF_AUTH_SIMPLE_SIZE);
932 }
933 else if (vl_config->md5_key)
934 {
935 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id)
936 != NULL)
937 {
938 vty_out (vty, "OSPF: Key %d already exists%s",
939 vl_config->crypto_key_id, VTY_NEWLINE);
940 return CMD_WARNING;
941 }
942 ck = ospf_crypt_key_new ();
943 ck->key_id = vl_config->crypto_key_id;
944 memset(ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
c9e52be3 945 strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE);
718e3744 946
947 ospf_crypt_key_add (IF_DEF_PARAMS (ifp)->auth_crypt, ck);
948 }
949 else if (vl_config->crypto_key_id != 0)
950 {
951 /* Delete a key */
952
953 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp)->auth_crypt,
954 vl_config->crypto_key_id) == NULL)
955 {
956 vty_out (vty, "OSPF: Key %d does not exist%s",
957 vl_config->crypto_key_id, VTY_NEWLINE);
958 return CMD_WARNING;
959 }
960
961 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp)->auth_crypt, vl_config->crypto_key_id);
962
963 }
964
965 return CMD_SUCCESS;
966}
967
4dadc291 968static int
718e3744 969ospf_vl_set_timers (struct ospf_vl_data *vl_data,
970 struct ospf_vl_config_data *vl_config)
971{
c8cdf5c7 972 struct interface *ifp = vl_data->vl_oi->ifp;
718e3744 973 /* Virtual Link data initialised to defaults, so only set
974 if a value given */
975 if (vl_config->hello_interval)
976 {
977 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_hello);
978 IF_DEF_PARAMS (ifp)->v_hello = vl_config->hello_interval;
979 }
980
981 if (vl_config->dead_interval)
982 {
983 SET_IF_PARAM (IF_DEF_PARAMS (ifp), v_wait);
984 IF_DEF_PARAMS (ifp)->v_wait = vl_config->dead_interval;
985 }
986
987 if (vl_config->retransmit_interval)
988 {
989 SET_IF_PARAM (IF_DEF_PARAMS (ifp), retransmit_interval);
990 IF_DEF_PARAMS (ifp)->retransmit_interval = vl_config->retransmit_interval;
991 }
992
993 if (vl_config->transmit_delay)
994 {
995 SET_IF_PARAM (IF_DEF_PARAMS (ifp), transmit_delay);
996 IF_DEF_PARAMS (ifp)->transmit_delay = vl_config->transmit_delay;
997 }
998
999 return CMD_SUCCESS;
1000}
1001
1002
1003
1004/* The business end of all of the above */
4dadc291 1005static int
68980084 1006ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
718e3744 1007{
1008 struct ospf_vl_data *vl_data;
1009 int ret;
1010
68980084 1011 vl_data = ospf_find_vl_data (ospf, vl_config);
718e3744 1012 if (!vl_data)
1013 return CMD_WARNING;
1014
1015 /* Process this one first as it can have a fatal result, which can
1016 only logically occur if the virtual link exists already
1017 Thus a command error does not result in a change to the
1018 running configuration such as unexpectedly altered timer
1019 values etc.*/
1020 ret = ospf_vl_set_security (vl_data, vl_config);
1021 if (ret != CMD_SUCCESS)
1022 return ret;
1023
1024 /* Set any time based parameters, these area already range checked */
1025
1026 ret = ospf_vl_set_timers (vl_data, vl_config);
1027 if (ret != CMD_SUCCESS)
1028 return ret;
1029
1030 return CMD_SUCCESS;
1031
1032}
1033
1034/* This stuff exists to make specifying all the alias commands A LOT simpler
1035 */
1036#define VLINK_HELPSTR_IPADDR \
1037 "OSPF area parameters\n" \
1038 "OSPF area ID in IP address format\n" \
1039 "OSPF area ID as a decimal value\n" \
1040 "Configure a virtual link\n" \
1041 "Router ID of the remote ABR\n"
1042
1043#define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
1044 "Enable authentication on this virtual link\n" \
1045 "dummy string \n"
1046
1047#define VLINK_HELPSTR_AUTHTYPE_ALL \
1048 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
1049 "Use null authentication\n" \
1050 "Use message-digest authentication\n"
1051
1052#define VLINK_HELPSTR_TIME_PARAM_NOSECS \
1053 "Time between HELLO packets\n" \
1054 "Time between retransmitting lost link state advertisements\n" \
1055 "Link state transmit delay\n" \
1056 "Interval after which a neighbor is declared dead\n"
1057
1058#define VLINK_HELPSTR_TIME_PARAM \
1059 VLINK_HELPSTR_TIME_PARAM_NOSECS \
1060 "Seconds\n"
1061
1062#define VLINK_HELPSTR_AUTH_SIMPLE \
1063 "Authentication password (key)\n" \
1064 "The OSPF password (key)"
1065
1066#define VLINK_HELPSTR_AUTH_MD5 \
1067 "Message digest authentication password (key)\n" \
1068 "dummy string \n" \
1069 "Key ID\n" \
1070 "Use MD5 algorithm\n" \
1071 "The OSPF password (key)"
1072
a2c62831 1073DEFUN (ospf_area_vlink,
1074 ospf_area_vlink_cmd,
718e3744 1075 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1076 VLINK_HELPSTR_IPADDR)
1077{
68980084 1078 struct ospf *ospf = vty->index;
718e3744 1079 struct ospf_vl_config_data vl_config;
1080 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
1081 char md5_key[OSPF_AUTH_MD5_SIZE+1];
1082 int i;
1083 int ret;
1084
7c8ff89e
DS
1085 if (!ospf)
1086 return CMD_SUCCESS;
1087
718e3744 1088 ospf_vl_config_data_init(&vl_config, vty);
1089
1090 /* Read off first 2 parameters and check them */
1091 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &vl_config.format);
1092 if (ret < 0)
1093 {
1094 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
1095 return CMD_WARNING;
1096 }
1097
1098 ret = inet_aton (argv[1], &vl_config.vl_peer);
1099 if (! ret)
1100 {
1101 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
1102 VTY_NEWLINE);
1103 return CMD_WARNING;
1104 }
1105
1106 if (argc <=2)
1107 {
1108 /* Thats all folks! - BUGS B. strikes again!!!*/
1109
68980084 1110 return ospf_vl_set (ospf, &vl_config);
718e3744 1111 }
1112
1113 /* Deal with other parameters */
1114 for (i=2; i < argc; i++)
1115 {
1116
1117 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1118
1119 switch (argv[i][0])
1120 {
1121
1122 case 'a':
1123 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
1124 {
1125 /* authentication-key - this option can occur anywhere on
1126 command line. At start of command line
1127 must check for authentication option. */
1128 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
1129 strncpy (auth_key, argv[i+1], OSPF_AUTH_SIMPLE_SIZE);
1130 vl_config.auth_key = auth_key;
1131 i++;
1132 }
1133 else if (strncmp (argv[i], "authentication", 14) == 0)
1134 {
1135 /* authentication - this option can only occur at start
1136 of command line */
1137 vl_config.auth_type = OSPF_AUTH_SIMPLE;
1138 if ((i+1) < argc)
1139 {
1140 if (strncmp (argv[i+1], "n", 1) == 0)
1141 {
1142 /* "authentication null" */
1143 vl_config.auth_type = OSPF_AUTH_NULL;
1144 i++;
1145 }
1146 else if (strncmp (argv[i+1], "m", 1) == 0
1147 && strcmp (argv[i+1], "message-digest-") != 0)
1148 {
1149 /* "authentication message-digest" */
1150 vl_config.auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
1151 i++;
1152 }
1153 }
1154 }
1155 break;
1156
1157 case 'm':
1158 /* message-digest-key */
1159 i++;
1160 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1161 if (vl_config.crypto_key_id < 0)
1162 return CMD_WARNING;
1163 i++;
1164 memset(md5_key, 0, OSPF_AUTH_MD5_SIZE+1);
1165 strncpy (md5_key, argv[i], OSPF_AUTH_MD5_SIZE);
1166 vl_config.md5_key = md5_key;
1167 break;
1168
1169 case 'h':
1170 /* Hello interval */
1171 i++;
1172 vl_config.hello_interval = strtol (argv[i], NULL, 10);
1173 if (vl_config.hello_interval < 0)
1174 return CMD_WARNING;
1175 break;
1176
1177 case 'r':
1178 /* Retransmit Interval */
1179 i++;
1180 vl_config.retransmit_interval = strtol (argv[i], NULL, 10);
1181 if (vl_config.retransmit_interval < 0)
1182 return CMD_WARNING;
1183 break;
1184
1185 case 't':
1186 /* Transmit Delay */
1187 i++;
1188 vl_config.transmit_delay = strtol (argv[i], NULL, 10);
1189 if (vl_config.transmit_delay < 0)
1190 return CMD_WARNING;
1191 break;
1192
1193 case 'd':
1194 /* Dead Interval */
1195 i++;
1196 vl_config.dead_interval = strtol (argv[i], NULL, 10);
1197 if (vl_config.dead_interval < 0)
1198 return CMD_WARNING;
1199 break;
1200 }
1201 }
1202
1203
1204 /* Action configuration */
1205
68980084 1206 return ospf_vl_set (ospf, &vl_config);
718e3744 1207
1208}
1209
a2c62831 1210DEFUN (no_ospf_area_vlink,
1211 no_ospf_area_vlink_cmd,
718e3744 1212 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1213 NO_STR
1214 VLINK_HELPSTR_IPADDR)
1215{
68980084 1216 struct ospf *ospf = vty->index;
718e3744 1217 struct ospf_area *area;
1218 struct ospf_vl_config_data vl_config;
1219 struct ospf_vl_data *vl_data = NULL;
1220 char auth_key[OSPF_AUTH_SIMPLE_SIZE+1];
1221 int i;
1222 int ret, format;
1223
7c8ff89e
DS
1224 if (!ospf)
1225 return CMD_SUCCESS;
1226
718e3744 1227 ospf_vl_config_data_init(&vl_config, vty);
1228
1229 ret = ospf_str2area_id (argv[0], &vl_config.area_id, &format);
1230 if (ret < 0)
1231 {
1232 vty_out (vty, "OSPF area ID is invalid%s", VTY_NEWLINE);
1233 return CMD_WARNING;
1234 }
1235
68980084 1236 area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id);
718e3744 1237 if (!area)
1238 {
1239 vty_out (vty, "Area does not exist%s", VTY_NEWLINE);
1240 return CMD_WARNING;
1241 }
1242
1243 ret = inet_aton (argv[1], &vl_config.vl_peer);
1244 if (! ret)
1245 {
1246 vty_out (vty, "Please specify valid Router ID as a.b.c.d%s",
1247 VTY_NEWLINE);
1248 return CMD_WARNING;
1249 }
1250
1251 if (argc <=2)
1252 {
1253 /* Basic VLink no command */
1254 /* Thats all folks! - BUGS B. strikes again!!!*/
9c27ef9b 1255 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer)))
68980084 1256 ospf_vl_delete (ospf, vl_data);
718e3744 1257
68980084 1258 ospf_area_check_free (ospf, vl_config.area_id);
718e3744 1259
1260 return CMD_SUCCESS;
1261 }
1262
1263 /* If we are down here, we are reseting parameters */
1264
1265 /* Deal with other parameters */
1266 for (i=2; i < argc; i++)
1267 {
718e3744 1268 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1269
1270 switch (argv[i][0])
1271 {
1272
1273 case 'a':
1274 if (i > 2 || strncmp (argv[i], "authentication-", 15) == 0)
1275 {
1276 /* authentication-key - this option can occur anywhere on
1277 command line. At start of command line
1278 must check for authentication option. */
1279 memset (auth_key, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
1280 vl_config.auth_key = auth_key;
1281 }
1282 else if (strncmp (argv[i], "authentication", 14) == 0)
1283 {
1284 /* authentication - this option can only occur at start
1285 of command line */
1286 vl_config.auth_type = OSPF_AUTH_NOTSET;
1287 }
1288 break;
1289
1290 case 'm':
1291 /* message-digest-key */
1292 /* Delete one key */
1293 i++;
36da0665
DS
1294 if (i < argc)
1295 {
1296 vl_config.crypto_key_id = strtol (argv[i], NULL, 10);
1297 if (vl_config.crypto_key_id < 0)
1298 return CMD_WARNING;
1299 vl_config.md5_key = NULL;
1300 }
1301 else
718e3744 1302 return CMD_WARNING;
718e3744 1303 break;
1304
1305 case 'h':
1306 /* Hello interval */
1307 vl_config.hello_interval = OSPF_HELLO_INTERVAL_DEFAULT;
1308 break;
1309
1310 case 'r':
1311 /* Retransmit Interval */
1312 vl_config.retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
1313 break;
1314
1315 case 't':
1316 /* Transmit Delay */
1317 vl_config.transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
1318 break;
1319
1320 case 'd':
1321 /* Dead Interval */
1322 i++;
1323 vl_config.dead_interval = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
1324 break;
1325 }
1326 }
1327
1328
1329 /* Action configuration */
1330
68980084 1331 return ospf_vl_set (ospf, &vl_config);
718e3744 1332}
1333
a2c62831 1334ALIAS (ospf_area_vlink,
1335 ospf_area_vlink_param1_cmd,
718e3744 1336 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1337 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1338 VLINK_HELPSTR_IPADDR
1339 VLINK_HELPSTR_TIME_PARAM)
1340
a2c62831 1341ALIAS (no_ospf_area_vlink,
1342 no_ospf_area_vlink_param1_cmd,
718e3744 1343 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
813d4307 1344 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
718e3744 1345 NO_STR
1346 VLINK_HELPSTR_IPADDR
1347 VLINK_HELPSTR_TIME_PARAM)
1348
a2c62831 1349ALIAS (ospf_area_vlink,
1350 ospf_area_vlink_param2_cmd,
718e3744 1351 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1352 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1353 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1354 VLINK_HELPSTR_IPADDR
1355 VLINK_HELPSTR_TIME_PARAM
1356 VLINK_HELPSTR_TIME_PARAM)
1357
a2c62831 1358ALIAS (no_ospf_area_vlink,
1359 no_ospf_area_vlink_param2_cmd,
718e3744 1360 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
813d4307
DW
1361 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1362 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
718e3744 1363 NO_STR
1364 VLINK_HELPSTR_IPADDR
1365 VLINK_HELPSTR_TIME_PARAM
1366 VLINK_HELPSTR_TIME_PARAM)
1367
a2c62831 1368ALIAS (ospf_area_vlink,
1369 ospf_area_vlink_param3_cmd,
718e3744 1370 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1371 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1372 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1373 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1374 VLINK_HELPSTR_IPADDR
1375 VLINK_HELPSTR_TIME_PARAM
1376 VLINK_HELPSTR_TIME_PARAM
1377 VLINK_HELPSTR_TIME_PARAM)
1378
a2c62831 1379ALIAS (no_ospf_area_vlink,
1380 no_ospf_area_vlink_param3_cmd,
718e3744 1381 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
813d4307
DW
1382 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1383 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1384 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
718e3744 1385 NO_STR
1386 VLINK_HELPSTR_IPADDR
1387 VLINK_HELPSTR_TIME_PARAM
1388 VLINK_HELPSTR_TIME_PARAM
1389 VLINK_HELPSTR_TIME_PARAM)
1390
a2c62831 1391ALIAS (ospf_area_vlink,
1392 ospf_area_vlink_param4_cmd,
718e3744 1393 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1394 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1395 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1396 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1397 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1398 VLINK_HELPSTR_IPADDR
1399 VLINK_HELPSTR_TIME_PARAM
1400 VLINK_HELPSTR_TIME_PARAM
1401 VLINK_HELPSTR_TIME_PARAM
1402 VLINK_HELPSTR_TIME_PARAM)
1403
a2c62831 1404ALIAS (no_ospf_area_vlink,
1405 no_ospf_area_vlink_param4_cmd,
718e3744 1406 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
813d4307
DW
1407 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1408 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1409 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1410 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
718e3744 1411 NO_STR
1412 VLINK_HELPSTR_IPADDR
1413 VLINK_HELPSTR_TIME_PARAM
1414 VLINK_HELPSTR_TIME_PARAM
1415 VLINK_HELPSTR_TIME_PARAM
1416 VLINK_HELPSTR_TIME_PARAM)
1417
a2c62831 1418ALIAS (ospf_area_vlink,
1419 ospf_area_vlink_authtype_args_cmd,
718e3744 1420 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1421 "(authentication|) (message-digest|null)",
1422 VLINK_HELPSTR_IPADDR
1423 VLINK_HELPSTR_AUTHTYPE_ALL)
1424
813d4307
DW
1425ALIAS (no_ospf_area_vlink,
1426 no_ospf_area_vlink_authtype_args_cmd,
1427 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1428 "(authentication|) (message-digest|null)",
1429 NO_STR
1430 VLINK_HELPSTR_IPADDR
1431 VLINK_HELPSTR_AUTHTYPE_ALL)
1432
a2c62831 1433ALIAS (ospf_area_vlink,
1434 ospf_area_vlink_authtype_cmd,
718e3744 1435 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1436 "(authentication|)",
1437 VLINK_HELPSTR_IPADDR
1438 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1439
a2c62831 1440ALIAS (no_ospf_area_vlink,
1441 no_ospf_area_vlink_authtype_cmd,
718e3744 1442 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1443 "(authentication|)",
1444 NO_STR
1445 VLINK_HELPSTR_IPADDR
1446 VLINK_HELPSTR_AUTHTYPE_SIMPLE)
1447
a2c62831 1448ALIAS (ospf_area_vlink,
1449 ospf_area_vlink_md5_cmd,
718e3744 1450 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1451 "(message-digest-key|) <1-255> md5 KEY",
1452 VLINK_HELPSTR_IPADDR
1453 VLINK_HELPSTR_AUTH_MD5)
1454
a2c62831 1455ALIAS (no_ospf_area_vlink,
1456 no_ospf_area_vlink_md5_cmd,
718e3744 1457 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
813d4307 1458 "(message-digest-key|) <1-255> md5 KEY",
718e3744 1459 NO_STR
1460 VLINK_HELPSTR_IPADDR
1461 VLINK_HELPSTR_AUTH_MD5)
1462
a2c62831 1463ALIAS (ospf_area_vlink,
1464 ospf_area_vlink_authkey_cmd,
718e3744 1465 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1466 "(authentication-key|) AUTH_KEY",
1467 VLINK_HELPSTR_IPADDR
1468 VLINK_HELPSTR_AUTH_SIMPLE)
1469
a2c62831 1470ALIAS (no_ospf_area_vlink,
1471 no_ospf_area_vlink_authkey_cmd,
718e3744 1472 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
813d4307 1473 "(authentication-key|) AUTH_KEY",
718e3744 1474 NO_STR
1475 VLINK_HELPSTR_IPADDR
1476 VLINK_HELPSTR_AUTH_SIMPLE)
1477
a2c62831 1478ALIAS (ospf_area_vlink,
1479 ospf_area_vlink_authtype_args_authkey_cmd,
718e3744 1480 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1481 "(authentication|) (message-digest|null) "
1482 "(authentication-key|) AUTH_KEY",
1483 VLINK_HELPSTR_IPADDR
1484 VLINK_HELPSTR_AUTHTYPE_ALL
1485 VLINK_HELPSTR_AUTH_SIMPLE)
1486
813d4307
DW
1487ALIAS (no_ospf_area_vlink,
1488 no_ospf_area_vlink_authtype_args_authkey_cmd,
1489 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1490 "(authentication|) (message-digest|null) "
1491 "(authentication-key|) AUTH_KEY",
1492 NO_STR
1493 VLINK_HELPSTR_IPADDR
1494 VLINK_HELPSTR_AUTHTYPE_ALL
1495 VLINK_HELPSTR_AUTH_SIMPLE)
1496
a2c62831 1497ALIAS (ospf_area_vlink,
1498 ospf_area_vlink_authtype_authkey_cmd,
718e3744 1499 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1500 "(authentication|) "
1501 "(authentication-key|) AUTH_KEY",
1502 VLINK_HELPSTR_IPADDR
1503 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1504 VLINK_HELPSTR_AUTH_SIMPLE)
1505
a2c62831 1506ALIAS (no_ospf_area_vlink,
1507 no_ospf_area_vlink_authtype_authkey_cmd,
718e3744 1508 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1509 "(authentication|) "
813d4307 1510 "(authentication-key|) AUTH_KEY",
718e3744 1511 NO_STR
1512 VLINK_HELPSTR_IPADDR
1513 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1514 VLINK_HELPSTR_AUTH_SIMPLE)
1515
a2c62831 1516ALIAS (ospf_area_vlink,
1517 ospf_area_vlink_authtype_args_md5_cmd,
718e3744 1518 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1519 "(authentication|) (message-digest|null) "
1520 "(message-digest-key|) <1-255> md5 KEY",
1521 VLINK_HELPSTR_IPADDR
1522 VLINK_HELPSTR_AUTHTYPE_ALL
1523 VLINK_HELPSTR_AUTH_MD5)
1524
813d4307
DW
1525ALIAS (no_ospf_area_vlink,
1526 no_ospf_area_vlink_authtype_args_md5_cmd,
1527 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1528 "(authentication|) (message-digest|null) "
1529 "(message-digest-key|) <1-255> md5 KEY",
1530 NO_STR
1531 VLINK_HELPSTR_IPADDR
1532 VLINK_HELPSTR_AUTHTYPE_ALL
1533 VLINK_HELPSTR_AUTH_MD5)
1534
a2c62831 1535ALIAS (ospf_area_vlink,
1536 ospf_area_vlink_authtype_md5_cmd,
718e3744 1537 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1538 "(authentication|) "
1539 "(message-digest-key|) <1-255> md5 KEY",
1540 VLINK_HELPSTR_IPADDR
1541 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1542 VLINK_HELPSTR_AUTH_MD5)
1543
a2c62831 1544ALIAS (no_ospf_area_vlink,
1545 no_ospf_area_vlink_authtype_md5_cmd,
718e3744 1546 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1547 "(authentication|) "
813d4307 1548 "(message-digest-key|) <1-255> md5 KEY",
718e3744 1549 NO_STR
1550 VLINK_HELPSTR_IPADDR
1551 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1552 VLINK_HELPSTR_AUTH_MD5)
1553
6b0655a2 1554
a2c62831 1555DEFUN (ospf_area_shortcut,
1556 ospf_area_shortcut_cmd,
718e3744 1557 "area (A.B.C.D|<0-4294967295>) shortcut (default|enable|disable)",
1558 "OSPF area parameters\n"
1559 "OSPF area ID in IP address format\n"
1560 "OSPF area ID as a decimal value\n"
1561 "Configure the area's shortcutting mode\n"
1562 "Set default shortcutting behavior\n"
1563 "Enable shortcutting through the area\n"
1564 "Disable shortcutting through the area\n")
1565{
68980084 1566 struct ospf *ospf = vty->index;
718e3744 1567 struct ospf_area *area;
1568 struct in_addr area_id;
1569 int mode;
1570 int format;
1571
7c8ff89e
DS
1572 if (!ospf)
1573 return CMD_SUCCESS;
1574
718e3744 1575 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1576
68980084 1577 area = ospf_area_get (ospf, area_id, format);
718e3744 1578
1579 if (strncmp (argv[1], "de", 2) == 0)
1580 mode = OSPF_SHORTCUT_DEFAULT;
1581 else if (strncmp (argv[1], "di", 2) == 0)
1582 mode = OSPF_SHORTCUT_DISABLE;
1583 else if (strncmp (argv[1], "e", 1) == 0)
1584 mode = OSPF_SHORTCUT_ENABLE;
1585 else
1586 return CMD_WARNING;
1587
68980084 1588 ospf_area_shortcut_set (ospf, area, mode);
718e3744 1589
68980084 1590 if (ospf->abr_type != OSPF_ABR_SHORTCUT)
718e3744 1591 vty_out (vty, "Shortcut area setting will take effect "
1592 "only when the router is configured as Shortcut ABR%s",
1593 VTY_NEWLINE);
1594
1595 return CMD_SUCCESS;
1596}
1597
a2c62831 1598DEFUN (no_ospf_area_shortcut,
1599 no_ospf_area_shortcut_cmd,
718e3744 1600 "no area (A.B.C.D|<0-4294967295>) shortcut (enable|disable)",
1601 NO_STR
1602 "OSPF area parameters\n"
1603 "OSPF area ID in IP address format\n"
1604 "OSPF area ID as a decimal value\n"
1605 "Deconfigure the area's shortcutting mode\n"
1606 "Deconfigure enabled shortcutting through the area\n"
1607 "Deconfigure disabled shortcutting through the area\n")
1608{
68980084 1609 struct ospf *ospf = vty->index;
718e3744 1610 struct ospf_area *area;
1611 struct in_addr area_id;
1612 int format;
1613
7c8ff89e
DS
1614 if (!ospf)
1615 return CMD_SUCCESS;
1616
718e3744 1617 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1618
68980084 1619 area = ospf_area_lookup_by_area_id (ospf, area_id);
718e3744 1620 if (!area)
1621 return CMD_SUCCESS;
1622
68980084 1623 ospf_area_shortcut_unset (ospf, area);
718e3744 1624
1625 return CMD_SUCCESS;
1626}
1627
6b0655a2 1628
a2c62831 1629DEFUN (ospf_area_stub,
1630 ospf_area_stub_cmd,
718e3744 1631 "area (A.B.C.D|<0-4294967295>) stub",
1632 "OSPF area parameters\n"
1633 "OSPF area ID in IP address format\n"
1634 "OSPF area ID as a decimal value\n"
1635 "Configure OSPF area as stub\n")
1636{
1637 struct ospf *ospf = vty->index;
1638 struct in_addr area_id;
1639 int ret, format;
1640
7c8ff89e
DS
1641 if (!ospf)
1642 return CMD_SUCCESS;
1643
718e3744 1644 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1645
1646 ret = ospf_area_stub_set (ospf, area_id);
1647 if (ret == 0)
1648 {
1649 vty_out (vty, "First deconfigure all virtual link through this area%s",
1650 VTY_NEWLINE);
1651 return CMD_WARNING;
1652 }
1653
1654 ospf_area_no_summary_unset (ospf, area_id);
1655
1656 return CMD_SUCCESS;
1657}
1658
a2c62831 1659DEFUN (ospf_area_stub_no_summary,
1660 ospf_area_stub_no_summary_cmd,
718e3744 1661 "area (A.B.C.D|<0-4294967295>) stub no-summary",
1662 "OSPF stub parameters\n"
1663 "OSPF area ID in IP address format\n"
1664 "OSPF area ID as a decimal value\n"
1665 "Configure OSPF area as stub\n"
1666 "Do not inject inter-area routes into stub\n")
1667{
1668 struct ospf *ospf = vty->index;
1669 struct in_addr area_id;
1670 int ret, format;
1671
7c8ff89e
DS
1672 if (!ospf)
1673 return CMD_SUCCESS;
1674
718e3744 1675 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1676
1677 ret = ospf_area_stub_set (ospf, area_id);
1678 if (ret == 0)
1679 {
b0a053be 1680 vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s",
718e3744 1681 VTY_NEWLINE);
1682 return CMD_WARNING;
1683 }
1684
1685 ospf_area_no_summary_set (ospf, area_id);
1686
1687 return CMD_SUCCESS;
1688}
1689
a2c62831 1690DEFUN (no_ospf_area_stub,
1691 no_ospf_area_stub_cmd,
718e3744 1692 "no area (A.B.C.D|<0-4294967295>) stub",
1693 NO_STR
1694 "OSPF area parameters\n"
1695 "OSPF area ID in IP address format\n"
1696 "OSPF area ID as a decimal value\n"
1697 "Configure OSPF area as stub\n")
1698{
1699 struct ospf *ospf = vty->index;
1700 struct in_addr area_id;
1701 int format;
1702
7c8ff89e
DS
1703 if (!ospf)
1704 return CMD_SUCCESS;
1705
718e3744 1706 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1707
1708 ospf_area_stub_unset (ospf, area_id);
1709 ospf_area_no_summary_unset (ospf, area_id);
1710
1711 return CMD_SUCCESS;
1712}
1713
a2c62831 1714DEFUN (no_ospf_area_stub_no_summary,
1715 no_ospf_area_stub_no_summary_cmd,
718e3744 1716 "no area (A.B.C.D|<0-4294967295>) stub no-summary",
1717 NO_STR
1718 "OSPF area parameters\n"
1719 "OSPF area ID in IP address format\n"
1720 "OSPF area ID as a decimal value\n"
1721 "Configure OSPF area as stub\n"
1722 "Do not inject inter-area routes into area\n")
1723{
1724 struct ospf *ospf = vty->index;
1725 struct in_addr area_id;
1726 int format;
1727
7c8ff89e
DS
1728 if (!ospf)
1729 return CMD_SUCCESS;
1730
718e3744 1731 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id, format, argv[0]);
1732 ospf_area_no_summary_unset (ospf, area_id);
1733
1734 return CMD_SUCCESS;
1735}
1736
4dadc291 1737static int
6c835671 1738ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[],
1739 int nosum)
718e3744 1740{
1741 struct ospf *ospf = vty->index;
1742 struct in_addr area_id;
1743 int ret, format;
1744
7c8ff89e
DS
1745 if (!ospf)
1746 return CMD_SUCCESS;
1747
718e3744 1748 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1749
1750 ret = ospf_area_nssa_set (ospf, area_id);
1751 if (ret == 0)
1752 {
1753 vty_out (vty, "%% Area cannot be nssa as it contains a virtual link%s",
1754 VTY_NEWLINE);
1755 return CMD_WARNING;
1756 }
1757
1758 if (argc > 1)
1759 {
1760 if (strncmp (argv[1], "translate-c", 11) == 0)
b0a053be 1761 ospf_area_nssa_translator_role_set (ospf, area_id,
718e3744 1762 OSPF_NSSA_ROLE_CANDIDATE);
1763 else if (strncmp (argv[1], "translate-n", 11) == 0)
b0a053be 1764 ospf_area_nssa_translator_role_set (ospf, area_id,
718e3744 1765 OSPF_NSSA_ROLE_NEVER);
1766 else if (strncmp (argv[1], "translate-a", 11) == 0)
b0a053be 1767 ospf_area_nssa_translator_role_set (ospf, area_id,
718e3744 1768 OSPF_NSSA_ROLE_ALWAYS);
1769 }
b0a053be 1770 else
1771 {
1772 ospf_area_nssa_translator_role_set (ospf, area_id,
1773 OSPF_NSSA_ROLE_CANDIDATE);
1774 }
718e3744 1775
b0a053be 1776 if (nosum)
718e3744 1777 ospf_area_no_summary_set (ospf, area_id);
b0a053be 1778 else
1779 ospf_area_no_summary_unset (ospf, area_id);
718e3744 1780
b0a053be 1781 ospf_schedule_abr_task (ospf);
1782
718e3744 1783 return CMD_SUCCESS;
1784}
1785
b0a053be 1786DEFUN (ospf_area_nssa_translate_no_summary,
a2c62831 1787 ospf_area_nssa_translate_no_summary_cmd,
b0a053be 1788 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary",
718e3744 1789 "OSPF area parameters\n"
1790 "OSPF area ID in IP address format\n"
1791 "OSPF area ID as a decimal value\n"
1792 "Configure OSPF area as nssa\n"
1793 "Configure NSSA-ABR for translate election (default)\n"
1794 "Configure NSSA-ABR to never translate\n"
1795 "Configure NSSA-ABR to always translate\n"
b0a053be 1796 "Do not inject inter-area routes into nssa\n")
1797{
1798 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
1799}
718e3744 1800
b0a053be 1801DEFUN (ospf_area_nssa_translate,
a2c62831 1802 ospf_area_nssa_translate_cmd,
718e3744 1803 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always)",
1804 "OSPF area parameters\n"
1805 "OSPF area ID in IP address format\n"
1806 "OSPF area ID as a decimal value\n"
1807 "Configure OSPF area as nssa\n"
1808 "Configure NSSA-ABR for translate election (default)\n"
1809 "Configure NSSA-ABR to never translate\n"
1810 "Configure NSSA-ABR to always translate\n")
b0a053be 1811{
1812 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1813}
1814
1815DEFUN (ospf_area_nssa,
1816 ospf_area_nssa_cmd,
1817 "area (A.B.C.D|<0-4294967295>) nssa",
1818 "OSPF area parameters\n"
1819 "OSPF area ID in IP address format\n"
1820 "OSPF area ID as a decimal value\n"
1821 "Configure OSPF area as nssa\n")
1822{
1823 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1824}
718e3744 1825
a2c62831 1826DEFUN (ospf_area_nssa_no_summary,
1827 ospf_area_nssa_no_summary_cmd,
718e3744 1828 "area (A.B.C.D|<0-4294967295>) nssa no-summary",
1829 "OSPF area parameters\n"
1830 "OSPF area ID in IP address format\n"
1831 "OSPF area ID as a decimal value\n"
1832 "Configure OSPF area as nssa\n"
1833 "Do not inject inter-area routes into nssa\n")
1834{
b0a053be 1835 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
718e3744 1836}
1837
a2c62831 1838DEFUN (no_ospf_area_nssa,
1839 no_ospf_area_nssa_cmd,
718e3744 1840 "no area (A.B.C.D|<0-4294967295>) nssa",
1841 NO_STR
1842 "OSPF area parameters\n"
1843 "OSPF area ID in IP address format\n"
1844 "OSPF area ID as a decimal value\n"
1845 "Configure OSPF area as nssa\n")
1846{
1847 struct ospf *ospf = vty->index;
1848 struct in_addr area_id;
1849 int format;
1850
7c8ff89e
DS
1851 if (!ospf)
1852 return CMD_SUCCESS;
1853
718e3744 1854 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id, format, argv[0]);
1855
1856 ospf_area_nssa_unset (ospf, area_id);
1857 ospf_area_no_summary_unset (ospf, area_id);
1858
b0a053be 1859 ospf_schedule_abr_task (ospf);
1860
718e3744 1861 return CMD_SUCCESS;
1862}
1863
813d4307 1864ALIAS (no_ospf_area_nssa,
a2c62831 1865 no_ospf_area_nssa_no_summary_cmd,
813d4307 1866 "no area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always|) {no-summary}",
718e3744 1867 NO_STR
1868 "OSPF area parameters\n"
1869 "OSPF area ID in IP address format\n"
1870 "OSPF area ID as a decimal value\n"
1871 "Configure OSPF area as nssa\n"
813d4307
DW
1872 "Configure NSSA-ABR for translate election (default)\n"
1873 "Configure NSSA-ABR to never translate\n"
1874 "Configure NSSA-ABR to always translate\n"
718e3744 1875 "Do not inject inter-area routes into nssa\n")
718e3744 1876
a2c62831 1877DEFUN (ospf_area_default_cost,
1878 ospf_area_default_cost_cmd,
718e3744 1879 "area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1880 "OSPF area parameters\n"
1881 "OSPF area ID in IP address format\n"
1882 "OSPF area ID as a decimal value\n"
1883 "Set the summary-default cost of a NSSA or stub area\n"
1884 "Stub's advertised default summary cost\n")
1885{
68980084 1886 struct ospf *ospf = vty->index;
718e3744 1887 struct ospf_area *area;
1888 struct in_addr area_id;
1889 u_int32_t cost;
1890 int format;
ba682537 1891 struct prefix_ipv4 p;
718e3744 1892
7c8ff89e
DS
1893 if (!ospf)
1894 return CMD_SUCCESS;
1895
718e3744 1896 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1897 VTY_GET_INTEGER_RANGE ("stub default cost", cost, argv[1], 0, 16777215);
1898
68980084 1899 area = ospf_area_get (ospf, area_id, format);
718e3744 1900
1901 if (area->external_routing == OSPF_AREA_DEFAULT)
1902 {
1903 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1904 return CMD_WARNING;
1905 }
1906
1907 area->default_cost = cost;
1908
ba682537 1909 p.family = AF_INET;
1910 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1911 p.prefixlen = 0;
1912 if (IS_DEBUG_OSPF_EVENT)
1913 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1914 "announcing 0.0.0.0/0 to area %s",
1915 inet_ntoa (area->area_id));
1916 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1917
718e3744 1918 return CMD_SUCCESS;
1919}
1920
a2c62831 1921DEFUN (no_ospf_area_default_cost,
1922 no_ospf_area_default_cost_cmd,
718e3744 1923 "no area (A.B.C.D|<0-4294967295>) default-cost <0-16777215>",
1924 NO_STR
1925 "OSPF area parameters\n"
1926 "OSPF area ID in IP address format\n"
1927 "OSPF area ID as a decimal value\n"
1928 "Set the summary-default cost of a NSSA or stub area\n"
1929 "Stub's advertised default summary cost\n")
1930{
68980084 1931 struct ospf *ospf = vty->index;
718e3744 1932 struct ospf_area *area;
1933 struct in_addr area_id;
718e3744 1934 int format;
ba682537 1935 struct prefix_ipv4 p;
718e3744 1936
7c8ff89e
DS
1937 if (!ospf)
1938 return CMD_SUCCESS;
1939
718e3744 1940 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
0798cee3 1941 VTY_CHECK_INTEGER_RANGE ("stub default cost", argv[1], 0, OSPF_LS_INFINITY);
718e3744 1942
68980084 1943 area = ospf_area_lookup_by_area_id (ospf, area_id);
718e3744 1944 if (area == NULL)
1945 return CMD_SUCCESS;
1946
1947 if (area->external_routing == OSPF_AREA_DEFAULT)
1948 {
1949 vty_out (vty, "The area is neither stub, nor NSSA%s", VTY_NEWLINE);
1950 return CMD_WARNING;
1951 }
1952
1953 area->default_cost = 1;
1954
ba682537 1955 p.family = AF_INET;
1956 p.prefix.s_addr = OSPF_DEFAULT_DESTINATION;
1957 p.prefixlen = 0;
1958 if (IS_DEBUG_OSPF_EVENT)
1959 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1960 "announcing 0.0.0.0/0 to area %s",
1961 inet_ntoa (area->area_id));
1962 ospf_abr_announce_network_to_area (&p, area->default_cost, area);
1963
1964
68980084 1965 ospf_area_check_free (ospf, area_id);
718e3744 1966
1967 return CMD_SUCCESS;
1968}
1969
a2c62831 1970DEFUN (ospf_area_export_list,
1971 ospf_area_export_list_cmd,
718e3744 1972 "area (A.B.C.D|<0-4294967295>) export-list NAME",
1973 "OSPF area parameters\n"
1974 "OSPF area ID in IP address format\n"
1975 "OSPF area ID as a decimal value\n"
1976 "Set the filter for networks announced to other areas\n"
1977 "Name of the access-list\n")
1978{
68980084 1979 struct ospf *ospf = vty->index;
718e3744 1980 struct ospf_area *area;
1981 struct in_addr area_id;
1982 int format;
1983
7c8ff89e
DS
1984 if (!ospf)
1985 return CMD_SUCCESS;
1986
52930766 1987 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1988
68980084 1989 area = ospf_area_get (ospf, area_id, format);
1990 ospf_area_export_list_set (ospf, area, argv[1]);
718e3744 1991
1992 return CMD_SUCCESS;
1993}
1994
a2c62831 1995DEFUN (no_ospf_area_export_list,
1996 no_ospf_area_export_list_cmd,
718e3744 1997 "no area (A.B.C.D|<0-4294967295>) export-list NAME",
1998 NO_STR
1999 "OSPF area parameters\n"
2000 "OSPF area ID in IP address format\n"
2001 "OSPF area ID as a decimal value\n"
2002 "Unset the filter for networks announced to other areas\n"
2003 "Name of the access-list\n")
2004{
68980084 2005 struct ospf *ospf = vty->index;
718e3744 2006 struct ospf_area *area;
2007 struct in_addr area_id;
2008 int format;
2009
7c8ff89e
DS
2010 if (!ospf)
2011 return CMD_SUCCESS;
2012
52930766 2013 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2014
68980084 2015 area = ospf_area_lookup_by_area_id (ospf, area_id);
718e3744 2016 if (area == NULL)
2017 return CMD_SUCCESS;
2018
68980084 2019 ospf_area_export_list_unset (ospf, area);
718e3744 2020
2021 return CMD_SUCCESS;
2022}
2023
2024
a2c62831 2025DEFUN (ospf_area_import_list,
2026 ospf_area_import_list_cmd,
718e3744 2027 "area (A.B.C.D|<0-4294967295>) import-list NAME",
2028 "OSPF area parameters\n"
2029 "OSPF area ID in IP address format\n"
2030 "OSPF area ID as a decimal value\n"
2031 "Set the filter for networks from other areas announced to the specified one\n"
2032 "Name of the access-list\n")
2033{
68980084 2034 struct ospf *ospf = vty->index;
718e3744 2035 struct ospf_area *area;
2036 struct in_addr area_id;
2037 int format;
2038
7c8ff89e
DS
2039 if (!ospf)
2040 return CMD_SUCCESS;
2041
52930766 2042 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2043
68980084 2044 area = ospf_area_get (ospf, area_id, format);
2045 ospf_area_import_list_set (ospf, area, argv[1]);
718e3744 2046
2047 return CMD_SUCCESS;
2048}
2049
a2c62831 2050DEFUN (no_ospf_area_import_list,
2051 no_ospf_area_import_list_cmd,
718e3744 2052 "no area (A.B.C.D|<0-4294967295>) import-list NAME",
2053 NO_STR
2054 "OSPF area parameters\n"
2055 "OSPF area ID in IP address format\n"
2056 "OSPF area ID as a decimal value\n"
2057 "Unset the filter for networks announced to other areas\n"
2058 "Name of the access-list\n")
2059{
68980084 2060 struct ospf *ospf = vty->index;
718e3744 2061 struct ospf_area *area;
2062 struct in_addr area_id;
2063 int format;
2064
7c8ff89e
DS
2065 if (!ospf)
2066 return CMD_SUCCESS;
2067
52930766 2068 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2069
68980084 2070 area = ospf_area_lookup_by_area_id (ospf, area_id);
718e3744 2071 if (area == NULL)
2072 return CMD_SUCCESS;
2073
68980084 2074 ospf_area_import_list_unset (ospf, area);
718e3744 2075
2076 return CMD_SUCCESS;
2077}
2078
a2c62831 2079DEFUN (ospf_area_filter_list,
2080 ospf_area_filter_list_cmd,
718e3744 2081 "area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
2082 "OSPF area parameters\n"
2083 "OSPF area ID in IP address format\n"
2084 "OSPF area ID as a decimal value\n"
2085 "Filter networks between OSPF areas\n"
2086 "Filter prefixes between OSPF areas\n"
2087 "Name of an IP prefix-list\n"
2088 "Filter networks sent to this area\n"
2089 "Filter networks sent from this area\n")
2090{
68980084 2091 struct ospf *ospf = vty->index;
718e3744 2092 struct ospf_area *area;
2093 struct in_addr area_id;
2094 struct prefix_list *plist;
2095 int format;
2096
7c8ff89e
DS
2097 if (!ospf)
2098 return CMD_SUCCESS;
2099
718e3744 2100 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2101
68980084 2102 area = ospf_area_get (ospf, area_id, format);
718e3744 2103 plist = prefix_list_lookup (AFI_IP, argv[1]);
2104 if (strncmp (argv[2], "in", 2) == 0)
2105 {
2106 PREFIX_LIST_IN (area) = plist;
2107 if (PREFIX_NAME_IN (area))
2108 free (PREFIX_NAME_IN (area));
2109
2110 PREFIX_NAME_IN (area) = strdup (argv[1]);
68980084 2111 ospf_schedule_abr_task (ospf);
718e3744 2112 }
2113 else
2114 {
2115 PREFIX_LIST_OUT (area) = plist;
2116 if (PREFIX_NAME_OUT (area))
2117 free (PREFIX_NAME_OUT (area));
2118
2119 PREFIX_NAME_OUT (area) = strdup (argv[1]);
68980084 2120 ospf_schedule_abr_task (ospf);
718e3744 2121 }
2122
2123 return CMD_SUCCESS;
2124}
2125
a2c62831 2126DEFUN (no_ospf_area_filter_list,
2127 no_ospf_area_filter_list_cmd,
718e3744 2128 "no area (A.B.C.D|<0-4294967295>) filter-list prefix WORD (in|out)",
2129 NO_STR
2130 "OSPF area parameters\n"
2131 "OSPF area ID in IP address format\n"
2132 "OSPF area ID as a decimal value\n"
2133 "Filter networks between OSPF areas\n"
2134 "Filter prefixes between OSPF areas\n"
2135 "Name of an IP prefix-list\n"
2136 "Filter networks sent to this area\n"
2137 "Filter networks sent from this area\n")
2138{
68980084 2139 struct ospf *ospf = vty->index;
718e3744 2140 struct ospf_area *area;
2141 struct in_addr area_id;
718e3744 2142 int format;
2143
7c8ff89e
DS
2144 if (!ospf)
2145 return CMD_SUCCESS;
2146
718e3744 2147 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2148
1a8ec2b9
PJ
2149 if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL)
2150 return CMD_SUCCESS;
2151
718e3744 2152 if (strncmp (argv[2], "in", 2) == 0)
2153 {
2154 if (PREFIX_NAME_IN (area))
2155 if (strcmp (PREFIX_NAME_IN (area), argv[1]) != 0)
2156 return CMD_SUCCESS;
2157
2158 PREFIX_LIST_IN (area) = NULL;
2159 if (PREFIX_NAME_IN (area))
2160 free (PREFIX_NAME_IN (area));
2161
2162 PREFIX_NAME_IN (area) = NULL;
2163
68980084 2164 ospf_schedule_abr_task (ospf);
718e3744 2165 }
2166 else
2167 {
2168 if (PREFIX_NAME_OUT (area))
2169 if (strcmp (PREFIX_NAME_OUT (area), argv[1]) != 0)
2170 return CMD_SUCCESS;
2171
2172 PREFIX_LIST_OUT (area) = NULL;
2173 if (PREFIX_NAME_OUT (area))
2174 free (PREFIX_NAME_OUT (area));
2175
2176 PREFIX_NAME_OUT (area) = NULL;
2177
68980084 2178 ospf_schedule_abr_task (ospf);
718e3744 2179 }
2180
2181 return CMD_SUCCESS;
2182}
2183
6b0655a2 2184
a2c62831 2185DEFUN (ospf_area_authentication_message_digest,
2186 ospf_area_authentication_message_digest_cmd,
718e3744 2187 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
2188 "OSPF area parameters\n"
2b00515a
CF
2189 "OSPF area ID in IP address format\n"
2190 "OSPF area ID as a decimal value\n"
718e3744 2191 "Enable authentication\n"
2192 "Use message-digest authentication\n")
2193{
68980084 2194 struct ospf *ospf = vty->index;
718e3744 2195 struct ospf_area *area;
2196 struct in_addr area_id;
2197 int format;
2198
7c8ff89e
DS
2199 if (!ospf)
2200 return CMD_SUCCESS;
2201
718e3744 2202 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2203
68980084 2204 area = ospf_area_get (ospf, area_id, format);
718e3744 2205 area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
2206
2207 return CMD_SUCCESS;
2208}
2209
a2c62831 2210DEFUN (ospf_area_authentication,
2211 ospf_area_authentication_cmd,
718e3744 2212 "area (A.B.C.D|<0-4294967295>) authentication",
2213 "OSPF area parameters\n"
2214 "OSPF area ID in IP address format\n"
2215 "OSPF area ID as a decimal value\n"
2216 "Enable authentication\n")
2217{
68980084 2218 struct ospf *ospf = vty->index;
718e3744 2219 struct ospf_area *area;
2220 struct in_addr area_id;
2221 int format;
2222
7c8ff89e
DS
2223 if (!ospf)
2224 return CMD_SUCCESS;
2225
718e3744 2226 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2227
68980084 2228 area = ospf_area_get (ospf, area_id, format);
718e3744 2229 area->auth_type = OSPF_AUTH_SIMPLE;
2230
2231 return CMD_SUCCESS;
2232}
2233
a2c62831 2234DEFUN (no_ospf_area_authentication,
2235 no_ospf_area_authentication_cmd,
718e3744 2236 "no area (A.B.C.D|<0-4294967295>) authentication",
2237 NO_STR
2238 "OSPF area parameters\n"
2239 "OSPF area ID in IP address format\n"
2240 "OSPF area ID as a decimal value\n"
2241 "Enable authentication\n")
2242{
68980084 2243 struct ospf *ospf = vty->index;
718e3744 2244 struct ospf_area *area;
2245 struct in_addr area_id;
2246 int format;
2247
7c8ff89e
DS
2248 if (!ospf)
2249 return CMD_SUCCESS;
2250
718e3744 2251 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2252
68980084 2253 area = ospf_area_lookup_by_area_id (ospf, area_id);
718e3744 2254 if (area == NULL)
2255 return CMD_SUCCESS;
2256
2257 area->auth_type = OSPF_AUTH_NULL;
2258
68980084 2259 ospf_area_check_free (ospf, area_id);
718e3744 2260
2261 return CMD_SUCCESS;
2262}
2263
6b0655a2 2264
718e3744 2265DEFUN (ospf_abr_type,
2266 ospf_abr_type_cmd,
2267 "ospf abr-type (cisco|ibm|shortcut|standard)",
2268 "OSPF specific commands\n"
2269 "Set OSPF ABR type\n"
2270 "Alternative ABR, cisco implementation\n"
2271 "Alternative ABR, IBM implementation\n"
2272 "Shortcut ABR\n"
2273 "Standard behavior (RFC2328)\n")
2274{
68980084 2275 struct ospf *ospf = vty->index;
718e3744 2276 u_char abr_type = OSPF_ABR_UNKNOWN;
2277
7c8ff89e
DS
2278 if (!ospf)
2279 return CMD_SUCCESS;
2280
718e3744 2281 if (strncmp (argv[0], "c", 1) == 0)
2282 abr_type = OSPF_ABR_CISCO;
2283 else if (strncmp (argv[0], "i", 1) == 0)
2284 abr_type = OSPF_ABR_IBM;
2285 else if (strncmp (argv[0], "sh", 2) == 0)
2286 abr_type = OSPF_ABR_SHORTCUT;
2287 else if (strncmp (argv[0], "st", 2) == 0)
2288 abr_type = OSPF_ABR_STAND;
2289 else
2290 return CMD_WARNING;
2291
2292 /* If ABR type value is changed, schedule ABR task. */
68980084 2293 if (ospf->abr_type != abr_type)
718e3744 2294 {
68980084 2295 ospf->abr_type = abr_type;
2296 ospf_schedule_abr_task (ospf);
718e3744 2297 }
2298
2299 return CMD_SUCCESS;
2300}
2301
2302DEFUN (no_ospf_abr_type,
2303 no_ospf_abr_type_cmd,
d57834f6 2304 "no ospf abr-type (cisco|ibm|shortcut|standard)",
718e3744 2305 NO_STR
2306 "OSPF specific commands\n"
2307 "Set OSPF ABR type\n"
2308 "Alternative ABR, cisco implementation\n"
2309 "Alternative ABR, IBM implementation\n"
2310 "Shortcut ABR\n")
2311{
68980084 2312 struct ospf *ospf = vty->index;
718e3744 2313 u_char abr_type = OSPF_ABR_UNKNOWN;
2314
7c8ff89e
DS
2315 if (!ospf)
2316 return CMD_SUCCESS;
2317
718e3744 2318 if (strncmp (argv[0], "c", 1) == 0)
2319 abr_type = OSPF_ABR_CISCO;
2320 else if (strncmp (argv[0], "i", 1) == 0)
2321 abr_type = OSPF_ABR_IBM;
04d23314 2322 else if (strncmp (argv[0], "sh", 2) == 0)
718e3744 2323 abr_type = OSPF_ABR_SHORTCUT;
04d23314
FD
2324 else if (strncmp (argv[0], "st", 2) == 0)
2325 abr_type = OSPF_ABR_STAND;
718e3744 2326 else
2327 return CMD_WARNING;
2328
2329 /* If ABR type value is changed, schedule ABR task. */
68980084 2330 if (ospf->abr_type == abr_type)
718e3744 2331 {
d57834f6 2332 ospf->abr_type = OSPF_ABR_DEFAULT;
68980084 2333 ospf_schedule_abr_task (ospf);
718e3744 2334 }
2335
2336 return CMD_SUCCESS;
2337}
2338
d7e60dd7
AS
2339DEFUN (ospf_log_adjacency_changes,
2340 ospf_log_adjacency_changes_cmd,
2341 "log-adjacency-changes",
2342 "Log changes in adjacency state\n")
2343{
2344 struct ospf *ospf = vty->index;
2345
7c8ff89e
DS
2346 if (!ospf)
2347 return CMD_SUCCESS;
2348
d7e60dd7 2349 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
692c7954 2350 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
d7e60dd7
AS
2351 return CMD_SUCCESS;
2352}
2353
2354DEFUN (ospf_log_adjacency_changes_detail,
2355 ospf_log_adjacency_changes_detail_cmd,
2356 "log-adjacency-changes detail",
2357 "Log changes in adjacency state\n"
2358 "Log all state changes\n")
2359{
2360 struct ospf *ospf = vty->index;
2361
7c8ff89e
DS
2362 if (!ospf)
2363 return CMD_SUCCESS;
2364
d7e60dd7
AS
2365 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2366 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2367 return CMD_SUCCESS;
2368}
2369
2370DEFUN (no_ospf_log_adjacency_changes,
2371 no_ospf_log_adjacency_changes_cmd,
2372 "no log-adjacency-changes",
2373 NO_STR
2374 "Log changes in adjacency state\n")
2375{
2376 struct ospf *ospf = vty->index;
2377
7c8ff89e
DS
2378 if (!ospf)
2379 return CMD_SUCCESS;
2380
d7e60dd7
AS
2381 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2382 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2383 return CMD_SUCCESS;
2384}
2385
2386DEFUN (no_ospf_log_adjacency_changes_detail,
2387 no_ospf_log_adjacency_changes_detail_cmd,
2388 "no log-adjacency-changes detail",
2389 NO_STR
2390 "Log changes in adjacency state\n"
2391 "Log all state changes\n")
2392{
2393 struct ospf *ospf = vty->index;
2394
7c8ff89e
DS
2395 if (!ospf)
2396 return CMD_SUCCESS;
2397
692c7954 2398 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
d7e60dd7
AS
2399 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2400 return CMD_SUCCESS;
2401}
2402
718e3744 2403DEFUN (ospf_compatible_rfc1583,
2404 ospf_compatible_rfc1583_cmd,
2405 "compatible rfc1583",
2406 "OSPF compatibility list\n"
2407 "compatible with RFC 1583\n")
2408{
2409 struct ospf *ospf = vty->index;
2410
7c8ff89e
DS
2411 if (!ospf)
2412 return CMD_SUCCESS;
2413
718e3744 2414 if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2415 {
2416 SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
d3a9c768 2417 ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE);
718e3744 2418 }
2419 return CMD_SUCCESS;
2420}
2421
2422DEFUN (no_ospf_compatible_rfc1583,
2423 no_ospf_compatible_rfc1583_cmd,
2424 "no compatible rfc1583",
2425 NO_STR
2426 "OSPF compatibility list\n"
2427 "compatible with RFC 1583\n")
2428{
2429 struct ospf *ospf = vty->index;
2430
7c8ff89e
DS
2431 if (!ospf)
2432 return CMD_SUCCESS;
2433
718e3744 2434 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2435 {
2436 UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
d3a9c768 2437 ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE);
718e3744 2438 }
2439 return CMD_SUCCESS;
2440}
2441
2442ALIAS (ospf_compatible_rfc1583,
2443 ospf_rfc1583_flag_cmd,
2444 "ospf rfc1583compatibility",
2445 "OSPF specific commands\n"
2446 "Enable the RFC1583Compatibility flag\n")
2447
2448ALIAS (no_ospf_compatible_rfc1583,
2449 no_ospf_rfc1583_flag_cmd,
2450 "no ospf rfc1583compatibility",
2451 NO_STR
2452 "OSPF specific commands\n"
2453 "Disable the RFC1583Compatibility flag\n")
6b0655a2 2454
d24f6e2a 2455static int
2456ospf_timers_spf_set (struct vty *vty, unsigned int delay,
2457 unsigned int hold,
2458 unsigned int max)
2459{
2460 struct ospf *ospf = vty->index;
2461
7c8ff89e
DS
2462 if (!ospf)
2463 return CMD_SUCCESS;
2464
d24f6e2a 2465 ospf->spf_delay = delay;
2466 ospf->spf_holdtime = hold;
2467 ospf->spf_max_holdtime = max;
2468
2469 return CMD_SUCCESS;
2470}
718e3744 2471
ac7424f9
MR
2472DEFUN (ospf_timers_min_ls_interval,
2473 ospf_timers_min_ls_interval_cmd,
2474 "timers throttle lsa all <0-5000>",
2475 "Adjust routing timers\n"
2476 "Throttling adaptive timer\n"
2477 "LSA delay between transmissions\n"
813d4307 2478 "All LSA types\n"
ac7424f9
MR
2479 "Delay (msec) between sending LSAs\n")
2480{
2481 struct ospf *ospf = vty->index;
2482 unsigned int interval;
2483
d8f70b86
DS
2484 if (!ospf)
2485 return CMD_SUCCESS;
2486
ac7424f9
MR
2487 if (argc != 1)
2488 {
2489 vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
2490 return CMD_WARNING;
2491 }
2492
2493 VTY_GET_INTEGER ("LSA interval", interval, argv[0]);
2494
2495 ospf->min_ls_interval = interval;
2496
2497 return CMD_SUCCESS;
2498}
2499
2500DEFUN (no_ospf_timers_min_ls_interval,
2501 no_ospf_timers_min_ls_interval_cmd,
2502 "no timers throttle lsa all",
2503 NO_STR
2504 "Adjust routing timers\n"
2505 "Throttling adaptive timer\n"
813d4307
DW
2506 "LSA delay between transmissions\n"
2507 "All LSA types\n")
ac7424f9
MR
2508{
2509 struct ospf *ospf = vty->index;
2510 ospf->min_ls_interval = OSPF_MIN_LS_INTERVAL;
2511
2512 return CMD_SUCCESS;
2513}
2514
813d4307
DW
2515ALIAS (no_ospf_timers_min_ls_interval,
2516 no_ospf_timers_min_ls_interval_val_cmd,
2517 "no timers throttle lsa all <0-5000>",
2518 NO_STR
2519 "Adjust routing timers\n"
2520 "Throttling adaptive timer\n"
2521 "LSA delay between transmissions\n"
2522 "All LSA types\n"
2523 "Delay (msec) between sending LSAs\n")
2524
ac7424f9
MR
2525DEFUN (ospf_timers_min_ls_arrival,
2526 ospf_timers_min_ls_arrival_cmd,
2527 "timers lsa arrival <0-1000>",
2528 "Adjust routing timers\n"
2529 "Throttling link state advertisement delays\n"
2530 "OSPF minimum arrival interval delay\n"
2531 "Delay (msec) between accepted LSAs\n")
2532{
2533 struct ospf *ospf = vty->index;
2534 unsigned int arrival;
2535
d8f70b86
DS
2536 if (!ospf)
2537 return CMD_SUCCESS;
2538
ac7424f9
MR
2539 if (argc != 1)
2540 {
2541 vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
2542 return CMD_WARNING;
2543 }
2544
2545 VTY_GET_INTEGER_RANGE ("minimum LSA inter-arrival time", arrival, argv[0], 0, 1000);
2546
2547 ospf->min_ls_arrival = arrival;
2548
2549 return CMD_SUCCESS;
2550}
2551
2552DEFUN (no_ospf_timers_min_ls_arrival,
2553 no_ospf_timers_min_ls_arrival_cmd,
2554 "no timers lsa arrival",
2555 NO_STR
2556 "Adjust routing timers\n"
2557 "Throttling link state advertisement delays\n"
2558 "OSPF minimum arrival interval delay\n")
2559{
2560 struct ospf *ospf = vty->index;
d8f70b86
DS
2561
2562 if (!ospf)
2563 return CMD_SUCCESS;
2564
ac7424f9
MR
2565 ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL;
2566
2567 return CMD_SUCCESS;
2568}
2569
813d4307
DW
2570ALIAS (no_ospf_timers_min_ls_arrival,
2571 no_ospf_timers_min_ls_arrival_val_cmd,
2572 "no timers lsa arrival <0-1000>",
2573 NO_STR
2574 "Adjust routing timers\n"
2575 "Throttling link state advertisement delays\n"
2576 "OSPF minimum arrival interval delay\n"
2577 "Delay (msec) between accepted LSAs\n")
2578
d24f6e2a 2579DEFUN (ospf_timers_throttle_spf,
2580 ospf_timers_throttle_spf_cmd,
2581 "timers throttle spf <0-600000> <0-600000> <0-600000>",
2582 "Adjust routing timers\n"
2583 "Throttling adaptive timer\n"
2584 "OSPF SPF timers\n"
2585 "Delay (msec) from first change received till SPF calculation\n"
2586 "Initial hold time (msec) between consecutive SPF calculations\n"
2587 "Maximum hold time (msec)\n")
2588{
2589 unsigned int delay, hold, max;
2590
2591 if (argc != 3)
2592 {
2593 vty_out (vty, "Insufficient arguments%s", VTY_NEWLINE);
2594 return CMD_WARNING;
2595 }
2596
2597 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay, argv[0], 0, 600000);
2598 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold, argv[1], 0, 600000);
2599 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max, argv[2], 0, 600000);
2600
2601 return ospf_timers_spf_set (vty, delay, hold, max);
2602}
2603
d24f6e2a 2604DEFUN (no_ospf_timers_throttle_spf,
2605 no_ospf_timers_throttle_spf_cmd,
2606 "no timers throttle spf",
718e3744 2607 NO_STR
2608 "Adjust routing timers\n"
d24f6e2a 2609 "Throttling adaptive timer\n"
718e3744 2610 "OSPF SPF timers\n")
2611{
d24f6e2a 2612 return ospf_timers_spf_set (vty,
2613 OSPF_SPF_DELAY_DEFAULT,
2614 OSPF_SPF_HOLDTIME_DEFAULT,
2615 OSPF_SPF_MAX_HOLDTIME_DEFAULT);
718e3744 2616}
2617
b4a039bf
DS
2618ALIAS (no_ospf_timers_throttle_spf,
2619 no_ospf_timers_throttle_spf_val_cmd,
813d4307 2620 "no timers throttle spf <0-600000> <0-600000> <0-600000>",
b4a039bf
DS
2621 NO_STR
2622 "Adjust routing timers\n"
2623 "Throttling adaptive timer\n"
2624 "OSPF SPF timers\n"
2625 "Delay (msec) from first change received till SPF calculation\n"
2626 "Initial hold time (msec) between consecutive SPF calculations\n"
2627 "Maximum hold time (msec)\n")
2628
b6927875
DS
2629DEFUN (ospf_timers_lsa,
2630 ospf_timers_lsa_cmd,
2631 "timers lsa min-arrival <0-600000>",
2632 "Adjust routing timers\n"
2633 "OSPF LSA timers\n"
2634 "Minimum delay in receiving new version of a LSA\n"
2635 "Delay in milliseconds\n")
2636{
2637 unsigned int minarrival;
2638 struct ospf *ospf = vty->index;
2639
2640 if (!ospf)
2641 return CMD_SUCCESS;
2642
2643 if (argc != 1)
2644 {
2645 vty_out (vty, "Insufficient number of arguments%s", VTY_NEWLINE);
2646 return CMD_WARNING;
2647 }
2648
2649 VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[0]);
2650
ac7424f9 2651 ospf->min_ls_arrival = minarrival;
b6927875
DS
2652
2653 return CMD_SUCCESS;
2654}
2655
2656DEFUN (no_ospf_timers_lsa,
2657 no_ospf_timers_lsa_cmd,
2658 "no timers lsa min-arrival",
2659 NO_STR
2660 "Adjust routing timers\n"
2661 "OSPF LSA timers\n"
2662 "Minimum delay in receiving new version of a LSA\n")
2663{
2664 unsigned int minarrival;
2665 struct ospf *ospf = vty->index;
2666
2667 if (!ospf)
2668 return CMD_SUCCESS;
2669
2670 if (argc)
2671 {
2672 VTY_GET_INTEGER ("LSA min-arrival", minarrival, argv[0]);
2673
ac7424f9 2674 if (ospf->min_ls_arrival != minarrival ||
b6927875
DS
2675 minarrival == OSPF_MIN_LS_ARRIVAL)
2676 return CMD_SUCCESS;
2677 }
2678
ac7424f9 2679 ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL;
b6927875
DS
2680
2681 return CMD_SUCCESS;
2682}
2683
2684ALIAS (no_ospf_timers_lsa,
2685 no_ospf_timers_lsa_val_cmd,
2686 "no timers lsa min-arrival <0-600000>",
2687 NO_STR
2688 "Adjust routing timers\n"
2689 "OSPF LSA timers\n"
2690 "Minimum delay in receiving new version of a LSA\n"
2691 "Delay in milliseconds\n")
2692
2693
a2c62831 2694DEFUN (ospf_neighbor,
2695 ospf_neighbor_cmd,
718e3744 2696 "neighbor A.B.C.D",
2697 NEIGHBOR_STR
2698 "Neighbor IP address\n")
2699{
2700 struct ospf *ospf = vty->index;
2701 struct in_addr nbr_addr;
eb1ce605 2702 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2703 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
718e3744 2704
7c8ff89e
DS
2705 if (!ospf)
2706 return CMD_SUCCESS;
2707
718e3744 2708 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2709
2710 if (argc > 1)
2711 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[1], 0, 255);
2712
2713 if (argc > 2)
2714 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[2], 1, 65535);
2715
2716 ospf_nbr_nbma_set (ospf, nbr_addr);
2717 if (argc > 1)
2718 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2719 if (argc > 2)
1a61ad10 2720 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
718e3744 2721
2722 return CMD_SUCCESS;
2723}
2724
a2c62831 2725ALIAS (ospf_neighbor,
2726 ospf_neighbor_priority_poll_interval_cmd,
718e3744 2727 "neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2728 NEIGHBOR_STR
2729 "Neighbor IP address\n"
2730 "Neighbor Priority\n"
2731 "Priority\n"
2732 "Dead Neighbor Polling interval\n"
2733 "Seconds\n")
2734
a2c62831 2735ALIAS (ospf_neighbor,
2736 ospf_neighbor_priority_cmd,
718e3744 2737 "neighbor A.B.C.D priority <0-255>",
2738 NEIGHBOR_STR
2739 "Neighbor IP address\n"
2740 "Neighbor Priority\n"
2741 "Seconds\n")
2742
a2c62831 2743DEFUN (ospf_neighbor_poll_interval,
2744 ospf_neighbor_poll_interval_cmd,
718e3744 2745 "neighbor A.B.C.D poll-interval <1-65535>",
2746 NEIGHBOR_STR
2747 "Neighbor IP address\n"
2748 "Dead Neighbor Polling interval\n"
2749 "Seconds\n")
2750{
2751 struct ospf *ospf = vty->index;
2752 struct in_addr nbr_addr;
eb1ce605 2753 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2754 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
718e3744 2755
7c8ff89e
DS
2756 if (!ospf)
2757 return CMD_SUCCESS;
2758
718e3744 2759 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2760
2761 if (argc > 1)
2762 VTY_GET_INTEGER_RANGE ("poll interval", interval, argv[1], 1, 65535);
2763
2764 if (argc > 2)
2765 VTY_GET_INTEGER_RANGE ("neighbor priority", priority, argv[2], 0, 255);
2766
2767 ospf_nbr_nbma_set (ospf, nbr_addr);
2768 if (argc > 1)
2769 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
2770 if (argc > 2)
2771 ospf_nbr_nbma_priority_set (ospf, nbr_addr, priority);
2772
2773 return CMD_SUCCESS;
2774}
2775
a2c62831 2776ALIAS (ospf_neighbor_poll_interval,
2777 ospf_neighbor_poll_interval_priority_cmd,
718e3744 2778 "neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2779 NEIGHBOR_STR
2780 "Neighbor address\n"
2781 "OSPF dead-router polling interval\n"
2782 "Seconds\n"
2783 "OSPF priority of non-broadcast neighbor\n"
2784 "Priority\n")
2785
a2c62831 2786DEFUN (no_ospf_neighbor,
2787 no_ospf_neighbor_cmd,
718e3744 2788 "no neighbor A.B.C.D",
2789 NO_STR
2790 NEIGHBOR_STR
2791 "Neighbor IP address\n")
2792{
2793 struct ospf *ospf = vty->index;
2794 struct in_addr nbr_addr;
718e3744 2795
7c8ff89e
DS
2796 if (!ospf)
2797 return CMD_SUCCESS;
2798
718e3744 2799 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2800
0798cee3 2801 (void)ospf_nbr_nbma_unset (ospf, nbr_addr);
718e3744 2802
2803 return CMD_SUCCESS;
2804}
2805
a2c62831 2806ALIAS (no_ospf_neighbor,
2807 no_ospf_neighbor_priority_cmd,
718e3744 2808 "no neighbor A.B.C.D priority <0-255>",
2809 NO_STR
2810 NEIGHBOR_STR
2811 "Neighbor IP address\n"
2812 "Neighbor Priority\n"
2813 "Priority\n")
2814
a2c62831 2815ALIAS (no_ospf_neighbor,
2816 no_ospf_neighbor_poll_interval_cmd,
718e3744 2817 "no neighbor A.B.C.D poll-interval <1-65535>",
2818 NO_STR
2819 NEIGHBOR_STR
2820 "Neighbor IP address\n"
2821 "Dead Neighbor Polling interval\n"
2822 "Seconds\n")
2823
813d4307
DW
2824ALIAS (no_ospf_neighbor,
2825 no_ospf_neighbor_poll_interval_priority_cmd,
2826 "no neighbor A.B.C.D poll-interval <1-65535> priority <0-255>",
2827 NO_STR
2828 NEIGHBOR_STR
2829 "Neighbor IP address\n"
2830 "Dead Neighbor Polling interval\n"
2831 "Seconds\n"
2832 "OSPF priority of non-broadcast neighbor\n"
2833 "Priority\n")
2834
a2c62831 2835ALIAS (no_ospf_neighbor,
2836 no_ospf_neighbor_priority_pollinterval_cmd,
718e3744 2837 "no neighbor A.B.C.D priority <0-255> poll-interval <1-65535>",
2838 NO_STR
2839 NEIGHBOR_STR
2840 "Neighbor IP address\n"
2841 "Neighbor Priority\n"
2842 "Priority\n"
2843 "Dead Neighbor Polling interval\n"
2844 "Seconds\n")
2845
a2c62831 2846DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
718e3744 2847 "refresh timer <10-1800>",
2848 "Adjust refresh parameters\n"
2849 "Set refresh timer\n"
2850 "Timer value in seconds\n")
2851{
2852 struct ospf *ospf = vty->index;
eb1ce605 2853 unsigned int interval;
718e3744 2854
7c8ff89e
DS
2855 if (!ospf)
2856 return CMD_SUCCESS;
2857
718e3744 2858 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
535c84b1 2859 interval = (interval / OSPF_LSA_REFRESHER_GRANULARITY) * OSPF_LSA_REFRESHER_GRANULARITY;
718e3744 2860
2861 ospf_timers_refresh_set (ospf, interval);
2862
2863 return CMD_SUCCESS;
2864}
2865
a2c62831 2866DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
718e3744 2867 "no refresh timer <10-1800>",
2868 "Adjust refresh parameters\n"
2869 "Unset refresh timer\n"
2870 "Timer value in seconds\n")
2871{
2872 struct ospf *ospf = vty->index;
eb1ce605 2873 unsigned int interval;
718e3744 2874
7c8ff89e
DS
2875 if (!ospf)
2876 return CMD_SUCCESS;
2877
718e3744 2878 if (argc == 1)
2879 {
2880 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2881
2882 if (ospf->lsa_refresh_interval != interval ||
2883 interval == OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
2884 return CMD_SUCCESS;
2885 }
2886
2887 ospf_timers_refresh_unset (ospf);
2888
2889 return CMD_SUCCESS;
2890}
2891
a2c62831 2892ALIAS (no_ospf_refresh_timer,
2893 no_ospf_refresh_timer_cmd,
718e3744 2894 "no refresh timer",
2895 "Adjust refresh parameters\n"
2896 "Unset refresh timer\n")
2897
a2c62831 2898DEFUN (ospf_auto_cost_reference_bandwidth,
2899 ospf_auto_cost_reference_bandwidth_cmd,
718e3744 2900 "auto-cost reference-bandwidth <1-4294967>",
2901 "Calculate OSPF interface cost according to bandwidth\n"
2902 "Use reference bandwidth method to assign OSPF cost\n"
2903 "The reference bandwidth in terms of Mbits per second\n")
2904{
68980084 2905 struct ospf *ospf = vty->index;
718e3744 2906 u_int32_t refbw;
52dc7ee6 2907 struct listnode *node;
1eb8ef25 2908 struct interface *ifp;
718e3744 2909
7c8ff89e
DS
2910 if (!ospf)
2911 return CMD_SUCCESS;
2912
718e3744 2913 refbw = strtol (argv[0], NULL, 10);
2914 if (refbw < 1 || refbw > 4294967)
2915 {
2916 vty_out (vty, "reference-bandwidth value is invalid%s", VTY_NEWLINE);
2917 return CMD_WARNING;
2918 }
2919
2920 /* If reference bandwidth is changed. */
70bd3c43 2921 if ((refbw) == ospf->ref_bandwidth)
718e3744 2922 return CMD_SUCCESS;
2923
70bd3c43 2924 ospf->ref_bandwidth = refbw;
1eb8ef25 2925 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
2926 ospf_if_recalculate_output_cost (ifp);
718e3744 2927
2928 return CMD_SUCCESS;
2929}
2930
a2c62831 2931DEFUN (no_ospf_auto_cost_reference_bandwidth,
2932 no_ospf_auto_cost_reference_bandwidth_cmd,
718e3744 2933 "no auto-cost reference-bandwidth",
2934 NO_STR
2935 "Calculate OSPF interface cost according to bandwidth\n"
2936 "Use reference bandwidth method to assign OSPF cost\n")
2937{
68980084 2938 struct ospf *ospf = vty->index;
1eb8ef25 2939 struct listnode *node, *nnode;
2940 struct interface *ifp;
718e3744 2941
7c8ff89e
DS
2942 if (!ospf)
2943 return CMD_SUCCESS;
2944
68980084 2945 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
718e3744 2946 return CMD_SUCCESS;
2947
68980084 2948 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
718e3744 2949 vty_out (vty, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE);
2950 vty_out (vty, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE);
2951
1eb8ef25 2952 for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp))
2953 ospf_if_recalculate_output_cost (ifp);
718e3744 2954
2955 return CMD_SUCCESS;
2956}
2957
813d4307
DW
2958ALIAS (no_ospf_auto_cost_reference_bandwidth,
2959 no_ospf_auto_cost_reference_bandwidth_val_cmd,
2960 "no auto-cost reference-bandwidth <1-4294967>",
2961 NO_STR
2962 "Calculate OSPF interface cost according to bandwidth\n"
2963 "Use reference bandwidth method to assign OSPF cost\n"
2964 "The reference bandwidth in terms of Mbits per second\n")
2965
2f8f370e
DS
2966DEFUN (ospf_write_multiplier,
2967 ospf_write_multiplier_cmd,
e8f45e82
DS
2968 "ospf write-multiplier <1-100>",
2969 "OSPF specific commands\n"
2970 "Write multiplier\n"
2971 "Maximum number of interface serviced per write\n")
2f8f370e
DS
2972{
2973 struct ospf *ospf = vty->index;
e8f45e82 2974 u_int32_t write_oi_count;
2f8f370e 2975
7c8ff89e
DS
2976 if (!ospf)
2977 return CMD_SUCCESS;
2978
e8f45e82
DS
2979 write_oi_count = strtol (argv[0], NULL, 10);
2980 if (write_oi_count < 1 || write_oi_count > 100)
2f8f370e
DS
2981 {
2982 vty_out (vty, "write-multiplier value is invalid%s", VTY_NEWLINE);
2983 return CMD_WARNING;
2984 }
2985
e8f45e82 2986 ospf->write_oi_count = write_oi_count;
2f8f370e
DS
2987 return CMD_SUCCESS;
2988}
2989
e8f45e82
DS
2990ALIAS (ospf_write_multiplier,
2991 write_multiplier_cmd,
2992 "write-multiplier <1-100>",
2993 "Write multiplier\n"
2994 "Maximum number of interface serviced per write\n")
2995
2f8f370e
DS
2996DEFUN (no_ospf_write_multiplier,
2997 no_ospf_write_multiplier_cmd,
813d4307 2998 "no ospf write-multiplier <1-100>",
2f8f370e 2999 NO_STR
e8f45e82 3000 "OSPF specific commands\n"
813d4307
DW
3001 "Write multiplier\n"
3002 "Maximum number of interface serviced per write\n")
2f8f370e
DS
3003{
3004 struct ospf *ospf = vty->index;
3005
7c8ff89e
DS
3006 if (!ospf)
3007 return CMD_SUCCESS;
3008
e8f45e82 3009 ospf->write_oi_count = OSPF_WRITE_INTERFACE_COUNT_DEFAULT;
2f8f370e
DS
3010 return CMD_SUCCESS;
3011}
3012
e8f45e82
DS
3013ALIAS (no_ospf_write_multiplier,
3014 no_write_multiplier_cmd,
3015 "no write-multiplier",
3016 NO_STR
3017 "Write multiplier\n")
3018
813d4307
DW
3019ALIAS (no_ospf_write_multiplier,
3020 no_write_multiplier_val_cmd,
3021 "no write-multiplier <1-100>",
3022 NO_STR
3023 "Write multiplier\n"
3024 "Maximum number of interface serviced per write\n")
3025
eb1ce605 3026const char *ospf_abr_type_descr_str[] =
718e3744 3027{
3028 "Unknown",
3029 "Standard (RFC2328)",
3030 "Alternative IBM",
3031 "Alternative Cisco",
3032 "Alternative Shortcut"
3033};
3034
eb1ce605 3035const char *ospf_shortcut_mode_descr_str[] =
718e3744 3036{
3037 "Default",
3038 "Enabled",
3039 "Disabled"
3040};
3041
4dadc291 3042static void
ca08c43d 3043show_ip_ospf_area (struct vty *vty, struct ospf_area *area, json_object *json_areas, u_char use_json)
718e3744 3044{
ca08c43d
DS
3045 json_object *json_area = NULL;
3046
3047 if (use_json)
3048 json_area = json_object_new_object();
3049
718e3744 3050 /* Show Area ID. */
ca08c43d
DS
3051 if (!use_json)
3052 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
718e3744 3053
3054 /* Show Area type/mode. */
3055 if (OSPF_IS_AREA_BACKBONE (area))
ca08c43d
DS
3056 {
3057 if (use_json)
3058 json_object_boolean_true_add(json_area, "backbone");
3059 else
3060 vty_out (vty, " (Backbone)%s", VTY_NEWLINE);
3061 }
718e3744 3062 else
3063 {
ca08c43d
DS
3064 if (use_json)
3065 {
3066 if (area->external_routing == OSPF_AREA_STUB)
3067 {
3068 if (area->no_summary)
3069 json_object_boolean_true_add(json_area, "stubNoSummary");
3070 if (area->shortcut_configured)
3071 json_object_boolean_true_add(json_area, "stubShortcut");
3072 }
3073 else if (area->external_routing == OSPF_AREA_NSSA)
3074 {
3075 if (area->no_summary)
3076 json_object_boolean_true_add(json_area, "nssaNoSummary");
3077 if (area->shortcut_configured)
3078 json_object_boolean_true_add(json_area, "nssaShortcut");
3079 }
3080
3081 json_object_string_add(json_area,"shortcuttingMode",
3082 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
3083 if (area->shortcut_capability)
3084 json_object_boolean_true_add(json_area,"sBitConcensus");
3085 }
3086 else
3087 {
3088 if (area->external_routing == OSPF_AREA_STUB)
3089 vty_out (vty, " (Stub%s%s)",
3090 area->no_summary ? ", no summary" : "",
3091 area->shortcut_configured ? "; " : "");
3092 else if (area->external_routing == OSPF_AREA_NSSA)
3093 vty_out (vty, " (NSSA%s%s)",
3094 area->no_summary ? ", no summary" : "",
3095 area->shortcut_configured ? "; " : "");
3096
3097 vty_out (vty, "%s", VTY_NEWLINE);
3098 vty_out (vty, " Shortcutting mode: %s",
3099 ospf_shortcut_mode_descr_str[area->shortcut_configured]);
3100 vty_out (vty, ", S-bit consensus: %s%s",
3101 area->shortcut_capability ? "ok" : "no", VTY_NEWLINE);
3102 }
3103 }
3104
3105 /* Show number of interfaces */
3106 if (use_json)
3107 {
3ac237f8
MS
3108 json_object_int_add(json_area, "areaIfTotalCounter", listcount (area->oiflist));
3109 json_object_int_add(json_area, "areaIfActiveCounter", area->act_ints);
718e3744 3110 }
ca08c43d
DS
3111 else
3112 vty_out (vty, " Number of interfaces in this area: Total: %d, "
3113 "Active: %d%s", listcount (area->oiflist),
3114 area->act_ints, VTY_NEWLINE);
718e3744 3115
718e3744 3116 if (area->external_routing == OSPF_AREA_NSSA)
3117 {
ca08c43d
DS
3118 if (use_json)
3119 {
3120 json_object_boolean_true_add(json_area, "nssa");
3121 if (! IS_OSPF_ABR (area->ospf))
3122 json_object_boolean_false_add(json_area, "abr");
3123 else if (area->NSSATranslatorState)
3124 {
3125 json_object_boolean_true_add(json_area, "abr");
3126 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
3127 json_object_boolean_true_add(json_area, "nssaTranslatorElected");
3128 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
3129 json_object_boolean_true_add(json_area, "nssaTranslatorAlways");
3130 }
3131 else
3132 {
3133 json_object_boolean_true_add(json_area, "abr");
3134 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
3135 json_object_boolean_false_add(json_area, "nssaTranslatorElected");
3136 else
3137 json_object_boolean_true_add(json_area, "nssaTranslatorNever");
3138 }
3139 }
718e3744 3140 else
ca08c43d
DS
3141 {
3142 vty_out (vty, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE, VTY_NEWLINE);
3143 if (! IS_OSPF_ABR (area->ospf))
3144 vty_out (vty, " It is not ABR, therefore not Translator. %s",
3145 VTY_NEWLINE);
3146 else if (area->NSSATranslatorState)
3147 {
3148 vty_out (vty, " We are an ABR and ");
3149 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
3150 vty_out (vty, "the NSSA Elected Translator. %s",
3151 VTY_NEWLINE);
3152 else if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_ALWAYS)
3153 vty_out (vty, "always an NSSA Translator. %s",
3154 VTY_NEWLINE);
3155 }
3156 else
3157 {
3158 vty_out (vty, " We are an ABR, but ");
3159 if (area->NSSATranslatorRole == OSPF_NSSA_ROLE_CANDIDATE)
3160 vty_out (vty, "not the NSSA Elected Translator. %s",
3161 VTY_NEWLINE);
3162 else
3163 vty_out (vty, "never an NSSA Translator. %s",
3164 VTY_NEWLINE);
3165 }
3166 }
718e3744 3167 }
ca08c43d 3168
88d6cf37 3169 /* Stub-router state for this area */
3170 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
3171 {
649654ab 3172 char timebuf[OSPF_TIME_DUMP_SIZE];
ca08c43d
DS
3173
3174 if (use_json)
3175 {
3176 json_object_boolean_true_add(json_area, "originStubMaxDistRouterLsa");
3177 if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
3178 json_object_boolean_true_add(json_area, "indefiniteActiveAdmin");
3179 if (area->t_stub_router)
3180 {
3181 struct timeval result;
3182 unsigned long time_store = 0;
3183 result = tv_sub (area->t_stub_router->u.sands, recent_relative_time());
3184 time_store = (1000 * result.tv_sec) + (result.tv_usec / 1000);
3185 json_object_int_add(json_area, "activeStartupRemainderMsecs", time_store);
3186 }
3187 }
3188 else
3189 {
3190 vty_out (vty, " Originating stub / maximum-distance Router-LSA%s",
3191 VTY_NEWLINE);
3192 if (CHECK_FLAG(area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
3193 vty_out (vty, " Administratively activated (indefinitely)%s",
3194 VTY_NEWLINE);
3195 if (area->t_stub_router)
3196 vty_out (vty, " Active from startup, %s remaining%s",
3197 ospf_timer_dump (area->t_stub_router, timebuf,
3198 sizeof(timebuf)), VTY_NEWLINE);
3199 }
3200 }
3201
3202 if (use_json)
3203 {
3204 /* Show number of fully adjacent neighbors. */
3ac237f8 3205 json_object_int_add(json_area, "nbrFullAdjacentCounter", area->full_nbrs);
ca08c43d
DS
3206
3207 /* Show authentication type. */
3208 if (area->auth_type == OSPF_AUTH_NULL)
3209 json_object_string_add(json_area, "authentication", "authenticationNone");
3210 else if (area->auth_type == OSPF_AUTH_SIMPLE)
3211 json_object_string_add(json_area, "authentication", "authenticationSimplePassword");
3212 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
3213 json_object_string_add(json_area, "authentication", "authenticationMessageDigest");
3214
3215 if (!OSPF_IS_AREA_BACKBONE (area))
3ac237f8 3216 json_object_int_add(json_area, "virtualAdjacenciesPassingCounter", area->full_vls);
ca08c43d
DS
3217
3218 /* Show SPF calculation times. */
3ac237f8 3219 json_object_int_add(json_area, "spfExecutedCounter", area->spf_calculation);
ca08c43d
DS
3220 json_object_int_add(json_area, "lsaNumber", area->lsdb->total);
3221 json_object_int_add(json_area, "lsaRouterNumber", ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA));
3222 json_object_int_add(json_area, "lsaRouterChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA));
3223 json_object_int_add(json_area, "lsaNetworkNumber", ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA));
3224 json_object_int_add(json_area, "lsaNetworkChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA));
3225 json_object_int_add(json_area, "lsaSummaryNumber", ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA));
3226 json_object_int_add(json_area, "lsaSummaryChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA));
3227 json_object_int_add(json_area, "lsaAsbrNumber", ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA));
3228 json_object_int_add(json_area, "lsaAsbrChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA));
3229 json_object_int_add(json_area, "lsaNssaNumber", ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA));
3230 json_object_int_add(json_area, "lsaNssaChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA));
88d6cf37 3231 }
ca08c43d
DS
3232 else
3233 {
3234 /* Show number of fully adjacent neighbors. */
3235 vty_out (vty, " Number of fully adjacent neighbors in this area:"
3236 " %d%s", area->full_nbrs, VTY_NEWLINE);
3237
3238 /* Show authentication type. */
3239 vty_out (vty, " Area has ");
3240 if (area->auth_type == OSPF_AUTH_NULL)
3241 vty_out (vty, "no authentication%s", VTY_NEWLINE);
3242 else if (area->auth_type == OSPF_AUTH_SIMPLE)
3243 vty_out (vty, "simple password authentication%s", VTY_NEWLINE);
3244 else if (area->auth_type == OSPF_AUTH_CRYPTOGRAPHIC)
3245 vty_out (vty, "message digest authentication%s", VTY_NEWLINE);
3246
3247 if (!OSPF_IS_AREA_BACKBONE (area))
3248 vty_out (vty, " Number of full virtual adjacencies going through"
3249 " this area: %d%s", area->full_vls, VTY_NEWLINE);
3250
3251 /* Show SPF calculation times. */
3252 vty_out (vty, " SPF algorithm executed %d times%s",
3253 area->spf_calculation, VTY_NEWLINE);
3254
3255 /* Show number of LSA. */
3256 vty_out (vty, " Number of LSA %ld%s", area->lsdb->total, VTY_NEWLINE);
3257 vty_out (vty, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
3258 ospf_lsdb_count (area->lsdb, OSPF_ROUTER_LSA),
3259 ospf_lsdb_checksum (area->lsdb, OSPF_ROUTER_LSA), VTY_NEWLINE);
3260 vty_out (vty, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
3261 ospf_lsdb_count (area->lsdb, OSPF_NETWORK_LSA),
3262 ospf_lsdb_checksum (area->lsdb, OSPF_NETWORK_LSA), VTY_NEWLINE);
3263 vty_out (vty, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
3264 ospf_lsdb_count (area->lsdb, OSPF_SUMMARY_LSA),
3265 ospf_lsdb_checksum (area->lsdb, OSPF_SUMMARY_LSA), VTY_NEWLINE);
3266 vty_out (vty, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
3267 ospf_lsdb_count (area->lsdb, OSPF_ASBR_SUMMARY_LSA),
3268 ospf_lsdb_checksum (area->lsdb, OSPF_ASBR_SUMMARY_LSA), VTY_NEWLINE);
3269 vty_out (vty, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
3270 ospf_lsdb_count (area->lsdb, OSPF_AS_NSSA_LSA),
3271 ospf_lsdb_checksum (area->lsdb, OSPF_AS_NSSA_LSA), VTY_NEWLINE);
3272 }
3273
ca08c43d
DS
3274 if (use_json)
3275 {
3276 json_object_int_add(json_area, "lsaOpaqueLinkNumber", ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA));
3277 json_object_int_add(json_area, "lsaOpaqueLinkChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA));
3278 json_object_int_add(json_area, "lsaOpaqueAreaNumber", ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA));
3279 json_object_int_add(json_area, "lsaOpaqueAreaChecksum", ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA));
3280 }
3281 else
3282 {
3283 vty_out (vty, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
3284 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_LINK_LSA),
3285 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_LINK_LSA), VTY_NEWLINE);
3286 vty_out (vty, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
3287 ospf_lsdb_count (area->lsdb, OSPF_OPAQUE_AREA_LSA),
3288 ospf_lsdb_checksum (area->lsdb, OSPF_OPAQUE_AREA_LSA), VTY_NEWLINE);
3289 }
ca08c43d
DS
3290
3291 if (use_json)
3292 json_object_object_add(json_areas, inet_ntoa (area->area_id), json_area);
3293 else
3294 vty_out (vty, "%s", VTY_NEWLINE);
718e3744 3295}
3296
7c8ff89e 3297static int
ca08c43d 3298show_ip_ospf_common (struct vty *vty, struct ospf *ospf, u_char use_json)
718e3744 3299{
1eb8ef25 3300 struct listnode *node, *nnode;
718e3744 3301 struct ospf_area * area;
d24f6e2a 3302 struct timeval result;
649654ab 3303 char timebuf[OSPF_TIME_DUMP_SIZE];
ca08c43d
DS
3304 json_object *json = NULL;
3305 json_object *json_areas = NULL;
3306
3307 if (use_json)
0cad6e26
DS
3308 {
3309 json = json_object_new_object();
3310 json_areas = json_object_new_object();
3311 }
718e3744 3312
7c8ff89e 3313 if (ospf->instance)
ca08c43d
DS
3314 {
3315 if (use_json)
3316 {
3317 json_object_int_add(json, "ospfInstance", ospf->instance);
3318 }
3319 else
3320 {
3321 vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance,
3322 VTY_NEWLINE, VTY_NEWLINE);
3323 }
3324 }
718e3744 3325
3326 /* Show Router ID. */
ca08c43d
DS
3327 if (use_json)
3328 {
3329 json_object_string_add(json, "routerId", inet_ntoa (ospf->router_id));
3330 }
3331 else
3332 {
3333 vty_out (vty, " OSPF Routing Process, Router ID: %s%s",
3334 inet_ntoa (ospf->router_id),
3335 VTY_NEWLINE);
3336 }
7c8ff89e 3337
88d6cf37 3338 /* Graceful shutdown */
c9c93d50 3339 if (ospf->t_deferred_shutdown)
ca08c43d
DS
3340 {
3341 if (use_json)
3342 {
3343 unsigned long time_store = 0;
3344 result = tv_sub (ospf->t_deferred_shutdown->u.sands, recent_relative_time());
3345 time_store = (1000 * result.tv_sec) + (result.tv_usec / 1000);
3346 json_object_int_add(json, "deferredShutdownMsecs", time_store);
3347 }
3348 else
3349 {
3350 vty_out (vty, " Deferred shutdown in progress, %s remaining%s",
3351 ospf_timer_dump (ospf->t_deferred_shutdown,
3352 timebuf, sizeof (timebuf)), VTY_NEWLINE);
3353 }
3354 }
3355
718e3744 3356 /* Show capability. */
ca08c43d
DS
3357 if (use_json)
3358 {
3359 json_object_boolean_true_add(json, "tosRoutesOnly");
3360 json_object_boolean_true_add(json, "rfc2328Conform");
3361 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
3362 {
3363 json_object_boolean_true_add(json, "rfc1583Compatibility");
3364 }
3365 }
3366 else
3367 {
3368 vty_out (vty, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE);
3369 vty_out (vty, " This implementation conforms to RFC2328%s", VTY_NEWLINE);
3370 vty_out (vty, " RFC1583Compatibility flag is %s%s",
3371 CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE) ?
3372 "enabled" : "disabled", VTY_NEWLINE);
3373 }
3374
ca08c43d
DS
3375 if (use_json)
3376 {
3377 if (CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE))
3378 {
3379 json_object_boolean_true_add(json, "opaqueCapable");
3380 }
ca08c43d
DS
3381 }
3382 else
3383 {
801e0e14 3384 vty_out (vty, " OpaqueCapability flag is %s%s",
ca08c43d 3385 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ? "enabled" : "disabled",
ca08c43d
DS
3386 VTY_NEWLINE);
3387 }
ca08c43d 3388
88d6cf37 3389 /* Show stub-router configuration */
3390 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED
3391 || ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
3392 {
ca08c43d
DS
3393 if (use_json)
3394 {
3395 json_object_boolean_true_add(json, "stubAdvertisement");
3396 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
3397 json_object_int_add(json,"postStartEnabledMsecs", ospf->stub_router_startup_time / 1000);
3398 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
3399 json_object_int_add(json,"preShutdownEnabledMsecs", ospf->stub_router_shutdown_time / 1000);
3400 }
3401 else
3402 {
3403 vty_out (vty, " Stub router advertisement is configured%s",
3404 VTY_NEWLINE);
3405 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
3406 vty_out (vty, " Enabled for %us after start-up%s",
3407 ospf->stub_router_startup_time, VTY_NEWLINE);
3408 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
3409 vty_out (vty, " Enabled for %us prior to full shutdown%s",
3410 ospf->stub_router_shutdown_time, VTY_NEWLINE);
3411 }
88d6cf37 3412 }
ca08c43d 3413
718e3744 3414 /* Show SPF timers. */
ca08c43d
DS
3415 if (use_json)
3416 {
3417 json_object_int_add(json, "spfScheduleDelayMsecs", ospf->spf_delay);
3418 json_object_int_add(json, "holdtimeMinMsecs", ospf->spf_holdtime);
3419 json_object_int_add(json, "holdtimeMaxMsecs", ospf->spf_max_holdtime);
3420 json_object_int_add(json, "holdtimeMultplier", ospf->spf_hold_multiplier);
b8ad39d4 3421 }
3422 else
ca08c43d
DS
3423 {
3424 vty_out (vty, " Initial SPF scheduling delay %d millisec(s)%s"
3425 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
3426 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
3427 " Hold time multiplier is currently %d%s",
3428 ospf->spf_delay, VTY_NEWLINE,
3429 ospf->spf_holdtime, VTY_NEWLINE,
3430 ospf->spf_max_holdtime, VTY_NEWLINE,
3431 ospf->spf_hold_multiplier, VTY_NEWLINE);
3432 }
b6927875 3433
ca08c43d
DS
3434 if (use_json)
3435 {
3436 if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec)
3437 {
3438 unsigned long time_store = 0;
3439
3440 result = tv_sub (recent_relative_time(), ospf->ts_spf);
3441 result = tv_sub (result, recent_relative_time());
3442 time_store = (1000 * result.tv_sec) + (result.tv_usec / 1000);
3443 json_object_int_add(json, "spfLastExecutedMsecs", time_store);
3444
3445 time_store = (1000 * ospf->ts_spf_duration.tv_sec) + (ospf->ts_spf_duration.tv_usec / 1000);
3446 json_object_int_add(json, "spfLastDurationMsecs", time_store);
3447 }
3448 else
3449 json_object_boolean_true_add(json, "spfHasNotRun");
3450 }
3451 else
3452 {
3453 vty_out (vty, " SPF algorithm ");
3454 if (ospf->ts_spf.tv_sec || ospf->ts_spf.tv_usec)
3455 {
3456 result = tv_sub (recent_relative_time(), ospf->ts_spf);
3457 vty_out (vty, "last executed %s ago%s",
3458 ospf_timeval_dump (&result, timebuf, sizeof (timebuf)),
3459 VTY_NEWLINE);
3460 vty_out (vty, " Last SPF duration %s%s",
3461 ospf_timeval_dump (&ospf->ts_spf_duration, timebuf, sizeof (timebuf)),
3462 VTY_NEWLINE);
3463 }
3464 else
3465 vty_out (vty, "has not been run%s", VTY_NEWLINE);
3466 }
3467
3468 if (use_json)
3469 {
3470 struct timeval temp_time;
3471 unsigned long time_store = 0;
3472
3473 if (ospf->t_spf_calc)
3474 {
3475 temp_time = tv_sub (ospf->t_spf_calc->u.sands, recent_relative_time());
3476 time_store = (1000 * temp_time.tv_sec) + (temp_time.tv_usec / 1000);
3477 json_object_int_add(json, "spfTimerDueInMsecs", time_store);
3478 }
3479
ac7424f9
MR
3480 json_object_int_add(json, "lsaMinIntervalMsecs", ospf->min_ls_interval);
3481 json_object_int_add(json, "lsaMinArrivalMsecs", ospf->min_ls_arrival);
ca08c43d
DS
3482 /* Show write multiplier values */
3483 json_object_int_add(json, "writeMultiplier", ospf->write_oi_count);
3484 /* Show refresh parameters. */
54b7214f 3485 json_object_int_add(json, "refreshTimerMsecs", ospf->lsa_refresh_interval * 1000);
ca08c43d
DS
3486 }
3487 else
3488 {
3489 vty_out (vty, " SPF timer %s%s%s",
3490 (ospf->t_spf_calc ? "due in " : "is "),
3491 ospf_timer_dump (ospf->t_spf_calc, timebuf, sizeof (timebuf)),
3492 VTY_NEWLINE);
3493
ac7424f9
MR
3494 vty_out (vty, " LSA minimum interval %d msecs%s",
3495 ospf->min_ls_interval, VTY_NEWLINE);
ca08c43d 3496 vty_out (vty, " LSA minimum arrival %d msecs%s",
ac7424f9 3497 ospf->min_ls_arrival, VTY_NEWLINE);
ca08c43d
DS
3498
3499 /* Show write multiplier values */
3500 vty_out (vty, " Write Multiplier set to %d %s",
3501 ospf->write_oi_count, VTY_NEWLINE);
3502
3503 /* Show refresh parameters. */
3504 vty_out (vty, " Refresh timer %d secs%s",
3505 ospf->lsa_refresh_interval, VTY_NEWLINE);
3506 }
2f8f370e 3507
718e3744 3508 /* Show ABR/ASBR flags. */
68980084 3509 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
ca08c43d
DS
3510 {
3511 if (use_json)
3512 json_object_string_add(json, "abrType", ospf_abr_type_descr_str[ospf->abr_type]);
3513 else
3514 vty_out (vty, " This router is an ABR, ABR type is: %s%s",
3515 ospf_abr_type_descr_str[ospf->abr_type], VTY_NEWLINE);
3516 }
68980084 3517 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
ca08c43d
DS
3518 {
3519 if (use_json)
3520 json_object_string_add(json, "asbrRouter", "injectingExternalRoutingInformation");
3521 else
3522 vty_out (vty, " This router is an ASBR "
3523 "(injecting external routing information)%s", VTY_NEWLINE);
3524 }
718e3744 3525
3526 /* Show Number of AS-external-LSAs. */
ca08c43d
DS
3527 if (use_json)
3528 {
3ac237f8 3529 json_object_int_add(json, "lsaExternalCounter",
ca08c43d
DS
3530 ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA));
3531 json_object_int_add(json, "lsaExternalChecksum",
3532 ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA));
3533 }
3534 else
3535 {
3536 vty_out (vty, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
3537 ospf_lsdb_count (ospf->lsdb, OSPF_AS_EXTERNAL_LSA),
3538 ospf_lsdb_checksum (ospf->lsdb, OSPF_AS_EXTERNAL_LSA), VTY_NEWLINE);
3539 }
3540
ca08c43d
DS
3541 if (use_json)
3542 {
3ac237f8 3543 json_object_int_add(json, "lsaAsopaqueCounter",
ca08c43d
DS
3544 ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA));
3545 json_object_int_add(json, "lsaAsOpaqueChecksum",
3546 ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA));
3547 }
3548 else
3549 {
3550 vty_out (vty, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
3551 ospf_lsdb_count (ospf->lsdb, OSPF_OPAQUE_AS_LSA),
3552 ospf_lsdb_checksum (ospf->lsdb, OSPF_OPAQUE_AS_LSA), VTY_NEWLINE);
3553 }
ca08c43d 3554
718e3744 3555 /* Show number of areas attached. */
ca08c43d 3556 if (use_json)
3ac237f8 3557 json_object_int_add(json, "attachedAreaCounter", listcount (ospf->areas));
ca08c43d
DS
3558 else
3559 vty_out (vty, " Number of areas attached to this router: %d%s",
3560 listcount (ospf->areas), VTY_NEWLINE);
d7e60dd7
AS
3561
3562 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
3563 {
3564 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
ca08c43d
DS
3565 {
3566 if (use_json)
3567 json_object_boolean_true_add(json, "adjacencyChangesLoggedAll");
3568 else
3569 vty_out(vty, " All adjacency changes are logged%s",VTY_NEWLINE);
3570 }
d7e60dd7 3571 else
ca08c43d
DS
3572 {
3573 if (use_json)
3574 json_object_boolean_true_add(json, "adjacencyChangesLogged");
3575 else
3576 vty_out(vty, " Adjacency changes are logged%s",VTY_NEWLINE);
3577 }
d7e60dd7 3578 }
718e3744 3579 /* Show each area status. */
1eb8ef25 3580 for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
ca08c43d
DS
3581 show_ip_ospf_area (vty, area, json_areas, use_json);
3582
3583 if (use_json)
3584 {
3585 json_object_object_add(json, "areas", json_areas);
2aac5767 3586 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
ca08c43d
DS
3587 json_object_free(json);
3588 }
3589 else
3590 vty_out (vty, "%s",VTY_NEWLINE);
718e3744 3591
3592 return CMD_SUCCESS;
3593}
3594
7c8ff89e
DS
3595DEFUN (show_ip_ospf,
3596 show_ip_ospf_cmd,
ca08c43d 3597 "show ip ospf {json}",
7c8ff89e
DS
3598 SHOW_STR
3599 IP_STR
ca08c43d
DS
3600 "OSPF information\n"
3601 "JavaScript Object Notation\n")
7c8ff89e
DS
3602{
3603 struct ospf *ospf;
db7c8528 3604 u_char uj = use_json(argc, argv);
7c8ff89e 3605
0bad4851 3606 if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running)
7c8ff89e
DS
3607 return CMD_SUCCESS;
3608
db7c8528 3609 return (show_ip_ospf_common(vty, ospf, uj));
7c8ff89e
DS
3610}
3611
3612DEFUN (show_ip_ospf_instance,
3613 show_ip_ospf_instance_cmd,
ca08c43d 3614 "show ip ospf <1-65535> {json}",
7c8ff89e
DS
3615 SHOW_STR
3616 IP_STR
3617 "OSPF information\n"
ca08c43d
DS
3618 "Instance ID\n"
3619 "JavaScript Object Notation\n")
7c8ff89e
DS
3620{
3621 struct ospf *ospf;
3622 u_short instance = 0;
db7c8528 3623 u_char uj = use_json(argc, argv);
7c8ff89e
DS
3624
3625 VTY_GET_INTEGER ("Instance", instance, argv[0]);
0bad4851 3626 if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running)
7c8ff89e
DS
3627 return CMD_SUCCESS;
3628
db7c8528 3629 return (show_ip_ospf_common(vty, ospf, uj));
7c8ff89e
DS
3630}
3631
fd651fa6 3632static void
7ec4159b
DS
3633show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, struct interface *ifp,
3634 json_object *json_interface_sub, u_char use_json)
718e3744 3635{
fd651fa6 3636 int is_up;
718e3744 3637 struct ospf_neighbor *nbr;
718e3744 3638 struct route_node *rn;
718e3744 3639
718e3744 3640 /* Is interface up? */
7ec4159b
DS
3641 if (use_json)
3642 {
3643 is_up = if_is_operative(ifp);
3644 if (is_up)
3645 json_object_boolean_true_add(json_interface_sub, "ifUp");
3646 else
3647 json_object_boolean_false_add(json_interface_sub, "ifDown");
3648
3649 json_object_int_add(json_interface_sub, "ifIndex", ifp->ifindex);
3650 json_object_int_add(json_interface_sub, "mtuBytes", ifp->mtu);
70bd3c43 3651 json_object_int_add(json_interface_sub, "bandwidthMbit", ifp->bandwidth);
7ec4159b
DS
3652 json_object_string_add(json_interface_sub, "ifFlags", if_flag_dump(ifp->flags));
3653 }
3654 else
3655 {
3656 vty_out (vty, "%s is %s%s", ifp->name,
3657 ((is_up = if_is_operative(ifp)) ? "up" : "down"), VTY_NEWLINE);
70bd3c43 3658 vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Mbit %s%s",
7ec4159b
DS
3659 ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags),
3660 VTY_NEWLINE);
3661 }
718e3744 3662
3663 /* Is interface OSPF enabled? */
7ec4159b 3664 if (use_json)
718e3744 3665 {
7ec4159b
DS
3666 if (ospf_oi_count(ifp) == 0)
3667 {
3668 json_object_boolean_false_add(json_interface_sub, "ospfEnabled");
3669 return;
3670 }
3671 else if (!is_up)
3672 {
3673 json_object_boolean_false_add(json_interface_sub, "ospfRunning");
3674 return;
3675 }
3676 else
3677 json_object_boolean_true_add(json_interface_sub, "ospfEnabled");
718e3744 3678 }
7ec4159b 3679 else
fd651fa6 3680 {
7ec4159b
DS
3681 if (ospf_oi_count(ifp) == 0)
3682 {
3683 vty_out (vty, " OSPF not enabled on this interface%s", VTY_NEWLINE);
3684 return;
3685 }
3686 else if (!is_up)
3687 {
3688 vty_out (vty, " OSPF is enabled, but not running on this interface%s",
3689 VTY_NEWLINE);
3690 return;
3691 }
fd651fa6 3692 }
3693
718e3744 3694 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3695 {
3696 struct ospf_interface *oi = rn->info;
7ec4159b 3697
718e3744 3698 if (oi == NULL)
7ec4159b
DS
3699 continue;
3700
525c1839
DS
3701 if (CHECK_FLAG(oi->connected->flags, ZEBRA_IFA_UNNUMBERED))
3702 {
7ec4159b
DS
3703 if (use_json)
3704 json_object_boolean_true_add(json_interface_sub, "ifUnnumbered");
3705 else
3706 vty_out (vty, " This interface is UNNUMBERED,");
525c1839
DS
3707 }
3708 else
9c27ef9b 3709 {
525c1839 3710 /* Show OSPF interface information. */
7ec4159b
DS
3711 if (use_json)
3712 {
3713 json_object_string_add(json_interface_sub, "ipAddress", inet_ntoa (oi->address->u.prefix4));
3714 json_object_int_add(json_interface_sub, "ipAddressPrefixlen", oi->address->prefixlen);
3715 }
3716 else
3717 vty_out (vty, " Internet Address %s/%d,",
3718 inet_ntoa (oi->address->u.prefix4), oi->address->prefixlen);
525c1839
DS
3719
3720 if (oi->connected->destination || oi->type == OSPF_IFTYPE_VIRTUALLINK)
3721 {
3722 struct in_addr *dest;
3723 const char *dstr;
3724
3725 if (CONNECTED_PEER(oi->connected)
3726 || oi->type == OSPF_IFTYPE_VIRTUALLINK)
3727 dstr = "Peer";
3728 else
3729 dstr = "Broadcast";
3730
3731 /* For Vlinks, showing the peer address is probably more
7ec4159b
DS
3732 * * * * * informative than the local interface that is being used
3733 * * * * */
525c1839
DS
3734 if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
3735 dest = &oi->vl_data->peer_addr;
3736 else
3737 dest = &oi->connected->destination->u.prefix4;
3738
7ec4159b
DS
3739 if (use_json)
3740 {
3741 json_object_string_add(json_interface_sub, "ospfIfType", dstr);
3742 if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
3743 json_object_string_add(json_interface_sub, "vlinkPeer", inet_ntoa (*dest));
3744 else
3745 json_object_string_add(json_interface_sub, "localIfUsed", inet_ntoa (*dest));
3746 }
3747 else
3748 vty_out (vty, " %s %s,", dstr, inet_ntoa (*dest));
525c1839 3749 }
9c27ef9b 3750 }
7ec4159b
DS
3751 if (use_json)
3752 {
3753 json_object_string_add(json_interface_sub, "area", ospf_area_desc_string (oi->area));
3754 if (OSPF_IF_PARAM(oi, mtu_ignore))
3755 json_object_boolean_true_add(json_interface_sub, "mtuMismatchDetect");
3756 json_object_string_add(json_interface_sub, "routerId", inet_ntoa (ospf->router_id));
3757 json_object_string_add(json_interface_sub, "networkType", ospf_network_type_str[oi->type]);
3758 json_object_int_add(json_interface_sub, "cost", oi->output_cost);
3759 json_object_int_add(json_interface_sub, "transmitDelayMsecs", 1000 / OSPF_IF_PARAM (oi,transmit_delay));
3760 json_object_string_add(json_interface_sub, "state", LOOKUP (ospf_ism_state_msg, oi->state));
3761 json_object_int_add(json_interface_sub, "priority", PRIORITY (oi));
3762 }
3763 else
3764 {
3765 vty_out (vty, " Area %s%s", ospf_area_desc_string (oi->area),
3766 VTY_NEWLINE);
3fb9cd6e 3767
7ec4159b
DS
3768 vty_out (vty, " MTU mismatch detection:%s%s",
3769 OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE);
ba682537 3770
7ec4159b
DS
3771 vty_out (vty, " Router ID %s, Network Type %s, Cost: %d%s",
3772 inet_ntoa (ospf->router_id), ospf_network_type_str[oi->type],
3773 oi->output_cost, VTY_NEWLINE);
718e3744 3774
7ec4159b
DS
3775 vty_out (vty, " Transmit Delay is %d sec, State %s, Priority %d%s",
3776 OSPF_IF_PARAM (oi,transmit_delay), LOOKUP (ospf_ism_state_msg, oi->state),
3777 PRIORITY (oi), VTY_NEWLINE);
3778 }
718e3744 3779
3780 /* Show DR information. */
3781 if (DR (oi).s_addr == 0)
7ec4159b
DS
3782 {
3783 if (!use_json)
3784 vty_out (vty, " No backup designated router on this network%s",
3785 VTY_NEWLINE);
3786 }
718e3744 3787 else
7ec4159b
DS
3788 {
3789 nbr = ospf_nbr_lookup_by_addr (oi->nbrs, &BDR (oi));
3790 if (nbr == NULL)
3791 {
3792 if (!use_json)
3793 vty_out (vty, " No backup designated router on this network%s",
3794 VTY_NEWLINE);
3795 }
3796 else
3797 {
3798 if (use_json)
3799 {
3800 json_object_string_add(json_interface_sub, "bdrId", inet_ntoa (nbr->router_id));
3801 json_object_string_add(json_interface_sub, "bdrAddress", inet_ntoa (nbr->address.u.prefix4));
3802 }
3803 else
3804 {
3805 vty_out (vty, " Backup Designated Router (ID) %s,",
3806 inet_ntoa (nbr->router_id));
3807 vty_out (vty, " Interface Address %s%s",
3808 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
3809 }
3810 }
3811 }
525c1839 3812
7eb5b47e 3813 /* Next network-LSA sequence number we'll use, if we're elected DR */
7ec4159b 3814 if (oi->params && ntohl (oi->params->network_lsa_seqnum) != OSPF_INITIAL_SEQUENCE_NUMBER)
429ac78c 3815 {
7ec4159b
DS
3816 if (use_json)
3817 json_object_int_add(json_interface_sub, "networkLsaSequence", ntohl (oi->params->network_lsa_seqnum));
3818 else
3819 vty_out (vty, " Saved Network-LSA sequence number 0x%x%s",
3820 ntohl (oi->params->network_lsa_seqnum), VTY_NEWLINE);
3821 }
3822
3823 if (use_json)
3824 {
3825 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)
3826 || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
3827 {
3828 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS))
3829 json_object_boolean_true_add(json_interface_sub, "mcastMemberOspfAllRouters");
3830 if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
3831 json_object_boolean_true_add(json_interface_sub, "mcastMemberOspfDesignatedRouters");
3832 }
429ac78c
PJ
3833 }
3834 else
7ec4159b
DS
3835 {
3836 vty_out (vty, " Multicast group memberships:");
3837 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS)
3838 || OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
3839 {
3840 if (OI_MEMBER_CHECK(oi, MEMBER_ALLROUTERS))
3841 vty_out (vty, " OSPFAllRouters");
3842 if (OI_MEMBER_CHECK(oi, MEMBER_DROUTERS))
3843 vty_out (vty, " OSPFDesignatedRouters");
3844 }
3845 else
3846 vty_out (vty, " <None>");
3847 vty_out (vty, "%s", VTY_NEWLINE);
3848 }
ba6454ec 3849
7ec4159b
DS
3850 if (use_json)
3851 {
3852 if (OSPF_IF_PARAM (oi, fast_hello) == 0)
3853 json_object_int_add(json_interface_sub, "timerMsecs", 1000 /OSPF_IF_PARAM (oi, v_hello));
3854 else
3855 json_object_int_add(json_interface_sub, "timerMsecs", 1000 / OSPF_IF_PARAM (oi, fast_hello));
3856 json_object_int_add(json_interface_sub, "timerDeadMsecs", 1000 / OSPF_IF_PARAM (oi, v_wait));
3857 json_object_int_add(json_interface_sub, "timerWaitMsecs", 1000 / OSPF_IF_PARAM (oi, v_wait));
3858 json_object_int_add(json_interface_sub, "timerRetransmit", 1000 / OSPF_IF_PARAM (oi, retransmit_interval));
3859 }
f9ad937f 3860 else
7ec4159b
DS
3861 {
3862 vty_out (vty, " Timer intervals configured,");
3863 vty_out (vty, " Hello ");
3864 if (OSPF_IF_PARAM (oi, fast_hello) == 0)
3865 vty_out (vty, "%ds,", OSPF_IF_PARAM (oi, v_hello));
3866 else
3867 vty_out (vty, "%dms,", 1000 / OSPF_IF_PARAM (oi, fast_hello));
3868 vty_out (vty, " Dead %ds, Wait %ds, Retransmit %d%s",
3869 OSPF_IF_PARAM (oi, v_wait),
3870 OSPF_IF_PARAM (oi, v_wait),
3871 OSPF_IF_PARAM (oi, retransmit_interval),
3872 VTY_NEWLINE);
3873 }
3874
7ffa8fa2 3875 if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE)
f9ad937f 3876 {
7ec4159b
DS
3877 char timebuf[OSPF_TIME_DUMP_SIZE];
3878 if (use_json)
3879 {
3880 struct timeval result;
3881 unsigned long time_store = 0;
b8dfa544
DS
3882 if (oi->t_hello)
3883 result = tv_sub (oi->t_hello->u.sands, recent_relative_time());
3884 else
3885 {
3886 result.tv_sec = 0;
3887 result.tv_usec = 0;
3888 }
7ec4159b
DS
3889 time_store = (1000 * result.tv_sec) + (result.tv_usec / 1000);
3890 json_object_int_add(json_interface_sub, "timerHelloInMsecs", time_store);
3891 }
3892 else
3893 vty_out (vty, " Hello due in %s%s",
3894 ospf_timer_dump (oi->t_hello, timebuf, sizeof(timebuf)),
3895 VTY_NEWLINE);
f9ad937f 3896 }
7ffa8fa2 3897 else /* passive-interface is set */
7ec4159b
DS
3898 {
3899 if (use_json)
3900 json_object_boolean_true_add(json_interface_sub, "timerPassiveIface");
3901 else
3902 vty_out (vty, " No Hellos (Passive interface)%s", VTY_NEWLINE);
3903 }
3904
3905 if (use_json)
3906 {
3907 json_object_int_add(json_interface_sub, "nbrCount", ospf_nbr_count (oi, 0));
3908 json_object_int_add(json_interface_sub, "nbrAdjacentCount", ospf_nbr_count (oi, NSM_Full));
3909 }
3910 else
3911 vty_out (vty, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
3912 ospf_nbr_count (oi, 0), ospf_nbr_count (oi, NSM_Full),
3913 VTY_NEWLINE);
68fe91d6 3914 ospf_bfd_interface_show(vty, ifp, json_interface_sub, use_json);
718e3744 3915 }
3916}
3917
7c8ff89e 3918static int
7ec4159b
DS
3919show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc,
3920 const char **argv, int iface_argv, u_char use_json)
718e3744 3921{
3922 struct interface *ifp;
52dc7ee6 3923 struct listnode *node;
7ec4159b
DS
3924 json_object *json = NULL;
3925 json_object *json_interface_sub = NULL;
3926
3927 if (use_json)
3928 {
3929 json = json_object_new_object();
3930 json_interface_sub = json_object_new_object();
3931 }
718e3744 3932
7c8ff89e 3933 if (ospf->instance)
7ec4159b
DS
3934 {
3935 if (use_json)
3936 json_object_int_add(json, "ospfInstance", ospf->instance);
3937 else
3938 vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance,
3939 VTY_NEWLINE, VTY_NEWLINE);
3940 }
7c8ff89e 3941
7ec4159b
DS
3942 if (argc == (iface_argv + 1))
3943 {
3944 /* Show All Interfaces.*/
b2d7c082 3945 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp))
7ec4159b
DS
3946 {
3947 if (ospf_oi_count(ifp))
3948 {
3949 show_ip_ospf_interface_sub (vty, ospf, ifp, json_interface_sub, use_json);
b8dfa544
DS
3950 if (use_json)
3951 json_object_object_add (json, ifp->name, json_interface_sub);
7ec4159b
DS
3952 }
3953 }
3954 }
3955 else if (argv[iface_argv] && strcmp(argv[iface_argv], "json") == 0)
cac3b5c4 3956 {
b8dfa544
DS
3957 if (!use_json)
3958 {
3959 json = json_object_new_object();
3960 json_interface_sub = json_object_new_object ();
3961 use_json = 1;
3962 }
7c8ff89e 3963 /* Show All Interfaces. */
b2d7c082 3964 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp))
7ec4159b
DS
3965 {
3966 if (ospf_oi_count(ifp))
3967 {
3968 show_ip_ospf_interface_sub (vty, ospf, ifp, json_interface_sub, use_json);
b8dfa544
DS
3969 if (use_json)
3970 json_object_object_add(json, ifp->name, json_interface_sub);
3971 }
3972 }
cac3b5c4 3973 }
718e3744 3974 else
3975 {
7c8ff89e 3976 /* Interface name is specified. */
7ec4159b
DS
3977 if ((ifp = if_lookup_by_name (argv[iface_argv])) == NULL)
3978 {
3979 if (use_json)
3980 json_object_boolean_true_add(json, "noSuchIface");
3981 else
3982 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
3983 }
718e3744 3984 else
7ec4159b
DS
3985 {
3986 show_ip_ospf_interface_sub (vty, ospf, ifp, json_interface_sub, use_json);
3987 if (use_json)
3988 json_object_object_add(json, ifp->name, json_interface_sub);
3989 }
718e3744 3990 }
3991
7ec4159b
DS
3992 if (use_json)
3993 {
2aac5767 3994 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
7ec4159b
DS
3995 json_object_free(json);
3996 }
3997 else
3998 vty_out (vty, "%s", VTY_NEWLINE);
7c8ff89e 3999
718e3744 4000 return CMD_SUCCESS;
4001}
4002
7c8ff89e
DS
4003DEFUN (show_ip_ospf_interface,
4004 show_ip_ospf_interface_cmd,
7ec4159b 4005 "show ip ospf interface [INTERFACE] {json}",
7c8ff89e
DS
4006 SHOW_STR
4007 IP_STR
4008 "OSPF information\n"
4009 "Interface information\n"
7ec4159b
DS
4010 "Interface name\n"
4011 "JavaScript Object Notation\n")
7c8ff89e
DS
4012{
4013 struct ospf *ospf;
db7c8528 4014 u_char uj = use_json(argc, argv);
7c8ff89e 4015
0bad4851 4016 if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running)
7c8ff89e
DS
4017 return CMD_SUCCESS;
4018
db7c8528 4019 return show_ip_ospf_interface_common(vty, ospf, argc, argv, 0, uj);
7c8ff89e
DS
4020}
4021
4022DEFUN (show_ip_ospf_instance_interface,
4023 show_ip_ospf_instance_interface_cmd,
7ec4159b 4024 "show ip ospf <1-65535> interface [INTERFACE] {json}",
7c8ff89e
DS
4025 SHOW_STR
4026 IP_STR
4027 "OSPF information\n"
4028 "Instance ID\n"
4029 "Interface information\n"
7ec4159b
DS
4030 "Interface name\n"
4031 "JavaScript Object Notation\n")
7c8ff89e
DS
4032{
4033 struct ospf *ospf;
4034 u_short instance = 0;
db7c8528 4035 u_char uj = use_json(argc, argv);
7c8ff89e
DS
4036
4037 VTY_GET_INTEGER ("Instance", instance, argv[0]);
0bad4851 4038 if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running)
7c8ff89e
DS
4039 return CMD_SUCCESS;
4040
db7c8528 4041 return show_ip_ospf_interface_common(vty, ospf, argc, argv, 1, uj);
7c8ff89e
DS
4042}
4043
d24f6e2a 4044static void
4045show_ip_ospf_neighbour_header (struct vty *vty)
4046{
490578f3 4047 vty_out (vty, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
d24f6e2a 4048 VTY_NEWLINE,
4049 "Neighbor ID", "Pri", "State", "Dead Time",
4050 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
4051 VTY_NEWLINE);
4052}
4053
4dadc291 4054static void
91756b38 4055show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi, json_object *json, u_char use_json)
718e3744 4056{
4057 struct route_node *rn;
4058 struct ospf_neighbor *nbr;
4059 char msgbuf[16];
649654ab 4060 char timebuf[OSPF_TIME_DUMP_SIZE];
91756b38 4061 json_object *json_neighbor = NULL;
718e3744 4062
4063 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
91756b38
DS
4064 {
4065 if ((nbr = rn->info))
4066 {
4067 /* Do not show myself. */
4068 if (nbr != oi->nbr_self)
4069 {
4070 /* Down state is not shown. */
4071 if (nbr->state != NSM_Down)
4072 {
4073 if (use_json)
4074 {
4075 json_neighbor = json_object_new_object();
4076 ospf_nbr_state_message (nbr, msgbuf, 16);
4077
4078 struct timeval result;
4079 unsigned long time_store = 0;
4080
4081 result = tv_sub (nbr->t_inactivity->u.sands, recent_relative_time());
4082 time_store = (1000 * result.tv_sec) + (result.tv_usec / 1000);
4083
4084 json_object_int_add (json_neighbor, "priority", nbr->priority);
4085 json_object_string_add (json_neighbor, "state", msgbuf);
4086 json_object_int_add (json_neighbor, "deadTimeMsecs", time_store);
4087 json_object_string_add (json_neighbor, "address", inet_ntoa (nbr->src));
4088 json_object_string_add (json_neighbor, "ifaceName", IF_NAME (oi));
3ac237f8
MS
4089 json_object_int_add (json_neighbor, "retransmitCounter", ospf_ls_retransmit_count (nbr));
4090 json_object_int_add (json_neighbor, "requestCounter", ospf_ls_request_count (nbr));
4091 json_object_int_add (json_neighbor, "dbSummaryCounter", ospf_db_summary_count (nbr));
91756b38
DS
4092 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
4093 json_object_object_add(json, "neighbor", json_neighbor);
4094 else
4095 json_object_object_add(json, inet_ntoa (nbr->router_id), json_neighbor);
4096 }
4097 else
4098 {
4099 ospf_nbr_state_message (nbr, msgbuf, 16);
4100
4101 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
4102 vty_out (vty, "%-15s %3d %-15s ",
4103 "-", nbr->priority,
4104 msgbuf);
4105 else
4106 vty_out (vty, "%-15s %3d %-15s ",
4107 inet_ntoa (nbr->router_id), nbr->priority,
4108 msgbuf);
4109
4110 vty_out (vty, "%9s ",
4111 ospf_timer_dump (nbr->t_inactivity, timebuf,
4112 sizeof(timebuf)));
4113 vty_out (vty, "%-15s ", inet_ntoa (nbr->src));
4114 vty_out (vty, "%-20s %5ld %5ld %5d%s",
4115 IF_NAME (oi), ospf_ls_retransmit_count (nbr),
4116 ospf_ls_request_count (nbr), ospf_db_summary_count (nbr),
4117 VTY_NEWLINE);
4118 }
4119 }
4120 }
4121 }
4122 }
718e3744 4123}
4124
7c8ff89e 4125static int
91756b38 4126show_ip_ospf_neighbor_common (struct vty *vty, struct ospf *ospf, u_char use_json)
718e3744 4127{
1eb8ef25 4128 struct ospf_interface *oi;
52dc7ee6 4129 struct listnode *node;
91756b38 4130 json_object *json = NULL;
718e3744 4131
91756b38
DS
4132 if (use_json)
4133 json = json_object_new_object();
4134 else
4135 show_ip_ospf_neighbour_header (vty);
718e3744 4136
91756b38
DS
4137 if (ospf->instance)
4138 {
4139 if (use_json)
4140 json_object_int_add(json, "ospfInstance", ospf->instance);
4141 else
4142 vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance,
4143 VTY_NEWLINE, VTY_NEWLINE);
4144 }
718e3744 4145
1eb8ef25 4146 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
91756b38 4147 show_ip_ospf_neighbor_sub (vty, oi, json, use_json);
718e3744 4148
91756b38
DS
4149 if (use_json)
4150 {
2aac5767 4151 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
91756b38
DS
4152 json_object_free(json);
4153 }
4154 else
4155 vty_out (vty, "%s", VTY_NEWLINE);
7c8ff89e 4156
718e3744 4157 return CMD_SUCCESS;
4158}
4159
7c8ff89e
DS
4160DEFUN (show_ip_ospf_neighbor,
4161 show_ip_ospf_neighbor_cmd,
91756b38 4162 "show ip ospf neighbor {json}",
718e3744 4163 SHOW_STR
4164 IP_STR
4165 "OSPF information\n"
91756b38
DS
4166 "Neighbor list\n"
4167 "JavaScript Object Notation\n")
718e3744 4168{
7c8ff89e 4169 struct ospf *ospf;
db7c8528 4170 u_char uj = use_json(argc, argv);
718e3744 4171
0bad4851 4172 if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running)
7c8ff89e
DS
4173 return CMD_SUCCESS;
4174
db7c8528 4175 return show_ip_ospf_neighbor_common(vty, ospf, uj);
7c8ff89e
DS
4176}
4177
4178
4179DEFUN (show_ip_ospf_instance_neighbor,
4180 show_ip_ospf_instance_neighbor_cmd,
91756b38 4181 "show ip ospf <1-65535> neighbor {json}",
7c8ff89e
DS
4182 SHOW_STR
4183 IP_STR
4184 "OSPF information\n"
4185 "Instance ID\n"
91756b38
DS
4186 "Neighbor list\n"
4187 "JavaScript Object Notation\n")
7c8ff89e
DS
4188{
4189 struct ospf *ospf;
4190 u_short instance = 0;
db7c8528 4191 u_char uj = use_json(argc, argv);
7c8ff89e
DS
4192
4193 VTY_GET_INTEGER ("Instance", instance, argv[0]);
0bad4851 4194 if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running)
7c8ff89e
DS
4195 return CMD_SUCCESS;
4196
db7c8528 4197 return show_ip_ospf_neighbor_common(vty, ospf, uj);
7c8ff89e
DS
4198}
4199
4200static int
91756b38 4201show_ip_ospf_neighbor_all_common (struct vty *vty, struct ospf *ospf, u_char use_json)
7c8ff89e
DS
4202{
4203 struct listnode *node;
4204 struct ospf_interface *oi;
91756b38
DS
4205 json_object *json = NULL;
4206 json_object *json_neighbor_sub = NULL;
7c8ff89e 4207
91756b38
DS
4208 if (use_json)
4209 {
4210 json = json_object_new_object();
4211 json_neighbor_sub = json_object_new_object();
4212 }
4213 else
4214 show_ip_ospf_neighbour_header (vty);
7c8ff89e 4215
91756b38
DS
4216 if (ospf->instance)
4217 {
4218 if (use_json)
4219 json_object_int_add(json, "ospfInstance", ospf->instance);
4220 else
4221 vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance,
4222 VTY_NEWLINE, VTY_NEWLINE);
4223 }
7c8ff89e
DS
4224
4225 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
4226 {
52dc7ee6 4227 struct listnode *nbr_node;
1eb8ef25 4228 struct ospf_nbr_nbma *nbr_nbma;
718e3744 4229
91756b38 4230 show_ip_ospf_neighbor_sub (vty, oi, json, use_json);
718e3744 4231
91756b38
DS
4232 /* print Down neighbor status */
4233 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nbr_node, nbr_nbma))
4234 {
4235 if (nbr_nbma->nbr == NULL
4236 || nbr_nbma->nbr->state == NSM_Down)
4237 {
4238 if (use_json)
4239 {
4240 json_object_int_add (json_neighbor_sub, "nbrNbmaPriority", nbr_nbma->priority);
4241 json_object_boolean_true_add (json_neighbor_sub, "nbrNbmaDown");
4242 json_object_string_add (json_neighbor_sub, "nbrNbmaIfaceName", IF_NAME (oi));
3ac237f8
MS
4243 json_object_int_add (json_neighbor_sub, "nbrNbmaRetransmitCounter", 0);
4244 json_object_int_add (json_neighbor_sub, "nbrNbmaRequestCounter", 0);
4245 json_object_int_add (json_neighbor_sub, "nbrNbmaDbSummaryCounter", 0);
91756b38
DS
4246 json_object_object_add(json, inet_ntoa (nbr_nbma->addr), json_neighbor_sub);
4247 }
4248 else
4249 {
4250 vty_out (vty, "%-15s %3d %-15s %9s ",
4251 "-", nbr_nbma->priority, "Down", "-");
4252 vty_out (vty, "%-15s %-20s %5d %5d %5d%s",
4253 inet_ntoa (nbr_nbma->addr), IF_NAME (oi),
4254 0, 0, 0, VTY_NEWLINE);
4255 }
4256 }
4257 }
718e3744 4258 }
4259
91756b38
DS
4260 if (use_json)
4261 {
2aac5767 4262 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
91756b38
DS
4263 json_object_free(json);
4264 }
4265 else
4266 vty_out (vty, "%s", VTY_NEWLINE);
7c8ff89e 4267
718e3744 4268 return CMD_SUCCESS;
4269}
4270
7c8ff89e
DS
4271DEFUN (show_ip_ospf_neighbor_all,
4272 show_ip_ospf_neighbor_all_cmd,
91756b38 4273 "show ip ospf neighbor all {json}",
718e3744 4274 SHOW_STR
4275 IP_STR
4276 "OSPF information\n"
4277 "Neighbor list\n"
91756b38
DS
4278 "include down status neighbor\n"
4279 "JavaScript Object Notation\n")
7c8ff89e
DS
4280{
4281 struct ospf *ospf;
db7c8528 4282 u_char uj = use_json(argc, argv);
7c8ff89e 4283
0bad4851 4284 if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running)
7c8ff89e
DS
4285 return CMD_SUCCESS;
4286
db7c8528 4287 return show_ip_ospf_neighbor_all_common(vty, ospf, uj);
7c8ff89e
DS
4288}
4289
4290DEFUN (show_ip_ospf_instance_neighbor_all,
4291 show_ip_ospf_instance_neighbor_all_cmd,
91756b38 4292 "show ip ospf <1-65535> neighbor all {json}",
7c8ff89e
DS
4293 SHOW_STR
4294 IP_STR
4295 "OSPF information\n"
4296 "Instance ID\n"
4297 "Neighbor list\n"
91756b38
DS
4298 "include down status neighbor\n"
4299 "JavaScript Object Notation\n")
718e3744 4300{
020709f9 4301 struct ospf *ospf;
7c8ff89e 4302 u_short instance = 0;
db7c8528 4303 u_char uj = use_json(argc, argv);
7c8ff89e
DS
4304
4305 VTY_GET_INTEGER ("Instance", instance, argv[0]);
0bad4851 4306 if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running)
7c8ff89e
DS
4307 return CMD_SUCCESS;
4308
db7c8528 4309 return show_ip_ospf_neighbor_all_common(vty, ospf, uj);
7c8ff89e
DS
4310}
4311
4312static int
4313show_ip_ospf_neighbor_int_common (struct vty *vty, struct ospf *ospf, int arg_base,
91756b38 4314 const char **argv, u_char use_json)
7c8ff89e 4315{
bb5b7552 4316 struct interface *ifp;
4317 struct route_node *rn;
91756b38
DS
4318 json_object *json = NULL;
4319
4320 if (use_json)
4321 json = json_object_new_object();
4322 else
4323 show_ip_ospf_neighbour_header (vty);
7c8ff89e
DS
4324
4325 if (ospf->instance)
91756b38
DS
4326 {
4327 if (use_json)
4328 json_object_int_add(json, "ospfInstance", ospf->instance);
4329 else
4330 vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance,
4331 VTY_NEWLINE, VTY_NEWLINE);
4332 }
7c8ff89e 4333
91756b38 4334 ifp = if_lookup_by_name (argv[arg_base]);
bb5b7552 4335 if (!ifp)
718e3744 4336 {
91756b38
DS
4337 if (use_json)
4338 json_object_boolean_true_add(json, "noSuchIface");
4339 else
4340 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
718e3744 4341 return CMD_WARNING;
4342 }
d24f6e2a 4343
bb5b7552 4344 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
718e3744 4345 {
bb5b7552 4346 struct ospf_interface *oi = rn->info;
4347
4348 if (oi == NULL)
91756b38 4349 continue;
bb5b7552 4350
91756b38 4351 show_ip_ospf_neighbor_sub (vty, oi, json, use_json);
718e3744 4352 }
4353
91756b38
DS
4354 if (use_json)
4355 {
2aac5767 4356 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
91756b38
DS
4357 json_object_free(json);
4358 }
4359 else
4360 vty_out (vty, "%s", VTY_NEWLINE);
4361
718e3744 4362 return CMD_SUCCESS;
4363}
4364
7c8ff89e
DS
4365DEFUN (show_ip_ospf_neighbor_int,
4366 show_ip_ospf_neighbor_int_cmd,
91756b38 4367 "show ip ospf neighbor IFNAME {json}",
7c8ff89e
DS
4368 SHOW_STR
4369 IP_STR
4370 "OSPF information\n"
4371 "Neighbor list\n"
91756b38
DS
4372 "Interface name\n"
4373 "JavaScript Object Notation\n")
7c8ff89e
DS
4374{
4375 struct ospf *ospf;
db7c8528 4376 u_char uj = use_json(argc, argv);
7c8ff89e 4377
0bad4851 4378 if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running)
7c8ff89e
DS
4379 return CMD_SUCCESS;
4380
db7c8528 4381 return show_ip_ospf_neighbor_int_common(vty, ospf, 0, argv, uj);
7c8ff89e
DS
4382}
4383
4384DEFUN (show_ip_ospf_instance_neighbor_int,
4385 show_ip_ospf_instance_neighbor_int_cmd,
91756b38 4386 "show ip ospf <1-65535> neighbor IFNAME {json}",
7c8ff89e
DS
4387 SHOW_STR
4388 IP_STR
4389 "OSPF information\n"
4390 "Instance ID\n"
4391 "Neighbor list\n"
91756b38
DS
4392 "Interface name\n"
4393 "JavaScript Object Notation\n")
7c8ff89e
DS
4394{
4395 struct ospf *ospf;
4396 u_short instance = 0;
db7c8528 4397 u_char uj = use_json(argc, argv);
7c8ff89e
DS
4398
4399 VTY_GET_INTEGER ("Instance", instance, argv[0]);
0bad4851 4400 if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running)
7c8ff89e
DS
4401 return CMD_SUCCESS;
4402
db7c8528 4403 return show_ip_ospf_neighbor_int_common(vty, ospf, 1, argv, uj);
7c8ff89e
DS
4404}
4405
4dadc291 4406static void
3ac237f8
MS
4407show_ip_ospf_nbr_nbma_detail_sub (struct vty *vty, struct ospf_interface *oi, struct ospf_nbr_nbma *nbr_nbma,
4408 u_char use_json, json_object *json)
718e3744 4409{
649654ab 4410 char timebuf[OSPF_TIME_DUMP_SIZE];
3ac237f8 4411 json_object *json_sub = NULL;
718e3744 4412
3ac237f8
MS
4413 if (use_json)
4414 json_sub = json_object_new_object();
4415 else /* Show neighbor ID. */
4416 vty_out (vty, " Neighbor %s,", "-");
718e3744 4417
4418 /* Show interface address. */
3ac237f8
MS
4419 if (use_json)
4420 json_object_string_add(json_sub, "ifaceAddress", inet_ntoa (nbr_nbma->addr));
4421 else
4422 vty_out (vty, " interface address %s%s",
4423 inet_ntoa (nbr_nbma->addr), VTY_NEWLINE);
4424
718e3744 4425 /* Show Area ID. */
3ac237f8
MS
4426 if (use_json)
4427 {
4428 json_object_string_add(json_sub, "areaId", ospf_area_desc_string (oi->area));
4429 json_object_string_add(json_sub, "iface", IF_NAME (oi));
4430 }
4431 else
4432 vty_out (vty, " In the area %s via interface %s%s",
4433 ospf_area_desc_string (oi->area), IF_NAME (oi), VTY_NEWLINE);
4434
718e3744 4435 /* Show neighbor priority and state. */
3ac237f8
MS
4436 if (use_json)
4437 {
4438 json_object_int_add(json_sub, "nbrPriority", nbr_nbma->priority);
4439 json_object_string_add(json_sub, "nbrState", "down");
4440 }
4441 else
4442 vty_out (vty, " Neighbor priority is %d, State is %s,",
4443 nbr_nbma->priority, "Down");
4444
718e3744 4445 /* Show state changes. */
3ac237f8
MS
4446 if (use_json)
4447 json_object_int_add(json_sub, "stateChangeCounter", nbr_nbma->state_change);
4448 else
4449 vty_out (vty, " %d state changes%s", nbr_nbma->state_change, VTY_NEWLINE);
718e3744 4450
4451 /* Show PollInterval */
3ac237f8
MS
4452 if (use_json)
4453 json_object_int_add(json_sub, "pollInterval", nbr_nbma->v_poll);
4454 else
4455 vty_out (vty, " Poll interval %d%s", nbr_nbma->v_poll, VTY_NEWLINE);
718e3744 4456
4457 /* Show poll-interval timer. */
3ac237f8
MS
4458 if (use_json)
4459 {
4460 struct timeval res = tv_sub (nbr_nbma->t_poll->u.sands, recent_relative_time ());
4461 unsigned long time_store = 0;
4462 time_store = (1000 * res.tv_sec) + (res.tv_usec / 1000);
4463 json_object_int_add(json_sub, "pollIntervalTimerDueMsec", time_store);
4464 }
4465 else
4466 vty_out (vty, " Poll timer due in %s%s",
4467 ospf_timer_dump (nbr_nbma->t_poll, timebuf, sizeof(timebuf)),
4468 VTY_NEWLINE);
718e3744 4469
4470 /* Show poll-interval timer thread. */
3ac237f8
MS
4471 if (use_json)
4472 {
4473 if (nbr_nbma->t_poll != NULL)
4474 json_object_string_add(json_sub, "pollIntervalTimerThread", "on");
4475 }
4476 else
4477 vty_out (vty, " Thread Poll Timer %s%s",
4478 nbr_nbma->t_poll != NULL ? "on" : "off", VTY_NEWLINE);
4479
4480 if (use_json)
4481 json_object_object_add(json, "noNbrId", json_sub);
718e3744 4482}
4483
4dadc291 4484static void
718e3744 4485show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
3ac237f8 4486 struct ospf_neighbor *nbr, u_char use_json, json_object *json)
718e3744 4487{
649654ab 4488 char timebuf[OSPF_TIME_DUMP_SIZE];
3ac237f8 4489 json_object *json_sub = NULL;
718e3744 4490
3ac237f8
MS
4491 if (use_json)
4492 json_sub = json_object_new_object();
718e3744 4493 else
3ac237f8
MS
4494 {
4495 /* Show neighbor ID. */
4496 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
4497 vty_out (vty, " Neighbor %s,", "-");
4498 else
4499 vty_out (vty, " Neighbor %s,", inet_ntoa (nbr->router_id));
4500 }
718e3744 4501
4502 /* Show interface address. */
3ac237f8
MS
4503 if (use_json)
4504 json_object_string_add(json_sub, "ifaceAddress", inet_ntoa (nbr->address.u.prefix4));
4505 else
4506 vty_out (vty, " interface address %s%s",
4507 inet_ntoa (nbr->address.u.prefix4), VTY_NEWLINE);
4508
718e3744 4509 /* Show Area ID. */
3ac237f8
MS
4510 if (use_json)
4511 {
4512 json_object_string_add(json_sub, "areaId", ospf_area_desc_string (oi->area));
4513 json_object_string_add(json_sub, "ifaceName", oi->ifp->name);
4514 }
4515 else
4516 vty_out (vty, " In the area %s via interface %s%s",
4517 ospf_area_desc_string (oi->area), oi->ifp->name, VTY_NEWLINE);
4518
718e3744 4519 /* Show neighbor priority and state. */
3ac237f8
MS
4520 if (use_json)
4521 {
4522 json_object_int_add(json_sub, "nbrPriority", nbr->priority);
4523 json_object_string_add(json_sub, "nbrState", LOOKUP (ospf_nsm_state_msg, nbr->state));
4524 }
4525 else
4526 vty_out (vty, " Neighbor priority is %d, State is %s,",
4527 nbr->priority, LOOKUP (ospf_nsm_state_msg, nbr->state));
4528
718e3744 4529 /* Show state changes. */
3ac237f8
MS
4530 if (use_json)
4531 json_object_int_add(json_sub, "stateChangeCounter", nbr->state_change);
4532 else
4533 vty_out (vty, " %d state changes%s", nbr->state_change, VTY_NEWLINE);
4534
3fed4160 4535 if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec)
90c33177 4536 {
3ac237f8
MS
4537 struct timeval res = tv_sub (recent_relative_time (), nbr->ts_last_progress);
4538 if (use_json)
4539 {
4540 unsigned long time_store = 0;
4541 time_store = (1000 * res.tv_sec) + (res.tv_usec / 1000);
4542 json_object_int_add(json_sub, "lastPrgrsvChangeMsec", time_store);
4543 }
4544 else
4545 {
4546 vty_out (vty, " Most recent state change statistics:%s",
4547 VTY_NEWLINE);
4548 vty_out (vty, " Progressive change %s ago%s",
4549 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
4550 VTY_NEWLINE);
4551 }
3fed4160 4552 }
3ac237f8 4553
3fed4160
PJ
4554 if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec)
4555 {
3ac237f8
MS
4556 struct timeval res = tv_sub (recent_relative_time (), nbr->ts_last_regress);
4557 if (use_json)
4558 {
4559 unsigned long time_store = 0;
4560 time_store = (1000 * res.tv_sec) + (res.tv_usec / 1000);
4561 json_object_int_add(json_sub, "lastRegressiveChangeMsec", time_store);
4562 if (nbr->last_regress_str)
4563 json_object_string_add(json_sub, "lastRegressiveChangeReason", nbr->last_regress_str);
4564 }
4565 else
4566 {
4567 vty_out (vty, " Regressive change %s ago, due to %s%s",
4568 ospf_timeval_dump (&res, timebuf, sizeof(timebuf)),
4569 (nbr->last_regress_str ? nbr->last_regress_str : "??"),
4570 VTY_NEWLINE);
4571 }
90c33177 4572 }
3ac237f8 4573
718e3744 4574 /* Show Designated Rotuer ID. */
3ac237f8
MS
4575 if (use_json)
4576 json_object_string_add(json_sub, "routerDesignatedId", inet_ntoa (nbr->d_router));
4577 else
4578 vty_out (vty, " DR is %s,", inet_ntoa (nbr->d_router));
4579
718e3744 4580 /* Show Backup Designated Rotuer ID. */
3ac237f8
MS
4581 if (use_json)
4582 json_object_string_add(json_sub, "routerDesignatedBackupId", inet_ntoa (nbr->bd_router));
4583 else
4584 vty_out (vty, " BDR is %s%s", inet_ntoa (nbr->bd_router), VTY_NEWLINE);
4585
718e3744 4586 /* Show options. */
3ac237f8
MS
4587 if (use_json)
4588 {
4589 json_object_int_add(json_sub, "optionsCounter", nbr->options);
4590 json_object_string_add(json_sub, "optionsList", ospf_options_dump (nbr->options));
4591 }
4592 else
4593 vty_out (vty, " Options %d %s%s", nbr->options,
4594 ospf_options_dump (nbr->options), VTY_NEWLINE);
4595
718e3744 4596 /* Show Router Dead interval timer. */
3ac237f8
MS
4597 if (use_json)
4598 {
45d430e8
DS
4599 if (nbr->t_inactivity)
4600 {
4601 struct timeval res = tv_sub (nbr->t_inactivity->u.sands, recent_relative_time ());
4602 unsigned long time_store = 0;
4603 time_store = (1000 * res.tv_sec) + (res.tv_usec / 1000);
4604 json_object_int_add(json_sub, "routerDeadIntervalTimerDueMsec", time_store);
4605 }
4606 else
4607 json_object_int_add(json_sub, "routerDeadIntervalTimerDueMsec", -1);
3ac237f8
MS
4608 }
4609 else
4610 vty_out (vty, " Dead timer due in %s%s",
4611 ospf_timer_dump (nbr->t_inactivity, timebuf, sizeof (timebuf)),
4612 VTY_NEWLINE);
4613
718e3744 4614 /* Show Database Summary list. */
3ac237f8
MS
4615 if (use_json)
4616 json_object_int_add(json_sub, "databaseSummaryListCounter", ospf_db_summary_count (nbr));
4617 else
4618 vty_out (vty, " Database Summary List %d%s",
4619 ospf_db_summary_count (nbr), VTY_NEWLINE);
4620
718e3744 4621 /* Show Link State Request list. */
3ac237f8
MS
4622 if (use_json)
4623 json_object_int_add(json_sub, "linkStateRequestListCounter", ospf_ls_request_count (nbr));
4624 else
4625 vty_out (vty, " Link State Request List %ld%s",
4626 ospf_ls_request_count (nbr), VTY_NEWLINE);
4627
718e3744 4628 /* Show Link State Retransmission list. */
3ac237f8
MS
4629 if (use_json)
4630 json_object_int_add(json_sub, "linkStateRetransmissionListCounter", ospf_ls_retransmit_count (nbr));
4631 else
4632 vty_out (vty, " Link State Retransmission List %ld%s",
4633 ospf_ls_retransmit_count (nbr), VTY_NEWLINE);
4634
718e3744 4635 /* Show inactivity timer thread. */
3ac237f8
MS
4636 if (use_json)
4637 {
4638 if (nbr->t_inactivity != NULL)
4639 json_object_string_add(json_sub, "threadInactivityTimer", "on");
4640 }
4641 else
4642 vty_out (vty, " Thread Inactivity Timer %s%s",
4643 nbr->t_inactivity != NULL ? "on" : "off", VTY_NEWLINE);
4644
718e3744 4645 /* Show Database Description retransmission thread. */
3ac237f8
MS
4646 if (use_json)
4647 {
4648 if (nbr->t_db_desc != NULL)
4649 json_object_string_add(json_sub, "threadDatabaseDescriptionRetransmission", "on");
4650 }
4651 else
4652 vty_out (vty, " Thread Database Description Retransmision %s%s",
4653 nbr->t_db_desc != NULL ? "on" : "off", VTY_NEWLINE);
4654
718e3744 4655 /* Show Link State Request Retransmission thread. */
3ac237f8
MS
4656 if (use_json)
4657 {
4658 if (nbr->t_ls_req != NULL)
4659 json_object_string_add(json_sub, "threadLinkStateRequestRetransmission", "on");
4660 }
4661 else
4662 vty_out (vty, " Thread Link State Request Retransmission %s%s",
4663 nbr->t_ls_req != NULL ? "on" : "off", VTY_NEWLINE);
4664
718e3744 4665 /* Show Link State Update Retransmission thread. */
3ac237f8
MS
4666 if (use_json)
4667 {
4668 if (nbr->t_ls_upd != NULL)
4669 json_object_string_add(json_sub, "threadLinkStateUpdateRetransmission", "on");
4670 }
4671 else
4672 vty_out (vty, " Thread Link State Update Retransmission %s%s%s",
4673 nbr->t_ls_upd != NULL ? "on" : "off", VTY_NEWLINE, VTY_NEWLINE);
4674
4675 if (use_json)
4676 {
4677 if (nbr->state == NSM_Attempt && nbr->router_id.s_addr == 0)
4678 json_object_object_add(json, "noNbrId", json_sub);
4679 else
4680 json_object_object_add(json, inet_ntoa (nbr->router_id), json_sub);
4681 }
68fe91d6 4682
4683 ospf_bfd_show_info(vty, nbr->bfd_info, json, use_json, 0);
718e3744 4684}
4685
7c8ff89e
DS
4686static int
4687show_ip_ospf_neighbor_id_common (struct vty *vty, struct ospf *ospf,
3ac237f8 4688 int arg_base, const char **argv, u_char use_json)
718e3744 4689{
52dc7ee6 4690 struct listnode *node;
718e3744 4691 struct ospf_neighbor *nbr;
1eb8ef25 4692 struct ospf_interface *oi;
718e3744 4693 struct in_addr router_id;
4694 int ret;
3ac237f8
MS
4695 json_object *json = NULL;
4696
4697 if (use_json)
4698 json = json_object_new_object();
718e3744 4699
7c8ff89e 4700 if (ospf->instance)
3ac237f8
MS
4701 {
4702 if (use_json)
4703 json_object_int_add(json, "ospfInstance", ospf->instance);
4704 else
4705 vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance,
4706 VTY_NEWLINE, VTY_NEWLINE);
4707 }
7c8ff89e 4708
3ac237f8 4709 ret = inet_aton (argv[arg_base], &router_id);
718e3744 4710 if (!ret)
4711 {
3ac237f8
MS
4712 if (!use_json)
4713 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
718e3744 4714 return CMD_WARNING;
4715 }
4716
1eb8ef25 4717 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
3ac237f8
MS
4718 {
4719 if ((nbr = ospf_nbr_lookup_by_routerid (oi->nbrs, &router_id)))
4720 {
4721 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr, use_json, json);
4722 }
4723 }
4724
4725 if (use_json)
4726 {
2aac5767 4727 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
3ac237f8
MS
4728 json_object_free(json);
4729 }
4730 else
4731 vty_out (vty, "%s", VTY_NEWLINE);
718e3744 4732
718e3744 4733 return CMD_SUCCESS;
4734}
4735
7c8ff89e
DS
4736DEFUN (show_ip_ospf_neighbor_id,
4737 show_ip_ospf_neighbor_id_cmd,
3ac237f8 4738 "show ip ospf neighbor A.B.C.D {json}",
718e3744 4739 SHOW_STR
4740 IP_STR
4741 "OSPF information\n"
4742 "Neighbor list\n"
3ac237f8
MS
4743 "Neighbor ID\n"
4744 "JavaScript Object Notation\n")
718e3744 4745{
020709f9 4746 struct ospf *ospf;
db7c8528 4747 u_char uj = use_json(argc, argv);
7c8ff89e 4748
0bad4851 4749 if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running)
7c8ff89e
DS
4750 return CMD_SUCCESS;
4751
db7c8528 4752 return show_ip_ospf_neighbor_id_common(vty, ospf, 0, argv, uj);
7c8ff89e
DS
4753}
4754
4755DEFUN (show_ip_ospf_instance_neighbor_id,
4756 show_ip_ospf_instance_neighbor_id_cmd,
3ac237f8 4757 "show ip ospf <1-65535> neighbor A.B.C.D {json}",
7c8ff89e
DS
4758 SHOW_STR
4759 IP_STR
4760 "OSPF information\n"
4761 "Instance ID\n"
4762 "Neighbor list\n"
3ac237f8
MS
4763 "Neighbor ID\n"
4764 "JavaScript Object Notation\n")
7c8ff89e
DS
4765{
4766 struct ospf *ospf;
4767 u_short instance = 0;
db7c8528 4768 u_char uj = use_json(argc, argv);
7c8ff89e
DS
4769
4770 VTY_GET_INTEGER ("Instance", instance, argv[0]);
0bad4851 4771 if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running)
7c8ff89e
DS
4772 return CMD_SUCCESS;
4773
db7c8528 4774 return show_ip_ospf_neighbor_id_common(vty, ospf, 1, argv, uj);
7c8ff89e
DS
4775}
4776
4777static int
3ac237f8 4778show_ip_ospf_neighbor_detail_common (struct vty *vty, struct ospf *ospf, u_char use_json)
7c8ff89e 4779{
1eb8ef25 4780 struct ospf_interface *oi;
52dc7ee6 4781 struct listnode *node;
3ac237f8
MS
4782 json_object *json = NULL;
4783
4784 if (use_json)
4785 json = json_object_new_object();
718e3744 4786
7c8ff89e 4787 if (ospf->instance)
3ac237f8
MS
4788 {
4789 if (use_json)
4790 json_object_int_add(json, "ospfInstance", ospf->instance);
4791 else
4792 vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance,
4793 VTY_NEWLINE, VTY_NEWLINE);
4794 }
718e3744 4795
1eb8ef25 4796 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
718e3744 4797 {
718e3744 4798 struct route_node *rn;
4799 struct ospf_neighbor *nbr;
4800
4801 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
3ac237f8
MS
4802 {
4803 if ((nbr = rn->info))
4804 {
4805 if (nbr != oi->nbr_self)
4806 {
4807 if (nbr->state != NSM_Down)
4808 {
4809 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr, use_json, json);
4810 }
4811 }
4812 }
4813 }
718e3744 4814 }
4815
3ac237f8
MS
4816 if (use_json)
4817 {
2aac5767 4818 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
3ac237f8
MS
4819 json_object_free(json);
4820 }
4821 else
4822 vty_out (vty, "%s", VTY_NEWLINE);
4823
718e3744 4824 return CMD_SUCCESS;
4825}
4826
7c8ff89e
DS
4827DEFUN (show_ip_ospf_neighbor_detail,
4828 show_ip_ospf_neighbor_detail_cmd,
3ac237f8 4829 "show ip ospf neighbor detail {json}",
718e3744 4830 SHOW_STR
4831 IP_STR
4832 "OSPF information\n"
4833 "Neighbor list\n"
3ac237f8
MS
4834 "detail of all neighbors\n"
4835 "JavaScript Object Notation\n")
718e3744 4836{
020709f9 4837 struct ospf *ospf;
db7c8528 4838 u_char uj = use_json(argc, argv);
7c8ff89e 4839
0bad4851 4840 if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running)
7c8ff89e
DS
4841 return CMD_SUCCESS;
4842
db7c8528 4843 return show_ip_ospf_neighbor_detail_common(vty, ospf, uj);
7c8ff89e
DS
4844}
4845
4846DEFUN (show_ip_ospf_instance_neighbor_detail,
4847 show_ip_ospf_instance_neighbor_detail_cmd,
3ac237f8 4848 "show ip ospf <1-65535> neighbor detail {json}",
7c8ff89e
DS
4849 SHOW_STR
4850 IP_STR
4851 "OSPF information\n"
4852 "Instance ID\n"
4853 "Neighbor list\n"
3ac237f8
MS
4854 "detail of all neighbors\n"
4855 "JavaScript Object Notation\n")
7c8ff89e
DS
4856{
4857 struct ospf *ospf;
4858 u_short instance = 0;
db7c8528 4859 u_char uj = use_json(argc, argv);
7c8ff89e
DS
4860
4861 VTY_GET_INTEGER ("Instance", instance, argv[0]);
0bad4851 4862 if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running)
7c8ff89e
DS
4863 return CMD_SUCCESS;
4864
db7c8528 4865 return show_ip_ospf_neighbor_detail_common(vty, ospf, uj);
7c8ff89e
DS
4866}
4867
4868static int
3ac237f8 4869show_ip_ospf_neighbor_detail_all_common (struct vty *vty, struct ospf *ospf, u_char use_json)
7c8ff89e 4870{
52dc7ee6 4871 struct listnode *node;
1eb8ef25 4872 struct ospf_interface *oi;
3ac237f8
MS
4873 json_object *json = NULL;
4874
4875 if (use_json)
4876 json = json_object_new_object();
718e3744 4877
7c8ff89e 4878 if (ospf->instance)
3ac237f8
MS
4879 {
4880 if (use_json)
4881 json_object_int_add(json, "ospfInstance", ospf->instance);
4882 else
4883 vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance,
4884 VTY_NEWLINE, VTY_NEWLINE);
4885 }
718e3744 4886
1eb8ef25 4887 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
718e3744 4888 {
718e3744 4889 struct route_node *rn;
4890 struct ospf_neighbor *nbr;
1eb8ef25 4891 struct ospf_nbr_nbma *nbr_nbma;
718e3744 4892
4893 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4894 if ((nbr = rn->info))
4895 if (nbr != oi->nbr_self)
a452df33 4896 if (nbr->state != NSM_Down)
3ac237f8 4897 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info, use_json, json);
718e3744 4898
4899 if (oi->type == OSPF_IFTYPE_NBMA)
3ac237f8
MS
4900 {
4901 struct listnode *nd;
718e3744 4902
3ac237f8
MS
4903 for (ALL_LIST_ELEMENTS_RO (oi->nbr_nbma, nd, nbr_nbma))
4904 {
4905 if (nbr_nbma->nbr == NULL || nbr_nbma->nbr->state == NSM_Down)
4906 show_ip_ospf_nbr_nbma_detail_sub (vty, oi, nbr_nbma, use_json, json);
4907 }
4908 }
4909 }
4910
4911 if (use_json)
4912 {
2aac5767 4913 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
3ac237f8
MS
4914 json_object_free(json);
4915 }
4916 else
4917 {
4918 vty_out (vty, "%s", VTY_NEWLINE);
718e3744 4919 }
4920
4921 return CMD_SUCCESS;
4922}
4923
7c8ff89e
DS
4924DEFUN (show_ip_ospf_neighbor_detail_all,
4925 show_ip_ospf_neighbor_detail_all_cmd,
3ac237f8 4926 "show ip ospf neighbor detail all {json}",
718e3744 4927 SHOW_STR
4928 IP_STR
4929 "OSPF information\n"
4930 "Neighbor list\n"
7c8ff89e 4931 "detail of all neighbors\n"
3ac237f8
MS
4932 "include down status neighbor\n"
4933 "JavaScript Object Notation\n")
718e3744 4934{
020709f9 4935 struct ospf *ospf;
db7c8528 4936 u_char uj = use_json(argc, argv);
7c8ff89e 4937
0bad4851 4938 if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running)
7c8ff89e
DS
4939 return CMD_SUCCESS;
4940
db7c8528 4941 return show_ip_ospf_neighbor_detail_all_common(vty, ospf, uj);
7c8ff89e
DS
4942}
4943
4944DEFUN (show_ip_ospf_instance_neighbor_detail_all,
4945 show_ip_ospf_instance_neighbor_detail_all_cmd,
3ac237f8 4946 "show ip ospf <1-65535> neighbor detail all {json}",
7c8ff89e
DS
4947 SHOW_STR
4948 IP_STR
4949 "OSPF information\n"
4950 "Instance ID\n"
4951 "Neighbor list\n"
4952 "detail of all neighbors\n"
3ac237f8
MS
4953 "include down status neighbor\n"
4954 "JavaScript Object Notation\n")
7c8ff89e
DS
4955{
4956 struct ospf *ospf;
4957 u_short instance = 0;
db7c8528 4958 u_char uj = use_json(argc, argv);
7c8ff89e
DS
4959
4960 VTY_GET_INTEGER ("Instance", instance, argv[0]);
0bad4851 4961 if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running)
7c8ff89e
DS
4962 return CMD_SUCCESS;
4963
db7c8528 4964 return show_ip_ospf_neighbor_detail_all_common(vty, ospf, uj);
7c8ff89e
DS
4965}
4966
4967static int
4968show_ip_ospf_neighbor_int_detail_common (struct vty *vty, struct ospf *ospf,
3ac237f8 4969 int arg_base, const char **argv, u_char use_json)
7c8ff89e 4970{
718e3744 4971 struct ospf_interface *oi;
bb5b7552 4972 struct interface *ifp;
4973 struct route_node *rn, *nrn;
4974 struct ospf_neighbor *nbr;
3ac237f8
MS
4975 json_object *json = NULL;
4976
4977 if (use_json)
4978 json = json_object_new_object();
bb5b7552 4979
7c8ff89e 4980 if (ospf->instance)
3ac237f8
MS
4981 {
4982 if (use_json)
4983 json_object_int_add(json, "ospfInstance", ospf->instance);
4984 else
4985 vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance,
4986 VTY_NEWLINE, VTY_NEWLINE);
4987 }
7c8ff89e 4988
3ac237f8 4989 ifp = if_lookup_by_name (argv[arg_base]);
bb5b7552 4990 if (!ifp)
718e3744 4991 {
3ac237f8
MS
4992 if (!use_json)
4993 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
718e3744 4994 return CMD_WARNING;
4995 }
4996
bb5b7552 4997 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3ac237f8
MS
4998 {
4999 if ((oi = rn->info))
5000 {
5001 for (nrn = route_top (oi->nbrs); nrn; nrn = route_next (nrn))
5002 {
5003 if ((nbr = nrn->info))
5004 {
5005 if (nbr != oi->nbr_self)
5006 {
5007 if (nbr->state != NSM_Down)
5008 show_ip_ospf_neighbor_detail_sub (vty, oi, nbr, use_json, json);
5009 }
5010 }
5011 }
5012 }
5013 }
5014
5015 if (use_json)
5016 {
2aac5767 5017 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
3ac237f8
MS
5018 json_object_free(json);
5019 }
5020 else
5021 vty_out (vty, "%s", VTY_NEWLINE);
718e3744 5022
5023 return CMD_SUCCESS;
5024}
5025
7c8ff89e
DS
5026DEFUN (show_ip_ospf_neighbor_int_detail,
5027 show_ip_ospf_neighbor_int_detail_cmd,
3ac237f8 5028 "show ip ospf neighbor IFNAME detail {json}",
7c8ff89e
DS
5029 SHOW_STR
5030 IP_STR
5031 "OSPF information\n"
5032 "Neighbor list\n"
5033 "Interface name\n"
3ac237f8
MS
5034 "detail of all neighbors\n"
5035 "JavaScript Object Notation\n")
7c8ff89e
DS
5036{
5037 struct ospf *ospf;
db7c8528 5038 u_char uj = use_json(argc, argv);
7c8ff89e 5039
0bad4851 5040 if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running)
7c8ff89e
DS
5041 return CMD_SUCCESS;
5042
db7c8528 5043 return show_ip_ospf_neighbor_int_detail_common(vty, ospf, 0, argv, uj);
7c8ff89e
DS
5044}
5045
5046DEFUN (show_ip_ospf_instance_neighbor_int_detail,
5047 show_ip_ospf_instance_neighbor_int_detail_cmd,
3ac237f8 5048 "show ip ospf <1-65535> neighbor IFNAME detail {json}",
7c8ff89e
DS
5049 SHOW_STR
5050 IP_STR
5051 "OSPF information\n"
5052 "Instance ID\n"
5053 "Neighbor list\n"
5054 "Interface name\n"
3ac237f8
MS
5055 "detail of all neighbors\n"
5056 "JavaScript Object Notation\n")
7c8ff89e
DS
5057{
5058 struct ospf *ospf;
5059 u_short instance = 0;
db7c8528 5060 u_char uj = use_json(argc, argv);
7c8ff89e
DS
5061
5062 VTY_GET_INTEGER ("Instance", instance, argv[0]);
0bad4851 5063 if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running)
7c8ff89e
DS
5064 return CMD_SUCCESS;
5065
db7c8528 5066 return show_ip_ospf_neighbor_int_detail_common(vty, ospf, 1, argv, uj);
7c8ff89e 5067}
6b0655a2 5068
718e3744 5069/* Show functions */
4dadc291 5070static int
020709f9 5071show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
718e3744 5072{
718e3744 5073 struct router_lsa *rl;
5074 struct summary_lsa *sl;
5075 struct as_external_lsa *asel;
5076 struct prefix_ipv4 p;
5077
5078 if (lsa != NULL)
5079 /* If self option is set, check LSA self flag. */
5080 if (self == 0 || IS_LSA_SELF (lsa))
5081 {
5082 /* LSA common part show. */
5083 vty_out (vty, "%-15s ", inet_ntoa (lsa->data->id));
5084 vty_out (vty, "%-15s %4d 0x%08lx 0x%04x",
5085 inet_ntoa (lsa->data->adv_router), LS_AGE (lsa),
5086 (u_long)ntohl (lsa->data->ls_seqnum), ntohs (lsa->data->checksum));
5087 /* LSA specific part show. */
5088 switch (lsa->data->type)
5089 {
5090 case OSPF_ROUTER_LSA:
5091 rl = (struct router_lsa *) lsa->data;
5092 vty_out (vty, " %-d", ntohs (rl->links));
5093 break;
5094 case OSPF_SUMMARY_LSA:
5095 sl = (struct summary_lsa *) lsa->data;
5096
5097 p.family = AF_INET;
5098 p.prefix = sl->header.id;
5099 p.prefixlen = ip_masklen (sl->mask);
5100 apply_mask_ipv4 (&p);
5101
5102 vty_out (vty, " %s/%d", inet_ntoa (p.prefix), p.prefixlen);
5103 break;
5104 case OSPF_AS_EXTERNAL_LSA:
551a8979 5105 case OSPF_AS_NSSA_LSA:
718e3744 5106 asel = (struct as_external_lsa *) lsa->data;
5107
5108 p.family = AF_INET;
5109 p.prefix = asel->header.id;
5110 p.prefixlen = ip_masklen (asel->mask);
5111 apply_mask_ipv4 (&p);
5112
5113 vty_out (vty, " %s %s/%d [0x%lx]",
5114 IS_EXTERNAL_METRIC (asel->e[0].tos) ? "E2" : "E1",
5115 inet_ntoa (p.prefix), p.prefixlen,
5116 (u_long)ntohl (asel->e[0].route_tag));
5117 break;
5118 case OSPF_NETWORK_LSA:
5119 case OSPF_ASBR_SUMMARY_LSA:
718e3744 5120 case OSPF_OPAQUE_LINK_LSA:
5121 case OSPF_OPAQUE_AREA_LSA:
5122 case OSPF_OPAQUE_AS_LSA:
718e3744 5123 default:
5124 break;
5125 }
5126 vty_out (vty, VTY_NEWLINE);
5127 }
5128
5129 return 0;
5130}
5131
8b6a15b2 5132static const char *show_database_desc[] =
718e3744 5133{
5134 "unknown",
5135 "Router Link States",
5136 "Net Link States",
5137 "Summary Link States",
5138 "ASBR-Summary Link States",
5139 "AS External Link States",
718e3744 5140 "Group Membership LSA",
5141 "NSSA-external Link States",
718e3744 5142 "Type-8 LSA",
5143 "Link-Local Opaque-LSA",
5144 "Area-Local Opaque-LSA",
5145 "AS-external Opaque-LSA",
718e3744 5146};
5147
8b6a15b2 5148static const char *show_database_header[] =
718e3744 5149{
5150 "",
5151 "Link ID ADV Router Age Seq# CkSum Link count",
5152 "Link ID ADV Router Age Seq# CkSum",
5153 "Link ID ADV Router Age Seq# CkSum Route",
5154 "Link ID ADV Router Age Seq# CkSum",
5155 "Link ID ADV Router Age Seq# CkSum Route",
718e3744 5156 " --- header for Group Member ----",
5157 "Link ID ADV Router Age Seq# CkSum Route",
718e3744 5158 " --- type-8 ---",
5159 "Opaque-Type/Id ADV Router Age Seq# CkSum",
5160 "Opaque-Type/Id ADV Router Age Seq# CkSum",
5161 "Opaque-Type/Id ADV Router Age Seq# CkSum",
718e3744 5162};
5163
4dadc291 5164static void
718e3744 5165show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
5166{
5167 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
4957f494 5168
718e3744 5169 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
4957f494 5170 vty_out (vty, " Options: 0x%-2x : %s%s",
5171 lsa->data->options,
5172 ospf_options_dump(lsa->data->options),
5173 VTY_NEWLINE);
5174 vty_out (vty, " LS Flags: 0x%-2x %s%s",
9d526037 5175 lsa->flags,
4957f494 5176 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
5177 VTY_NEWLINE);
718e3744 5178
5179 if (lsa->data->type == OSPF_ROUTER_LSA)
5180 {
5181 vty_out (vty, " Flags: 0x%x" , rlsa->flags);
5182
5183 if (rlsa->flags)
5184 vty_out (vty, " :%s%s%s%s",
5185 IS_ROUTER_LSA_BORDER (rlsa) ? " ABR" : "",
5186 IS_ROUTER_LSA_EXTERNAL (rlsa) ? " ASBR" : "",
5187 IS_ROUTER_LSA_VIRTUAL (rlsa) ? " VL-endpoint" : "",
5188 IS_ROUTER_LSA_SHORTCUT (rlsa) ? " Shortcut" : "");
5189
5190 vty_out (vty, "%s", VTY_NEWLINE);
5191 }
5192 vty_out (vty, " LS Type: %s%s",
5193 LOOKUP (ospf_lsa_type_msg, lsa->data->type), VTY_NEWLINE);
5194 vty_out (vty, " Link State ID: %s %s%s", inet_ntoa (lsa->data->id),
5195 LOOKUP (ospf_link_state_id_type_msg, lsa->data->type), VTY_NEWLINE);
5196 vty_out (vty, " Advertising Router: %s%s",
5197 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
5198 vty_out (vty, " LS Seq Number: %08lx%s", (u_long)ntohl (lsa->data->ls_seqnum),
5199 VTY_NEWLINE);
5200 vty_out (vty, " Checksum: 0x%04x%s", ntohs (lsa->data->checksum),
5201 VTY_NEWLINE);
5202 vty_out (vty, " Length: %d%s", ntohs (lsa->data->length), VTY_NEWLINE);
5203}
5204
eb1ce605 5205const char *link_type_desc[] =
718e3744 5206{
5207 "(null)",
5208 "another Router (point-to-point)",
5209 "a Transit Network",
5210 "Stub Network",
5211 "a Virtual Link",
5212};
5213
eb1ce605 5214const char *link_id_desc[] =
718e3744 5215{
5216 "(null)",
5217 "Neighboring Router ID",
5218 "Designated Router address",
68980084 5219 "Net",
718e3744 5220 "Neighboring Router ID",
5221};
5222
eb1ce605 5223const char *link_data_desc[] =
718e3744 5224{
5225 "(null)",
5226 "Router Interface address",
5227 "Router Interface address",
5228 "Network Mask",
5229 "Router Interface address",
5230};
5231
5232/* Show router-LSA each Link information. */
4dadc291 5233static void
718e3744 5234show_ip_ospf_database_router_links (struct vty *vty,
5235 struct router_lsa *rl)
5236{
b07c4cb3
DS
5237 int len, type;
5238 unsigned int i;
718e3744 5239
5240 len = ntohs (rl->header.length) - 4;
5241 for (i = 0; i < ntohs (rl->links) && len > 0; len -= 12, i++)
5242 {
5243 type = rl->link[i].type;
5244
5245 vty_out (vty, " Link connected to: %s%s",
5246 link_type_desc[type], VTY_NEWLINE);
5247 vty_out (vty, " (Link ID) %s: %s%s", link_id_desc[type],
5248 inet_ntoa (rl->link[i].link_id), VTY_NEWLINE);
5249 vty_out (vty, " (Link Data) %s: %s%s", link_data_desc[type],
5250 inet_ntoa (rl->link[i].link_data), VTY_NEWLINE);
5251 vty_out (vty, " Number of TOS metrics: 0%s", VTY_NEWLINE);
5252 vty_out (vty, " TOS 0 Metric: %d%s",
5253 ntohs (rl->link[i].metric), VTY_NEWLINE);
5254 vty_out (vty, "%s", VTY_NEWLINE);
5255 }
5256}
5257
5258/* Show router-LSA detail information. */
4dadc291 5259static int
718e3744 5260show_router_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
5261{
5262 if (lsa != NULL)
5263 {
5264 struct router_lsa *rl = (struct router_lsa *) lsa->data;
5265
5266 show_ip_ospf_database_header (vty, lsa);
5267
5268 vty_out (vty, " Number of Links: %d%s%s", ntohs (rl->links),
5269 VTY_NEWLINE, VTY_NEWLINE);
5270
5271 show_ip_ospf_database_router_links (vty, rl);
b0a053be 5272 vty_out (vty, "%s", VTY_NEWLINE);
718e3744 5273 }
5274
5275 return 0;
5276}
5277
5278/* Show network-LSA detail information. */
4dadc291 5279static int
718e3744 5280show_network_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
5281{
5282 int length, i;
5283
5284 if (lsa != NULL)
5285 {
5286 struct network_lsa *nl = (struct network_lsa *) lsa->data;
5287
5288 show_ip_ospf_database_header (vty, lsa);
5289
5290 vty_out (vty, " Network Mask: /%d%s",
5291 ip_masklen (nl->mask), VTY_NEWLINE);
5292
5293 length = ntohs (lsa->data->length) - OSPF_LSA_HEADER_SIZE - 4;
5294
5295 for (i = 0; length > 0; i++, length -= 4)
5296 vty_out (vty, " Attached Router: %s%s",
5297 inet_ntoa (nl->routers[i]), VTY_NEWLINE);
5298
5299 vty_out (vty, "%s", VTY_NEWLINE);
5300 }
5301
5302 return 0;
5303}
5304
5305/* Show summary-LSA detail information. */
4dadc291 5306static int
718e3744 5307show_summary_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
5308{
5309 if (lsa != NULL)
5310 {
5311 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
5312
5313 show_ip_ospf_database_header (vty, lsa);
5314
5315 vty_out (vty, " Network Mask: /%d%s", ip_masklen (sl->mask),
5316 VTY_NEWLINE);
5317 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
5318 VTY_NEWLINE);
b0a053be 5319 vty_out (vty, "%s", VTY_NEWLINE);
718e3744 5320 }
5321
5322 return 0;
5323}
5324
5325/* Show summary-ASBR-LSA detail information. */
4dadc291 5326static int
718e3744 5327show_summary_asbr_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
5328{
5329 if (lsa != NULL)
5330 {
5331 struct summary_lsa *sl = (struct summary_lsa *) lsa->data;
5332
5333 show_ip_ospf_database_header (vty, lsa);
5334
5335 vty_out (vty, " Network Mask: /%d%s",
5336 ip_masklen (sl->mask), VTY_NEWLINE);
5337 vty_out (vty, " TOS: 0 Metric: %d%s", GET_METRIC (sl->metric),
5338 VTY_NEWLINE);
b0a053be 5339 vty_out (vty, "%s", VTY_NEWLINE);
718e3744 5340 }
5341
5342 return 0;
5343}
5344
5345/* Show AS-external-LSA detail information. */
4dadc291 5346static int
718e3744 5347show_as_external_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
5348{
5349 if (lsa != NULL)
5350 {
5351 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
5352
5353 show_ip_ospf_database_header (vty, lsa);
5354
5355 vty_out (vty, " Network Mask: /%d%s",
5356 ip_masklen (al->mask), VTY_NEWLINE);
5357 vty_out (vty, " Metric Type: %s%s",
5358 IS_EXTERNAL_METRIC (al->e[0].tos) ?
5359 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
5360 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
5361 vty_out (vty, " Metric: %d%s",
5362 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
5363 vty_out (vty, " Forward Address: %s%s",
5364 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
5365
dc9ffce8
CF
5366 vty_out (vty, " External Route Tag: %"ROUTE_TAG_PRI"%s%s",
5367 (route_tag_t)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
718e3744 5368 }
5369
5370 return 0;
5371}
5372
075e12f5 5373#if 0
4dadc291 5374static int
718e3744 5375show_as_external_lsa_stdvty (struct ospf_lsa *lsa)
5376{
5377 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
5378
5379 /* show_ip_ospf_database_header (vty, lsa); */
5380
2a42e285 5381 zlog_debug( " Network Mask: /%d%s",
718e3744 5382 ip_masklen (al->mask), "\n");
2a42e285 5383 zlog_debug( " Metric Type: %s%s",
718e3744 5384 IS_EXTERNAL_METRIC (al->e[0].tos) ?
5385 "2 (Larger than any link state path)" : "1", "\n");
2a42e285 5386 zlog_debug( " TOS: 0%s", "\n");
5387 zlog_debug( " Metric: %d%s",
718e3744 5388 GET_METRIC (al->e[0].metric), "\n");
2a42e285 5389 zlog_debug( " Forward Address: %s%s",
718e3744 5390 inet_ntoa (al->e[0].fwd_addr), "\n");
5391
dc9ffce8
CF
5392 zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI"%s%s",
5393 (route_tag_t)ntohl (al->e[0].route_tag), "\n", "\n");
718e3744 5394
5395 return 0;
5396}
075e12f5 5397#endif
718e3744 5398
5399/* Show AS-NSSA-LSA detail information. */
4dadc291 5400static int
718e3744 5401show_as_nssa_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
5402{
5403 if (lsa != NULL)
5404 {
5405 struct as_external_lsa *al = (struct as_external_lsa *) lsa->data;
5406
5407 show_ip_ospf_database_header (vty, lsa);
5408
5409 vty_out (vty, " Network Mask: /%d%s",
5410 ip_masklen (al->mask), VTY_NEWLINE);
5411 vty_out (vty, " Metric Type: %s%s",
5412 IS_EXTERNAL_METRIC (al->e[0].tos) ?
5413 "2 (Larger than any link state path)" : "1", VTY_NEWLINE);
5414 vty_out (vty, " TOS: 0%s", VTY_NEWLINE);
5415 vty_out (vty, " Metric: %d%s",
5416 GET_METRIC (al->e[0].metric), VTY_NEWLINE);
5417 vty_out (vty, " NSSA: Forward Address: %s%s",
5418 inet_ntoa (al->e[0].fwd_addr), VTY_NEWLINE);
5419
dc9ffce8
CF
5420 vty_out (vty, " External Route Tag: %"ROUTE_TAG_PRI"%s%s",
5421 (route_tag_t)ntohl (al->e[0].route_tag), VTY_NEWLINE, VTY_NEWLINE);
718e3744 5422 }
5423
5424 return 0;
5425}
5426
4dadc291 5427static int
718e3744 5428show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
5429{
5430 return 0;
5431}
5432
4dadc291 5433static int
718e3744 5434show_opaque_lsa_detail (struct vty *vty, struct ospf_lsa *lsa)
5435{
5436 if (lsa != NULL)
5437 {
5438 show_ip_ospf_database_header (vty, lsa);
5439 show_opaque_info_detail (vty, lsa);
5440
5441 vty_out (vty, "%s", VTY_NEWLINE);
5442 }
5443 return 0;
5444}
718e3744 5445
5446int (*show_function[])(struct vty *, struct ospf_lsa *) =
5447{
5448 NULL,
5449 show_router_lsa_detail,
5450 show_network_lsa_detail,
5451 show_summary_lsa_detail,
5452 show_summary_asbr_lsa_detail,
5453 show_as_external_lsa_detail,
718e3744 5454 show_func_dummy,
5455 show_as_nssa_lsa_detail, /* almost same as external */
718e3744 5456 NULL, /* type-8 */
5457 show_opaque_lsa_detail,
5458 show_opaque_lsa_detail,
5459 show_opaque_lsa_detail,
718e3744 5460};
5461
4dadc291 5462static void
718e3744 5463show_lsa_prefix_set (struct vty *vty, struct prefix_ls *lp, struct in_addr *id,
5464 struct in_addr *adv_router)
5465{
5466 memset (lp, 0, sizeof (struct prefix_ls));
5467 lp->family = 0;
5468 if (id == NULL)
5469 lp->prefixlen = 0;
5470 else if (adv_router == NULL)
5471 {
5472 lp->prefixlen = 32;
5473 lp->id = *id;
5474 }
5475 else
5476 {
5477 lp->prefixlen = 64;
5478 lp->id = *id;
5479 lp->adv_router = *adv_router;
5480 }
5481}
5482
4dadc291 5483static void
718e3744 5484show_lsa_detail_proc (struct vty *vty, struct route_table *rt,
5485 struct in_addr *id, struct in_addr *adv_router)
5486{
5487 struct prefix_ls lp;
5488 struct route_node *rn, *start;
5489 struct ospf_lsa *lsa;
5490
5491 show_lsa_prefix_set (vty, &lp, id, adv_router);
5492 start = route_node_get (rt, (struct prefix *) &lp);
5493 if (start)
5494 {
5495 route_lock_node (start);
5496 for (rn = start; rn; rn = route_next_until (rn, start))
5497 if ((lsa = rn->info))
5498 {
718e3744 5499 if (show_function[lsa->data->type] != NULL)
5500 show_function[lsa->data->type] (vty, lsa);
5501 }
5502 route_unlock_node (start);
5503 }
5504}
5505
5506/* Show detail LSA information
5507 -- if id is NULL then show all LSAs. */
4dadc291 5508static void
020709f9 5509show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
718e3744 5510 struct in_addr *id, struct in_addr *adv_router)
5511{
52dc7ee6 5512 struct listnode *node;
1eb8ef25 5513 struct ospf_area *area;
5514
718e3744 5515 switch (type)
5516 {
5517 case OSPF_AS_EXTERNAL_LSA:
718e3744 5518 case OSPF_OPAQUE_AS_LSA:
718e3744 5519 vty_out (vty, " %s %s%s",
5520 show_database_desc[type],
5521 VTY_NEWLINE, VTY_NEWLINE);
68980084 5522 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
718e3744 5523 break;
5524 default:
1eb8ef25 5525 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
718e3744 5526 {
718e3744 5527 vty_out (vty, "%s %s (Area %s)%s%s",
5528 VTY_NEWLINE, show_database_desc[type],
5529 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
5530 show_lsa_detail_proc (vty, AREA_LSDB (area, type), id, adv_router);
5531 }
5532 break;
5533 }
5534}
5535
4dadc291 5536static void
718e3744 5537show_lsa_detail_adv_router_proc (struct vty *vty, struct route_table *rt,
5538 struct in_addr *adv_router)
5539{
5540 struct route_node *rn;
5541 struct ospf_lsa *lsa;
5542
5543 for (rn = route_top (rt); rn; rn = route_next (rn))
5544 if ((lsa = rn->info))
5545 if (IPV4_ADDR_SAME (adv_router, &lsa->data->adv_router))
5546 {
718e3744 5547 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
5548 continue;
718e3744 5549 if (show_function[lsa->data->type] != NULL)
5550 show_function[lsa->data->type] (vty, lsa);
5551 }
5552}
5553
5554/* Show detail LSA information. */
4dadc291 5555static void
020709f9 5556show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
718e3744 5557 struct in_addr *adv_router)
5558{
52dc7ee6 5559 struct listnode *node;
1eb8ef25 5560 struct ospf_area *area;
718e3744 5561
5562 switch (type)
5563 {
5564 case OSPF_AS_EXTERNAL_LSA:
718e3744 5565 case OSPF_OPAQUE_AS_LSA:
718e3744 5566 vty_out (vty, " %s %s%s",
5567 show_database_desc[type],
5568 VTY_NEWLINE, VTY_NEWLINE);
68980084 5569 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
718e3744 5570 adv_router);
5571 break;
5572 default:
1eb8ef25 5573 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
718e3744 5574 {
718e3744 5575 vty_out (vty, "%s %s (Area %s)%s%s",
5576 VTY_NEWLINE, show_database_desc[type],
5577 ospf_area_desc_string (area), VTY_NEWLINE, VTY_NEWLINE);
5578 show_lsa_detail_adv_router_proc (vty, AREA_LSDB (area, type),
5579 adv_router);
5580 }
5581 break;
5582 }
5583}
5584
4dadc291 5585static void
020709f9 5586show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
718e3744 5587{
020709f9 5588 struct ospf_lsa *lsa;
5589 struct route_node *rn;
1eb8ef25 5590 struct ospf_area *area;
52dc7ee6 5591 struct listnode *node;
718e3744 5592 int type;
5593
1eb8ef25 5594 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
718e3744 5595 {
718e3744 5596 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
5597 {
5598 switch (type)
5599 {
5600 case OSPF_AS_EXTERNAL_LSA:
718e3744 5601 case OSPF_OPAQUE_AS_LSA:
718e3744 5602 continue;
5603 default:
5604 break;
5605 }
5606 if (ospf_lsdb_count_self (area->lsdb, type) > 0 ||
5607 (!self && ospf_lsdb_count (area->lsdb, type) > 0))
5608 {
5609 vty_out (vty, " %s (Area %s)%s%s",
5610 show_database_desc[type],
5611 ospf_area_desc_string (area),
5612 VTY_NEWLINE, VTY_NEWLINE);
5613 vty_out (vty, "%s%s", show_database_header[type], VTY_NEWLINE);
5614
020709f9 5615 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
5616 show_lsa_summary (vty, lsa, self);
718e3744 5617
5618 vty_out (vty, "%s", VTY_NEWLINE);
5619 }
5620 }
5621 }
5622
5623 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
5624 {
5625 switch (type)
5626 {
5627 case OSPF_AS_EXTERNAL_LSA:
718e3744 5628 case OSPF_OPAQUE_AS_LSA:
e8e1946e 5629 break;
718e3744 5630 default:
5631 continue;
5632 }
68980084 5633 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
5634 (!self && ospf_lsdb_count (ospf->lsdb, type)))
718e3744 5635 {
5636 vty_out (vty, " %s%s%s",
5637 show_database_desc[type],
5638 VTY_NEWLINE, VTY_NEWLINE);
5639 vty_out (vty, "%s%s", show_database_header[type],
5640 VTY_NEWLINE);
020709f9 5641
5642 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
5643 show_lsa_summary (vty, lsa, self);
5644
718e3744 5645 vty_out (vty, "%s", VTY_NEWLINE);
5646 }
5647 }
5648
5649 vty_out (vty, "%s", VTY_NEWLINE);
5650}
5651
4dadc291 5652static void
020709f9 5653show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
718e3744 5654{
91e6a0e5 5655 struct route_node *rn;
718e3744 5656
5657 vty_out (vty, "%s MaxAge Link States:%s%s",
5658 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
5659
91e6a0e5 5660 for (rn = route_top (ospf->maxage_lsa); rn; rn = route_next (rn))
1eb8ef25 5661 {
91e6a0e5
DD
5662 struct ospf_lsa *lsa;
5663
5664 if ((lsa = rn->info) != NULL)
5665 {
5666 vty_out (vty, "Link type: %d%s", lsa->data->type, VTY_NEWLINE);
5667 vty_out (vty, "Link State ID: %s%s",
5668 inet_ntoa (lsa->data->id), VTY_NEWLINE);
5669 vty_out (vty, "Advertising Router: %s%s",
5670 inet_ntoa (lsa->data->adv_router), VTY_NEWLINE);
5671 vty_out (vty, "LSA lock count: %d%s", lsa->lock, VTY_NEWLINE);
5672 vty_out (vty, "%s", VTY_NEWLINE);
5673 }
1eb8ef25 5674 }
718e3744 5675}
5676
718e3744 5677#define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
5678#define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
718e3744 5679
718e3744 5680#define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
5681#define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
5682#define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
5683#define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
718e3744 5684
5685#define OSPF_LSA_TYPES_CMD_STR \
5686 "asbr-summary|external|network|router|summary" \
5687 OSPF_LSA_TYPE_NSSA_CMD_STR \
5688 OSPF_LSA_TYPE_OPAQUE_CMD_STR
5689
5690#define OSPF_LSA_TYPES_DESC \
5691 "ASBR summary link states\n" \
5692 "External link states\n" \
5693 "Network link states\n" \
5694 "Router link states\n" \
5695 "Network summary link states\n" \
5696 OSPF_LSA_TYPE_NSSA_DESC \
5697 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
5698 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
5699 OSPF_LSA_TYPE_OPAQUE_AS_DESC
5700
7c8ff89e
DS
5701static int
5702show_ip_ospf_database_common (struct vty *vty, struct ospf *ospf,
5703 int arg_base, int argc, const char **argv)
718e3744 5704{
5705 int type, ret;
5706 struct in_addr id, adv_router;
5707
7c8ff89e
DS
5708 if (ospf->instance)
5709 vty_out (vty, "%sOSPF Instance: %d%s", VTY_NEWLINE, ospf->instance,
5710 VTY_NEWLINE);
718e3744 5711
5712 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
68980084 5713 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
718e3744 5714
5715 /* Show all LSA. */
7c8ff89e 5716 if (argc == arg_base + 0)
718e3744 5717 {
020709f9 5718 show_ip_ospf_database_summary (vty, ospf, 0);
718e3744 5719 return CMD_SUCCESS;
5720 }
5721
5722 /* Set database type to show. */
7c8ff89e 5723 if (strncmp (argv[arg_base + 0], "r", 1) == 0)
718e3744 5724 type = OSPF_ROUTER_LSA;
7c8ff89e 5725 else if (strncmp (argv[arg_base + 0], "ne", 2) == 0)
718e3744 5726 type = OSPF_NETWORK_LSA;
7c8ff89e 5727 else if (strncmp (argv[arg_base + 0], "ns", 2) == 0)
718e3744 5728 type = OSPF_AS_NSSA_LSA;
7c8ff89e 5729 else if (strncmp (argv[arg_base + 0], "su", 2) == 0)
718e3744 5730 type = OSPF_SUMMARY_LSA;
7c8ff89e 5731 else if (strncmp (argv[arg_base + 0], "a", 1) == 0)
718e3744 5732 type = OSPF_ASBR_SUMMARY_LSA;
7c8ff89e 5733 else if (strncmp (argv[arg_base + 0], "e", 1) == 0)
718e3744 5734 type = OSPF_AS_EXTERNAL_LSA;
7c8ff89e 5735 else if (strncmp (argv[arg_base + 0], "se", 2) == 0)
718e3744 5736 {
020709f9 5737 show_ip_ospf_database_summary (vty, ospf, 1);
718e3744 5738 return CMD_SUCCESS;
5739 }
7c8ff89e 5740 else if (strncmp (argv[arg_base + 0], "m", 1) == 0)
718e3744 5741 {
020709f9 5742 show_ip_ospf_database_maxage (vty, ospf);
718e3744 5743 return CMD_SUCCESS;
5744 }
7c8ff89e 5745 else if (strncmp (argv[arg_base + 0], "opaque-l", 8) == 0)
718e3744 5746 type = OSPF_OPAQUE_LINK_LSA;
7c8ff89e 5747 else if (strncmp (argv[arg_base + 0], "opaque-ar", 9) == 0)
718e3744 5748 type = OSPF_OPAQUE_AREA_LSA;
7c8ff89e 5749 else if (strncmp (argv[arg_base + 0], "opaque-as", 9) == 0)
718e3744 5750 type = OSPF_OPAQUE_AS_LSA;
718e3744 5751 else
5752 return CMD_WARNING;
5753
5754 /* `show ip ospf database LSA'. */
7c8ff89e 5755 if (argc == arg_base + 1)
020709f9 5756 show_lsa_detail (vty, ospf, type, NULL, NULL);
7c8ff89e 5757 else if (argc >= arg_base + 2)
718e3744 5758 {
7c8ff89e 5759 ret = inet_aton (argv[arg_base + 1], &id);
718e3744 5760 if (!ret)
5761 return CMD_WARNING;
5762
5763 /* `show ip ospf database LSA ID'. */
7c8ff89e 5764 if (argc == arg_base + 2)
020709f9 5765 show_lsa_detail (vty, ospf, type, &id, NULL);
718e3744 5766 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
7c8ff89e 5767 else if (argc == arg_base + 3)
718e3744 5768 {
7c8ff89e 5769 if (strncmp (argv[arg_base + 2], "s", 1) == 0)
68980084 5770 adv_router = ospf->router_id;
718e3744 5771 else
5772 {
7c8ff89e 5773 ret = inet_aton (argv[arg_base + 2], &adv_router);
718e3744 5774 if (!ret)
5775 return CMD_WARNING;
5776 }
020709f9 5777 show_lsa_detail (vty, ospf, type, &id, &adv_router);
718e3744 5778 }
5779 }
5780
5781 return CMD_SUCCESS;
5782}
5783
7c8ff89e
DS
5784DEFUN (show_ip_ospf_database,
5785 show_ip_ospf_database_cmd,
5786 "show ip ospf database",
5787 SHOW_STR
5788 IP_STR
5789 "OSPF information\n"
5790 "Database summary\n")
5791{
5792 struct ospf *ospf;
5793
0bad4851 5794 if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running)
7c8ff89e
DS
5795 return CMD_SUCCESS;
5796
5797 return (show_ip_ospf_database_common(vty, ospf, 0, argc, argv));
5798}
5799
718e3744 5800ALIAS (show_ip_ospf_database,
5801 show_ip_ospf_database_type_cmd,
5802 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
5803 SHOW_STR
5804 IP_STR
5805 "OSPF information\n"
5806 "Database summary\n"
5807 OSPF_LSA_TYPES_DESC
5808 "LSAs in MaxAge list\n"
5809 "Self-originated link states\n")
5810
5811ALIAS (show_ip_ospf_database,
5812 show_ip_ospf_database_type_id_cmd,
5813 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
5814 SHOW_STR
5815 IP_STR
5816 "OSPF information\n"
5817 "Database summary\n"
5818 OSPF_LSA_TYPES_DESC
5819 "Link State ID (as an IP address)\n")
5820
5821ALIAS (show_ip_ospf_database,
5822 show_ip_ospf_database_type_id_adv_router_cmd,
5823 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
5824 SHOW_STR
5825 IP_STR
5826 "OSPF information\n"
5827 "Database summary\n"
5828 OSPF_LSA_TYPES_DESC
5829 "Link State ID (as an IP address)\n"
5830 "Advertising Router link states\n"
5831 "Advertising Router (as an IP address)\n")
5832
5833ALIAS (show_ip_ospf_database,
5834 show_ip_ospf_database_type_id_self_cmd,
5835 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
5836 SHOW_STR
5837 IP_STR
5838 "OSPF information\n"
5839 "Database summary\n"
5840 OSPF_LSA_TYPES_DESC
5841 "Link State ID (as an IP address)\n"
5842 "Self-originated link states\n"
5843 "\n")
5844
7c8ff89e
DS
5845DEFUN (show_ip_ospf_instance_database,
5846 show_ip_ospf_instance_database_cmd,
5847 "show ip ospf <1-65535> database",
718e3744 5848 SHOW_STR
5849 IP_STR
5850 "OSPF information\n"
7c8ff89e
DS
5851 "Instance ID\n"
5852 "Database summary\n")
5853{
5854 struct ospf *ospf;
5855 u_short instance = 0;
5856
5857 VTY_GET_INTEGER ("Instance", instance, argv[0]);
5858
0bad4851 5859 if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running)
7c8ff89e
DS
5860 return CMD_SUCCESS;
5861
5862 return (show_ip_ospf_database_common(vty, ospf, 1, argc, argv));
5863}
5864
5865ALIAS (show_ip_ospf_instance_database,
5866 show_ip_ospf_instance_database_type_cmd,
5867 "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR "|max-age|self-originate)",
5868 SHOW_STR
5869 IP_STR
5870 "OSPF information\n"
5871 "Instance ID\n"
5872 "Database summary\n"
5873 OSPF_LSA_TYPES_DESC
5874 "LSAs in MaxAge list\n"
5875 "Self-originated link states\n")
5876
5877ALIAS (show_ip_ospf_instance_database,
5878 show_ip_ospf_instance_database_type_id_cmd,
5879 "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D",
5880 SHOW_STR
5881 IP_STR
5882 "OSPF information\n"
5883 "Instance ID\n"
5884 "Database summary\n"
5885 OSPF_LSA_TYPES_DESC
5886 "Link State ID (as an IP address)\n")
5887
5888ALIAS (show_ip_ospf_instance_database,
5889 show_ip_ospf_instance_database_type_id_adv_router_cmd,
5890 "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D adv-router A.B.C.D",
5891 SHOW_STR
5892 IP_STR
5893 "OSPF information\n"
5894 "Instance ID\n"
718e3744 5895 "Database summary\n"
5896 OSPF_LSA_TYPES_DESC
7c8ff89e 5897 "Link State ID (as an IP address)\n"
718e3744 5898 "Advertising Router link states\n"
5899 "Advertising Router (as an IP address)\n")
7c8ff89e
DS
5900
5901ALIAS (show_ip_ospf_instance_database,
5902 show_ip_ospf_instance_database_type_id_self_cmd,
5903 "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") A.B.C.D (self-originate|)",
5904 SHOW_STR
5905 IP_STR
5906 "OSPF information\n"
5907 "Instance ID\n"
5908 "Database summary\n"
5909 OSPF_LSA_TYPES_DESC
5910 "Link State ID (as an IP address)\n"
5911 "Self-originated link states\n"
5912 "\n")
5913
5914
5915static int
5916show_ip_ospf_database_type_adv_router_common (struct vty *vty, struct ospf *ospf,
5917 int arg_base, int argc, const char **argv)
718e3744 5918{
5919 int type, ret;
5920 struct in_addr adv_router;
5921
7c8ff89e
DS
5922 if (ospf->instance)
5923 vty_out (vty, "%sOSPF Instance: %d%s", VTY_NEWLINE, ospf->instance,
5924 VTY_NEWLINE);
718e3744 5925
5926 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
68980084 5927 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
718e3744 5928
7c8ff89e 5929 if (argc != arg_base + 2)
718e3744 5930 return CMD_WARNING;
5931
5932 /* Set database type to show. */
7c8ff89e 5933 if (strncmp (argv[arg_base + 0], "r", 1) == 0)
718e3744 5934 type = OSPF_ROUTER_LSA;
7c8ff89e 5935 else if (strncmp (argv[arg_base + 0], "ne", 2) == 0)
718e3744 5936 type = OSPF_NETWORK_LSA;
7c8ff89e 5937 else if (strncmp (argv[arg_base + 0], "ns", 2) == 0)
718e3744 5938 type = OSPF_AS_NSSA_LSA;
7c8ff89e 5939 else if (strncmp (argv[arg_base + 0], "s", 1) == 0)
718e3744 5940 type = OSPF_SUMMARY_LSA;
7c8ff89e 5941 else if (strncmp (argv[arg_base + 0], "a", 1) == 0)
718e3744 5942 type = OSPF_ASBR_SUMMARY_LSA;
7c8ff89e 5943 else if (strncmp (argv[arg_base + 0], "e", 1) == 0)
718e3744 5944 type = OSPF_AS_EXTERNAL_LSA;
7c8ff89e 5945 else if (strncmp (argv[arg_base + 0], "opaque-l", 8) == 0)
718e3744 5946 type = OSPF_OPAQUE_LINK_LSA;
7c8ff89e 5947 else if (strncmp (argv[arg_base + 0], "opaque-ar", 9) == 0)
718e3744 5948 type = OSPF_OPAQUE_AREA_LSA;
7c8ff89e 5949 else if (strncmp (argv[arg_base + 0], "opaque-as", 9) == 0)
718e3744 5950 type = OSPF_OPAQUE_AS_LSA;
718e3744 5951 else
5952 return CMD_WARNING;
5953
7c8ff89e
DS
5954 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
5955 if (strncmp (argv[arg_base + 1], "s", 1) == 0)
5956 adv_router = ospf->router_id;
5957 else
5958 {
5959 ret = inet_aton (argv[arg_base + 1], &adv_router);
5960 if (!ret)
5961 return CMD_WARNING;
5962 }
5963
5964 show_lsa_detail_adv_router (vty, ospf, type, &adv_router);
5965
5966 return CMD_SUCCESS;
5967}
5968
5969DEFUN (show_ip_ospf_database_type_adv_router,
5970 show_ip_ospf_database_type_adv_router_cmd,
5971 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
5972 SHOW_STR
5973 IP_STR
5974 "OSPF information\n"
5975 "Database summary\n"
5976 OSPF_LSA_TYPES_DESC
5977 "Advertising Router link states\n"
5978 "Advertising Router (as an IP address)\n")
5979{
5980 struct ospf *ospf;
5981
0bad4851 5982 if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running)
7c8ff89e
DS
5983 return CMD_SUCCESS;
5984
5985 return (show_ip_ospf_database_type_adv_router_common(vty, ospf, 0, argc, argv));
5986}
5987
5988ALIAS (show_ip_ospf_database_type_adv_router,
5989 show_ip_ospf_database_type_self_cmd,
5990 "show ip ospf database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
5991 SHOW_STR
5992 IP_STR
5993 "OSPF information\n"
5994 "Database summary\n"
5995 OSPF_LSA_TYPES_DESC
5996 "Self-originated link states\n")
5997
5998DEFUN (show_ip_ospf_instance_database_type_adv_router,
5999 show_ip_ospf_instance_database_type_adv_router_cmd,
6000 "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") adv-router A.B.C.D",
6001 SHOW_STR
6002 IP_STR
6003 "OSPF information\n"
6004 "Instance ID\n"
6005 "Database summary\n"
6006 OSPF_LSA_TYPES_DESC
6007 "Advertising Router link states\n"
6008 "Advertising Router (as an IP address)\n")
6009{
6010 struct ospf *ospf;
6011 u_short instance = 0;
6012
6013 VTY_GET_INTEGER ("Instance", instance, argv[0]);
718e3744 6014
0bad4851 6015 if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running)
7c8ff89e 6016 return CMD_SUCCESS;
718e3744 6017
7c8ff89e 6018 return (show_ip_ospf_database_type_adv_router_common(vty, ospf, 1, argc, argv));
718e3744 6019}
6020
7c8ff89e
DS
6021ALIAS (show_ip_ospf_instance_database_type_adv_router,
6022 show_ip_ospf_instance_database_type_self_cmd,
6023 "show ip ospf <1-65535> database (" OSPF_LSA_TYPES_CMD_STR ") (self-originate|)",
718e3744 6024 SHOW_STR
6025 IP_STR
6026 "OSPF information\n"
7c8ff89e 6027 "Instance ID\n"
718e3744 6028 "Database summary\n"
6029 OSPF_LSA_TYPES_DESC
6030 "Self-originated link states\n")
6031
718e3744 6032DEFUN (ip_ospf_authentication_args,
6033 ip_ospf_authentication_args_addr_cmd,
6034 "ip ospf authentication (null|message-digest) A.B.C.D",
6035 "IP Information\n"
6036 "OSPF interface commands\n"
6037 "Enable authentication on this interface\n"
6038 "Use null authentication\n"
6039 "Use message-digest authentication\n"
6040 "Address of interface")
6041{
6042 struct interface *ifp;
6043 struct in_addr addr;
6044 int ret;
6045 struct ospf_if_params *params;
6046
6047 ifp = vty->index;
6048 params = IF_DEF_PARAMS (ifp);
6049
6050 if (argc == 2)
6051 {
6052 ret = inet_aton(argv[1], &addr);
6053 if (!ret)
6054 {
6055 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6056 VTY_NEWLINE);
6057 return CMD_WARNING;
6058 }
6059
6060 params = ospf_get_if_params (ifp, addr);
6061 ospf_if_update_params (ifp, addr);
6062 }
6063
6064 /* Handle null authentication */
6065 if ( argv[0][0] == 'n' )
6066 {
6067 SET_IF_PARAM (params, auth_type);
6068 params->auth_type = OSPF_AUTH_NULL;
6069 return CMD_SUCCESS;
6070 }
6071
6072 /* Handle message-digest authentication */
6073 if ( argv[0][0] == 'm' )
6074 {
6075 SET_IF_PARAM (params, auth_type);
6076 params->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
6077 return CMD_SUCCESS;
6078 }
6079
6080 vty_out (vty, "You shouldn't get here!%s", VTY_NEWLINE);
6081 return CMD_WARNING;
6082}
6083
6084ALIAS (ip_ospf_authentication_args,
6085 ip_ospf_authentication_args_cmd,
6086 "ip ospf authentication (null|message-digest)",
6087 "IP Information\n"
6088 "OSPF interface commands\n"
6089 "Enable authentication on this interface\n"
6090 "Use null authentication\n"
6091 "Use message-digest authentication\n")
6092
6093DEFUN (ip_ospf_authentication,
6094 ip_ospf_authentication_addr_cmd,
6095 "ip ospf authentication A.B.C.D",
6096 "IP Information\n"
6097 "OSPF interface commands\n"
6098 "Enable authentication on this interface\n"
6099 "Address of interface")
6100{
6101 struct interface *ifp;
6102 struct in_addr addr;
6103 int ret;
6104 struct ospf_if_params *params;
6105
6106 ifp = vty->index;
6107 params = IF_DEF_PARAMS (ifp);
6108
6109 if (argc == 1)
6110 {
5dcf71df 6111 ret = inet_aton(argv[0], &addr);
718e3744 6112 if (!ret)
6113 {
6114 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6115 VTY_NEWLINE);
6116 return CMD_WARNING;
6117 }
6118
6119 params = ospf_get_if_params (ifp, addr);
6120 ospf_if_update_params (ifp, addr);
6121 }
6122
6123 SET_IF_PARAM (params, auth_type);
6124 params->auth_type = OSPF_AUTH_SIMPLE;
6125
6126 return CMD_SUCCESS;
6127}
6128
6129ALIAS (ip_ospf_authentication,
6130 ip_ospf_authentication_cmd,
6131 "ip ospf authentication",
6132 "IP Information\n"
6133 "OSPF interface commands\n"
6134 "Enable authentication on this interface\n")
6135
b4a039bf
DS
6136DEFUN (no_ip_ospf_authentication_args,
6137 no_ip_ospf_authentication_args_addr_cmd,
6138 "no ip ospf authentication (null|message-digest) A.B.C.D",
6139 NO_STR
6140 "IP Information\n"
6141 "OSPF interface commands\n"
6142 "Enable authentication on this interface\n"
6143 "Use null authentication\n"
6144 "Use message-digest authentication\n"
6145 "Address of interface")
6146{
6147 struct interface *ifp;
6148 struct in_addr addr;
6149 int ret;
6150 struct ospf_if_params *params;
6151 struct route_node *rn;
6152 int auth_type;
6153
6154 ifp = vty->index;
6155 params = IF_DEF_PARAMS (ifp);
6156
6157 if (argc == 2)
6158 {
6159 ret = inet_aton(argv[1], &addr);
6160 if (!ret)
6161 {
6162 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6163 VTY_NEWLINE);
6164 return CMD_WARNING;
6165 }
6166
6167 params = ospf_lookup_if_params (ifp, addr);
6168 if (params == NULL)
6169 {
6170 vty_out (vty, "Ip Address specified is unknown%s", VTY_NEWLINE);
6171 return CMD_WARNING;
6172 }
6173 params->auth_type = OSPF_AUTH_NOTSET;
6174 UNSET_IF_PARAM (params, auth_type);
6175 if (params != IF_DEF_PARAMS (ifp))
6176 {
6177 ospf_free_if_params (ifp, addr);
6178 ospf_if_update_params (ifp, addr);
6179 }
6180 }
6181 else
6182 {
6183 if ( argv[0][0] == 'n' )
6184 {
6185 auth_type = OSPF_AUTH_NULL;
6186 }
6187 else if ( argv[0][0] == 'm' )
6188 {
6189 auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
6190 }
6191 else
6192 {
6193 vty_out (vty, "Unexpected input encountered%s", VTY_NEWLINE);
6194 return CMD_WARNING;
6195 }
6196 /*
6197 * Here we have a case where the user has entered
6198 * 'no ip ospf authentication (null | message_digest )'
6199 * we need to find if we have any ip addresses underneath it that
6200 * correspond to the associated type.
6201 */
813d4307
DW
6202 if (params->auth_type == auth_type)
6203 {
6204 params->auth_type = OSPF_AUTH_NOTSET;
6205 UNSET_IF_PARAM (params, auth_type);
6206 }
6207
b4a039bf
DS
6208 for (rn = route_top (IF_OIFS_PARAMS (ifp)); rn; rn = route_next (rn))
6209 {
6210 if ((params = rn->info))
6211 {
6212 if (params->auth_type == auth_type)
6213 {
6214 params->auth_type = OSPF_AUTH_NOTSET;
6215 UNSET_IF_PARAM (params, auth_type);
6216 if (params != IF_DEF_PARAMS (ifp))
6217 {
6218 ospf_free_if_params (ifp, rn->p.u.prefix4);
6219 ospf_if_update_params(ifp, rn->p.u.prefix4);
6220 }
6221 }
6222 }
6223 }
6224 }
6225
6226 return CMD_SUCCESS;
6227}
6228
6229ALIAS (no_ip_ospf_authentication_args,
6230 no_ip_ospf_authentication_args_cmd,
6231 "no ip ospf authentication (null|message-digest)",
6232 NO_STR
6233 "IP Information\n"
6234 "OSPF interface commands\n"
6235 "Enable authentication on this interface\n"
6236 "Use null authentication\n"
6237 "Use message-digest authentication\n")
6238
718e3744 6239DEFUN (no_ip_ospf_authentication,
6240 no_ip_ospf_authentication_addr_cmd,
6241 "no ip ospf authentication A.B.C.D",
6242 NO_STR
6243 "IP Information\n"
6244 "OSPF interface commands\n"
6245 "Enable authentication on this interface\n"
6246 "Address of interface")
6247{
6248 struct interface *ifp;
6249 struct in_addr addr;
6250 int ret;
6251 struct ospf_if_params *params;
b4a039bf
DS
6252 struct route_node *rn;
6253
718e3744 6254 ifp = vty->index;
6255 params = IF_DEF_PARAMS (ifp);
6256
6257 if (argc == 1)
6258 {
5dcf71df 6259 ret = inet_aton(argv[0], &addr);
718e3744 6260 if (!ret)
6261 {
6262 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6263 VTY_NEWLINE);
6264 return CMD_WARNING;
6265 }
6266
6267 params = ospf_lookup_if_params (ifp, addr);
6268 if (params == NULL)
b4a039bf
DS
6269 {
6270 vty_out (vty, "Ip Address specified is unknown%s", VTY_NEWLINE);
6271 return CMD_WARNING;
6272 }
718e3744 6273
b4a039bf
DS
6274 params->auth_type = OSPF_AUTH_NOTSET;
6275 UNSET_IF_PARAM (params, auth_type);
6276 if (params != IF_DEF_PARAMS (ifp))
6277 {
6278 ospf_free_if_params (ifp, addr);
6279 ospf_if_update_params (ifp, addr);
6280 }
6281 }
6282 else
718e3744 6283 {
b4a039bf
DS
6284 /*
6285 * When a user enters 'no ip ospf authentication'
6286 * We should remove all authentication types from
6287 * the interface.
6288 */
813d4307
DW
6289 if ((params->auth_type == OSPF_AUTH_NULL) ||
6290 (params->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) ||
6291 (params->auth_type == OSPF_AUTH_SIMPLE))
6292 {
6293 params->auth_type = OSPF_AUTH_NOTSET;
6294 UNSET_IF_PARAM (params, auth_type);
6295 }
6296
b4a039bf
DS
6297 for (rn = route_top (IF_OIFS_PARAMS (ifp)); rn; rn = route_next (rn))
6298 {
6299 if ((params = rn->info))
6300 {
813d4307 6301
b4a039bf
DS
6302 if ((params->auth_type == OSPF_AUTH_NULL) ||
6303 (params->auth_type == OSPF_AUTH_CRYPTOGRAPHIC) ||
6304 (params->auth_type == OSPF_AUTH_SIMPLE))
6305 {
6306 params->auth_type = OSPF_AUTH_NOTSET;
6307 UNSET_IF_PARAM (params, auth_type);
6308 if (params != IF_DEF_PARAMS (ifp))
6309 {
6310 ospf_free_if_params (ifp, rn->p.u.prefix4);
6311 ospf_if_update_params(ifp, rn->p.u.prefix4);
6312 }
6313 }
6314 }
6315 }
718e3744 6316 }
6317
6318 return CMD_SUCCESS;
6319}
6320
6321ALIAS (no_ip_ospf_authentication,
6322 no_ip_ospf_authentication_cmd,
6323 "no ip ospf authentication",
6324 NO_STR
6325 "IP Information\n"
6326 "OSPF interface commands\n"
6327 "Enable authentication on this interface\n")
6328
6329DEFUN (ip_ospf_authentication_key,
6330 ip_ospf_authentication_key_addr_cmd,
6331 "ip ospf authentication-key AUTH_KEY A.B.C.D",
6332 "IP Information\n"
6333 "OSPF interface commands\n"
6334 "Authentication password (key)\n"
6335 "The OSPF password (key)\n"
6336 "Address of interface")
6337{
6338 struct interface *ifp;
6339 struct in_addr addr;
6340 int ret;
6341 struct ospf_if_params *params;
6342
6343 ifp = vty->index;
6344 params = IF_DEF_PARAMS (ifp);
6345
6346 if (argc == 2)
6347 {
6348 ret = inet_aton(argv[1], &addr);
6349 if (!ret)
6350 {
6351 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6352 VTY_NEWLINE);
6353 return CMD_WARNING;
6354 }
6355
6356 params = ospf_get_if_params (ifp, addr);
6357 ospf_if_update_params (ifp, addr);
6358 }
6359
718e3744 6360 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
c9e52be3 6361 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
718e3744 6362 SET_IF_PARAM (params, auth_simple);
6363
6364 return CMD_SUCCESS;
6365}
6366
6367ALIAS (ip_ospf_authentication_key,
6368 ip_ospf_authentication_key_cmd,
6369 "ip ospf authentication-key AUTH_KEY",
6370 "IP Information\n"
6371 "OSPF interface commands\n"
6372 "Authentication password (key)\n"
6373 "The OSPF password (key)")
6374
747e489c
DW
6375ALIAS_HIDDEN (ip_ospf_authentication_key,
6376 ospf_authentication_key_cmd,
6377 "ospf authentication-key AUTH_KEY",
6378 "OSPF interface commands\n"
6379 "Authentication password (key)\n"
6380 "The OSPF password (key)")
718e3744 6381
6382DEFUN (no_ip_ospf_authentication_key,
813d4307
DW
6383 no_ip_ospf_authentication_key_authkey_addr_cmd,
6384 "no ip ospf authentication-key AUTH_KEY A.B.C.D",
718e3744 6385 NO_STR
6386 "IP Information\n"
6387 "OSPF interface commands\n"
6388 "Authentication password (key)\n"
813d4307 6389 "The OSPF password (key)")
718e3744 6390{
6391 struct interface *ifp;
6392 struct in_addr addr;
718e3744 6393 struct ospf_if_params *params;
813d4307 6394 int ret;
718e3744 6395
6396 ifp = vty->index;
6397 params = IF_DEF_PARAMS (ifp);
6398
813d4307 6399 if (argc == 2)
718e3744 6400 {
813d4307 6401 ret = inet_aton(argv[1], &addr);
718e3744 6402 if (!ret)
6403 {
6404 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6405 VTY_NEWLINE);
6406 return CMD_WARNING;
6407 }
6408
6409 params = ospf_lookup_if_params (ifp, addr);
6410 if (params == NULL)
6411 return CMD_SUCCESS;
6412 }
6413
6414 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE);
6415 UNSET_IF_PARAM (params, auth_simple);
6416
6417 if (params != IF_DEF_PARAMS (ifp))
6418 {
6419 ospf_free_if_params (ifp, addr);
6420 ospf_if_update_params (ifp, addr);
6421 }
6422
6423 return CMD_SUCCESS;
6424}
6425
813d4307
DW
6426ALIAS (no_ip_ospf_authentication_key,
6427 no_ip_ospf_authentication_key_authkey_cmd,
6428 "no ip ospf authentication-key AUTH_KEY",
6429 NO_STR
6430 "IP Information\n"
6431 "OSPF interface commands\n"
6432 "Authentication password (key)\n")
6433
718e3744 6434ALIAS (no_ip_ospf_authentication_key,
6435 no_ip_ospf_authentication_key_cmd,
6436 "no ip ospf authentication-key",
6437 NO_STR
6438 "IP Information\n"
6439 "OSPF interface commands\n"
6440 "Authentication password (key)\n")
6441
6442ALIAS (no_ip_ospf_authentication_key,
6443 no_ospf_authentication_key_cmd,
6444 "no ospf authentication-key",
6445 NO_STR
6446 "OSPF interface commands\n"
6447 "Authentication password (key)\n")
6448
813d4307
DW
6449ALIAS (no_ip_ospf_authentication_key,
6450 no_ospf_authentication_key_authkey_cmd,
6451 "no ospf authentication-key AUTH_KEY",
6452 NO_STR
6453 "OSPF interface commands\n"
6454 "Authentication password (key)\n"
6455 "The OSPF password (key)\n")
6456
6457ALIAS (no_ip_ospf_authentication_key,
6458 no_ospf_authentication_key_authkey_ip_cmd,
6459 "no ospf authentication-key AUTH_KEY A.B.C.D",
6460 NO_STR
6461 "OSPF interface commands\n"
6462 "Authentication password (key)\n"
6463 "The OSPF password (key)\n"
6464 "Address of interface")
6465
718e3744 6466DEFUN (ip_ospf_message_digest_key,
6467 ip_ospf_message_digest_key_addr_cmd,
6468 "ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
6469 "IP Information\n"
6470 "OSPF interface commands\n"
6471 "Message digest authentication password (key)\n"
6472 "Key ID\n"
6473 "Use MD5 algorithm\n"
6474 "The OSPF password (key)"
6475 "Address of interface")
6476{
6477 struct interface *ifp;
6478 struct crypt_key *ck;
6479 u_char key_id;
6480 struct in_addr addr;
6481 int ret;
6482 struct ospf_if_params *params;
6483
6484 ifp = vty->index;
6485 params = IF_DEF_PARAMS (ifp);
6486
6487 if (argc == 3)
6488 {
6489 ret = inet_aton(argv[2], &addr);
6490 if (!ret)
6491 {
6492 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6493 VTY_NEWLINE);
6494 return CMD_WARNING;
6495 }
6496
6497 params = ospf_get_if_params (ifp, addr);
6498 ospf_if_update_params (ifp, addr);
6499 }
6500
6501 key_id = strtol (argv[0], NULL, 10);
6502 if (ospf_crypt_key_lookup (params->auth_crypt, key_id) != NULL)
6503 {
6504 vty_out (vty, "OSPF: Key %d already exists%s", key_id, VTY_NEWLINE);
6505 return CMD_WARNING;
6506 }
6507
6508 ck = ospf_crypt_key_new ();
6509 ck->key_id = (u_char) key_id;
6510 memset (ck->auth_key, 0, OSPF_AUTH_MD5_SIZE+1);
c9e52be3 6511 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
718e3744 6512
6513 ospf_crypt_key_add (params->auth_crypt, ck);
6514 SET_IF_PARAM (params, auth_crypt);
6515
6516 return CMD_SUCCESS;
6517}
6518
6519ALIAS (ip_ospf_message_digest_key,
6520 ip_ospf_message_digest_key_cmd,
6521 "ip ospf message-digest-key <1-255> md5 KEY",
6522 "IP Information\n"
6523 "OSPF interface commands\n"
6524 "Message digest authentication password (key)\n"
6525 "Key ID\n"
6526 "Use MD5 algorithm\n"
6527 "The OSPF password (key)")
6528
747e489c
DW
6529ALIAS_HIDDEN (ip_ospf_message_digest_key,
6530 ospf_message_digest_key_cmd,
6531 "ospf message-digest-key <1-255> md5 KEY",
6532 "OSPF interface commands\n"
6533 "Message digest authentication password (key)\n"
6534 "Key ID\n"
6535 "Use MD5 algorithm\n"
6536 "The OSPF password (key)")
718e3744 6537
813d4307
DW
6538DEFUN (no_ip_ospf_message_digest_key_md5,
6539 no_ip_ospf_message_digest_key_md5_addr_cmd,
6540 "no ip ospf message-digest-key <1-255> md5 KEY A.B.C.D",
6541 NO_STR
6542 "IP Information\n"
6543 "OSPF interface commands\n"
6544 "Message digest authentication password (key)\n"
6545 "Key ID\n"
6546 "Use MD5 algorithm\n"
6547 "The OSPF password (key)"
6548 "Address of interface")
6549{
6550 struct interface *ifp;
6551 struct crypt_key *ck;
6552 int key_id;
6553 struct in_addr addr;
6554 int ret;
6555 struct ospf_if_params *params;
6556
6557 ifp = vty->index;
6558 params = IF_DEF_PARAMS (ifp);
6559
6560 if (argc == 3)
6561 {
6562 ret = inet_aton(argv[2], &addr);
6563 if (!ret)
6564 {
6565 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6566 VTY_NEWLINE);
6567 return CMD_WARNING;
6568 }
6569
6570 params = ospf_lookup_if_params (ifp, addr);
6571 if (params == NULL)
6572 return CMD_SUCCESS;
6573 }
6574
6575 key_id = strtol (argv[0], NULL, 10);
6576 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
6577 if (ck == NULL)
6578 {
6579 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
6580 return CMD_WARNING;
6581 }
6582
6583 ospf_crypt_key_delete (params->auth_crypt, key_id);
6584
6585 if (params != IF_DEF_PARAMS (ifp))
6586 {
6587 ospf_free_if_params (ifp, addr);
6588 ospf_if_update_params (ifp, addr);
6589 }
6590
6591 return CMD_SUCCESS;
6592}
6593
6594ALIAS (no_ip_ospf_message_digest_key_md5,
6595 no_ip_ospf_message_digest_key_md5_cmd,
6596 "no ip ospf message-digest-key <1-255> md5 KEY",
6597 NO_STR
6598 "IP Information\n"
6599 "OSPF interface commands\n"
6600 "Message digest authentication password (key)\n"
6601 "Key ID\n"
6602 "Use MD5 algorithm\n"
6603 "The OSPF password (key)")
6604
718e3744 6605DEFUN (no_ip_ospf_message_digest_key,
6606 no_ip_ospf_message_digest_key_addr_cmd,
6607 "no ip ospf message-digest-key <1-255> A.B.C.D",
6608 NO_STR
6609 "IP Information\n"
6610 "OSPF interface commands\n"
6611 "Message digest authentication password (key)\n"
6612 "Key ID\n"
6613 "Address of interface")
6614{
6615 struct interface *ifp;
6616 struct crypt_key *ck;
6617 int key_id;
6618 struct in_addr addr;
6619 int ret;
6620 struct ospf_if_params *params;
6621
6622 ifp = vty->index;
6623 params = IF_DEF_PARAMS (ifp);
6624
6625 if (argc == 2)
6626 {
6627 ret = inet_aton(argv[1], &addr);
6628 if (!ret)
6629 {
6630 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6631 VTY_NEWLINE);
6632 return CMD_WARNING;
6633 }
6634
6635 params = ospf_lookup_if_params (ifp, addr);
6636 if (params == NULL)
6637 return CMD_SUCCESS;
6638 }
6639
6640 key_id = strtol (argv[0], NULL, 10);
6641 ck = ospf_crypt_key_lookup (params->auth_crypt, key_id);
6642 if (ck == NULL)
6643 {
6644 vty_out (vty, "OSPF: Key %d does not exist%s", key_id, VTY_NEWLINE);
6645 return CMD_WARNING;
6646 }
6647
6648 ospf_crypt_key_delete (params->auth_crypt, key_id);
6649
6650 if (params != IF_DEF_PARAMS (ifp))
6651 {
6652 ospf_free_if_params (ifp, addr);
6653 ospf_if_update_params (ifp, addr);
6654 }
6655
6656 return CMD_SUCCESS;
6657}
6658
6659ALIAS (no_ip_ospf_message_digest_key,
6660 no_ip_ospf_message_digest_key_cmd,
6661 "no ip ospf message-digest-key <1-255>",
6662 NO_STR
6663 "IP Information\n"
6664 "OSPF interface commands\n"
6665 "Message digest authentication password (key)\n"
6666 "Key ID\n")
6667
6668ALIAS (no_ip_ospf_message_digest_key,
6669 no_ospf_message_digest_key_cmd,
6670 "no ospf message-digest-key <1-255>",
6671 NO_STR
6672 "OSPF interface commands\n"
6673 "Message digest authentication password (key)\n"
6674 "Key ID\n")
6675
6676DEFUN (ip_ospf_cost,
9eff36b3 6677 ip_ospf_cost_u32_inet4_cmd,
718e3744 6678 "ip ospf cost <1-65535> A.B.C.D",
6679 "IP Information\n"
6680 "OSPF interface commands\n"
6681 "Interface cost\n"
6682 "Cost\n"
6683 "Address of interface")
6684{
6685 struct interface *ifp = vty->index;
6686 u_int32_t cost;
6687 struct in_addr addr;
6688 int ret;
6689 struct ospf_if_params *params;
6690
6691 params = IF_DEF_PARAMS (ifp);
6692
6693 cost = strtol (argv[0], NULL, 10);
6694
6695 /* cost range is <1-65535>. */
6696 if (cost < 1 || cost > 65535)
6697 {
6698 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
6699 return CMD_WARNING;
6700 }
6701
6702 if (argc == 2)
6703 {
6704 ret = inet_aton(argv[1], &addr);
6705 if (!ret)
6706 {
6707 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6708 VTY_NEWLINE);
6709 return CMD_WARNING;
6710 }
6711
6712 params = ospf_get_if_params (ifp, addr);
6713 ospf_if_update_params (ifp, addr);
6714 }
6715
6716 SET_IF_PARAM (params, output_cost_cmd);
6717 params->output_cost_cmd = cost;
6718
6719 ospf_if_recalculate_output_cost (ifp);
6720
6721 return CMD_SUCCESS;
6722}
6723
6724ALIAS (ip_ospf_cost,
9eff36b3 6725 ip_ospf_cost_u32_cmd,
718e3744 6726 "ip ospf cost <1-65535>",
6727 "IP Information\n"
6728 "OSPF interface commands\n"
6729 "Interface cost\n"
6730 "Cost")
6731
747e489c
DW
6732ALIAS_HIDDEN (ip_ospf_cost,
6733 ospf_cost_u32_cmd,
6734 "ospf cost <1-65535>",
6735 "OSPF interface commands\n"
6736 "Interface cost\n"
6737 "Cost")
6738
6739ALIAS_HIDDEN (ip_ospf_cost,
6740 ospf_cost_u32_inet4_cmd,
6741 "ospf cost <1-65535> A.B.C.D",
6742 "OSPF interface commands\n"
6743 "Interface cost\n"
6744 "Cost\n"
6745 "Address of interface")
9eff36b3 6746
718e3744 6747DEFUN (no_ip_ospf_cost,
9eff36b3 6748 no_ip_ospf_cost_inet4_cmd,
718e3744 6749 "no ip ospf cost A.B.C.D",
6750 NO_STR
6751 "IP Information\n"
6752 "OSPF interface commands\n"
6753 "Interface cost\n"
6754 "Address of interface")
6755{
6756 struct interface *ifp = vty->index;
6757 struct in_addr addr;
6758 int ret;
6759 struct ospf_if_params *params;
6760
6761 ifp = vty->index;
6762 params = IF_DEF_PARAMS (ifp);
6763
6764 if (argc == 1)
6765 {
6766 ret = inet_aton(argv[0], &addr);
6767 if (!ret)
6768 {
6769 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6770 VTY_NEWLINE);
6771 return CMD_WARNING;
6772 }
6773
6774 params = ospf_lookup_if_params (ifp, addr);
6775 if (params == NULL)
6776 return CMD_SUCCESS;
6777 }
6778
6779 UNSET_IF_PARAM (params, output_cost_cmd);
6780
6781 if (params != IF_DEF_PARAMS (ifp))
6782 {
6783 ospf_free_if_params (ifp, addr);
6784 ospf_if_update_params (ifp, addr);
6785 }
6786
6787 ospf_if_recalculate_output_cost (ifp);
6788
6789 return CMD_SUCCESS;
6790}
6791
6792ALIAS (no_ip_ospf_cost,
6793 no_ip_ospf_cost_cmd,
6794 "no ip ospf cost",
6795 NO_STR
6796 "IP Information\n"
6797 "OSPF interface commands\n"
6798 "Interface cost\n")
6799
6800ALIAS (no_ip_ospf_cost,
6801 no_ospf_cost_cmd,
6802 "no ospf cost",
6803 NO_STR
6804 "OSPF interface commands\n"
6805 "Interface cost\n")
6806
9eff36b3
DO
6807ALIAS (no_ip_ospf_cost,
6808 no_ospf_cost_inet4_cmd,
6809 "no ospf cost A.B.C.D",
6810 NO_STR
6811 "OSPF interface commands\n"
6812 "Interface cost\n"
6813 "Address of interface")
6814
827341b7
DO
6815DEFUN (no_ip_ospf_cost2,
6816 no_ip_ospf_cost_u32_cmd,
6817 "no ip ospf cost <1-65535>",
6818 NO_STR
6819 "IP Information\n"
6820 "OSPF interface commands\n"
6821 "Interface cost\n"
6822 "Cost")
6823{
6824 struct interface *ifp = vty->index;
6825 struct in_addr addr;
6826 u_int32_t cost;
6827 int ret;
6828 struct ospf_if_params *params;
6829
6830 ifp = vty->index;
6831 params = IF_DEF_PARAMS (ifp);
6832
6833 /* According to the semantics we are mimicking "no ip ospf cost N" is
6834 * always treated as "no ip ospf cost" regardless of the actual value
6835 * of N already configured for the interface. Thus the first argument
6836 * is always checked to be a number, but is ignored after that.
6837 */
6838 cost = strtol (argv[0], NULL, 10);
6839 if (cost < 1 || cost > 65535)
6840 {
6841 vty_out (vty, "Interface output cost is invalid%s", VTY_NEWLINE);
6842 return CMD_WARNING;
6843 }
6844
6845 if (argc == 2)
6846 {
6847 ret = inet_aton(argv[1], &addr);
6848 if (!ret)
6849 {
6850 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6851 VTY_NEWLINE);
6852 return CMD_WARNING;
6853 }
6854
6855 params = ospf_lookup_if_params (ifp, addr);
6856 if (params == NULL)
6857 return CMD_SUCCESS;
6858 }
6859
6860 UNSET_IF_PARAM (params, output_cost_cmd);
6861
6862 if (params != IF_DEF_PARAMS (ifp))
6863 {
6864 ospf_free_if_params (ifp, addr);
6865 ospf_if_update_params (ifp, addr);
6866 }
6867
6868 ospf_if_recalculate_output_cost (ifp);
6869
6870 return CMD_SUCCESS;
6871}
6872
6873ALIAS (no_ip_ospf_cost2,
6874 no_ospf_cost_u32_cmd,
6875 "no ospf cost <1-65535>",
6876 NO_STR
6877 "OSPF interface commands\n"
6878 "Interface cost\n"
6879 "Cost")
6880
6881ALIAS (no_ip_ospf_cost2,
6882 no_ip_ospf_cost_u32_inet4_cmd,
6883 "no ip ospf cost <1-65535> A.B.C.D",
6884 NO_STR
6885 "IP Information\n"
6886 "OSPF interface commands\n"
6887 "Interface cost\n"
6888 "Cost\n"
6889 "Address of interface")
6890
6891ALIAS (no_ip_ospf_cost2,
6892 no_ospf_cost_u32_inet4_cmd,
6893 "no ospf cost <1-65535> A.B.C.D",
6894 NO_STR
6895 "OSPF interface commands\n"
6896 "Interface cost\n"
6897 "Cost\n"
6898 "Address of interface")
9eff36b3 6899
4dadc291 6900static void
718e3744 6901ospf_nbr_timer_update (struct ospf_interface *oi)
6902{
6903 struct route_node *rn;
6904 struct ospf_neighbor *nbr;
6905
6906 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
6907 if ((nbr = rn->info))
6908 {
6909 nbr->v_inactivity = OSPF_IF_PARAM (oi, v_wait);
6910 nbr->v_db_desc = OSPF_IF_PARAM (oi, retransmit_interval);
6911 nbr->v_ls_req = OSPF_IF_PARAM (oi, retransmit_interval);
6912 nbr->v_ls_upd = OSPF_IF_PARAM (oi, retransmit_interval);
6913 }
6914}
6915
f9ad937f 6916static int
6917ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
6918 const char *nbr_str,
6919 const char *fast_hello_str)
718e3744 6920{
6921 struct interface *ifp = vty->index;
6922 u_int32_t seconds;
f9ad937f 6923 u_char hellomult;
718e3744 6924 struct in_addr addr;
6925 int ret;
6926 struct ospf_if_params *params;
6927 struct ospf_interface *oi;
6928 struct route_node *rn;
6929
6930 params = IF_DEF_PARAMS (ifp);
f9ad937f 6931
6932 if (nbr_str)
718e3744 6933 {
f9ad937f 6934 ret = inet_aton(nbr_str, &addr);
718e3744 6935 if (!ret)
6936 {
6937 vty_out (vty, "Please specify interface address by A.B.C.D%s",
6938 VTY_NEWLINE);
6939 return CMD_WARNING;
6940 }
6941
6942 params = ospf_get_if_params (ifp, addr);
6943 ospf_if_update_params (ifp, addr);
6944 }
6945
f9ad937f 6946 if (interval_str)
6947 {
6948 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds, interval_str,
6949 1, 65535);
6950
6951 /* reset fast_hello too, just to be sure */
6952 UNSET_IF_PARAM (params, fast_hello);
6953 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
6954 }
6955 else if (fast_hello_str)
6956 {
6957 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult, fast_hello_str,
6958 1, 10);
6959 /* 1s dead-interval with sub-second hellos desired */
6960 seconds = OSPF_ROUTER_DEAD_INTERVAL_MINIMAL;
6961 SET_IF_PARAM (params, fast_hello);
6962 params->fast_hello = hellomult;
6963 }
6964 else
6965 {
6966 vty_out (vty, "Please specify dead-interval or hello-multiplier%s",
6967 VTY_NEWLINE);
6968 return CMD_WARNING;
6969 }
6970
718e3744 6971 SET_IF_PARAM (params, v_wait);
6972 params->v_wait = seconds;
6973
6974 /* Update timer values in neighbor structure. */
f9ad937f 6975 if (nbr_str)
718e3744 6976 {
cac3b5c4
PJ
6977 struct ospf *ospf;
6978 if ((ospf = ospf_lookup()))
68980084 6979 {
6980 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
6981 if (oi)
6982 ospf_nbr_timer_update (oi);
6983 }
718e3744 6984 }
6985 else
6986 {
6987 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
6988 if ((oi = rn->info))
6989 ospf_nbr_timer_update (oi);
6990 }
6991
6992 return CMD_SUCCESS;
6993}
6994
f9ad937f 6995
6996DEFUN (ip_ospf_dead_interval,
6997 ip_ospf_dead_interval_addr_cmd,
6998 "ip ospf dead-interval <1-65535> A.B.C.D",
6999 "IP Information\n"
7000 "OSPF interface commands\n"
7001 "Interval after which a neighbor is declared dead\n"
7002 "Seconds\n"
7003 "Address of interface\n")
7004{
7005 if (argc == 2)
7006 return ospf_vty_dead_interval_set (vty, argv[0], argv[1], NULL);
7007 else
7008 return ospf_vty_dead_interval_set (vty, argv[0], NULL, NULL);
7009}
7010
718e3744 7011ALIAS (ip_ospf_dead_interval,
7012 ip_ospf_dead_interval_cmd,
7013 "ip ospf dead-interval <1-65535>",
7014 "IP Information\n"
7015 "OSPF interface commands\n"
7016 "Interval after which a neighbor is declared dead\n"
7017 "Seconds\n")
7018
747e489c
DW
7019ALIAS_HIDDEN (ip_ospf_dead_interval,
7020 ospf_dead_interval_cmd,
7021 "ospf dead-interval <1-65535>",
7022 "OSPF interface commands\n"
7023 "Interval after which a neighbor is declared dead\n"
7024 "Seconds\n")
718e3744 7025
f9ad937f 7026DEFUN (ip_ospf_dead_interval_minimal,
7027 ip_ospf_dead_interval_minimal_addr_cmd,
7028 "ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
7029 "IP Information\n"
7030 "OSPF interface commands\n"
7031 "Interval after which a neighbor is declared dead\n"
7032 "Minimal 1s dead-interval with fast sub-second hellos\n"
7033 "Hello multiplier factor\n"
7034 "Number of Hellos to send each second\n"
7035 "Address of interface\n")
7036{
7037 if (argc == 2)
7038 return ospf_vty_dead_interval_set (vty, NULL, argv[1], argv[0]);
7039 else
7040 return ospf_vty_dead_interval_set (vty, NULL, NULL, argv[0]);
7041}
7042
7043ALIAS (ip_ospf_dead_interval_minimal,
7044 ip_ospf_dead_interval_minimal_cmd,
7045 "ip ospf dead-interval minimal hello-multiplier <1-10>",
7046 "IP Information\n"
7047 "OSPF interface commands\n"
7048 "Interval after which a neighbor is declared dead\n"
7049 "Minimal 1s dead-interval with fast sub-second hellos\n"
7050 "Hello multiplier factor\n"
7051 "Number of Hellos to send each second\n")
7052
718e3744 7053DEFUN (no_ip_ospf_dead_interval,
7054 no_ip_ospf_dead_interval_addr_cmd,
f9dfba8d 7055 "no ip ospf dead-interval <1-65535> A.B.C.D",
718e3744 7056 NO_STR
7057 "IP Information\n"
7058 "OSPF interface commands\n"
7059 "Interval after which a neighbor is declared dead\n"
f9dfba8d 7060 "Seconds\n"
718e3744 7061 "Address of interface")
7062{
7063 struct interface *ifp = vty->index;
7064 struct in_addr addr;
7065 int ret;
7066 struct ospf_if_params *params;
7067 struct ospf_interface *oi;
7068 struct route_node *rn;
020709f9 7069
718e3744 7070 ifp = vty->index;
7071 params = IF_DEF_PARAMS (ifp);
7072
f9dfba8d 7073 if (argc == 2)
718e3744 7074 {
f9dfba8d 7075 ret = inet_aton(argv[1], &addr);
718e3744 7076 if (!ret)
7077 {
7078 vty_out (vty, "Please specify interface address by A.B.C.D%s",
7079 VTY_NEWLINE);
7080 return CMD_WARNING;
7081 }
7082
7083 params = ospf_lookup_if_params (ifp, addr);
7084 if (params == NULL)
7085 return CMD_SUCCESS;
7086 }
7087
7088 UNSET_IF_PARAM (params, v_wait);
7089 params->v_wait = OSPF_ROUTER_DEAD_INTERVAL_DEFAULT;
f9ad937f 7090
7091 UNSET_IF_PARAM (params, fast_hello);
7092 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
7093
718e3744 7094 if (params != IF_DEF_PARAMS (ifp))
7095 {
7096 ospf_free_if_params (ifp, addr);
7097 ospf_if_update_params (ifp, addr);
7098 }
7099
7100 /* Update timer values in neighbor structure. */
7101 if (argc == 1)
7102 {
cac3b5c4
PJ
7103 struct ospf *ospf;
7104
7105 if ((ospf = ospf_lookup()))
68980084 7106 {
7107 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
7108 if (oi)
7109 ospf_nbr_timer_update (oi);
7110 }
718e3744 7111 }
7112 else
7113 {
7114 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
7115 if ((oi = rn->info))
7116 ospf_nbr_timer_update (oi);
7117 }
7118
7119 return CMD_SUCCESS;
7120}
7121
f9dfba8d
DS
7122ALIAS (no_ip_ospf_dead_interval,
7123 no_ip_ospf_dead_interval_seconds_cmd,
7124 "no ip ospf dead-interval <1-65535>",
7125 NO_STR
7126 "IP Information\n"
7127 "OSPF interface commands\n"
7128 "Interval after which a neighbor is declared dead\n"
7129 "Seconds\n")
7130
718e3744 7131ALIAS (no_ip_ospf_dead_interval,
7132 no_ip_ospf_dead_interval_cmd,
7133 "no ip ospf dead-interval",
7134 NO_STR
7135 "IP Information\n"
7136 "OSPF interface commands\n"
7137 "Interval after which a neighbor is declared dead\n")
7138
7139ALIAS (no_ip_ospf_dead_interval,
7140 no_ospf_dead_interval_cmd,
7141 "no ospf dead-interval",
7142 NO_STR
7143 "OSPF interface commands\n"
7144 "Interval after which a neighbor is declared dead\n")
7145
813d4307
DW
7146ALIAS (no_ip_ospf_dead_interval,
7147 no_ip_ospf_dead_interval_minimal_addr_cmd,
7148 "no ip ospf dead-interval minimal hello-multiplier <1-10> A.B.C.D",
7149 NO_STR
7150 "IP Information\n"
7151 "OSPF interface commands\n"
7152 "Interval after which a neighbor is declared dead\n"
7153 "Minimal 1s dead-interval with fast sub-second hellos\n"
7154 "Hello multiplier factor\n"
7155 "Number of Hellos to send each second\n"
7156 "Address of interface\n")
7157
7158ALIAS (no_ip_ospf_dead_interval,
7159 no_ip_ospf_dead_interval_minimal_cmd,
7160 "no ip ospf dead-interval minimal hello-multiplier <1-10>",
7161 NO_STR
7162 "IP Information\n"
7163 "OSPF interface commands\n"
7164 "Interval after which a neighbor is declared dead\n"
7165 "Minimal 1s dead-interval with fast sub-second hellos\n"
7166 "Hello multiplier factor\n"
7167 "Number of Hellos to send each second\n")
7168
718e3744 7169DEFUN (ip_ospf_hello_interval,
7170 ip_ospf_hello_interval_addr_cmd,
7171 "ip ospf hello-interval <1-65535> A.B.C.D",
7172 "IP Information\n"
7173 "OSPF interface commands\n"
7174 "Time between HELLO packets\n"
7175 "Seconds\n"
7176 "Address of interface")
7177{
7178 struct interface *ifp = vty->index;
7179 u_int32_t seconds;
7180 struct in_addr addr;
7181 int ret;
7182 struct ospf_if_params *params;
7183
7184 params = IF_DEF_PARAMS (ifp);
7185
7186 seconds = strtol (argv[0], NULL, 10);
7187
7188 /* HelloInterval range is <1-65535>. */
7189 if (seconds < 1 || seconds > 65535)
7190 {
7191 vty_out (vty, "Hello Interval is invalid%s", VTY_NEWLINE);
7192 return CMD_WARNING;
7193 }
7194
7195 if (argc == 2)
7196 {
7197 ret = inet_aton(argv[1], &addr);
7198 if (!ret)
7199 {
7200 vty_out (vty, "Please specify interface address by A.B.C.D%s",
7201 VTY_NEWLINE);
7202 return CMD_WARNING;
7203 }
7204
7205 params = ospf_get_if_params (ifp, addr);
7206 ospf_if_update_params (ifp, addr);
7207 }
7208
f9ad937f 7209 SET_IF_PARAM (params, v_hello);
718e3744 7210 params->v_hello = seconds;
7211
7212 return CMD_SUCCESS;
7213}
7214
7215ALIAS (ip_ospf_hello_interval,
7216 ip_ospf_hello_interval_cmd,
7217 "ip ospf hello-interval <1-65535>",
7218 "IP Information\n"
7219 "OSPF interface commands\n"
7220 "Time between HELLO packets\n"
7221 "Seconds\n")
7222
747e489c
DW
7223ALIAS_HIDDEN (ip_ospf_hello_interval,
7224 ospf_hello_interval_cmd,
7225 "ospf hello-interval <1-65535>",
7226 "OSPF interface commands\n"
7227 "Time between HELLO packets\n"
7228 "Seconds\n")
718e3744 7229
7230DEFUN (no_ip_ospf_hello_interval,
7231 no_ip_ospf_hello_interval_addr_cmd,
f9dfba8d 7232 "no ip ospf hello-interval <1-65535> A.B.C.D",
718e3744 7233 NO_STR
7234 "IP Information\n"
7235 "OSPF interface commands\n"
7236 "Time between HELLO packets\n"
f9dfba8d 7237 "Seconds\n"
718e3744 7238 "Address of interface")
7239{
7240 struct interface *ifp = vty->index;
7241 struct in_addr addr;
7242 int ret;
7243 struct ospf_if_params *params;
7244
7245 ifp = vty->index;
7246 params = IF_DEF_PARAMS (ifp);
7247
f9dfba8d 7248 if (argc == 2)
718e3744 7249 {
f9dfba8d 7250 ret = inet_aton(argv[1], &addr);
718e3744 7251 if (!ret)
7252 {
7253 vty_out (vty, "Please specify interface address by A.B.C.D%s",
7254 VTY_NEWLINE);
7255 return CMD_WARNING;
7256 }
7257
7258 params = ospf_lookup_if_params (ifp, addr);
7259 if (params == NULL)
7260 return CMD_SUCCESS;
7261 }
7262
7263 UNSET_IF_PARAM (params, v_hello);
f9ad937f 7264 params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
718e3744 7265
7266 if (params != IF_DEF_PARAMS (ifp))
7267 {
7268 ospf_free_if_params (ifp, addr);
7269 ospf_if_update_params (ifp, addr);
7270 }
7271
7272 return CMD_SUCCESS;
7273}
7274
f9dfba8d
DS
7275ALIAS (no_ip_ospf_hello_interval,
7276 no_ip_ospf_hello_interval_seconds_cmd,
7277 "no ip ospf hello-interval <1-65535>",
7278 NO_STR
7279 "IP Information\n"
7280 "OSPF interface commands\n"
7281 "Time between HELLO packets\n"
7282 "Seconds\n")
7283
718e3744 7284ALIAS (no_ip_ospf_hello_interval,
7285 no_ip_ospf_hello_interval_cmd,
7286 "no ip ospf hello-interval",
7287 NO_STR
7288 "IP Information\n"
7289 "OSPF interface commands\n"
7290 "Time between HELLO packets\n")
7291
7292ALIAS (no_ip_ospf_hello_interval,
7293 no_ospf_hello_interval_cmd,
813d4307 7294 "no ospf hello-interval <1-65535>",
718e3744 7295 NO_STR
7296 "OSPF interface commands\n"
813d4307
DW
7297 "Time between HELLO packets\n"
7298 "Seconds\n")
718e3744 7299
7300DEFUN (ip_ospf_network,
7301 ip_ospf_network_cmd,
7302 "ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
7303 "IP Information\n"
7304 "OSPF interface commands\n"
7305 "Network type\n"
7306 "Specify OSPF broadcast multi-access network\n"
7307 "Specify OSPF NBMA network\n"
7308 "Specify OSPF point-to-multipoint network\n"
7309 "Specify OSPF point-to-point network\n")
7310{
7311 struct interface *ifp = vty->index;
7312 int old_type = IF_DEF_PARAMS (ifp)->type;
7313 struct route_node *rn;
4b4bda9b
CF
7314
7315 if (old_type == OSPF_IFTYPE_LOOPBACK)
7316 {
7317 vty_out (vty, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE);
7318 return CMD_WARNING;
7319 }
7320
718e3744 7321 if (strncmp (argv[0], "b", 1) == 0)
7322 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_BROADCAST;
7323 else if (strncmp (argv[0], "n", 1) == 0)
7324 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_NBMA;
7325 else if (strncmp (argv[0], "point-to-m", 10) == 0)
7326 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOMULTIPOINT;
7327 else if (strncmp (argv[0], "point-to-p", 10) == 0)
7328 IF_DEF_PARAMS (ifp)->type = OSPF_IFTYPE_POINTOPOINT;
7329
7330 if (IF_DEF_PARAMS (ifp)->type == old_type)
7331 return CMD_SUCCESS;
7332
7333 SET_IF_PARAM (IF_DEF_PARAMS (ifp), type);
7334
7335 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
7336 {
7337 struct ospf_interface *oi = rn->info;
7338
7339 if (!oi)
7340 continue;
7341
7342 oi->type = IF_DEF_PARAMS (ifp)->type;
7343
7344 if (oi->state > ISM_Down)
7345 {
7346 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
7347 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
7348 }
7349 }
7350
7351 return CMD_SUCCESS;
7352}
7353
747e489c
DW
7354ALIAS_HIDDEN (ip_ospf_network,
7355 ospf_network_cmd,
7356 "ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
7357 "OSPF interface commands\n"
7358 "Network type\n"
7359 "Specify OSPF broadcast multi-access network\n"
7360 "Specify OSPF NBMA network\n"
7361 "Specify OSPF point-to-multipoint network\n"
7362 "Specify OSPF point-to-point network\n")
718e3744 7363
7364DEFUN (no_ip_ospf_network,
7365 no_ip_ospf_network_cmd,
7366 "no ip ospf network",
7367 NO_STR
7368 "IP Information\n"
7369 "OSPF interface commands\n"
7370 "Network type\n")
7371{
7372 struct interface *ifp = vty->index;
7373 int old_type = IF_DEF_PARAMS (ifp)->type;
7374 struct route_node *rn;
7375
bc18d616 7376 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
718e3744 7377
7378 if (IF_DEF_PARAMS (ifp)->type == old_type)
7379 return CMD_SUCCESS;
7380
7381 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
7382 {
7383 struct ospf_interface *oi = rn->info;
7384
7385 if (!oi)
7386 continue;
7387
7388 oi->type = IF_DEF_PARAMS (ifp)->type;
7389
7390 if (oi->state > ISM_Down)
7391 {
7392 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceDown);
7393 OSPF_ISM_EVENT_EXECUTE (oi, ISM_InterfaceUp);
7394 }
7395 }
7396
7397 return CMD_SUCCESS;
7398}
7399
813d4307
DW
7400ALIAS (no_ip_ospf_network,
7401 no_ip_ospf_network_val_cmd,
7402 "no ip ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
7403 NO_STR
7404 "IP Information\n"
7405 "OSPF interface commands\n"
7406 "Network type\n"
7407 "Specify OSPF broadcast multi-access network\n"
7408 "Specify OSPF NBMA network\n"
7409 "Specify OSPF point-to-multipoint network\n"
7410 "Specify OSPF point-to-point network\n")
7411
718e3744 7412ALIAS (no_ip_ospf_network,
7413 no_ospf_network_cmd,
7414 "no ospf network",
7415 NO_STR
7416 "OSPF interface commands\n"
7417 "Network type\n")
7418
813d4307
DW
7419ALIAS (no_ip_ospf_network,
7420 no_ospf_network_val_cmd,
7421 "no ospf network (broadcast|non-broadcast|point-to-multipoint|point-to-point)",
7422 NO_STR
7423 "OSPF interface commands\n"
7424 "Network type\n"
7425 "Specify OSPF broadcast multi-access network\n"
7426 "Specify OSPF NBMA network\n"
7427 "Specify OSPF point-to-multipoint network\n"
7428 "Specify OSPF point-to-point network\n")
7429
718e3744 7430DEFUN (ip_ospf_priority,
7431 ip_ospf_priority_addr_cmd,
7432 "ip ospf priority <0-255> A.B.C.D",
7433 "IP Information\n"
7434 "OSPF interface commands\n"
7435 "Router priority\n"
7436 "Priority\n"
7437 "Address of interface")
7438{
7439 struct interface *ifp = vty->index;
0798cee3 7440 long priority;
718e3744 7441 struct route_node *rn;
7442 struct in_addr addr;
7443 int ret;
7444 struct ospf_if_params *params;
7445
7446 params = IF_DEF_PARAMS (ifp);
7447
7448 priority = strtol (argv[0], NULL, 10);
7449
7450 /* Router Priority range is <0-255>. */
7451 if (priority < 0 || priority > 255)
7452 {
7453 vty_out (vty, "Router Priority is invalid%s", VTY_NEWLINE);
7454 return CMD_WARNING;
7455 }
7456
7457 if (argc == 2)
7458 {
7459 ret = inet_aton(argv[1], &addr);
7460 if (!ret)
7461 {
7462 vty_out (vty, "Please specify interface address by A.B.C.D%s",
7463 VTY_NEWLINE);
7464 return CMD_WARNING;
7465 }
7466
7467 params = ospf_get_if_params (ifp, addr);
7468 ospf_if_update_params (ifp, addr);
7469 }
7470
7471 SET_IF_PARAM (params, priority);
7472 params->priority = priority;
7473
7474 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
7475 {
7476 struct ospf_interface *oi = rn->info;
7477
7478 if (!oi)
7479 continue;
7480
7481
7482 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
7483 {
7484 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
7485 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
7486 }
7487 }
7488
7489 return CMD_SUCCESS;
7490}
7491
7492ALIAS (ip_ospf_priority,
7493 ip_ospf_priority_cmd,
7494 "ip ospf priority <0-255>",
7495 "IP Information\n"
7496 "OSPF interface commands\n"
7497 "Router priority\n"
7498 "Priority\n")
7499
747e489c
DW
7500ALIAS_HIDDEN (ip_ospf_priority,
7501 ospf_priority_cmd,
7502 "ospf priority <0-255>",
7503 "OSPF interface commands\n"
7504 "Router priority\n"
7505 "Priority\n")
718e3744 7506
7507DEFUN (no_ip_ospf_priority,
7508 no_ip_ospf_priority_addr_cmd,
813d4307 7509 "no ip ospf priority <0-255> A.B.C.D",
718e3744 7510 NO_STR
7511 "IP Information\n"
7512 "OSPF interface commands\n"
7513 "Router priority\n"
813d4307 7514 "Priority\n"
718e3744 7515 "Address of interface")
7516{
7517 struct interface *ifp = vty->index;
7518 struct route_node *rn;
7519 struct in_addr addr;
7520 int ret;
7521 struct ospf_if_params *params;
7522
7523 ifp = vty->index;
7524 params = IF_DEF_PARAMS (ifp);
7525
813d4307 7526 if (argc == 2)
718e3744 7527 {
813d4307 7528 ret = inet_aton(argv[1], &addr);
718e3744 7529 if (!ret)
7530 {
7531 vty_out (vty, "Please specify interface address by A.B.C.D%s",
7532 VTY_NEWLINE);
7533 return CMD_WARNING;
7534 }
7535
7536 params = ospf_lookup_if_params (ifp, addr);
7537 if (params == NULL)
7538 return CMD_SUCCESS;
7539 }
7540
7541 UNSET_IF_PARAM (params, priority);
7542 params->priority = OSPF_ROUTER_PRIORITY_DEFAULT;
7543
7544 if (params != IF_DEF_PARAMS (ifp))
7545 {
7546 ospf_free_if_params (ifp, addr);
7547 ospf_if_update_params (ifp, addr);
7548 }
7549
7550 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
7551 {
7552 struct ospf_interface *oi = rn->info;
7553
7554 if (!oi)
7555 continue;
7556
7557
7558 if (PRIORITY (oi) != OSPF_IF_PARAM (oi, priority))
7559 {
7560 PRIORITY (oi) = OSPF_IF_PARAM (oi, priority);
7561 OSPF_ISM_EVENT_SCHEDULE (oi, ISM_NeighborChange);
7562 }
7563 }
7564
7565 return CMD_SUCCESS;
7566}
7567
a1afa410
DS
7568ALIAS (no_ip_ospf_priority,
7569 no_ip_ospf_priority_no_param_cmd,
7570 "no ip ospf priority",
7571 NO_STR
7572 "IP Information\n"
7573 "OSPF interface commands\n"
7574 "Router priority\n");
7575
718e3744 7576ALIAS (no_ip_ospf_priority,
7577 no_ip_ospf_priority_cmd,
813d4307 7578 "no ip ospf priority <0-255>",
718e3744 7579 NO_STR
7580 "IP Information\n"
7581 "OSPF interface commands\n"
813d4307
DW
7582 "Router priority\n"
7583 "Priority\n")
718e3744 7584
7585ALIAS (no_ip_ospf_priority,
7586 no_ospf_priority_cmd,
813d4307 7587 "no ospf priority <0-255>",
718e3744 7588 NO_STR
7589 "OSPF interface commands\n"
813d4307
DW
7590 "Router priority\n"
7591 "Priority\n")
718e3744 7592
d5a5c8f0 7593
718e3744 7594DEFUN (ip_ospf_retransmit_interval,
7595 ip_ospf_retransmit_interval_addr_cmd,
7596 "ip ospf retransmit-interval <3-65535> A.B.C.D",
7597 "IP Information\n"
7598 "OSPF interface commands\n"
7599 "Time between retransmitting lost link state advertisements\n"
7600 "Seconds\n"
7601 "Address of interface")
7602{
7603 struct interface *ifp = vty->index;
7604 u_int32_t seconds;
7605 struct in_addr addr;
7606 int ret;
7607 struct ospf_if_params *params;
7608
7609 params = IF_DEF_PARAMS (ifp);
7610 seconds = strtol (argv[0], NULL, 10);
7611
7612 /* Retransmit Interval range is <3-65535>. */
7613 if (seconds < 3 || seconds > 65535)
7614 {
7615 vty_out (vty, "Retransmit Interval is invalid%s", VTY_NEWLINE);
7616 return CMD_WARNING;
7617 }
7618
7619
7620 if (argc == 2)
7621 {
7622 ret = inet_aton(argv[1], &addr);
7623 if (!ret)
7624 {
7625 vty_out (vty, "Please specify interface address by A.B.C.D%s",
7626 VTY_NEWLINE);
7627 return CMD_WARNING;
7628 }
7629
7630 params = ospf_get_if_params (ifp, addr);
7631 ospf_if_update_params (ifp, addr);
7632 }
7633
7634 SET_IF_PARAM (params, retransmit_interval);
7635 params->retransmit_interval = seconds;
7636
7637 return CMD_SUCCESS;
7638}
7639
7640ALIAS (ip_ospf_retransmit_interval,
7641 ip_ospf_retransmit_interval_cmd,
7642 "ip ospf retransmit-interval <3-65535>",
7643 "IP Information\n"
7644 "OSPF interface commands\n"
7645 "Time between retransmitting lost link state advertisements\n"
7646 "Seconds\n")
7647
747e489c
DW
7648ALIAS_HIDDEN (ip_ospf_retransmit_interval,
7649 ospf_retransmit_interval_cmd,
7650 "ospf retransmit-interval <3-65535>",
7651 "OSPF interface commands\n"
7652 "Time between retransmitting lost link state advertisements\n"
7653 "Seconds\n")
718e3744 7654
7655DEFUN (no_ip_ospf_retransmit_interval,
7656 no_ip_ospf_retransmit_interval_addr_cmd,
7657 "no ip ospf retransmit-interval A.B.C.D",
7658 NO_STR
7659 "IP Information\n"
7660 "OSPF interface commands\n"
7661 "Time between retransmitting lost link state advertisements\n"
7662 "Address of interface")
7663{
7664 struct interface *ifp = vty->index;
7665 struct in_addr addr;
7666 int ret;
7667 struct ospf_if_params *params;
813d4307 7668 int addr_index;
718e3744 7669
7670 ifp = vty->index;
7671 params = IF_DEF_PARAMS (ifp);
7672
813d4307 7673 if (argc >= 1)
718e3744 7674 {
813d4307
DW
7675 if (argc == 1)
7676 addr_index = 0;
7677 else
7678 addr_index = 1;
7679
7680 ret = inet_aton(argv[addr_index], &addr);
718e3744 7681 if (!ret)
7682 {
7683 vty_out (vty, "Please specify interface address by A.B.C.D%s",
7684 VTY_NEWLINE);
7685 return CMD_WARNING;
7686 }
7687
7688 params = ospf_lookup_if_params (ifp, addr);
7689 if (params == NULL)
7690 return CMD_SUCCESS;
7691 }
7692
7693 UNSET_IF_PARAM (params, retransmit_interval);
7694 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
7695
7696 if (params != IF_DEF_PARAMS (ifp))
7697 {
7698 ospf_free_if_params (ifp, addr);
7699 ospf_if_update_params (ifp, addr);
7700 }
7701
7702 return CMD_SUCCESS;
7703}
7704
813d4307
DW
7705ALIAS (no_ip_ospf_retransmit_interval,
7706 no_ip_ospf_retransmit_interval_sec_addr_cmd,
7707 "no ip ospf retransmit-interval <3-65535> A.B.C.D",
7708 NO_STR
7709 "IP Information\n"
7710 "OSPF interface commands\n"
7711 "Time between retransmitting lost link state advertisements\n"
7712 "Seconds\n"
7713 "Address of interface")
7714
718e3744 7715ALIAS (no_ip_ospf_retransmit_interval,
7716 no_ip_ospf_retransmit_interval_cmd,
7717 "no ip ospf retransmit-interval",
7718 NO_STR
7719 "IP Information\n"
7720 "OSPF interface commands\n"
7721 "Time between retransmitting lost link state advertisements\n")
7722
7723ALIAS (no_ip_ospf_retransmit_interval,
7724 no_ospf_retransmit_interval_cmd,
7725 "no ospf retransmit-interval",
7726 NO_STR
7727 "OSPF interface commands\n"
7728 "Time between retransmitting lost link state advertisements\n")
7729
813d4307
DW
7730DEFUN (no_ip_ospf_retransmit_interval_sec,
7731 no_ip_ospf_retransmit_interval_sec_cmd,
7732 "no ip ospf retransmit-interval <3-65535>",
7733 NO_STR
7734 "IP Information\n"
7735 "OSPF interface commands\n"
7736 "Time between retransmitting lost link state advertisements\n"
7737 "Seconds\n")
7738{
7739 struct interface *ifp = vty->index;
7740 struct ospf_if_params *params;
7741
7742 ifp = vty->index;
7743 params = IF_DEF_PARAMS (ifp);
7744
7745 UNSET_IF_PARAM (params, retransmit_interval);
7746 params->retransmit_interval = OSPF_RETRANSMIT_INTERVAL_DEFAULT;
7747
7748 return CMD_SUCCESS;
7749}
7750
7751
718e3744 7752DEFUN (ip_ospf_transmit_delay,
7753 ip_ospf_transmit_delay_addr_cmd,
7754 "ip ospf transmit-delay <1-65535> A.B.C.D",
7755 "IP Information\n"
7756 "OSPF interface commands\n"
7757 "Link state transmit delay\n"
7758 "Seconds\n"
7759 "Address of interface")
7760{
7761 struct interface *ifp = vty->index;
7762 u_int32_t seconds;
7763 struct in_addr addr;
7764 int ret;
7765 struct ospf_if_params *params;
7766
7767 params = IF_DEF_PARAMS (ifp);
7768 seconds = strtol (argv[0], NULL, 10);
7769
7770 /* Transmit Delay range is <1-65535>. */
7771 if (seconds < 1 || seconds > 65535)
7772 {
7773 vty_out (vty, "Transmit Delay is invalid%s", VTY_NEWLINE);
7774 return CMD_WARNING;
7775 }
7776
7777 if (argc == 2)
7778 {
7779 ret = inet_aton(argv[1], &addr);
7780 if (!ret)
7781 {
7782 vty_out (vty, "Please specify interface address by A.B.C.D%s",
7783 VTY_NEWLINE);
7784 return CMD_WARNING;
7785 }
7786
7787 params = ospf_get_if_params (ifp, addr);
7788 ospf_if_update_params (ifp, addr);
7789 }
7790
7791 SET_IF_PARAM (params, transmit_delay);
7792 params->transmit_delay = seconds;
7793
7794 return CMD_SUCCESS;
7795}
7796
7797ALIAS (ip_ospf_transmit_delay,
7798 ip_ospf_transmit_delay_cmd,
7799 "ip ospf transmit-delay <1-65535>",
7800 "IP Information\n"
7801 "OSPF interface commands\n"
7802 "Link state transmit delay\n"
7803 "Seconds\n")
7804
747e489c
DW
7805ALIAS_HIDDEN (ip_ospf_transmit_delay,
7806 ospf_transmit_delay_cmd,
7807 "ospf transmit-delay <1-65535>",
7808 "OSPF interface commands\n"
7809 "Link state transmit delay\n"
7810 "Seconds\n")
718e3744 7811
7812DEFUN (no_ip_ospf_transmit_delay,
7813 no_ip_ospf_transmit_delay_addr_cmd,
7814 "no ip ospf transmit-delay A.B.C.D",
7815 NO_STR
7816 "IP Information\n"
7817 "OSPF interface commands\n"
7818 "Link state transmit delay\n"
7819 "Address of interface")
7820{
7821 struct interface *ifp = vty->index;
7822 struct in_addr addr;
7823 int ret;
7824 struct ospf_if_params *params;
813d4307 7825 int addr_index;
718e3744 7826
7827 ifp = vty->index;
7828 params = IF_DEF_PARAMS (ifp);
7829
813d4307 7830 if (argc >= 1)
718e3744 7831 {
813d4307
DW
7832 if (argc == 1)
7833 addr_index = 0;
7834 else
7835 addr_index = 1;
7836
7837 ret = inet_aton(argv[addr_index], &addr);
718e3744 7838 if (!ret)
7839 {
7840 vty_out (vty, "Please specify interface address by A.B.C.D%s",
7841 VTY_NEWLINE);
7842 return CMD_WARNING;
7843 }
7844
7845 params = ospf_lookup_if_params (ifp, addr);
7846 if (params == NULL)
7847 return CMD_SUCCESS;
7848 }
7849
7850 UNSET_IF_PARAM (params, transmit_delay);
7851 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
7852
7853 if (params != IF_DEF_PARAMS (ifp))
7854 {
7855 ospf_free_if_params (ifp, addr);
7856 ospf_if_update_params (ifp, addr);
7857 }
7858
7859 return CMD_SUCCESS;
7860}
7861
813d4307
DW
7862ALIAS (no_ip_ospf_transmit_delay,
7863 no_ip_ospf_transmit_delay_sec_addr_cmd,
7864 "no ip ospf transmit-delay <1-65535> A.B.C.D",
7865 NO_STR
7866 "IP Information\n"
7867 "OSPF interface commands\n"
7868 "Link state transmit delay\n"
7869 "Seconds\n"
7870 "Address of interface")
7871
718e3744 7872ALIAS (no_ip_ospf_transmit_delay,
7873 no_ip_ospf_transmit_delay_cmd,
7874 "no ip ospf transmit-delay",
7875 NO_STR
7876 "IP Information\n"
7877 "OSPF interface commands\n"
7878 "Link state transmit delay\n")
7879
7880ALIAS (no_ip_ospf_transmit_delay,
7881 no_ospf_transmit_delay_cmd,
7882 "no ospf transmit-delay",
7883 NO_STR
7884 "OSPF interface commands\n"
7885 "Link state transmit delay\n")
7886
813d4307
DW
7887DEFUN (no_ip_ospf_transmit_delay_sec,
7888 no_ip_ospf_transmit_delay_sec_cmd,
7889 "no ip ospf transmit-delay <1-65535>",
7890 NO_STR
7891 "IP Information\n"
7892 "OSPF interface commands\n"
7893 "Link state transmit delay\n"
7894 "Seconds\n"
7895 "Address of interface")
7896{
7897 struct interface *ifp = vty->index;
7898 struct ospf_if_params *params;
7899
7900 ifp = vty->index;
7901 params = IF_DEF_PARAMS (ifp);
7902
7903 UNSET_IF_PARAM (params, transmit_delay);
7904 params->transmit_delay = OSPF_TRANSMIT_DELAY_DEFAULT;
7905
7906 return CMD_SUCCESS;
7907}
7908
e723861d
DS
7909DEFUN (ip_ospf_area,
7910 ip_ospf_area_cmd,
7911 "ip ospf area (A.B.C.D|<0-4294967295>)",
7912 "IP Information\n"
7913 "OSPF interface commands\n"
7914 "Enable OSPF on this interface\n"
7915 "OSPF area ID in IP address format\n"
7916 "OSPF area ID as a decimal value\n")
7917{
7918 struct interface *ifp = vty->index;
7919 int format, ret;
7920 struct in_addr area_id;
7921 struct ospf *ospf;
7922 struct ospf_if_params *params;
7923 struct route_node *rn;
7c8ff89e 7924 u_short instance = 0;
e723861d 7925
7c8ff89e
DS
7926 if (argc == 2)
7927 VTY_GET_INTEGER ("Instance", instance, argv[0]);
7928
7929 ospf = ospf_lookup_instance (instance);
e723861d
DS
7930 if (ospf == NULL)
7931 {
7c8ff89e
DS
7932 params = IF_DEF_PARAMS (ifp);
7933 if (OSPF_IF_PARAM_CONFIGURED(params, if_area))
7934 {
7935 ospf_interface_unset (ifp);
7936 ospf = ospf_lookup();
7937 ospf->if_ospf_cli_count--;
7938 }
e723861d
DS
7939 return CMD_SUCCESS;
7940 }
7941
7c8ff89e 7942 ret = ospf_str2area_id (argv[instance ? 1 : 0], &area_id, &format);
e723861d
DS
7943 if (ret < 0)
7944 {
7945 vty_out (vty, "Please specify area by A.B.C.D|<0-4294967295>%s",
7946 VTY_NEWLINE);
7947 return CMD_WARNING;
7948 }
7949 if (memcmp (ifp->name, "VLINK", 5) == 0)
7950 {
7951 vty_out (vty, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE);
7952 return CMD_WARNING;
7953 }
7954
7955 params = IF_DEF_PARAMS (ifp);
7956 if (OSPF_IF_PARAM_CONFIGURED(params, if_area))
7957 {
73b9f703
VK
7958 vty_out (vty,
7959 "Must remove previous area config before changing ospf area %s",
7960 VTY_NEWLINE);
e723861d
DS
7961 return CMD_WARNING;
7962 }
7963
7964 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
7965 {
7966 if (rn->info != NULL)
7967 {
7968 vty_out (vty, "Please remove all network commands first.%s", VTY_NEWLINE);
7969 return CMD_WARNING;
7970 }
7971 }
7972
7973 /* enable ospf on this interface with area_id */
7974 ospf_interface_set (ifp, area_id);
7975 ospf->if_ospf_cli_count++;
7976
7977 return CMD_SUCCESS;
7978}
7979
7c8ff89e
DS
7980ALIAS (ip_ospf_area,
7981 ip_ospf_instance_area_cmd,
7982 "ip ospf <1-65535> area (A.B.C.D|<0-4294967295>)",
7983 "IP Information\n"
7984 "OSPF interface commands\n"
7985 "Instance ID\n"
7986 "Enable OSPF on this interface\n"
7987 "OSPF area ID in IP address format\n"
7988 "OSPF area ID as a decimal value\n")
7989
e723861d
DS
7990DEFUN (no_ip_ospf_area,
7991 no_ip_ospf_area_cmd,
7992 "no ip ospf area",
7993 NO_STR
7994 "IP Information\n"
7995 "OSPF interface commands\n"
7996 "Disable OSPF on this interface\n")
7997{
7998 struct interface *ifp = vty->index;
7999 struct ospf *ospf;
8000 struct ospf_if_params *params;
7c8ff89e 8001 u_short instance = 0;
e723861d 8002
7c8ff89e
DS
8003 if ((ospf = ospf_lookup_instance (instance)) == NULL)
8004 return CMD_SUCCESS;
e723861d
DS
8005
8006 params = IF_DEF_PARAMS (ifp);
8007 if (!OSPF_IF_PARAM_CONFIGURED(params, if_area))
8008 {
8009 vty_out (vty, "Can't find specified inteface area configuration.%s", VTY_NEWLINE);
8010 return CMD_WARNING;
8011 }
8012
8013 ospf_interface_unset (ifp);
8014 ospf->if_ospf_cli_count--;
8015 return CMD_SUCCESS;
8016}
8017
7c8ff89e 8018ALIAS (no_ip_ospf_area,
813d4307
DW
8019 no_ip_ospf_area_val_cmd,
8020 "no ip ospf area (A.B.C.D|<0-4294967295>)",
8021 NO_STR
8022 "IP Information\n"
8023 "OSPF interface commands\n"
8024 "Disable OSPF on this interface\n"
8025 "OSPF area ID in IP address format\n"
8026 "OSPF area ID as a decimal value\n")
8027
8028DEFUN (no_ip_ospf_instance_area,
7c8ff89e
DS
8029 no_ip_ospf_instance_area_cmd,
8030 "no ip ospf <1-65535> area",
8031 NO_STR
8032 "IP Information\n"
8033 "OSPF interface commands\n"
8034 "Instance ID\n"
8035 "Disable OSPF on this interface\n")
813d4307
DW
8036{
8037 struct interface *ifp = vty->index;
8038 struct ospf *ospf;
8039 struct ospf_if_params *params;
8040 u_short instance = 0;
8041
8042 VTY_GET_INTEGER ("Instance", instance, argv[0]);
8043
8044 if ((ospf = ospf_lookup_instance (instance)) == NULL)
8045 return CMD_SUCCESS;
8046
8047 params = IF_DEF_PARAMS (ifp);
8048 if (!OSPF_IF_PARAM_CONFIGURED(params, if_area))
8049 {
8050 vty_out (vty, "Can't find specified inteface area configuration.%s", VTY_NEWLINE);
8051 return CMD_WARNING;
8052 }
8053
8054 ospf_interface_unset (ifp);
8055 ospf->if_ospf_cli_count--;
8056 return CMD_SUCCESS;
8057}
8058
8059ALIAS (no_ip_ospf_instance_area,
8060 no_ip_ospf_instance_area_val_cmd,
8061 "no ip ospf <1-65535> area (A.B.C.D|<0-4294967295>)",
8062 NO_STR
8063 "IP Information\n"
8064 "OSPF interface commands\n"
8065 "Instance ID\n"
8066 "Disable OSPF on this interface\n"
8067 "OSPF area ID in IP address format\n"
8068 "OSPF area ID as a decimal value\n")
7c8ff89e 8069
6f2a6703
CF
8070DEFUN (ospf_redistribute_source,
8071 ospf_redistribute_source_cmd,
ab0181ee 8072 "redistribute " FRR_REDIST_STR_OSPFD
6f2a6703 8073 " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
d1c65c21 8074 REDIST_STR
ab0181ee 8075 FRR_REDIST_HELP_STR_OSPFD
718e3744 8076 "Metric for redistributed routes\n"
8077 "OSPF default metric\n"
8078 "OSPF exterior metric type for redistributed routes\n"
8079 "Set OSPF External Type 1 metrics\n"
8080 "Set OSPF External Type 2 metrics\n"
8081 "Route map reference\n"
8082 "Pointer to route-map entries\n")
8083{
020709f9 8084 struct ospf *ospf = vty->index;
718e3744 8085 int source;
8086 int type = -1;
8087 int metric = -1;
7c8ff89e 8088 struct ospf_redist *red;
718e3744 8089
d8f70b86
DS
8090 if (!ospf)
8091 return CMD_SUCCESS;
8092
6f2a6703
CF
8093 if (argc < 4)
8094 return CMD_WARNING; /* should not happen */
8095
7c8ff89e
DS
8096 if (!ospf)
8097 return CMD_SUCCESS;
8098
718e3744 8099 /* Get distribute source. */
e0ca5fde
DL
8100 source = proto_redistnum(AFI_IP, argv[0]);
8101 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
718e3744 8102 return CMD_WARNING;
8103
8104 /* Get metric value. */
6f2a6703 8105 if (argv[1] != NULL)
718e3744 8106 if (!str2metric (argv[1], &metric))
8107 return CMD_WARNING;
8108
8109 /* Get metric type. */
6f2a6703 8110 if (argv[2] != NULL)
718e3744 8111 if (!str2metric_type (argv[2], &type))
8112 return CMD_WARNING;
8113
7c8ff89e
DS
8114 red = ospf_redist_add(ospf, source, 0);
8115
6f2a6703 8116 if (argv[3] != NULL)
7c8ff89e 8117 ospf_routemap_set (red, argv[3]);
718e3744 8118 else
7c8ff89e 8119 ospf_routemap_unset (red);
718e3744 8120
7c8ff89e 8121 return ospf_redistribute_set (ospf, source, 0, type, metric);
718e3744 8122}
8123
718e3744 8124DEFUN (no_ospf_redistribute_source,
8125 no_ospf_redistribute_source_cmd,
ab0181ee 8126 "no redistribute " FRR_REDIST_STR_OSPFD
813d4307 8127 " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
718e3744 8128 NO_STR
d1c65c21 8129 REDIST_STR
ab0181ee 8130 FRR_REDIST_HELP_STR_OSPFD
813d4307
DW
8131 "Metric for redistributed routes\n"
8132 "OSPF default metric\n"
8133 "OSPF exterior metric type for redistributed routes\n"
8134 "Set OSPF External Type 1 metrics\n"
8135 "Set OSPF External Type 2 metrics\n"
8136 "Route map reference\n"
8137 "Pointer to route-map entries\n")
718e3744 8138{
020709f9 8139 struct ospf *ospf = vty->index;
718e3744 8140 int source;
7c8ff89e
DS
8141 struct ospf_redist *red;
8142 if (!ospf)
8143 return CMD_SUCCESS;
718e3744 8144
e0ca5fde
DL
8145 source = proto_redistnum(AFI_IP, argv[0]);
8146 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
718e3744 8147 return CMD_WARNING;
8148
7c8ff89e
DS
8149 red = ospf_redist_lookup(ospf, source, 0);
8150 if (!red)
8151 return CMD_SUCCESS;
8152
8153 ospf_routemap_unset (red);
8154 return ospf_redistribute_unset (ospf, source, 0);
8155}
8156
8157DEFUN (ospf_redistribute_instance_source,
8158 ospf_redistribute_instance_source_cmd,
2d627ff5 8159 "redistribute (ospf|table) <1-65535>"
7c8ff89e
DS
8160 " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
8161 REDIST_STR
8162 "Open Shortest Path First\n"
2d627ff5
DS
8163 "Non-main Kernel Routing Table\n"
8164 "Instance ID/Table ID\n"
7c8ff89e
DS
8165 "Metric for redistributed routes\n"
8166 "OSPF default metric\n"
8167 "OSPF exterior metric type for redistributed routes\n"
8168 "Set OSPF External Type 1 metrics\n"
8169 "Set OSPF External Type 2 metrics\n"
8170 "Route map reference\n"
8171 "Pointer to route-map entries\n")
8172{
8173 struct ospf *ospf = vty->index;
8174 int source;
8175 int type = -1;
8176 int metric = -1;
8177 u_short instance;
8178 struct ospf_redist *red;
8179
d8f70b86
DS
8180 if (!ospf)
8181 return CMD_SUCCESS;
8182
2d627ff5
DS
8183 if (strncmp(argv[0], "o", 1) == 0)
8184 source = ZEBRA_ROUTE_OSPF;
8185 else
8186 source = ZEBRA_ROUTE_TABLE;
8187
8188 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
7c8ff89e
DS
8189
8190 if (!ospf)
8191 return CMD_SUCCESS;
8192
2d627ff5 8193 if ((source == ZEBRA_ROUTE_OSPF) && !ospf->instance)
7c8ff89e
DS
8194 {
8195 vty_out (vty, "Instance redistribution in non-instanced OSPF not allowed%s",
8196 VTY_NEWLINE);
8197 return CMD_WARNING;
8198 }
8199
2d627ff5 8200 if ((source == ZEBRA_ROUTE_OSPF) && (ospf->instance == instance))
7c8ff89e
DS
8201 {
8202 vty_out (vty, "Same instance OSPF redistribution not allowed%s",
8203 VTY_NEWLINE);
8204 return CMD_WARNING;
8205 }
8206
7c8ff89e 8207 /* Get metric value. */
2d627ff5
DS
8208 if (argv[2] != NULL)
8209 if (!str2metric (argv[2], &metric))
7c8ff89e
DS
8210 return CMD_WARNING;
8211
8212 /* Get metric type. */
2d627ff5
DS
8213 if (argv[3] != NULL)
8214 if (!str2metric_type (argv[3], &type))
7c8ff89e
DS
8215 return CMD_WARNING;
8216
8217 red = ospf_redist_add(ospf, source, instance);
2d627ff5
DS
8218 if (argv[4] != NULL)
8219 ospf_routemap_set (red, argv[4]);
7c8ff89e
DS
8220 else
8221 ospf_routemap_unset (red);
8222
8223 return ospf_redistribute_set (ospf, source, instance, type, metric);
8224}
8225
8226DEFUN (no_ospf_redistribute_instance_source,
8227 no_ospf_redistribute_instance_source_cmd,
2d627ff5 8228 "no redistribute (ospf|table) <1-65535>"
7c8ff89e
DS
8229 " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
8230 NO_STR
8231 REDIST_STR
8232 "Open Shortest Path First\n"
2d627ff5
DS
8233 "Non-main Kernel Routing Table\n"
8234 "Instance ID/Table Id\n"
7c8ff89e
DS
8235 "Metric for redistributed routes\n"
8236 "OSPF default metric\n"
8237 "OSPF exterior metric type for redistributed routes\n"
8238 "Set OSPF External Type 1 metrics\n"
8239 "Set OSPF External Type 2 metrics\n"
8240 "Route map reference\n"
8241 "Pointer to route-map entries\n")
8242{
8243 struct ospf *ospf = vty->index;
8244 u_int instance;
8245 struct ospf_redist *red;
8246 int source;
8247
8248 if (!ospf)
8249 return CMD_SUCCESS;
8250
2d627ff5
DS
8251 if (strncmp(argv[0], "o", 1) == 0)
8252 source = ZEBRA_ROUTE_OSPF;
8253 else
8254 source = ZEBRA_ROUTE_TABLE;
8255
8256 VTY_GET_INTEGER ("Instance ID", instance, argv[1]);
7c8ff89e 8257
2d627ff5 8258 if ((source == ZEBRA_ROUTE_OSPF) && !ospf->instance)
7c8ff89e
DS
8259 {
8260 vty_out (vty, "Instance redistribution in non-instanced OSPF not allowed%s",
8261 VTY_NEWLINE);
8262 return CMD_WARNING;
8263 }
8264
2d627ff5 8265 if ((source == ZEBRA_ROUTE_OSPF) && (ospf->instance == instance))
7c8ff89e
DS
8266 {
8267 vty_out (vty, "Same instance OSPF redistribution not allowed%s",
8268 VTY_NEWLINE);
8269 return CMD_WARNING;
8270 }
8271
7c8ff89e
DS
8272 red = ospf_redist_lookup(ospf, source, instance);
8273 if (!red)
8274 return CMD_SUCCESS;
8275
8276 ospf_routemap_unset (red);
8277 return ospf_redistribute_unset (ospf, source, instance);
718e3744 8278}
8279
8280DEFUN (ospf_distribute_list_out,
8281 ospf_distribute_list_out_cmd,
ab0181ee 8282 "distribute-list WORD out " FRR_REDIST_STR_OSPFD,
718e3744 8283 "Filter networks in routing updates\n"
6f2a6703
CF
8284 "Access-list name\n"
8285 OUT_STR
ab0181ee 8286 FRR_REDIST_HELP_STR_OSPFD)
718e3744 8287{
020709f9 8288 struct ospf *ospf = vty->index;
6f2a6703 8289 int source;
718e3744 8290
7c8ff89e
DS
8291 if (!ospf)
8292 return CMD_SUCCESS;
8293
6f2a6703
CF
8294 /* Get distribute source. */
8295 source = proto_redistnum(AFI_IP, argv[1]);
8296 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
8297 return CMD_WARNING;
718e3744 8298
6f2a6703 8299 return ospf_distribute_list_out_set (ospf, source, argv[0]);
718e3744 8300}
8301
6f2a6703
CF
8302DEFUN (no_ospf_distribute_list_out,
8303 no_ospf_distribute_list_out_cmd,
ab0181ee 8304 "no distribute-list WORD out " FRR_REDIST_STR_OSPFD,
6f2a6703
CF
8305 NO_STR
8306 "Filter networks in routing updates\n"
8307 "Access-list name\n"
8308 OUT_STR
ab0181ee 8309 FRR_REDIST_HELP_STR_OSPFD)
718e3744 8310{
020709f9 8311 struct ospf *ospf = vty->index;
6f2a6703 8312 int source;
020709f9 8313
7c8ff89e
DS
8314 if (!ospf)
8315 return CMD_SUCCESS;
8316
6f2a6703
CF
8317 source = proto_redistnum(AFI_IP, argv[1]);
8318 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
8319 return CMD_WARNING;
718e3744 8320
6f2a6703 8321 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
718e3744 8322}
8323
6f2a6703
CF
8324/* Default information originate. */
8325DEFUN (ospf_default_information_originate,
8326 ospf_default_information_originate_cmd,
8327 "default-information originate "
8328 "{always|metric <0-16777214>|metric-type (1|2)|route-map WORD}",
718e3744 8329 "Control distribution of default information\n"
8330 "Distribute a default route\n"
8331 "Always advertise default route\n"
6f2a6703
CF
8332 "OSPF default metric\n"
8333 "OSPF metric\n"
718e3744 8334 "OSPF metric type for default routes\n"
8335 "Set OSPF External Type 1 metrics\n"
8336 "Set OSPF External Type 2 metrics\n"
718e3744 8337 "Route map reference\n"
8338 "Pointer to route-map entries\n")
8339{
020709f9 8340 struct ospf *ospf = vty->index;
6f2a6703 8341 int default_originate = DEFAULT_ORIGINATE_ZEBRA;
718e3744 8342 int type = -1;
8343 int metric = -1;
7c8ff89e
DS
8344 struct ospf_redist *red;
8345
8346 if (!ospf)
8347 return CMD_SUCCESS;
718e3744 8348
6f2a6703
CF
8349 if (argc < 4)
8350 return CMD_WARNING; /* this should not happen */
8351
8352 /* Check whether "always" was specified */
8353 if (argv[0] != NULL)
8354 default_originate = DEFAULT_ORIGINATE_ALWAYS;
718e3744 8355
7c8ff89e
DS
8356 red = ospf_redist_add(ospf, DEFAULT_ROUTE, 0);
8357
718e3744 8358 /* Get metric value. */
6f2a6703 8359 if (argv[1] != NULL)
718e3744 8360 if (!str2metric (argv[1], &metric))
8361 return CMD_WARNING;
8362
718e3744 8363 /* Get metric type. */
6f2a6703
CF
8364 if (argv[2] != NULL)
8365 if (!str2metric_type (argv[2], &type))
718e3744 8366 return CMD_WARNING;
8367
6f2a6703 8368 if (argv[3] != NULL)
7c8ff89e 8369 ospf_routemap_set (red, argv[3]);
718e3744 8370 else
7c8ff89e 8371 ospf_routemap_unset (red);
718e3744 8372
6f2a6703
CF
8373 return ospf_redistribute_default_set (ospf, default_originate,
8374 type, metric);
718e3744 8375}
8376
8377DEFUN (no_ospf_default_information_originate,
8378 no_ospf_default_information_originate_cmd,
813d4307
DW
8379 "no default-information originate"
8380 "{always|metric <0-16777214>|metric-type (1|2)|route-map WORD}",
718e3744 8381 NO_STR
8382 "Control distribution of default information\n"
813d4307
DW
8383 "Distribute a default route\n"
8384 "Always advertise default route\n"
8385 "OSPF default metric\n"
8386 "OSPF metric\n"
8387 "OSPF metric type for default routes\n"
8388 "Set OSPF External Type 1 metrics\n"
8389 "Set OSPF External Type 2 metrics\n"
8390 "Route map reference\n"
8391 "Pointer to route-map entries\n")
718e3744 8392{
68980084 8393 struct ospf *ospf = vty->index;
718e3744 8394 struct prefix_ipv4 p;
7c8ff89e
DS
8395 struct ospf_external *ext;
8396 struct ospf_redist *red;
718e3744 8397
7c8ff89e
DS
8398 if (!ospf)
8399 return CMD_SUCCESS;
8400
718e3744 8401 p.family = AF_INET;
8402 p.prefix.s_addr = 0;
8403 p.prefixlen = 0;
8404
5339cfdb 8405 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
718e3744 8406
7c8ff89e
DS
8407 if ((ext = ospf_external_lookup(DEFAULT_ROUTE, 0)) &&
8408 EXTERNAL_INFO (ext)) {
8409 ospf_external_info_delete (DEFAULT_ROUTE, 0, p);
8410 ospf_external_del (DEFAULT_ROUTE, 0);
718e3744 8411 }
8412
7c8ff89e
DS
8413 red = ospf_redist_lookup(ospf, DEFAULT_ROUTE, 0);
8414 if (!red)
8415 return CMD_SUCCESS;
8416
8417 ospf_routemap_unset (red);
020709f9 8418 return ospf_redistribute_default_unset (ospf);
718e3744 8419}
8420
8421DEFUN (ospf_default_metric,
8422 ospf_default_metric_cmd,
8423 "default-metric <0-16777214>",
8424 "Set metric of redistributed routes\n"
8425 "Default metric\n")
8426{
68980084 8427 struct ospf *ospf = vty->index;
718e3744 8428 int metric = -1;
8429
7c8ff89e
DS
8430 if (!ospf)
8431 return CMD_SUCCESS;
8432
718e3744 8433 if (!str2metric (argv[0], &metric))
8434 return CMD_WARNING;
8435
68980084 8436 ospf->default_metric = metric;
718e3744 8437
8438 return CMD_SUCCESS;
8439}
8440
8441DEFUN (no_ospf_default_metric,
8442 no_ospf_default_metric_cmd,
8443 "no default-metric",
8444 NO_STR
8445 "Set metric of redistributed routes\n")
8446{
68980084 8447 struct ospf *ospf = vty->index;
8448
7c8ff89e
DS
8449 if (!ospf)
8450 return CMD_SUCCESS;
8451
68980084 8452 ospf->default_metric = -1;
8453
718e3744 8454 return CMD_SUCCESS;
8455}
8456
8457ALIAS (no_ospf_default_metric,
8458 no_ospf_default_metric_val_cmd,
8459 "no default-metric <0-16777214>",
8460 NO_STR
8461 "Set metric of redistributed routes\n"
8462 "Default metric\n")
8463
8464DEFUN (ospf_distance,
8465 ospf_distance_cmd,
8466 "distance <1-255>",
8467 "Define an administrative distance\n"
8468 "OSPF Administrative distance\n")
8469{
68980084 8470 struct ospf *ospf = vty->index;
8471
7c8ff89e
DS
8472 if (!ospf)
8473 return CMD_SUCCESS;
8474
68980084 8475 ospf->distance_all = atoi (argv[0]);
8476
718e3744 8477 return CMD_SUCCESS;
8478}
8479
8480DEFUN (no_ospf_distance,
8481 no_ospf_distance_cmd,
8482 "no distance <1-255>",
8483 NO_STR
8484 "Define an administrative distance\n"
8485 "OSPF Administrative distance\n")
8486{
68980084 8487 struct ospf *ospf = vty->index;
8488
7c8ff89e
DS
8489 if (!ospf)
8490 return CMD_SUCCESS;
8491
68980084 8492 ospf->distance_all = 0;
8493
718e3744 8494 return CMD_SUCCESS;
8495}
8496
8497DEFUN (no_ospf_distance_ospf,
8498 no_ospf_distance_ospf_cmd,
813d4307 8499 "no distance ospf {intra-area <1-255>|inter-area <1-255>|external <1-255>}",
718e3744 8500 NO_STR
8501 "Define an administrative distance\n"
8502 "OSPF Administrative distance\n"
718e3744 8503 "Intra-area routes\n"
813d4307 8504 "Distance for intra-area routes\n"
718e3744 8505 "Inter-area routes\n"
813d4307
DW
8506 "Distance for inter-area routes\n"
8507 "External routes\n"
8508 "Distance for external routes\n")
718e3744 8509{
68980084 8510 struct ospf *ospf = vty->index;
8511
d8f70b86
DS
8512 if (!ospf)
8513 return CMD_SUCCESS;
8514
6f2a6703
CF
8515 if (argc < 3)
8516 return CMD_WARNING;
718e3744 8517
7c8ff89e
DS
8518 if (!ospf)
8519 return CMD_SUCCESS;
8520
6f2a6703
CF
8521 if (argv[0] != NULL)
8522 ospf->distance_intra = 0;
68980084 8523
6f2a6703
CF
8524 if (argv[1] != NULL)
8525 ospf->distance_inter = 0;
68980084 8526
6f2a6703
CF
8527 if (argv[2] != NULL)
8528 ospf->distance_external = 0;
718e3744 8529
6f2a6703
CF
8530 if (argv[0] || argv[1] || argv[2])
8531 return CMD_SUCCESS;
68980084 8532
6f2a6703
CF
8533 /* If no arguments are given, clear all distance information */
8534 ospf->distance_intra = 0;
8535 ospf->distance_inter = 0;
8536 ospf->distance_external = 0;
68980084 8537
718e3744 8538 return CMD_SUCCESS;
8539}
8540
6f2a6703
CF
8541DEFUN (ospf_distance_ospf,
8542 ospf_distance_ospf_cmd,
8543 "distance ospf "
2b053042 8544 "{intra-area <1-255>|inter-area <1-255>|external <1-255>}",
718e3744 8545 "Define an administrative distance\n"
8546 "OSPF Administrative distance\n"
718e3744 8547 "Intra-area routes\n"
8548 "Distance for intra-area routes\n"
718e3744 8549 "Inter-area routes\n"
8550 "Distance for inter-area routes\n"
8551 "External routes\n"
718e3744 8552 "Distance for external routes\n")
8553{
68980084 8554 struct ospf *ospf = vty->index;
8555
d8f70b86
DS
8556 if (!ospf)
8557 return CMD_SUCCESS;
8558
6f2a6703
CF
8559 if (argc < 3) /* should not happen */
8560 return CMD_WARNING;
68980084 8561
6f2a6703
CF
8562 if (!argv[0] && !argv[1] && !argv[2])
8563 {
8564 vty_out(vty, "%% Command incomplete. (Arguments required)%s",
8565 VTY_NEWLINE);
8566 return CMD_WARNING;
8567 }
68980084 8568
6f2a6703
CF
8569 if (argv[0] != NULL)
8570 ospf->distance_intra = atoi(argv[0]);
718e3744 8571
6f2a6703
CF
8572 if (argv[1] != NULL)
8573 ospf->distance_inter = atoi(argv[1]);
68980084 8574
6f2a6703
CF
8575 if (argv[2] != NULL)
8576 ospf->distance_external = atoi(argv[2]);
68980084 8577
718e3744 8578 return CMD_SUCCESS;
8579}
8580
8581DEFUN (ospf_distance_source,
8582 ospf_distance_source_cmd,
8583 "distance <1-255> A.B.C.D/M",
8584 "Administrative distance\n"
8585 "Distance value\n"
8586 "IP source prefix\n")
8587{
020709f9 8588 struct ospf *ospf = vty->index;
8589
7c8ff89e
DS
8590 if (!ospf)
8591 return CMD_SUCCESS;
8592
020709f9 8593 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
68980084 8594
718e3744 8595 return CMD_SUCCESS;
8596}
8597
8598DEFUN (no_ospf_distance_source,
8599 no_ospf_distance_source_cmd,
8600 "no distance <1-255> A.B.C.D/M",
8601 NO_STR
8602 "Administrative distance\n"
8603 "Distance value\n"
8604 "IP source prefix\n")
8605{
020709f9 8606 struct ospf *ospf = vty->index;
8607
7c8ff89e
DS
8608 if (!ospf)
8609 return CMD_SUCCESS;
8610
020709f9 8611 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
8612
718e3744 8613 return CMD_SUCCESS;
8614}
8615
8616DEFUN (ospf_distance_source_access_list,
8617 ospf_distance_source_access_list_cmd,
8618 "distance <1-255> A.B.C.D/M WORD",
8619 "Administrative distance\n"
8620 "Distance value\n"
8621 "IP source prefix\n"
8622 "Access list name\n")
8623{
020709f9 8624 struct ospf *ospf = vty->index;
8625
7c8ff89e
DS
8626 if (!ospf)
8627 return CMD_SUCCESS;
8628
020709f9 8629 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
8630
718e3744 8631 return CMD_SUCCESS;
8632}
8633
8634DEFUN (no_ospf_distance_source_access_list,
8635 no_ospf_distance_source_access_list_cmd,
8636 "no distance <1-255> A.B.C.D/M WORD",
8637 NO_STR
8638 "Administrative distance\n"
8639 "Distance value\n"
8640 "IP source prefix\n"
8641 "Access list name\n")
8642{
020709f9 8643 struct ospf *ospf = vty->index;
8644
7c8ff89e
DS
8645 if (!ospf)
8646 return CMD_SUCCESS;
8647
020709f9 8648 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
8649
718e3744 8650 return CMD_SUCCESS;
8651}
8652
ba682537 8653DEFUN (ip_ospf_mtu_ignore,
8654 ip_ospf_mtu_ignore_addr_cmd,
8655 "ip ospf mtu-ignore A.B.C.D",
8656 "IP Information\n"
8657 "OSPF interface commands\n"
8658 "Disable mtu mismatch detection\n"
8659 "Address of interface")
8660{
8661 struct interface *ifp = vty->index;
8662 struct in_addr addr;
8663 int ret;
8664
8665 struct ospf_if_params *params;
8666 params = IF_DEF_PARAMS (ifp);
8667
8668 if (argc == 1)
8669 {
8670 ret = inet_aton(argv[0], &addr);
8671 if (!ret)
8672 {
8673 vty_out (vty, "Please specify interface address by A.B.C.D%s",
8674 VTY_NEWLINE);
8675 return CMD_WARNING;
8676 }
8677 params = ospf_get_if_params (ifp, addr);
8678 ospf_if_update_params (ifp, addr);
8679 }
8680 params->mtu_ignore = 1;
8681 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
8682 SET_IF_PARAM (params, mtu_ignore);
8683 else
8684 {
8685 UNSET_IF_PARAM (params, mtu_ignore);
8686 if (params != IF_DEF_PARAMS (ifp))
8687 {
8688 ospf_free_if_params (ifp, addr);
8689 ospf_if_update_params (ifp, addr);
8690 }
8691 }
8692 return CMD_SUCCESS;
8693}
8694
8695ALIAS (ip_ospf_mtu_ignore,
8696 ip_ospf_mtu_ignore_cmd,
8697 "ip ospf mtu-ignore",
8698 "IP Information\n"
8699 "OSPF interface commands\n"
8700 "Disable mtu mismatch detection\n")
8701
8702
8703DEFUN (no_ip_ospf_mtu_ignore,
8704 no_ip_ospf_mtu_ignore_addr_cmd,
8705 "no ip ospf mtu-ignore A.B.C.D",
8706 "IP Information\n"
8707 "OSPF interface commands\n"
8708 "Disable mtu mismatch detection\n"
8709 "Address of interface")
8710{
8711 struct interface *ifp = vty->index;
8712 struct in_addr addr;
8713 int ret;
8714
8715 struct ospf_if_params *params;
8716 params = IF_DEF_PARAMS (ifp);
8717
8718 if (argc == 1)
8719 {
8720 ret = inet_aton(argv[0], &addr);
8721 if (!ret)
8722 {
8723 vty_out (vty, "Please specify interface address by A.B.C.D%s",
8724 VTY_NEWLINE);
8725 return CMD_WARNING;
8726 }
8727 params = ospf_get_if_params (ifp, addr);
8728 ospf_if_update_params (ifp, addr);
8729 }
8730 params->mtu_ignore = 0;
8731 if (params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
8732 SET_IF_PARAM (params, mtu_ignore);
8733 else
8734 {
8735 UNSET_IF_PARAM (params, mtu_ignore);
8736 if (params != IF_DEF_PARAMS (ifp))
8737 {
8738 ospf_free_if_params (ifp, addr);
8739 ospf_if_update_params (ifp, addr);
8740 }
8741 }
8742 return CMD_SUCCESS;
8743}
8744
8745ALIAS (no_ip_ospf_mtu_ignore,
8746 no_ip_ospf_mtu_ignore_cmd,
8747 "no ip ospf mtu-ignore",
8748 "IP Information\n"
8749 "OSPF interface commands\n"
8750 "Disable mtu mismatch detection\n")
6b0655a2 8751
88d6cf37 8752DEFUN (ospf_max_metric_router_lsa_admin,
8753 ospf_max_metric_router_lsa_admin_cmd,
8754 "max-metric router-lsa administrative",
8755 "OSPF maximum / infinite-distance metric\n"
8756 "Advertise own Router-LSA with infinite distance (stub router)\n"
8757 "Administratively applied, for an indefinite period\n")
8758{
8759 struct listnode *ln;
8760 struct ospf_area *area;
8761 struct ospf *ospf = vty->index;
ba682537 8762
7c8ff89e
DS
8763 if (!ospf)
8764 return CMD_SUCCESS;
8765
88d6cf37 8766 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
8767 {
8768 SET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
8769
8770 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
c363d386 8771 ospf_router_lsa_update_area (area);
88d6cf37 8772 }
4ba4fc85
AB
8773
8774 /* Allows for areas configured later to get the property */
8775 ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_SET;
8776
88d6cf37 8777 return CMD_SUCCESS;
8778}
8779
8780DEFUN (no_ospf_max_metric_router_lsa_admin,
8781 no_ospf_max_metric_router_lsa_admin_cmd,
8782 "no max-metric router-lsa administrative",
8783 NO_STR
8784 "OSPF maximum / infinite-distance metric\n"
8785 "Advertise own Router-LSA with infinite distance (stub router)\n"
8786 "Administratively applied, for an indefinite period\n")
8787{
8788 struct listnode *ln;
8789 struct ospf_area *area;
8790 struct ospf *ospf = vty->index;
8791
7c8ff89e
DS
8792 if (!ospf)
8793 return CMD_SUCCESS;
8794
88d6cf37 8795 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
8796 {
8797 UNSET_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED);
8798
8799 /* Don't trample on the start-up stub timer */
8800 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED)
8801 && !area->t_stub_router)
8802 {
8803 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
c363d386 8804 ospf_router_lsa_update_area (area);
88d6cf37 8805 }
8806 }
4ba4fc85 8807 ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET;
88d6cf37 8808 return CMD_SUCCESS;
8809}
8810
8811DEFUN (ospf_max_metric_router_lsa_startup,
8812 ospf_max_metric_router_lsa_startup_cmd,
8813 "max-metric router-lsa on-startup <5-86400>",
8814 "OSPF maximum / infinite-distance metric\n"
8815 "Advertise own Router-LSA with infinite distance (stub router)\n"
8816 "Automatically advertise stub Router-LSA on startup of OSPF\n"
8817 "Time (seconds) to advertise self as stub-router\n")
8818{
8819 unsigned int seconds;
8820 struct ospf *ospf = vty->index;
8821
7c8ff89e
DS
8822 if (!ospf)
8823 return CMD_SUCCESS;
8824
88d6cf37 8825 if (argc != 1)
8826 {
8827 vty_out (vty, "%% Must supply stub-router period");
8828 return CMD_WARNING;
8829 }
8830
8831 VTY_GET_INTEGER ("stub-router startup period", seconds, argv[0]);
8832
8833 ospf->stub_router_startup_time = seconds;
8834
8835 return CMD_SUCCESS;
8836}
8837
8838DEFUN (no_ospf_max_metric_router_lsa_startup,
8839 no_ospf_max_metric_router_lsa_startup_cmd,
813d4307 8840 "no max-metric router-lsa on-startup <5-86400>",
88d6cf37 8841 NO_STR
8842 "OSPF maximum / infinite-distance metric\n"
8843 "Advertise own Router-LSA with infinite distance (stub router)\n"
813d4307
DW
8844 "Automatically advertise stub Router-LSA on startup of OSPF\n"
8845 "Time (seconds) to advertise self as stub-router\n")
88d6cf37 8846{
8847 struct listnode *ln;
8848 struct ospf_area *area;
8849 struct ospf *ospf = vty->index;
8850
7c8ff89e
DS
8851 if (!ospf)
8852 return CMD_SUCCESS;
8853
88d6cf37 8854 ospf->stub_router_startup_time = OSPF_STUB_ROUTER_UNCONFIGURED;
8855
8856 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
8857 {
8858 SET_FLAG (area->stub_router_state, OSPF_AREA_WAS_START_STUB_ROUTED);
8859 OSPF_TIMER_OFF (area->t_stub_router);
8860
8861 /* Don't trample on admin stub routed */
8862 if (!CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
8863 {
8864 UNSET_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED);
c363d386 8865 ospf_router_lsa_update_area (area);
88d6cf37 8866 }
8867 }
8868 return CMD_SUCCESS;
8869}
8870
a1afa410
DS
8871ALIAS (no_ospf_max_metric_router_lsa_startup,
8872 no_ospf_max_metric_router_lsa_startup_no_param_cmd,
8873 "no max-metric router-lsa on-startup",
8874 NO_STR
8875 "OSPF maximum / infinite-distance metric\n"
8876 "Advertise own Router-LSA with infinite distance (stub router)\n"
8877 "Automatically advertise stub Router-LSA on startup of OSPF\n");
8878
88d6cf37 8879DEFUN (ospf_max_metric_router_lsa_shutdown,
8880 ospf_max_metric_router_lsa_shutdown_cmd,
804fb5c1 8881 "max-metric router-lsa on-shutdown <5-100>",
88d6cf37 8882 "OSPF maximum / infinite-distance metric\n"
8883 "Advertise own Router-LSA with infinite distance (stub router)\n"
8884 "Advertise stub-router prior to full shutdown of OSPF\n"
8885 "Time (seconds) to wait till full shutdown\n")
8886{
8887 unsigned int seconds;
8888 struct ospf *ospf = vty->index;
8889
7c8ff89e
DS
8890 if (!ospf)
8891 return CMD_SUCCESS;
8892
88d6cf37 8893 if (argc != 1)
8894 {
8895 vty_out (vty, "%% Must supply stub-router shutdown period");
8896 return CMD_WARNING;
8897 }
8898
8899 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds, argv[0]);
8900
8901 ospf->stub_router_shutdown_time = seconds;
8902
8903 return CMD_SUCCESS;
8904}
8905
8906DEFUN (no_ospf_max_metric_router_lsa_shutdown,
8907 no_ospf_max_metric_router_lsa_shutdown_cmd,
813d4307 8908 "no max-metric router-lsa on-shutdown <5-100>",
88d6cf37 8909 NO_STR
8910 "OSPF maximum / infinite-distance metric\n"
8911 "Advertise own Router-LSA with infinite distance (stub router)\n"
813d4307
DW
8912 "Advertise stub-router prior to full shutdown of OSPF\n"
8913 "Time (seconds) to wait till full shutdown\n")
88d6cf37 8914{
8915 struct ospf *ospf = vty->index;
8916
7c8ff89e
DS
8917 if (!ospf)
8918 return CMD_SUCCESS;
8919
88d6cf37 8920 ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
8921
8922 return CMD_SUCCESS;
8923}
8924
a1afa410
DS
8925ALIAS (no_ospf_max_metric_router_lsa_shutdown,
8926 no_ospf_max_metric_router_lsa_shutdown_no_param_cmd,
8927 "no max-metric router-lsa on-shutdown",
8928 NO_STR
8929 "OSPF maximum / infinite-distance metric\n"
8930 "Advertise own Router-LSA with infinite distance (stub router)\n"
8931 "Advertise stub-router prior to full shutdown of OSPF\n");
8932
88d6cf37 8933static void
8934config_write_stub_router (struct vty *vty, struct ospf *ospf)
8935{
8936 struct listnode *ln;
8937 struct ospf_area *area;
8938
8939 if (ospf->stub_router_startup_time != OSPF_STUB_ROUTER_UNCONFIGURED)
8940 vty_out (vty, " max-metric router-lsa on-startup %u%s",
8941 ospf->stub_router_startup_time, VTY_NEWLINE);
8942 if (ospf->stub_router_shutdown_time != OSPF_STUB_ROUTER_UNCONFIGURED)
8943 vty_out (vty, " max-metric router-lsa on-shutdown %u%s",
8944 ospf->stub_router_shutdown_time, VTY_NEWLINE);
8945 for (ALL_LIST_ELEMENTS_RO (ospf->areas, ln, area))
8946 {
8947 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_ADMIN_STUB_ROUTED))
8948 {
8949 vty_out (vty, " max-metric router-lsa administrative%s",
8950 VTY_NEWLINE);
8951 break;
8952 }
8953 }
8954 return;
8955}
6b0655a2 8956
4dadc291 8957static void
718e3744 8958show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
8959{
8960 struct route_node *rn;
8961 struct ospf_route *or;
1eb8ef25 8962 struct listnode *pnode, *pnnode;
718e3744 8963 struct ospf_path *path;
8964
8965 vty_out (vty, "============ OSPF network routing table ============%s",
8966 VTY_NEWLINE);
8967
8968 for (rn = route_top (rt); rn; rn = route_next (rn))
8969 if ((or = rn->info) != NULL)
8970 {
8971 char buf1[19];
8972 snprintf (buf1, 19, "%s/%d",
8973 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
8974
8975 switch (or->path_type)
8976 {
8977 case OSPF_PATH_INTER_AREA:
8978 if (or->type == OSPF_DESTINATION_NETWORK)
8979 vty_out (vty, "N IA %-18s [%d] area: %s%s", buf1, or->cost,
8980 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
8981 else if (or->type == OSPF_DESTINATION_DISCARD)
8982 vty_out (vty, "D IA %-18s Discard entry%s", buf1, VTY_NEWLINE);
8983 break;
8984 case OSPF_PATH_INTRA_AREA:
8985 vty_out (vty, "N %-18s [%d] area: %s%s", buf1, or->cost,
8986 inet_ntoa (or->u.std.area_id), VTY_NEWLINE);
8987 break;
8988 default:
8989 break;
8990 }
8991
8992 if (or->type == OSPF_DESTINATION_NETWORK)
1eb8ef25 8993 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
96735eea 8994 {
a8ba847f 8995 if (if_lookup_by_index(path->ifindex))
96735eea 8996 {
8997 if (path->nexthop.s_addr == 0)
8998 vty_out (vty, "%24s directly attached to %s%s",
a8ba847f 8999 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
96735eea 9000 else
9001 vty_out (vty, "%24s via %s, %s%s", "",
a8ba847f
JT
9002 inet_ntoa (path->nexthop),
9003 ifindex2ifname (path->ifindex), VTY_NEWLINE);
96735eea 9004 }
9005 }
718e3744 9006 }
9007 vty_out (vty, "%s", VTY_NEWLINE);
9008}
9009
4dadc291 9010static void
718e3744 9011show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
9012{
9013 struct route_node *rn;
9014 struct ospf_route *or;
1eb8ef25 9015 struct listnode *pnode;
9016 struct listnode *node;
718e3744 9017 struct ospf_path *path;
9018
9019 vty_out (vty, "============ OSPF router routing table =============%s",
9020 VTY_NEWLINE);
9021 for (rn = route_top (rtrs); rn; rn = route_next (rn))
9022 if (rn->info)
9023 {
9024 int flag = 0;
9025
9026 vty_out (vty, "R %-15s ", inet_ntoa (rn->p.u.prefix4));
9027
1eb8ef25 9028 for (ALL_LIST_ELEMENTS_RO ((struct list *)rn->info, node, or))
9029 {
9030 if (flag++)
9031 vty_out (vty, "%24s", "");
9032
9033 /* Show path. */
9034 vty_out (vty, "%s [%d] area: %s",
9035 (or->path_type == OSPF_PATH_INTER_AREA ? "IA" : " "),
9036 or->cost, inet_ntoa (or->u.std.area_id));
9037 /* Show flags. */
9038 vty_out (vty, "%s%s%s",
9039 (or->u.std.flags & ROUTER_LSA_BORDER ? ", ABR" : ""),
9040 (or->u.std.flags & ROUTER_LSA_EXTERNAL ? ", ASBR" : ""),
9041 VTY_NEWLINE);
9042
9043 for (ALL_LIST_ELEMENTS_RO (or->paths, pnode, path))
9044 {
a8ba847f 9045 if (if_lookup_by_index(path->ifindex))
54bedb55 9046 {
9047 if (path->nexthop.s_addr == 0)
9048 vty_out (vty, "%24s directly attached to %s%s",
a8ba847f
JT
9049 "", ifindex2ifname (path->ifindex),
9050 VTY_NEWLINE);
54bedb55 9051 else
9052 vty_out (vty, "%24s via %s, %s%s", "",
9053 inet_ntoa (path->nexthop),
a8ba847f
JT
9054 ifindex2ifname (path->ifindex),
9055 VTY_NEWLINE);
54bedb55 9056 }
1eb8ef25 9057 }
9058 }
718e3744 9059 }
9060 vty_out (vty, "%s", VTY_NEWLINE);
9061}
9062
4dadc291 9063static void
718e3744 9064show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
9065{
9066 struct route_node *rn;
9067 struct ospf_route *er;
1eb8ef25 9068 struct listnode *pnode, *pnnode;
718e3744 9069 struct ospf_path *path;
9070
9071 vty_out (vty, "============ OSPF external routing table ===========%s",
9072 VTY_NEWLINE);
9073 for (rn = route_top (rt); rn; rn = route_next (rn))
9074 if ((er = rn->info) != NULL)
9075 {
9076 char buf1[19];
9077 snprintf (buf1, 19, "%s/%d",
9078 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen);
9079
9080 switch (er->path_type)
9081 {
9082 case OSPF_PATH_TYPE1_EXTERNAL:
dc9ffce8 9083 vty_out (vty, "N E1 %-18s [%d] tag: %"ROUTE_TAG_PRI"%s", buf1,
718e3744 9084 er->cost, er->u.ext.tag, VTY_NEWLINE);
9085 break;
9086 case OSPF_PATH_TYPE2_EXTERNAL:
dc9ffce8 9087 vty_out (vty, "N E2 %-18s [%d/%d] tag: %"ROUTE_TAG_PRI"%s", buf1, er->cost,
718e3744 9088 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
9089 break;
9090 }
9091
1eb8ef25 9092 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
718e3744 9093 {
a8ba847f 9094 if (if_lookup_by_index(path->ifindex))
718e3744 9095 {
9096 if (path->nexthop.s_addr == 0)
96735eea 9097 vty_out (vty, "%24s directly attached to %s%s",
a8ba847f 9098 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
96735eea 9099 else
9100 vty_out (vty, "%24s via %s, %s%s", "",
a8ba847f
JT
9101 inet_ntoa (path->nexthop),
9102 ifindex2ifname (path->ifindex),
96735eea 9103 VTY_NEWLINE);
718e3744 9104 }
9105 }
9106 }
9107 vty_out (vty, "%s", VTY_NEWLINE);
9108}
9109
7c8ff89e
DS
9110static int
9111show_ip_ospf_border_routers_common (struct vty *vty, struct ospf *ospf)
718e3744 9112{
7c8ff89e
DS
9113 if (ospf->instance)
9114 vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance,
9115 VTY_NEWLINE, VTY_NEWLINE);
718e3744 9116
68980084 9117 if (ospf->new_table == NULL)
718e3744 9118 {
9119 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
9120 return CMD_SUCCESS;
9121 }
9122
9123 /* Show Network routes.
020709f9 9124 show_ip_ospf_route_network (vty, ospf->new_table); */
718e3744 9125
9126 /* Show Router routes. */
68980084 9127 show_ip_ospf_route_router (vty, ospf->new_rtrs);
718e3744 9128
7c8ff89e
DS
9129 vty_out (vty, "%s", VTY_NEWLINE);
9130
718e3744 9131 return CMD_SUCCESS;
9132}
718e3744 9133
7c8ff89e
DS
9134DEFUN (show_ip_ospf_border_routers,
9135 show_ip_ospf_border_routers_cmd,
9136 "show ip ospf border-routers",
718e3744 9137 SHOW_STR
9138 IP_STR
9139 "OSPF information\n"
7c8ff89e 9140 "Show all the ABR's and ASBR's\n")
718e3744 9141{
020709f9 9142 struct ospf *ospf;
68980084 9143
0bad4851 9144 if ((ospf = ospf_lookup ()) == NULL || !ospf->oi_running)
7c8ff89e
DS
9145 return CMD_SUCCESS;
9146
9147 return show_ip_ospf_border_routers_common(vty, ospf);
9148}
9149
9150DEFUN (show_ip_ospf_instance_border_routers,
9151 show_ip_ospf_instance_border_routers_cmd,
9152 "show ip ospf <1-65535> border-routers",
9153 SHOW_STR
9154 IP_STR
9155 "OSPF information\n"
9156 "Instance ID\n"
9157 "Show all the ABR's and ASBR's\n")
9158{
9159 struct ospf *ospf;
9160 u_short instance = 0;
9161
9162 VTY_GET_INTEGER ("Instance", instance, argv[0]);
0bad4851 9163 if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running)
7c8ff89e
DS
9164 return CMD_SUCCESS;
9165
9166 return show_ip_ospf_border_routers_common(vty, ospf);
9167}
9168
9169static int
9170show_ip_ospf_route_common (struct vty *vty, struct ospf *ospf)
9171{
9172 if (ospf->instance)
9173 vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance,
9174 VTY_NEWLINE, VTY_NEWLINE);
718e3744 9175
68980084 9176 if (ospf->new_table == NULL)
718e3744 9177 {
9178 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
9179 return CMD_SUCCESS;
9180 }
9181
9182 /* Show Network routes. */
68980084 9183 show_ip_ospf_route_network (vty, ospf->new_table);
718e3744 9184
9185 /* Show Router routes. */
68980084 9186 show_ip_ospf_route_router (vty, ospf->new_rtrs);
718e3744 9187
9188 /* Show AS External routes. */
68980084 9189 show_ip_ospf_route_external (vty, ospf->old_external_route);
718e3744 9190
7c8ff89e
DS
9191 vty_out (vty, "%s", VTY_NEWLINE);
9192
718e3744 9193 return CMD_SUCCESS;
9194}
9195
7c8ff89e
DS
9196DEFUN (show_ip_ospf_route,
9197 show_ip_ospf_route_cmd,
9198 "show ip ospf route",
9199 SHOW_STR
9200 IP_STR
9201 "OSPF information\n"
9202 "OSPF routing table\n")
9203{
9204 struct ospf *ospf;
9205
0bad4851 9206 if ((ospf = ospf_lookup ()) == NULL || !ospf->oi_running)
7c8ff89e
DS
9207 return CMD_SUCCESS;
9208
9209 return show_ip_ospf_route_common(vty, ospf);
9210}
9211
9212DEFUN (show_ip_ospf_instance_route,
9213 show_ip_ospf_instance_route_cmd,
9214 "show ip ospf <1-65535> route",
9215 SHOW_STR
9216 IP_STR
9217 "OSPF information\n"
9218 "Instance ID\n"
9219 "OSPF routing table\n")
9220{
9221 struct ospf *ospf;
9222 u_short instance = 0;
9223
9224 VTY_GET_INTEGER ("Instance", instance, argv[0]);
0bad4851 9225 if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running)
7c8ff89e
DS
9226 return CMD_SUCCESS;
9227
9228 return show_ip_ospf_route_common(vty, ospf);
9229}
6b0655a2 9230
eb1ce605 9231const char *ospf_abr_type_str[] =
718e3744 9232{
9233 "unknown",
9234 "standard",
9235 "ibm",
9236 "cisco",
9237 "shortcut"
9238};
9239
eb1ce605 9240const char *ospf_shortcut_mode_str[] =
718e3744 9241{
9242 "default",
9243 "enable",
9244 "disable"
9245};
9246
9247
4dadc291 9248static void
718e3744 9249area_id2str (char *buf, int length, struct ospf_area *area)
9250{
9251 memset (buf, 0, length);
9252
9253 if (area->format == OSPF_AREA_ID_FORMAT_ADDRESS)
9254 strncpy (buf, inet_ntoa (area->area_id), length);
9255 else
9256 sprintf (buf, "%lu", (unsigned long) ntohl (area->area_id.s_addr));
9257}
9258
6b0655a2 9259
eb1ce605 9260const char *ospf_int_type_str[] =
718e3744 9261{
9262 "unknown", /* should never be used. */
9263 "point-to-point",
9264 "broadcast",
9265 "non-broadcast",
9266 "point-to-multipoint",
9267 "virtual-link", /* should never be used. */
9268 "loopback"
9269};
9270
9271/* Configuration write function for ospfd. */
4dadc291 9272static int
718e3744 9273config_write_interface (struct vty *vty)
9274{
52dc7ee6 9275 struct listnode *n1, *n2;
718e3744 9276 struct interface *ifp;
9277 struct crypt_key *ck;
9278 int write = 0;
9279 struct route_node *rn = NULL;
9280 struct ospf_if_params *params;
7c8ff89e 9281 struct ospf *ospf = ospf_lookup();
718e3744 9282
b2d7c082 9283 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), n1, ifp))
718e3744 9284 {
718e3744 9285 if (memcmp (ifp->name, "VLINK", 5) == 0)
9286 continue;
9287
84361d61
DS
9288 if (ifp->ifindex == IFINDEX_DELETED)
9289 continue;
9290
718e3744 9291 vty_out (vty, "!%s", VTY_NEWLINE);
9292 vty_out (vty, "interface %s%s", ifp->name,
9293 VTY_NEWLINE);
9294 if (ifp->desc)
9295 vty_out (vty, " description %s%s", ifp->desc,
9296 VTY_NEWLINE);
9297
9298 write++;
9299
9300 params = IF_DEF_PARAMS (ifp);
9301
9302 do {
9303 /* Interface Network print. */
9304 if (OSPF_IF_PARAM_CONFIGURED (params, type) &&
718e3744 9305 params->type != OSPF_IFTYPE_LOOPBACK)
9306 {
bc18d616 9307 if (params->type != ospf_default_iftype(ifp))
7b90143f 9308 {
9309 vty_out (vty, " ip ospf network %s",
9310 ospf_int_type_str[params->type]);
9311 if (params != IF_DEF_PARAMS (ifp))
9312 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
9313 vty_out (vty, "%s", VTY_NEWLINE);
9314 }
718e3744 9315 }
9316
9317 /* OSPF interface authentication print */
9318 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
9319 params->auth_type != OSPF_AUTH_NOTSET)
9320 {
eb1ce605 9321 const char *auth_str;
718e3744 9322
9323 /* Translation tables are not that much help here due to syntax
9324 of the simple option */
9325 switch (params->auth_type)
9326 {
9327
9328 case OSPF_AUTH_NULL:
9329 auth_str = " null";
9330 break;
9331
9332 case OSPF_AUTH_SIMPLE:
9333 auth_str = "";
9334 break;
9335
9336 case OSPF_AUTH_CRYPTOGRAPHIC:
9337 auth_str = " message-digest";
9338 break;
9339
9340 default:
9341 auth_str = "";
9342 break;
9343 }
9344
9345 vty_out (vty, " ip ospf authentication%s", auth_str);
9346 if (params != IF_DEF_PARAMS (ifp))
9347 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
9348 vty_out (vty, "%s", VTY_NEWLINE);
9349 }
9350
9351 /* Simple Authentication Password print. */
9352 if (OSPF_IF_PARAM_CONFIGURED (params, auth_simple) &&
9353 params->auth_simple[0] != '\0')
9354 {
9355 vty_out (vty, " ip ospf authentication-key %s",
9356 params->auth_simple);
9357 if (params != IF_DEF_PARAMS (ifp))
9358 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
9359 vty_out (vty, "%s", VTY_NEWLINE);
9360 }
9361
9362 /* Cryptographic Authentication Key print. */
1eb8ef25 9363 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
718e3744 9364 {
718e3744 9365 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
7c8ff89e 9366 ck->key_id, ck->auth_key);
718e3744 9367 if (params != IF_DEF_PARAMS (ifp))
9368 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
9369 vty_out (vty, "%s", VTY_NEWLINE);
9370 }
9371
9372 /* Interface Output Cost print. */
9373 if (OSPF_IF_PARAM_CONFIGURED (params, output_cost_cmd))
9374 {
9375 vty_out (vty, " ip ospf cost %u", params->output_cost_cmd);
9376 if (params != IF_DEF_PARAMS (ifp))
9377 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
9378 vty_out (vty, "%s", VTY_NEWLINE);
9379 }
9380
9381 /* Hello Interval print. */
9382 if (OSPF_IF_PARAM_CONFIGURED (params, v_hello) &&
9383 params->v_hello != OSPF_HELLO_INTERVAL_DEFAULT)
9384 {
9385 vty_out (vty, " ip ospf hello-interval %u", params->v_hello);
9386 if (params != IF_DEF_PARAMS (ifp))
9387 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
9388 vty_out (vty, "%s", VTY_NEWLINE);
9389 }
9390
9391
9392 /* Router Dead Interval print. */
9393 if (OSPF_IF_PARAM_CONFIGURED (params, v_wait) &&
9394 params->v_wait != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT)
9395 {
f9ad937f 9396 vty_out (vty, " ip ospf dead-interval ");
9397
9398 /* fast hello ? */
9399 if (OSPF_IF_PARAM_CONFIGURED (params, fast_hello))
9400 vty_out (vty, "minimal hello-multiplier %d",
9401 params->fast_hello);
9402 else
9403 vty_out (vty, "%u", params->v_wait);
9404
718e3744 9405 if (params != IF_DEF_PARAMS (ifp))
9406 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
9407 vty_out (vty, "%s", VTY_NEWLINE);
9408 }
9409
9410 /* Router Priority print. */
9411 if (OSPF_IF_PARAM_CONFIGURED (params, priority) &&
9412 params->priority != OSPF_ROUTER_PRIORITY_DEFAULT)
9413 {
9414 vty_out (vty, " ip ospf priority %u", params->priority);
9415 if (params != IF_DEF_PARAMS (ifp))
9416 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
9417 vty_out (vty, "%s", VTY_NEWLINE);
9418 }
9419
9420 /* Retransmit Interval print. */
9421 if (OSPF_IF_PARAM_CONFIGURED (params, retransmit_interval) &&
9422 params->retransmit_interval != OSPF_RETRANSMIT_INTERVAL_DEFAULT)
9423 {
9424 vty_out (vty, " ip ospf retransmit-interval %u",
9425 params->retransmit_interval);
9426 if (params != IF_DEF_PARAMS (ifp))
9427 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
9428 vty_out (vty, "%s", VTY_NEWLINE);
9429 }
9430
9431 /* Transmit Delay print. */
9432 if (OSPF_IF_PARAM_CONFIGURED (params, transmit_delay) &&
9433 params->transmit_delay != OSPF_TRANSMIT_DELAY_DEFAULT)
9434 {
9435 vty_out (vty, " ip ospf transmit-delay %u", params->transmit_delay);
9436 if (params != IF_DEF_PARAMS (ifp))
9437 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
9438 vty_out (vty, "%s", VTY_NEWLINE);
9439 }
9440
953cde65
JT
9441 /* Area print. */
9442 if (OSPF_IF_PARAM_CONFIGURED (params, if_area))
9443 {
9444 if (ospf->instance)
9445 vty_out (vty, " ip ospf %d area %s%s", ospf->instance,
9446 inet_ntoa (params->if_area), VTY_NEWLINE);
9447 else
9448 vty_out (vty, " ip ospf area %s%s",
9449 inet_ntoa (params->if_area), VTY_NEWLINE);
9450
9451 }
9452
d5a5c8f0 9453 /* bfd print. */
7f342629 9454 ospf_bfd_write_config(vty, params);
d5a5c8f0 9455
ba682537 9456 /* MTU ignore print. */
9457 if (OSPF_IF_PARAM_CONFIGURED (params, mtu_ignore) &&
9458 params->mtu_ignore != OSPF_MTU_IGNORE_DEFAULT)
9459 {
9460 if (params->mtu_ignore == 0)
9461 vty_out (vty, " no ip ospf mtu-ignore");
9462 else
9463 vty_out (vty, " ip ospf mtu-ignore");
9464 if (params != IF_DEF_PARAMS (ifp))
9465 vty_out (vty, " %s", inet_ntoa (rn->p.u.prefix4));
9466 vty_out (vty, "%s", VTY_NEWLINE);
9467 }
9468
9469
718e3744 9470 while (1)
9471 {
9472 if (rn == NULL)
9473 rn = route_top (IF_OIFS_PARAMS (ifp));
9474 else
9475 rn = route_next (rn);
9476
9477 if (rn == NULL)
9478 break;
9479 params = rn->info;
9480 if (params != NULL)
9481 break;
9482 }
9483 } while (rn);
9484
718e3744 9485 ospf_opaque_config_write_if (vty, ifp);
718e3744 9486 }
9487
9488 return write;
9489}
9490
4dadc291 9491static int
68980084 9492config_write_network_area (struct vty *vty, struct ospf *ospf)
718e3744 9493{
9494 struct route_node *rn;
9495 u_char buf[INET_ADDRSTRLEN];
9496
9497 /* `network area' print. */
68980084 9498 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
718e3744 9499 if (rn->info)
9500 {
9501 struct ospf_network *n = rn->info;
9502
9503 memset (buf, 0, INET_ADDRSTRLEN);
9504
9505 /* Create Area ID string by specified Area ID format. */
9506 if (n->format == OSPF_AREA_ID_FORMAT_ADDRESS)
c9e52be3 9507 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
718e3744 9508 else
c9e52be3 9509 sprintf ((char *) buf, "%lu",
718e3744 9510 (unsigned long int) ntohl (n->area_id.s_addr));
9511
9512 /* Network print. */
9513 vty_out (vty, " network %s/%d area %s%s",
9514 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
9515 buf, VTY_NEWLINE);
9516 }
9517
9518 return 0;
9519}
9520
4dadc291 9521static int
68980084 9522config_write_ospf_area (struct vty *vty, struct ospf *ospf)
718e3744 9523{
52dc7ee6 9524 struct listnode *node;
1eb8ef25 9525 struct ospf_area *area;
718e3744 9526 u_char buf[INET_ADDRSTRLEN];
9527
9528 /* Area configuration print. */
1eb8ef25 9529 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
718e3744 9530 {
718e3744 9531 struct route_node *rn1;
9532
c9e52be3 9533 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
718e3744 9534
9535 if (area->auth_type != OSPF_AUTH_NULL)
9536 {
9537 if (area->auth_type == OSPF_AUTH_SIMPLE)
9538 vty_out (vty, " area %s authentication%s", buf, VTY_NEWLINE);
9539 else
9540 vty_out (vty, " area %s authentication message-digest%s",
9541 buf, VTY_NEWLINE);
9542 }
9543
9544 if (area->shortcut_configured != OSPF_SHORTCUT_DEFAULT)
9545 vty_out (vty, " area %s shortcut %s%s", buf,
9546 ospf_shortcut_mode_str[area->shortcut_configured],
9547 VTY_NEWLINE);
9548
9549 if ((area->external_routing == OSPF_AREA_STUB)
718e3744 9550 || (area->external_routing == OSPF_AREA_NSSA)
718e3744 9551 )
9552 {
b0a053be 9553 if (area->external_routing == OSPF_AREA_STUB)
9554 vty_out (vty, " area %s stub", buf);
b0a053be 9555 else if (area->external_routing == OSPF_AREA_NSSA)
9556 {
9557 vty_out (vty, " area %s nssa", buf);
9558 switch (area->NSSATranslatorRole)
9559 {
9560 case OSPF_NSSA_ROLE_NEVER:
9561 vty_out (vty, " translate-never");
9562 break;
9563 case OSPF_NSSA_ROLE_ALWAYS:
9564 vty_out (vty, " translate-always");
9565 break;
9566 case OSPF_NSSA_ROLE_CANDIDATE:
9567 default:
9568 vty_out (vty, " translate-candidate");
9569 }
9570 }
718e3744 9571
9572 if (area->no_summary)
9573 vty_out (vty, " no-summary");
9574
9575 vty_out (vty, "%s", VTY_NEWLINE);
9576
9577 if (area->default_cost != 1)
9578 vty_out (vty, " area %s default-cost %d%s", buf,
9579 area->default_cost, VTY_NEWLINE);
9580 }
9581
9582 for (rn1 = route_top (area->ranges); rn1; rn1 = route_next (rn1))
9583 if (rn1->info)
9584 {
9585 struct ospf_area_range *range = rn1->info;
9586
9587 vty_out (vty, " area %s range %s/%d", buf,
9588 inet_ntoa (rn1->p.u.prefix4), rn1->p.prefixlen);
9589
6c835671 9590 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
718e3744 9591 vty_out (vty, " cost %d", range->cost_config);
9592
9593 if (!CHECK_FLAG (range->flags, OSPF_AREA_RANGE_ADVERTISE))
9594 vty_out (vty, " not-advertise");
9595
9596 if (CHECK_FLAG (range->flags, OSPF_AREA_RANGE_SUBSTITUTE))
9597 vty_out (vty, " substitute %s/%d",
9598 inet_ntoa (range->subst_addr), range->subst_masklen);
9599
9600 vty_out (vty, "%s", VTY_NEWLINE);
9601 }
9602
9603 if (EXPORT_NAME (area))
9604 vty_out (vty, " area %s export-list %s%s", buf,
9605 EXPORT_NAME (area), VTY_NEWLINE);
9606
9607 if (IMPORT_NAME (area))
9608 vty_out (vty, " area %s import-list %s%s", buf,
9609 IMPORT_NAME (area), VTY_NEWLINE);
9610
9611 if (PREFIX_NAME_IN (area))
9612 vty_out (vty, " area %s filter-list prefix %s in%s", buf,
9613 PREFIX_NAME_IN (area), VTY_NEWLINE);
9614
9615 if (PREFIX_NAME_OUT (area))
9616 vty_out (vty, " area %s filter-list prefix %s out%s", buf,
9617 PREFIX_NAME_OUT (area), VTY_NEWLINE);
9618 }
9619
9620 return 0;
9621}
9622
4dadc291 9623static int
68980084 9624config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
718e3744 9625{
9626 struct ospf_nbr_nbma *nbr_nbma;
9627 struct route_node *rn;
9628
9629 /* Static Neighbor configuration print. */
68980084 9630 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
718e3744 9631 if ((nbr_nbma = rn->info))
9632 {
9633 vty_out (vty, " neighbor %s", inet_ntoa (nbr_nbma->addr));
9634
9635 if (nbr_nbma->priority != OSPF_NEIGHBOR_PRIORITY_DEFAULT)
9636 vty_out (vty, " priority %d", nbr_nbma->priority);
9637
9638 if (nbr_nbma->v_poll != OSPF_POLL_INTERVAL_DEFAULT)
9639 vty_out (vty, " poll-interval %d", nbr_nbma->v_poll);
9640
9641 vty_out (vty, "%s", VTY_NEWLINE);
9642 }
9643
9644 return 0;
9645}
9646
4dadc291 9647static int
68980084 9648config_write_virtual_link (struct vty *vty, struct ospf *ospf)
718e3744 9649{
52dc7ee6 9650 struct listnode *node;
1eb8ef25 9651 struct ospf_vl_data *vl_data;
718e3744 9652 u_char buf[INET_ADDRSTRLEN];
9653
9654 /* Virtual-Link print */
1eb8ef25 9655 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
718e3744 9656 {
52dc7ee6 9657 struct listnode *n2;
718e3744 9658 struct crypt_key *ck;
718e3744 9659 struct ospf_interface *oi;
9660
9661 if (vl_data != NULL)
9662 {
9663 memset (buf, 0, INET_ADDRSTRLEN);
9664
9665 if (vl_data->format == OSPF_AREA_ID_FORMAT_ADDRESS)
c9e52be3 9666 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
718e3744 9667 else
c9e52be3 9668 sprintf ((char *) buf, "%lu",
718e3744 9669 (unsigned long int) ntohl (vl_data->vl_area_id.s_addr));
9670 oi = vl_data->vl_oi;
9671
9672 /* timers */
9673 if (OSPF_IF_PARAM (oi, v_hello) != OSPF_HELLO_INTERVAL_DEFAULT ||
9674 OSPF_IF_PARAM (oi, v_wait) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT ||
9675 OSPF_IF_PARAM (oi, retransmit_interval) != OSPF_RETRANSMIT_INTERVAL_DEFAULT ||
9676 OSPF_IF_PARAM (oi, transmit_delay) != OSPF_TRANSMIT_DELAY_DEFAULT)
9677 vty_out (vty, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
9678 buf,
9679 inet_ntoa (vl_data->vl_peer),
9680 OSPF_IF_PARAM (oi, v_hello),
9681 OSPF_IF_PARAM (oi, retransmit_interval),
9682 OSPF_IF_PARAM (oi, transmit_delay),
9683 OSPF_IF_PARAM (oi, v_wait),
9684 VTY_NEWLINE);
9685 else
9686 vty_out (vty, " area %s virtual-link %s%s", buf,
9687 inet_ntoa (vl_data->vl_peer), VTY_NEWLINE);
9688 /* Auth key */
9689 if (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple[0] != '\0')
9690 vty_out (vty, " area %s virtual-link %s authentication-key %s%s",
9691 buf,
9692 inet_ntoa (vl_data->vl_peer),
9693 IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_simple,
9694 VTY_NEWLINE);
9695 /* md5 keys */
1eb8ef25 9696 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data->vl_oi->ifp)->auth_crypt,
9697 n2, ck))
9698 vty_out (vty, " area %s virtual-link %s"
9699 " message-digest-key %d md5 %s%s",
9700 buf,
9701 inet_ntoa (vl_data->vl_peer),
9702 ck->key_id, ck->auth_key, VTY_NEWLINE);
718e3744 9703
9704 }
9705 }
9706
9707 return 0;
9708}
9709
6b0655a2 9710
4dadc291 9711static int
68980084 9712config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
718e3744 9713{
9714 int type;
9715
9716 /* redistribute print. */
9717 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
7c8ff89e
DS
9718 {
9719 struct list *red_list;
9720 struct listnode *node;
9721 struct ospf_redist *red;
718e3744 9722
7c8ff89e
DS
9723 red_list = ospf->redist[type];
9724 if (!red_list)
9725 continue;
9726
9727 for (ALL_LIST_ELEMENTS_RO(red_list, node, red))
9728 {
9729 vty_out (vty, " redistribute %s", zebra_route_string(type));
9730 if (red->instance)
9731 vty_out (vty, " %d", red->instance);
9732
9733 if (red->dmetric.value >= 0)
9734 vty_out (vty, " metric %d", red->dmetric.value);
9735
9736 if (red->dmetric.type == EXTERNAL_METRIC_TYPE_1)
9737 vty_out (vty, " metric-type 1");
9738
9739 if (ROUTEMAP_NAME (red))
9740 vty_out (vty, " route-map %s", ROUTEMAP_NAME (red));
9741
9742 vty_out (vty, "%s", VTY_NEWLINE);
9743 }
9744 }
718e3744 9745
9746 return 0;
9747}
9748
4dadc291 9749static int
68980084 9750config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
718e3744 9751{
68980084 9752 if (ospf->default_metric != -1)
9753 vty_out (vty, " default-metric %d%s", ospf->default_metric,
718e3744 9754 VTY_NEWLINE);
9755 return 0;
9756}
9757
4dadc291 9758static int
68980084 9759config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
718e3744 9760{
9761 int type;
7c8ff89e 9762 struct ospf_redist *red;
718e3744 9763
68980084 9764 if (ospf)
718e3744 9765 {
9766 /* distribute-list print. */
9767 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
171c9a99 9768 if (DISTRIBUTE_NAME (ospf, type))
718e3744 9769 vty_out (vty, " distribute-list %s out %s%s",
171c9a99 9770 DISTRIBUTE_NAME (ospf, type),
f52d13cb 9771 zebra_route_string(type), VTY_NEWLINE);
718e3744 9772
9773 /* default-information print. */
68980084 9774 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
718e3744 9775 {
c42c177d 9776 vty_out (vty, " default-information originate");
9777 if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS)
9778 vty_out (vty, " always");
718e3744 9779
7c8ff89e
DS
9780 red = ospf_redist_lookup(ospf, DEFAULT_ROUTE, 0);
9781 if (red)
9782 {
9783 if (red->dmetric.value >= 0)
9784 vty_out (vty, " metric %d",
9785 red->dmetric.value);
9786 if (red->dmetric.type == EXTERNAL_METRIC_TYPE_1)
9787 vty_out (vty, " metric-type 1");
9788
9789 if (ROUTEMAP_NAME (red))
9790 vty_out (vty, " route-map %s",
9791 ROUTEMAP_NAME (red));
9792 }
718e3744 9793
9794 vty_out (vty, "%s", VTY_NEWLINE);
9795 }
9796
9797 }
9798
9799 return 0;
9800}
9801
4dadc291 9802static int
68980084 9803config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
718e3744 9804{
9805 struct route_node *rn;
9806 struct ospf_distance *odistance;
9807
68980084 9808 if (ospf->distance_all)
9809 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
718e3744 9810
68980084 9811 if (ospf->distance_intra
9812 || ospf->distance_inter
9813 || ospf->distance_external)
718e3744 9814 {
9815 vty_out (vty, " distance ospf");
9816
68980084 9817 if (ospf->distance_intra)
9818 vty_out (vty, " intra-area %d", ospf->distance_intra);
9819 if (ospf->distance_inter)
9820 vty_out (vty, " inter-area %d", ospf->distance_inter);
9821 if (ospf->distance_external)
9822 vty_out (vty, " external %d", ospf->distance_external);
718e3744 9823
9824 vty_out (vty, "%s", VTY_NEWLINE);
9825 }
9826
68980084 9827 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
718e3744 9828 if ((odistance = rn->info) != NULL)
9829 {
9830 vty_out (vty, " distance %d %s/%d %s%s", odistance->distance,
9831 inet_ntoa (rn->p.u.prefix4), rn->p.prefixlen,
9832 odistance->access_list ? odistance->access_list : "",
9833 VTY_NEWLINE);
9834 }
9835 return 0;
9836}
9837
9838/* OSPF configuration write function. */
4dadc291 9839static int
718e3744 9840ospf_config_write (struct vty *vty)
9841{
020709f9 9842 struct ospf *ospf;
1eb8ef25 9843 struct interface *ifp;
9844 struct ospf_interface *oi;
52dc7ee6 9845 struct listnode *node;
718e3744 9846 int write = 0;
9847
020709f9 9848 ospf = ospf_lookup ();
0bad4851 9849 if (ospf != NULL && ospf->oi_running)
718e3744 9850 {
9851 /* `router ospf' print. */
7c8ff89e
DS
9852 if (ospf->instance)
9853 vty_out (vty, "router ospf %d%s", ospf->instance, VTY_NEWLINE);
9854 else
9855 vty_out (vty, "router ospf%s", VTY_NEWLINE);
718e3744 9856
9857 write++;
9858
68980084 9859 if (!ospf->networks)
718e3744 9860 return write;
9861
9862 /* Router ID print. */
68980084 9863 if (ospf->router_id_static.s_addr != 0)
718e3744 9864 vty_out (vty, " ospf router-id %s%s",
68980084 9865 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
718e3744 9866
9867 /* ABR type print. */
d57834f6 9868 if (ospf->abr_type != OSPF_ABR_DEFAULT)
718e3744 9869 vty_out (vty, " ospf abr-type %s%s",
68980084 9870 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
718e3744 9871
d7e60dd7
AS
9872 /* log-adjacency-changes flag print. */
9873 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
9874 {
d7e60dd7 9875 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
692c7954 9876 vty_out(vty, " log-adjacency-changes detail%s", VTY_NEWLINE);
8efe88ea
DL
9877 else if (!DFLT_OSPF_LOG_ADJACENCY_CHANGES)
9878 vty_out(vty, " log-adjacency-changes%s", VTY_NEWLINE);
d7e60dd7 9879 }
8efe88ea 9880 else if (DFLT_OSPF_LOG_ADJACENCY_CHANGES)
692c7954
DW
9881 {
9882 vty_out(vty, " no log-adjacency-changes%s", VTY_NEWLINE);
9883 }
d7e60dd7 9884
718e3744 9885 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
68980084 9886 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
718e3744 9887 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
9888
9889 /* auto-cost reference-bandwidth configuration. */
68980084 9890 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
f9ad937f 9891 {
9892 vty_out (vty, "! Important: ensure reference bandwidth "
9893 "is consistent across all routers%s", VTY_NEWLINE);
9894 vty_out (vty, " auto-cost reference-bandwidth %d%s",
70bd3c43 9895 ospf->ref_bandwidth, VTY_NEWLINE);
f9ad937f 9896 }
718e3744 9897
9898 /* SPF timers print. */
68980084 9899 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
ea4ffc90 9900 ospf->spf_holdtime != OSPF_SPF_HOLDTIME_DEFAULT ||
9901 ospf->spf_max_holdtime != OSPF_SPF_MAX_HOLDTIME_DEFAULT)
9902 vty_out (vty, " timers throttle spf %d %d %d%s",
88d6cf37 9903 ospf->spf_delay, ospf->spf_holdtime,
ea4ffc90 9904 ospf->spf_max_holdtime, VTY_NEWLINE);
b6927875
DS
9905
9906 /* LSA timers print. */
ac7424f9
MR
9907 if (ospf->min_ls_interval != OSPF_MIN_LS_INTERVAL)
9908 vty_out (vty, " timers throttle lsa all %d%s",
9909 ospf->min_ls_interval, VTY_NEWLINE);
9910 if (ospf->min_ls_arrival != OSPF_MIN_LS_ARRIVAL)
b6927875 9911 vty_out (vty, " timers lsa min-arrival %d%s",
ac7424f9 9912 ospf->min_ls_arrival, VTY_NEWLINE);
b6927875 9913
2f8f370e 9914 /* Write multiplier print. */
e8f45e82 9915 if (ospf->write_oi_count != OSPF_WRITE_INTERFACE_COUNT_DEFAULT)
2f8f370e 9916 vty_out (vty, " ospf write-multiplier %d%s",
e8f45e82 9917 ospf->write_oi_count, VTY_NEWLINE);
2f8f370e 9918
88d6cf37 9919 /* Max-metric router-lsa print */
9920 config_write_stub_router (vty, ospf);
9921
718e3744 9922 /* SPF refresh parameters print. */
68980084 9923 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
718e3744 9924 vty_out (vty, " refresh timer %d%s",
68980084 9925 ospf->lsa_refresh_interval, VTY_NEWLINE);
718e3744 9926
9927 /* Redistribute information print. */
68980084 9928 config_write_ospf_redistribute (vty, ospf);
718e3744 9929
9930 /* passive-interface print. */
7ffa8fa2
PJ
9931 if (ospf->passive_interface_default == OSPF_IF_PASSIVE)
9932 vty_out (vty, " passive-interface default%s", VTY_NEWLINE);
9933
1eb8ef25 9934 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
7ffa8fa2
PJ
9935 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp), passive_interface)
9936 && IF_DEF_PARAMS (ifp)->passive_interface !=
9937 ospf->passive_interface_default)
9938 {
9939 vty_out (vty, " %spassive-interface %s%s",
9940 IF_DEF_PARAMS (ifp)->passive_interface ? "" : "no ",
9941 ifp->name, VTY_NEWLINE);
9942 }
1eb8ef25 9943 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
7ffa8fa2
PJ
9944 {
9945 if (!OSPF_IF_PARAM_CONFIGURED (oi->params, passive_interface))
9946 continue;
9947 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi->ifp),
9948 passive_interface))
9949 {
9950 if (oi->params->passive_interface == IF_DEF_PARAMS (oi->ifp)->passive_interface)
9951 continue;
9952 }
9953 else if (oi->params->passive_interface == ospf->passive_interface_default)
9954 continue;
9955
9956 vty_out (vty, " %spassive-interface %s %s%s",
9957 oi->params->passive_interface ? "" : "no ",
1eb8ef25 9958 oi->ifp->name,
9959 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
7ffa8fa2 9960 }
718e3744 9961
9962 /* Network area print. */
68980084 9963 config_write_network_area (vty, ospf);
718e3744 9964
9965 /* Area config print. */
68980084 9966 config_write_ospf_area (vty, ospf);
718e3744 9967
9968 /* static neighbor print. */
68980084 9969 config_write_ospf_nbr_nbma (vty, ospf);
718e3744 9970
9971 /* Virtual-Link print. */
68980084 9972 config_write_virtual_link (vty, ospf);
718e3744 9973
9974 /* Default metric configuration. */
68980084 9975 config_write_ospf_default_metric (vty, ospf);
718e3744 9976
9977 /* Distribute-list and default-information print. */
68980084 9978 config_write_ospf_distribute (vty, ospf);
718e3744 9979
9980 /* Distance configuration. */
68980084 9981 config_write_ospf_distance (vty, ospf);
718e3744 9982
68980084 9983 ospf_opaque_config_write_router (vty, ospf);
718e3744 9984 }
9985
9986 return write;
9987}
9988
9989void
4dadc291 9990ospf_vty_show_init (void)
718e3744 9991{
9992 /* "show ip ospf" commands. */
9993 install_element (VIEW_NODE, &show_ip_ospf_cmd);
718e3744 9994
7c8ff89e 9995 install_element (VIEW_NODE, &show_ip_ospf_instance_cmd);
7c8ff89e 9996
718e3744 9997 /* "show ip ospf database" commands. */
9998 install_element (VIEW_NODE, &show_ip_ospf_database_type_cmd);
9999 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_cmd);
10000 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_adv_router_cmd);
10001 install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd);
10002 install_element (VIEW_NODE, &show_ip_ospf_database_type_id_self_cmd);
10003 install_element (VIEW_NODE, &show_ip_ospf_database_type_self_cmd);
10004 install_element (VIEW_NODE, &show_ip_ospf_database_cmd);
718e3744 10005
7c8ff89e
DS
10006 install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_cmd);
10007 install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_id_cmd);
10008 install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_id_adv_router_cmd);
10009 install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_adv_router_cmd);
10010 install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_id_self_cmd);
10011 install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_self_cmd);
10012 install_element (VIEW_NODE, &show_ip_ospf_instance_database_cmd);
7c8ff89e 10013
718e3744 10014 /* "show ip ospf interface" commands. */
10015 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
718e3744 10016
7c8ff89e 10017 install_element (VIEW_NODE, &show_ip_ospf_instance_interface_cmd);
7c8ff89e 10018
718e3744 10019 /* "show ip ospf neighbor" commands. */
10020 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_detail_cmd);
10021 install_element (VIEW_NODE, &show_ip_ospf_neighbor_int_cmd);
10022 install_element (VIEW_NODE, &show_ip_ospf_neighbor_id_cmd);
10023 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_all_cmd);
10024 install_element (VIEW_NODE, &show_ip_ospf_neighbor_detail_cmd);
10025 install_element (VIEW_NODE, &show_ip_ospf_neighbor_cmd);
10026 install_element (VIEW_NODE, &show_ip_ospf_neighbor_all_cmd);
718e3744 10027
7c8ff89e
DS
10028 install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_int_detail_cmd);
10029 install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_int_cmd);
10030 install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_id_cmd);
10031 install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_detail_all_cmd);
10032 install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_detail_cmd);
10033 install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_cmd);
10034 install_element (VIEW_NODE, &show_ip_ospf_instance_neighbor_all_cmd);
7c8ff89e 10035
718e3744 10036 /* "show ip ospf route" commands. */
10037 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
718e3744 10038 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
7c8ff89e
DS
10039
10040 install_element (VIEW_NODE, &show_ip_ospf_instance_route_cmd);
7c8ff89e 10041 install_element (VIEW_NODE, &show_ip_ospf_instance_border_routers_cmd);
718e3744 10042}
10043
6b0655a2 10044
718e3744 10045/* ospfd's interface node. */
7fc626de 10046static struct cmd_node interface_node =
718e3744 10047{
10048 INTERFACE_NODE,
10049 "%s(config-if)# ",
10050 1
10051};
10052
10053/* Initialization of OSPF interface. */
4dadc291 10054static void
10055ospf_vty_if_init (void)
718e3744 10056{
10057 /* Install interface node. */
10058 install_node (&interface_node, config_write_interface);
10059
10060 install_element (CONFIG_NODE, &interface_cmd);
32d2463c 10061 install_element (CONFIG_NODE, &no_interface_cmd);
718e3744 10062 install_default (INTERFACE_NODE);
10063
10064 /* "description" commands. */
10065 install_element (INTERFACE_NODE, &interface_desc_cmd);
10066 install_element (INTERFACE_NODE, &no_interface_desc_cmd);
10067
10068 /* "ip ospf authentication" commands. */
10069 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_addr_cmd);
10070 install_element (INTERFACE_NODE, &ip_ospf_authentication_args_cmd);
10071 install_element (INTERFACE_NODE, &ip_ospf_authentication_addr_cmd);
10072 install_element (INTERFACE_NODE, &ip_ospf_authentication_cmd);
b4a039bf
DS
10073 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_args_addr_cmd);
10074 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_args_cmd);
718e3744 10075 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_addr_cmd);
10076 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_cmd);
10077 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_addr_cmd);
10078 install_element (INTERFACE_NODE, &ip_ospf_authentication_key_cmd);
813d4307
DW
10079 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_authkey_addr_cmd);
10080 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_authkey_cmd);
718e3744 10081 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_key_cmd);
10082
10083 /* "ip ospf message-digest-key" commands. */
10084 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_addr_cmd);
10085 install_element (INTERFACE_NODE, &ip_ospf_message_digest_key_cmd);
10086 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_addr_cmd);
10087 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_cmd);
813d4307
DW
10088 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_md5_addr_cmd);
10089 install_element (INTERFACE_NODE, &no_ip_ospf_message_digest_key_md5_cmd);
718e3744 10090
10091 /* "ip ospf cost" commands. */
9eff36b3
DO
10092 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_inet4_cmd);
10093 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_cmd);
827341b7
DO
10094 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_cmd);
10095 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_inet4_cmd);
9eff36b3 10096 install_element (INTERFACE_NODE, &no_ip_ospf_cost_inet4_cmd);
718e3744 10097 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
10098
ba682537 10099 /* "ip ospf mtu-ignore" commands. */
10100 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_addr_cmd);
10101 install_element (INTERFACE_NODE, &ip_ospf_mtu_ignore_cmd);
10102 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_addr_cmd);
10103 install_element (INTERFACE_NODE, &no_ip_ospf_mtu_ignore_cmd);
10104
718e3744 10105 /* "ip ospf dead-interval" commands. */
10106 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_addr_cmd);
10107 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_cmd);
f9ad937f 10108 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
10109 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
718e3744 10110 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
10111 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
f9dfba8d 10112 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_seconds_cmd);
f9ad937f 10113
718e3744 10114 /* "ip ospf hello-interval" commands. */
10115 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_addr_cmd);
10116 install_element (INTERFACE_NODE, &ip_ospf_hello_interval_cmd);
10117 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_addr_cmd);
10118 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_cmd);
f9dfba8d 10119 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_seconds_cmd);
718e3744 10120
10121 /* "ip ospf network" commands. */
10122 install_element (INTERFACE_NODE, &ip_ospf_network_cmd);
10123 install_element (INTERFACE_NODE, &no_ip_ospf_network_cmd);
813d4307 10124 install_element (INTERFACE_NODE, &no_ip_ospf_network_val_cmd);
718e3744 10125
10126 /* "ip ospf priority" commands. */
10127 install_element (INTERFACE_NODE, &ip_ospf_priority_addr_cmd);
10128 install_element (INTERFACE_NODE, &ip_ospf_priority_cmd);
718e3744 10129 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
a1afa410 10130 install_element (INTERFACE_NODE, &no_ip_ospf_priority_no_param_cmd);
813d4307 10131 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
718e3744 10132
10133 /* "ip ospf retransmit-interval" commands. */
10134 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_addr_cmd);
10135 install_element (INTERFACE_NODE, &ip_ospf_retransmit_interval_cmd);
10136 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_addr_cmd);
10137 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_cmd);
813d4307
DW
10138 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_sec_addr_cmd);
10139 install_element (INTERFACE_NODE, &no_ip_ospf_retransmit_interval_sec_cmd);
718e3744 10140
10141 /* "ip ospf transmit-delay" commands. */
10142 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_addr_cmd);
10143 install_element (INTERFACE_NODE, &ip_ospf_transmit_delay_cmd);
10144 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_addr_cmd);
10145 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_cmd);
813d4307
DW
10146 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_sec_addr_cmd);
10147 install_element (INTERFACE_NODE, &no_ip_ospf_transmit_delay_sec_cmd);
718e3744 10148
953cde65
JT
10149 /* "ip ospf area" commands. */
10150 install_element (INTERFACE_NODE, &ip_ospf_area_cmd);
10151 install_element (INTERFACE_NODE, &no_ip_ospf_area_cmd);
10152 install_element (INTERFACE_NODE, &no_ip_ospf_area_val_cmd);
10153 install_element (INTERFACE_NODE, &ip_ospf_instance_area_cmd);
10154 install_element (INTERFACE_NODE, &no_ip_ospf_instance_area_cmd);
10155 install_element (INTERFACE_NODE, &no_ip_ospf_instance_area_val_cmd);
10156
718e3744 10157 /* These commands are compatibitliy for previous version. */
10158 install_element (INTERFACE_NODE, &ospf_authentication_key_cmd);
10159 install_element (INTERFACE_NODE, &no_ospf_authentication_key_cmd);
813d4307
DW
10160 install_element (INTERFACE_NODE, &no_ospf_authentication_key_authkey_cmd);
10161 install_element (INTERFACE_NODE, &no_ospf_authentication_key_authkey_ip_cmd);
718e3744 10162 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
10163 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
9eff36b3
DO
10164 install_element (INTERFACE_NODE, &ospf_cost_u32_cmd);
10165 install_element (INTERFACE_NODE, &ospf_cost_u32_inet4_cmd);
718e3744 10166 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
827341b7
DO
10167 install_element (INTERFACE_NODE, &no_ospf_cost_u32_cmd);
10168 install_element (INTERFACE_NODE, &no_ospf_cost_u32_inet4_cmd);
9eff36b3 10169 install_element (INTERFACE_NODE, &no_ospf_cost_inet4_cmd);
718e3744 10170 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
10171 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
813d4307
DW
10172 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_minimal_addr_cmd);
10173 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_minimal_cmd);
718e3744 10174 install_element (INTERFACE_NODE, &ospf_hello_interval_cmd);
10175 install_element (INTERFACE_NODE, &no_ospf_hello_interval_cmd);
10176 install_element (INTERFACE_NODE, &ospf_network_cmd);
10177 install_element (INTERFACE_NODE, &no_ospf_network_cmd);
813d4307 10178 install_element (INTERFACE_NODE, &no_ospf_network_val_cmd);
718e3744 10179 install_element (INTERFACE_NODE, &ospf_priority_cmd);
10180 install_element (INTERFACE_NODE, &no_ospf_priority_cmd);
10181 install_element (INTERFACE_NODE, &ospf_retransmit_interval_cmd);
10182 install_element (INTERFACE_NODE, &no_ospf_retransmit_interval_cmd);
10183 install_element (INTERFACE_NODE, &ospf_transmit_delay_cmd);
10184 install_element (INTERFACE_NODE, &no_ospf_transmit_delay_cmd);
10185}
10186
4dadc291 10187static void
10188ospf_vty_zebra_init (void)
718e3744 10189{
718e3744 10190 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
718e3744 10191 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
7c8ff89e
DS
10192 install_element (OSPF_NODE, &ospf_redistribute_instance_source_cmd);
10193 install_element (OSPF_NODE, &no_ospf_redistribute_instance_source_cmd);
718e3744 10194
10195 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
10196 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
10197
718e3744 10198 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
718e3744 10199 install_element (OSPF_NODE, &no_ospf_default_information_originate_cmd);
10200
10201 install_element (OSPF_NODE, &ospf_default_metric_cmd);
10202 install_element (OSPF_NODE, &no_ospf_default_metric_cmd);
10203 install_element (OSPF_NODE, &no_ospf_default_metric_val_cmd);
10204
10205 install_element (OSPF_NODE, &ospf_distance_cmd);
10206 install_element (OSPF_NODE, &no_ospf_distance_cmd);
10207 install_element (OSPF_NODE, &no_ospf_distance_ospf_cmd);
6f2a6703 10208 install_element (OSPF_NODE, &ospf_distance_ospf_cmd);
718e3744 10209#if 0
10210 install_element (OSPF_NODE, &ospf_distance_source_cmd);
10211 install_element (OSPF_NODE, &no_ospf_distance_source_cmd);
10212 install_element (OSPF_NODE, &ospf_distance_source_access_list_cmd);
10213 install_element (OSPF_NODE, &no_ospf_distance_source_access_list_cmd);
10214#endif /* 0 */
10215}
10216
7fc626de 10217static struct cmd_node ospf_node =
718e3744 10218{
10219 OSPF_NODE,
10220 "%s(config-router)# ",
10221 1
10222};
10223
09f35f8c
DS
10224static void
10225ospf_interface_clear (struct interface *ifp)
10226{
10227 if (!if_is_operative (ifp)) return;
10228
10229 if (IS_DEBUG_OSPF (ism, ISM_EVENTS))
10230 zlog (NULL, LOG_DEBUG, "ISM[%s]: clear by reset", ifp->name);
10231
10232 ospf_if_reset(ifp);
10233}
10234
10235DEFUN (clear_ip_ospf_interface,
10236 clear_ip_ospf_interface_cmd,
10237 "clear ip ospf interface [IFNAME]",
10238 CLEAR_STR
10239 IP_STR
10240 "OSPF information\n"
10241 "Interface information\n"
10242 "Interface name\n")
10243{
10244 struct interface *ifp;
10245 struct listnode *node;
10246
10247 if (argc == 0) /* Clear all the ospfv2 interfaces. */
10248 {
b2d7c082 10249 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp))
09f35f8c
DS
10250 ospf_interface_clear(ifp);
10251 }
10252 else /* Interface name is specified. */
10253 {
10254 if ((ifp = if_lookup_by_name (argv[0])) == NULL)
10255 vty_out (vty, "No such interface name%s", VTY_NEWLINE);
10256 else
10257 ospf_interface_clear(ifp);
10258 }
10259
10260 return CMD_SUCCESS;
10261}
10262
10263void
10264ospf_vty_clear_init (void)
10265{
10266 install_element (ENABLE_NODE, &clear_ip_ospf_interface_cmd);
10267}
10268
6b0655a2 10269
718e3744 10270/* Install OSPF related vty commands. */
10271void
4dadc291 10272ospf_vty_init (void)
718e3744 10273{
10274 /* Install ospf top node. */
10275 install_node (&ospf_node, ospf_config_write);
10276
10277 /* "router ospf" commands. */
10278 install_element (CONFIG_NODE, &router_ospf_cmd);
10279 install_element (CONFIG_NODE, &no_router_ospf_cmd);
10280
7c8ff89e
DS
10281 install_element (CONFIG_NODE, &router_ospf_instance_cmd);
10282 install_element (CONFIG_NODE, &no_router_ospf_instance_cmd);
10283
718e3744 10284 install_default (OSPF_NODE);
10285
10286 /* "ospf router-id" commands. */
10287 install_element (OSPF_NODE, &ospf_router_id_cmd);
747e489c 10288 install_element (OSPF_NODE, &ospf_router_id_old_cmd);
718e3744 10289 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
12fde75b 10290 install_element (OSPF_NODE, &no_ospf_router_id_val_cmd);
718e3744 10291
10292 /* "passive-interface" commands. */
a2c62831 10293 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
10294 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
7ffa8fa2 10295 install_element (OSPF_NODE, &ospf_passive_interface_default_cmd);
a2c62831 10296 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
10297 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
7ffa8fa2 10298 install_element (OSPF_NODE, &no_ospf_passive_interface_default_cmd);
718e3744 10299
10300 /* "ospf abr-type" commands. */
10301 install_element (OSPF_NODE, &ospf_abr_type_cmd);
10302 install_element (OSPF_NODE, &no_ospf_abr_type_cmd);
10303
d7e60dd7
AS
10304 /* "ospf log-adjacency-changes" commands. */
10305 install_element (OSPF_NODE, &ospf_log_adjacency_changes_cmd);
10306 install_element (OSPF_NODE, &ospf_log_adjacency_changes_detail_cmd);
10307 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_cmd);
10308 install_element (OSPF_NODE, &no_ospf_log_adjacency_changes_detail_cmd);
10309
718e3744 10310 /* "ospf rfc1583-compatible" commands. */
10311 install_element (OSPF_NODE, &ospf_rfc1583_flag_cmd);
10312 install_element (OSPF_NODE, &no_ospf_rfc1583_flag_cmd);
10313 install_element (OSPF_NODE, &ospf_compatible_rfc1583_cmd);
10314 install_element (OSPF_NODE, &no_ospf_compatible_rfc1583_cmd);
10315
10316 /* "network area" commands. */
a2c62831 10317 install_element (OSPF_NODE, &ospf_network_area_cmd);
10318 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
718e3744 10319
10320 /* "area authentication" commands. */
a2c62831 10321 install_element (OSPF_NODE, &ospf_area_authentication_message_digest_cmd);
10322 install_element (OSPF_NODE, &ospf_area_authentication_cmd);
10323 install_element (OSPF_NODE, &no_ospf_area_authentication_cmd);
718e3744 10324
10325 /* "area range" commands. */
a2c62831 10326 install_element (OSPF_NODE, &ospf_area_range_cmd);
10327 install_element (OSPF_NODE, &ospf_area_range_advertise_cmd);
10328 install_element (OSPF_NODE, &ospf_area_range_cost_cmd);
10329 install_element (OSPF_NODE, &ospf_area_range_advertise_cost_cmd);
10330 install_element (OSPF_NODE, &ospf_area_range_not_advertise_cmd);
10331 install_element (OSPF_NODE, &no_ospf_area_range_cmd);
10332 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cmd);
10333 install_element (OSPF_NODE, &no_ospf_area_range_cost_cmd);
10334 install_element (OSPF_NODE, &no_ospf_area_range_advertise_cost_cmd);
10335 install_element (OSPF_NODE, &ospf_area_range_substitute_cmd);
10336 install_element (OSPF_NODE, &no_ospf_area_range_substitute_cmd);
718e3744 10337
10338 /* "area virtual-link" commands. */
a2c62831 10339 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
10340 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
718e3744 10341
a2c62831 10342 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
10343 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
718e3744 10344
a2c62831 10345 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
10346 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
718e3744 10347
a2c62831 10348 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
10349 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
718e3744 10350
a2c62831 10351 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
10352 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
718e3744 10353
a2c62831 10354 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
813d4307 10355 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_args_cmd);
a2c62831 10356 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
10357 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
718e3744 10358
a2c62831 10359 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
10360 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
718e3744 10361
a2c62831 10362 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
10363 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
718e3744 10364
a2c62831 10365 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
813d4307 10366 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_args_authkey_cmd);
a2c62831 10367 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
10368 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
718e3744 10369
a2c62831 10370 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
813d4307 10371 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_args_md5_cmd);
a2c62831 10372 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
10373 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
718e3744 10374
10375 /* "area stub" commands. */
a2c62831 10376 install_element (OSPF_NODE, &ospf_area_stub_no_summary_cmd);
10377 install_element (OSPF_NODE, &ospf_area_stub_cmd);
10378 install_element (OSPF_NODE, &no_ospf_area_stub_no_summary_cmd);
10379 install_element (OSPF_NODE, &no_ospf_area_stub_cmd);
718e3744 10380
718e3744 10381 /* "area nssa" commands. */
a2c62831 10382 install_element (OSPF_NODE, &ospf_area_nssa_cmd);
10383 install_element (OSPF_NODE, &ospf_area_nssa_translate_no_summary_cmd);
10384 install_element (OSPF_NODE, &ospf_area_nssa_translate_cmd);
10385 install_element (OSPF_NODE, &ospf_area_nssa_no_summary_cmd);
10386 install_element (OSPF_NODE, &no_ospf_area_nssa_cmd);
10387 install_element (OSPF_NODE, &no_ospf_area_nssa_no_summary_cmd);
718e3744 10388
a2c62831 10389 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
10390 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
718e3744 10391
a2c62831 10392 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
10393 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
718e3744 10394
a2c62831 10395 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
10396 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
718e3744 10397
a2c62831 10398 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
10399 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
718e3744 10400
a2c62831 10401 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
10402 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
88d6cf37 10403
10404 /* SPF timer commands */
d24f6e2a 10405 install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
10406 install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
b4a039bf 10407 install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_val_cmd);
d24f6e2a 10408
b6927875 10409 /* LSA timers commands */
ac7424f9
MR
10410 install_element (OSPF_NODE, &ospf_timers_min_ls_interval_cmd);
10411 install_element (OSPF_NODE, &no_ospf_timers_min_ls_interval_cmd);
813d4307 10412 install_element (OSPF_NODE, &no_ospf_timers_min_ls_interval_val_cmd);
ac7424f9
MR
10413 install_element (OSPF_NODE, &ospf_timers_min_ls_arrival_cmd);
10414 install_element (OSPF_NODE, &no_ospf_timers_min_ls_arrival_cmd);
813d4307 10415 install_element (OSPF_NODE, &no_ospf_timers_min_ls_arrival_val_cmd);
b6927875
DS
10416 install_element (OSPF_NODE, &ospf_timers_lsa_cmd);
10417 install_element (OSPF_NODE, &no_ospf_timers_lsa_cmd);
10418 install_element (OSPF_NODE, &no_ospf_timers_lsa_val_cmd);
10419
88d6cf37 10420 /* refresh timer commands */
a2c62831 10421 install_element (OSPF_NODE, &ospf_refresh_timer_cmd);
10422 install_element (OSPF_NODE, &no_ospf_refresh_timer_val_cmd);
10423 install_element (OSPF_NODE, &no_ospf_refresh_timer_cmd);
718e3744 10424
88d6cf37 10425 /* max-metric commands */
10426 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_admin_cmd);
10427 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_admin_cmd);
10428 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_startup_cmd);
10429 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_cmd);
a1afa410 10430 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_no_param_cmd);
88d6cf37 10431 install_element (OSPF_NODE, &ospf_max_metric_router_lsa_shutdown_cmd);
10432 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_cmd);
a1afa410 10433 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_no_param_cmd);
88d6cf37 10434
10435 /* reference bandwidth commands */
a2c62831 10436 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
10437 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
813d4307 10438 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_val_cmd);
718e3744 10439
10440 /* "neighbor" commands. */
a2c62831 10441 install_element (OSPF_NODE, &ospf_neighbor_cmd);
10442 install_element (OSPF_NODE, &ospf_neighbor_priority_poll_interval_cmd);
10443 install_element (OSPF_NODE, &ospf_neighbor_priority_cmd);
10444 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_cmd);
10445 install_element (OSPF_NODE, &ospf_neighbor_poll_interval_priority_cmd);
10446 install_element (OSPF_NODE, &no_ospf_neighbor_cmd);
10447 install_element (OSPF_NODE, &no_ospf_neighbor_priority_cmd);
10448 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_cmd);
813d4307
DW
10449 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_priority_cmd);
10450 install_element (OSPF_NODE, &no_ospf_neighbor_priority_pollinterval_cmd);
718e3744 10451
2f8f370e
DS
10452 /* write multiplier commands */
10453 install_element (OSPF_NODE, &ospf_write_multiplier_cmd);
10454 install_element (OSPF_NODE, &no_ospf_write_multiplier_cmd);
e8f45e82
DS
10455 install_element (OSPF_NODE, &write_multiplier_cmd);
10456 install_element (OSPF_NODE, &no_write_multiplier_cmd);
813d4307 10457 install_element (OSPF_NODE, &no_write_multiplier_val_cmd);
2f8f370e 10458
718e3744 10459 /* Init interface related vty commands. */
10460 ospf_vty_if_init ();
10461
10462 /* Init zebra related vty commands. */
10463 ospf_vty_zebra_init ();
10464}