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