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