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