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