]> git.proxmox.com Git - mirror_frr.git/blob - ospfd/ospf_vty.c
Merge pull request #299 from opensourcerouting/test-ref-out
[mirror_frr.git] / ospfd / ospf_vty.c
1 /* OSPF VTY interface.
2 * Copyright (C) 2005 6WIND <alain.ritoux@6wind.com>
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>
24 #include <lib/json.h>
25 #include <string.h>
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"
36 #include "defaults.h"
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"
54 #include "ospfd/ospf_bfd.h"
55
56 static const char *ospf_network_type_str[] =
57 {
58 "Null",
59 "POINTOPOINT",
60 "BROADCAST",
61 "NBMA",
62 "POINTOMULTIPOINT",
63 "VIRTUALLINK",
64 "LOOPBACK"
65 };
66
67 /* Utility functions. */
68 int
69 ospf_str2area_id (const char *str, struct in_addr *area_id, int *format)
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 {
85 if (*str == '-')
86 return -1;
87 errno = 0;
88 ret = strtoul (str, &endptr, 10);
89 if (*endptr != '\0' || errno || ret > UINT32_MAX)
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
99
100 static int
101 str2metric (const char *str, int *metric)
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
117 static int
118 str2metric_type (const char *str, int *metric_type)
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
134 int
135 ospf_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
147
148 DEFUN (router_ospf,
149 router_ospf_cmd,
150 "router ospf",
151 "Enable a routing process\n"
152 "Start OSPF configuration\n")
153 {
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
164 vty->node = OSPF_NODE;
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
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 }
181
182 return CMD_SUCCESS;
183 }
184
185 ALIAS (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
192 DEFUN (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 {
199 struct ospf *ospf;
200 u_short instance = 0;
201
202 if (argc)
203 VTY_GET_INTEGER ("Instance", instance, argv[0]);
204
205 if ((ospf = ospf_lookup_instance (instance)) == NULL)
206 return CMD_SUCCESS;
207
208 ospf_finish (ospf);
209
210 return CMD_SUCCESS;
211 }
212
213 ALIAS (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
221 DEFUN (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 {
228 struct ospf *ospf = vty->index;
229 struct listnode *node;
230 struct ospf_area *area;
231 struct in_addr router_id;
232 int ret;
233
234 if (!ospf)
235 return CMD_SUCCESS;
236
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
244 ospf->router_id_static = router_id;
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
254 ospf_router_id_update (ospf);
255
256 return CMD_SUCCESS;
257 }
258
259 ALIAS_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
265 DEFUN (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 {
272 struct ospf *ospf = vty->index;
273 struct listnode *node;
274 struct ospf_area *area;
275
276 if (!ospf)
277 return CMD_SUCCESS;
278
279 ospf->router_id_static.s_addr = 0;
280
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
289 ospf_router_id_update (ospf);
290
291 return CMD_SUCCESS;
292 }
293
294 ALIAS (no_ospf_router_id,
295 no_ospf_router_id_val_cmd,
296 "no ospf router-id A.B.C.D",
297 NO_STR
298 "OSPF specific commands\n"
299 "router-id for the OSPF process\n"
300 "OSPF router-id in IP address format\n")
301
302 static void
303 ospf_passive_interface_default (struct ospf *ospf, u_char newval)
304 {
305 struct listnode *ln;
306 struct interface *ifp;
307 struct ospf_interface *oi;
308
309 ospf->passive_interface_default = newval;
310
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);
321 /* update multicast memberships */
322 ospf_if_set_multicast(oi);
323 }
324 }
325
326 static void
327 ospf_passive_interface_update_addr (struct ospf *ospf, struct interface *ifp,
328 struct ospf_if_params *params, u_char value,
329 struct in_addr addr)
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 }
349 }
350
351 static void
352 ospf_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))
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
365 DEFUN (ospf_passive_interface,
366 ospf_passive_interface_addr_cmd,
367 "passive-interface IFNAME A.B.C.D",
368 "Suppress routing updates on an interface\n"
369 "Interface's name\n")
370 {
371 struct interface *ifp;
372 struct in_addr addr = { .s_addr = INADDR_ANY };
373 int ret;
374 struct ospf_if_params *params;
375 struct route_node *rn;
376 struct ospf *ospf = vty->index;
377
378 if (!ospf)
379 return CMD_SUCCESS;
380
381 if (argc == 0)
382 {
383 ospf_passive_interface_default (ospf, OSPF_IF_PASSIVE);
384 return CMD_SUCCESS;
385 }
386
387 ifp = if_get_by_name (argv[0]);
388
389 params = IF_DEF_PARAMS (ifp);
390
391 if (argc == 2)
392 {
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);
403 ospf_passive_interface_update_addr (ospf, ifp, params,
404 OSPF_IF_PASSIVE, addr);
405 }
406
407 ospf_passive_interface_update (ospf, ifp, params, OSPF_IF_PASSIVE);
408
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 */
416
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))
422 ospf_if_set_multicast(oi);
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
431 return CMD_SUCCESS;
432 }
433
434 ALIAS (ospf_passive_interface,
435 ospf_passive_interface_cmd,
436 "passive-interface IFNAME",
437 "Suppress routing updates on an interface\n"
438 "Interface's name\n")
439
440 ALIAS (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
446 DEFUN (no_ospf_passive_interface,
447 no_ospf_passive_interface_addr_cmd,
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;
454 struct in_addr addr = { .s_addr = INADDR_ANY };
455 struct ospf_if_params *params;
456 int ret;
457 struct route_node *rn;
458 struct ospf *ospf = vty->index;
459
460 if (!ospf)
461 return CMD_SUCCESS;
462
463 if (argc == 0)
464 {
465 ospf_passive_interface_default (ospf, OSPF_IF_ACTIVE);
466 return CMD_SUCCESS;
467 }
468
469 ifp = if_get_by_name (argv[0]);
470
471 params = IF_DEF_PARAMS (ifp);
472
473 if (argc == 2)
474 {
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;
486 ospf_passive_interface_update_addr (ospf, ifp, params, OSPF_IF_ACTIVE,
487 addr);
488 }
489 ospf_passive_interface_update (ospf, ifp, params, OSPF_IF_ACTIVE);
490
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
506 return CMD_SUCCESS;
507 }
508
509 ALIAS (no_ospf_passive_interface,
510 no_ospf_passive_interface_cmd,
511 "no passive-interface IFNAME",
512 NO_STR
513 "Allow routing updates on an interface\n"
514 "Interface's name\n")
515
516 ALIAS (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
523 DEFUN (ospf_network_area,
524 ospf_network_area_cmd,
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
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
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
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
568 DEFUN (no_ospf_network_area,
569 no_ospf_network_area_cmd,
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
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
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
608
609 DEFUN (ospf_area_range,
610 ospf_area_range_cmd,
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
624 if (!ospf)
625 return CMD_SUCCESS;
626
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 {
633 VTY_GET_INTEGER ("range cost", cost, argv[2]);
634 ospf_area_range_cost_set (ospf, area_id, &p, cost);
635 }
636
637 return CMD_SUCCESS;
638 }
639
640 ALIAS (ospf_area_range,
641 ospf_area_range_advertise_cmd,
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
650 ALIAS (ospf_area_range,
651 ospf_area_range_cost_cmd,
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
661 ALIAS (ospf_area_range,
662 ospf_area_range_advertise_cost_cmd,
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
673 DEFUN (ospf_area_range_not_advertise,
674 ospf_area_range_not_advertise_cmd,
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
688 if (!ospf)
689 return CMD_SUCCESS;
690
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
699 DEFUN (no_ospf_area_range,
700 no_ospf_area_range_cmd,
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
714 if (!ospf)
715 return CMD_SUCCESS;
716
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
725 ALIAS (no_ospf_area_range,
726 no_ospf_area_range_advertise_cmd,
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
737 ALIAS (no_ospf_area_range,
738 no_ospf_area_range_cost_cmd,
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
749 ALIAS (no_ospf_area_range,
750 no_ospf_area_range_advertise_cost_cmd,
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")
761
762 DEFUN (ospf_area_range_substitute,
763 ospf_area_range_substitute_cmd,
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
778 if (!ospf)
779 return CMD_SUCCESS;
780
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
790 DEFUN (no_ospf_area_range_substitute,
791 no_ospf_area_range_substitute_cmd,
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
807 if (!ospf)
808 return CMD_SUCCESS;
809
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
819
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 */
838 struct 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
853 static void
854 ospf_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
862 static struct ospf_vl_data *
863 ospf_find_vl_data (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
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 }
880 area = ospf_area_get (ospf, area_id, vl_config->format);
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),
887 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
888 VTY_NEWLINE);
889 else
890 vty_out (vty, "Area %ld is %s%s",
891 (u_long)ntohl (area_id.s_addr),
892 area->external_routing == OSPF_AREA_NSSA?"nssa":"stub",
893 VTY_NEWLINE);
894 return NULL;
895 }
896
897 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config->vl_peer)) == NULL)
898 {
899 vl_data = ospf_vl_data_new (area, vl_config->vl_peer);
900 if (vl_data->vl_oi == NULL)
901 {
902 vl_data->vl_oi = ospf_vl_new (ospf, vl_data);
903 ospf_vl_add (ospf, vl_data);
904 ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE);
905 }
906 }
907 return vl_data;
908 }
909
910
911 static int
912 ospf_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);
930 strncpy ((char *) IF_DEF_PARAMS (ifp)->auth_simple, vl_config->auth_key,
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);
945 strncpy ((char *) ck->auth_key, vl_config->md5_key, OSPF_AUTH_MD5_SIZE);
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
968 static int
969 ospf_vl_set_timers (struct ospf_vl_data *vl_data,
970 struct ospf_vl_config_data *vl_config)
971 {
972 struct interface *ifp = vl_data->vl_oi->ifp;
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 */
1005 static int
1006 ospf_vl_set (struct ospf *ospf, struct ospf_vl_config_data *vl_config)
1007 {
1008 struct ospf_vl_data *vl_data;
1009 int ret;
1010
1011 vl_data = ospf_find_vl_data (ospf, vl_config);
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
1073 DEFUN (ospf_area_vlink,
1074 ospf_area_vlink_cmd,
1075 "area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1076 VLINK_HELPSTR_IPADDR)
1077 {
1078 struct ospf *ospf = vty->index;
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
1085 if (!ospf)
1086 return CMD_SUCCESS;
1087
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
1110 return ospf_vl_set (ospf, &vl_config);
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
1206 return ospf_vl_set (ospf, &vl_config);
1207
1208 }
1209
1210 DEFUN (no_ospf_area_vlink,
1211 no_ospf_area_vlink_cmd,
1212 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D",
1213 NO_STR
1214 VLINK_HELPSTR_IPADDR)
1215 {
1216 struct ospf *ospf = vty->index;
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
1224 if (!ospf)
1225 return CMD_SUCCESS;
1226
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
1236 area = ospf_area_lookup_by_area_id (ospf, vl_config.area_id);
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!!!*/
1255 if ((vl_data = ospf_vl_lookup (ospf, area, vl_config.vl_peer)))
1256 ospf_vl_delete (ospf, vl_data);
1257
1258 ospf_area_check_free (ospf, vl_config.area_id);
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 {
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++;
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
1302 return CMD_WARNING;
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
1331 return ospf_vl_set (ospf, &vl_config);
1332 }
1333
1334 ALIAS (ospf_area_vlink,
1335 ospf_area_vlink_param1_cmd,
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
1341 ALIAS (no_ospf_area_vlink,
1342 no_ospf_area_vlink_param1_cmd,
1343 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1344 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1345 NO_STR
1346 VLINK_HELPSTR_IPADDR
1347 VLINK_HELPSTR_TIME_PARAM)
1348
1349 ALIAS (ospf_area_vlink,
1350 ospf_area_vlink_param2_cmd,
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
1358 ALIAS (no_ospf_area_vlink,
1359 no_ospf_area_vlink_param2_cmd,
1360 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1361 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535> "
1362 "(hello-interval|retransmit-interval|transmit-delay|dead-interval) <1-65535>",
1363 NO_STR
1364 VLINK_HELPSTR_IPADDR
1365 VLINK_HELPSTR_TIME_PARAM
1366 VLINK_HELPSTR_TIME_PARAM)
1367
1368 ALIAS (ospf_area_vlink,
1369 ospf_area_vlink_param3_cmd,
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
1379 ALIAS (no_ospf_area_vlink,
1380 no_ospf_area_vlink_param3_cmd,
1381 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
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>",
1385 NO_STR
1386 VLINK_HELPSTR_IPADDR
1387 VLINK_HELPSTR_TIME_PARAM
1388 VLINK_HELPSTR_TIME_PARAM
1389 VLINK_HELPSTR_TIME_PARAM)
1390
1391 ALIAS (ospf_area_vlink,
1392 ospf_area_vlink_param4_cmd,
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
1404 ALIAS (no_ospf_area_vlink,
1405 no_ospf_area_vlink_param4_cmd,
1406 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
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>",
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
1418 ALIAS (ospf_area_vlink,
1419 ospf_area_vlink_authtype_args_cmd,
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
1425 ALIAS (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
1433 ALIAS (ospf_area_vlink,
1434 ospf_area_vlink_authtype_cmd,
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
1440 ALIAS (no_ospf_area_vlink,
1441 no_ospf_area_vlink_authtype_cmd,
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
1448 ALIAS (ospf_area_vlink,
1449 ospf_area_vlink_md5_cmd,
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
1455 ALIAS (no_ospf_area_vlink,
1456 no_ospf_area_vlink_md5_cmd,
1457 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1458 "(message-digest-key|) <1-255> md5 KEY",
1459 NO_STR
1460 VLINK_HELPSTR_IPADDR
1461 VLINK_HELPSTR_AUTH_MD5)
1462
1463 ALIAS (ospf_area_vlink,
1464 ospf_area_vlink_authkey_cmd,
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
1470 ALIAS (no_ospf_area_vlink,
1471 no_ospf_area_vlink_authkey_cmd,
1472 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1473 "(authentication-key|) AUTH_KEY",
1474 NO_STR
1475 VLINK_HELPSTR_IPADDR
1476 VLINK_HELPSTR_AUTH_SIMPLE)
1477
1478 ALIAS (ospf_area_vlink,
1479 ospf_area_vlink_authtype_args_authkey_cmd,
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
1487 ALIAS (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
1497 ALIAS (ospf_area_vlink,
1498 ospf_area_vlink_authtype_authkey_cmd,
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
1506 ALIAS (no_ospf_area_vlink,
1507 no_ospf_area_vlink_authtype_authkey_cmd,
1508 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1509 "(authentication|) "
1510 "(authentication-key|) AUTH_KEY",
1511 NO_STR
1512 VLINK_HELPSTR_IPADDR
1513 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1514 VLINK_HELPSTR_AUTH_SIMPLE)
1515
1516 ALIAS (ospf_area_vlink,
1517 ospf_area_vlink_authtype_args_md5_cmd,
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
1525 ALIAS (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
1535 ALIAS (ospf_area_vlink,
1536 ospf_area_vlink_authtype_md5_cmd,
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
1544 ALIAS (no_ospf_area_vlink,
1545 no_ospf_area_vlink_authtype_md5_cmd,
1546 "no area (A.B.C.D|<0-4294967295>) virtual-link A.B.C.D "
1547 "(authentication|) "
1548 "(message-digest-key|) <1-255> md5 KEY",
1549 NO_STR
1550 VLINK_HELPSTR_IPADDR
1551 VLINK_HELPSTR_AUTHTYPE_SIMPLE
1552 VLINK_HELPSTR_AUTH_MD5)
1553
1554
1555 DEFUN (ospf_area_shortcut,
1556 ospf_area_shortcut_cmd,
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 {
1566 struct ospf *ospf = vty->index;
1567 struct ospf_area *area;
1568 struct in_addr area_id;
1569 int mode;
1570 int format;
1571
1572 if (!ospf)
1573 return CMD_SUCCESS;
1574
1575 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1576
1577 area = ospf_area_get (ospf, area_id, format);
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
1588 ospf_area_shortcut_set (ospf, area, mode);
1589
1590 if (ospf->abr_type != OSPF_ABR_SHORTCUT)
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
1598 DEFUN (no_ospf_area_shortcut,
1599 no_ospf_area_shortcut_cmd,
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 {
1609 struct ospf *ospf = vty->index;
1610 struct ospf_area *area;
1611 struct in_addr area_id;
1612 int format;
1613
1614 if (!ospf)
1615 return CMD_SUCCESS;
1616
1617 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id, format, argv[0]);
1618
1619 area = ospf_area_lookup_by_area_id (ospf, area_id);
1620 if (!area)
1621 return CMD_SUCCESS;
1622
1623 ospf_area_shortcut_unset (ospf, area);
1624
1625 return CMD_SUCCESS;
1626 }
1627
1628
1629 DEFUN (ospf_area_stub,
1630 ospf_area_stub_cmd,
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
1641 if (!ospf)
1642 return CMD_SUCCESS;
1643
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
1659 DEFUN (ospf_area_stub_no_summary,
1660 ospf_area_stub_no_summary_cmd,
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
1672 if (!ospf)
1673 return CMD_SUCCESS;
1674
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 {
1680 vty_out (vty, "%% Area cannot be stub as it contains a virtual link%s",
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
1690 DEFUN (no_ospf_area_stub,
1691 no_ospf_area_stub_cmd,
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
1703 if (!ospf)
1704 return CMD_SUCCESS;
1705
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
1714 DEFUN (no_ospf_area_stub_no_summary,
1715 no_ospf_area_stub_no_summary_cmd,
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
1728 if (!ospf)
1729 return CMD_SUCCESS;
1730
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
1737 static int
1738 ospf_area_nssa_cmd_handler (struct vty *vty, int argc, const char *argv[],
1739 int nosum)
1740 {
1741 struct ospf *ospf = vty->index;
1742 struct in_addr area_id;
1743 int ret, format;
1744
1745 if (!ospf)
1746 return CMD_SUCCESS;
1747
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)
1761 ospf_area_nssa_translator_role_set (ospf, area_id,
1762 OSPF_NSSA_ROLE_CANDIDATE);
1763 else if (strncmp (argv[1], "translate-n", 11) == 0)
1764 ospf_area_nssa_translator_role_set (ospf, area_id,
1765 OSPF_NSSA_ROLE_NEVER);
1766 else if (strncmp (argv[1], "translate-a", 11) == 0)
1767 ospf_area_nssa_translator_role_set (ospf, area_id,
1768 OSPF_NSSA_ROLE_ALWAYS);
1769 }
1770 else
1771 {
1772 ospf_area_nssa_translator_role_set (ospf, area_id,
1773 OSPF_NSSA_ROLE_CANDIDATE);
1774 }
1775
1776 if (nosum)
1777 ospf_area_no_summary_set (ospf, area_id);
1778 else
1779 ospf_area_no_summary_unset (ospf, area_id);
1780
1781 ospf_schedule_abr_task (ospf);
1782
1783 return CMD_SUCCESS;
1784 }
1785
1786 DEFUN (ospf_area_nssa_translate_no_summary,
1787 ospf_area_nssa_translate_no_summary_cmd,
1788 "area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always) no-summary",
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"
1796 "Do not inject inter-area routes into nssa\n")
1797 {
1798 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
1799 }
1800
1801 DEFUN (ospf_area_nssa_translate,
1802 ospf_area_nssa_translate_cmd,
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")
1811 {
1812 return ospf_area_nssa_cmd_handler (vty, argc, argv, 0);
1813 }
1814
1815 DEFUN (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 }
1825
1826 DEFUN (ospf_area_nssa_no_summary,
1827 ospf_area_nssa_no_summary_cmd,
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 {
1835 return ospf_area_nssa_cmd_handler (vty, argc, argv, 1);
1836 }
1837
1838 DEFUN (no_ospf_area_nssa,
1839 no_ospf_area_nssa_cmd,
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
1851 if (!ospf)
1852 return CMD_SUCCESS;
1853
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
1859 ospf_schedule_abr_task (ospf);
1860
1861 return CMD_SUCCESS;
1862 }
1863
1864 ALIAS (no_ospf_area_nssa,
1865 no_ospf_area_nssa_no_summary_cmd,
1866 "no area (A.B.C.D|<0-4294967295>) nssa (translate-candidate|translate-never|translate-always|) {no-summary}",
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"
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"
1875 "Do not inject inter-area routes into nssa\n")
1876
1877 DEFUN (ospf_area_default_cost,
1878 ospf_area_default_cost_cmd,
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 {
1886 struct ospf *ospf = vty->index;
1887 struct ospf_area *area;
1888 struct in_addr area_id;
1889 u_int32_t cost;
1890 int format;
1891 struct prefix_ipv4 p;
1892
1893 if (!ospf)
1894 return CMD_SUCCESS;
1895
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
1899 area = ospf_area_get (ospf, area_id, format);
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
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
1918 return CMD_SUCCESS;
1919 }
1920
1921 DEFUN (no_ospf_area_default_cost,
1922 no_ospf_area_default_cost_cmd,
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 {
1931 struct ospf *ospf = vty->index;
1932 struct ospf_area *area;
1933 struct in_addr area_id;
1934 int format;
1935 struct prefix_ipv4 p;
1936
1937 if (!ospf)
1938 return CMD_SUCCESS;
1939
1940 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id, format, argv[0]);
1941 VTY_CHECK_INTEGER_RANGE ("stub default cost", argv[1], 0, OSPF_LS_INFINITY);
1942
1943 area = ospf_area_lookup_by_area_id (ospf, area_id);
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
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
1965 ospf_area_check_free (ospf, area_id);
1966
1967 return CMD_SUCCESS;
1968 }
1969
1970 DEFUN (ospf_area_export_list,
1971 ospf_area_export_list_cmd,
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 {
1979 struct ospf *ospf = vty->index;
1980 struct ospf_area *area;
1981 struct in_addr area_id;
1982 int format;
1983
1984 if (!ospf)
1985 return CMD_SUCCESS;
1986
1987 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
1988
1989 area = ospf_area_get (ospf, area_id, format);
1990 ospf_area_export_list_set (ospf, area, argv[1]);
1991
1992 return CMD_SUCCESS;
1993 }
1994
1995 DEFUN (no_ospf_area_export_list,
1996 no_ospf_area_export_list_cmd,
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 {
2005 struct ospf *ospf = vty->index;
2006 struct ospf_area *area;
2007 struct in_addr area_id;
2008 int format;
2009
2010 if (!ospf)
2011 return CMD_SUCCESS;
2012
2013 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2014
2015 area = ospf_area_lookup_by_area_id (ospf, area_id);
2016 if (area == NULL)
2017 return CMD_SUCCESS;
2018
2019 ospf_area_export_list_unset (ospf, area);
2020
2021 return CMD_SUCCESS;
2022 }
2023
2024
2025 DEFUN (ospf_area_import_list,
2026 ospf_area_import_list_cmd,
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 {
2034 struct ospf *ospf = vty->index;
2035 struct ospf_area *area;
2036 struct in_addr area_id;
2037 int format;
2038
2039 if (!ospf)
2040 return CMD_SUCCESS;
2041
2042 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2043
2044 area = ospf_area_get (ospf, area_id, format);
2045 ospf_area_import_list_set (ospf, area, argv[1]);
2046
2047 return CMD_SUCCESS;
2048 }
2049
2050 DEFUN (no_ospf_area_import_list,
2051 no_ospf_area_import_list_cmd,
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 {
2060 struct ospf *ospf = vty->index;
2061 struct ospf_area *area;
2062 struct in_addr area_id;
2063 int format;
2064
2065 if (!ospf)
2066 return CMD_SUCCESS;
2067
2068 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2069
2070 area = ospf_area_lookup_by_area_id (ospf, area_id);
2071 if (area == NULL)
2072 return CMD_SUCCESS;
2073
2074 ospf_area_import_list_unset (ospf, area);
2075
2076 return CMD_SUCCESS;
2077 }
2078
2079 DEFUN (ospf_area_filter_list,
2080 ospf_area_filter_list_cmd,
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 {
2091 struct ospf *ospf = vty->index;
2092 struct ospf_area *area;
2093 struct in_addr area_id;
2094 struct prefix_list *plist;
2095 int format;
2096
2097 if (!ospf)
2098 return CMD_SUCCESS;
2099
2100 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2101
2102 area = ospf_area_get (ospf, area_id, format);
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]);
2111 ospf_schedule_abr_task (ospf);
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]);
2120 ospf_schedule_abr_task (ospf);
2121 }
2122
2123 return CMD_SUCCESS;
2124 }
2125
2126 DEFUN (no_ospf_area_filter_list,
2127 no_ospf_area_filter_list_cmd,
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 {
2139 struct ospf *ospf = vty->index;
2140 struct ospf_area *area;
2141 struct in_addr area_id;
2142 int format;
2143
2144 if (!ospf)
2145 return CMD_SUCCESS;
2146
2147 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2148
2149 if ((area = ospf_area_lookup_by_area_id (ospf, area_id)) == NULL)
2150 return CMD_SUCCESS;
2151
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
2164 ospf_schedule_abr_task (ospf);
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
2178 ospf_schedule_abr_task (ospf);
2179 }
2180
2181 return CMD_SUCCESS;
2182 }
2183
2184
2185 DEFUN (ospf_area_authentication_message_digest,
2186 ospf_area_authentication_message_digest_cmd,
2187 "area (A.B.C.D|<0-4294967295>) authentication message-digest",
2188 "OSPF area parameters\n"
2189 "OSPF area ID in IP address format\n"
2190 "OSPF area ID as a decimal value\n"
2191 "Enable authentication\n"
2192 "Use message-digest authentication\n")
2193 {
2194 struct ospf *ospf = vty->index;
2195 struct ospf_area *area;
2196 struct in_addr area_id;
2197 int format;
2198
2199 if (!ospf)
2200 return CMD_SUCCESS;
2201
2202 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2203
2204 area = ospf_area_get (ospf, area_id, format);
2205 area->auth_type = OSPF_AUTH_CRYPTOGRAPHIC;
2206
2207 return CMD_SUCCESS;
2208 }
2209
2210 DEFUN (ospf_area_authentication,
2211 ospf_area_authentication_cmd,
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 {
2218 struct ospf *ospf = vty->index;
2219 struct ospf_area *area;
2220 struct in_addr area_id;
2221 int format;
2222
2223 if (!ospf)
2224 return CMD_SUCCESS;
2225
2226 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2227
2228 area = ospf_area_get (ospf, area_id, format);
2229 area->auth_type = OSPF_AUTH_SIMPLE;
2230
2231 return CMD_SUCCESS;
2232 }
2233
2234 DEFUN (no_ospf_area_authentication,
2235 no_ospf_area_authentication_cmd,
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 {
2243 struct ospf *ospf = vty->index;
2244 struct ospf_area *area;
2245 struct in_addr area_id;
2246 int format;
2247
2248 if (!ospf)
2249 return CMD_SUCCESS;
2250
2251 VTY_GET_OSPF_AREA_ID (area_id, format, argv[0]);
2252
2253 area = ospf_area_lookup_by_area_id (ospf, area_id);
2254 if (area == NULL)
2255 return CMD_SUCCESS;
2256
2257 area->auth_type = OSPF_AUTH_NULL;
2258
2259 ospf_area_check_free (ospf, area_id);
2260
2261 return CMD_SUCCESS;
2262 }
2263
2264
2265 DEFUN (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 {
2275 struct ospf *ospf = vty->index;
2276 u_char abr_type = OSPF_ABR_UNKNOWN;
2277
2278 if (!ospf)
2279 return CMD_SUCCESS;
2280
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. */
2293 if (ospf->abr_type != abr_type)
2294 {
2295 ospf->abr_type = abr_type;
2296 ospf_schedule_abr_task (ospf);
2297 }
2298
2299 return CMD_SUCCESS;
2300 }
2301
2302 DEFUN (no_ospf_abr_type,
2303 no_ospf_abr_type_cmd,
2304 "no ospf abr-type (cisco|ibm|shortcut|standard)",
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 {
2312 struct ospf *ospf = vty->index;
2313 u_char abr_type = OSPF_ABR_UNKNOWN;
2314
2315 if (!ospf)
2316 return CMD_SUCCESS;
2317
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;
2322 else if (strncmp (argv[0], "sh", 2) == 0)
2323 abr_type = OSPF_ABR_SHORTCUT;
2324 else if (strncmp (argv[0], "st", 2) == 0)
2325 abr_type = OSPF_ABR_STAND;
2326 else
2327 return CMD_WARNING;
2328
2329 /* If ABR type value is changed, schedule ABR task. */
2330 if (ospf->abr_type == abr_type)
2331 {
2332 ospf->abr_type = OSPF_ABR_DEFAULT;
2333 ospf_schedule_abr_task (ospf);
2334 }
2335
2336 return CMD_SUCCESS;
2337 }
2338
2339 DEFUN (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
2346 if (!ospf)
2347 return CMD_SUCCESS;
2348
2349 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2350 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2351 return CMD_SUCCESS;
2352 }
2353
2354 DEFUN (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
2362 if (!ospf)
2363 return CMD_SUCCESS;
2364
2365 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2366 SET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2367 return CMD_SUCCESS;
2368 }
2369
2370 DEFUN (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
2378 if (!ospf)
2379 return CMD_SUCCESS;
2380
2381 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2382 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2383 return CMD_SUCCESS;
2384 }
2385
2386 DEFUN (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
2395 if (!ospf)
2396 return CMD_SUCCESS;
2397
2398 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES);
2399 UNSET_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL);
2400 return CMD_SUCCESS;
2401 }
2402
2403 DEFUN (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
2411 if (!ospf)
2412 return CMD_SUCCESS;
2413
2414 if (!CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2415 {
2416 SET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
2417 ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE);
2418 }
2419 return CMD_SUCCESS;
2420 }
2421
2422 DEFUN (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
2431 if (!ospf)
2432 return CMD_SUCCESS;
2433
2434 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
2435 {
2436 UNSET_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE);
2437 ospf_spf_calculate_schedule (ospf, SPF_FLAG_CONFIG_CHANGE);
2438 }
2439 return CMD_SUCCESS;
2440 }
2441
2442 ALIAS (ospf_compatible_rfc1583,
2443 ospf_rfc1583_flag_cmd,
2444 "ospf rfc1583compatibility",
2445 "OSPF specific commands\n"
2446 "Enable the RFC1583Compatibility flag\n")
2447
2448 ALIAS (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")
2454
2455 static int
2456 ospf_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
2462 if (!ospf)
2463 return CMD_SUCCESS;
2464
2465 ospf->spf_delay = delay;
2466 ospf->spf_holdtime = hold;
2467 ospf->spf_max_holdtime = max;
2468
2469 return CMD_SUCCESS;
2470 }
2471
2472 DEFUN (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"
2478 "All LSA types\n"
2479 "Delay (msec) between sending LSAs\n")
2480 {
2481 struct ospf *ospf = vty->index;
2482 unsigned int interval;
2483
2484 if (!ospf)
2485 return CMD_SUCCESS;
2486
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
2500 DEFUN (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"
2506 "LSA delay between transmissions\n"
2507 "All LSA types\n")
2508 {
2509 struct ospf *ospf = vty->index;
2510 ospf->min_ls_interval = OSPF_MIN_LS_INTERVAL;
2511
2512 return CMD_SUCCESS;
2513 }
2514
2515 ALIAS (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
2525 DEFUN (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
2536 if (!ospf)
2537 return CMD_SUCCESS;
2538
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
2552 DEFUN (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;
2561
2562 if (!ospf)
2563 return CMD_SUCCESS;
2564
2565 ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL;
2566
2567 return CMD_SUCCESS;
2568 }
2569
2570 ALIAS (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
2579 DEFUN (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
2604 DEFUN (no_ospf_timers_throttle_spf,
2605 no_ospf_timers_throttle_spf_cmd,
2606 "no timers throttle spf",
2607 NO_STR
2608 "Adjust routing timers\n"
2609 "Throttling adaptive timer\n"
2610 "OSPF SPF timers\n")
2611 {
2612 return ospf_timers_spf_set (vty,
2613 OSPF_SPF_DELAY_DEFAULT,
2614 OSPF_SPF_HOLDTIME_DEFAULT,
2615 OSPF_SPF_MAX_HOLDTIME_DEFAULT);
2616 }
2617
2618 ALIAS (no_ospf_timers_throttle_spf,
2619 no_ospf_timers_throttle_spf_val_cmd,
2620 "no timers throttle spf <0-600000> <0-600000> <0-600000>",
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
2629 DEFUN (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
2651 ospf->min_ls_arrival = minarrival;
2652
2653 return CMD_SUCCESS;
2654 }
2655
2656 DEFUN (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
2674 if (ospf->min_ls_arrival != minarrival ||
2675 minarrival == OSPF_MIN_LS_ARRIVAL)
2676 return CMD_SUCCESS;
2677 }
2678
2679 ospf->min_ls_arrival = OSPF_MIN_LS_ARRIVAL;
2680
2681 return CMD_SUCCESS;
2682 }
2683
2684 ALIAS (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
2694 DEFUN (ospf_neighbor,
2695 ospf_neighbor_cmd,
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;
2702 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2703 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
2704
2705 if (!ospf)
2706 return CMD_SUCCESS;
2707
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)
2720 ospf_nbr_nbma_poll_interval_set (ospf, nbr_addr, interval);
2721
2722 return CMD_SUCCESS;
2723 }
2724
2725 ALIAS (ospf_neighbor,
2726 ospf_neighbor_priority_poll_interval_cmd,
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
2735 ALIAS (ospf_neighbor,
2736 ospf_neighbor_priority_cmd,
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
2743 DEFUN (ospf_neighbor_poll_interval,
2744 ospf_neighbor_poll_interval_cmd,
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;
2753 unsigned int priority = OSPF_NEIGHBOR_PRIORITY_DEFAULT;
2754 unsigned int interval = OSPF_POLL_INTERVAL_DEFAULT;
2755
2756 if (!ospf)
2757 return CMD_SUCCESS;
2758
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
2776 ALIAS (ospf_neighbor_poll_interval,
2777 ospf_neighbor_poll_interval_priority_cmd,
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
2786 DEFUN (no_ospf_neighbor,
2787 no_ospf_neighbor_cmd,
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;
2795
2796 if (!ospf)
2797 return CMD_SUCCESS;
2798
2799 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr, argv[0]);
2800
2801 (void)ospf_nbr_nbma_unset (ospf, nbr_addr);
2802
2803 return CMD_SUCCESS;
2804 }
2805
2806 ALIAS (no_ospf_neighbor,
2807 no_ospf_neighbor_priority_cmd,
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
2815 ALIAS (no_ospf_neighbor,
2816 no_ospf_neighbor_poll_interval_cmd,
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
2824 ALIAS (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
2835 ALIAS (no_ospf_neighbor,
2836 no_ospf_neighbor_priority_pollinterval_cmd,
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
2846 DEFUN (ospf_refresh_timer, ospf_refresh_timer_cmd,
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;
2853 unsigned int interval;
2854
2855 if (!ospf)
2856 return CMD_SUCCESS;
2857
2858 VTY_GET_INTEGER_RANGE ("refresh timer", interval, argv[0], 10, 1800);
2859 interval = (interval / OSPF_LSA_REFRESHER_GRANULARITY) * OSPF_LSA_REFRESHER_GRANULARITY;
2860
2861 ospf_timers_refresh_set (ospf, interval);
2862
2863 return CMD_SUCCESS;
2864 }
2865
2866 DEFUN (no_ospf_refresh_timer, no_ospf_refresh_timer_val_cmd,
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;
2873 unsigned int interval;
2874
2875 if (!ospf)
2876 return CMD_SUCCESS;
2877
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
2892 ALIAS (no_ospf_refresh_timer,
2893 no_ospf_refresh_timer_cmd,
2894 "no refresh timer",
2895 "Adjust refresh parameters\n"
2896 "Unset refresh timer\n")
2897
2898 DEFUN (ospf_auto_cost_reference_bandwidth,
2899 ospf_auto_cost_reference_bandwidth_cmd,
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 {
2905 struct ospf *ospf = vty->index;
2906 u_int32_t refbw;
2907 struct listnode *node;
2908 struct interface *ifp;
2909
2910 if (!ospf)
2911 return CMD_SUCCESS;
2912
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. */
2921 if ((refbw) == ospf->ref_bandwidth)
2922 return CMD_SUCCESS;
2923
2924 ospf->ref_bandwidth = refbw;
2925 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
2926 ospf_if_recalculate_output_cost (ifp);
2927
2928 return CMD_SUCCESS;
2929 }
2930
2931 DEFUN (no_ospf_auto_cost_reference_bandwidth,
2932 no_ospf_auto_cost_reference_bandwidth_cmd,
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 {
2938 struct ospf *ospf = vty->index;
2939 struct listnode *node, *nnode;
2940 struct interface *ifp;
2941
2942 if (!ospf)
2943 return CMD_SUCCESS;
2944
2945 if (ospf->ref_bandwidth == OSPF_DEFAULT_REF_BANDWIDTH)
2946 return CMD_SUCCESS;
2947
2948 ospf->ref_bandwidth = OSPF_DEFAULT_REF_BANDWIDTH;
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
2952 for (ALL_LIST_ELEMENTS (om->iflist, node, nnode, ifp))
2953 ospf_if_recalculate_output_cost (ifp);
2954
2955 return CMD_SUCCESS;
2956 }
2957
2958 ALIAS (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
2966 DEFUN (ospf_write_multiplier,
2967 ospf_write_multiplier_cmd,
2968 "ospf write-multiplier <1-100>",
2969 "OSPF specific commands\n"
2970 "Write multiplier\n"
2971 "Maximum number of interface serviced per write\n")
2972 {
2973 struct ospf *ospf = vty->index;
2974 u_int32_t write_oi_count;
2975
2976 if (!ospf)
2977 return CMD_SUCCESS;
2978
2979 write_oi_count = strtol (argv[0], NULL, 10);
2980 if (write_oi_count < 1 || write_oi_count > 100)
2981 {
2982 vty_out (vty, "write-multiplier value is invalid%s", VTY_NEWLINE);
2983 return CMD_WARNING;
2984 }
2985
2986 ospf->write_oi_count = write_oi_count;
2987 return CMD_SUCCESS;
2988 }
2989
2990 ALIAS (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
2996 DEFUN (no_ospf_write_multiplier,
2997 no_ospf_write_multiplier_cmd,
2998 "no ospf write-multiplier <1-100>",
2999 NO_STR
3000 "OSPF specific commands\n"
3001 "Write multiplier\n"
3002 "Maximum number of interface serviced per write\n")
3003 {
3004 struct ospf *ospf = vty->index;
3005
3006 if (!ospf)
3007 return CMD_SUCCESS;
3008
3009 ospf->write_oi_count = OSPF_WRITE_INTERFACE_COUNT_DEFAULT;
3010 return CMD_SUCCESS;
3011 }
3012
3013 ALIAS (no_ospf_write_multiplier,
3014 no_write_multiplier_cmd,
3015 "no write-multiplier",
3016 NO_STR
3017 "Write multiplier\n")
3018
3019 ALIAS (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
3026 const char *ospf_abr_type_descr_str[] =
3027 {
3028 "Unknown",
3029 "Standard (RFC2328)",
3030 "Alternative IBM",
3031 "Alternative Cisco",
3032 "Alternative Shortcut"
3033 };
3034
3035 const char *ospf_shortcut_mode_descr_str[] =
3036 {
3037 "Default",
3038 "Enabled",
3039 "Disabled"
3040 };
3041
3042 static void
3043 show_ip_ospf_area (struct vty *vty, struct ospf_area *area, json_object *json_areas, u_char use_json)
3044 {
3045 json_object *json_area = NULL;
3046
3047 if (use_json)
3048 json_area = json_object_new_object();
3049
3050 /* Show Area ID. */
3051 if (!use_json)
3052 vty_out (vty, " Area ID: %s", inet_ntoa (area->area_id));
3053
3054 /* Show Area type/mode. */
3055 if (OSPF_IS_AREA_BACKBONE (area))
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 }
3062 else
3063 {
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 {
3108 json_object_int_add(json_area, "areaIfTotalCounter", listcount (area->oiflist));
3109 json_object_int_add(json_area, "areaIfActiveCounter", area->act_ints);
3110 }
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);
3115
3116 if (area->external_routing == OSPF_AREA_NSSA)
3117 {
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 }
3140 else
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 }
3167 }
3168
3169 /* Stub-router state for this area */
3170 if (CHECK_FLAG (area->stub_router_state, OSPF_AREA_IS_STUB_ROUTED))
3171 {
3172 char timebuf[OSPF_TIME_DUMP_SIZE];
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. */
3205 json_object_int_add(json_area, "nbrFullAdjacentCounter", area->full_nbrs);
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))
3216 json_object_int_add(json_area, "virtualAdjacenciesPassingCounter", area->full_vls);
3217
3218 /* Show SPF calculation times. */
3219 json_object_int_add(json_area, "spfExecutedCounter", area->spf_calculation);
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));
3231 }
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
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 }
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);
3295 }
3296
3297 static int
3298 show_ip_ospf_common (struct vty *vty, struct ospf *ospf, u_char use_json)
3299 {
3300 struct listnode *node, *nnode;
3301 struct ospf_area * area;
3302 struct timeval result;
3303 char timebuf[OSPF_TIME_DUMP_SIZE];
3304 json_object *json = NULL;
3305 json_object *json_areas = NULL;
3306
3307 if (use_json)
3308 {
3309 json = json_object_new_object();
3310 json_areas = json_object_new_object();
3311 }
3312
3313 if (ospf->instance)
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 }
3325
3326 /* Show Router ID. */
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 }
3337
3338 /* Graceful shutdown */
3339 if (ospf->t_deferred_shutdown)
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
3356 /* Show capability. */
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
3375 if (use_json)
3376 {
3377 if (CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE))
3378 {
3379 json_object_boolean_true_add(json, "opaqueCapable");
3380 }
3381 }
3382 else
3383 {
3384 vty_out (vty, " OpaqueCapability flag is %s%s",
3385 CHECK_FLAG (ospf->config, OSPF_OPAQUE_CAPABLE) ? "enabled" : "disabled",
3386 VTY_NEWLINE);
3387 }
3388
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 {
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 }
3412 }
3413
3414 /* Show SPF timers. */
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);
3421 }
3422 else
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 }
3433
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
3480 json_object_int_add(json, "lsaMinIntervalMsecs", ospf->min_ls_interval);
3481 json_object_int_add(json, "lsaMinArrivalMsecs", ospf->min_ls_arrival);
3482 /* Show write multiplier values */
3483 json_object_int_add(json, "writeMultiplier", ospf->write_oi_count);
3484 /* Show refresh parameters. */
3485 json_object_int_add(json, "refreshTimerMsecs", ospf->lsa_refresh_interval * 1000);
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
3494 vty_out (vty, " LSA minimum interval %d msecs%s",
3495 ospf->min_ls_interval, VTY_NEWLINE);
3496 vty_out (vty, " LSA minimum arrival %d msecs%s",
3497 ospf->min_ls_arrival, VTY_NEWLINE);
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 }
3507
3508 /* Show ABR/ASBR flags. */
3509 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ABR))
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 }
3517 if (CHECK_FLAG (ospf->flags, OSPF_FLAG_ASBR))
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 }
3525
3526 /* Show Number of AS-external-LSAs. */
3527 if (use_json)
3528 {
3529 json_object_int_add(json, "lsaExternalCounter",
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
3541 if (use_json)
3542 {
3543 json_object_int_add(json, "lsaAsopaqueCounter",
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 }
3554
3555 /* Show number of areas attached. */
3556 if (use_json)
3557 json_object_int_add(json, "attachedAreaCounter", listcount (ospf->areas));
3558 else
3559 vty_out (vty, " Number of areas attached to this router: %d%s",
3560 listcount (ospf->areas), VTY_NEWLINE);
3561
3562 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
3563 {
3564 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
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 }
3571 else
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 }
3578 }
3579 /* Show each area status. */
3580 for (ALL_LIST_ELEMENTS (ospf->areas, node, nnode, area))
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);
3586 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
3587 json_object_free(json);
3588 }
3589 else
3590 vty_out (vty, "%s",VTY_NEWLINE);
3591
3592 return CMD_SUCCESS;
3593 }
3594
3595 DEFUN (show_ip_ospf,
3596 show_ip_ospf_cmd,
3597 "show ip ospf {json}",
3598 SHOW_STR
3599 IP_STR
3600 "OSPF information\n"
3601 "JavaScript Object Notation\n")
3602 {
3603 struct ospf *ospf;
3604 u_char uj = use_json(argc, argv);
3605
3606 if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running)
3607 return CMD_SUCCESS;
3608
3609 return (show_ip_ospf_common(vty, ospf, uj));
3610 }
3611
3612 DEFUN (show_ip_ospf_instance,
3613 show_ip_ospf_instance_cmd,
3614 "show ip ospf <1-65535> {json}",
3615 SHOW_STR
3616 IP_STR
3617 "OSPF information\n"
3618 "Instance ID\n"
3619 "JavaScript Object Notation\n")
3620 {
3621 struct ospf *ospf;
3622 u_short instance = 0;
3623 u_char uj = use_json(argc, argv);
3624
3625 VTY_GET_INTEGER ("Instance", instance, argv[0]);
3626 if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running)
3627 return CMD_SUCCESS;
3628
3629 return (show_ip_ospf_common(vty, ospf, uj));
3630 }
3631
3632 static void
3633 show_ip_ospf_interface_sub (struct vty *vty, struct ospf *ospf, struct interface *ifp,
3634 json_object *json_interface_sub, u_char use_json)
3635 {
3636 int is_up;
3637 struct ospf_neighbor *nbr;
3638 struct route_node *rn;
3639
3640 /* Is interface up? */
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);
3651 json_object_int_add(json_interface_sub, "bandwidthMbit", ifp->bandwidth);
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);
3658 vty_out (vty, " ifindex %u, MTU %u bytes, BW %u Mbit %s%s",
3659 ifp->ifindex, ifp->mtu, ifp->bandwidth, if_flag_dump(ifp->flags),
3660 VTY_NEWLINE);
3661 }
3662
3663 /* Is interface OSPF enabled? */
3664 if (use_json)
3665 {
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");
3678 }
3679 else
3680 {
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 }
3692 }
3693
3694 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
3695 {
3696 struct ospf_interface *oi = rn->info;
3697
3698 if (oi == NULL)
3699 continue;
3700
3701 if (CHECK_FLAG(oi->connected->flags, ZEBRA_IFA_UNNUMBERED))
3702 {
3703 if (use_json)
3704 json_object_boolean_true_add(json_interface_sub, "ifUnnumbered");
3705 else
3706 vty_out (vty, " This interface is UNNUMBERED,");
3707 }
3708 else
3709 {
3710 /* Show OSPF interface information. */
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);
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
3732 * * * * * informative than the local interface that is being used
3733 * * * * */
3734 if (oi->type == OSPF_IFTYPE_VIRTUALLINK)
3735 dest = &oi->vl_data->peer_addr;
3736 else
3737 dest = &oi->connected->destination->u.prefix4;
3738
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));
3749 }
3750 }
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);
3767
3768 vty_out (vty, " MTU mismatch detection:%s%s",
3769 OSPF_IF_PARAM(oi, mtu_ignore) ? "disabled" : "enabled", VTY_NEWLINE);
3770
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);
3774
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 }
3779
3780 /* Show DR information. */
3781 if (DR (oi).s_addr == 0)
3782 {
3783 if (!use_json)
3784 vty_out (vty, " No backup designated router on this network%s",
3785 VTY_NEWLINE);
3786 }
3787 else
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 }
3812
3813 /* Next network-LSA sequence number we'll use, if we're elected DR */
3814 if (oi->params && ntohl (oi->params->network_lsa_seqnum) != OSPF_INITIAL_SEQUENCE_NUMBER)
3815 {
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 }
3833 }
3834 else
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 }
3849
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 }
3860 else
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
3875 if (OSPF_IF_PASSIVE_STATUS (oi) == OSPF_IF_ACTIVE)
3876 {
3877 char timebuf[OSPF_TIME_DUMP_SIZE];
3878 if (use_json)
3879 {
3880 struct timeval result;
3881 unsigned long time_store = 0;
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 }
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);
3896 }
3897 else /* passive-interface is set */
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);
3914 ospf_bfd_interface_show(vty, ifp, json_interface_sub, use_json);
3915 }
3916 }
3917
3918 static int
3919 show_ip_ospf_interface_common (struct vty *vty, struct ospf *ospf, int argc,
3920 const char **argv, int iface_argv, u_char use_json)
3921 {
3922 struct interface *ifp;
3923 struct listnode *node;
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 }
3932
3933 if (ospf->instance)
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 }
3941
3942 if (argc == (iface_argv + 1))
3943 {
3944 /* Show All Interfaces.*/
3945 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp))
3946 {
3947 if (ospf_oi_count(ifp))
3948 {
3949 show_ip_ospf_interface_sub (vty, ospf, ifp, json_interface_sub, use_json);
3950 if (use_json)
3951 json_object_object_add (json, ifp->name, json_interface_sub);
3952 }
3953 }
3954 }
3955 else if (argv[iface_argv] && strcmp(argv[iface_argv], "json") == 0)
3956 {
3957 if (!use_json)
3958 {
3959 json = json_object_new_object();
3960 json_interface_sub = json_object_new_object ();
3961 use_json = 1;
3962 }
3963 /* Show All Interfaces. */
3964 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp))
3965 {
3966 if (ospf_oi_count(ifp))
3967 {
3968 show_ip_ospf_interface_sub (vty, ospf, ifp, json_interface_sub, use_json);
3969 if (use_json)
3970 json_object_object_add(json, ifp->name, json_interface_sub);
3971 }
3972 }
3973 }
3974 else
3975 {
3976 /* Interface name is specified. */
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 }
3984 else
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 }
3990 }
3991
3992 if (use_json)
3993 {
3994 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
3995 json_object_free(json);
3996 }
3997 else
3998 vty_out (vty, "%s", VTY_NEWLINE);
3999
4000 return CMD_SUCCESS;
4001 }
4002
4003 DEFUN (show_ip_ospf_interface,
4004 show_ip_ospf_interface_cmd,
4005 "show ip ospf interface [INTERFACE] {json}",
4006 SHOW_STR
4007 IP_STR
4008 "OSPF information\n"
4009 "Interface information\n"
4010 "Interface name\n"
4011 "JavaScript Object Notation\n")
4012 {
4013 struct ospf *ospf;
4014 u_char uj = use_json(argc, argv);
4015
4016 if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running)
4017 return CMD_SUCCESS;
4018
4019 return show_ip_ospf_interface_common(vty, ospf, argc, argv, 0, uj);
4020 }
4021
4022 DEFUN (show_ip_ospf_instance_interface,
4023 show_ip_ospf_instance_interface_cmd,
4024 "show ip ospf <1-65535> interface [INTERFACE] {json}",
4025 SHOW_STR
4026 IP_STR
4027 "OSPF information\n"
4028 "Instance ID\n"
4029 "Interface information\n"
4030 "Interface name\n"
4031 "JavaScript Object Notation\n")
4032 {
4033 struct ospf *ospf;
4034 u_short instance = 0;
4035 u_char uj = use_json(argc, argv);
4036
4037 VTY_GET_INTEGER ("Instance", instance, argv[0]);
4038 if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running)
4039 return CMD_SUCCESS;
4040
4041 return show_ip_ospf_interface_common(vty, ospf, argc, argv, 1, uj);
4042 }
4043
4044 static void
4045 show_ip_ospf_neighbour_header (struct vty *vty)
4046 {
4047 vty_out (vty, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
4048 VTY_NEWLINE,
4049 "Neighbor ID", "Pri", "State", "Dead Time",
4050 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
4051 VTY_NEWLINE);
4052 }
4053
4054 static void
4055 show_ip_ospf_neighbor_sub (struct vty *vty, struct ospf_interface *oi, json_object *json, u_char use_json)
4056 {
4057 struct route_node *rn;
4058 struct ospf_neighbor *nbr;
4059 char msgbuf[16];
4060 char timebuf[OSPF_TIME_DUMP_SIZE];
4061 json_object *json_neighbor = NULL;
4062
4063 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
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));
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));
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 }
4123 }
4124
4125 static int
4126 show_ip_ospf_neighbor_common (struct vty *vty, struct ospf *ospf, u_char use_json)
4127 {
4128 struct ospf_interface *oi;
4129 struct listnode *node;
4130 json_object *json = NULL;
4131
4132 if (use_json)
4133 json = json_object_new_object();
4134 else
4135 show_ip_ospf_neighbour_header (vty);
4136
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 }
4145
4146 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
4147 show_ip_ospf_neighbor_sub (vty, oi, json, use_json);
4148
4149 if (use_json)
4150 {
4151 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
4152 json_object_free(json);
4153 }
4154 else
4155 vty_out (vty, "%s", VTY_NEWLINE);
4156
4157 return CMD_SUCCESS;
4158 }
4159
4160 DEFUN (show_ip_ospf_neighbor,
4161 show_ip_ospf_neighbor_cmd,
4162 "show ip ospf neighbor {json}",
4163 SHOW_STR
4164 IP_STR
4165 "OSPF information\n"
4166 "Neighbor list\n"
4167 "JavaScript Object Notation\n")
4168 {
4169 struct ospf *ospf;
4170 u_char uj = use_json(argc, argv);
4171
4172 if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running)
4173 return CMD_SUCCESS;
4174
4175 return show_ip_ospf_neighbor_common(vty, ospf, uj);
4176 }
4177
4178
4179 DEFUN (show_ip_ospf_instance_neighbor,
4180 show_ip_ospf_instance_neighbor_cmd,
4181 "show ip ospf <1-65535> neighbor {json}",
4182 SHOW_STR
4183 IP_STR
4184 "OSPF information\n"
4185 "Instance ID\n"
4186 "Neighbor list\n"
4187 "JavaScript Object Notation\n")
4188 {
4189 struct ospf *ospf;
4190 u_short instance = 0;
4191 u_char uj = use_json(argc, argv);
4192
4193 VTY_GET_INTEGER ("Instance", instance, argv[0]);
4194 if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running)
4195 return CMD_SUCCESS;
4196
4197 return show_ip_ospf_neighbor_common(vty, ospf, uj);
4198 }
4199
4200 static int
4201 show_ip_ospf_neighbor_all_common (struct vty *vty, struct ospf *ospf, u_char use_json)
4202 {
4203 struct listnode *node;
4204 struct ospf_interface *oi;
4205 json_object *json = NULL;
4206 json_object *json_neighbor_sub = NULL;
4207
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);
4215
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 }
4224
4225 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
4226 {
4227 struct listnode *nbr_node;
4228 struct ospf_nbr_nbma *nbr_nbma;
4229
4230 show_ip_ospf_neighbor_sub (vty, oi, json, use_json);
4231
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));
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);
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 }
4258 }
4259
4260 if (use_json)
4261 {
4262 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
4263 json_object_free(json);
4264 }
4265 else
4266 vty_out (vty, "%s", VTY_NEWLINE);
4267
4268 return CMD_SUCCESS;
4269 }
4270
4271 DEFUN (show_ip_ospf_neighbor_all,
4272 show_ip_ospf_neighbor_all_cmd,
4273 "show ip ospf neighbor all {json}",
4274 SHOW_STR
4275 IP_STR
4276 "OSPF information\n"
4277 "Neighbor list\n"
4278 "include down status neighbor\n"
4279 "JavaScript Object Notation\n")
4280 {
4281 struct ospf *ospf;
4282 u_char uj = use_json(argc, argv);
4283
4284 if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running)
4285 return CMD_SUCCESS;
4286
4287 return show_ip_ospf_neighbor_all_common(vty, ospf, uj);
4288 }
4289
4290 DEFUN (show_ip_ospf_instance_neighbor_all,
4291 show_ip_ospf_instance_neighbor_all_cmd,
4292 "show ip ospf <1-65535> neighbor all {json}",
4293 SHOW_STR
4294 IP_STR
4295 "OSPF information\n"
4296 "Instance ID\n"
4297 "Neighbor list\n"
4298 "include down status neighbor\n"
4299 "JavaScript Object Notation\n")
4300 {
4301 struct ospf *ospf;
4302 u_short instance = 0;
4303 u_char uj = use_json(argc, argv);
4304
4305 VTY_GET_INTEGER ("Instance", instance, argv[0]);
4306 if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running)
4307 return CMD_SUCCESS;
4308
4309 return show_ip_ospf_neighbor_all_common(vty, ospf, uj);
4310 }
4311
4312 static int
4313 show_ip_ospf_neighbor_int_common (struct vty *vty, struct ospf *ospf, int arg_base,
4314 const char **argv, u_char use_json)
4315 {
4316 struct interface *ifp;
4317 struct route_node *rn;
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);
4324
4325 if (ospf->instance)
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 }
4333
4334 ifp = if_lookup_by_name (argv[arg_base]);
4335 if (!ifp)
4336 {
4337 if (use_json)
4338 json_object_boolean_true_add(json, "noSuchIface");
4339 else
4340 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
4341 return CMD_WARNING;
4342 }
4343
4344 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
4345 {
4346 struct ospf_interface *oi = rn->info;
4347
4348 if (oi == NULL)
4349 continue;
4350
4351 show_ip_ospf_neighbor_sub (vty, oi, json, use_json);
4352 }
4353
4354 if (use_json)
4355 {
4356 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
4357 json_object_free(json);
4358 }
4359 else
4360 vty_out (vty, "%s", VTY_NEWLINE);
4361
4362 return CMD_SUCCESS;
4363 }
4364
4365 DEFUN (show_ip_ospf_neighbor_int,
4366 show_ip_ospf_neighbor_int_cmd,
4367 "show ip ospf neighbor IFNAME {json}",
4368 SHOW_STR
4369 IP_STR
4370 "OSPF information\n"
4371 "Neighbor list\n"
4372 "Interface name\n"
4373 "JavaScript Object Notation\n")
4374 {
4375 struct ospf *ospf;
4376 u_char uj = use_json(argc, argv);
4377
4378 if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running)
4379 return CMD_SUCCESS;
4380
4381 return show_ip_ospf_neighbor_int_common(vty, ospf, 0, argv, uj);
4382 }
4383
4384 DEFUN (show_ip_ospf_instance_neighbor_int,
4385 show_ip_ospf_instance_neighbor_int_cmd,
4386 "show ip ospf <1-65535> neighbor IFNAME {json}",
4387 SHOW_STR
4388 IP_STR
4389 "OSPF information\n"
4390 "Instance ID\n"
4391 "Neighbor list\n"
4392 "Interface name\n"
4393 "JavaScript Object Notation\n")
4394 {
4395 struct ospf *ospf;
4396 u_short instance = 0;
4397 u_char uj = use_json(argc, argv);
4398
4399 VTY_GET_INTEGER ("Instance", instance, argv[0]);
4400 if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running)
4401 return CMD_SUCCESS;
4402
4403 return show_ip_ospf_neighbor_int_common(vty, ospf, 1, argv, uj);
4404 }
4405
4406 static void
4407 show_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)
4409 {
4410 char timebuf[OSPF_TIME_DUMP_SIZE];
4411 json_object *json_sub = NULL;
4412
4413 if (use_json)
4414 json_sub = json_object_new_object();
4415 else /* Show neighbor ID. */
4416 vty_out (vty, " Neighbor %s,", "-");
4417
4418 /* Show interface address. */
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
4425 /* Show Area ID. */
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
4435 /* Show neighbor priority and state. */
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
4445 /* Show state changes. */
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);
4450
4451 /* Show PollInterval */
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);
4456
4457 /* Show poll-interval timer. */
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);
4469
4470 /* Show poll-interval timer thread. */
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);
4482 }
4483
4484 static void
4485 show_ip_ospf_neighbor_detail_sub (struct vty *vty, struct ospf_interface *oi,
4486 struct ospf_neighbor *nbr, u_char use_json, json_object *json)
4487 {
4488 char timebuf[OSPF_TIME_DUMP_SIZE];
4489 json_object *json_sub = NULL;
4490
4491 if (use_json)
4492 json_sub = json_object_new_object();
4493 else
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 }
4501
4502 /* Show interface address. */
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
4509 /* Show Area ID. */
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
4519 /* Show neighbor priority and state. */
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
4529 /* Show state changes. */
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
4535 if (nbr->ts_last_progress.tv_sec || nbr->ts_last_progress.tv_usec)
4536 {
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 }
4552 }
4553
4554 if (nbr->ts_last_regress.tv_sec || nbr->ts_last_regress.tv_usec)
4555 {
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 }
4572 }
4573
4574 /* Show Designated Rotuer ID. */
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
4580 /* Show Backup Designated Rotuer ID. */
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
4586 /* Show options. */
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
4596 /* Show Router Dead interval timer. */
4597 if (use_json)
4598 {
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);
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
4614 /* Show Database Summary list. */
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
4621 /* Show Link State Request list. */
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
4628 /* Show Link State Retransmission list. */
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
4635 /* Show inactivity timer thread. */
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
4645 /* Show Database Description retransmission thread. */
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
4655 /* Show Link State Request Retransmission thread. */
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
4665 /* Show Link State Update Retransmission thread. */
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 }
4682
4683 ospf_bfd_show_info(vty, nbr->bfd_info, json, use_json, 0);
4684 }
4685
4686 static int
4687 show_ip_ospf_neighbor_id_common (struct vty *vty, struct ospf *ospf,
4688 int arg_base, const char **argv, u_char use_json)
4689 {
4690 struct listnode *node;
4691 struct ospf_neighbor *nbr;
4692 struct ospf_interface *oi;
4693 struct in_addr router_id;
4694 int ret;
4695 json_object *json = NULL;
4696
4697 if (use_json)
4698 json = json_object_new_object();
4699
4700 if (ospf->instance)
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 }
4708
4709 ret = inet_aton (argv[arg_base], &router_id);
4710 if (!ret)
4711 {
4712 if (!use_json)
4713 vty_out (vty, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE);
4714 return CMD_WARNING;
4715 }
4716
4717 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
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 {
4727 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
4728 json_object_free(json);
4729 }
4730 else
4731 vty_out (vty, "%s", VTY_NEWLINE);
4732
4733 return CMD_SUCCESS;
4734 }
4735
4736 DEFUN (show_ip_ospf_neighbor_id,
4737 show_ip_ospf_neighbor_id_cmd,
4738 "show ip ospf neighbor A.B.C.D {json}",
4739 SHOW_STR
4740 IP_STR
4741 "OSPF information\n"
4742 "Neighbor list\n"
4743 "Neighbor ID\n"
4744 "JavaScript Object Notation\n")
4745 {
4746 struct ospf *ospf;
4747 u_char uj = use_json(argc, argv);
4748
4749 if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running)
4750 return CMD_SUCCESS;
4751
4752 return show_ip_ospf_neighbor_id_common(vty, ospf, 0, argv, uj);
4753 }
4754
4755 DEFUN (show_ip_ospf_instance_neighbor_id,
4756 show_ip_ospf_instance_neighbor_id_cmd,
4757 "show ip ospf <1-65535> neighbor A.B.C.D {json}",
4758 SHOW_STR
4759 IP_STR
4760 "OSPF information\n"
4761 "Instance ID\n"
4762 "Neighbor list\n"
4763 "Neighbor ID\n"
4764 "JavaScript Object Notation\n")
4765 {
4766 struct ospf *ospf;
4767 u_short instance = 0;
4768 u_char uj = use_json(argc, argv);
4769
4770 VTY_GET_INTEGER ("Instance", instance, argv[0]);
4771 if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running)
4772 return CMD_SUCCESS;
4773
4774 return show_ip_ospf_neighbor_id_common(vty, ospf, 1, argv, uj);
4775 }
4776
4777 static int
4778 show_ip_ospf_neighbor_detail_common (struct vty *vty, struct ospf *ospf, u_char use_json)
4779 {
4780 struct ospf_interface *oi;
4781 struct listnode *node;
4782 json_object *json = NULL;
4783
4784 if (use_json)
4785 json = json_object_new_object();
4786
4787 if (ospf->instance)
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 }
4795
4796 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
4797 {
4798 struct route_node *rn;
4799 struct ospf_neighbor *nbr;
4800
4801 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
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 }
4814 }
4815
4816 if (use_json)
4817 {
4818 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
4819 json_object_free(json);
4820 }
4821 else
4822 vty_out (vty, "%s", VTY_NEWLINE);
4823
4824 return CMD_SUCCESS;
4825 }
4826
4827 DEFUN (show_ip_ospf_neighbor_detail,
4828 show_ip_ospf_neighbor_detail_cmd,
4829 "show ip ospf neighbor detail {json}",
4830 SHOW_STR
4831 IP_STR
4832 "OSPF information\n"
4833 "Neighbor list\n"
4834 "detail of all neighbors\n"
4835 "JavaScript Object Notation\n")
4836 {
4837 struct ospf *ospf;
4838 u_char uj = use_json(argc, argv);
4839
4840 if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running)
4841 return CMD_SUCCESS;
4842
4843 return show_ip_ospf_neighbor_detail_common(vty, ospf, uj);
4844 }
4845
4846 DEFUN (show_ip_ospf_instance_neighbor_detail,
4847 show_ip_ospf_instance_neighbor_detail_cmd,
4848 "show ip ospf <1-65535> neighbor detail {json}",
4849 SHOW_STR
4850 IP_STR
4851 "OSPF information\n"
4852 "Instance ID\n"
4853 "Neighbor list\n"
4854 "detail of all neighbors\n"
4855 "JavaScript Object Notation\n")
4856 {
4857 struct ospf *ospf;
4858 u_short instance = 0;
4859 u_char uj = use_json(argc, argv);
4860
4861 VTY_GET_INTEGER ("Instance", instance, argv[0]);
4862 if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running)
4863 return CMD_SUCCESS;
4864
4865 return show_ip_ospf_neighbor_detail_common(vty, ospf, uj);
4866 }
4867
4868 static int
4869 show_ip_ospf_neighbor_detail_all_common (struct vty *vty, struct ospf *ospf, u_char use_json)
4870 {
4871 struct listnode *node;
4872 struct ospf_interface *oi;
4873 json_object *json = NULL;
4874
4875 if (use_json)
4876 json = json_object_new_object();
4877
4878 if (ospf->instance)
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 }
4886
4887 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
4888 {
4889 struct route_node *rn;
4890 struct ospf_neighbor *nbr;
4891 struct ospf_nbr_nbma *nbr_nbma;
4892
4893 for (rn = route_top (oi->nbrs); rn; rn = route_next (rn))
4894 if ((nbr = rn->info))
4895 if (nbr != oi->nbr_self)
4896 if (nbr->state != NSM_Down)
4897 show_ip_ospf_neighbor_detail_sub (vty, oi, rn->info, use_json, json);
4898
4899 if (oi->type == OSPF_IFTYPE_NBMA)
4900 {
4901 struct listnode *nd;
4902
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 {
4913 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
4914 json_object_free(json);
4915 }
4916 else
4917 {
4918 vty_out (vty, "%s", VTY_NEWLINE);
4919 }
4920
4921 return CMD_SUCCESS;
4922 }
4923
4924 DEFUN (show_ip_ospf_neighbor_detail_all,
4925 show_ip_ospf_neighbor_detail_all_cmd,
4926 "show ip ospf neighbor detail all {json}",
4927 SHOW_STR
4928 IP_STR
4929 "OSPF information\n"
4930 "Neighbor list\n"
4931 "detail of all neighbors\n"
4932 "include down status neighbor\n"
4933 "JavaScript Object Notation\n")
4934 {
4935 struct ospf *ospf;
4936 u_char uj = use_json(argc, argv);
4937
4938 if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running)
4939 return CMD_SUCCESS;
4940
4941 return show_ip_ospf_neighbor_detail_all_common(vty, ospf, uj);
4942 }
4943
4944 DEFUN (show_ip_ospf_instance_neighbor_detail_all,
4945 show_ip_ospf_instance_neighbor_detail_all_cmd,
4946 "show ip ospf <1-65535> neighbor detail all {json}",
4947 SHOW_STR
4948 IP_STR
4949 "OSPF information\n"
4950 "Instance ID\n"
4951 "Neighbor list\n"
4952 "detail of all neighbors\n"
4953 "include down status neighbor\n"
4954 "JavaScript Object Notation\n")
4955 {
4956 struct ospf *ospf;
4957 u_short instance = 0;
4958 u_char uj = use_json(argc, argv);
4959
4960 VTY_GET_INTEGER ("Instance", instance, argv[0]);
4961 if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running)
4962 return CMD_SUCCESS;
4963
4964 return show_ip_ospf_neighbor_detail_all_common(vty, ospf, uj);
4965 }
4966
4967 static int
4968 show_ip_ospf_neighbor_int_detail_common (struct vty *vty, struct ospf *ospf,
4969 int arg_base, const char **argv, u_char use_json)
4970 {
4971 struct ospf_interface *oi;
4972 struct interface *ifp;
4973 struct route_node *rn, *nrn;
4974 struct ospf_neighbor *nbr;
4975 json_object *json = NULL;
4976
4977 if (use_json)
4978 json = json_object_new_object();
4979
4980 if (ospf->instance)
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 }
4988
4989 ifp = if_lookup_by_name (argv[arg_base]);
4990 if (!ifp)
4991 {
4992 if (!use_json)
4993 vty_out (vty, "No such interface.%s", VTY_NEWLINE);
4994 return CMD_WARNING;
4995 }
4996
4997 for (rn = route_top (IF_OIFS (ifp)); rn; rn = route_next (rn))
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 {
5017 vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE);
5018 json_object_free(json);
5019 }
5020 else
5021 vty_out (vty, "%s", VTY_NEWLINE);
5022
5023 return CMD_SUCCESS;
5024 }
5025
5026 DEFUN (show_ip_ospf_neighbor_int_detail,
5027 show_ip_ospf_neighbor_int_detail_cmd,
5028 "show ip ospf neighbor IFNAME detail {json}",
5029 SHOW_STR
5030 IP_STR
5031 "OSPF information\n"
5032 "Neighbor list\n"
5033 "Interface name\n"
5034 "detail of all neighbors\n"
5035 "JavaScript Object Notation\n")
5036 {
5037 struct ospf *ospf;
5038 u_char uj = use_json(argc, argv);
5039
5040 if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running)
5041 return CMD_SUCCESS;
5042
5043 return show_ip_ospf_neighbor_int_detail_common(vty, ospf, 0, argv, uj);
5044 }
5045
5046 DEFUN (show_ip_ospf_instance_neighbor_int_detail,
5047 show_ip_ospf_instance_neighbor_int_detail_cmd,
5048 "show ip ospf <1-65535> neighbor IFNAME detail {json}",
5049 SHOW_STR
5050 IP_STR
5051 "OSPF information\n"
5052 "Instance ID\n"
5053 "Neighbor list\n"
5054 "Interface name\n"
5055 "detail of all neighbors\n"
5056 "JavaScript Object Notation\n")
5057 {
5058 struct ospf *ospf;
5059 u_short instance = 0;
5060 u_char uj = use_json(argc, argv);
5061
5062 VTY_GET_INTEGER ("Instance", instance, argv[0]);
5063 if ((ospf = ospf_lookup_instance(instance)) == NULL || !ospf->oi_running)
5064 return CMD_SUCCESS;
5065
5066 return show_ip_ospf_neighbor_int_detail_common(vty, ospf, 1, argv, uj);
5067 }
5068
5069 /* Show functions */
5070 static int
5071 show_lsa_summary (struct vty *vty, struct ospf_lsa *lsa, int self)
5072 {
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:
5105 case OSPF_AS_NSSA_LSA:
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:
5120 case OSPF_OPAQUE_LINK_LSA:
5121 case OSPF_OPAQUE_AREA_LSA:
5122 case OSPF_OPAQUE_AS_LSA:
5123 default:
5124 break;
5125 }
5126 vty_out (vty, VTY_NEWLINE);
5127 }
5128
5129 return 0;
5130 }
5131
5132 static const char *show_database_desc[] =
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",
5140 "Group Membership LSA",
5141 "NSSA-external Link States",
5142 "Type-8 LSA",
5143 "Link-Local Opaque-LSA",
5144 "Area-Local Opaque-LSA",
5145 "AS-external Opaque-LSA",
5146 };
5147
5148 static const char *show_database_header[] =
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",
5156 " --- header for Group Member ----",
5157 "Link ID ADV Router Age Seq# CkSum Route",
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",
5162 };
5163
5164 static void
5165 show_ip_ospf_database_header (struct vty *vty, struct ospf_lsa *lsa)
5166 {
5167 struct router_lsa *rlsa = (struct router_lsa*) lsa->data;
5168
5169 vty_out (vty, " LS age: %d%s", LS_AGE (lsa), VTY_NEWLINE);
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",
5175 lsa->flags,
5176 ((lsa->flags & OSPF_LSA_LOCAL_XLT) ? "(Translated from Type-7)" : ""),
5177 VTY_NEWLINE);
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
5205 const char *link_type_desc[] =
5206 {
5207 "(null)",
5208 "another Router (point-to-point)",
5209 "a Transit Network",
5210 "Stub Network",
5211 "a Virtual Link",
5212 };
5213
5214 const char *link_id_desc[] =
5215 {
5216 "(null)",
5217 "Neighboring Router ID",
5218 "Designated Router address",
5219 "Net",
5220 "Neighboring Router ID",
5221 };
5222
5223 const char *link_data_desc[] =
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. */
5233 static void
5234 show_ip_ospf_database_router_links (struct vty *vty,
5235 struct router_lsa *rl)
5236 {
5237 int len, type;
5238 unsigned int i;
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. */
5259 static int
5260 show_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);
5272 vty_out (vty, "%s", VTY_NEWLINE);
5273 }
5274
5275 return 0;
5276 }
5277
5278 /* Show network-LSA detail information. */
5279 static int
5280 show_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. */
5306 static int
5307 show_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);
5319 vty_out (vty, "%s", VTY_NEWLINE);
5320 }
5321
5322 return 0;
5323 }
5324
5325 /* Show summary-ASBR-LSA detail information. */
5326 static int
5327 show_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);
5339 vty_out (vty, "%s", VTY_NEWLINE);
5340 }
5341
5342 return 0;
5343 }
5344
5345 /* Show AS-external-LSA detail information. */
5346 static int
5347 show_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
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);
5368 }
5369
5370 return 0;
5371 }
5372
5373 #if 0
5374 static int
5375 show_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
5381 zlog_debug( " Network Mask: /%d%s",
5382 ip_masklen (al->mask), "\n");
5383 zlog_debug( " Metric Type: %s%s",
5384 IS_EXTERNAL_METRIC (al->e[0].tos) ?
5385 "2 (Larger than any link state path)" : "1", "\n");
5386 zlog_debug( " TOS: 0%s", "\n");
5387 zlog_debug( " Metric: %d%s",
5388 GET_METRIC (al->e[0].metric), "\n");
5389 zlog_debug( " Forward Address: %s%s",
5390 inet_ntoa (al->e[0].fwd_addr), "\n");
5391
5392 zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI"%s%s",
5393 (route_tag_t)ntohl (al->e[0].route_tag), "\n", "\n");
5394
5395 return 0;
5396 }
5397 #endif
5398
5399 /* Show AS-NSSA-LSA detail information. */
5400 static int
5401 show_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
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);
5422 }
5423
5424 return 0;
5425 }
5426
5427 static int
5428 show_func_dummy (struct vty *vty, struct ospf_lsa *lsa)
5429 {
5430 return 0;
5431 }
5432
5433 static int
5434 show_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 }
5445
5446 int (*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,
5454 show_func_dummy,
5455 show_as_nssa_lsa_detail, /* almost same as external */
5456 NULL, /* type-8 */
5457 show_opaque_lsa_detail,
5458 show_opaque_lsa_detail,
5459 show_opaque_lsa_detail,
5460 };
5461
5462 static void
5463 show_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
5483 static void
5484 show_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 {
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. */
5508 static void
5509 show_lsa_detail (struct vty *vty, struct ospf *ospf, int type,
5510 struct in_addr *id, struct in_addr *adv_router)
5511 {
5512 struct listnode *node;
5513 struct ospf_area *area;
5514
5515 switch (type)
5516 {
5517 case OSPF_AS_EXTERNAL_LSA:
5518 case OSPF_OPAQUE_AS_LSA:
5519 vty_out (vty, " %s %s%s",
5520 show_database_desc[type],
5521 VTY_NEWLINE, VTY_NEWLINE);
5522 show_lsa_detail_proc (vty, AS_LSDB (ospf, type), id, adv_router);
5523 break;
5524 default:
5525 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
5526 {
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
5536 static void
5537 show_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 {
5547 if (CHECK_FLAG (lsa->flags, OSPF_LSA_LOCAL_XLT))
5548 continue;
5549 if (show_function[lsa->data->type] != NULL)
5550 show_function[lsa->data->type] (vty, lsa);
5551 }
5552 }
5553
5554 /* Show detail LSA information. */
5555 static void
5556 show_lsa_detail_adv_router (struct vty *vty, struct ospf *ospf, int type,
5557 struct in_addr *adv_router)
5558 {
5559 struct listnode *node;
5560 struct ospf_area *area;
5561
5562 switch (type)
5563 {
5564 case OSPF_AS_EXTERNAL_LSA:
5565 case OSPF_OPAQUE_AS_LSA:
5566 vty_out (vty, " %s %s%s",
5567 show_database_desc[type],
5568 VTY_NEWLINE, VTY_NEWLINE);
5569 show_lsa_detail_adv_router_proc (vty, AS_LSDB (ospf, type),
5570 adv_router);
5571 break;
5572 default:
5573 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
5574 {
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
5585 static void
5586 show_ip_ospf_database_summary (struct vty *vty, struct ospf *ospf, int self)
5587 {
5588 struct ospf_lsa *lsa;
5589 struct route_node *rn;
5590 struct ospf_area *area;
5591 struct listnode *node;
5592 int type;
5593
5594 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
5595 {
5596 for (type = OSPF_MIN_LSA; type < OSPF_MAX_LSA; type++)
5597 {
5598 switch (type)
5599 {
5600 case OSPF_AS_EXTERNAL_LSA:
5601 case OSPF_OPAQUE_AS_LSA:
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
5615 LSDB_LOOP (AREA_LSDB (area, type), rn, lsa)
5616 show_lsa_summary (vty, lsa, self);
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:
5628 case OSPF_OPAQUE_AS_LSA:
5629 break;
5630 default:
5631 continue;
5632 }
5633 if (ospf_lsdb_count_self (ospf->lsdb, type) ||
5634 (!self && ospf_lsdb_count (ospf->lsdb, type)))
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);
5641
5642 LSDB_LOOP (AS_LSDB (ospf, type), rn, lsa)
5643 show_lsa_summary (vty, lsa, self);
5644
5645 vty_out (vty, "%s", VTY_NEWLINE);
5646 }
5647 }
5648
5649 vty_out (vty, "%s", VTY_NEWLINE);
5650 }
5651
5652 static void
5653 show_ip_ospf_database_maxage (struct vty *vty, struct ospf *ospf)
5654 {
5655 struct route_node *rn;
5656
5657 vty_out (vty, "%s MaxAge Link States:%s%s",
5658 VTY_NEWLINE, VTY_NEWLINE, VTY_NEWLINE);
5659
5660 for (rn = route_top (ospf->maxage_lsa); rn; rn = route_next (rn))
5661 {
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 }
5674 }
5675 }
5676
5677 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
5678 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
5679
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"
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
5701 static int
5702 show_ip_ospf_database_common (struct vty *vty, struct ospf *ospf,
5703 int arg_base, int argc, const char **argv)
5704 {
5705 int type, ret;
5706 struct in_addr id, adv_router;
5707
5708 if (ospf->instance)
5709 vty_out (vty, "%sOSPF Instance: %d%s", VTY_NEWLINE, ospf->instance,
5710 VTY_NEWLINE);
5711
5712 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
5713 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
5714
5715 /* Show all LSA. */
5716 if (argc == arg_base + 0)
5717 {
5718 show_ip_ospf_database_summary (vty, ospf, 0);
5719 return CMD_SUCCESS;
5720 }
5721
5722 /* Set database type to show. */
5723 if (strncmp (argv[arg_base + 0], "r", 1) == 0)
5724 type = OSPF_ROUTER_LSA;
5725 else if (strncmp (argv[arg_base + 0], "ne", 2) == 0)
5726 type = OSPF_NETWORK_LSA;
5727 else if (strncmp (argv[arg_base + 0], "ns", 2) == 0)
5728 type = OSPF_AS_NSSA_LSA;
5729 else if (strncmp (argv[arg_base + 0], "su", 2) == 0)
5730 type = OSPF_SUMMARY_LSA;
5731 else if (strncmp (argv[arg_base + 0], "a", 1) == 0)
5732 type = OSPF_ASBR_SUMMARY_LSA;
5733 else if (strncmp (argv[arg_base + 0], "e", 1) == 0)
5734 type = OSPF_AS_EXTERNAL_LSA;
5735 else if (strncmp (argv[arg_base + 0], "se", 2) == 0)
5736 {
5737 show_ip_ospf_database_summary (vty, ospf, 1);
5738 return CMD_SUCCESS;
5739 }
5740 else if (strncmp (argv[arg_base + 0], "m", 1) == 0)
5741 {
5742 show_ip_ospf_database_maxage (vty, ospf);
5743 return CMD_SUCCESS;
5744 }
5745 else if (strncmp (argv[arg_base + 0], "opaque-l", 8) == 0)
5746 type = OSPF_OPAQUE_LINK_LSA;
5747 else if (strncmp (argv[arg_base + 0], "opaque-ar", 9) == 0)
5748 type = OSPF_OPAQUE_AREA_LSA;
5749 else if (strncmp (argv[arg_base + 0], "opaque-as", 9) == 0)
5750 type = OSPF_OPAQUE_AS_LSA;
5751 else
5752 return CMD_WARNING;
5753
5754 /* `show ip ospf database LSA'. */
5755 if (argc == arg_base + 1)
5756 show_lsa_detail (vty, ospf, type, NULL, NULL);
5757 else if (argc >= arg_base + 2)
5758 {
5759 ret = inet_aton (argv[arg_base + 1], &id);
5760 if (!ret)
5761 return CMD_WARNING;
5762
5763 /* `show ip ospf database LSA ID'. */
5764 if (argc == arg_base + 2)
5765 show_lsa_detail (vty, ospf, type, &id, NULL);
5766 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
5767 else if (argc == arg_base + 3)
5768 {
5769 if (strncmp (argv[arg_base + 2], "s", 1) == 0)
5770 adv_router = ospf->router_id;
5771 else
5772 {
5773 ret = inet_aton (argv[arg_base + 2], &adv_router);
5774 if (!ret)
5775 return CMD_WARNING;
5776 }
5777 show_lsa_detail (vty, ospf, type, &id, &adv_router);
5778 }
5779 }
5780
5781 return CMD_SUCCESS;
5782 }
5783
5784 DEFUN (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
5794 if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running)
5795 return CMD_SUCCESS;
5796
5797 return (show_ip_ospf_database_common(vty, ospf, 0, argc, argv));
5798 }
5799
5800 ALIAS (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
5811 ALIAS (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
5821 ALIAS (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
5833 ALIAS (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
5845 DEFUN (show_ip_ospf_instance_database,
5846 show_ip_ospf_instance_database_cmd,
5847 "show ip ospf <1-65535> database",
5848 SHOW_STR
5849 IP_STR
5850 "OSPF information\n"
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
5859 if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running)
5860 return CMD_SUCCESS;
5861
5862 return (show_ip_ospf_database_common(vty, ospf, 1, argc, argv));
5863 }
5864
5865 ALIAS (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
5877 ALIAS (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
5888 ALIAS (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"
5895 "Database summary\n"
5896 OSPF_LSA_TYPES_DESC
5897 "Link State ID (as an IP address)\n"
5898 "Advertising Router link states\n"
5899 "Advertising Router (as an IP address)\n")
5900
5901 ALIAS (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
5915 static int
5916 show_ip_ospf_database_type_adv_router_common (struct vty *vty, struct ospf *ospf,
5917 int arg_base, int argc, const char **argv)
5918 {
5919 int type, ret;
5920 struct in_addr adv_router;
5921
5922 if (ospf->instance)
5923 vty_out (vty, "%sOSPF Instance: %d%s", VTY_NEWLINE, ospf->instance,
5924 VTY_NEWLINE);
5925
5926 vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE,
5927 inet_ntoa (ospf->router_id), VTY_NEWLINE, VTY_NEWLINE);
5928
5929 if (argc != arg_base + 2)
5930 return CMD_WARNING;
5931
5932 /* Set database type to show. */
5933 if (strncmp (argv[arg_base + 0], "r", 1) == 0)
5934 type = OSPF_ROUTER_LSA;
5935 else if (strncmp (argv[arg_base + 0], "ne", 2) == 0)
5936 type = OSPF_NETWORK_LSA;
5937 else if (strncmp (argv[arg_base + 0], "ns", 2) == 0)
5938 type = OSPF_AS_NSSA_LSA;
5939 else if (strncmp (argv[arg_base + 0], "s", 1) == 0)
5940 type = OSPF_SUMMARY_LSA;
5941 else if (strncmp (argv[arg_base + 0], "a", 1) == 0)
5942 type = OSPF_ASBR_SUMMARY_LSA;
5943 else if (strncmp (argv[arg_base + 0], "e", 1) == 0)
5944 type = OSPF_AS_EXTERNAL_LSA;
5945 else if (strncmp (argv[arg_base + 0], "opaque-l", 8) == 0)
5946 type = OSPF_OPAQUE_LINK_LSA;
5947 else if (strncmp (argv[arg_base + 0], "opaque-ar", 9) == 0)
5948 type = OSPF_OPAQUE_AREA_LSA;
5949 else if (strncmp (argv[arg_base + 0], "opaque-as", 9) == 0)
5950 type = OSPF_OPAQUE_AS_LSA;
5951 else
5952 return CMD_WARNING;
5953
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
5969 DEFUN (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
5982 if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running)
5983 return CMD_SUCCESS;
5984
5985 return (show_ip_ospf_database_type_adv_router_common(vty, ospf, 0, argc, argv));
5986 }
5987
5988 ALIAS (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
5998 DEFUN (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]);
6014
6015 if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running)
6016 return CMD_SUCCESS;
6017
6018 return (show_ip_ospf_database_type_adv_router_common(vty, ospf, 1, argc, argv));
6019 }
6020
6021 ALIAS (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|)",
6024 SHOW_STR
6025 IP_STR
6026 "OSPF information\n"
6027 "Instance ID\n"
6028 "Database summary\n"
6029 OSPF_LSA_TYPES_DESC
6030 "Self-originated link states\n")
6031
6032 DEFUN (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
6084 ALIAS (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
6093 DEFUN (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 {
6111 ret = inet_aton(argv[0], &addr);
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
6129 ALIAS (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
6136 DEFUN (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 */
6202 if (params->auth_type == auth_type)
6203 {
6204 params->auth_type = OSPF_AUTH_NOTSET;
6205 UNSET_IF_PARAM (params, auth_type);
6206 }
6207
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
6229 ALIAS (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
6239 DEFUN (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;
6252 struct route_node *rn;
6253
6254 ifp = vty->index;
6255 params = IF_DEF_PARAMS (ifp);
6256
6257 if (argc == 1)
6258 {
6259 ret = inet_aton(argv[0], &addr);
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)
6269 {
6270 vty_out (vty, "Ip Address specified is unknown%s", VTY_NEWLINE);
6271 return CMD_WARNING;
6272 }
6273
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
6283 {
6284 /*
6285 * When a user enters 'no ip ospf authentication'
6286 * We should remove all authentication types from
6287 * the interface.
6288 */
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
6297 for (rn = route_top (IF_OIFS_PARAMS (ifp)); rn; rn = route_next (rn))
6298 {
6299 if ((params = rn->info))
6300 {
6301
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 }
6316 }
6317
6318 return CMD_SUCCESS;
6319 }
6320
6321 ALIAS (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
6329 DEFUN (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
6360 memset (params->auth_simple, 0, OSPF_AUTH_SIMPLE_SIZE + 1);
6361 strncpy ((char *) params->auth_simple, argv[0], OSPF_AUTH_SIMPLE_SIZE);
6362 SET_IF_PARAM (params, auth_simple);
6363
6364 return CMD_SUCCESS;
6365 }
6366
6367 ALIAS (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
6375 ALIAS_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)")
6381
6382 DEFUN (no_ip_ospf_authentication_key,
6383 no_ip_ospf_authentication_key_authkey_addr_cmd,
6384 "no ip ospf authentication-key AUTH_KEY A.B.C.D",
6385 NO_STR
6386 "IP Information\n"
6387 "OSPF interface commands\n"
6388 "Authentication password (key)\n"
6389 "The OSPF password (key)")
6390 {
6391 struct interface *ifp;
6392 struct in_addr addr;
6393 struct ospf_if_params *params;
6394 int ret;
6395
6396 ifp = vty->index;
6397 params = IF_DEF_PARAMS (ifp);
6398
6399 if (argc == 2)
6400 {
6401 ret = inet_aton(argv[1], &addr);
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
6426 ALIAS (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
6434 ALIAS (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
6442 ALIAS (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
6449 ALIAS (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
6457 ALIAS (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
6466 DEFUN (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);
6511 strncpy ((char *) ck->auth_key, argv[1], OSPF_AUTH_MD5_SIZE);
6512
6513 ospf_crypt_key_add (params->auth_crypt, ck);
6514 SET_IF_PARAM (params, auth_crypt);
6515
6516 return CMD_SUCCESS;
6517 }
6518
6519 ALIAS (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
6529 ALIAS_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)")
6537
6538 DEFUN (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
6594 ALIAS (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
6605 DEFUN (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
6659 ALIAS (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
6668 ALIAS (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
6676 DEFUN (ip_ospf_cost,
6677 ip_ospf_cost_u32_inet4_cmd,
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
6724 ALIAS (ip_ospf_cost,
6725 ip_ospf_cost_u32_cmd,
6726 "ip ospf cost <1-65535>",
6727 "IP Information\n"
6728 "OSPF interface commands\n"
6729 "Interface cost\n"
6730 "Cost")
6731
6732 ALIAS_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
6739 ALIAS_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")
6746
6747 DEFUN (no_ip_ospf_cost,
6748 no_ip_ospf_cost_inet4_cmd,
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
6792 ALIAS (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
6800 ALIAS (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
6807 ALIAS (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
6815 DEFUN (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
6873 ALIAS (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
6881 ALIAS (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
6891 ALIAS (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")
6899
6900 static void
6901 ospf_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
6916 static int
6917 ospf_vty_dead_interval_set (struct vty *vty, const char *interval_str,
6918 const char *nbr_str,
6919 const char *fast_hello_str)
6920 {
6921 struct interface *ifp = vty->index;
6922 u_int32_t seconds;
6923 u_char hellomult;
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);
6931
6932 if (nbr_str)
6933 {
6934 ret = inet_aton(nbr_str, &addr);
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
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
6971 SET_IF_PARAM (params, v_wait);
6972 params->v_wait = seconds;
6973
6974 /* Update timer values in neighbor structure. */
6975 if (nbr_str)
6976 {
6977 struct ospf *ospf;
6978 if ((ospf = ospf_lookup()))
6979 {
6980 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
6981 if (oi)
6982 ospf_nbr_timer_update (oi);
6983 }
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
6995
6996 DEFUN (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
7011 ALIAS (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
7019 ALIAS_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")
7025
7026 DEFUN (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
7043 ALIAS (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
7053 DEFUN (no_ip_ospf_dead_interval,
7054 no_ip_ospf_dead_interval_addr_cmd,
7055 "no ip ospf dead-interval <1-65535> A.B.C.D",
7056 NO_STR
7057 "IP Information\n"
7058 "OSPF interface commands\n"
7059 "Interval after which a neighbor is declared dead\n"
7060 "Seconds\n"
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;
7069
7070 ifp = vty->index;
7071 params = IF_DEF_PARAMS (ifp);
7072
7073 if (argc == 2)
7074 {
7075 ret = inet_aton(argv[1], &addr);
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;
7090
7091 UNSET_IF_PARAM (params, fast_hello);
7092 params->fast_hello = OSPF_FAST_HELLO_DEFAULT;
7093
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 {
7103 struct ospf *ospf;
7104
7105 if ((ospf = ospf_lookup()))
7106 {
7107 oi = ospf_if_lookup_by_local_addr (ospf, ifp, addr);
7108 if (oi)
7109 ospf_nbr_timer_update (oi);
7110 }
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
7122 ALIAS (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
7131 ALIAS (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
7139 ALIAS (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
7146 ALIAS (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
7158 ALIAS (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
7169 DEFUN (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
7209 SET_IF_PARAM (params, v_hello);
7210 params->v_hello = seconds;
7211
7212 return CMD_SUCCESS;
7213 }
7214
7215 ALIAS (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
7223 ALIAS_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")
7229
7230 DEFUN (no_ip_ospf_hello_interval,
7231 no_ip_ospf_hello_interval_addr_cmd,
7232 "no ip ospf hello-interval <1-65535> A.B.C.D",
7233 NO_STR
7234 "IP Information\n"
7235 "OSPF interface commands\n"
7236 "Time between HELLO packets\n"
7237 "Seconds\n"
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
7248 if (argc == 2)
7249 {
7250 ret = inet_aton(argv[1], &addr);
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);
7264 params->v_hello = OSPF_HELLO_INTERVAL_DEFAULT;
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
7275 ALIAS (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
7284 ALIAS (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
7292 ALIAS (no_ip_ospf_hello_interval,
7293 no_ospf_hello_interval_cmd,
7294 "no ospf hello-interval <1-65535>",
7295 NO_STR
7296 "OSPF interface commands\n"
7297 "Time between HELLO packets\n"
7298 "Seconds\n")
7299
7300 DEFUN (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;
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
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
7354 ALIAS_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")
7363
7364 DEFUN (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
7376 IF_DEF_PARAMS (ifp)->type = ospf_default_iftype(ifp);
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
7400 ALIAS (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
7412 ALIAS (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
7419 ALIAS (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
7430 DEFUN (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;
7440 long priority;
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
7492 ALIAS (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
7500 ALIAS_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")
7506
7507 DEFUN (no_ip_ospf_priority,
7508 no_ip_ospf_priority_addr_cmd,
7509 "no ip ospf priority <0-255> A.B.C.D",
7510 NO_STR
7511 "IP Information\n"
7512 "OSPF interface commands\n"
7513 "Router priority\n"
7514 "Priority\n"
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
7526 if (argc == 2)
7527 {
7528 ret = inet_aton(argv[1], &addr);
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
7568 ALIAS (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
7576 ALIAS (no_ip_ospf_priority,
7577 no_ip_ospf_priority_cmd,
7578 "no ip ospf priority <0-255>",
7579 NO_STR
7580 "IP Information\n"
7581 "OSPF interface commands\n"
7582 "Router priority\n"
7583 "Priority\n")
7584
7585 ALIAS (no_ip_ospf_priority,
7586 no_ospf_priority_cmd,
7587 "no ospf priority <0-255>",
7588 NO_STR
7589 "OSPF interface commands\n"
7590 "Router priority\n"
7591 "Priority\n")
7592
7593
7594 DEFUN (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
7640 ALIAS (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
7648 ALIAS_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")
7654
7655 DEFUN (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;
7668 int addr_index;
7669
7670 ifp = vty->index;
7671 params = IF_DEF_PARAMS (ifp);
7672
7673 if (argc >= 1)
7674 {
7675 if (argc == 1)
7676 addr_index = 0;
7677 else
7678 addr_index = 1;
7679
7680 ret = inet_aton(argv[addr_index], &addr);
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
7705 ALIAS (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
7715 ALIAS (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
7723 ALIAS (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
7730 DEFUN (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
7752 DEFUN (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
7797 ALIAS (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
7805 ALIAS_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")
7811
7812 DEFUN (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;
7825 int addr_index;
7826
7827 ifp = vty->index;
7828 params = IF_DEF_PARAMS (ifp);
7829
7830 if (argc >= 1)
7831 {
7832 if (argc == 1)
7833 addr_index = 0;
7834 else
7835 addr_index = 1;
7836
7837 ret = inet_aton(argv[addr_index], &addr);
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
7862 ALIAS (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
7872 ALIAS (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
7880 ALIAS (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
7887 DEFUN (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
7909 DEFUN (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;
7924 u_short instance = 0;
7925
7926 if (argc == 2)
7927 VTY_GET_INTEGER ("Instance", instance, argv[0]);
7928
7929 ospf = ospf_lookup_instance (instance);
7930 if (ospf == NULL)
7931 {
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 }
7939 return CMD_SUCCESS;
7940 }
7941
7942 ret = ospf_str2area_id (argv[instance ? 1 : 0], &area_id, &format);
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 {
7958 vty_out (vty,
7959 "Must remove previous area config before changing ospf area %s",
7960 VTY_NEWLINE);
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
7980 ALIAS (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
7990 DEFUN (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;
8001 u_short instance = 0;
8002
8003 if ((ospf = ospf_lookup_instance (instance)) == NULL)
8004 return CMD_SUCCESS;
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
8018 ALIAS (no_ip_ospf_area,
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
8028 DEFUN (no_ip_ospf_instance_area,
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")
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
8059 ALIAS (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")
8069
8070 DEFUN (ospf_redistribute_source,
8071 ospf_redistribute_source_cmd,
8072 "redistribute " FRR_REDIST_STR_OSPFD
8073 " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
8074 REDIST_STR
8075 FRR_REDIST_HELP_STR_OSPFD
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 {
8084 struct ospf *ospf = vty->index;
8085 int source;
8086 int type = -1;
8087 int metric = -1;
8088 struct ospf_redist *red;
8089
8090 if (!ospf)
8091 return CMD_SUCCESS;
8092
8093 if (argc < 4)
8094 return CMD_WARNING; /* should not happen */
8095
8096 if (!ospf)
8097 return CMD_SUCCESS;
8098
8099 /* Get distribute source. */
8100 source = proto_redistnum(AFI_IP, argv[0]);
8101 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
8102 return CMD_WARNING;
8103
8104 /* Get metric value. */
8105 if (argv[1] != NULL)
8106 if (!str2metric (argv[1], &metric))
8107 return CMD_WARNING;
8108
8109 /* Get metric type. */
8110 if (argv[2] != NULL)
8111 if (!str2metric_type (argv[2], &type))
8112 return CMD_WARNING;
8113
8114 red = ospf_redist_add(ospf, source, 0);
8115
8116 if (argv[3] != NULL)
8117 ospf_routemap_set (red, argv[3]);
8118 else
8119 ospf_routemap_unset (red);
8120
8121 return ospf_redistribute_set (ospf, source, 0, type, metric);
8122 }
8123
8124 DEFUN (no_ospf_redistribute_source,
8125 no_ospf_redistribute_source_cmd,
8126 "no redistribute " FRR_REDIST_STR_OSPFD
8127 " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
8128 NO_STR
8129 REDIST_STR
8130 FRR_REDIST_HELP_STR_OSPFD
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")
8138 {
8139 struct ospf *ospf = vty->index;
8140 int source;
8141 struct ospf_redist *red;
8142 if (!ospf)
8143 return CMD_SUCCESS;
8144
8145 source = proto_redistnum(AFI_IP, argv[0]);
8146 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
8147 return CMD_WARNING;
8148
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
8157 DEFUN (ospf_redistribute_instance_source,
8158 ospf_redistribute_instance_source_cmd,
8159 "redistribute (ospf|table) <1-65535>"
8160 " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
8161 REDIST_STR
8162 "Open Shortest Path First\n"
8163 "Non-main Kernel Routing Table\n"
8164 "Instance ID/Table ID\n"
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
8180 if (!ospf)
8181 return CMD_SUCCESS;
8182
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]);
8189
8190 if (!ospf)
8191 return CMD_SUCCESS;
8192
8193 if ((source == ZEBRA_ROUTE_OSPF) && !ospf->instance)
8194 {
8195 vty_out (vty, "Instance redistribution in non-instanced OSPF not allowed%s",
8196 VTY_NEWLINE);
8197 return CMD_WARNING;
8198 }
8199
8200 if ((source == ZEBRA_ROUTE_OSPF) && (ospf->instance == instance))
8201 {
8202 vty_out (vty, "Same instance OSPF redistribution not allowed%s",
8203 VTY_NEWLINE);
8204 return CMD_WARNING;
8205 }
8206
8207 /* Get metric value. */
8208 if (argv[2] != NULL)
8209 if (!str2metric (argv[2], &metric))
8210 return CMD_WARNING;
8211
8212 /* Get metric type. */
8213 if (argv[3] != NULL)
8214 if (!str2metric_type (argv[3], &type))
8215 return CMD_WARNING;
8216
8217 red = ospf_redist_add(ospf, source, instance);
8218 if (argv[4] != NULL)
8219 ospf_routemap_set (red, argv[4]);
8220 else
8221 ospf_routemap_unset (red);
8222
8223 return ospf_redistribute_set (ospf, source, instance, type, metric);
8224 }
8225
8226 DEFUN (no_ospf_redistribute_instance_source,
8227 no_ospf_redistribute_instance_source_cmd,
8228 "no redistribute (ospf|table) <1-65535>"
8229 " {metric <0-16777214>|metric-type (1|2)|route-map WORD}",
8230 NO_STR
8231 REDIST_STR
8232 "Open Shortest Path First\n"
8233 "Non-main Kernel Routing Table\n"
8234 "Instance ID/Table Id\n"
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
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]);
8257
8258 if ((source == ZEBRA_ROUTE_OSPF) && !ospf->instance)
8259 {
8260 vty_out (vty, "Instance redistribution in non-instanced OSPF not allowed%s",
8261 VTY_NEWLINE);
8262 return CMD_WARNING;
8263 }
8264
8265 if ((source == ZEBRA_ROUTE_OSPF) && (ospf->instance == instance))
8266 {
8267 vty_out (vty, "Same instance OSPF redistribution not allowed%s",
8268 VTY_NEWLINE);
8269 return CMD_WARNING;
8270 }
8271
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);
8278 }
8279
8280 DEFUN (ospf_distribute_list_out,
8281 ospf_distribute_list_out_cmd,
8282 "distribute-list WORD out " FRR_REDIST_STR_OSPFD,
8283 "Filter networks in routing updates\n"
8284 "Access-list name\n"
8285 OUT_STR
8286 FRR_REDIST_HELP_STR_OSPFD)
8287 {
8288 struct ospf *ospf = vty->index;
8289 int source;
8290
8291 if (!ospf)
8292 return CMD_SUCCESS;
8293
8294 /* Get distribute source. */
8295 source = proto_redistnum(AFI_IP, argv[1]);
8296 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
8297 return CMD_WARNING;
8298
8299 return ospf_distribute_list_out_set (ospf, source, argv[0]);
8300 }
8301
8302 DEFUN (no_ospf_distribute_list_out,
8303 no_ospf_distribute_list_out_cmd,
8304 "no distribute-list WORD out " FRR_REDIST_STR_OSPFD,
8305 NO_STR
8306 "Filter networks in routing updates\n"
8307 "Access-list name\n"
8308 OUT_STR
8309 FRR_REDIST_HELP_STR_OSPFD)
8310 {
8311 struct ospf *ospf = vty->index;
8312 int source;
8313
8314 if (!ospf)
8315 return CMD_SUCCESS;
8316
8317 source = proto_redistnum(AFI_IP, argv[1]);
8318 if (source < 0 || source == ZEBRA_ROUTE_OSPF)
8319 return CMD_WARNING;
8320
8321 return ospf_distribute_list_out_unset (ospf, source, argv[0]);
8322 }
8323
8324 /* Default information originate. */
8325 DEFUN (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}",
8329 "Control distribution of default information\n"
8330 "Distribute a default route\n"
8331 "Always advertise default route\n"
8332 "OSPF default metric\n"
8333 "OSPF metric\n"
8334 "OSPF metric type for default routes\n"
8335 "Set OSPF External Type 1 metrics\n"
8336 "Set OSPF External Type 2 metrics\n"
8337 "Route map reference\n"
8338 "Pointer to route-map entries\n")
8339 {
8340 struct ospf *ospf = vty->index;
8341 int default_originate = DEFAULT_ORIGINATE_ZEBRA;
8342 int type = -1;
8343 int metric = -1;
8344 struct ospf_redist *red;
8345
8346 if (!ospf)
8347 return CMD_SUCCESS;
8348
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;
8355
8356 red = ospf_redist_add(ospf, DEFAULT_ROUTE, 0);
8357
8358 /* Get metric value. */
8359 if (argv[1] != NULL)
8360 if (!str2metric (argv[1], &metric))
8361 return CMD_WARNING;
8362
8363 /* Get metric type. */
8364 if (argv[2] != NULL)
8365 if (!str2metric_type (argv[2], &type))
8366 return CMD_WARNING;
8367
8368 if (argv[3] != NULL)
8369 ospf_routemap_set (red, argv[3]);
8370 else
8371 ospf_routemap_unset (red);
8372
8373 return ospf_redistribute_default_set (ospf, default_originate,
8374 type, metric);
8375 }
8376
8377 DEFUN (no_ospf_default_information_originate,
8378 no_ospf_default_information_originate_cmd,
8379 "no default-information originate"
8380 "{always|metric <0-16777214>|metric-type (1|2)|route-map WORD}",
8381 NO_STR
8382 "Control distribution of default information\n"
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")
8392 {
8393 struct ospf *ospf = vty->index;
8394 struct prefix_ipv4 p;
8395 struct ospf_external *ext;
8396 struct ospf_redist *red;
8397
8398 if (!ospf)
8399 return CMD_SUCCESS;
8400
8401 p.family = AF_INET;
8402 p.prefix.s_addr = 0;
8403 p.prefixlen = 0;
8404
8405 ospf_external_lsa_flush (ospf, DEFAULT_ROUTE, &p, 0);
8406
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);
8411 }
8412
8413 red = ospf_redist_lookup(ospf, DEFAULT_ROUTE, 0);
8414 if (!red)
8415 return CMD_SUCCESS;
8416
8417 ospf_routemap_unset (red);
8418 return ospf_redistribute_default_unset (ospf);
8419 }
8420
8421 DEFUN (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 {
8427 struct ospf *ospf = vty->index;
8428 int metric = -1;
8429
8430 if (!ospf)
8431 return CMD_SUCCESS;
8432
8433 if (!str2metric (argv[0], &metric))
8434 return CMD_WARNING;
8435
8436 ospf->default_metric = metric;
8437
8438 return CMD_SUCCESS;
8439 }
8440
8441 DEFUN (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 {
8447 struct ospf *ospf = vty->index;
8448
8449 if (!ospf)
8450 return CMD_SUCCESS;
8451
8452 ospf->default_metric = -1;
8453
8454 return CMD_SUCCESS;
8455 }
8456
8457 ALIAS (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
8464 DEFUN (ospf_distance,
8465 ospf_distance_cmd,
8466 "distance <1-255>",
8467 "Define an administrative distance\n"
8468 "OSPF Administrative distance\n")
8469 {
8470 struct ospf *ospf = vty->index;
8471
8472 if (!ospf)
8473 return CMD_SUCCESS;
8474
8475 ospf->distance_all = atoi (argv[0]);
8476
8477 return CMD_SUCCESS;
8478 }
8479
8480 DEFUN (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 {
8487 struct ospf *ospf = vty->index;
8488
8489 if (!ospf)
8490 return CMD_SUCCESS;
8491
8492 ospf->distance_all = 0;
8493
8494 return CMD_SUCCESS;
8495 }
8496
8497 DEFUN (no_ospf_distance_ospf,
8498 no_ospf_distance_ospf_cmd,
8499 "no distance ospf {intra-area <1-255>|inter-area <1-255>|external <1-255>}",
8500 NO_STR
8501 "Define an administrative distance\n"
8502 "OSPF Administrative distance\n"
8503 "Intra-area routes\n"
8504 "Distance for intra-area routes\n"
8505 "Inter-area routes\n"
8506 "Distance for inter-area routes\n"
8507 "External routes\n"
8508 "Distance for external routes\n")
8509 {
8510 struct ospf *ospf = vty->index;
8511
8512 if (!ospf)
8513 return CMD_SUCCESS;
8514
8515 if (argc < 3)
8516 return CMD_WARNING;
8517
8518 if (!ospf)
8519 return CMD_SUCCESS;
8520
8521 if (argv[0] != NULL)
8522 ospf->distance_intra = 0;
8523
8524 if (argv[1] != NULL)
8525 ospf->distance_inter = 0;
8526
8527 if (argv[2] != NULL)
8528 ospf->distance_external = 0;
8529
8530 if (argv[0] || argv[1] || argv[2])
8531 return CMD_SUCCESS;
8532
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;
8537
8538 return CMD_SUCCESS;
8539 }
8540
8541 DEFUN (ospf_distance_ospf,
8542 ospf_distance_ospf_cmd,
8543 "distance ospf "
8544 "{intra-area <1-255>|inter-area <1-255>|external <1-255>}",
8545 "Define an administrative distance\n"
8546 "OSPF Administrative distance\n"
8547 "Intra-area routes\n"
8548 "Distance for intra-area routes\n"
8549 "Inter-area routes\n"
8550 "Distance for inter-area routes\n"
8551 "External routes\n"
8552 "Distance for external routes\n")
8553 {
8554 struct ospf *ospf = vty->index;
8555
8556 if (!ospf)
8557 return CMD_SUCCESS;
8558
8559 if (argc < 3) /* should not happen */
8560 return CMD_WARNING;
8561
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 }
8568
8569 if (argv[0] != NULL)
8570 ospf->distance_intra = atoi(argv[0]);
8571
8572 if (argv[1] != NULL)
8573 ospf->distance_inter = atoi(argv[1]);
8574
8575 if (argv[2] != NULL)
8576 ospf->distance_external = atoi(argv[2]);
8577
8578 return CMD_SUCCESS;
8579 }
8580
8581 DEFUN (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 {
8588 struct ospf *ospf = vty->index;
8589
8590 if (!ospf)
8591 return CMD_SUCCESS;
8592
8593 ospf_distance_set (vty, ospf, argv[0], argv[1], NULL);
8594
8595 return CMD_SUCCESS;
8596 }
8597
8598 DEFUN (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 {
8606 struct ospf *ospf = vty->index;
8607
8608 if (!ospf)
8609 return CMD_SUCCESS;
8610
8611 ospf_distance_unset (vty, ospf, argv[0], argv[1], NULL);
8612
8613 return CMD_SUCCESS;
8614 }
8615
8616 DEFUN (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 {
8624 struct ospf *ospf = vty->index;
8625
8626 if (!ospf)
8627 return CMD_SUCCESS;
8628
8629 ospf_distance_set (vty, ospf, argv[0], argv[1], argv[2]);
8630
8631 return CMD_SUCCESS;
8632 }
8633
8634 DEFUN (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 {
8643 struct ospf *ospf = vty->index;
8644
8645 if (!ospf)
8646 return CMD_SUCCESS;
8647
8648 ospf_distance_unset (vty, ospf, argv[0], argv[1], argv[2]);
8649
8650 return CMD_SUCCESS;
8651 }
8652
8653 DEFUN (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
8695 ALIAS (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
8703 DEFUN (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
8745 ALIAS (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")
8751
8752 DEFUN (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;
8762
8763 if (!ospf)
8764 return CMD_SUCCESS;
8765
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))
8771 ospf_router_lsa_update_area (area);
8772 }
8773
8774 /* Allows for areas configured later to get the property */
8775 ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_SET;
8776
8777 return CMD_SUCCESS;
8778 }
8779
8780 DEFUN (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
8792 if (!ospf)
8793 return CMD_SUCCESS;
8794
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);
8804 ospf_router_lsa_update_area (area);
8805 }
8806 }
8807 ospf->stub_router_admin_set = OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET;
8808 return CMD_SUCCESS;
8809 }
8810
8811 DEFUN (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
8822 if (!ospf)
8823 return CMD_SUCCESS;
8824
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
8838 DEFUN (no_ospf_max_metric_router_lsa_startup,
8839 no_ospf_max_metric_router_lsa_startup_cmd,
8840 "no max-metric router-lsa on-startup <5-86400>",
8841 NO_STR
8842 "OSPF maximum / infinite-distance metric\n"
8843 "Advertise own Router-LSA with infinite distance (stub router)\n"
8844 "Automatically advertise stub Router-LSA on startup of OSPF\n"
8845 "Time (seconds) to advertise self as stub-router\n")
8846 {
8847 struct listnode *ln;
8848 struct ospf_area *area;
8849 struct ospf *ospf = vty->index;
8850
8851 if (!ospf)
8852 return CMD_SUCCESS;
8853
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);
8865 ospf_router_lsa_update_area (area);
8866 }
8867 }
8868 return CMD_SUCCESS;
8869 }
8870
8871 ALIAS (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
8879 DEFUN (ospf_max_metric_router_lsa_shutdown,
8880 ospf_max_metric_router_lsa_shutdown_cmd,
8881 "max-metric router-lsa on-shutdown <5-100>",
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
8890 if (!ospf)
8891 return CMD_SUCCESS;
8892
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
8906 DEFUN (no_ospf_max_metric_router_lsa_shutdown,
8907 no_ospf_max_metric_router_lsa_shutdown_cmd,
8908 "no max-metric router-lsa on-shutdown <5-100>",
8909 NO_STR
8910 "OSPF maximum / infinite-distance metric\n"
8911 "Advertise own Router-LSA with infinite distance (stub router)\n"
8912 "Advertise stub-router prior to full shutdown of OSPF\n"
8913 "Time (seconds) to wait till full shutdown\n")
8914 {
8915 struct ospf *ospf = vty->index;
8916
8917 if (!ospf)
8918 return CMD_SUCCESS;
8919
8920 ospf->stub_router_shutdown_time = OSPF_STUB_ROUTER_UNCONFIGURED;
8921
8922 return CMD_SUCCESS;
8923 }
8924
8925 ALIAS (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
8933 static void
8934 config_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 }
8956
8957 static void
8958 show_ip_ospf_route_network (struct vty *vty, struct route_table *rt)
8959 {
8960 struct route_node *rn;
8961 struct ospf_route *or;
8962 struct listnode *pnode, *pnnode;
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)
8993 for (ALL_LIST_ELEMENTS (or->paths, pnode, pnnode, path))
8994 {
8995 if (if_lookup_by_index(path->ifindex))
8996 {
8997 if (path->nexthop.s_addr == 0)
8998 vty_out (vty, "%24s directly attached to %s%s",
8999 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
9000 else
9001 vty_out (vty, "%24s via %s, %s%s", "",
9002 inet_ntoa (path->nexthop),
9003 ifindex2ifname (path->ifindex), VTY_NEWLINE);
9004 }
9005 }
9006 }
9007 vty_out (vty, "%s", VTY_NEWLINE);
9008 }
9009
9010 static void
9011 show_ip_ospf_route_router (struct vty *vty, struct route_table *rtrs)
9012 {
9013 struct route_node *rn;
9014 struct ospf_route *or;
9015 struct listnode *pnode;
9016 struct listnode *node;
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
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 {
9045 if (if_lookup_by_index(path->ifindex))
9046 {
9047 if (path->nexthop.s_addr == 0)
9048 vty_out (vty, "%24s directly attached to %s%s",
9049 "", ifindex2ifname (path->ifindex),
9050 VTY_NEWLINE);
9051 else
9052 vty_out (vty, "%24s via %s, %s%s", "",
9053 inet_ntoa (path->nexthop),
9054 ifindex2ifname (path->ifindex),
9055 VTY_NEWLINE);
9056 }
9057 }
9058 }
9059 }
9060 vty_out (vty, "%s", VTY_NEWLINE);
9061 }
9062
9063 static void
9064 show_ip_ospf_route_external (struct vty *vty, struct route_table *rt)
9065 {
9066 struct route_node *rn;
9067 struct ospf_route *er;
9068 struct listnode *pnode, *pnnode;
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:
9083 vty_out (vty, "N E1 %-18s [%d] tag: %"ROUTE_TAG_PRI"%s", buf1,
9084 er->cost, er->u.ext.tag, VTY_NEWLINE);
9085 break;
9086 case OSPF_PATH_TYPE2_EXTERNAL:
9087 vty_out (vty, "N E2 %-18s [%d/%d] tag: %"ROUTE_TAG_PRI"%s", buf1, er->cost,
9088 er->u.ext.type2_cost, er->u.ext.tag, VTY_NEWLINE);
9089 break;
9090 }
9091
9092 for (ALL_LIST_ELEMENTS (er->paths, pnode, pnnode, path))
9093 {
9094 if (if_lookup_by_index(path->ifindex))
9095 {
9096 if (path->nexthop.s_addr == 0)
9097 vty_out (vty, "%24s directly attached to %s%s",
9098 "", ifindex2ifname (path->ifindex), VTY_NEWLINE);
9099 else
9100 vty_out (vty, "%24s via %s, %s%s", "",
9101 inet_ntoa (path->nexthop),
9102 ifindex2ifname (path->ifindex),
9103 VTY_NEWLINE);
9104 }
9105 }
9106 }
9107 vty_out (vty, "%s", VTY_NEWLINE);
9108 }
9109
9110 static int
9111 show_ip_ospf_border_routers_common (struct vty *vty, struct ospf *ospf)
9112 {
9113 if (ospf->instance)
9114 vty_out (vty, "%sOSPF Instance: %d%s%s", VTY_NEWLINE, ospf->instance,
9115 VTY_NEWLINE, VTY_NEWLINE);
9116
9117 if (ospf->new_table == NULL)
9118 {
9119 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
9120 return CMD_SUCCESS;
9121 }
9122
9123 /* Show Network routes.
9124 show_ip_ospf_route_network (vty, ospf->new_table); */
9125
9126 /* Show Router routes. */
9127 show_ip_ospf_route_router (vty, ospf->new_rtrs);
9128
9129 vty_out (vty, "%s", VTY_NEWLINE);
9130
9131 return CMD_SUCCESS;
9132 }
9133
9134 DEFUN (show_ip_ospf_border_routers,
9135 show_ip_ospf_border_routers_cmd,
9136 "show ip ospf border-routers",
9137 SHOW_STR
9138 IP_STR
9139 "OSPF information\n"
9140 "Show all the ABR's and ASBR's\n")
9141 {
9142 struct ospf *ospf;
9143
9144 if ((ospf = ospf_lookup ()) == NULL || !ospf->oi_running)
9145 return CMD_SUCCESS;
9146
9147 return show_ip_ospf_border_routers_common(vty, ospf);
9148 }
9149
9150 DEFUN (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]);
9163 if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running)
9164 return CMD_SUCCESS;
9165
9166 return show_ip_ospf_border_routers_common(vty, ospf);
9167 }
9168
9169 static int
9170 show_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);
9175
9176 if (ospf->new_table == NULL)
9177 {
9178 vty_out (vty, "No OSPF routing information exist%s", VTY_NEWLINE);
9179 return CMD_SUCCESS;
9180 }
9181
9182 /* Show Network routes. */
9183 show_ip_ospf_route_network (vty, ospf->new_table);
9184
9185 /* Show Router routes. */
9186 show_ip_ospf_route_router (vty, ospf->new_rtrs);
9187
9188 /* Show AS External routes. */
9189 show_ip_ospf_route_external (vty, ospf->old_external_route);
9190
9191 vty_out (vty, "%s", VTY_NEWLINE);
9192
9193 return CMD_SUCCESS;
9194 }
9195
9196 DEFUN (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
9206 if ((ospf = ospf_lookup ()) == NULL || !ospf->oi_running)
9207 return CMD_SUCCESS;
9208
9209 return show_ip_ospf_route_common(vty, ospf);
9210 }
9211
9212 DEFUN (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]);
9225 if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running)
9226 return CMD_SUCCESS;
9227
9228 return show_ip_ospf_route_common(vty, ospf);
9229 }
9230
9231 const char *ospf_abr_type_str[] =
9232 {
9233 "unknown",
9234 "standard",
9235 "ibm",
9236 "cisco",
9237 "shortcut"
9238 };
9239
9240 const char *ospf_shortcut_mode_str[] =
9241 {
9242 "default",
9243 "enable",
9244 "disable"
9245 };
9246
9247
9248 static void
9249 area_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
9259
9260 const char *ospf_int_type_str[] =
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. */
9272 static int
9273 config_write_interface (struct vty *vty)
9274 {
9275 struct listnode *n1, *n2;
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;
9281 struct ospf *ospf = ospf_lookup();
9282
9283 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), n1, ifp))
9284 {
9285 if (memcmp (ifp->name, "VLINK", 5) == 0)
9286 continue;
9287
9288 if (ifp->ifindex == IFINDEX_DELETED)
9289 continue;
9290
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) &&
9305 params->type != OSPF_IFTYPE_LOOPBACK)
9306 {
9307 if (params->type != ospf_default_iftype(ifp))
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 }
9315 }
9316
9317 /* OSPF interface authentication print */
9318 if (OSPF_IF_PARAM_CONFIGURED (params, auth_type) &&
9319 params->auth_type != OSPF_AUTH_NOTSET)
9320 {
9321 const char *auth_str;
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. */
9363 for (ALL_LIST_ELEMENTS_RO (params->auth_crypt, n2, ck))
9364 {
9365 vty_out (vty, " ip ospf message-digest-key %d md5 %s",
9366 ck->key_id, ck->auth_key);
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 {
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
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
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
9453 /* bfd print. */
9454 ospf_bfd_write_config(vty, params);
9455
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
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
9485 ospf_opaque_config_write_if (vty, ifp);
9486 }
9487
9488 return write;
9489 }
9490
9491 static int
9492 config_write_network_area (struct vty *vty, struct ospf *ospf)
9493 {
9494 struct route_node *rn;
9495 u_char buf[INET_ADDRSTRLEN];
9496
9497 /* `network area' print. */
9498 for (rn = route_top (ospf->networks); rn; rn = route_next (rn))
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)
9507 strncpy ((char *) buf, inet_ntoa (n->area_id), INET_ADDRSTRLEN);
9508 else
9509 sprintf ((char *) buf, "%lu",
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
9521 static int
9522 config_write_ospf_area (struct vty *vty, struct ospf *ospf)
9523 {
9524 struct listnode *node;
9525 struct ospf_area *area;
9526 u_char buf[INET_ADDRSTRLEN];
9527
9528 /* Area configuration print. */
9529 for (ALL_LIST_ELEMENTS_RO (ospf->areas, node, area))
9530 {
9531 struct route_node *rn1;
9532
9533 area_id2str ((char *) buf, INET_ADDRSTRLEN, area);
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)
9550 || (area->external_routing == OSPF_AREA_NSSA)
9551 )
9552 {
9553 if (area->external_routing == OSPF_AREA_STUB)
9554 vty_out (vty, " area %s stub", buf);
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 }
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
9590 if (range->cost_config != OSPF_AREA_RANGE_COST_UNSPEC)
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
9623 static int
9624 config_write_ospf_nbr_nbma (struct vty *vty, struct ospf *ospf)
9625 {
9626 struct ospf_nbr_nbma *nbr_nbma;
9627 struct route_node *rn;
9628
9629 /* Static Neighbor configuration print. */
9630 for (rn = route_top (ospf->nbr_nbma); rn; rn = route_next (rn))
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
9647 static int
9648 config_write_virtual_link (struct vty *vty, struct ospf *ospf)
9649 {
9650 struct listnode *node;
9651 struct ospf_vl_data *vl_data;
9652 u_char buf[INET_ADDRSTRLEN];
9653
9654 /* Virtual-Link print */
9655 for (ALL_LIST_ELEMENTS_RO (ospf->vlinks, node, vl_data))
9656 {
9657 struct listnode *n2;
9658 struct crypt_key *ck;
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)
9666 strncpy ((char *) buf, inet_ntoa (vl_data->vl_area_id), INET_ADDRSTRLEN);
9667 else
9668 sprintf ((char *) buf, "%lu",
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 */
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);
9703
9704 }
9705 }
9706
9707 return 0;
9708 }
9709
9710
9711 static int
9712 config_write_ospf_redistribute (struct vty *vty, struct ospf *ospf)
9713 {
9714 int type;
9715
9716 /* redistribute print. */
9717 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
9718 {
9719 struct list *red_list;
9720 struct listnode *node;
9721 struct ospf_redist *red;
9722
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 }
9745
9746 return 0;
9747 }
9748
9749 static int
9750 config_write_ospf_default_metric (struct vty *vty, struct ospf *ospf)
9751 {
9752 if (ospf->default_metric != -1)
9753 vty_out (vty, " default-metric %d%s", ospf->default_metric,
9754 VTY_NEWLINE);
9755 return 0;
9756 }
9757
9758 static int
9759 config_write_ospf_distribute (struct vty *vty, struct ospf *ospf)
9760 {
9761 int type;
9762 struct ospf_redist *red;
9763
9764 if (ospf)
9765 {
9766 /* distribute-list print. */
9767 for (type = 0; type < ZEBRA_ROUTE_MAX; type++)
9768 if (DISTRIBUTE_NAME (ospf, type))
9769 vty_out (vty, " distribute-list %s out %s%s",
9770 DISTRIBUTE_NAME (ospf, type),
9771 zebra_route_string(type), VTY_NEWLINE);
9772
9773 /* default-information print. */
9774 if (ospf->default_originate != DEFAULT_ORIGINATE_NONE)
9775 {
9776 vty_out (vty, " default-information originate");
9777 if (ospf->default_originate == DEFAULT_ORIGINATE_ALWAYS)
9778 vty_out (vty, " always");
9779
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 }
9793
9794 vty_out (vty, "%s", VTY_NEWLINE);
9795 }
9796
9797 }
9798
9799 return 0;
9800 }
9801
9802 static int
9803 config_write_ospf_distance (struct vty *vty, struct ospf *ospf)
9804 {
9805 struct route_node *rn;
9806 struct ospf_distance *odistance;
9807
9808 if (ospf->distance_all)
9809 vty_out (vty, " distance %d%s", ospf->distance_all, VTY_NEWLINE);
9810
9811 if (ospf->distance_intra
9812 || ospf->distance_inter
9813 || ospf->distance_external)
9814 {
9815 vty_out (vty, " distance ospf");
9816
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);
9823
9824 vty_out (vty, "%s", VTY_NEWLINE);
9825 }
9826
9827 for (rn = route_top (ospf->distance_table); rn; rn = route_next (rn))
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. */
9839 static int
9840 ospf_config_write (struct vty *vty)
9841 {
9842 struct ospf *ospf;
9843 struct interface *ifp;
9844 struct ospf_interface *oi;
9845 struct listnode *node;
9846 int write = 0;
9847
9848 ospf = ospf_lookup ();
9849 if (ospf != NULL && ospf->oi_running)
9850 {
9851 /* `router ospf' print. */
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);
9856
9857 write++;
9858
9859 if (!ospf->networks)
9860 return write;
9861
9862 /* Router ID print. */
9863 if (ospf->router_id_static.s_addr != 0)
9864 vty_out (vty, " ospf router-id %s%s",
9865 inet_ntoa (ospf->router_id_static), VTY_NEWLINE);
9866
9867 /* ABR type print. */
9868 if (ospf->abr_type != OSPF_ABR_DEFAULT)
9869 vty_out (vty, " ospf abr-type %s%s",
9870 ospf_abr_type_str[ospf->abr_type], VTY_NEWLINE);
9871
9872 /* log-adjacency-changes flag print. */
9873 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_CHANGES))
9874 {
9875 if (CHECK_FLAG(ospf->config, OSPF_LOG_ADJACENCY_DETAIL))
9876 vty_out(vty, " log-adjacency-changes detail%s", VTY_NEWLINE);
9877 else if (!DFLT_OSPF_LOG_ADJACENCY_CHANGES)
9878 vty_out(vty, " log-adjacency-changes%s", VTY_NEWLINE);
9879 }
9880 else if (DFLT_OSPF_LOG_ADJACENCY_CHANGES)
9881 {
9882 vty_out(vty, " no log-adjacency-changes%s", VTY_NEWLINE);
9883 }
9884
9885 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
9886 if (CHECK_FLAG (ospf->config, OSPF_RFC1583_COMPATIBLE))
9887 vty_out (vty, " compatible rfc1583%s", VTY_NEWLINE);
9888
9889 /* auto-cost reference-bandwidth configuration. */
9890 if (ospf->ref_bandwidth != OSPF_DEFAULT_REF_BANDWIDTH)
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",
9895 ospf->ref_bandwidth, VTY_NEWLINE);
9896 }
9897
9898 /* SPF timers print. */
9899 if (ospf->spf_delay != OSPF_SPF_DELAY_DEFAULT ||
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",
9903 ospf->spf_delay, ospf->spf_holdtime,
9904 ospf->spf_max_holdtime, VTY_NEWLINE);
9905
9906 /* LSA timers print. */
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)
9911 vty_out (vty, " timers lsa min-arrival %d%s",
9912 ospf->min_ls_arrival, VTY_NEWLINE);
9913
9914 /* Write multiplier print. */
9915 if (ospf->write_oi_count != OSPF_WRITE_INTERFACE_COUNT_DEFAULT)
9916 vty_out (vty, " ospf write-multiplier %d%s",
9917 ospf->write_oi_count, VTY_NEWLINE);
9918
9919 /* Max-metric router-lsa print */
9920 config_write_stub_router (vty, ospf);
9921
9922 /* SPF refresh parameters print. */
9923 if (ospf->lsa_refresh_interval != OSPF_LSA_REFRESH_INTERVAL_DEFAULT)
9924 vty_out (vty, " refresh timer %d%s",
9925 ospf->lsa_refresh_interval, VTY_NEWLINE);
9926
9927 /* Redistribute information print. */
9928 config_write_ospf_redistribute (vty, ospf);
9929
9930 /* passive-interface print. */
9931 if (ospf->passive_interface_default == OSPF_IF_PASSIVE)
9932 vty_out (vty, " passive-interface default%s", VTY_NEWLINE);
9933
9934 for (ALL_LIST_ELEMENTS_RO (om->iflist, node, ifp))
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 }
9943 for (ALL_LIST_ELEMENTS_RO (ospf->oiflist, node, oi))
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 ",
9958 oi->ifp->name,
9959 inet_ntoa (oi->address->u.prefix4), VTY_NEWLINE);
9960 }
9961
9962 /* Network area print. */
9963 config_write_network_area (vty, ospf);
9964
9965 /* Area config print. */
9966 config_write_ospf_area (vty, ospf);
9967
9968 /* static neighbor print. */
9969 config_write_ospf_nbr_nbma (vty, ospf);
9970
9971 /* Virtual-Link print. */
9972 config_write_virtual_link (vty, ospf);
9973
9974 /* Default metric configuration. */
9975 config_write_ospf_default_metric (vty, ospf);
9976
9977 /* Distribute-list and default-information print. */
9978 config_write_ospf_distribute (vty, ospf);
9979
9980 /* Distance configuration. */
9981 config_write_ospf_distance (vty, ospf);
9982
9983 ospf_opaque_config_write_router (vty, ospf);
9984 }
9985
9986 return write;
9987 }
9988
9989 void
9990 ospf_vty_show_init (void)
9991 {
9992 /* "show ip ospf" commands. */
9993 install_element (VIEW_NODE, &show_ip_ospf_cmd);
9994
9995 install_element (VIEW_NODE, &show_ip_ospf_instance_cmd);
9996
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);
10005
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);
10013
10014 /* "show ip ospf interface" commands. */
10015 install_element (VIEW_NODE, &show_ip_ospf_interface_cmd);
10016
10017 install_element (VIEW_NODE, &show_ip_ospf_instance_interface_cmd);
10018
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);
10027
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);
10035
10036 /* "show ip ospf route" commands. */
10037 install_element (VIEW_NODE, &show_ip_ospf_route_cmd);
10038 install_element (VIEW_NODE, &show_ip_ospf_border_routers_cmd);
10039
10040 install_element (VIEW_NODE, &show_ip_ospf_instance_route_cmd);
10041 install_element (VIEW_NODE, &show_ip_ospf_instance_border_routers_cmd);
10042 }
10043
10044
10045 /* ospfd's interface node. */
10046 static struct cmd_node interface_node =
10047 {
10048 INTERFACE_NODE,
10049 "%s(config-if)# ",
10050 1
10051 };
10052
10053 /* Initialization of OSPF interface. */
10054 static void
10055 ospf_vty_if_init (void)
10056 {
10057 /* Install interface node. */
10058 install_node (&interface_node, config_write_interface);
10059
10060 install_element (CONFIG_NODE, &interface_cmd);
10061 install_element (CONFIG_NODE, &no_interface_cmd);
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);
10073 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_args_addr_cmd);
10074 install_element (INTERFACE_NODE, &no_ip_ospf_authentication_args_cmd);
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);
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);
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);
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);
10090
10091 /* "ip ospf cost" commands. */
10092 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_inet4_cmd);
10093 install_element (INTERFACE_NODE, &ip_ospf_cost_u32_cmd);
10094 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_cmd);
10095 install_element (INTERFACE_NODE, &no_ip_ospf_cost_u32_inet4_cmd);
10096 install_element (INTERFACE_NODE, &no_ip_ospf_cost_inet4_cmd);
10097 install_element (INTERFACE_NODE, &no_ip_ospf_cost_cmd);
10098
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
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);
10108 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_addr_cmd);
10109 install_element (INTERFACE_NODE, &ip_ospf_dead_interval_minimal_cmd);
10110 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_addr_cmd);
10111 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_cmd);
10112 install_element (INTERFACE_NODE, &no_ip_ospf_dead_interval_seconds_cmd);
10113
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);
10119 install_element (INTERFACE_NODE, &no_ip_ospf_hello_interval_seconds_cmd);
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);
10124 install_element (INTERFACE_NODE, &no_ip_ospf_network_val_cmd);
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);
10129 install_element (INTERFACE_NODE, &no_ip_ospf_priority_cmd);
10130 install_element (INTERFACE_NODE, &no_ip_ospf_priority_no_param_cmd);
10131 install_element (INTERFACE_NODE, &no_ip_ospf_priority_addr_cmd);
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);
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);
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);
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);
10148
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
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);
10160 install_element (INTERFACE_NODE, &no_ospf_authentication_key_authkey_cmd);
10161 install_element (INTERFACE_NODE, &no_ospf_authentication_key_authkey_ip_cmd);
10162 install_element (INTERFACE_NODE, &ospf_message_digest_key_cmd);
10163 install_element (INTERFACE_NODE, &no_ospf_message_digest_key_cmd);
10164 install_element (INTERFACE_NODE, &ospf_cost_u32_cmd);
10165 install_element (INTERFACE_NODE, &ospf_cost_u32_inet4_cmd);
10166 install_element (INTERFACE_NODE, &no_ospf_cost_cmd);
10167 install_element (INTERFACE_NODE, &no_ospf_cost_u32_cmd);
10168 install_element (INTERFACE_NODE, &no_ospf_cost_u32_inet4_cmd);
10169 install_element (INTERFACE_NODE, &no_ospf_cost_inet4_cmd);
10170 install_element (INTERFACE_NODE, &ospf_dead_interval_cmd);
10171 install_element (INTERFACE_NODE, &no_ospf_dead_interval_cmd);
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);
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);
10178 install_element (INTERFACE_NODE, &no_ospf_network_val_cmd);
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
10187 static void
10188 ospf_vty_zebra_init (void)
10189 {
10190 install_element (OSPF_NODE, &ospf_redistribute_source_cmd);
10191 install_element (OSPF_NODE, &no_ospf_redistribute_source_cmd);
10192 install_element (OSPF_NODE, &ospf_redistribute_instance_source_cmd);
10193 install_element (OSPF_NODE, &no_ospf_redistribute_instance_source_cmd);
10194
10195 install_element (OSPF_NODE, &ospf_distribute_list_out_cmd);
10196 install_element (OSPF_NODE, &no_ospf_distribute_list_out_cmd);
10197
10198 install_element (OSPF_NODE, &ospf_default_information_originate_cmd);
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);
10208 install_element (OSPF_NODE, &ospf_distance_ospf_cmd);
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
10217 static struct cmd_node ospf_node =
10218 {
10219 OSPF_NODE,
10220 "%s(config-router)# ",
10221 1
10222 };
10223
10224 static void
10225 ospf_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
10235 DEFUN (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 {
10249 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT), node, ifp))
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
10263 void
10264 ospf_vty_clear_init (void)
10265 {
10266 install_element (ENABLE_NODE, &clear_ip_ospf_interface_cmd);
10267 }
10268
10269
10270 /* Install OSPF related vty commands. */
10271 void
10272 ospf_vty_init (void)
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
10281 install_element (CONFIG_NODE, &router_ospf_instance_cmd);
10282 install_element (CONFIG_NODE, &no_router_ospf_instance_cmd);
10283
10284 install_default (OSPF_NODE);
10285
10286 /* "ospf router-id" commands. */
10287 install_element (OSPF_NODE, &ospf_router_id_cmd);
10288 install_element (OSPF_NODE, &ospf_router_id_old_cmd);
10289 install_element (OSPF_NODE, &no_ospf_router_id_cmd);
10290 install_element (OSPF_NODE, &no_ospf_router_id_val_cmd);
10291
10292 /* "passive-interface" commands. */
10293 install_element (OSPF_NODE, &ospf_passive_interface_addr_cmd);
10294 install_element (OSPF_NODE, &ospf_passive_interface_cmd);
10295 install_element (OSPF_NODE, &ospf_passive_interface_default_cmd);
10296 install_element (OSPF_NODE, &no_ospf_passive_interface_addr_cmd);
10297 install_element (OSPF_NODE, &no_ospf_passive_interface_cmd);
10298 install_element (OSPF_NODE, &no_ospf_passive_interface_default_cmd);
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
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
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. */
10317 install_element (OSPF_NODE, &ospf_network_area_cmd);
10318 install_element (OSPF_NODE, &no_ospf_network_area_cmd);
10319
10320 /* "area authentication" commands. */
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);
10324
10325 /* "area range" commands. */
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);
10337
10338 /* "area virtual-link" commands. */
10339 install_element (OSPF_NODE, &ospf_area_vlink_cmd);
10340 install_element (OSPF_NODE, &no_ospf_area_vlink_cmd);
10341
10342 install_element (OSPF_NODE, &ospf_area_vlink_param1_cmd);
10343 install_element (OSPF_NODE, &no_ospf_area_vlink_param1_cmd);
10344
10345 install_element (OSPF_NODE, &ospf_area_vlink_param2_cmd);
10346 install_element (OSPF_NODE, &no_ospf_area_vlink_param2_cmd);
10347
10348 install_element (OSPF_NODE, &ospf_area_vlink_param3_cmd);
10349 install_element (OSPF_NODE, &no_ospf_area_vlink_param3_cmd);
10350
10351 install_element (OSPF_NODE, &ospf_area_vlink_param4_cmd);
10352 install_element (OSPF_NODE, &no_ospf_area_vlink_param4_cmd);
10353
10354 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_cmd);
10355 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_args_cmd);
10356 install_element (OSPF_NODE, &ospf_area_vlink_authtype_cmd);
10357 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_cmd);
10358
10359 install_element (OSPF_NODE, &ospf_area_vlink_md5_cmd);
10360 install_element (OSPF_NODE, &no_ospf_area_vlink_md5_cmd);
10361
10362 install_element (OSPF_NODE, &ospf_area_vlink_authkey_cmd);
10363 install_element (OSPF_NODE, &no_ospf_area_vlink_authkey_cmd);
10364
10365 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_authkey_cmd);
10366 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_args_authkey_cmd);
10367 install_element (OSPF_NODE, &ospf_area_vlink_authtype_authkey_cmd);
10368 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_authkey_cmd);
10369
10370 install_element (OSPF_NODE, &ospf_area_vlink_authtype_args_md5_cmd);
10371 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_args_md5_cmd);
10372 install_element (OSPF_NODE, &ospf_area_vlink_authtype_md5_cmd);
10373 install_element (OSPF_NODE, &no_ospf_area_vlink_authtype_md5_cmd);
10374
10375 /* "area stub" commands. */
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);
10380
10381 /* "area nssa" commands. */
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);
10388
10389 install_element (OSPF_NODE, &ospf_area_default_cost_cmd);
10390 install_element (OSPF_NODE, &no_ospf_area_default_cost_cmd);
10391
10392 install_element (OSPF_NODE, &ospf_area_shortcut_cmd);
10393 install_element (OSPF_NODE, &no_ospf_area_shortcut_cmd);
10394
10395 install_element (OSPF_NODE, &ospf_area_export_list_cmd);
10396 install_element (OSPF_NODE, &no_ospf_area_export_list_cmd);
10397
10398 install_element (OSPF_NODE, &ospf_area_filter_list_cmd);
10399 install_element (OSPF_NODE, &no_ospf_area_filter_list_cmd);
10400
10401 install_element (OSPF_NODE, &ospf_area_import_list_cmd);
10402 install_element (OSPF_NODE, &no_ospf_area_import_list_cmd);
10403
10404 /* SPF timer commands */
10405 install_element (OSPF_NODE, &ospf_timers_throttle_spf_cmd);
10406 install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_cmd);
10407 install_element (OSPF_NODE, &no_ospf_timers_throttle_spf_val_cmd);
10408
10409 /* LSA timers commands */
10410 install_element (OSPF_NODE, &ospf_timers_min_ls_interval_cmd);
10411 install_element (OSPF_NODE, &no_ospf_timers_min_ls_interval_cmd);
10412 install_element (OSPF_NODE, &no_ospf_timers_min_ls_interval_val_cmd);
10413 install_element (OSPF_NODE, &ospf_timers_min_ls_arrival_cmd);
10414 install_element (OSPF_NODE, &no_ospf_timers_min_ls_arrival_cmd);
10415 install_element (OSPF_NODE, &no_ospf_timers_min_ls_arrival_val_cmd);
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
10420 /* refresh timer commands */
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);
10424
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);
10430 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_startup_no_param_cmd);
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);
10433 install_element (OSPF_NODE, &no_ospf_max_metric_router_lsa_shutdown_no_param_cmd);
10434
10435 /* reference bandwidth commands */
10436 install_element (OSPF_NODE, &ospf_auto_cost_reference_bandwidth_cmd);
10437 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_cmd);
10438 install_element (OSPF_NODE, &no_ospf_auto_cost_reference_bandwidth_val_cmd);
10439
10440 /* "neighbor" commands. */
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);
10449 install_element (OSPF_NODE, &no_ospf_neighbor_poll_interval_priority_cmd);
10450 install_element (OSPF_NODE, &no_ospf_neighbor_priority_pollinterval_cmd);
10451
10452 /* write multiplier commands */
10453 install_element (OSPF_NODE, &ospf_write_multiplier_cmd);
10454 install_element (OSPF_NODE, &no_ospf_write_multiplier_cmd);
10455 install_element (OSPF_NODE, &write_multiplier_cmd);
10456 install_element (OSPF_NODE, &no_write_multiplier_cmd);
10457 install_element (OSPF_NODE, &no_write_multiplier_val_cmd);
10458
10459 /* Init interface related vty commands. */
10460 ospf_vty_if_init ();
10461
10462 /* Init zebra related vty commands. */
10463 ospf_vty_zebra_init ();
10464 }