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