2 * Copyright (C) 2005 6WIND <alain.ritoux@6wind.com>
3 * Copyright (C) 2000 Toshiaki Takada
5 * This file is part of GNU Zebra.
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
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.
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
38 #include "ospfd/ospfd.h"
39 #include "ospfd/ospf_asbr.h"
40 #include "ospfd/ospf_lsa.h"
41 #include "ospfd/ospf_lsdb.h"
42 #include "ospfd/ospf_ism.h"
43 #include "ospfd/ospf_interface.h"
44 #include "ospfd/ospf_nsm.h"
45 #include "ospfd/ospf_neighbor.h"
46 #include "ospfd/ospf_flood.h"
47 #include "ospfd/ospf_abr.h"
48 #include "ospfd/ospf_spf.h"
49 #include "ospfd/ospf_route.h"
50 #include "ospfd/ospf_zebra.h"
51 /*#include "ospfd/ospf_routemap.h" */
52 #include "ospfd/ospf_vty.h"
53 #include "ospfd/ospf_dump.h"
54 #include "ospfd/ospf_bfd.h"
56 static const char *ospf_network_type_str
[] =
67 /* Utility functions. */
69 ospf_str2area_id (const char *str
, struct in_addr
*area_id
, int *format
)
74 /* match "A.B.C.D". */
75 if (strchr (str
, '.') != NULL
)
77 ret
= inet_aton (str
, area_id
);
80 *format
= OSPF_AREA_ID_FORMAT_ADDRESS
;
82 /* match "<0-4294967295>". */
88 ret
= strtoul (str
, &endptr
, 10);
89 if (*endptr
!= '\0' || errno
|| ret
> UINT32_MAX
)
92 area_id
->s_addr
= htonl (ret
);
93 *format
= OSPF_AREA_ID_FORMAT_DECIMAL
;
101 str2metric (const char *str
, int *metric
)
107 *metric
= strtol (str
, NULL
, 10);
108 if (*metric
< 0 && *metric
> 16777214)
110 /* vty_out (vty, "OSPF metric value is invalid%s", VTY_NEWLINE); */
118 str2metric_type (const char *str
, int *metric_type
)
124 if (strncmp (str
, "1", 1) == 0)
125 *metric_type
= EXTERNAL_METRIC_TYPE_1
;
126 else if (strncmp (str
, "2", 1) == 0)
127 *metric_type
= EXTERNAL_METRIC_TYPE_2
;
135 ospf_oi_count (struct interface
*ifp
)
137 struct route_node
*rn
;
140 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
149 "router ospf [(1-65535)]",
150 "Enable a routing process\n"
151 "Start OSPF configuration\n"
155 u_short instance
= 0;
157 ospf
= ospf_lookup();
160 vty_out (vty
, "There isn't active ospf instance %s", VTY_NEWLINE
);
165 VTY_GET_INTEGER ("Instance", instance
, argv
[2]->arg
);
167 /* The following logic to set the vty qobj index is in place to be able
168 to ignore the commands which dont belong to this instance. */
169 if (ospf
->instance
!= instance
)
170 VTY_PUSH_CONTEXT_NULL(OSPF_NODE
);
173 if (IS_DEBUG_OSPF_EVENT
)
174 zlog_debug ("Config command 'router ospf %d' received", instance
);
175 ospf
->oi_running
= 1;
176 VTY_PUSH_CONTEXT(OSPF_NODE
, ospf
);
177 ospf_router_id_update (ospf
);
183 DEFUN (no_router_ospf
,
185 "no router ospf [(1-65535)]",
187 "Enable a routing process\n"
188 "Start OSPF configuration\n"
192 u_short instance
= 0;
195 VTY_GET_INTEGER ("Instance", instance
, argv
[3]->arg
);
197 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
206 DEFUN (ospf_router_id
,
208 "ospf router-id A.B.C.D",
209 "OSPF specific commands\n"
210 "router-id for the OSPF process\n"
211 "OSPF router-id in IP address format\n")
213 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
215 struct listnode
*node
;
216 struct ospf_area
*area
;
217 struct in_addr router_id
;
220 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &router_id
);
223 vty_out (vty
, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE
);
227 ospf
->router_id_static
= router_id
;
229 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
232 vty_out (vty
, "For this router-id change to take effect,"
233 " save config and restart ospfd%s", VTY_NEWLINE
);
237 ospf_router_id_update (ospf
);
242 DEFUN_HIDDEN (ospf_router_id_old
,
243 ospf_router_id_old_cmd
,
245 "router-id for the OSPF process\n"
246 "OSPF router-id in IP address format\n")
248 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
250 struct listnode
*node
;
251 struct ospf_area
*area
;
252 struct in_addr router_id
;
255 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &router_id
);
258 vty_out (vty
, "Please specify Router ID by A.B.C.D%s", VTY_NEWLINE
);
262 ospf
->router_id_static
= router_id
;
264 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
267 vty_out (vty
, "For this router-id change to take effect,"
268 " save config and restart ospfd%s", VTY_NEWLINE
);
272 ospf_router_id_update (ospf
);
277 DEFUN (no_ospf_router_id
,
278 no_ospf_router_id_cmd
,
279 "no ospf router-id [A.B.C.D]",
281 "OSPF specific commands\n"
282 "router-id for the OSPF process\n"
283 "OSPF router-id in IP address format\n")
285 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
286 struct listnode
*node
;
287 struct ospf_area
*area
;
289 ospf
->router_id_static
.s_addr
= 0;
291 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
294 vty_out (vty
, "For this router-id change to take effect,"
295 " save config and restart ospfd%s", VTY_NEWLINE
);
299 ospf_router_id_update (ospf
);
306 ospf_passive_interface_default (struct ospf
*ospf
, u_char newval
)
309 struct interface
*ifp
;
310 struct ospf_interface
*oi
;
312 ospf
->passive_interface_default
= newval
;
314 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, ln
, ifp
))
317 OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
))
318 UNSET_IF_PARAM (IF_DEF_PARAMS (ifp
), passive_interface
);
320 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, ln
, oi
))
322 if (OSPF_IF_PARAM_CONFIGURED (oi
->params
, passive_interface
))
323 UNSET_IF_PARAM (oi
->params
, passive_interface
);
324 /* update multicast memberships */
325 ospf_if_set_multicast(oi
);
330 ospf_passive_interface_update_addr (struct ospf
*ospf
, struct interface
*ifp
,
331 struct ospf_if_params
*params
, u_char value
,
336 params
->passive_interface
= value
;
337 if (params
!= IF_DEF_PARAMS (ifp
))
339 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
))
340 dflt
= IF_DEF_PARAMS (ifp
)->passive_interface
;
342 dflt
= ospf
->passive_interface_default
;
345 SET_IF_PARAM (params
, passive_interface
);
347 UNSET_IF_PARAM (params
, passive_interface
);
349 ospf_free_if_params (ifp
, addr
);
350 ospf_if_update_params (ifp
, addr
);
355 ospf_passive_interface_update (struct ospf
*ospf
, struct interface
*ifp
,
356 struct ospf_if_params
*params
, u_char value
)
358 params
->passive_interface
= value
;
359 if (params
== IF_DEF_PARAMS (ifp
))
361 if (value
!= ospf
->passive_interface_default
)
362 SET_IF_PARAM (params
, passive_interface
);
364 UNSET_IF_PARAM (params
, passive_interface
);
368 DEFUN (ospf_passive_interface
,
369 ospf_passive_interface_addr_cmd
,
370 "passive-interface <IFNAME [A.B.C.D]|default>",
371 "Suppress routing updates on an interface\n"
374 "Suppress routing updates on interfaces by default\n")
376 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
378 struct interface
*ifp
;
379 struct in_addr addr
= { .s_addr
= INADDR_ANY
};
381 struct ospf_if_params
*params
;
382 struct route_node
*rn
;
384 if (strcmp (argv
[1]->text
, "default") == 0)
386 ospf_passive_interface_default (ospf
, OSPF_IF_PASSIVE
);
390 ifp
= if_get_by_name (argv
[1]->arg
);
392 params
= IF_DEF_PARAMS (ifp
);
396 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
399 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
404 params
= ospf_get_if_params (ifp
, addr
);
405 ospf_if_update_params (ifp
, addr
);
406 ospf_passive_interface_update_addr (ospf
, ifp
, params
,
407 OSPF_IF_PASSIVE
, addr
);
410 ospf_passive_interface_update (ospf
, ifp
, params
, OSPF_IF_PASSIVE
);
412 /* XXX We should call ospf_if_set_multicast on exactly those
413 * interfaces for which the passive property changed. It is too much
414 * work to determine this set, so we do this for every interface.
415 * This is safe and reasonable because ospf_if_set_multicast uses a
416 * record of joined groups to avoid systems calls if the desired
417 * memberships match the current memership.
420 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next (rn
))
422 struct ospf_interface
*oi
= rn
->info
;
424 if (oi
&& (OSPF_IF_PARAM(oi
, passive_interface
) == OSPF_IF_PASSIVE
))
425 ospf_if_set_multicast(oi
);
428 * XXX It is not clear what state transitions the interface needs to
429 * undergo when going from active to passive. Fixing this will
430 * require precise identification of interfaces having such a
437 DEFUN (no_ospf_passive_interface
,
438 no_ospf_passive_interface_addr_cmd
,
439 "no passive-interface <IFNAME [A.B.C.D]|default>",
441 "Allow routing updates on an interface\n"
444 "Allow routing updates on interfaces by default\n")
446 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
448 struct interface
*ifp
;
449 struct in_addr addr
= { .s_addr
= INADDR_ANY
};
450 struct ospf_if_params
*params
;
452 struct route_node
*rn
;
454 if (strcmp (argv
[2]->text
, "default") == 0)
456 ospf_passive_interface_default (ospf
, OSPF_IF_ACTIVE
);
460 ifp
= if_get_by_name (argv
[2]->arg
);
462 params
= IF_DEF_PARAMS (ifp
);
466 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
469 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
474 params
= ospf_lookup_if_params (ifp
, addr
);
477 ospf_passive_interface_update_addr (ospf
, ifp
, params
, OSPF_IF_ACTIVE
,
480 ospf_passive_interface_update (ospf
, ifp
, params
, OSPF_IF_ACTIVE
);
482 /* XXX We should call ospf_if_set_multicast on exactly those
483 * interfaces for which the passive property changed. It is too much
484 * work to determine this set, so we do this for every interface.
485 * This is safe and reasonable because ospf_if_set_multicast uses a
486 * record of joined groups to avoid systems calls if the desired
487 * memberships match the current memership.
489 for (rn
= route_top(IF_OIFS(ifp
)); rn
; rn
= route_next (rn
))
491 struct ospf_interface
*oi
= rn
->info
;
493 if (oi
&& (OSPF_IF_PARAM(oi
, passive_interface
) == OSPF_IF_ACTIVE
))
494 ospf_if_set_multicast(oi
);
502 DEFUN (ospf_network_area
,
503 ospf_network_area_cmd
,
504 "network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
505 "Enable routing on an IP network\n"
506 "OSPF network prefix\n"
507 "Set the OSPF area ID\n"
508 "OSPF area ID in IP address format\n"
509 "OSPF area ID as a decimal value\n")
511 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
512 int idx_ipv4_prefixlen
= 1;
513 int idx_ipv4_number
= 3;
514 struct prefix_ipv4 p
;
515 struct in_addr area_id
;
520 vty_out (vty
, "The network command is not supported in multi-instance ospf%s",
525 if (ospf
->if_ospf_cli_count
> 0)
527 vty_out (vty
, "Please remove all ip ospf area x.x.x.x commands first.%s",
532 /* Get network prefix and Area ID. */
533 VTY_GET_IPV4_PREFIX ("network prefix", p
, argv
[idx_ipv4_prefixlen
]->arg
);
534 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
536 ret
= ospf_network_set (ospf
, &p
, area_id
);
539 vty_out (vty
, "There is already same network statement.%s", VTY_NEWLINE
);
546 DEFUN (no_ospf_network_area
,
547 no_ospf_network_area_cmd
,
548 "no network A.B.C.D/M area <A.B.C.D|(0-4294967295)>",
550 "Enable routing on an IP network\n"
551 "OSPF network prefix\n"
552 "Set the OSPF area ID\n"
553 "OSPF area ID in IP address format\n"
554 "OSPF area ID as a decimal value\n")
556 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
557 int idx_ipv4_prefixlen
= 2;
558 int idx_ipv4_number
= 4;
559 struct prefix_ipv4 p
;
560 struct in_addr area_id
;
565 vty_out (vty
, "The network command is not supported in multi-instance ospf%s",
570 /* Get network prefix and Area ID. */
571 VTY_GET_IPV4_PREFIX ("network prefix", p
, argv
[idx_ipv4_prefixlen
]->arg
);
572 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
574 ret
= ospf_network_unset (ospf
, &p
, area_id
);
577 vty_out (vty
, "Can't find specified network area configuration.%s",
585 DEFUN (ospf_area_range
,
587 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [advertise [cost (0-16777215)]]",
588 "OSPF area parameters\n"
589 "OSPF area ID in IP address format\n"
590 "OSPF area ID as a decimal value\n"
591 "Summarize routes matching address/mask (border routers only)\n"
592 "Area range prefix\n"
593 "Advertise this range (default)\n"
594 "User specified metric for this range\n"
595 "Advertised metric for this range\n")
597 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
598 int idx_ipv4_number
= 1;
599 int idx_ipv4_prefixlen
= 3;
601 struct prefix_ipv4 p
;
602 struct in_addr area_id
;
606 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
607 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
609 ospf_area_range_set (ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
612 VTY_GET_INTEGER ("range cost", cost
, argv
[idx_cost
]->arg
);
613 ospf_area_range_cost_set (ospf
, area_id
, &p
, cost
);
619 DEFUN (ospf_area_range_cost
,
620 ospf_area_range_cost_cmd
,
621 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M cost (0-16777215)",
622 "OSPF area parameters\n"
623 "OSPF area ID in IP address format\n"
624 "OSPF area ID as a decimal value\n"
625 "Summarize routes matching address/mask (border routers only)\n"
626 "Area range prefix\n"
627 "User specified metric for this range\n"
628 "Advertised metric for this range\n")
630 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
631 int idx_ipv4_number
= 1;
632 int idx_ipv4_prefixlen
= 3;
634 struct prefix_ipv4 p
;
635 struct in_addr area_id
;
639 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
640 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
642 ospf_area_range_set (ospf
, area_id
, &p
, OSPF_AREA_RANGE_ADVERTISE
);
644 VTY_GET_INTEGER ("range cost", cost
, argv
[idx_cost
]->arg
);
645 ospf_area_range_cost_set (ospf
, area_id
, &p
, cost
);
650 DEFUN (ospf_area_range_not_advertise
,
651 ospf_area_range_not_advertise_cmd
,
652 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M not-advertise",
653 "OSPF area parameters\n"
654 "OSPF area ID in IP address format\n"
655 "OSPF area ID as a decimal value\n"
656 "Summarize routes matching address/mask (border routers only)\n"
657 "Area range prefix\n"
658 "DoNotAdvertise this range\n")
660 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
661 int idx_ipv4_number
= 1;
662 int idx_ipv4_prefixlen
= 3;
663 struct prefix_ipv4 p
;
664 struct in_addr area_id
;
667 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
668 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
670 ospf_area_range_set (ospf
, area_id
, &p
, 0);
675 DEFUN (no_ospf_area_range
,
676 no_ospf_area_range_cmd
,
677 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M [<cost (0-16777215)|advertise [cost (0-16777215)]|not-advertise>]",
679 "OSPF area parameters\n"
680 "OSPF area ID in IP address format\n"
681 "OSPF area ID as a decimal value\n"
682 "Summarize routes matching address/mask (border routers only)\n"
683 "Area range prefix\n"
684 "User specified metric for this range\n"
685 "Advertised metric for this range\n"
686 "Advertise this range (default)\n"
687 "User specified metric for this range\n"
688 "Advertised metric for this range\n"
689 "DoNotAdvertise this range\n")
691 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
692 int idx_ipv4_number
= 2;
693 int idx_ipv4_prefixlen
= 4;
694 struct prefix_ipv4 p
;
695 struct in_addr area_id
;
698 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
699 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
701 ospf_area_range_unset (ospf
, area_id
, &p
);
706 DEFUN (ospf_area_range_substitute
,
707 ospf_area_range_substitute_cmd
,
708 "area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
709 "OSPF area parameters\n"
710 "OSPF area ID in IP address format\n"
711 "OSPF area ID as a decimal value\n"
712 "Summarize routes matching address/mask (border routers only)\n"
713 "Area range prefix\n"
714 "Announce area range as another prefix\n"
715 "Network prefix to be announced instead of range\n")
717 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
718 int idx_ipv4_number
= 1;
719 int idx_ipv4_prefixlen
= 3;
720 int idx_ipv4_prefixlen_2
= 5;
721 struct prefix_ipv4 p
, s
;
722 struct in_addr area_id
;
725 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
726 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
727 VTY_GET_IPV4_PREFIX ("substituted network prefix", s
, argv
[idx_ipv4_prefixlen_2
]->arg
);
729 ospf_area_range_substitute_set (ospf
, area_id
, &p
, &s
);
734 DEFUN (no_ospf_area_range_substitute
,
735 no_ospf_area_range_substitute_cmd
,
736 "no area <A.B.C.D|(0-4294967295)> range A.B.C.D/M substitute A.B.C.D/M",
738 "OSPF area parameters\n"
739 "OSPF area ID in IP address format\n"
740 "OSPF area ID as a decimal value\n"
741 "Summarize routes matching address/mask (border routers only)\n"
742 "Area range prefix\n"
743 "Announce area range as another prefix\n"
744 "Network prefix to be announced instead of range\n")
746 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
747 int idx_ipv4_number
= 2;
748 int idx_ipv4_prefixlen
= 4;
749 int idx_ipv4_prefixlen_2
= 6;
750 struct prefix_ipv4 p
, s
;
751 struct in_addr area_id
;
754 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
755 VTY_GET_IPV4_PREFIX ("area range", p
, argv
[idx_ipv4_prefixlen
]->arg
);
756 VTY_GET_IPV4_PREFIX ("substituted network prefix", s
, argv
[idx_ipv4_prefixlen_2
]->arg
);
758 ospf_area_range_substitute_unset (ospf
, area_id
, &p
);
764 /* Command Handler Logic in VLink stuff is delicate!!
766 ALTER AT YOUR OWN RISK!!!!
768 Various dummy values are used to represent 'NoChange' state for
769 VLink configuration NOT being changed by a VLink command, and
770 special syntax is used within the command strings so that the
771 typed in command verbs can be seen in the configuration command
772 bacckend handler. This is to drastically reduce the verbeage
773 required to coe up with a reasonably compatible Cisco VLink command
775 - Matthew Grant <grantma@anathoth.gen.nz>
776 Wed, 21 Feb 2001 15:13:52 +1300
779 /* Configuration data for virtual links
781 struct ospf_vl_config_data
{
782 struct vty
*vty
; /* vty stuff */
783 struct in_addr area_id
; /* area ID from command line */
784 int format
; /* command line area ID format */
785 struct in_addr vl_peer
; /* command line vl_peer */
786 int auth_type
; /* Authehntication type, if given */
787 char *auth_key
; /* simple password if present */
788 int crypto_key_id
; /* Cryptographic key ID */
789 char *md5_key
; /* MD5 authentication key */
790 int hello_interval
; /* Obvious what these are... */
791 int retransmit_interval
;
797 ospf_vl_config_data_init (struct ospf_vl_config_data
*vl_config
,
800 memset (vl_config
, 0, sizeof (struct ospf_vl_config_data
));
801 vl_config
->auth_type
= OSPF_AUTH_CMD_NOTSEEN
;
802 vl_config
->vty
= vty
;
805 static struct ospf_vl_data
*
806 ospf_find_vl_data (struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
808 struct ospf_area
*area
;
809 struct ospf_vl_data
*vl_data
;
811 struct in_addr area_id
;
813 vty
= vl_config
->vty
;
814 area_id
= vl_config
->area_id
;
816 if (area_id
.s_addr
== OSPF_AREA_BACKBONE
)
819 "Configuring VLs over the backbone is not allowed%s",
823 area
= ospf_area_get (ospf
, area_id
, vl_config
->format
);
825 if (area
->external_routing
!= OSPF_AREA_DEFAULT
)
827 if (vl_config
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
828 vty_out (vty
, "Area %s is %s%s",
830 area
->external_routing
== OSPF_AREA_NSSA
?"nssa":"stub",
833 vty_out (vty
, "Area %ld is %s%s",
834 (u_long
)ntohl (area_id
.s_addr
),
835 area
->external_routing
== OSPF_AREA_NSSA
?"nssa":"stub",
840 if ((vl_data
= ospf_vl_lookup (ospf
, area
, vl_config
->vl_peer
)) == NULL
)
842 vl_data
= ospf_vl_data_new (area
, vl_config
->vl_peer
);
843 if (vl_data
->vl_oi
== NULL
)
845 vl_data
->vl_oi
= ospf_vl_new (ospf
, vl_data
);
846 ospf_vl_add (ospf
, vl_data
);
847 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
855 ospf_vl_set_security (struct ospf_vl_data
*vl_data
,
856 struct ospf_vl_config_data
*vl_config
)
858 struct crypt_key
*ck
;
860 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
862 vty
= vl_config
->vty
;
864 if (vl_config
->auth_type
!= OSPF_AUTH_CMD_NOTSEEN
)
866 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), auth_type
);
867 IF_DEF_PARAMS (ifp
)->auth_type
= vl_config
->auth_type
;
870 if (vl_config
->auth_key
)
872 memset(IF_DEF_PARAMS (ifp
)->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+1);
873 strncpy ((char *) IF_DEF_PARAMS (ifp
)->auth_simple
, vl_config
->auth_key
,
874 OSPF_AUTH_SIMPLE_SIZE
);
876 else if (vl_config
->md5_key
)
878 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp
)->auth_crypt
, vl_config
->crypto_key_id
)
881 vty_out (vty
, "OSPF: Key %d already exists%s",
882 vl_config
->crypto_key_id
, VTY_NEWLINE
);
885 ck
= ospf_crypt_key_new ();
886 ck
->key_id
= vl_config
->crypto_key_id
;
887 memset(ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
888 strncpy ((char *) ck
->auth_key
, vl_config
->md5_key
, OSPF_AUTH_MD5_SIZE
);
890 ospf_crypt_key_add (IF_DEF_PARAMS (ifp
)->auth_crypt
, ck
);
892 else if (vl_config
->crypto_key_id
!= 0)
896 if (ospf_crypt_key_lookup (IF_DEF_PARAMS (ifp
)->auth_crypt
,
897 vl_config
->crypto_key_id
) == NULL
)
899 vty_out (vty
, "OSPF: Key %d does not exist%s",
900 vl_config
->crypto_key_id
, VTY_NEWLINE
);
904 ospf_crypt_key_delete (IF_DEF_PARAMS (ifp
)->auth_crypt
, vl_config
->crypto_key_id
);
912 ospf_vl_set_timers (struct ospf_vl_data
*vl_data
,
913 struct ospf_vl_config_data
*vl_config
)
915 struct interface
*ifp
= vl_data
->vl_oi
->ifp
;
916 /* Virtual Link data initialised to defaults, so only set
918 if (vl_config
->hello_interval
)
920 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), v_hello
);
921 IF_DEF_PARAMS (ifp
)->v_hello
= vl_config
->hello_interval
;
924 if (vl_config
->dead_interval
)
926 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), v_wait
);
927 IF_DEF_PARAMS (ifp
)->v_wait
= vl_config
->dead_interval
;
930 if (vl_config
->retransmit_interval
)
932 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), retransmit_interval
);
933 IF_DEF_PARAMS (ifp
)->retransmit_interval
= vl_config
->retransmit_interval
;
936 if (vl_config
->transmit_delay
)
938 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), transmit_delay
);
939 IF_DEF_PARAMS (ifp
)->transmit_delay
= vl_config
->transmit_delay
;
946 /* The business end of all of the above */
948 ospf_vl_set (struct ospf
*ospf
, struct ospf_vl_config_data
*vl_config
)
950 struct ospf_vl_data
*vl_data
;
953 vl_data
= ospf_find_vl_data (ospf
, vl_config
);
957 /* Process this one first as it can have a fatal result, which can
958 only logically occur if the virtual link exists already
959 Thus a command error does not result in a change to the
960 running configuration such as unexpectedly altered timer
962 ret
= ospf_vl_set_security (vl_data
, vl_config
);
963 if (ret
!= CMD_SUCCESS
)
966 /* Set any time based parameters, these area already range checked */
968 ret
= ospf_vl_set_timers (vl_data
, vl_config
);
969 if (ret
!= CMD_SUCCESS
)
976 /* This stuff exists to make specifying all the alias commands A LOT simpler
978 #define VLINK_HELPSTR_IPADDR \
979 "OSPF area parameters\n" \
980 "OSPF area ID in IP address format\n" \
981 "OSPF area ID as a decimal value\n" \
982 "Configure a virtual link\n" \
983 "Router ID of the remote ABR\n"
985 #define VLINK_HELPSTR_AUTHTYPE_SIMPLE \
986 "Enable authentication on this virtual link\n" \
989 #define VLINK_HELPSTR_AUTHTYPE_ALL \
990 VLINK_HELPSTR_AUTHTYPE_SIMPLE \
991 "Use null authentication\n" \
992 "Use message-digest authentication\n"
994 #define VLINK_HELPSTR_TIME_PARAM_NOSECS \
995 "Time between HELLO packets\n" \
996 "Time between retransmitting lost link state advertisements\n" \
997 "Link state transmit delay\n" \
998 "Interval time after which a neighbor is declared down\n"
1000 #define VLINK_HELPSTR_TIME_PARAM \
1001 VLINK_HELPSTR_TIME_PARAM_NOSECS \
1004 #define VLINK_HELPSTR_AUTH_SIMPLE \
1005 "Authentication password (key)\n" \
1006 "The OSPF password (key)"
1008 #define VLINK_HELPSTR_AUTH_MD5 \
1009 "Message digest authentication password (key)\n" \
1012 "Use MD5 algorithm\n" \
1013 "The OSPF password (key)"
1015 DEFUN (ospf_area_vlink
,
1016 ospf_area_vlink_cmd
,
1017 "area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D [authentication] [<message-digest|null>] [<message-digest-key (1-255) md5 KEY|authentication-key AUTH_KEY>]",
1018 VLINK_HELPSTR_IPADDR
1019 "Enable authentication on this virtual link\n" \
1020 "Use null authentication\n" \
1021 "Use message-digest authentication\n"
1022 "Message digest authentication password (key)\n" \
1024 "Use MD5 algorithm\n" \
1025 "The OSPF password (key)")
1027 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1028 int idx_ipv4_number
= 1;
1030 struct ospf_vl_config_data vl_config
;
1031 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+1];
1032 char md5_key
[OSPF_AUTH_MD5_SIZE
+1];
1036 ospf_vl_config_data_init(&vl_config
, vty
);
1038 /* Read off first 2 parameters and check them */
1039 ret
= ospf_str2area_id (argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
, &vl_config
.format
);
1042 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1046 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1049 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s",
1056 /* Thats all folks! - BUGS B. strikes again!!!*/
1058 return ospf_vl_set (ospf
, &vl_config
);
1061 /* Deal with other parameters */
1062 for (i
=5; i
< argc
; i
++)
1065 /* vty_out (vty, "argv[%d]->arg - %s%s", i, argv[i]->text, VTY_NEWLINE); */
1067 switch (argv
[i
]->arg
[0])
1071 if (i
>5 || strncmp (argv
[i
]->arg
, "authentication-", 15) == 0)
1073 /* authentication-key - this option can occur anywhere on
1074 command line. At start of command line
1075 must check for authentication option. */
1076 memset (auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1077 strncpy (auth_key
, argv
[i
+1]->text
, OSPF_AUTH_SIMPLE_SIZE
);
1078 vl_config
.auth_key
= auth_key
;
1081 else if (strncmp (argv
[i
]->arg
, "authentication", 14) == 0)
1083 /* authentication - this option can only occur at start
1085 vl_config
.auth_type
= OSPF_AUTH_SIMPLE
;
1088 if (strncmp (argv
[i
+1]->arg
, "n", 1) == 0)
1090 /* "authentication null" */
1091 vl_config
.auth_type
= OSPF_AUTH_NULL
;
1094 else if (strncmp (argv
[i
+1]->arg
, "m", 1) == 0
1095 && strcmp (argv
[i
+1]->arg
, "message-digest-") != 0)
1097 /* "authentication message-digest" */
1098 vl_config
.auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
1106 /* message-digest-key */
1110 vl_config
.crypto_key_id
= strtol (argv
[i
]->arg
, NULL
, 10);
1111 if (vl_config
.crypto_key_id
< 0)
1116 memset(md5_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
1117 strncpy (md5_key
, argv
[i
]->arg
, OSPF_AUTH_MD5_SIZE
);
1118 vl_config
.md5_key
= md5_key
;
1122 vl_config
.md5_key
= NULL
;
1128 /* Action configuration */
1130 return ospf_vl_set (ospf
, &vl_config
);
1134 DEFUN (ospf_area_vlink_intervals
,
1135 ospf_area_vlink_intervals_cmd
,
1136 "area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D"
1137 "<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1138 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1139 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1140 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1142 VLINK_HELPSTR_IPADDR
1143 VLINK_HELPSTR_TIME_PARAM
1144 VLINK_HELPSTR_TIME_PARAM
1145 VLINK_HELPSTR_TIME_PARAM
1146 VLINK_HELPSTR_TIME_PARAM
)
1148 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1149 struct ospf_vl_config_data vl_config
;
1152 ospf_vl_config_data_init(&vl_config
, vty
);
1154 char *area_id
= argv
[1]->arg
;
1155 char *router_id
= argv
[3]->arg
;
1157 ret
= ospf_str2area_id (area_id
, &vl_config
.area_id
, &vl_config
.format
);
1160 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1164 ret
= inet_aton (router_id
, &vl_config
.vl_peer
);
1167 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE
);
1170 for (unsigned int i
= 0; i
< 4; i
++)
1173 if (argv_find (argv
, argc
, "hello-interval", &idx
))
1174 vl_config
.hello_interval
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1175 else if (argv_find (argv
, argc
, "retransmit-interval", &idx
))
1176 vl_config
.retransmit_interval
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1177 else if (argv_find (argv
, argc
, "transmit-delay", &idx
))
1178 vl_config
.transmit_delay
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1179 else if (argv_find (argv
, argc
, "dead-interval", &idx
))
1180 vl_config
.dead_interval
= strtol(argv
[idx
+1]->arg
, NULL
, 10);
1183 /* Action configuration */
1184 return ospf_vl_set (ospf
, &vl_config
);
1187 DEFUN (no_ospf_area_vlink
,
1188 no_ospf_area_vlink_cmd
,
1189 "no area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D [authentication] [<message-digest|null>] [<message-digest-key (1-255) md5 KEY|authentication-key AUTH_KEY>]",
1191 VLINK_HELPSTR_IPADDR
1192 "Enable authentication on this virtual link\n" \
1193 "Use null authentication\n" \
1194 "Use message-digest authentication\n"
1195 "Message digest authentication password (key)\n" \
1197 "Use MD5 algorithm\n" \
1198 "The OSPF password (key)")
1200 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1201 int idx_ipv4_number
= 2;
1203 struct ospf_area
*area
;
1204 struct ospf_vl_config_data vl_config
;
1205 struct ospf_vl_data
*vl_data
= NULL
;
1206 char auth_key
[OSPF_AUTH_SIMPLE_SIZE
+1];
1210 ospf_vl_config_data_init(&vl_config
, vty
);
1212 ret
= ospf_str2area_id (argv
[idx_ipv4_number
]->arg
, &vl_config
.area_id
, &format
);
1215 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1219 area
= ospf_area_lookup_by_area_id (ospf
, vl_config
.area_id
);
1222 vty_out (vty
, "Area does not exist%s", VTY_NEWLINE
);
1226 ret
= inet_aton (argv
[idx_ipv4
]->arg
, &vl_config
.vl_peer
);
1229 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s",
1236 /* Basic VLink no command */
1237 /* Thats all folks! - BUGS B. strikes again!!!*/
1238 if ((vl_data
= ospf_vl_lookup (ospf
, area
, vl_config
.vl_peer
)))
1239 ospf_vl_delete (ospf
, vl_data
);
1241 ospf_area_check_free (ospf
, vl_config
.area_id
);
1246 /* If we are down here, we are reseting parameters */
1248 /* Deal with other parameters */
1249 for (i
=6; i
< argc
; i
++)
1251 /* vty_out (vty, "argv[%d] - %s%s", i, argv[i], VTY_NEWLINE); */
1253 switch (argv
[i
]->arg
[0])
1257 if (i
> 2 || strncmp (argv
[i
]->text
, "authentication-", 15) == 0)
1259 /* authentication-key - this option can occur anywhere on
1260 command line. At start of command line
1261 must check for authentication option. */
1262 memset (auth_key
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
1263 vl_config
.auth_key
= auth_key
;
1265 else if (strncmp (argv
[i
]->text
, "authentication", 14) == 0)
1267 /* authentication - this option can only occur at start
1269 vl_config
.auth_type
= OSPF_AUTH_NOTSET
;
1274 /* message-digest-key */
1275 /* Delete one key */
1279 vl_config
.crypto_key_id
= strtol (argv
[i
]->arg
, NULL
, 10);
1280 if (vl_config
.crypto_key_id
< 0)
1282 vl_config
.md5_key
= NULL
;
1292 /* Action configuration */
1294 return ospf_vl_set (ospf
, &vl_config
);
1297 DEFUN (no_ospf_area_vlink_intervals
,
1298 no_ospf_area_vlink_intervals_cmd
,
1299 "no area <A.B.C.D|(0-4294967295)> virtual-link A.B.C.D"
1300 "<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1301 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1302 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1303 "[<hello-interval|retransmit-interval|transmit-delay|dead-interval> (1-65535)"
1306 VLINK_HELPSTR_IPADDR
1307 VLINK_HELPSTR_TIME_PARAM
1308 VLINK_HELPSTR_TIME_PARAM
1309 VLINK_HELPSTR_TIME_PARAM
1310 VLINK_HELPSTR_TIME_PARAM
)
1312 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1313 struct ospf_vl_config_data vl_config
;
1316 ospf_vl_config_data_init(&vl_config
, vty
);
1318 char *area_id
= argv
[2]->arg
;
1319 char *router_id
= argv
[4]->arg
;
1321 ret
= ospf_str2area_id (area_id
, &vl_config
.area_id
, &vl_config
.format
);
1324 vty_out (vty
, "OSPF area ID is invalid%s", VTY_NEWLINE
);
1328 ret
= inet_aton (router_id
, &vl_config
.vl_peer
);
1331 vty_out (vty
, "Please specify valid Router ID as a.b.c.d%s", VTY_NEWLINE
);
1335 for (unsigned int i
= 0; i
< 4; i
++)
1338 if (argv_find (argv
, argc
, "hello-interval", &idx
))
1339 vl_config
.hello_interval
= OSPF_HELLO_INTERVAL_DEFAULT
;
1340 else if (argv_find (argv
, argc
, "retransmit-interval", &idx
))
1341 vl_config
.retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
1342 else if (argv_find (argv
, argc
, "transmit-delay", &idx
))
1343 vl_config
.transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
1344 else if (argv_find (argv
, argc
, "dead-interval", &idx
))
1345 vl_config
.dead_interval
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
1348 /* Action configuration */
1349 return ospf_vl_set (ospf
, &vl_config
);
1352 DEFUN (ospf_area_shortcut
,
1353 ospf_area_shortcut_cmd
,
1354 "area <A.B.C.D|(0-4294967295)> shortcut <default|enable|disable>",
1355 "OSPF area parameters\n"
1356 "OSPF area ID in IP address format\n"
1357 "OSPF area ID as a decimal value\n"
1358 "Configure the area's shortcutting mode\n"
1359 "Set default shortcutting behavior\n"
1360 "Enable shortcutting through the area\n"
1361 "Disable shortcutting through the area\n")
1363 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1364 int idx_ipv4_number
= 1;
1365 int idx_enable_disable
= 3;
1366 struct ospf_area
*area
;
1367 struct in_addr area_id
;
1371 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1373 area
= ospf_area_get (ospf
, area_id
, format
);
1375 if (strncmp (argv
[idx_enable_disable
]->arg
, "de", 2) == 0)
1376 mode
= OSPF_SHORTCUT_DEFAULT
;
1377 else if (strncmp (argv
[idx_enable_disable
]->arg
, "di", 2) == 0)
1378 mode
= OSPF_SHORTCUT_DISABLE
;
1379 else if (strncmp (argv
[idx_enable_disable
]->arg
, "e", 1) == 0)
1380 mode
= OSPF_SHORTCUT_ENABLE
;
1384 ospf_area_shortcut_set (ospf
, area
, mode
);
1386 if (ospf
->abr_type
!= OSPF_ABR_SHORTCUT
)
1387 vty_out (vty
, "Shortcut area setting will take effect "
1388 "only when the router is configured as Shortcut ABR%s",
1394 DEFUN (no_ospf_area_shortcut
,
1395 no_ospf_area_shortcut_cmd
,
1396 "no area <A.B.C.D|(0-4294967295)> shortcut <enable|disable>",
1398 "OSPF area parameters\n"
1399 "OSPF area ID in IP address format\n"
1400 "OSPF area ID as a decimal value\n"
1401 "Deconfigure the area's shortcutting mode\n"
1402 "Deconfigure enabled shortcutting through the area\n"
1403 "Deconfigure disabled shortcutting through the area\n")
1405 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1406 int idx_ipv4_number
= 2;
1407 struct ospf_area
*area
;
1408 struct in_addr area_id
;
1411 VTY_GET_OSPF_AREA_ID_NO_BB ("shortcut", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1413 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1417 ospf_area_shortcut_unset (ospf
, area
);
1423 DEFUN (ospf_area_stub
,
1425 "area <A.B.C.D|(0-4294967295)> stub",
1426 "OSPF area parameters\n"
1427 "OSPF area ID in IP address format\n"
1428 "OSPF area ID as a decimal value\n"
1429 "Configure OSPF area as stub\n")
1431 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1432 int idx_ipv4_number
= 1;
1433 struct in_addr area_id
;
1436 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1438 ret
= ospf_area_stub_set (ospf
, area_id
);
1441 vty_out (vty
, "First deconfigure all virtual link through this area%s",
1446 ospf_area_no_summary_unset (ospf
, area_id
);
1451 DEFUN (ospf_area_stub_no_summary
,
1452 ospf_area_stub_no_summary_cmd
,
1453 "area <A.B.C.D|(0-4294967295)> stub no-summary",
1454 "OSPF stub parameters\n"
1455 "OSPF area ID in IP address format\n"
1456 "OSPF area ID as a decimal value\n"
1457 "Configure OSPF area as stub\n"
1458 "Do not inject inter-area routes into stub\n")
1460 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1461 int idx_ipv4_number
= 1;
1462 struct in_addr area_id
;
1465 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1467 ret
= ospf_area_stub_set (ospf
, area_id
);
1470 vty_out (vty
, "%% Area cannot be stub as it contains a virtual link%s",
1475 ospf_area_no_summary_set (ospf
, area_id
);
1480 DEFUN (no_ospf_area_stub
,
1481 no_ospf_area_stub_cmd
,
1482 "no area <A.B.C.D|(0-4294967295)> stub",
1484 "OSPF area parameters\n"
1485 "OSPF area ID in IP address format\n"
1486 "OSPF area ID as a decimal value\n"
1487 "Configure OSPF area as stub\n")
1489 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1490 int idx_ipv4_number
= 2;
1491 struct in_addr area_id
;
1494 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1496 ospf_area_stub_unset (ospf
, area_id
);
1497 ospf_area_no_summary_unset (ospf
, area_id
);
1502 DEFUN (no_ospf_area_stub_no_summary
,
1503 no_ospf_area_stub_no_summary_cmd
,
1504 "no area <A.B.C.D|(0-4294967295)> stub no-summary",
1506 "OSPF area parameters\n"
1507 "OSPF area ID in IP address format\n"
1508 "OSPF area ID as a decimal value\n"
1509 "Configure OSPF area as stub\n"
1510 "Do not inject inter-area routes into area\n")
1512 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1513 int idx_ipv4_number
= 2;
1514 struct in_addr area_id
;
1517 VTY_GET_OSPF_AREA_ID_NO_BB ("stub", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1518 ospf_area_no_summary_unset (ospf
, area_id
);
1524 ospf_area_nssa_cmd_handler (struct vty
*vty
, int argc
, struct cmd_token
**argv
,
1527 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1528 struct in_addr area_id
;
1531 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id
, format
, argv
[1]->arg
);
1533 ret
= ospf_area_nssa_set (ospf
, area_id
);
1536 vty_out (vty
, "%% Area cannot be nssa as it contains a virtual link%s",
1543 if (strncmp (argv
[3]->text
, "translate-c", 11) == 0)
1544 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1545 OSPF_NSSA_ROLE_CANDIDATE
);
1546 else if (strncmp (argv
[3]->text
, "translate-n", 11) == 0)
1547 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1548 OSPF_NSSA_ROLE_NEVER
);
1549 else if (strncmp (argv
[3]->text
, "translate-a", 11) == 0)
1550 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1551 OSPF_NSSA_ROLE_ALWAYS
);
1555 ospf_area_nssa_translator_role_set (ospf
, area_id
,
1556 OSPF_NSSA_ROLE_CANDIDATE
);
1560 ospf_area_no_summary_set (ospf
, area_id
);
1562 ospf_area_no_summary_unset (ospf
, area_id
);
1564 ospf_schedule_abr_task (ospf
);
1569 DEFUN (ospf_area_nssa_translate_no_summary
,
1570 ospf_area_nssa_translate_no_summary_cmd
,
1571 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always> no-summary",
1572 "OSPF area parameters\n"
1573 "OSPF area ID in IP address format\n"
1574 "OSPF area ID as a decimal value\n"
1575 "Configure OSPF area as nssa\n"
1576 "Configure NSSA-ABR for translate election (default)\n"
1577 "Configure NSSA-ABR to never translate\n"
1578 "Configure NSSA-ABR to always translate\n"
1579 "Do not inject inter-area routes into nssa\n")
1581 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 1);
1584 DEFUN (ospf_area_nssa_translate
,
1585 ospf_area_nssa_translate_cmd
,
1586 "area <A.B.C.D|(0-4294967295)> nssa <translate-candidate|translate-never|translate-always>",
1587 "OSPF area parameters\n"
1588 "OSPF area ID in IP address format\n"
1589 "OSPF area ID as a decimal value\n"
1590 "Configure OSPF area as nssa\n"
1591 "Configure NSSA-ABR for translate election (default)\n"
1592 "Configure NSSA-ABR to never translate\n"
1593 "Configure NSSA-ABR to always translate\n")
1595 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 0);
1598 DEFUN (ospf_area_nssa
,
1600 "area <A.B.C.D|(0-4294967295)> nssa",
1601 "OSPF area parameters\n"
1602 "OSPF area ID in IP address format\n"
1603 "OSPF area ID as a decimal value\n"
1604 "Configure OSPF area as nssa\n")
1606 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 0);
1609 DEFUN (ospf_area_nssa_no_summary
,
1610 ospf_area_nssa_no_summary_cmd
,
1611 "area <A.B.C.D|(0-4294967295)> nssa no-summary",
1612 "OSPF area parameters\n"
1613 "OSPF area ID in IP address format\n"
1614 "OSPF area ID as a decimal value\n"
1615 "Configure OSPF area as nssa\n"
1616 "Do not inject inter-area routes into nssa\n")
1618 return ospf_area_nssa_cmd_handler (vty
, argc
, argv
, 1);
1621 DEFUN (no_ospf_area_nssa
,
1622 no_ospf_area_nssa_cmd
,
1623 "no area <A.B.C.D|(0-4294967295)> nssa [<translate-candidate|translate-never|translate-always> [no-summary]]",
1625 "OSPF area parameters\n"
1626 "OSPF area ID in IP address format\n"
1627 "OSPF area ID as a decimal value\n"
1628 "Configure OSPF area as nssa\n"
1629 "Configure NSSA-ABR for translate election (default)\n"
1630 "Configure NSSA-ABR to never translate\n"
1631 "Configure NSSA-ABR to always translate\n"
1632 "Do not inject inter-area routes into nssa\n")
1634 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1635 int idx_ipv4_number
= 2;
1636 struct in_addr area_id
;
1639 VTY_GET_OSPF_AREA_ID_NO_BB ("NSSA", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1641 ospf_area_nssa_unset (ospf
, area_id
);
1642 ospf_area_no_summary_unset (ospf
, area_id
);
1644 ospf_schedule_abr_task (ospf
);
1650 DEFUN (ospf_area_default_cost
,
1651 ospf_area_default_cost_cmd
,
1652 "area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1653 "OSPF area parameters\n"
1654 "OSPF area ID in IP address format\n"
1655 "OSPF area ID as a decimal value\n"
1656 "Set the summary-default cost of a NSSA or stub area\n"
1657 "Stub's advertised default summary cost\n")
1659 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1660 int idx_ipv4_number
= 1;
1662 struct ospf_area
*area
;
1663 struct in_addr area_id
;
1666 struct prefix_ipv4 p
;
1668 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1669 VTY_GET_INTEGER_RANGE ("stub default cost", cost
, argv
[idx_number
]->arg
, 0, 16777215);
1671 area
= ospf_area_get (ospf
, area_id
, format
);
1673 if (area
->external_routing
== OSPF_AREA_DEFAULT
)
1675 vty_out (vty
, "The area is neither stub, nor NSSA%s", VTY_NEWLINE
);
1679 area
->default_cost
= cost
;
1682 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1684 if (IS_DEBUG_OSPF_EVENT
)
1685 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1686 "announcing 0.0.0.0/0 to area %s",
1687 inet_ntoa (area
->area_id
));
1688 ospf_abr_announce_network_to_area (&p
, area
->default_cost
, area
);
1693 DEFUN (no_ospf_area_default_cost
,
1694 no_ospf_area_default_cost_cmd
,
1695 "no area <A.B.C.D|(0-4294967295)> default-cost (0-16777215)",
1697 "OSPF area parameters\n"
1698 "OSPF area ID in IP address format\n"
1699 "OSPF area ID as a decimal value\n"
1700 "Set the summary-default cost of a NSSA or stub area\n"
1701 "Stub's advertised default summary cost\n")
1703 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1704 int idx_ipv4_number
= 2;
1706 struct ospf_area
*area
;
1707 struct in_addr area_id
;
1709 struct prefix_ipv4 p
;
1711 VTY_GET_OSPF_AREA_ID_NO_BB ("default-cost", area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1712 VTY_CHECK_INTEGER_RANGE ("stub default cost", argv
[idx_number
]->arg
, 0, OSPF_LS_INFINITY
);
1714 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1718 if (area
->external_routing
== OSPF_AREA_DEFAULT
)
1720 vty_out (vty
, "The area is neither stub, nor NSSA%s", VTY_NEWLINE
);
1724 area
->default_cost
= 1;
1727 p
.prefix
.s_addr
= OSPF_DEFAULT_DESTINATION
;
1729 if (IS_DEBUG_OSPF_EVENT
)
1730 zlog_debug ("ospf_abr_announce_stub_defaults(): "
1731 "announcing 0.0.0.0/0 to area %s",
1732 inet_ntoa (area
->area_id
));
1733 ospf_abr_announce_network_to_area (&p
, area
->default_cost
, area
);
1736 ospf_area_check_free (ospf
, area_id
);
1741 DEFUN (ospf_area_export_list
,
1742 ospf_area_export_list_cmd
,
1743 "area <A.B.C.D|(0-4294967295)> export-list NAME",
1744 "OSPF area parameters\n"
1745 "OSPF area ID in IP address format\n"
1746 "OSPF area ID as a decimal value\n"
1747 "Set the filter for networks announced to other areas\n"
1748 "Name of the access-list\n")
1750 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1751 int idx_ipv4_number
= 1;
1752 struct ospf_area
*area
;
1753 struct in_addr area_id
;
1756 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1758 area
= ospf_area_get (ospf
, area_id
, format
);
1759 ospf_area_export_list_set (ospf
, area
, argv
[3]->arg
);
1764 DEFUN (no_ospf_area_export_list
,
1765 no_ospf_area_export_list_cmd
,
1766 "no area <A.B.C.D|(0-4294967295)> export-list NAME",
1768 "OSPF area parameters\n"
1769 "OSPF area ID in IP address format\n"
1770 "OSPF area ID as a decimal value\n"
1771 "Unset the filter for networks announced to other areas\n"
1772 "Name of the access-list\n")
1774 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1775 int idx_ipv4_number
= 2;
1776 struct ospf_area
*area
;
1777 struct in_addr area_id
;
1780 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1782 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1786 ospf_area_export_list_unset (ospf
, area
);
1792 DEFUN (ospf_area_import_list
,
1793 ospf_area_import_list_cmd
,
1794 "area <A.B.C.D|(0-4294967295)> import-list NAME",
1795 "OSPF area parameters\n"
1796 "OSPF area ID in IP address format\n"
1797 "OSPF area ID as a decimal value\n"
1798 "Set the filter for networks from other areas announced to the specified one\n"
1799 "Name of the access-list\n")
1801 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1802 int idx_ipv4_number
= 1;
1803 struct ospf_area
*area
;
1804 struct in_addr area_id
;
1807 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1809 area
= ospf_area_get (ospf
, area_id
, format
);
1810 ospf_area_import_list_set (ospf
, area
, argv
[3]->arg
);
1815 DEFUN (no_ospf_area_import_list
,
1816 no_ospf_area_import_list_cmd
,
1817 "no area <A.B.C.D|(0-4294967295)> import-list NAME",
1819 "OSPF area parameters\n"
1820 "OSPF area ID in IP address format\n"
1821 "OSPF area ID as a decimal value\n"
1822 "Unset the filter for networks announced to other areas\n"
1823 "Name of the access-list\n")
1825 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1826 int idx_ipv4_number
= 2;
1827 struct ospf_area
*area
;
1828 struct in_addr area_id
;
1831 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1833 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
1837 ospf_area_import_list_unset (ospf
, area
);
1842 DEFUN (ospf_area_filter_list
,
1843 ospf_area_filter_list_cmd
,
1844 "area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1845 "OSPF area parameters\n"
1846 "OSPF area ID in IP address format\n"
1847 "OSPF area ID as a decimal value\n"
1848 "Filter networks between OSPF areas\n"
1849 "Filter prefixes between OSPF areas\n"
1850 "Name of an IP prefix-list\n"
1851 "Filter networks sent to this area\n"
1852 "Filter networks sent from this area\n")
1854 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1855 int idx_ipv4_number
= 1;
1858 struct ospf_area
*area
;
1859 struct in_addr area_id
;
1860 struct prefix_list
*plist
;
1863 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1865 area
= ospf_area_get (ospf
, area_id
, format
);
1866 plist
= prefix_list_lookup (AFI_IP
, argv
[idx_word
]->arg
);
1867 if (strncmp (argv
[idx_in_out
]->arg
, "in", 2) == 0)
1869 PREFIX_LIST_IN (area
) = plist
;
1870 if (PREFIX_NAME_IN (area
))
1871 free (PREFIX_NAME_IN (area
));
1873 PREFIX_NAME_IN (area
) = strdup (argv
[idx_word
]->arg
);
1874 ospf_schedule_abr_task (ospf
);
1878 PREFIX_LIST_OUT (area
) = plist
;
1879 if (PREFIX_NAME_OUT (area
))
1880 free (PREFIX_NAME_OUT (area
));
1882 PREFIX_NAME_OUT (area
) = strdup (argv
[idx_word
]->arg
);
1883 ospf_schedule_abr_task (ospf
);
1889 DEFUN (no_ospf_area_filter_list
,
1890 no_ospf_area_filter_list_cmd
,
1891 "no area <A.B.C.D|(0-4294967295)> filter-list prefix WORD <in|out>",
1893 "OSPF area parameters\n"
1894 "OSPF area ID in IP address format\n"
1895 "OSPF area ID as a decimal value\n"
1896 "Filter networks between OSPF areas\n"
1897 "Filter prefixes between OSPF areas\n"
1898 "Name of an IP prefix-list\n"
1899 "Filter networks sent to this area\n"
1900 "Filter networks sent from this area\n")
1902 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1903 int idx_ipv4_number
= 2;
1906 struct ospf_area
*area
;
1907 struct in_addr area_id
;
1910 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1912 if ((area
= ospf_area_lookup_by_area_id (ospf
, area_id
)) == NULL
)
1915 if (strncmp (argv
[idx_in_out
]->arg
, "in", 2) == 0)
1917 if (PREFIX_NAME_IN (area
))
1918 if (strcmp (PREFIX_NAME_IN (area
), argv
[idx_word
]->arg
) != 0)
1921 PREFIX_LIST_IN (area
) = NULL
;
1922 if (PREFIX_NAME_IN (area
))
1923 free (PREFIX_NAME_IN (area
));
1925 PREFIX_NAME_IN (area
) = NULL
;
1927 ospf_schedule_abr_task (ospf
);
1931 if (PREFIX_NAME_OUT (area
))
1932 if (strcmp (PREFIX_NAME_OUT (area
), argv
[idx_word
]->arg
) != 0)
1935 PREFIX_LIST_OUT (area
) = NULL
;
1936 if (PREFIX_NAME_OUT (area
))
1937 free (PREFIX_NAME_OUT (area
));
1939 PREFIX_NAME_OUT (area
) = NULL
;
1941 ospf_schedule_abr_task (ospf
);
1948 DEFUN (ospf_area_authentication_message_digest
,
1949 ospf_area_authentication_message_digest_cmd
,
1950 "area <A.B.C.D|(0-4294967295)> authentication message-digest",
1951 "OSPF area parameters\n"
1952 "OSPF area ID in IP address format\n"
1953 "OSPF area ID as a decimal value\n"
1954 "Enable authentication\n"
1955 "Use message-digest authentication\n")
1957 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1958 int idx_ipv4_number
= 1;
1959 struct ospf_area
*area
;
1960 struct in_addr area_id
;
1963 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1965 area
= ospf_area_get (ospf
, area_id
, format
);
1966 area
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
1971 DEFUN (ospf_area_authentication
,
1972 ospf_area_authentication_cmd
,
1973 "area <A.B.C.D|(0-4294967295)> authentication",
1974 "OSPF area parameters\n"
1975 "OSPF area ID in IP address format\n"
1976 "OSPF area ID as a decimal value\n"
1977 "Enable authentication\n")
1979 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
1980 int idx_ipv4_number
= 1;
1981 struct ospf_area
*area
;
1982 struct in_addr area_id
;
1985 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
1987 area
= ospf_area_get (ospf
, area_id
, format
);
1988 area
->auth_type
= OSPF_AUTH_SIMPLE
;
1993 DEFUN (no_ospf_area_authentication
,
1994 no_ospf_area_authentication_cmd
,
1995 "no area <A.B.C.D|(0-4294967295)> authentication",
1997 "OSPF area parameters\n"
1998 "OSPF area ID in IP address format\n"
1999 "OSPF area ID as a decimal value\n"
2000 "Enable authentication\n")
2002 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2003 int idx_ipv4_number
= 2;
2004 struct ospf_area
*area
;
2005 struct in_addr area_id
;
2008 VTY_GET_OSPF_AREA_ID (area_id
, format
, argv
[idx_ipv4_number
]->arg
);
2010 area
= ospf_area_lookup_by_area_id (ospf
, area_id
);
2014 area
->auth_type
= OSPF_AUTH_NULL
;
2016 ospf_area_check_free (ospf
, area_id
);
2022 DEFUN (ospf_abr_type
,
2024 "ospf abr-type <cisco|ibm|shortcut|standard>",
2025 "OSPF specific commands\n"
2026 "Set OSPF ABR type\n"
2027 "Alternative ABR, cisco implementation\n"
2028 "Alternative ABR, IBM implementation\n"
2030 "Standard behavior (RFC2328)\n")
2032 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2034 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2036 if (strncmp (argv
[idx_vendor
]->arg
, "c", 1) == 0)
2037 abr_type
= OSPF_ABR_CISCO
;
2038 else if (strncmp (argv
[idx_vendor
]->arg
, "i", 1) == 0)
2039 abr_type
= OSPF_ABR_IBM
;
2040 else if (strncmp (argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2041 abr_type
= OSPF_ABR_SHORTCUT
;
2042 else if (strncmp (argv
[idx_vendor
]->arg
, "st", 2) == 0)
2043 abr_type
= OSPF_ABR_STAND
;
2047 /* If ABR type value is changed, schedule ABR task. */
2048 if (ospf
->abr_type
!= abr_type
)
2050 ospf
->abr_type
= abr_type
;
2051 ospf_schedule_abr_task (ospf
);
2057 DEFUN (no_ospf_abr_type
,
2058 no_ospf_abr_type_cmd
,
2059 "no ospf abr-type <cisco|ibm|shortcut|standard>",
2061 "OSPF specific commands\n"
2062 "Set OSPF ABR type\n"
2063 "Alternative ABR, cisco implementation\n"
2064 "Alternative ABR, IBM implementation\n"
2068 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2070 u_char abr_type
= OSPF_ABR_UNKNOWN
;
2072 if (strncmp (argv
[idx_vendor
]->arg
, "c", 1) == 0)
2073 abr_type
= OSPF_ABR_CISCO
;
2074 else if (strncmp (argv
[idx_vendor
]->arg
, "i", 1) == 0)
2075 abr_type
= OSPF_ABR_IBM
;
2076 else if (strncmp (argv
[idx_vendor
]->arg
, "sh", 2) == 0)
2077 abr_type
= OSPF_ABR_SHORTCUT
;
2078 else if (strncmp (argv
[idx_vendor
]->arg
, "st", 2) == 0)
2079 abr_type
= OSPF_ABR_STAND
;
2083 /* If ABR type value is changed, schedule ABR task. */
2084 if (ospf
->abr_type
== abr_type
)
2086 ospf
->abr_type
= OSPF_ABR_DEFAULT
;
2087 ospf_schedule_abr_task (ospf
);
2093 DEFUN (ospf_log_adjacency_changes
,
2094 ospf_log_adjacency_changes_cmd
,
2095 "log-adjacency-changes",
2096 "Log changes in adjacency state\n")
2098 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2100 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2101 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2105 DEFUN (ospf_log_adjacency_changes_detail
,
2106 ospf_log_adjacency_changes_detail_cmd
,
2107 "log-adjacency-changes detail",
2108 "Log changes in adjacency state\n"
2109 "Log all state changes\n")
2111 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2113 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2114 SET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2118 DEFUN (no_ospf_log_adjacency_changes
,
2119 no_ospf_log_adjacency_changes_cmd
,
2120 "no log-adjacency-changes",
2122 "Log changes in adjacency state\n")
2124 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2126 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2127 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2131 DEFUN (no_ospf_log_adjacency_changes_detail
,
2132 no_ospf_log_adjacency_changes_detail_cmd
,
2133 "no log-adjacency-changes detail",
2135 "Log changes in adjacency state\n"
2136 "Log all state changes\n")
2138 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2140 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
);
2141 UNSET_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
);
2145 DEFUN (ospf_compatible_rfc1583
,
2146 ospf_compatible_rfc1583_cmd
,
2147 "compatible rfc1583",
2148 "OSPF compatibility list\n"
2149 "compatible with RFC 1583\n")
2151 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2153 if (!CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2155 SET_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2156 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
2161 DEFUN (no_ospf_compatible_rfc1583
,
2162 no_ospf_compatible_rfc1583_cmd
,
2163 "no compatible rfc1583",
2165 "OSPF compatibility list\n"
2166 "compatible with RFC 1583\n")
2168 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2170 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2172 UNSET_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
);
2173 ospf_spf_calculate_schedule (ospf
, SPF_FLAG_CONFIG_CHANGE
);
2178 ALIAS (ospf_compatible_rfc1583
,
2179 ospf_rfc1583_flag_cmd
,
2180 "ospf rfc1583compatibility",
2181 "OSPF specific commands\n"
2182 "Enable the RFC1583Compatibility flag\n")
2184 ALIAS (no_ospf_compatible_rfc1583
,
2185 no_ospf_rfc1583_flag_cmd
,
2186 "no ospf rfc1583compatibility",
2188 "OSPF specific commands\n"
2189 "Disable the RFC1583Compatibility flag\n")
2192 ospf_timers_spf_set (struct vty
*vty
, unsigned int delay
,
2196 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2198 ospf
->spf_delay
= delay
;
2199 ospf
->spf_holdtime
= hold
;
2200 ospf
->spf_max_holdtime
= max
;
2205 DEFUN (ospf_timers_min_ls_interval
,
2206 ospf_timers_min_ls_interval_cmd
,
2207 "timers throttle lsa all (0-5000)",
2208 "Adjust routing timers\n"
2209 "Throttling adaptive timer\n"
2210 "LSA delay between transmissions\n"
2212 "Delay (msec) between sending LSAs\n")
2214 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2216 unsigned int interval
;
2220 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2224 VTY_GET_INTEGER ("LSA interval", interval
, argv
[idx_number
]->arg
);
2226 ospf
->min_ls_interval
= interval
;
2231 DEFUN (no_ospf_timers_min_ls_interval
,
2232 no_ospf_timers_min_ls_interval_cmd
,
2233 "no timers throttle lsa all [(0-5000)]",
2235 "Adjust routing timers\n"
2236 "Throttling adaptive timer\n"
2237 "LSA delay between transmissions\n"
2239 "Delay (msec) between sending LSAs\n")
2241 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2242 ospf
->min_ls_interval
= OSPF_MIN_LS_INTERVAL
;
2248 DEFUN (ospf_timers_min_ls_arrival
,
2249 ospf_timers_min_ls_arrival_cmd
,
2250 "timers lsa arrival (0-1000)",
2251 "Adjust routing timers\n"
2252 "Throttling link state advertisement delays\n"
2253 "OSPF minimum arrival interval delay\n"
2254 "Delay (msec) between accepted LSAs\n")
2256 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2258 unsigned int arrival
;
2262 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2266 VTY_GET_INTEGER_RANGE ("minimum LSA inter-arrival time", arrival
, argv
[idx_number
]->arg
, 0, 1000);
2268 ospf
->min_ls_arrival
= arrival
;
2273 DEFUN (no_ospf_timers_min_ls_arrival
,
2274 no_ospf_timers_min_ls_arrival_cmd
,
2275 "no timers lsa arrival [(0-1000)]",
2277 "Adjust routing timers\n"
2278 "Throttling link state advertisement delays\n"
2279 "OSPF minimum arrival interval delay\n"
2280 "Delay (msec) between accepted LSAs\n")
2282 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2284 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2290 DEFUN (ospf_timers_throttle_spf
,
2291 ospf_timers_throttle_spf_cmd
,
2292 "timers throttle spf (0-600000) (0-600000) (0-600000)",
2293 "Adjust routing timers\n"
2294 "Throttling adaptive timer\n"
2296 "Delay (msec) from first change received till SPF calculation\n"
2297 "Initial hold time (msec) between consecutive SPF calculations\n"
2298 "Maximum hold time (msec)\n")
2301 int idx_number_2
= 4;
2302 int idx_number_3
= 5;
2303 unsigned int delay
, hold
, max
;
2307 vty_out (vty
, "Insufficient arguments%s", VTY_NEWLINE
);
2311 VTY_GET_INTEGER_RANGE ("SPF delay timer", delay
, argv
[idx_number
]->arg
, 0, 600000);
2312 VTY_GET_INTEGER_RANGE ("SPF hold timer", hold
, argv
[idx_number_2
]->arg
, 0, 600000);
2313 VTY_GET_INTEGER_RANGE ("SPF max-hold timer", max
, argv
[idx_number_3
]->arg
, 0, 600000);
2315 return ospf_timers_spf_set (vty
, delay
, hold
, max
);
2318 DEFUN (no_ospf_timers_throttle_spf
,
2319 no_ospf_timers_throttle_spf_cmd
,
2320 "no timers throttle spf [(0-600000)(0-600000)(0-600000)]",
2322 "Adjust routing timers\n"
2323 "Throttling adaptive timer\n"
2325 "Delay (msec) from first change received till SPF calculation\n"
2326 "Initial hold time (msec) between consecutive SPF calculations\n"
2327 "Maximum hold time (msec)\n")
2329 return ospf_timers_spf_set (vty
,
2330 OSPF_SPF_DELAY_DEFAULT
,
2331 OSPF_SPF_HOLDTIME_DEFAULT
,
2332 OSPF_SPF_MAX_HOLDTIME_DEFAULT
);
2336 DEFUN (ospf_timers_lsa
,
2337 ospf_timers_lsa_cmd
,
2338 "timers lsa min-arrival (0-600000)",
2339 "Adjust routing timers\n"
2341 "Minimum delay in receiving new version of a LSA\n"
2342 "Delay in milliseconds\n")
2344 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2346 unsigned int minarrival
;
2350 vty_out (vty
, "Insufficient number of arguments%s", VTY_NEWLINE
);
2354 VTY_GET_INTEGER ("LSA min-arrival", minarrival
, argv
[idx_number
]->arg
);
2356 ospf
->min_ls_arrival
= minarrival
;
2361 DEFUN (no_ospf_timers_lsa
,
2362 no_ospf_timers_lsa_cmd
,
2363 "no timers lsa min-arrival [(0-600000)]",
2365 "Adjust routing timers\n"
2367 "Minimum delay in receiving new version of a LSA\n"
2368 "Delay in milliseconds\n")
2370 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2371 unsigned int minarrival
;
2375 VTY_GET_INTEGER ("LSA min-arrival", minarrival
, argv
[4]->arg
);
2377 if (ospf
->min_ls_arrival
!= minarrival
||
2378 minarrival
== OSPF_MIN_LS_ARRIVAL
)
2382 ospf
->min_ls_arrival
= OSPF_MIN_LS_ARRIVAL
;
2387 DEFUN (ospf_neighbor
,
2389 "neighbor A.B.C.D [priority (0-255) [poll-interval (1-65535)]]",
2391 "Neighbor IP address\n"
2392 "Neighbor Priority\n"
2394 "Dead Neighbor Polling interval\n"
2397 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2401 struct in_addr nbr_addr
;
2402 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2403 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2405 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2408 VTY_GET_INTEGER_RANGE ("neighbor priority", priority
, argv
[idx_pri
]->arg
, 0, 255);
2411 VTY_GET_INTEGER_RANGE ("poll interval", interval
, argv
[idx_poll
]->arg
, 1, 65535);
2413 ospf_nbr_nbma_set (ospf
, nbr_addr
);
2416 ospf_nbr_nbma_priority_set (ospf
, nbr_addr
, priority
);
2419 ospf_nbr_nbma_poll_interval_set (ospf
, nbr_addr
, interval
);
2424 DEFUN (ospf_neighbor_poll_interval
,
2425 ospf_neighbor_poll_interval_cmd
,
2426 "neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2428 "Neighbor IP address\n"
2429 "Dead Neighbor Polling interval\n"
2431 "OSPF priority of non-broadcast neighbor\n"
2434 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2438 struct in_addr nbr_addr
;
2439 unsigned int priority
= OSPF_NEIGHBOR_PRIORITY_DEFAULT
;
2440 unsigned int interval
= OSPF_POLL_INTERVAL_DEFAULT
;
2442 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2444 VTY_GET_INTEGER_RANGE ("poll interval", interval
, argv
[idx_poll
]->arg
, 1, 65535);
2447 VTY_GET_INTEGER_RANGE ("neighbor priority", priority
, argv
[idx_pri
]->arg
, 0, 255);
2449 ospf_nbr_nbma_set (ospf
, nbr_addr
);
2450 ospf_nbr_nbma_poll_interval_set (ospf
, nbr_addr
, interval
);
2453 ospf_nbr_nbma_priority_set (ospf
, nbr_addr
, priority
);
2458 DEFUN (no_ospf_neighbor
,
2459 no_ospf_neighbor_cmd
,
2460 "no neighbor A.B.C.D [priority (0-255) [poll-interval (1-65525)]]",
2463 "Neighbor IP address\n"
2464 "Neighbor Priority\n"
2466 "Dead Neighbor Polling interval\n"
2469 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2471 struct in_addr nbr_addr
;
2473 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2475 (void)ospf_nbr_nbma_unset (ospf
, nbr_addr
);
2480 DEFUN (no_ospf_neighbor_poll
,
2481 no_ospf_neighbor_poll_cmd
,
2482 "no neighbor A.B.C.D poll-interval (1-65535) [priority (0-255)]",
2485 "Neighbor IP address\n"
2486 "Dead Neighbor Polling interval\n"
2488 "Neighbor Priority\n"
2491 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2493 struct in_addr nbr_addr
;
2495 VTY_GET_IPV4_ADDRESS ("neighbor address", nbr_addr
, argv
[idx_ipv4
]->arg
);
2497 (void)ospf_nbr_nbma_unset (ospf
, nbr_addr
);
2502 DEFUN (ospf_refresh_timer
,
2503 ospf_refresh_timer_cmd
,
2504 "refresh timer (10-1800)",
2505 "Adjust refresh parameters\n"
2506 "Set refresh timer\n"
2507 "Timer value in seconds\n")
2509 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2511 unsigned int interval
;
2513 VTY_GET_INTEGER_RANGE ("refresh timer", interval
, argv
[idx_number
]->arg
, 10, 1800);
2514 interval
= (interval
/ OSPF_LSA_REFRESHER_GRANULARITY
) * OSPF_LSA_REFRESHER_GRANULARITY
;
2516 ospf_timers_refresh_set (ospf
, interval
);
2521 DEFUN (no_ospf_refresh_timer
,
2522 no_ospf_refresh_timer_val_cmd
,
2523 "no refresh timer [(10-1800)]",
2525 "Adjust refresh parameters\n"
2526 "Unset refresh timer\n"
2527 "Timer value in seconds\n")
2529 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2531 unsigned int interval
;
2535 VTY_GET_INTEGER_RANGE ("refresh timer", interval
, argv
[idx_number
]->arg
, 10, 1800);
2537 if (ospf
->lsa_refresh_interval
!= interval
||
2538 interval
== OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
2542 ospf_timers_refresh_unset (ospf
);
2548 DEFUN (ospf_auto_cost_reference_bandwidth
,
2549 ospf_auto_cost_reference_bandwidth_cmd
,
2550 "auto-cost reference-bandwidth (1-4294967)",
2551 "Calculate OSPF interface cost according to bandwidth\n"
2552 "Use reference bandwidth method to assign OSPF cost\n"
2553 "The reference bandwidth in terms of Mbits per second\n")
2555 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2558 struct listnode
*node
;
2559 struct interface
*ifp
;
2561 refbw
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
2562 if (refbw
< 1 || refbw
> 4294967)
2564 vty_out (vty
, "reference-bandwidth value is invalid%s", VTY_NEWLINE
);
2568 /* If reference bandwidth is changed. */
2569 if ((refbw
) == ospf
->ref_bandwidth
)
2572 ospf
->ref_bandwidth
= refbw
;
2573 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
2574 ospf_if_recalculate_output_cost (ifp
);
2579 DEFUN (no_ospf_auto_cost_reference_bandwidth
,
2580 no_ospf_auto_cost_reference_bandwidth_cmd
,
2581 "no auto-cost reference-bandwidth [(1-4294967)]",
2583 "Calculate OSPF interface cost according to bandwidth\n"
2584 "Use reference bandwidth method to assign OSPF cost\n"
2585 "The reference bandwidth in terms of Mbits per second\n")
2587 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2588 struct listnode
*node
, *nnode
;
2589 struct interface
*ifp
;
2591 if (ospf
->ref_bandwidth
== OSPF_DEFAULT_REF_BANDWIDTH
)
2594 ospf
->ref_bandwidth
= OSPF_DEFAULT_REF_BANDWIDTH
;
2595 vty_out (vty
, "%% OSPF: Reference bandwidth is changed.%s", VTY_NEWLINE
);
2596 vty_out (vty
, " Please ensure reference bandwidth is consistent across all routers%s", VTY_NEWLINE
);
2598 for (ALL_LIST_ELEMENTS (om
->iflist
, node
, nnode
, ifp
))
2599 ospf_if_recalculate_output_cost (ifp
);
2604 DEFUN (ospf_write_multiplier
,
2605 ospf_write_multiplier_cmd
,
2606 "ospf write-multiplier (1-100)",
2607 "OSPF specific commands\n"
2608 "Write multiplier\n"
2609 "Maximum number of interface serviced per write\n")
2611 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2613 u_int32_t write_oi_count
;
2620 write_oi_count
= strtol (argv
[idx_number
]->arg
, NULL
, 10);
2621 if (write_oi_count
< 1 || write_oi_count
> 100)
2623 vty_out (vty
, "write-multiplier value is invalid%s", VTY_NEWLINE
);
2627 ospf
->write_oi_count
= write_oi_count
;
2631 ALIAS (ospf_write_multiplier
,
2632 write_multiplier_cmd
,
2633 "write-multiplier (1-100)",
2634 "Write multiplier\n"
2635 "Maximum number of interface serviced per write\n")
2637 DEFUN (no_ospf_write_multiplier
,
2638 no_ospf_write_multiplier_cmd
,
2639 "no ospf write-multiplier (1-100)",
2641 "OSPF specific commands\n"
2642 "Write multiplier\n"
2643 "Maximum number of interface serviced per write\n")
2645 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
2647 ospf
->write_oi_count
= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
;
2651 ALIAS (no_ospf_write_multiplier
,
2652 no_write_multiplier_cmd
,
2653 "no write-multiplier (1-100)",
2655 "Write multiplier\n"
2656 "Maximum number of interface serviced per write\n")
2658 const char *ospf_abr_type_descr_str
[] =
2661 "Standard (RFC2328)",
2663 "Alternative Cisco",
2664 "Alternative Shortcut"
2667 const char *ospf_shortcut_mode_descr_str
[] =
2675 show_ip_ospf_area (struct vty
*vty
, struct ospf_area
*area
, json_object
*json_areas
, u_char use_json
)
2677 json_object
*json_area
= NULL
;
2680 json_area
= json_object_new_object();
2684 vty_out (vty
, " Area ID: %s", inet_ntoa (area
->area_id
));
2686 /* Show Area type/mode. */
2687 if (OSPF_IS_AREA_BACKBONE (area
))
2690 json_object_boolean_true_add(json_area
, "backbone");
2692 vty_out (vty
, " (Backbone)%s", VTY_NEWLINE
);
2698 if (area
->external_routing
== OSPF_AREA_STUB
)
2700 if (area
->no_summary
)
2701 json_object_boolean_true_add(json_area
, "stubNoSummary");
2702 if (area
->shortcut_configured
)
2703 json_object_boolean_true_add(json_area
, "stubShortcut");
2705 else if (area
->external_routing
== OSPF_AREA_NSSA
)
2707 if (area
->no_summary
)
2708 json_object_boolean_true_add(json_area
, "nssaNoSummary");
2709 if (area
->shortcut_configured
)
2710 json_object_boolean_true_add(json_area
, "nssaShortcut");
2713 json_object_string_add(json_area
,"shortcuttingMode",
2714 ospf_shortcut_mode_descr_str
[area
->shortcut_configured
]);
2715 if (area
->shortcut_capability
)
2716 json_object_boolean_true_add(json_area
,"sBitConcensus");
2720 if (area
->external_routing
== OSPF_AREA_STUB
)
2721 vty_out (vty
, " (Stub%s%s)",
2722 area
->no_summary
? ", no summary" : "",
2723 area
->shortcut_configured
? "; " : "");
2724 else if (area
->external_routing
== OSPF_AREA_NSSA
)
2725 vty_out (vty
, " (NSSA%s%s)",
2726 area
->no_summary
? ", no summary" : "",
2727 area
->shortcut_configured
? "; " : "");
2729 vty_out (vty
, "%s", VTY_NEWLINE
);
2730 vty_out (vty
, " Shortcutting mode: %s",
2731 ospf_shortcut_mode_descr_str
[area
->shortcut_configured
]);
2732 vty_out (vty
, ", S-bit consensus: %s%s",
2733 area
->shortcut_capability
? "ok" : "no", VTY_NEWLINE
);
2737 /* Show number of interfaces */
2740 json_object_int_add(json_area
, "areaIfTotalCounter", listcount (area
->oiflist
));
2741 json_object_int_add(json_area
, "areaIfActiveCounter", area
->act_ints
);
2744 vty_out (vty
, " Number of interfaces in this area: Total: %d, "
2745 "Active: %d%s", listcount (area
->oiflist
),
2746 area
->act_ints
, VTY_NEWLINE
);
2748 if (area
->external_routing
== OSPF_AREA_NSSA
)
2752 json_object_boolean_true_add(json_area
, "nssa");
2753 if (! IS_OSPF_ABR (area
->ospf
))
2754 json_object_boolean_false_add(json_area
, "abr");
2755 else if (area
->NSSATranslatorState
)
2757 json_object_boolean_true_add(json_area
, "abr");
2758 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2759 json_object_boolean_true_add(json_area
, "nssaTranslatorElected");
2760 else if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_ALWAYS
)
2761 json_object_boolean_true_add(json_area
, "nssaTranslatorAlways");
2765 json_object_boolean_true_add(json_area
, "abr");
2766 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2767 json_object_boolean_false_add(json_area
, "nssaTranslatorElected");
2769 json_object_boolean_true_add(json_area
, "nssaTranslatorNever");
2774 vty_out (vty
, " It is an NSSA configuration. %s Elected NSSA/ABR performs type-7/type-5 LSA translation. %s", VTY_NEWLINE
, VTY_NEWLINE
);
2775 if (! IS_OSPF_ABR (area
->ospf
))
2776 vty_out (vty
, " It is not ABR, therefore not Translator. %s",
2778 else if (area
->NSSATranslatorState
)
2780 vty_out (vty
, " We are an ABR and ");
2781 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2782 vty_out (vty
, "the NSSA Elected Translator. %s",
2784 else if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_ALWAYS
)
2785 vty_out (vty
, "always an NSSA Translator. %s",
2790 vty_out (vty
, " We are an ABR, but ");
2791 if (area
->NSSATranslatorRole
== OSPF_NSSA_ROLE_CANDIDATE
)
2792 vty_out (vty
, "not the NSSA Elected Translator. %s",
2795 vty_out (vty
, "never an NSSA Translator. %s",
2801 /* Stub-router state for this area */
2802 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
2804 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2808 json_object_boolean_true_add(json_area
, "originStubMaxDistRouterLsa");
2809 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
2810 json_object_boolean_true_add(json_area
, "indefiniteActiveAdmin");
2811 if (area
->t_stub_router
)
2814 time_store
= monotime_until(&area
->t_stub_router
->u
.sands
, NULL
) / 1000LL;
2815 json_object_int_add(json_area
, "activeStartupRemainderMsecs", time_store
);
2820 vty_out (vty
, " Originating stub / maximum-distance Router-LSA%s",
2822 if (CHECK_FLAG(area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
2823 vty_out (vty
, " Administratively activated (indefinitely)%s",
2825 if (area
->t_stub_router
)
2826 vty_out (vty
, " Active from startup, %s remaining%s",
2827 ospf_timer_dump (area
->t_stub_router
, timebuf
,
2828 sizeof(timebuf
)), VTY_NEWLINE
);
2834 /* Show number of fully adjacent neighbors. */
2835 json_object_int_add(json_area
, "nbrFullAdjacentCounter", area
->full_nbrs
);
2837 /* Show authentication type. */
2838 if (area
->auth_type
== OSPF_AUTH_NULL
)
2839 json_object_string_add(json_area
, "authentication", "authenticationNone");
2840 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2841 json_object_string_add(json_area
, "authentication", "authenticationSimplePassword");
2842 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2843 json_object_string_add(json_area
, "authentication", "authenticationMessageDigest");
2845 if (!OSPF_IS_AREA_BACKBONE (area
))
2846 json_object_int_add(json_area
, "virtualAdjacenciesPassingCounter", area
->full_vls
);
2848 /* Show SPF calculation times. */
2849 json_object_int_add(json_area
, "spfExecutedCounter", area
->spf_calculation
);
2850 json_object_int_add(json_area
, "lsaNumber", area
->lsdb
->total
);
2851 json_object_int_add(json_area
, "lsaRouterNumber", ospf_lsdb_count (area
->lsdb
, OSPF_ROUTER_LSA
));
2852 json_object_int_add(json_area
, "lsaRouterChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_ROUTER_LSA
));
2853 json_object_int_add(json_area
, "lsaNetworkNumber", ospf_lsdb_count (area
->lsdb
, OSPF_NETWORK_LSA
));
2854 json_object_int_add(json_area
, "lsaNetworkChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_NETWORK_LSA
));
2855 json_object_int_add(json_area
, "lsaSummaryNumber", ospf_lsdb_count (area
->lsdb
, OSPF_SUMMARY_LSA
));
2856 json_object_int_add(json_area
, "lsaSummaryChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_SUMMARY_LSA
));
2857 json_object_int_add(json_area
, "lsaAsbrNumber", ospf_lsdb_count (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2858 json_object_int_add(json_area
, "lsaAsbrChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
));
2859 json_object_int_add(json_area
, "lsaNssaNumber", ospf_lsdb_count (area
->lsdb
, OSPF_AS_NSSA_LSA
));
2860 json_object_int_add(json_area
, "lsaNssaChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_AS_NSSA_LSA
));
2864 /* Show number of fully adjacent neighbors. */
2865 vty_out (vty
, " Number of fully adjacent neighbors in this area:"
2866 " %d%s", area
->full_nbrs
, VTY_NEWLINE
);
2868 /* Show authentication type. */
2869 vty_out (vty
, " Area has ");
2870 if (area
->auth_type
== OSPF_AUTH_NULL
)
2871 vty_out (vty
, "no authentication%s", VTY_NEWLINE
);
2872 else if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
2873 vty_out (vty
, "simple password authentication%s", VTY_NEWLINE
);
2874 else if (area
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
)
2875 vty_out (vty
, "message digest authentication%s", VTY_NEWLINE
);
2877 if (!OSPF_IS_AREA_BACKBONE (area
))
2878 vty_out (vty
, " Number of full virtual adjacencies going through"
2879 " this area: %d%s", area
->full_vls
, VTY_NEWLINE
);
2881 /* Show SPF calculation times. */
2882 vty_out (vty
, " SPF algorithm executed %d times%s",
2883 area
->spf_calculation
, VTY_NEWLINE
);
2885 /* Show number of LSA. */
2886 vty_out (vty
, " Number of LSA %ld%s", area
->lsdb
->total
, VTY_NEWLINE
);
2887 vty_out (vty
, " Number of router LSA %ld. Checksum Sum 0x%08x%s",
2888 ospf_lsdb_count (area
->lsdb
, OSPF_ROUTER_LSA
),
2889 ospf_lsdb_checksum (area
->lsdb
, OSPF_ROUTER_LSA
), VTY_NEWLINE
);
2890 vty_out (vty
, " Number of network LSA %ld. Checksum Sum 0x%08x%s",
2891 ospf_lsdb_count (area
->lsdb
, OSPF_NETWORK_LSA
),
2892 ospf_lsdb_checksum (area
->lsdb
, OSPF_NETWORK_LSA
), VTY_NEWLINE
);
2893 vty_out (vty
, " Number of summary LSA %ld. Checksum Sum 0x%08x%s",
2894 ospf_lsdb_count (area
->lsdb
, OSPF_SUMMARY_LSA
),
2895 ospf_lsdb_checksum (area
->lsdb
, OSPF_SUMMARY_LSA
), VTY_NEWLINE
);
2896 vty_out (vty
, " Number of ASBR summary LSA %ld. Checksum Sum 0x%08x%s",
2897 ospf_lsdb_count (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
),
2898 ospf_lsdb_checksum (area
->lsdb
, OSPF_ASBR_SUMMARY_LSA
), VTY_NEWLINE
);
2899 vty_out (vty
, " Number of NSSA LSA %ld. Checksum Sum 0x%08x%s",
2900 ospf_lsdb_count (area
->lsdb
, OSPF_AS_NSSA_LSA
),
2901 ospf_lsdb_checksum (area
->lsdb
, OSPF_AS_NSSA_LSA
), VTY_NEWLINE
);
2906 json_object_int_add(json_area
, "lsaOpaqueLinkNumber", ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2907 json_object_int_add(json_area
, "lsaOpaqueLinkChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
));
2908 json_object_int_add(json_area
, "lsaOpaqueAreaNumber", ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2909 json_object_int_add(json_area
, "lsaOpaqueAreaChecksum", ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
));
2913 vty_out (vty
, " Number of opaque link LSA %ld. Checksum Sum 0x%08x%s",
2914 ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
),
2915 ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_LINK_LSA
), VTY_NEWLINE
);
2916 vty_out (vty
, " Number of opaque area LSA %ld. Checksum Sum 0x%08x%s",
2917 ospf_lsdb_count (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
),
2918 ospf_lsdb_checksum (area
->lsdb
, OSPF_OPAQUE_AREA_LSA
), VTY_NEWLINE
);
2922 json_object_object_add(json_areas
, inet_ntoa (area
->area_id
), json_area
);
2924 vty_out (vty
, "%s", VTY_NEWLINE
);
2928 show_ip_ospf_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
2930 struct listnode
*node
, *nnode
;
2931 struct ospf_area
* area
;
2932 struct timeval result
;
2933 char timebuf
[OSPF_TIME_DUMP_SIZE
];
2934 json_object
*json
= NULL
;
2935 json_object
*json_areas
= NULL
;
2939 json
= json_object_new_object();
2940 json_areas
= json_object_new_object();
2947 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
2951 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
2952 VTY_NEWLINE
, VTY_NEWLINE
);
2956 /* Show Router ID. */
2959 json_object_string_add(json
, "routerId", inet_ntoa (ospf
->router_id
));
2963 vty_out (vty
, " OSPF Routing Process, Router ID: %s%s",
2964 inet_ntoa (ospf
->router_id
),
2968 /* Graceful shutdown */
2969 if (ospf
->t_deferred_shutdown
)
2974 time_store
= monotime_until(&ospf
->t_deferred_shutdown
->u
.sands
, NULL
) / 1000LL;
2975 json_object_int_add(json
, "deferredShutdownMsecs", time_store
);
2979 vty_out (vty
, " Deferred shutdown in progress, %s remaining%s",
2980 ospf_timer_dump (ospf
->t_deferred_shutdown
,
2981 timebuf
, sizeof (timebuf
)), VTY_NEWLINE
);
2985 /* Show capability. */
2988 json_object_boolean_true_add(json
, "tosRoutesOnly");
2989 json_object_boolean_true_add(json
, "rfc2328Conform");
2990 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
2992 json_object_boolean_true_add(json
, "rfc1583Compatibility");
2997 vty_out (vty
, " Supports only single TOS (TOS0) routes%s", VTY_NEWLINE
);
2998 vty_out (vty
, " This implementation conforms to RFC2328%s", VTY_NEWLINE
);
2999 vty_out (vty
, " RFC1583Compatibility flag is %s%s",
3000 CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
) ?
3001 "enabled" : "disabled", VTY_NEWLINE
);
3006 if (CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
))
3008 json_object_boolean_true_add(json
, "opaqueCapable");
3013 vty_out (vty
, " OpaqueCapability flag is %s%s",
3014 CHECK_FLAG (ospf
->config
, OSPF_OPAQUE_CAPABLE
) ? "enabled" : "disabled",
3018 /* Show stub-router configuration */
3019 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
3020 || ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3024 json_object_boolean_true_add(json
, "stubAdvertisement");
3025 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3026 json_object_int_add(json
,"postStartEnabledMsecs", ospf
->stub_router_startup_time
/ 1000);
3027 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3028 json_object_int_add(json
,"preShutdownEnabledMsecs", ospf
->stub_router_shutdown_time
/ 1000);
3032 vty_out (vty
, " Stub router advertisement is configured%s",
3034 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3035 vty_out (vty
, " Enabled for %us after start-up%s",
3036 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
3037 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
3038 vty_out (vty
, " Enabled for %us prior to full shutdown%s",
3039 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
3043 /* Show SPF timers. */
3046 json_object_int_add(json
, "spfScheduleDelayMsecs", ospf
->spf_delay
);
3047 json_object_int_add(json
, "holdtimeMinMsecs", ospf
->spf_holdtime
);
3048 json_object_int_add(json
, "holdtimeMaxMsecs", ospf
->spf_max_holdtime
);
3049 json_object_int_add(json
, "holdtimeMultplier", ospf
->spf_hold_multiplier
);
3053 vty_out (vty
, " Initial SPF scheduling delay %d millisec(s)%s"
3054 " Minimum hold time between consecutive SPFs %d millisec(s)%s"
3055 " Maximum hold time between consecutive SPFs %d millisec(s)%s"
3056 " Hold time multiplier is currently %d%s",
3057 ospf
->spf_delay
, VTY_NEWLINE
,
3058 ospf
->spf_holdtime
, VTY_NEWLINE
,
3059 ospf
->spf_max_holdtime
, VTY_NEWLINE
,
3060 ospf
->spf_hold_multiplier
, VTY_NEWLINE
);
3065 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3067 long time_store
= 0;
3069 time_store
= monotime_since(&ospf
->ts_spf
, NULL
) / 1000LL;
3070 json_object_int_add(json
, "spfLastExecutedMsecs", time_store
);
3072 time_store
= (1000 * ospf
->ts_spf_duration
.tv_sec
) + (ospf
->ts_spf_duration
.tv_usec
/ 1000);
3073 json_object_int_add(json
, "spfLastDurationMsecs", time_store
);
3076 json_object_boolean_true_add(json
, "spfHasNotRun");
3080 vty_out (vty
, " SPF algorithm ");
3081 if (ospf
->ts_spf
.tv_sec
|| ospf
->ts_spf
.tv_usec
)
3083 monotime_since(&ospf
->ts_spf
, &result
);
3084 vty_out (vty
, "last executed %s ago%s",
3085 ospf_timeval_dump (&result
, timebuf
, sizeof (timebuf
)),
3087 vty_out (vty
, " Last SPF duration %s%s",
3088 ospf_timeval_dump (&ospf
->ts_spf_duration
, timebuf
, sizeof (timebuf
)),
3092 vty_out (vty
, "has not been run%s", VTY_NEWLINE
);
3097 if (ospf
->t_spf_calc
)
3100 time_store
= monotime_until(&ospf
->t_spf_calc
->u
.sands
, NULL
) / 1000LL;
3101 json_object_int_add(json
, "spfTimerDueInMsecs", time_store
);
3104 json_object_int_add(json
, "lsaMinIntervalMsecs", ospf
->min_ls_interval
);
3105 json_object_int_add(json
, "lsaMinArrivalMsecs", ospf
->min_ls_arrival
);
3106 /* Show write multiplier values */
3107 json_object_int_add(json
, "writeMultiplier", ospf
->write_oi_count
);
3108 /* Show refresh parameters. */
3109 json_object_int_add(json
, "refreshTimerMsecs", ospf
->lsa_refresh_interval
* 1000);
3113 vty_out (vty
, " SPF timer %s%s%s",
3114 (ospf
->t_spf_calc
? "due in " : "is "),
3115 ospf_timer_dump (ospf
->t_spf_calc
, timebuf
, sizeof (timebuf
)),
3118 vty_out (vty
, " LSA minimum interval %d msecs%s",
3119 ospf
->min_ls_interval
, VTY_NEWLINE
);
3120 vty_out (vty
, " LSA minimum arrival %d msecs%s",
3121 ospf
->min_ls_arrival
, VTY_NEWLINE
);
3123 /* Show write multiplier values */
3124 vty_out (vty
, " Write Multiplier set to %d %s",
3125 ospf
->write_oi_count
, VTY_NEWLINE
);
3127 /* Show refresh parameters. */
3128 vty_out (vty
, " Refresh timer %d secs%s",
3129 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
3132 /* Show ABR/ASBR flags. */
3133 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ABR
))
3136 json_object_string_add(json
, "abrType", ospf_abr_type_descr_str
[ospf
->abr_type
]);
3138 vty_out (vty
, " This router is an ABR, ABR type is: %s%s",
3139 ospf_abr_type_descr_str
[ospf
->abr_type
], VTY_NEWLINE
);
3141 if (CHECK_FLAG (ospf
->flags
, OSPF_FLAG_ASBR
))
3144 json_object_string_add(json
, "asbrRouter", "injectingExternalRoutingInformation");
3146 vty_out (vty
, " This router is an ASBR "
3147 "(injecting external routing information)%s", VTY_NEWLINE
);
3150 /* Show Number of AS-external-LSAs. */
3153 json_object_int_add(json
, "lsaExternalCounter",
3154 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3155 json_object_int_add(json
, "lsaExternalChecksum",
3156 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
));
3160 vty_out (vty
, " Number of external LSA %ld. Checksum Sum 0x%08x%s",
3161 ospf_lsdb_count (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
),
3162 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_AS_EXTERNAL_LSA
), VTY_NEWLINE
);
3167 json_object_int_add(json
, "lsaAsopaqueCounter",
3168 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3169 json_object_int_add(json
, "lsaAsOpaqueChecksum",
3170 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
));
3174 vty_out (vty
, " Number of opaque AS LSA %ld. Checksum Sum 0x%08x%s",
3175 ospf_lsdb_count (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
),
3176 ospf_lsdb_checksum (ospf
->lsdb
, OSPF_OPAQUE_AS_LSA
), VTY_NEWLINE
);
3179 /* Show number of areas attached. */
3181 json_object_int_add(json
, "attachedAreaCounter", listcount (ospf
->areas
));
3183 vty_out (vty
, " Number of areas attached to this router: %d%s",
3184 listcount (ospf
->areas
), VTY_NEWLINE
);
3186 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
3188 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
3191 json_object_boolean_true_add(json
, "adjacencyChangesLoggedAll");
3193 vty_out(vty
, " All adjacency changes are logged%s",VTY_NEWLINE
);
3198 json_object_boolean_true_add(json
, "adjacencyChangesLogged");
3200 vty_out(vty
, " Adjacency changes are logged%s",VTY_NEWLINE
);
3203 /* Show each area status. */
3204 for (ALL_LIST_ELEMENTS (ospf
->areas
, node
, nnode
, area
))
3205 show_ip_ospf_area (vty
, area
, json_areas
, use_json
);
3209 json_object_object_add(json
, "areas", json_areas
);
3210 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3211 json_object_free(json
);
3214 vty_out (vty
, "%s",VTY_NEWLINE
);
3219 DEFUN (show_ip_ospf
,
3221 "show ip ospf [json]",
3224 "OSPF information\n"
3228 u_char uj
= use_json(argc
, argv
);
3230 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3233 return (show_ip_ospf_common(vty
, ospf
, uj
));
3236 DEFUN (show_ip_ospf_instance
,
3237 show_ip_ospf_instance_cmd
,
3238 "show ip ospf (1-65535) [json]",
3241 "OSPF information\n"
3247 u_short instance
= 0;
3248 u_char uj
= use_json(argc
, argv
);
3250 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3251 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3254 return (show_ip_ospf_common(vty
, ospf
, uj
));
3258 show_ip_ospf_interface_sub (struct vty
*vty
, struct ospf
*ospf
, struct interface
*ifp
,
3259 json_object
*json_interface_sub
, u_char use_json
)
3262 struct ospf_neighbor
*nbr
;
3263 struct route_node
*rn
;
3265 /* Is interface up? */
3268 is_up
= if_is_operative(ifp
);
3270 json_object_boolean_true_add(json_interface_sub
, "ifUp");
3272 json_object_boolean_false_add(json_interface_sub
, "ifDown");
3274 json_object_int_add(json_interface_sub
, "ifIndex", ifp
->ifindex
);
3275 json_object_int_add(json_interface_sub
, "mtuBytes", ifp
->mtu
);
3276 json_object_int_add(json_interface_sub
, "bandwidthMbit", ifp
->bandwidth
);
3277 json_object_string_add(json_interface_sub
, "ifFlags", if_flag_dump(ifp
->flags
));
3281 vty_out (vty
, "%s is %s%s", ifp
->name
,
3282 ((is_up
= if_is_operative(ifp
)) ? "up" : "down"), VTY_NEWLINE
);
3283 vty_out (vty
, " ifindex %u, MTU %u bytes, BW %u Mbit %s%s",
3284 ifp
->ifindex
, ifp
->mtu
, ifp
->bandwidth
, if_flag_dump(ifp
->flags
),
3288 /* Is interface OSPF enabled? */
3291 if (ospf_oi_count(ifp
) == 0)
3293 json_object_boolean_false_add(json_interface_sub
, "ospfEnabled");
3298 json_object_boolean_false_add(json_interface_sub
, "ospfRunning");
3302 json_object_boolean_true_add(json_interface_sub
, "ospfEnabled");
3306 if (ospf_oi_count(ifp
) == 0)
3308 vty_out (vty
, " OSPF not enabled on this interface%s", VTY_NEWLINE
);
3313 vty_out (vty
, " OSPF is enabled, but not running on this interface%s",
3319 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
3321 struct ospf_interface
*oi
= rn
->info
;
3326 if (CHECK_FLAG(oi
->connected
->flags
, ZEBRA_IFA_UNNUMBERED
))
3329 json_object_boolean_true_add(json_interface_sub
, "ifUnnumbered");
3331 vty_out (vty
, " This interface is UNNUMBERED,");
3335 /* Show OSPF interface information. */
3338 json_object_string_add(json_interface_sub
, "ipAddress", inet_ntoa (oi
->address
->u
.prefix4
));
3339 json_object_int_add(json_interface_sub
, "ipAddressPrefixlen", oi
->address
->prefixlen
);
3342 vty_out (vty
, " Internet Address %s/%d,",
3343 inet_ntoa (oi
->address
->u
.prefix4
), oi
->address
->prefixlen
);
3345 if (oi
->connected
->destination
|| oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3347 struct in_addr
*dest
;
3350 if (CONNECTED_PEER(oi
->connected
)
3351 || oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3356 /* For Vlinks, showing the peer address is probably more
3357 * * * * * informative than the local interface that is being used
3359 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3360 dest
= &oi
->vl_data
->peer_addr
;
3362 dest
= &oi
->connected
->destination
->u
.prefix4
;
3366 json_object_string_add(json_interface_sub
, "ospfIfType", dstr
);
3367 if (oi
->type
== OSPF_IFTYPE_VIRTUALLINK
)
3368 json_object_string_add(json_interface_sub
, "vlinkPeer", inet_ntoa (*dest
));
3370 json_object_string_add(json_interface_sub
, "localIfUsed", inet_ntoa (*dest
));
3373 vty_out (vty
, " %s %s,", dstr
, inet_ntoa (*dest
));
3378 json_object_string_add(json_interface_sub
, "area", ospf_area_desc_string (oi
->area
));
3379 if (OSPF_IF_PARAM(oi
, mtu_ignore
))
3380 json_object_boolean_true_add(json_interface_sub
, "mtuMismatchDetect");
3381 json_object_string_add(json_interface_sub
, "routerId", inet_ntoa (ospf
->router_id
));
3382 json_object_string_add(json_interface_sub
, "networkType", ospf_network_type_str
[oi
->type
]);
3383 json_object_int_add(json_interface_sub
, "cost", oi
->output_cost
);
3384 json_object_int_add(json_interface_sub
, "transmitDelayMsecs", 1000 / OSPF_IF_PARAM (oi
,transmit_delay
));
3385 json_object_string_add(json_interface_sub
, "state", LOOKUP (ospf_ism_state_msg
, oi
->state
));
3386 json_object_int_add(json_interface_sub
, "priority", PRIORITY (oi
));
3390 vty_out (vty
, " Area %s%s", ospf_area_desc_string (oi
->area
),
3393 vty_out (vty
, " MTU mismatch detection:%s%s",
3394 OSPF_IF_PARAM(oi
, mtu_ignore
) ? "disabled" : "enabled", VTY_NEWLINE
);
3396 vty_out (vty
, " Router ID %s, Network Type %s, Cost: %d%s",
3397 inet_ntoa (ospf
->router_id
), ospf_network_type_str
[oi
->type
],
3398 oi
->output_cost
, VTY_NEWLINE
);
3400 vty_out (vty
, " Transmit Delay is %d sec, State %s, Priority %d%s",
3401 OSPF_IF_PARAM (oi
,transmit_delay
), LOOKUP (ospf_ism_state_msg
, oi
->state
),
3402 PRIORITY (oi
), VTY_NEWLINE
);
3405 /* Show DR information. */
3406 if (DR (oi
).s_addr
== 0)
3409 vty_out (vty
, " No backup designated router on this network%s",
3414 nbr
= ospf_nbr_lookup_by_addr (oi
->nbrs
, &BDR (oi
));
3418 vty_out (vty
, " No backup designated router on this network%s",
3425 json_object_string_add(json_interface_sub
, "bdrId", inet_ntoa (nbr
->router_id
));
3426 json_object_string_add(json_interface_sub
, "bdrAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
3430 vty_out (vty
, " Backup Designated Router (ID) %s,",
3431 inet_ntoa (nbr
->router_id
));
3432 vty_out (vty
, " Interface Address %s%s",
3433 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
3438 /* Next network-LSA sequence number we'll use, if we're elected DR */
3439 if (oi
->params
&& ntohl (oi
->params
->network_lsa_seqnum
) != OSPF_INITIAL_SEQUENCE_NUMBER
)
3442 json_object_int_add(json_interface_sub
, "networkLsaSequence", ntohl (oi
->params
->network_lsa_seqnum
));
3444 vty_out (vty
, " Saved Network-LSA sequence number 0x%x%s",
3445 ntohl (oi
->params
->network_lsa_seqnum
), VTY_NEWLINE
);
3450 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3451 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3453 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3454 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfAllRouters");
3455 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3456 json_object_boolean_true_add(json_interface_sub
, "mcastMemberOspfDesignatedRouters");
3461 vty_out (vty
, " Multicast group memberships:");
3462 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
)
3463 || OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3465 if (OI_MEMBER_CHECK(oi
, MEMBER_ALLROUTERS
))
3466 vty_out (vty
, " OSPFAllRouters");
3467 if (OI_MEMBER_CHECK(oi
, MEMBER_DROUTERS
))
3468 vty_out (vty
, " OSPFDesignatedRouters");
3471 vty_out (vty
, " <None>");
3472 vty_out (vty
, "%s", VTY_NEWLINE
);
3477 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3478 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 /OSPF_IF_PARAM (oi
, v_hello
));
3480 json_object_int_add(json_interface_sub
, "timerMsecs", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3481 json_object_int_add(json_interface_sub
, "timerDeadMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3482 json_object_int_add(json_interface_sub
, "timerWaitMsecs", 1000 / OSPF_IF_PARAM (oi
, v_wait
));
3483 json_object_int_add(json_interface_sub
, "timerRetransmit", 1000 / OSPF_IF_PARAM (oi
, retransmit_interval
));
3487 vty_out (vty
, " Timer intervals configured,");
3488 vty_out (vty
, " Hello ");
3489 if (OSPF_IF_PARAM (oi
, fast_hello
) == 0)
3490 vty_out (vty
, "%ds,", OSPF_IF_PARAM (oi
, v_hello
));
3492 vty_out (vty
, "%dms,", 1000 / OSPF_IF_PARAM (oi
, fast_hello
));
3493 vty_out (vty
, " Dead %ds, Wait %ds, Retransmit %d%s",
3494 OSPF_IF_PARAM (oi
, v_wait
),
3495 OSPF_IF_PARAM (oi
, v_wait
),
3496 OSPF_IF_PARAM (oi
, retransmit_interval
),
3500 if (OSPF_IF_PASSIVE_STATUS (oi
) == OSPF_IF_ACTIVE
)
3502 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3505 long time_store
= 0;
3507 time_store
= monotime_until(&oi
->t_hello
->u
.sands
, NULL
) / 1000LL;
3508 json_object_int_add(json_interface_sub
, "timerHelloInMsecs", time_store
);
3511 vty_out (vty
, " Hello due in %s%s",
3512 ospf_timer_dump (oi
->t_hello
, timebuf
, sizeof(timebuf
)),
3515 else /* passive-interface is set */
3518 json_object_boolean_true_add(json_interface_sub
, "timerPassiveIface");
3520 vty_out (vty
, " No Hellos (Passive interface)%s", VTY_NEWLINE
);
3525 json_object_int_add(json_interface_sub
, "nbrCount", ospf_nbr_count (oi
, 0));
3526 json_object_int_add(json_interface_sub
, "nbrAdjacentCount", ospf_nbr_count (oi
, NSM_Full
));
3529 vty_out (vty
, " Neighbor Count is %d, Adjacent neighbor count is %d%s",
3530 ospf_nbr_count (oi
, 0), ospf_nbr_count (oi
, NSM_Full
),
3532 ospf_bfd_interface_show(vty
, ifp
, json_interface_sub
, use_json
);
3537 show_ip_ospf_interface_common (struct vty
*vty
, struct ospf
*ospf
, int argc
,
3538 struct cmd_token
**argv
, int iface_argv
, u_char use_json
)
3540 struct interface
*ifp
;
3541 struct listnode
*node
;
3542 json_object
*json
= NULL
;
3543 json_object
*json_interface_sub
= NULL
;
3547 json
= json_object_new_object();
3548 json_interface_sub
= json_object_new_object();
3554 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3556 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3557 VTY_NEWLINE
, VTY_NEWLINE
);
3560 if (argc
== (iface_argv
+ 1))
3562 /* Show All Interfaces.*/
3563 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
3565 if (ospf_oi_count(ifp
))
3567 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3569 json_object_object_add (json
, ifp
->name
, json_interface_sub
);
3573 else if (argv
[iface_argv
] && strcmp(argv
[iface_argv
]->arg
, "json") == 0)
3577 json
= json_object_new_object();
3578 json_interface_sub
= json_object_new_object ();
3581 /* Show All Interfaces. */
3582 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
3584 if (ospf_oi_count(ifp
))
3586 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3588 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3594 /* Interface name is specified. */
3595 if ((ifp
= if_lookup_by_name (argv
[iface_argv
]->arg
)) == NULL
)
3598 json_object_boolean_true_add(json
, "noSuchIface");
3600 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
3604 show_ip_ospf_interface_sub (vty
, ospf
, ifp
, json_interface_sub
, use_json
);
3606 json_object_object_add(json
, ifp
->name
, json_interface_sub
);
3612 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3613 json_object_free(json
);
3616 vty_out (vty
, "%s", VTY_NEWLINE
);
3621 DEFUN (show_ip_ospf_interface
,
3622 show_ip_ospf_interface_cmd
,
3623 "show ip ospf interface [INTERFACE] [json]",
3626 "OSPF information\n"
3627 "Interface information\n"
3632 u_char uj
= use_json(argc
, argv
);
3634 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3637 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 0, uj
);
3640 DEFUN (show_ip_ospf_instance_interface
,
3641 show_ip_ospf_instance_interface_cmd
,
3642 "show ip ospf (1-65535) interface [INTERFACE] [json]",
3645 "OSPF information\n"
3647 "Interface information\n"
3653 u_short instance
= 0;
3654 u_char uj
= use_json(argc
, argv
);
3656 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3657 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
3660 return show_ip_ospf_interface_common(vty
, ospf
, argc
, argv
, 1, uj
);
3664 show_ip_ospf_neighbour_header (struct vty
*vty
)
3666 vty_out (vty
, "%s%-15s %3s %-15s %9s %-15s %-20s %5s %5s %5s%s",
3668 "Neighbor ID", "Pri", "State", "Dead Time",
3669 "Address", "Interface", "RXmtL", "RqstL", "DBsmL",
3674 show_ip_ospf_neighbor_sub (struct vty
*vty
, struct ospf_interface
*oi
, json_object
*json
, u_char use_json
)
3676 struct route_node
*rn
;
3677 struct ospf_neighbor
*nbr
;
3679 char timebuf
[OSPF_TIME_DUMP_SIZE
];
3680 json_object
*json_neighbor
= NULL
;
3682 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
3684 if ((nbr
= rn
->info
))
3686 /* Do not show myself. */
3687 if (nbr
!= oi
->nbr_self
)
3689 /* Down state is not shown. */
3690 if (nbr
->state
!= NSM_Down
)
3694 json_neighbor
= json_object_new_object();
3695 ospf_nbr_state_message (nbr
, msgbuf
, 16);
3699 time_store
= monotime_until(&nbr
->t_inactivity
->u
.sands
, NULL
) / 1000LL;
3701 json_object_int_add (json_neighbor
, "priority", nbr
->priority
);
3702 json_object_string_add (json_neighbor
, "state", msgbuf
);
3703 json_object_int_add (json_neighbor
, "deadTimeMsecs", time_store
);
3704 json_object_string_add (json_neighbor
, "address", inet_ntoa (nbr
->src
));
3705 json_object_string_add (json_neighbor
, "ifaceName", IF_NAME (oi
));
3706 json_object_int_add (json_neighbor
, "retransmitCounter", ospf_ls_retransmit_count (nbr
));
3707 json_object_int_add (json_neighbor
, "requestCounter", ospf_ls_request_count (nbr
));
3708 json_object_int_add (json_neighbor
, "dbSummaryCounter", ospf_db_summary_count (nbr
));
3709 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
3710 json_object_object_add(json
, "neighbor", json_neighbor
);
3712 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_neighbor
);
3716 ospf_nbr_state_message (nbr
, msgbuf
, 16);
3718 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
3719 vty_out (vty
, "%-15s %3d %-15s ",
3723 vty_out (vty
, "%-15s %3d %-15s ",
3724 inet_ntoa (nbr
->router_id
), nbr
->priority
,
3727 vty_out (vty
, "%9s ",
3728 ospf_timer_dump (nbr
->t_inactivity
, timebuf
,
3730 vty_out (vty
, "%-15s ", inet_ntoa (nbr
->src
));
3731 vty_out (vty
, "%-20s %5ld %5ld %5d%s",
3732 IF_NAME (oi
), ospf_ls_retransmit_count (nbr
),
3733 ospf_ls_request_count (nbr
), ospf_db_summary_count (nbr
),
3743 show_ip_ospf_neighbor_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3745 struct ospf_interface
*oi
;
3746 struct listnode
*node
;
3747 json_object
*json
= NULL
;
3750 json
= json_object_new_object();
3752 show_ip_ospf_neighbour_header (vty
);
3757 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3759 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3760 VTY_NEWLINE
, VTY_NEWLINE
);
3763 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
3764 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3768 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3769 json_object_free(json
);
3772 vty_out (vty
, "%s", VTY_NEWLINE
);
3777 DEFUN (show_ip_ospf_neighbor
,
3778 show_ip_ospf_neighbor_cmd
,
3779 "show ip ospf neighbor [json]",
3782 "OSPF information\n"
3787 u_char uj
= use_json(argc
, argv
);
3789 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3792 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3796 DEFUN (show_ip_ospf_instance_neighbor
,
3797 show_ip_ospf_instance_neighbor_cmd
,
3798 "show ip ospf (1-65535) neighbor [json]",
3801 "OSPF information\n"
3808 u_short instance
= 0;
3809 u_char uj
= use_json(argc
, argv
);
3811 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3812 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
3815 return show_ip_ospf_neighbor_common(vty
, ospf
, uj
);
3819 show_ip_ospf_neighbor_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
3821 struct listnode
*node
;
3822 struct ospf_interface
*oi
;
3823 json_object
*json
= NULL
;
3824 json_object
*json_neighbor_sub
= NULL
;
3828 json
= json_object_new_object();
3829 json_neighbor_sub
= json_object_new_object();
3832 show_ip_ospf_neighbour_header (vty
);
3837 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3839 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3840 VTY_NEWLINE
, VTY_NEWLINE
);
3843 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
3845 struct listnode
*nbr_node
;
3846 struct ospf_nbr_nbma
*nbr_nbma
;
3848 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3850 /* print Down neighbor status */
3851 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nbr_node
, nbr_nbma
))
3853 if (nbr_nbma
->nbr
== NULL
3854 || nbr_nbma
->nbr
->state
== NSM_Down
)
3858 json_object_int_add (json_neighbor_sub
, "nbrNbmaPriority", nbr_nbma
->priority
);
3859 json_object_boolean_true_add (json_neighbor_sub
, "nbrNbmaDown");
3860 json_object_string_add (json_neighbor_sub
, "nbrNbmaIfaceName", IF_NAME (oi
));
3861 json_object_int_add (json_neighbor_sub
, "nbrNbmaRetransmitCounter", 0);
3862 json_object_int_add (json_neighbor_sub
, "nbrNbmaRequestCounter", 0);
3863 json_object_int_add (json_neighbor_sub
, "nbrNbmaDbSummaryCounter", 0);
3864 json_object_object_add(json
, inet_ntoa (nbr_nbma
->addr
), json_neighbor_sub
);
3868 vty_out (vty
, "%-15s %3d %-15s %9s ",
3869 "-", nbr_nbma
->priority
, "Down", "-");
3870 vty_out (vty
, "%-15s %-20s %5d %5d %5d%s",
3871 inet_ntoa (nbr_nbma
->addr
), IF_NAME (oi
),
3872 0, 0, 0, VTY_NEWLINE
);
3880 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3881 json_object_free(json
);
3884 vty_out (vty
, "%s", VTY_NEWLINE
);
3889 DEFUN (show_ip_ospf_neighbor_all
,
3890 show_ip_ospf_neighbor_all_cmd
,
3891 "show ip ospf neighbor all [json]",
3894 "OSPF information\n"
3896 "include down status neighbor\n"
3900 u_char uj
= use_json(argc
, argv
);
3902 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
3905 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
3908 DEFUN (show_ip_ospf_instance_neighbor_all
,
3909 show_ip_ospf_instance_neighbor_all_cmd
,
3910 "show ip ospf (1-65535) neighbor all [json]",
3913 "OSPF information\n"
3916 "include down status neighbor\n"
3921 u_short instance
= 0;
3922 u_char uj
= use_json(argc
, argv
);
3924 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
3925 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
3928 return show_ip_ospf_neighbor_all_common(vty
, ospf
, uj
);
3932 show_ip_ospf_neighbor_int_common (struct vty
*vty
, struct ospf
*ospf
, int arg_base
,
3933 struct cmd_token
**argv
, u_char use_json
)
3935 struct interface
*ifp
;
3936 struct route_node
*rn
;
3937 json_object
*json
= NULL
;
3940 json
= json_object_new_object();
3942 show_ip_ospf_neighbour_header (vty
);
3947 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
3949 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
3950 VTY_NEWLINE
, VTY_NEWLINE
);
3953 ifp
= if_lookup_by_name (argv
[arg_base
]->arg
);
3957 json_object_boolean_true_add(json
, "noSuchIface");
3959 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
3963 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
3965 struct ospf_interface
*oi
= rn
->info
;
3970 show_ip_ospf_neighbor_sub (vty
, oi
, json
, use_json
);
3975 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
3976 json_object_free(json
);
3979 vty_out (vty
, "%s", VTY_NEWLINE
);
3984 DEFUN (show_ip_ospf_neighbor_int
,
3985 show_ip_ospf_neighbor_int_cmd
,
3986 "show ip ospf neighbor IFNAME [json]",
3989 "OSPF information\n"
3995 u_char uj
= use_json(argc
, argv
);
3997 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4000 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 0, argv
, uj
);
4003 DEFUN (show_ip_ospf_instance_neighbor_int
,
4004 show_ip_ospf_instance_neighbor_int_cmd
,
4005 "show ip ospf (1-65535) neighbor IFNAME [json]",
4008 "OSPF information\n"
4016 u_short instance
= 0;
4017 u_char uj
= use_json(argc
, argv
);
4019 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4020 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4023 return show_ip_ospf_neighbor_int_common(vty
, ospf
, 1, argv
, uj
);
4027 show_ip_ospf_nbr_nbma_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
, struct ospf_nbr_nbma
*nbr_nbma
,
4028 u_char use_json
, json_object
*json
)
4030 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4031 json_object
*json_sub
= NULL
;
4034 json_sub
= json_object_new_object();
4035 else /* Show neighbor ID. */
4036 vty_out (vty
, " Neighbor %s,", "-");
4038 /* Show interface address. */
4040 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr_nbma
->addr
));
4042 vty_out (vty
, " interface address %s%s",
4043 inet_ntoa (nbr_nbma
->addr
), VTY_NEWLINE
);
4048 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4049 json_object_string_add(json_sub
, "iface", IF_NAME (oi
));
4052 vty_out (vty
, " In the area %s via interface %s%s",
4053 ospf_area_desc_string (oi
->area
), IF_NAME (oi
), VTY_NEWLINE
);
4055 /* Show neighbor priority and state. */
4058 json_object_int_add(json_sub
, "nbrPriority", nbr_nbma
->priority
);
4059 json_object_string_add(json_sub
, "nbrState", "down");
4062 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4063 nbr_nbma
->priority
, "Down");
4065 /* Show state changes. */
4067 json_object_int_add(json_sub
, "stateChangeCounter", nbr_nbma
->state_change
);
4069 vty_out (vty
, " %d state changes%s", nbr_nbma
->state_change
, VTY_NEWLINE
);
4071 /* Show PollInterval */
4073 json_object_int_add(json_sub
, "pollInterval", nbr_nbma
->v_poll
);
4075 vty_out (vty
, " Poll interval %d%s", nbr_nbma
->v_poll
, VTY_NEWLINE
);
4077 /* Show poll-interval timer. */
4081 time_store
= monotime_until(&nbr_nbma
->t_poll
->u
.sands
, NULL
) / 1000LL;
4082 json_object_int_add(json_sub
, "pollIntervalTimerDueMsec", time_store
);
4085 vty_out (vty
, " Poll timer due in %s%s",
4086 ospf_timer_dump (nbr_nbma
->t_poll
, timebuf
, sizeof(timebuf
)),
4089 /* Show poll-interval timer thread. */
4092 if (nbr_nbma
->t_poll
!= NULL
)
4093 json_object_string_add(json_sub
, "pollIntervalTimerThread", "on");
4096 vty_out (vty
, " Thread Poll Timer %s%s",
4097 nbr_nbma
->t_poll
!= NULL
? "on" : "off", VTY_NEWLINE
);
4100 json_object_object_add(json
, "noNbrId", json_sub
);
4104 show_ip_ospf_neighbor_detail_sub (struct vty
*vty
, struct ospf_interface
*oi
,
4105 struct ospf_neighbor
*nbr
, u_char use_json
, json_object
*json
)
4107 char timebuf
[OSPF_TIME_DUMP_SIZE
];
4108 json_object
*json_sub
= NULL
;
4111 json_sub
= json_object_new_object();
4114 /* Show neighbor ID. */
4115 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4116 vty_out (vty
, " Neighbor %s,", "-");
4118 vty_out (vty
, " Neighbor %s,", inet_ntoa (nbr
->router_id
));
4121 /* Show interface address. */
4123 json_object_string_add(json_sub
, "ifaceAddress", inet_ntoa (nbr
->address
.u
.prefix4
));
4125 vty_out (vty
, " interface address %s%s",
4126 inet_ntoa (nbr
->address
.u
.prefix4
), VTY_NEWLINE
);
4131 json_object_string_add(json_sub
, "areaId", ospf_area_desc_string (oi
->area
));
4132 json_object_string_add(json_sub
, "ifaceName", oi
->ifp
->name
);
4135 vty_out (vty
, " In the area %s via interface %s%s",
4136 ospf_area_desc_string (oi
->area
), oi
->ifp
->name
, VTY_NEWLINE
);
4138 /* Show neighbor priority and state. */
4141 json_object_int_add(json_sub
, "nbrPriority", nbr
->priority
);
4142 json_object_string_add(json_sub
, "nbrState", LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4145 vty_out (vty
, " Neighbor priority is %d, State is %s,",
4146 nbr
->priority
, LOOKUP (ospf_nsm_state_msg
, nbr
->state
));
4148 /* Show state changes. */
4150 json_object_int_add(json_sub
, "stateChangeCounter", nbr
->state_change
);
4152 vty_out (vty
, " %d state changes%s", nbr
->state_change
, VTY_NEWLINE
);
4154 if (nbr
->ts_last_progress
.tv_sec
|| nbr
->ts_last_progress
.tv_usec
)
4159 time_store
= monotime_since(&nbr
->ts_last_progress
, &res
) / 1000LL;
4162 json_object_int_add(json_sub
, "lastPrgrsvChangeMsec", time_store
);
4166 vty_out (vty
, " Most recent state change statistics:%s",
4168 vty_out (vty
, " Progressive change %s ago%s",
4169 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4174 if (nbr
->ts_last_regress
.tv_sec
|| nbr
->ts_last_regress
.tv_usec
)
4179 time_store
= monotime_since(&nbr
->ts_last_regress
, &res
) / 1000LL;
4182 json_object_int_add(json_sub
, "lastRegressiveChangeMsec", time_store
);
4183 if (nbr
->last_regress_str
)
4184 json_object_string_add(json_sub
, "lastRegressiveChangeReason", nbr
->last_regress_str
);
4188 vty_out (vty
, " Regressive change %s ago, due to %s%s",
4189 ospf_timeval_dump (&res
, timebuf
, sizeof(timebuf
)),
4190 (nbr
->last_regress_str
? nbr
->last_regress_str
: "??"),
4195 /* Show Designated Rotuer ID. */
4197 json_object_string_add(json_sub
, "routerDesignatedId", inet_ntoa (nbr
->d_router
));
4199 vty_out (vty
, " DR is %s,", inet_ntoa (nbr
->d_router
));
4201 /* Show Backup Designated Rotuer ID. */
4203 json_object_string_add(json_sub
, "routerDesignatedBackupId", inet_ntoa (nbr
->bd_router
));
4205 vty_out (vty
, " BDR is %s%s", inet_ntoa (nbr
->bd_router
), VTY_NEWLINE
);
4210 json_object_int_add(json_sub
, "optionsCounter", nbr
->options
);
4211 json_object_string_add(json_sub
, "optionsList", ospf_options_dump (nbr
->options
));
4214 vty_out (vty
, " Options %d %s%s", nbr
->options
,
4215 ospf_options_dump (nbr
->options
), VTY_NEWLINE
);
4217 /* Show Router Dead interval timer. */
4220 if (nbr
->t_inactivity
)
4223 time_store
= monotime_until(&nbr
->t_inactivity
->u
.sands
, NULL
) / 1000LL;
4224 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", time_store
);
4227 json_object_int_add(json_sub
, "routerDeadIntervalTimerDueMsec", -1);
4230 vty_out (vty
, " Dead timer due in %s%s",
4231 ospf_timer_dump (nbr
->t_inactivity
, timebuf
, sizeof (timebuf
)),
4234 /* Show Database Summary list. */
4236 json_object_int_add(json_sub
, "databaseSummaryListCounter", ospf_db_summary_count (nbr
));
4238 vty_out (vty
, " Database Summary List %d%s",
4239 ospf_db_summary_count (nbr
), VTY_NEWLINE
);
4241 /* Show Link State Request list. */
4243 json_object_int_add(json_sub
, "linkStateRequestListCounter", ospf_ls_request_count (nbr
));
4245 vty_out (vty
, " Link State Request List %ld%s",
4246 ospf_ls_request_count (nbr
), VTY_NEWLINE
);
4248 /* Show Link State Retransmission list. */
4250 json_object_int_add(json_sub
, "linkStateRetransmissionListCounter", ospf_ls_retransmit_count (nbr
));
4252 vty_out (vty
, " Link State Retransmission List %ld%s",
4253 ospf_ls_retransmit_count (nbr
), VTY_NEWLINE
);
4255 /* Show inactivity timer thread. */
4258 if (nbr
->t_inactivity
!= NULL
)
4259 json_object_string_add(json_sub
, "threadInactivityTimer", "on");
4262 vty_out (vty
, " Thread Inactivity Timer %s%s",
4263 nbr
->t_inactivity
!= NULL
? "on" : "off", VTY_NEWLINE
);
4265 /* Show Database Description retransmission thread. */
4268 if (nbr
->t_db_desc
!= NULL
)
4269 json_object_string_add(json_sub
, "threadDatabaseDescriptionRetransmission", "on");
4272 vty_out (vty
, " Thread Database Description Retransmision %s%s",
4273 nbr
->t_db_desc
!= NULL
? "on" : "off", VTY_NEWLINE
);
4275 /* Show Link State Request Retransmission thread. */
4278 if (nbr
->t_ls_req
!= NULL
)
4279 json_object_string_add(json_sub
, "threadLinkStateRequestRetransmission", "on");
4282 vty_out (vty
, " Thread Link State Request Retransmission %s%s",
4283 nbr
->t_ls_req
!= NULL
? "on" : "off", VTY_NEWLINE
);
4285 /* Show Link State Update Retransmission thread. */
4288 if (nbr
->t_ls_upd
!= NULL
)
4289 json_object_string_add(json_sub
, "threadLinkStateUpdateRetransmission", "on");
4292 vty_out (vty
, " Thread Link State Update Retransmission %s%s%s",
4293 nbr
->t_ls_upd
!= NULL
? "on" : "off", VTY_NEWLINE
, VTY_NEWLINE
);
4297 if (nbr
->state
== NSM_Attempt
&& nbr
->router_id
.s_addr
== 0)
4298 json_object_object_add(json
, "noNbrId", json_sub
);
4300 json_object_object_add(json
, inet_ntoa (nbr
->router_id
), json_sub
);
4303 ospf_bfd_show_info(vty
, nbr
->bfd_info
, json
, use_json
, 0);
4307 show_ip_ospf_neighbor_id_common (struct vty
*vty
, struct ospf
*ospf
,
4308 int arg_base
, struct cmd_token
**argv
, u_char use_json
)
4310 struct listnode
*node
;
4311 struct ospf_neighbor
*nbr
;
4312 struct ospf_interface
*oi
;
4313 struct in_addr router_id
;
4315 json_object
*json
= NULL
;
4318 json
= json_object_new_object();
4323 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4325 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4326 VTY_NEWLINE
, VTY_NEWLINE
);
4329 ret
= inet_aton (argv
[arg_base
]->arg
, &router_id
);
4333 vty_out (vty
, "Please specify Neighbor ID by A.B.C.D%s", VTY_NEWLINE
);
4337 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4339 if ((nbr
= ospf_nbr_lookup_by_routerid (oi
->nbrs
, &router_id
)))
4341 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4347 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4348 json_object_free(json
);
4351 vty_out (vty
, "%s", VTY_NEWLINE
);
4356 DEFUN (show_ip_ospf_neighbor_id
,
4357 show_ip_ospf_neighbor_id_cmd
,
4358 "show ip ospf neighbor A.B.C.D [json]",
4361 "OSPF information\n"
4367 u_char uj
= use_json(argc
, argv
);
4369 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4372 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 0, argv
, uj
);
4375 DEFUN (show_ip_ospf_instance_neighbor_id
,
4376 show_ip_ospf_instance_neighbor_id_cmd
,
4377 "show ip ospf (1-65535) neighbor A.B.C.D [json]",
4380 "OSPF information\n"
4388 u_short instance
= 0;
4389 u_char uj
= use_json(argc
, argv
);
4391 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4392 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4395 return show_ip_ospf_neighbor_id_common(vty
, ospf
, 1, argv
, uj
);
4399 show_ip_ospf_neighbor_detail_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4401 struct ospf_interface
*oi
;
4402 struct listnode
*node
;
4403 json_object
*json
= NULL
;
4406 json
= json_object_new_object();
4411 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4413 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4414 VTY_NEWLINE
, VTY_NEWLINE
);
4417 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4419 struct route_node
*rn
;
4420 struct ospf_neighbor
*nbr
;
4422 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4424 if ((nbr
= rn
->info
))
4426 if (nbr
!= oi
->nbr_self
)
4428 if (nbr
->state
!= NSM_Down
)
4430 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4439 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4440 json_object_free(json
);
4443 vty_out (vty
, "%s", VTY_NEWLINE
);
4448 DEFUN (show_ip_ospf_neighbor_detail
,
4449 show_ip_ospf_neighbor_detail_cmd
,
4450 "show ip ospf neighbor detail [json]",
4453 "OSPF information\n"
4455 "detail of all neighbors\n"
4459 u_char uj
= use_json(argc
, argv
);
4461 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4464 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4467 DEFUN (show_ip_ospf_instance_neighbor_detail
,
4468 show_ip_ospf_instance_neighbor_detail_cmd
,
4469 "show ip ospf (1-65535) neighbor detail [json]",
4472 "OSPF information\n"
4475 "detail of all neighbors\n"
4480 u_short instance
= 0;
4481 u_char uj
= use_json(argc
, argv
);
4483 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4484 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
4487 return show_ip_ospf_neighbor_detail_common(vty
, ospf
, uj
);
4491 show_ip_ospf_neighbor_detail_all_common (struct vty
*vty
, struct ospf
*ospf
, u_char use_json
)
4493 struct listnode
*node
;
4494 struct ospf_interface
*oi
;
4495 json_object
*json
= NULL
;
4498 json
= json_object_new_object();
4503 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4505 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4506 VTY_NEWLINE
, VTY_NEWLINE
);
4509 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
4511 struct route_node
*rn
;
4512 struct ospf_neighbor
*nbr
;
4513 struct ospf_nbr_nbma
*nbr_nbma
;
4515 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
4516 if ((nbr
= rn
->info
))
4517 if (nbr
!= oi
->nbr_self
)
4518 if (nbr
->state
!= NSM_Down
)
4519 show_ip_ospf_neighbor_detail_sub (vty
, oi
, rn
->info
, use_json
, json
);
4521 if (oi
->type
== OSPF_IFTYPE_NBMA
)
4523 struct listnode
*nd
;
4525 for (ALL_LIST_ELEMENTS_RO (oi
->nbr_nbma
, nd
, nbr_nbma
))
4527 if (nbr_nbma
->nbr
== NULL
|| nbr_nbma
->nbr
->state
== NSM_Down
)
4528 show_ip_ospf_nbr_nbma_detail_sub (vty
, oi
, nbr_nbma
, use_json
, json
);
4535 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4536 json_object_free(json
);
4540 vty_out (vty
, "%s", VTY_NEWLINE
);
4546 DEFUN (show_ip_ospf_neighbor_detail_all
,
4547 show_ip_ospf_neighbor_detail_all_cmd
,
4548 "show ip ospf neighbor detail all [json]",
4551 "OSPF information\n"
4553 "detail of all neighbors\n"
4554 "include down status neighbor\n"
4558 u_char uj
= use_json(argc
, argv
);
4560 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4563 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4566 DEFUN (show_ip_ospf_instance_neighbor_detail_all
,
4567 show_ip_ospf_instance_neighbor_detail_all_cmd
,
4568 "show ip ospf (1-65535) neighbor detail all [json]",
4571 "OSPF information\n"
4574 "detail of all neighbors\n"
4575 "include down status neighbor\n"
4580 u_short instance
= 0;
4581 u_char uj
= use_json(argc
, argv
);
4583 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4584 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4587 return show_ip_ospf_neighbor_detail_all_common(vty
, ospf
, uj
);
4591 show_ip_ospf_neighbor_int_detail_common (struct vty
*vty
, struct ospf
*ospf
,
4592 int arg_base
, struct cmd_token
**argv
, u_char use_json
)
4594 struct ospf_interface
*oi
;
4595 struct interface
*ifp
;
4596 struct route_node
*rn
, *nrn
;
4597 struct ospf_neighbor
*nbr
;
4598 json_object
*json
= NULL
;
4601 json
= json_object_new_object();
4606 json_object_int_add(json
, "ospfInstance", ospf
->instance
);
4608 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
4609 VTY_NEWLINE
, VTY_NEWLINE
);
4612 ifp
= if_lookup_by_name (argv
[arg_base
]->arg
);
4616 vty_out (vty
, "No such interface.%s", VTY_NEWLINE
);
4620 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
4622 if ((oi
= rn
->info
))
4624 for (nrn
= route_top (oi
->nbrs
); nrn
; nrn
= route_next (nrn
))
4626 if ((nbr
= nrn
->info
))
4628 if (nbr
!= oi
->nbr_self
)
4630 if (nbr
->state
!= NSM_Down
)
4631 show_ip_ospf_neighbor_detail_sub (vty
, oi
, nbr
, use_json
, json
);
4640 vty_out (vty
, "%s%s", json_object_to_json_string_ext(json
, JSON_C_TO_STRING_PRETTY
), VTY_NEWLINE
);
4641 json_object_free(json
);
4644 vty_out (vty
, "%s", VTY_NEWLINE
);
4649 DEFUN (show_ip_ospf_neighbor_int_detail
,
4650 show_ip_ospf_neighbor_int_detail_cmd
,
4651 "show ip ospf neighbor IFNAME detail [json]",
4654 "OSPF information\n"
4657 "detail of all neighbors\n"
4661 u_char uj
= use_json(argc
, argv
);
4663 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
4666 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 0, argv
, uj
);
4669 DEFUN (show_ip_ospf_instance_neighbor_int_detail
,
4670 show_ip_ospf_instance_neighbor_int_detail_cmd
,
4671 "show ip ospf (1-65535) neighbor IFNAME detail [json]",
4674 "OSPF information\n"
4678 "detail of all neighbors\n"
4683 u_short instance
= 0;
4684 u_char uj
= use_json(argc
, argv
);
4686 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
4687 if ((ospf
= ospf_lookup_instance(instance
)) == NULL
|| !ospf
->oi_running
)
4690 return show_ip_ospf_neighbor_int_detail_common(vty
, ospf
, 1, argv
, uj
);
4693 /* Show functions */
4695 show_lsa_summary (struct vty
*vty
, struct ospf_lsa
*lsa
, int self
)
4697 struct router_lsa
*rl
;
4698 struct summary_lsa
*sl
;
4699 struct as_external_lsa
*asel
;
4700 struct prefix_ipv4 p
;
4703 /* If self option is set, check LSA self flag. */
4704 if (self
== 0 || IS_LSA_SELF (lsa
))
4706 /* LSA common part show. */
4707 vty_out (vty
, "%-15s ", inet_ntoa (lsa
->data
->id
));
4708 vty_out (vty
, "%-15s %4d 0x%08lx 0x%04x",
4709 inet_ntoa (lsa
->data
->adv_router
), LS_AGE (lsa
),
4710 (u_long
)ntohl (lsa
->data
->ls_seqnum
), ntohs (lsa
->data
->checksum
));
4711 /* LSA specific part show. */
4712 switch (lsa
->data
->type
)
4714 case OSPF_ROUTER_LSA
:
4715 rl
= (struct router_lsa
*) lsa
->data
;
4716 vty_out (vty
, " %-d", ntohs (rl
->links
));
4718 case OSPF_SUMMARY_LSA
:
4719 sl
= (struct summary_lsa
*) lsa
->data
;
4722 p
.prefix
= sl
->header
.id
;
4723 p
.prefixlen
= ip_masklen (sl
->mask
);
4724 apply_mask_ipv4 (&p
);
4726 vty_out (vty
, " %s/%d", inet_ntoa (p
.prefix
), p
.prefixlen
);
4728 case OSPF_AS_EXTERNAL_LSA
:
4729 case OSPF_AS_NSSA_LSA
:
4730 asel
= (struct as_external_lsa
*) lsa
->data
;
4733 p
.prefix
= asel
->header
.id
;
4734 p
.prefixlen
= ip_masklen (asel
->mask
);
4735 apply_mask_ipv4 (&p
);
4737 vty_out (vty
, " %s %s/%d [0x%lx]",
4738 IS_EXTERNAL_METRIC (asel
->e
[0].tos
) ? "E2" : "E1",
4739 inet_ntoa (p
.prefix
), p
.prefixlen
,
4740 (u_long
)ntohl (asel
->e
[0].route_tag
));
4742 case OSPF_NETWORK_LSA
:
4743 case OSPF_ASBR_SUMMARY_LSA
:
4744 case OSPF_OPAQUE_LINK_LSA
:
4745 case OSPF_OPAQUE_AREA_LSA
:
4746 case OSPF_OPAQUE_AS_LSA
:
4750 vty_out (vty
, VTY_NEWLINE
);
4756 static const char *show_database_desc
[] =
4759 "Router Link States",
4761 "Summary Link States",
4762 "ASBR-Summary Link States",
4763 "AS External Link States",
4764 "Group Membership LSA",
4765 "NSSA-external Link States",
4767 "Link-Local Opaque-LSA",
4768 "Area-Local Opaque-LSA",
4769 "AS-external Opaque-LSA",
4772 static const char *show_database_header
[] =
4775 "Link ID ADV Router Age Seq# CkSum Link count",
4776 "Link ID ADV Router Age Seq# CkSum",
4777 "Link ID ADV Router Age Seq# CkSum Route",
4778 "Link ID ADV Router Age Seq# CkSum",
4779 "Link ID ADV Router Age Seq# CkSum Route",
4780 " --- header for Group Member ----",
4781 "Link ID ADV Router Age Seq# CkSum Route",
4783 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4784 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4785 "Opaque-Type/Id ADV Router Age Seq# CkSum",
4789 show_ip_ospf_database_header (struct vty
*vty
, struct ospf_lsa
*lsa
)
4791 struct router_lsa
*rlsa
= (struct router_lsa
*) lsa
->data
;
4793 vty_out (vty
, " LS age: %d%s", LS_AGE (lsa
), VTY_NEWLINE
);
4794 vty_out (vty
, " Options: 0x%-2x : %s%s",
4796 ospf_options_dump(lsa
->data
->options
),
4798 vty_out (vty
, " LS Flags: 0x%-2x %s%s",
4800 ((lsa
->flags
& OSPF_LSA_LOCAL_XLT
) ? "(Translated from Type-7)" : ""),
4803 if (lsa
->data
->type
== OSPF_ROUTER_LSA
)
4805 vty_out (vty
, " Flags: 0x%x" , rlsa
->flags
);
4808 vty_out (vty
, " :%s%s%s%s",
4809 IS_ROUTER_LSA_BORDER (rlsa
) ? " ABR" : "",
4810 IS_ROUTER_LSA_EXTERNAL (rlsa
) ? " ASBR" : "",
4811 IS_ROUTER_LSA_VIRTUAL (rlsa
) ? " VL-endpoint" : "",
4812 IS_ROUTER_LSA_SHORTCUT (rlsa
) ? " Shortcut" : "");
4814 vty_out (vty
, "%s", VTY_NEWLINE
);
4816 vty_out (vty
, " LS Type: %s%s",
4817 LOOKUP (ospf_lsa_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
4818 vty_out (vty
, " Link State ID: %s %s%s", inet_ntoa (lsa
->data
->id
),
4819 LOOKUP (ospf_link_state_id_type_msg
, lsa
->data
->type
), VTY_NEWLINE
);
4820 vty_out (vty
, " Advertising Router: %s%s",
4821 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
4822 vty_out (vty
, " LS Seq Number: %08lx%s", (u_long
)ntohl (lsa
->data
->ls_seqnum
),
4824 vty_out (vty
, " Checksum: 0x%04x%s", ntohs (lsa
->data
->checksum
),
4826 vty_out (vty
, " Length: %d%s", ntohs (lsa
->data
->length
), VTY_NEWLINE
);
4829 const char *link_type_desc
[] =
4832 "another Router (point-to-point)",
4833 "a Transit Network",
4838 const char *link_id_desc
[] =
4841 "Neighboring Router ID",
4842 "Designated Router address",
4844 "Neighboring Router ID",
4847 const char *link_data_desc
[] =
4850 "Router Interface address",
4851 "Router Interface address",
4853 "Router Interface address",
4856 /* Show router-LSA each Link information. */
4858 show_ip_ospf_database_router_links (struct vty
*vty
,
4859 struct router_lsa
*rl
)
4864 len
= ntohs (rl
->header
.length
) - 4;
4865 for (i
= 0; i
< ntohs (rl
->links
) && len
> 0; len
-= 12, i
++)
4867 type
= rl
->link
[i
].type
;
4869 vty_out (vty
, " Link connected to: %s%s",
4870 link_type_desc
[type
], VTY_NEWLINE
);
4871 vty_out (vty
, " (Link ID) %s: %s%s", link_id_desc
[type
],
4872 inet_ntoa (rl
->link
[i
].link_id
), VTY_NEWLINE
);
4873 vty_out (vty
, " (Link Data) %s: %s%s", link_data_desc
[type
],
4874 inet_ntoa (rl
->link
[i
].link_data
), VTY_NEWLINE
);
4875 vty_out (vty
, " Number of TOS metrics: 0%s", VTY_NEWLINE
);
4876 vty_out (vty
, " TOS 0 Metric: %d%s",
4877 ntohs (rl
->link
[i
].metric
), VTY_NEWLINE
);
4878 vty_out (vty
, "%s", VTY_NEWLINE
);
4882 /* Show router-LSA detail information. */
4884 show_router_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4888 struct router_lsa
*rl
= (struct router_lsa
*) lsa
->data
;
4890 show_ip_ospf_database_header (vty
, lsa
);
4892 vty_out (vty
, " Number of Links: %d%s%s", ntohs (rl
->links
),
4893 VTY_NEWLINE
, VTY_NEWLINE
);
4895 show_ip_ospf_database_router_links (vty
, rl
);
4896 vty_out (vty
, "%s", VTY_NEWLINE
);
4902 /* Show network-LSA detail information. */
4904 show_network_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4910 struct network_lsa
*nl
= (struct network_lsa
*) lsa
->data
;
4912 show_ip_ospf_database_header (vty
, lsa
);
4914 vty_out (vty
, " Network Mask: /%d%s",
4915 ip_masklen (nl
->mask
), VTY_NEWLINE
);
4917 length
= ntohs (lsa
->data
->length
) - OSPF_LSA_HEADER_SIZE
- 4;
4919 for (i
= 0; length
> 0; i
++, length
-= 4)
4920 vty_out (vty
, " Attached Router: %s%s",
4921 inet_ntoa (nl
->routers
[i
]), VTY_NEWLINE
);
4923 vty_out (vty
, "%s", VTY_NEWLINE
);
4929 /* Show summary-LSA detail information. */
4931 show_summary_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4935 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
4937 show_ip_ospf_database_header (vty
, lsa
);
4939 vty_out (vty
, " Network Mask: /%d%s", ip_masklen (sl
->mask
),
4941 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
4943 vty_out (vty
, "%s", VTY_NEWLINE
);
4949 /* Show summary-ASBR-LSA detail information. */
4951 show_summary_asbr_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4955 struct summary_lsa
*sl
= (struct summary_lsa
*) lsa
->data
;
4957 show_ip_ospf_database_header (vty
, lsa
);
4959 vty_out (vty
, " Network Mask: /%d%s",
4960 ip_masklen (sl
->mask
), VTY_NEWLINE
);
4961 vty_out (vty
, " TOS: 0 Metric: %d%s", GET_METRIC (sl
->metric
),
4963 vty_out (vty
, "%s", VTY_NEWLINE
);
4969 /* Show AS-external-LSA detail information. */
4971 show_as_external_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
4975 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
4977 show_ip_ospf_database_header (vty
, lsa
);
4979 vty_out (vty
, " Network Mask: /%d%s",
4980 ip_masklen (al
->mask
), VTY_NEWLINE
);
4981 vty_out (vty
, " Metric Type: %s%s",
4982 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
4983 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
4984 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
4985 vty_out (vty
, " Metric: %d%s",
4986 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
4987 vty_out (vty
, " Forward Address: %s%s",
4988 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
4990 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
4991 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
4998 show_as_external_lsa_stdvty (struct ospf_lsa
*lsa
)
5000 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5002 /* show_ip_ospf_database_header (vty, lsa); */
5004 zlog_debug( " Network Mask: /%d%s",
5005 ip_masklen (al
->mask
), "\n");
5006 zlog_debug( " Metric Type: %s%s",
5007 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5008 "2 (Larger than any link state path)" : "1", "\n");
5009 zlog_debug( " TOS: 0%s", "\n");
5010 zlog_debug( " Metric: %d%s",
5011 GET_METRIC (al
->e
[0].metric
), "\n");
5012 zlog_debug( " Forward Address: %s%s",
5013 inet_ntoa (al
->e
[0].fwd_addr
), "\n");
5015 zlog_debug( " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5016 (route_tag_t
)ntohl (al
->e
[0].route_tag
), "\n", "\n");
5021 /* Show AS-NSSA-LSA detail information. */
5023 show_as_nssa_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5027 struct as_external_lsa
*al
= (struct as_external_lsa
*) lsa
->data
;
5029 show_ip_ospf_database_header (vty
, lsa
);
5031 vty_out (vty
, " Network Mask: /%d%s",
5032 ip_masklen (al
->mask
), VTY_NEWLINE
);
5033 vty_out (vty
, " Metric Type: %s%s",
5034 IS_EXTERNAL_METRIC (al
->e
[0].tos
) ?
5035 "2 (Larger than any link state path)" : "1", VTY_NEWLINE
);
5036 vty_out (vty
, " TOS: 0%s", VTY_NEWLINE
);
5037 vty_out (vty
, " Metric: %d%s",
5038 GET_METRIC (al
->e
[0].metric
), VTY_NEWLINE
);
5039 vty_out (vty
, " NSSA: Forward Address: %s%s",
5040 inet_ntoa (al
->e
[0].fwd_addr
), VTY_NEWLINE
);
5042 vty_out (vty
, " External Route Tag: %"ROUTE_TAG_PRI
"%s%s",
5043 (route_tag_t
)ntohl (al
->e
[0].route_tag
), VTY_NEWLINE
, VTY_NEWLINE
);
5050 show_func_dummy (struct vty
*vty
, struct ospf_lsa
*lsa
)
5056 show_opaque_lsa_detail (struct vty
*vty
, struct ospf_lsa
*lsa
)
5060 show_ip_ospf_database_header (vty
, lsa
);
5061 show_opaque_info_detail (vty
, lsa
);
5063 vty_out (vty
, "%s", VTY_NEWLINE
);
5068 int (*show_function
[])(struct vty
*, struct ospf_lsa
*) =
5071 show_router_lsa_detail
,
5072 show_network_lsa_detail
,
5073 show_summary_lsa_detail
,
5074 show_summary_asbr_lsa_detail
,
5075 show_as_external_lsa_detail
,
5077 show_as_nssa_lsa_detail
, /* almost same as external */
5079 show_opaque_lsa_detail
,
5080 show_opaque_lsa_detail
,
5081 show_opaque_lsa_detail
,
5085 show_lsa_prefix_set (struct vty
*vty
, struct prefix_ls
*lp
, struct in_addr
*id
,
5086 struct in_addr
*adv_router
)
5088 memset (lp
, 0, sizeof (struct prefix_ls
));
5092 else if (adv_router
== NULL
)
5101 lp
->adv_router
= *adv_router
;
5106 show_lsa_detail_proc (struct vty
*vty
, struct route_table
*rt
,
5107 struct in_addr
*id
, struct in_addr
*adv_router
)
5109 struct prefix_ls lp
;
5110 struct route_node
*rn
, *start
;
5111 struct ospf_lsa
*lsa
;
5113 show_lsa_prefix_set (vty
, &lp
, id
, adv_router
);
5114 start
= route_node_get (rt
, (struct prefix
*) &lp
);
5117 route_lock_node (start
);
5118 for (rn
= start
; rn
; rn
= route_next_until (rn
, start
))
5119 if ((lsa
= rn
->info
))
5121 if (show_function
[lsa
->data
->type
] != NULL
)
5122 show_function
[lsa
->data
->type
] (vty
, lsa
);
5124 route_unlock_node (start
);
5128 /* Show detail LSA information
5129 -- if id is NULL then show all LSAs. */
5131 show_lsa_detail (struct vty
*vty
, struct ospf
*ospf
, int type
,
5132 struct in_addr
*id
, struct in_addr
*adv_router
)
5134 struct listnode
*node
;
5135 struct ospf_area
*area
;
5139 case OSPF_AS_EXTERNAL_LSA
:
5140 case OSPF_OPAQUE_AS_LSA
:
5141 vty_out (vty
, " %s %s%s",
5142 show_database_desc
[type
],
5143 VTY_NEWLINE
, VTY_NEWLINE
);
5144 show_lsa_detail_proc (vty
, AS_LSDB (ospf
, type
), id
, adv_router
);
5147 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5149 vty_out (vty
, "%s %s (Area %s)%s%s",
5150 VTY_NEWLINE
, show_database_desc
[type
],
5151 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5152 show_lsa_detail_proc (vty
, AREA_LSDB (area
, type
), id
, adv_router
);
5159 show_lsa_detail_adv_router_proc (struct vty
*vty
, struct route_table
*rt
,
5160 struct in_addr
*adv_router
)
5162 struct route_node
*rn
;
5163 struct ospf_lsa
*lsa
;
5165 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
5166 if ((lsa
= rn
->info
))
5167 if (IPV4_ADDR_SAME (adv_router
, &lsa
->data
->adv_router
))
5169 if (CHECK_FLAG (lsa
->flags
, OSPF_LSA_LOCAL_XLT
))
5171 if (show_function
[lsa
->data
->type
] != NULL
)
5172 show_function
[lsa
->data
->type
] (vty
, lsa
);
5176 /* Show detail LSA information. */
5178 show_lsa_detail_adv_router (struct vty
*vty
, struct ospf
*ospf
, int type
,
5179 struct in_addr
*adv_router
)
5181 struct listnode
*node
;
5182 struct ospf_area
*area
;
5186 case OSPF_AS_EXTERNAL_LSA
:
5187 case OSPF_OPAQUE_AS_LSA
:
5188 vty_out (vty
, " %s %s%s",
5189 show_database_desc
[type
],
5190 VTY_NEWLINE
, VTY_NEWLINE
);
5191 show_lsa_detail_adv_router_proc (vty
, AS_LSDB (ospf
, type
),
5195 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5197 vty_out (vty
, "%s %s (Area %s)%s%s",
5198 VTY_NEWLINE
, show_database_desc
[type
],
5199 ospf_area_desc_string (area
), VTY_NEWLINE
, VTY_NEWLINE
);
5200 show_lsa_detail_adv_router_proc (vty
, AREA_LSDB (area
, type
),
5208 show_ip_ospf_database_summary (struct vty
*vty
, struct ospf
*ospf
, int self
)
5210 struct ospf_lsa
*lsa
;
5211 struct route_node
*rn
;
5212 struct ospf_area
*area
;
5213 struct listnode
*node
;
5216 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
5218 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5222 case OSPF_AS_EXTERNAL_LSA
:
5223 case OSPF_OPAQUE_AS_LSA
:
5228 if (ospf_lsdb_count_self (area
->lsdb
, type
) > 0 ||
5229 (!self
&& ospf_lsdb_count (area
->lsdb
, type
) > 0))
5231 vty_out (vty
, " %s (Area %s)%s%s",
5232 show_database_desc
[type
],
5233 ospf_area_desc_string (area
),
5234 VTY_NEWLINE
, VTY_NEWLINE
);
5235 vty_out (vty
, "%s%s", show_database_header
[type
], VTY_NEWLINE
);
5237 LSDB_LOOP (AREA_LSDB (area
, type
), rn
, lsa
)
5238 show_lsa_summary (vty
, lsa
, self
);
5240 vty_out (vty
, "%s", VTY_NEWLINE
);
5245 for (type
= OSPF_MIN_LSA
; type
< OSPF_MAX_LSA
; type
++)
5249 case OSPF_AS_EXTERNAL_LSA
:
5250 case OSPF_OPAQUE_AS_LSA
:
5255 if (ospf_lsdb_count_self (ospf
->lsdb
, type
) ||
5256 (!self
&& ospf_lsdb_count (ospf
->lsdb
, type
)))
5258 vty_out (vty
, " %s%s%s",
5259 show_database_desc
[type
],
5260 VTY_NEWLINE
, VTY_NEWLINE
);
5261 vty_out (vty
, "%s%s", show_database_header
[type
],
5264 LSDB_LOOP (AS_LSDB (ospf
, type
), rn
, lsa
)
5265 show_lsa_summary (vty
, lsa
, self
);
5267 vty_out (vty
, "%s", VTY_NEWLINE
);
5271 vty_out (vty
, "%s", VTY_NEWLINE
);
5275 show_ip_ospf_database_maxage (struct vty
*vty
, struct ospf
*ospf
)
5277 struct route_node
*rn
;
5279 vty_out (vty
, "%s MaxAge Link States:%s%s",
5280 VTY_NEWLINE
, VTY_NEWLINE
, VTY_NEWLINE
);
5282 for (rn
= route_top (ospf
->maxage_lsa
); rn
; rn
= route_next (rn
))
5284 struct ospf_lsa
*lsa
;
5286 if ((lsa
= rn
->info
) != NULL
)
5288 vty_out (vty
, "Link type: %d%s", lsa
->data
->type
, VTY_NEWLINE
);
5289 vty_out (vty
, "Link State ID: %s%s",
5290 inet_ntoa (lsa
->data
->id
), VTY_NEWLINE
);
5291 vty_out (vty
, "Advertising Router: %s%s",
5292 inet_ntoa (lsa
->data
->adv_router
), VTY_NEWLINE
);
5293 vty_out (vty
, "LSA lock count: %d%s", lsa
->lock
, VTY_NEWLINE
);
5294 vty_out (vty
, "%s", VTY_NEWLINE
);
5299 #define OSPF_LSA_TYPE_NSSA_DESC "NSSA external link state\n"
5300 #define OSPF_LSA_TYPE_NSSA_CMD_STR "|nssa-external"
5302 #define OSPF_LSA_TYPE_OPAQUE_LINK_DESC "Link local Opaque-LSA\n"
5303 #define OSPF_LSA_TYPE_OPAQUE_AREA_DESC "Link area Opaque-LSA\n"
5304 #define OSPF_LSA_TYPE_OPAQUE_AS_DESC "Link AS Opaque-LSA\n"
5305 #define OSPF_LSA_TYPE_OPAQUE_CMD_STR "|opaque-link|opaque-area|opaque-as"
5307 #define OSPF_LSA_TYPES_DESC \
5308 "ASBR summary link states\n" \
5309 "External link states\n" \
5310 "Network link states\n" \
5311 "Router link states\n" \
5312 "Network summary link states\n" \
5313 OSPF_LSA_TYPE_NSSA_DESC \
5314 OSPF_LSA_TYPE_OPAQUE_LINK_DESC \
5315 OSPF_LSA_TYPE_OPAQUE_AREA_DESC \
5316 OSPF_LSA_TYPE_OPAQUE_AS_DESC
5319 show_ip_ospf_database_common (struct vty
*vty
, struct ospf
*ospf
,
5320 int arg_base
, int argc
, struct cmd_token
**argv
)
5324 struct in_addr id
, adv_router
;
5327 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5330 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5331 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5334 if (argc
== arg_base
+ 4)
5336 show_ip_ospf_database_summary (vty
, ospf
, 0);
5340 /* Set database type to show. */
5341 if (strncmp (argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5342 type
= OSPF_ROUTER_LSA
;
5343 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5344 type
= OSPF_NETWORK_LSA
;
5345 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5346 type
= OSPF_AS_NSSA_LSA
;
5347 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "su", 2) == 0)
5348 type
= OSPF_SUMMARY_LSA
;
5349 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5350 type
= OSPF_ASBR_SUMMARY_LSA
;
5351 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5352 type
= OSPF_AS_EXTERNAL_LSA
;
5353 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "se", 2) == 0)
5355 show_ip_ospf_database_summary (vty
, ospf
, 1);
5358 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "m", 1) == 0)
5360 show_ip_ospf_database_maxage (vty
, ospf
);
5363 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5364 type
= OSPF_OPAQUE_LINK_LSA
;
5365 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5366 type
= OSPF_OPAQUE_AREA_LSA
;
5367 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5368 type
= OSPF_OPAQUE_AS_LSA
;
5372 /* `show ip ospf database LSA'. */
5373 if (argc
== arg_base
+ 5)
5374 show_lsa_detail (vty
, ospf
, type
, NULL
, NULL
);
5375 else if (argc
>= arg_base
+ 6)
5377 ret
= inet_aton (argv
[arg_base
+ 5]->arg
, &id
);
5381 /* `show ip ospf database LSA ID'. */
5382 if (argc
== arg_base
+ 6)
5383 show_lsa_detail (vty
, ospf
, type
, &id
, NULL
);
5384 /* `show ip ospf database LSA ID adv-router ADV_ROUTER'. */
5385 else if (argc
== arg_base
+ 7)
5387 if (strncmp (argv
[arg_base
+ 6]->text
, "s", 1) == 0)
5388 adv_router
= ospf
->router_id
;
5391 ret
= inet_aton (argv
[arg_base
+ 7]->arg
, &adv_router
);
5395 show_lsa_detail (vty
, ospf
, type
, &id
, &adv_router
);
5402 DEFUN (show_ip_ospf_database_max
,
5403 show_ip_ospf_database_max_cmd
,
5404 "show ip ospf database <max-age|self-originate>",
5407 "OSPF information\n"
5408 "Database summary\n"
5409 "LSAs in MaxAge list\n"
5410 "Self-originated link states\n")
5414 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5417 return (show_ip_ospf_database_common(vty
, ospf
, 0, argc
, argv
));
5420 DEFUN (show_ip_ospf_instance_database
,
5421 show_ip_ospf_instance_database_cmd
,
5422 "show ip ospf [(1-65535)] database [<asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as> [A.B.C.D [<self-originate|adv-router A.B.C.D>]]]",
5425 "OSPF information\n"
5427 "Database summary\n"
5429 "Link State ID (as an IP address)\n"
5430 "Self-originated link states\n"
5431 "Advertising Router link states\n"
5432 "Advertising Router (as an IP address)\n")
5435 u_short instance
= 0;
5438 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
5440 VTY_GET_INTEGER ("Instance", instance
, argv
[idx
]->arg
);
5441 ospf
= ospf_lookup_instance (instance
);
5444 ospf
= ospf_lookup();
5447 if (!ospf
|| !ospf
->oi_running
)
5450 return (show_ip_ospf_database_common(vty
, ospf
, idx
? 1 : 0, argc
, argv
));
5453 DEFUN (show_ip_ospf_instance_database_max
,
5454 show_ip_ospf_instance_database_max_cmd
,
5455 "show ip ospf (1-65535) database <max-age|self-originate>",
5458 "OSPF information\n"
5460 "Database summary\n"
5461 "LSAs in MaxAge list\n"
5462 "Self-originated link states\n")
5466 u_short instance
= 0;
5468 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5470 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5473 return (show_ip_ospf_database_common(vty
, ospf
, 1, argc
, argv
));
5478 show_ip_ospf_database_type_adv_router_common (struct vty
*vty
, struct ospf
*ospf
,
5479 int arg_base
, int argc
, struct cmd_token
**argv
)
5483 struct in_addr adv_router
;
5486 vty_out (vty
, "%sOSPF Instance: %d%s", VTY_NEWLINE
, ospf
->instance
,
5489 vty_out (vty
, "%s OSPF Router with ID (%s)%s%s", VTY_NEWLINE
,
5490 inet_ntoa (ospf
->router_id
), VTY_NEWLINE
, VTY_NEWLINE
);
5492 if (argc
!= arg_base
+ 7)
5495 /* Set database type to show. */
5496 if (strncmp (argv
[arg_base
+ idx_type
]->text
, "r", 1) == 0)
5497 type
= OSPF_ROUTER_LSA
;
5498 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ne", 2) == 0)
5499 type
= OSPF_NETWORK_LSA
;
5500 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "ns", 2) == 0)
5501 type
= OSPF_AS_NSSA_LSA
;
5502 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "s", 1) == 0)
5503 type
= OSPF_SUMMARY_LSA
;
5504 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "a", 1) == 0)
5505 type
= OSPF_ASBR_SUMMARY_LSA
;
5506 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "e", 1) == 0)
5507 type
= OSPF_AS_EXTERNAL_LSA
;
5508 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-l", 8) == 0)
5509 type
= OSPF_OPAQUE_LINK_LSA
;
5510 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-ar", 9) == 0)
5511 type
= OSPF_OPAQUE_AREA_LSA
;
5512 else if (strncmp (argv
[arg_base
+ idx_type
]->text
, "opaque-as", 9) == 0)
5513 type
= OSPF_OPAQUE_AS_LSA
;
5517 /* `show ip ospf database LSA adv-router ADV_ROUTER'. */
5518 if (strncmp (argv
[arg_base
+ 5]->text
, "s", 1) == 0)
5519 adv_router
= ospf
->router_id
;
5522 ret
= inet_aton (argv
[arg_base
+ 6]->arg
, &adv_router
);
5527 show_lsa_detail_adv_router (vty
, ospf
, type
, &adv_router
);
5532 DEFUN (show_ip_ospf_database_type_adv_router
,
5533 show_ip_ospf_database_type_adv_router_cmd
,
5534 "show ip ospf database <asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as> <adv-router A.B.C.D|self-originate>",
5537 "OSPF information\n"
5538 "Database summary\n"
5540 "Advertising Router link states\n"
5541 "Advertising Router (as an IP address)\n"
5542 "Self-originated link states\n")
5546 if ((ospf
= ospf_lookup()) == NULL
|| !ospf
->oi_running
)
5549 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 0, argc
, argv
));
5552 DEFUN (show_ip_ospf_instance_database_type_adv_router
,
5553 show_ip_ospf_instance_database_type_adv_router_cmd
,
5554 "show ip ospf (1-65535) database <asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as> <adv-router A.B.C.D|self-originate>",
5557 "OSPF information\n"
5559 "Database summary\n"
5561 "Advertising Router link states\n"
5562 "Advertising Router (as an IP address)\n"
5563 "Self-originated link states\n")
5567 u_short instance
= 0;
5569 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
5571 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
5574 return (show_ip_ospf_database_type_adv_router_common(vty
, ospf
, 1, argc
, argv
));
5577 DEFUN (ip_ospf_authentication_args
,
5578 ip_ospf_authentication_args_addr_cmd
,
5579 "ip ospf authentication <null|message-digest> [A.B.C.D]",
5581 "OSPF interface commands\n"
5582 "Enable authentication on this interface\n"
5583 "Use null authentication\n"
5584 "Use message-digest authentication\n"
5585 "Address of interface\n")
5587 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5588 int idx_encryption
= 3;
5590 struct in_addr addr
;
5592 struct ospf_if_params
*params
;
5594 params
= IF_DEF_PARAMS (ifp
);
5598 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5601 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5606 params
= ospf_get_if_params (ifp
, addr
);
5607 ospf_if_update_params (ifp
, addr
);
5610 /* Handle null authentication */
5611 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5613 SET_IF_PARAM (params
, auth_type
);
5614 params
->auth_type
= OSPF_AUTH_NULL
;
5618 /* Handle message-digest authentication */
5619 if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5621 SET_IF_PARAM (params
, auth_type
);
5622 params
->auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5626 vty_out (vty
, "You shouldn't get here!%s", VTY_NEWLINE
);
5630 DEFUN (ip_ospf_authentication
,
5631 ip_ospf_authentication_addr_cmd
,
5632 "ip ospf authentication [A.B.C.D]",
5634 "OSPF interface commands\n"
5635 "Enable authentication on this interface\n"
5636 "Address of interface")
5638 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5640 struct in_addr addr
;
5642 struct ospf_if_params
*params
;
5644 params
= IF_DEF_PARAMS (ifp
);
5648 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5651 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5656 params
= ospf_get_if_params (ifp
, addr
);
5657 ospf_if_update_params (ifp
, addr
);
5660 SET_IF_PARAM (params
, auth_type
);
5661 params
->auth_type
= OSPF_AUTH_SIMPLE
;
5666 DEFUN (no_ip_ospf_authentication_args
,
5667 no_ip_ospf_authentication_args_addr_cmd
,
5668 "no ip ospf authentication <null|message-digest> [A.B.C.D]",
5671 "OSPF interface commands\n"
5672 "Enable authentication on this interface\n"
5673 "Use null authentication\n"
5674 "Use message-digest authentication\n"
5675 "Address of interface")
5677 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5678 int idx_encryption
= 4;
5680 struct in_addr addr
;
5682 struct ospf_if_params
*params
;
5683 struct route_node
*rn
;
5686 params
= IF_DEF_PARAMS (ifp
);
5690 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5693 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5698 params
= ospf_lookup_if_params (ifp
, addr
);
5701 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
5704 params
->auth_type
= OSPF_AUTH_NOTSET
;
5705 UNSET_IF_PARAM (params
, auth_type
);
5706 if (params
!= IF_DEF_PARAMS (ifp
))
5708 ospf_free_if_params (ifp
, addr
);
5709 ospf_if_update_params (ifp
, addr
);
5714 if ( argv
[idx_encryption
]->arg
[0] == 'n' )
5716 auth_type
= OSPF_AUTH_NULL
;
5718 else if ( argv
[idx_encryption
]->arg
[0] == 'm' )
5720 auth_type
= OSPF_AUTH_CRYPTOGRAPHIC
;
5724 vty_out (vty
, "Unexpected input encountered%s", VTY_NEWLINE
);
5728 * Here we have a case where the user has entered
5729 * 'no ip ospf authentication (null | message_digest )'
5730 * we need to find if we have any ip addresses underneath it that
5731 * correspond to the associated type.
5733 if (params
->auth_type
== auth_type
)
5735 params
->auth_type
= OSPF_AUTH_NOTSET
;
5736 UNSET_IF_PARAM (params
, auth_type
);
5739 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
5741 if ((params
= rn
->info
))
5743 if (params
->auth_type
== auth_type
)
5745 params
->auth_type
= OSPF_AUTH_NOTSET
;
5746 UNSET_IF_PARAM (params
, auth_type
);
5747 if (params
!= IF_DEF_PARAMS (ifp
))
5749 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
5750 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
5760 DEFUN (no_ip_ospf_authentication
,
5761 no_ip_ospf_authentication_addr_cmd
,
5762 "no ip ospf authentication [A.B.C.D]",
5765 "OSPF interface commands\n"
5766 "Enable authentication on this interface\n"
5767 "Address of interface")
5769 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5771 struct in_addr addr
;
5773 struct ospf_if_params
*params
;
5774 struct route_node
*rn
;
5776 params
= IF_DEF_PARAMS (ifp
);
5780 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
5783 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5788 params
= ospf_lookup_if_params (ifp
, addr
);
5791 vty_out (vty
, "Ip Address specified is unknown%s", VTY_NEWLINE
);
5795 params
->auth_type
= OSPF_AUTH_NOTSET
;
5796 UNSET_IF_PARAM (params
, auth_type
);
5797 if (params
!= IF_DEF_PARAMS (ifp
))
5799 ospf_free_if_params (ifp
, addr
);
5800 ospf_if_update_params (ifp
, addr
);
5806 * When a user enters 'no ip ospf authentication'
5807 * We should remove all authentication types from
5810 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
5811 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
5812 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
5814 params
->auth_type
= OSPF_AUTH_NOTSET
;
5815 UNSET_IF_PARAM (params
, auth_type
);
5818 for (rn
= route_top (IF_OIFS_PARAMS (ifp
)); rn
; rn
= route_next (rn
))
5820 if ((params
= rn
->info
))
5823 if ((params
->auth_type
== OSPF_AUTH_NULL
) ||
5824 (params
->auth_type
== OSPF_AUTH_CRYPTOGRAPHIC
) ||
5825 (params
->auth_type
== OSPF_AUTH_SIMPLE
))
5827 params
->auth_type
= OSPF_AUTH_NOTSET
;
5828 UNSET_IF_PARAM (params
, auth_type
);
5829 if (params
!= IF_DEF_PARAMS (ifp
))
5831 ospf_free_if_params (ifp
, rn
->p
.u
.prefix4
);
5832 ospf_if_update_params(ifp
, rn
->p
.u
.prefix4
);
5843 DEFUN (ip_ospf_authentication_key
,
5844 ip_ospf_authentication_key_addr_cmd
,
5845 "ip ospf authentication-key AUTH_KEY [A.B.C.D]",
5847 "OSPF interface commands\n"
5848 "Authentication password (key)\n"
5849 "The OSPF password (key)\n"
5850 "Address of interface")
5852 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5854 struct in_addr addr
;
5855 struct ospf_if_params
*params
;
5857 params
= IF_DEF_PARAMS (ifp
);
5859 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
5861 if (!inet_aton(argv
[idx
]->arg
, &addr
))
5863 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5868 params
= ospf_get_if_params (ifp
, addr
);
5869 ospf_if_update_params (ifp
, addr
);
5872 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
+ 1);
5873 strncpy ((char *) params
->auth_simple
, argv
[3]->arg
, OSPF_AUTH_SIMPLE_SIZE
);
5874 SET_IF_PARAM (params
, auth_simple
);
5879 DEFUN_HIDDEN (ospf_authentication_key
,
5880 ospf_authentication_key_cmd
,
5881 "ospf authentication-key AUTH_KEY [A.B.C.D]",
5882 "OSPF interface commands\n"
5883 "Authentication password (key)\n"
5884 "The OSPF password (key)\n"
5885 "Address of interface\n")
5887 return ip_ospf_authentication_key (self
, vty
, argc
, argv
);
5890 DEFUN (no_ip_ospf_authentication_key
,
5891 no_ip_ospf_authentication_key_authkey_addr_cmd
,
5892 "no ip ospf authentication-key [AUTH_KEY [A.B.C.D]]",
5895 "OSPF interface commands\n"
5896 "Authentication password (key)\n"
5897 "The OSPF password (key)")
5899 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5901 struct in_addr addr
;
5902 struct ospf_if_params
*params
;
5903 params
= IF_DEF_PARAMS (ifp
);
5905 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
5907 if (!inet_aton(argv
[idx
]->arg
, &addr
))
5909 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5914 params
= ospf_lookup_if_params (ifp
, addr
);
5919 memset (params
->auth_simple
, 0, OSPF_AUTH_SIMPLE_SIZE
);
5920 UNSET_IF_PARAM (params
, auth_simple
);
5922 if (params
!= IF_DEF_PARAMS (ifp
))
5924 ospf_free_if_params (ifp
, addr
);
5925 ospf_if_update_params (ifp
, addr
);
5931 DEFUN_HIDDEN (no_ospf_authentication_key
,
5932 no_ospf_authentication_key_authkey_addr_cmd
,
5933 "no ospf authentication-key [AUTH_KEY [A.B.C.D]]",
5935 "OSPF interface commands\n"
5936 "Authentication password (key)\n"
5937 "The OSPF password (key)")
5939 return no_ip_ospf_authentication_key (self
, vty
, argc
, argv
);
5942 DEFUN (ip_ospf_message_digest_key
,
5943 ip_ospf_message_digest_key_cmd
,
5944 "ip ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
5946 "OSPF interface commands\n"
5947 "Message digest authentication password (key)\n"
5949 "Use MD5 algorithm\n"
5950 "The OSPF password (key)\n"
5951 "Address of interface\n")
5953 VTY_DECLVAR_CONTEXT(interface
, ifp
);
5954 struct crypt_key
*ck
;
5956 struct in_addr addr
;
5957 struct ospf_if_params
*params
;
5959 params
= IF_DEF_PARAMS (ifp
);
5962 argv_find (argv
, argc
, "(1-255)", &idx
);
5963 char *keyid
= argv
[idx
]->arg
;
5964 argv_find (argv
, argc
, "KEY", &idx
);
5965 char *cryptkey
= argv
[idx
]->arg
;
5967 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
5969 if (!inet_aton(argv
[idx
]->arg
, &addr
))
5971 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
5976 params
= ospf_get_if_params (ifp
, addr
);
5977 ospf_if_update_params (ifp
, addr
);
5980 key_id
= strtol (keyid
, NULL
, 10);
5981 if (ospf_crypt_key_lookup (params
->auth_crypt
, key_id
) != NULL
)
5983 vty_out (vty
, "OSPF: Key %d already exists%s", key_id
, VTY_NEWLINE
);
5987 ck
= ospf_crypt_key_new ();
5988 ck
->key_id
= (u_char
) key_id
;
5989 memset (ck
->auth_key
, 0, OSPF_AUTH_MD5_SIZE
+1);
5990 strncpy ((char *) ck
->auth_key
, cryptkey
, OSPF_AUTH_MD5_SIZE
);
5992 ospf_crypt_key_add (params
->auth_crypt
, ck
);
5993 SET_IF_PARAM (params
, auth_crypt
);
5998 DEFUN_HIDDEN (ospf_message_digest_key
,
5999 ospf_message_digest_key_cmd
,
6000 "ospf message-digest-key (1-255) md5 KEY [A.B.C.D]",
6001 "OSPF interface commands\n"
6002 "Message digest authentication password (key)\n"
6004 "Use MD5 algorithm\n"
6005 "The OSPF password (key)\n"
6006 "Address of interface\n")
6008 return ip_ospf_message_digest_key (self
, vty
, argc
, argv
);
6011 DEFUN (no_ip_ospf_message_digest_key
,
6012 no_ip_ospf_message_digest_key_cmd
,
6013 "no ip ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6016 "OSPF interface commands\n"
6017 "Message digest authentication password (key)\n"
6019 "Use MD5 algorithm\n"
6020 "The OSPF password (key)\n"
6021 "Address of interface\n")
6023 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6025 struct crypt_key
*ck
;
6027 struct in_addr addr
;
6028 struct ospf_if_params
*params
;
6029 params
= IF_DEF_PARAMS (ifp
);
6031 argv_find (argv
, argc
, "(1-255)", &idx
);
6032 char *keyid
= argv
[idx
]->arg
;
6034 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6036 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6038 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6043 params
= ospf_lookup_if_params (ifp
, addr
);
6048 key_id
= strtol (keyid
, NULL
, 10);
6049 ck
= ospf_crypt_key_lookup (params
->auth_crypt
, key_id
);
6052 vty_out (vty
, "OSPF: Key %d does not exist%s", key_id
, VTY_NEWLINE
);
6056 ospf_crypt_key_delete (params
->auth_crypt
, key_id
);
6058 if (params
!= IF_DEF_PARAMS (ifp
))
6060 ospf_free_if_params (ifp
, addr
);
6061 ospf_if_update_params (ifp
, addr
);
6067 DEFUN_HIDDEN (no_ospf_message_digest_key
,
6068 no_ospf_message_digest_key_cmd
,
6069 "no ospf message-digest-key (1-255) [md5 KEY] [A.B.C.D]",
6071 "OSPF interface commands\n"
6072 "Message digest authentication password (key)\n"
6074 "Address of interface")
6076 return no_ip_ospf_message_digest_key (self
, vty
, argc
, argv
);
6079 DEFUN (ip_ospf_cost
,
6081 "ip ospf cost (1-65535) [A.B.C.D]",
6083 "OSPF interface commands\n"
6086 "Address of interface\n")
6088 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6091 struct in_addr addr
;
6092 struct ospf_if_params
*params
;
6093 params
= IF_DEF_PARAMS (ifp
);
6096 char *coststr
= NULL
, *ifaddr
= NULL
;
6097 coststr
= argv_find (argv
, argc
, "(1-65535)", &idx
) ? argv
[idx
]->arg
: NULL
;
6098 ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6100 cost
= strtol (coststr
, NULL
, 10);
6104 if(!inet_aton(ifaddr
, &addr
))
6106 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6111 params
= ospf_get_if_params (ifp
, addr
);
6112 ospf_if_update_params (ifp
, addr
);
6115 SET_IF_PARAM (params
, output_cost_cmd
);
6116 params
->output_cost_cmd
= cost
;
6118 ospf_if_recalculate_output_cost (ifp
);
6123 DEFUN_HIDDEN (ospf_cost
,
6125 "ospf cost (1-65535) [A.B.C.D]",
6126 "OSPF interface commands\n"
6129 "Address of interface\n")
6131 return ip_ospf_cost (self
, vty
, argc
, argv
);
6134 DEFUN (no_ip_ospf_cost
,
6135 no_ip_ospf_cost_cmd
,
6136 "no ip ospf cost [(1-65535)] [A.B.C.D]",
6138 "OSPF interface commands\n"
6140 "Address of interface")
6142 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6144 struct in_addr addr
;
6145 struct ospf_if_params
*params
;
6147 params
= IF_DEF_PARAMS (ifp
);
6150 char *ifaddr
= NULL
;
6151 ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6153 /* According to the semantics we are mimicking "no ip ospf cost N" is
6154 * always treated as "no ip ospf cost" regardless of the actual value
6155 * of N already configured for the interface. Thus ignore cost. */
6159 if (!inet_aton(ifaddr
, &addr
))
6161 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6166 params
= ospf_lookup_if_params (ifp
, addr
);
6171 UNSET_IF_PARAM (params
, output_cost_cmd
);
6173 if (params
!= IF_DEF_PARAMS (ifp
))
6175 ospf_free_if_params (ifp
, addr
);
6176 ospf_if_update_params (ifp
, addr
);
6179 ospf_if_recalculate_output_cost (ifp
);
6184 DEFUN_HIDDEN (no_ospf_cost
,
6186 "no ospf cost [(1-65535)] [A.B.C.D]",
6188 "OSPF interface commands\n"
6191 "Address of interface\n")
6193 return no_ip_ospf_cost (self
, vty
, argc
, argv
);
6197 ospf_nbr_timer_update (struct ospf_interface
*oi
)
6199 struct route_node
*rn
;
6200 struct ospf_neighbor
*nbr
;
6202 for (rn
= route_top (oi
->nbrs
); rn
; rn
= route_next (rn
))
6203 if ((nbr
= rn
->info
))
6205 nbr
->v_inactivity
= OSPF_IF_PARAM (oi
, v_wait
);
6206 nbr
->v_db_desc
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6207 nbr
->v_ls_req
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6208 nbr
->v_ls_upd
= OSPF_IF_PARAM (oi
, retransmit_interval
);
6213 ospf_vty_dead_interval_set (struct vty
*vty
, const char *interval_str
,
6214 const char *nbr_str
,
6215 const char *fast_hello_str
)
6217 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6220 struct in_addr addr
;
6222 struct ospf_if_params
*params
;
6223 struct ospf_interface
*oi
;
6224 struct route_node
*rn
;
6226 params
= IF_DEF_PARAMS (ifp
);
6230 ret
= inet_aton(nbr_str
, &addr
);
6233 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6238 params
= ospf_get_if_params (ifp
, addr
);
6239 ospf_if_update_params (ifp
, addr
);
6244 VTY_GET_INTEGER_RANGE ("Router Dead Interval", seconds
, interval_str
,
6247 /* reset fast_hello too, just to be sure */
6248 UNSET_IF_PARAM (params
, fast_hello
);
6249 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6251 else if (fast_hello_str
)
6253 VTY_GET_INTEGER_RANGE ("Hello Multiplier", hellomult
, fast_hello_str
,
6255 /* 1s dead-interval with sub-second hellos desired */
6256 seconds
= OSPF_ROUTER_DEAD_INTERVAL_MINIMAL
;
6257 SET_IF_PARAM (params
, fast_hello
);
6258 params
->fast_hello
= hellomult
;
6262 vty_out (vty
, "Please specify dead-interval or hello-multiplier%s",
6267 SET_IF_PARAM (params
, v_wait
);
6268 params
->v_wait
= seconds
;
6270 /* Update timer values in neighbor structure. */
6274 if ((ospf
= ospf_lookup()))
6276 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6278 ospf_nbr_timer_update (oi
);
6283 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6284 if ((oi
= rn
->info
))
6285 ospf_nbr_timer_update (oi
);
6291 DEFUN (ip_ospf_dead_interval
,
6292 ip_ospf_dead_interval_cmd
,
6293 "ip ospf dead-interval (1-65535) [A.B.C.D]",
6295 "OSPF interface commands\n"
6296 "Interval time after which a neighbor is declared down\n"
6298 "Address of interface\n")
6301 char *interval
= argv_find (argv
, argc
, "(1-65535)", &idx
) ? argv
[idx
]->arg
: NULL
;
6302 char *ifaddr
= argv_find (argv
, argc
, "A.B.C.D", &idx
) ? argv
[idx
]->arg
: NULL
;
6303 return ospf_vty_dead_interval_set (vty
, interval
, ifaddr
, NULL
);
6307 DEFUN_HIDDEN (ospf_dead_interval
,
6308 ospf_dead_interval_cmd
,
6309 "ospf dead-interval (1-65535) [A.B.C.D]",
6310 "OSPF interface commands\n"
6311 "Interval time after which a neighbor is declared down\n"
6313 "Address of interface\n")
6315 return ip_ospf_dead_interval (self
, vty
, argc
, argv
);
6318 DEFUN (ip_ospf_dead_interval_minimal
,
6319 ip_ospf_dead_interval_minimal_addr_cmd
,
6320 "ip ospf dead-interval minimal hello-multiplier (1-10) [A.B.C.D]",
6322 "OSPF interface commands\n"
6323 "Interval time after which a neighbor is declared down\n"
6324 "Minimal 1s dead-interval with fast sub-second hellos\n"
6325 "Hello multiplier factor\n"
6326 "Number of Hellos to send each second\n"
6327 "Address of interface\n")
6332 return ospf_vty_dead_interval_set (vty
, NULL
, argv
[idx_ipv4
]->arg
, argv
[idx_number
]->arg
);
6334 return ospf_vty_dead_interval_set (vty
, NULL
, NULL
, argv
[idx_number
]->arg
);
6337 DEFUN (no_ip_ospf_dead_interval
,
6338 no_ip_ospf_dead_interval_cmd
,
6339 "no ip ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6342 "OSPF interface commands\n"
6343 "Interval time after which a neighbor is declared down\n"
6345 "Address of interface")
6347 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6348 int idx_ipv4
= argc
- 1;
6349 struct in_addr addr
;
6351 struct ospf_if_params
*params
;
6352 struct ospf_interface
*oi
;
6353 struct route_node
*rn
;
6355 params
= IF_DEF_PARAMS (ifp
);
6357 if (argv
[idx_ipv4
]->type
== IPV4_TKN
)
6359 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
6362 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6367 params
= ospf_lookup_if_params (ifp
, addr
);
6372 UNSET_IF_PARAM (params
, v_wait
);
6373 params
->v_wait
= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
;
6375 UNSET_IF_PARAM (params
, fast_hello
);
6376 params
->fast_hello
= OSPF_FAST_HELLO_DEFAULT
;
6378 if (params
!= IF_DEF_PARAMS (ifp
))
6380 ospf_free_if_params (ifp
, addr
);
6381 ospf_if_update_params (ifp
, addr
);
6384 /* Update timer values in neighbor structure. */
6389 if ((ospf
= ospf_lookup()))
6391 oi
= ospf_if_lookup_by_local_addr (ospf
, ifp
, addr
);
6393 ospf_nbr_timer_update (oi
);
6398 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6399 if ((oi
= rn
->info
))
6400 ospf_nbr_timer_update (oi
);
6406 DEFUN_HIDDEN (no_ospf_dead_interval
,
6407 no_ospf_dead_interval_cmd
,
6408 "no ospf dead-interval [<(1-65535)|minimal hello-multiplier (1-10)> [A.B.C.D]]",
6410 "OSPF interface commands\n"
6411 "Interval time after which a neighbor is declared down\n"
6413 "Address of interface")
6415 return no_ip_ospf_dead_interval (self
, vty
, argc
, argv
);
6418 DEFUN (ip_ospf_hello_interval
,
6419 ip_ospf_hello_interval_cmd
,
6420 "ip ospf hello-interval (1-65535) [A.B.C.D]",
6422 "OSPF interface commands\n"
6423 "Time between HELLO packets\n"
6425 "Address of interface\n")
6427 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6429 struct in_addr addr
;
6430 struct ospf_if_params
*params
;
6431 params
= IF_DEF_PARAMS (ifp
);
6432 u_int32_t seconds
= 0;
6434 argv_find (argv
, argc
, "(1-65535)", &idx
);
6435 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6437 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6439 if(!inet_aton(argv
[idx
]->arg
, &addr
))
6441 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6446 params
= ospf_get_if_params (ifp
, addr
);
6447 ospf_if_update_params (ifp
, addr
);
6450 SET_IF_PARAM (params
, v_hello
);
6451 params
->v_hello
= seconds
;
6456 DEFUN_HIDDEN (ospf_hello_interval
,
6457 ospf_hello_interval_cmd
,
6458 "ospf hello-interval (1-65535) [A.B.C.D]",
6459 "OSPF interface commands\n"
6460 "Time between HELLO packets\n"
6462 "Address of interface\n")
6464 return ip_ospf_hello_interval (self
, vty
, argc
, argv
);
6467 DEFUN (no_ip_ospf_hello_interval
,
6468 no_ip_ospf_hello_interval_cmd
,
6469 "no ip ospf hello-interval [(1-65535) [A.B.C.D]]",
6472 "OSPF interface commands\n"
6473 "Time between HELLO packets\n" // ignored
6475 "Address of interface\n")
6477 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6479 struct in_addr addr
;
6480 struct ospf_if_params
*params
;
6481 params
= IF_DEF_PARAMS (ifp
);
6483 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6485 if(!inet_aton(argv
[idx
]->arg
, &addr
))
6487 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6492 params
= ospf_lookup_if_params (ifp
, addr
);
6497 UNSET_IF_PARAM (params
, v_hello
);
6498 params
->v_hello
= OSPF_HELLO_INTERVAL_DEFAULT
;
6500 if (params
!= IF_DEF_PARAMS (ifp
))
6502 ospf_free_if_params (ifp
, addr
);
6503 ospf_if_update_params (ifp
, addr
);
6509 DEFUN_HIDDEN (no_ospf_hello_interval
,
6510 no_ospf_hello_interval_cmd
,
6511 "no ospf hello-interval [(1-65535) [A.B.C.D]]",
6513 "OSPF interface commands\n"
6514 "Time between HELLO packets\n" // ignored
6516 "Address of interface\n")
6518 return no_ip_ospf_hello_interval (self
, vty
, argc
, argv
);
6521 DEFUN (ip_ospf_network
,
6522 ip_ospf_network_cmd
,
6523 "ip ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6525 "OSPF interface commands\n"
6527 "Specify OSPF broadcast multi-access network\n"
6528 "Specify OSPF NBMA network\n"
6529 "Specify OSPF point-to-multipoint network\n"
6530 "Specify OSPF point-to-point network\n")
6532 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6534 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
6535 struct route_node
*rn
;
6537 if (old_type
== OSPF_IFTYPE_LOOPBACK
)
6539 vty_out (vty
, "This is a loopback interface. Can't set network type.%s", VTY_NEWLINE
);
6543 if (argv_find (argv
, argc
, "broadcast", &idx
))
6544 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_BROADCAST
;
6545 else if (argv_find (argv
, argc
, "non-broadcast", &idx
))
6546 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_NBMA
;
6547 else if (argv_find (argv
, argc
, "point-to-multipoint", &idx
))
6548 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOMULTIPOINT
;
6549 else if (argv_find (argv
, argc
, "point-to-point", &idx
))
6550 IF_DEF_PARAMS (ifp
)->type
= OSPF_IFTYPE_POINTOPOINT
;
6552 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
6555 SET_IF_PARAM (IF_DEF_PARAMS (ifp
), type
);
6557 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6559 struct ospf_interface
*oi
= rn
->info
;
6564 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
6566 if (oi
->state
> ISM_Down
)
6568 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
6569 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
6576 DEFUN_HIDDEN (ospf_network
,
6578 "ospf network <broadcast|non-broadcast|point-to-multipoint|point-to-point>",
6579 "OSPF interface commands\n"
6581 "Specify OSPF broadcast multi-access network\n"
6582 "Specify OSPF NBMA network\n"
6583 "Specify OSPF point-to-multipoint network\n"
6584 "Specify OSPF point-to-point network\n")
6586 return ip_ospf_network (self
, vty
, argc
, argv
);
6589 DEFUN (no_ip_ospf_network
,
6590 no_ip_ospf_network_cmd
,
6591 "no ip ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6594 "OSPF interface commands\n"
6596 "Specify OSPF broadcast multi-access network\n"
6597 "Specify OSPF NBMA network\n"
6598 "Specify OSPF point-to-multipoint network\n"
6599 "Specify OSPF point-to-point network\n")
6601 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6602 int old_type
= IF_DEF_PARAMS (ifp
)->type
;
6603 struct route_node
*rn
;
6605 IF_DEF_PARAMS (ifp
)->type
= ospf_default_iftype(ifp
);
6607 if (IF_DEF_PARAMS (ifp
)->type
== old_type
)
6610 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6612 struct ospf_interface
*oi
= rn
->info
;
6617 oi
->type
= IF_DEF_PARAMS (ifp
)->type
;
6619 if (oi
->state
> ISM_Down
)
6621 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceDown
);
6622 OSPF_ISM_EVENT_EXECUTE (oi
, ISM_InterfaceUp
);
6629 DEFUN_HIDDEN (no_ospf_network
,
6630 no_ospf_network_cmd
,
6631 "no ospf network [<broadcast|non-broadcast|point-to-multipoint|point-to-point>]",
6633 "OSPF interface commands\n"
6635 "Specify OSPF broadcast multi-access network\n"
6636 "Specify OSPF NBMA network\n"
6637 "Specify OSPF point-to-multipoint network\n"
6638 "Specify OSPF point-to-point network\n")
6640 return no_ip_ospf_network (self
, vty
, argc
, argv
);
6643 DEFUN (ip_ospf_priority
,
6644 ip_ospf_priority_cmd
,
6645 "ip ospf priority (0-255) [A.B.C.D]",
6647 "OSPF interface commands\n"
6650 "Address of interface")
6652 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6655 struct route_node
*rn
;
6656 struct in_addr addr
;
6657 struct ospf_if_params
*params
;
6658 params
= IF_DEF_PARAMS (ifp
);
6660 argv_find (argv
, argc
, "(0-255)", &idx
);
6661 priority
= strtol (argv
[idx
]->arg
, NULL
, 10);
6663 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6665 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6667 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6672 params
= ospf_get_if_params (ifp
, addr
);
6673 ospf_if_update_params (ifp
, addr
);
6676 SET_IF_PARAM (params
, priority
);
6677 params
->priority
= priority
;
6679 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6681 struct ospf_interface
*oi
= rn
->info
;
6686 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
6688 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
6689 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
6696 DEFUN_HIDDEN (ospf_priority
,
6698 "ospf priority (0-255) [A.B.C.D]",
6699 "OSPF interface commands\n"
6702 "Address of interface")
6704 return ip_ospf_priority (self
, vty
, argc
, argv
);
6707 DEFUN (no_ip_ospf_priority
,
6708 no_ip_ospf_priority_cmd
,
6709 "no ip ospf priority [(0-255) [A.B.C.D]]",
6712 "OSPF interface commands\n"
6713 "Router priority\n" // ignored
6715 "Address of interface")
6717 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6719 struct route_node
*rn
;
6720 struct in_addr addr
;
6721 struct ospf_if_params
*params
;
6723 params
= IF_DEF_PARAMS (ifp
);
6725 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6727 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6729 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6734 params
= ospf_lookup_if_params (ifp
, addr
);
6739 UNSET_IF_PARAM (params
, priority
);
6740 params
->priority
= OSPF_ROUTER_PRIORITY_DEFAULT
;
6742 if (params
!= IF_DEF_PARAMS (ifp
))
6744 ospf_free_if_params (ifp
, addr
);
6745 ospf_if_update_params (ifp
, addr
);
6748 for (rn
= route_top (IF_OIFS (ifp
)); rn
; rn
= route_next (rn
))
6750 struct ospf_interface
*oi
= rn
->info
;
6755 if (PRIORITY (oi
) != OSPF_IF_PARAM (oi
, priority
))
6757 PRIORITY (oi
) = OSPF_IF_PARAM (oi
, priority
);
6758 OSPF_ISM_EVENT_SCHEDULE (oi
, ISM_NeighborChange
);
6765 DEFUN_HIDDEN (no_ospf_priority
,
6766 no_ospf_priority_cmd
,
6767 "no ospf priority [(0-255) [A.B.C.D]]",
6769 "OSPF interface commands\n"
6772 "Address of interface")
6774 return no_ip_ospf_priority (self
, vty
, argc
, argv
);
6777 DEFUN (ip_ospf_retransmit_interval
,
6778 ip_ospf_retransmit_interval_addr_cmd
,
6779 "ip ospf retransmit-interval (3-65535) [A.B.C.D]",
6781 "OSPF interface commands\n"
6782 "Time between retransmitting lost link state advertisements\n"
6784 "Address of interface")
6786 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6789 struct in_addr addr
;
6790 struct ospf_if_params
*params
;
6791 params
= IF_DEF_PARAMS (ifp
);
6793 argv_find (argv
, argc
, "(3-65535)", &idx
);
6794 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6796 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6798 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6800 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6805 params
= ospf_get_if_params (ifp
, addr
);
6806 ospf_if_update_params (ifp
, addr
);
6809 SET_IF_PARAM (params
, retransmit_interval
);
6810 params
->retransmit_interval
= seconds
;
6815 DEFUN_HIDDEN (ospf_retransmit_interval
,
6816 ospf_retransmit_interval_cmd
,
6817 "ospf retransmit-interval (3-65535) [A.B.C.D]",
6818 "OSPF interface commands\n"
6819 "Time between retransmitting lost link state advertisements\n"
6821 "Address of interface")
6823 return ip_ospf_retransmit_interval (self
, vty
, argc
, argv
);
6826 DEFUN (no_ip_ospf_retransmit_interval
,
6827 no_ip_ospf_retransmit_interval_addr_cmd
,
6828 "no ip ospf retransmit-interval [(3-65535)] [A.B.C.D]",
6831 "OSPF interface commands\n"
6832 "Time between retransmitting lost link state advertisements\n"
6834 "Address of interface\n")
6836 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6838 struct in_addr addr
;
6839 struct ospf_if_params
*params
;
6841 params
= IF_DEF_PARAMS (ifp
);
6843 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6845 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6847 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6852 params
= ospf_lookup_if_params (ifp
, addr
);
6857 UNSET_IF_PARAM (params
, retransmit_interval
);
6858 params
->retransmit_interval
= OSPF_RETRANSMIT_INTERVAL_DEFAULT
;
6860 if (params
!= IF_DEF_PARAMS (ifp
))
6862 ospf_free_if_params (ifp
, addr
);
6863 ospf_if_update_params (ifp
, addr
);
6869 DEFUN_HIDDEN (no_ospf_retransmit_interval
,
6870 no_ospf_retransmit_interval_cmd
,
6871 "no ospf retransmit-interval [(3-65535)] [A.B.C.D]",
6873 "OSPF interface commands\n"
6874 "Time between retransmitting lost link state advertisements\n"
6876 "Address of interface\n")
6878 return no_ip_ospf_retransmit_interval (self
, vty
, argc
, argv
);
6881 DEFUN (ip_ospf_transmit_delay
,
6882 ip_ospf_transmit_delay_addr_cmd
,
6883 "ip ospf transmit-delay (1-65535) [A.B.C.D]",
6885 "OSPF interface commands\n"
6886 "Link state transmit delay\n"
6888 "Address of interface")
6890 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6893 struct in_addr addr
;
6894 struct ospf_if_params
*params
;
6896 params
= IF_DEF_PARAMS (ifp
);
6897 argv_find (argv
, argc
, "(1-65535)", &idx
);
6898 seconds
= strtol (argv
[idx
]->arg
, NULL
, 10);
6900 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6902 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6904 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6909 params
= ospf_get_if_params (ifp
, addr
);
6910 ospf_if_update_params (ifp
, addr
);
6913 SET_IF_PARAM (params
, transmit_delay
);
6914 params
->transmit_delay
= seconds
;
6919 DEFUN_HIDDEN (ospf_transmit_delay
,
6920 ospf_transmit_delay_cmd
,
6921 "ospf transmit-delay (1-65535) [A.B.C.D]",
6922 "OSPF interface commands\n"
6923 "Link state transmit delay\n"
6925 "Address of interface")
6927 return ip_ospf_transmit_delay (self
, vty
, argc
, argv
);
6930 DEFUN (no_ip_ospf_transmit_delay
,
6931 no_ip_ospf_transmit_delay_addr_cmd
,
6932 "no ip ospf transmit-delay [(1-65535)] [A.B.C.D]",
6935 "OSPF interface commands\n"
6936 "Link state transmit delay\n"
6937 "Address of interface")
6939 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6941 struct in_addr addr
;
6942 struct ospf_if_params
*params
;
6944 params
= IF_DEF_PARAMS (ifp
);
6946 if (argv_find (argv
, argc
, "A.B.C.D", &idx
))
6948 if (!inet_aton(argv
[idx
]->arg
, &addr
))
6950 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
6955 params
= ospf_lookup_if_params (ifp
, addr
);
6960 UNSET_IF_PARAM (params
, transmit_delay
);
6961 params
->transmit_delay
= OSPF_TRANSMIT_DELAY_DEFAULT
;
6963 if (params
!= IF_DEF_PARAMS (ifp
))
6965 ospf_free_if_params (ifp
, addr
);
6966 ospf_if_update_params (ifp
, addr
);
6973 DEFUN_HIDDEN (no_ospf_transmit_delay
,
6974 no_ospf_transmit_delay_cmd
,
6975 "no ospf transmit-delay",
6977 "OSPF interface commands\n"
6978 "Link state transmit delay\n")
6980 return no_ip_ospf_transmit_delay (self
, vty
, argc
, argv
);
6983 DEFUN (ip_ospf_area
,
6985 "ip ospf [(1-65535)] area <A.B.C.D|(0-4294967295)>",
6987 "OSPF interface commands\n"
6989 "Enable OSPF on this interface\n"
6990 "OSPF area ID in IP address format\n"
6991 "OSPF area ID as a decimal value\n")
6993 VTY_DECLVAR_CONTEXT(interface
, ifp
);
6996 struct in_addr area_id
;
6998 struct ospf_if_params
*params
;
6999 struct route_node
*rn
;
7000 u_short instance
= 0;
7002 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
7003 instance
= strtol (argv
[idx
]->arg
, NULL
, 10);
7004 char *areaid
= argv
[argc
- 1]->arg
;
7006 ospf
= ospf_lookup_instance (instance
);
7009 params
= IF_DEF_PARAMS (ifp
);
7010 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7012 ospf_interface_unset (ifp
);
7013 ospf
= ospf_lookup();
7014 ospf
->if_ospf_cli_count
--;
7019 ret
= ospf_str2area_id (areaid
, &area_id
, &format
);
7022 vty_out (vty
, "Please specify area by A.B.C.D|<0-4294967295>%s",
7026 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
7028 vty_out (vty
, "Cannot enable OSPF on a virtual link.%s", VTY_NEWLINE
);
7032 params
= IF_DEF_PARAMS (ifp
);
7033 if (OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7036 "Must remove previous area config before changing ospf area %s",
7041 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
7043 if (rn
->info
!= NULL
)
7045 vty_out (vty
, "Please remove all network commands first.%s", VTY_NEWLINE
);
7050 /* enable ospf on this interface with area_id */
7051 ospf_interface_set (ifp
, area_id
);
7052 ospf
->if_ospf_cli_count
++;
7057 DEFUN (no_ip_ospf_area
,
7058 no_ip_ospf_area_cmd
,
7059 "no ip ospf [(1-65535)] area [<A.B.C.D|(0-4294967295)>]",
7062 "OSPF interface commands\n"
7064 "Disable OSPF on this interface\n"
7065 "OSPF area ID in IP address format\n"
7066 "OSPF area ID as a decimal value\n")
7068 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7071 struct ospf_if_params
*params
;
7072 u_short instance
= 0;
7074 if (argv_find (argv
, argc
, "(1-65535)", &idx
))
7075 instance
= strtol (argv
[idx
]->arg
, NULL
, 10);
7077 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
)
7080 params
= IF_DEF_PARAMS (ifp
);
7081 if (!OSPF_IF_PARAM_CONFIGURED(params
, if_area
))
7083 vty_out (vty
, "Can't find specified interface area configuration.%s", VTY_NEWLINE
);
7087 ospf_interface_unset (ifp
);
7088 ospf
->if_ospf_cli_count
--;
7092 DEFUN (ospf_redistribute_source
,
7093 ospf_redistribute_source_cmd
,
7094 "redistribute " FRR_REDIST_STR_OSPFD
" [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7096 FRR_REDIST_HELP_STR_OSPFD
7097 "Metric for redistributed routes\n"
7098 "OSPF default metric\n"
7099 "OSPF exterior metric type for redistributed routes\n"
7100 "Set OSPF External Type 1 metrics\n"
7101 "Set OSPF External Type 2 metrics\n"
7102 "Route map reference\n"
7103 "Pointer to route-map entries\n")
7105 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7106 int idx_protocol
= 1;
7110 struct ospf_redist
*red
;
7116 /* Get distribute source. */
7117 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
7121 red
= ospf_redist_add(ospf
, source
, 0);
7123 /* Get metric value. */
7124 if (argv_find (argv
, argc
, "(0-16777214)", &idx
)) {
7125 if (!str2metric (argv
[idx
]->arg
, &metric
))
7128 /* Get metric type. */
7129 else if (argv_find (argv
, argc
, "(1-2)", &idx
)) {
7130 if (!str2metric_type (argv
[idx
]->arg
, &type
))
7134 else if (argv_find (argv
, argc
, "WORD", &idx
)) {
7135 ospf_routemap_set (red
, argv
[idx
]->arg
);
7138 ospf_routemap_unset (red
);
7140 return ospf_redistribute_set (ospf
, source
, 0, type
, metric
);
7143 DEFUN (no_ospf_redistribute_source
,
7144 no_ospf_redistribute_source_cmd
,
7145 "no redistribute " FRR_REDIST_STR_OSPFD
" [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7148 FRR_REDIST_HELP_STR_OSPFD
7149 "Metric for redistributed routes\n"
7150 "OSPF default metric\n"
7151 "OSPF exterior metric type for redistributed routes\n"
7152 "Set OSPF External Type 1 metrics\n"
7153 "Set OSPF External Type 2 metrics\n"
7154 "Route map reference\n"
7155 "Pointer to route-map entries\n")
7157 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7158 int idx_protocol
= 2;
7160 struct ospf_redist
*red
;
7162 source
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
7166 red
= ospf_redist_lookup(ospf
, source
, 0);
7170 ospf_routemap_unset (red
);
7171 return ospf_redistribute_unset (ospf
, source
, 0);
7174 DEFUN (ospf_redistribute_instance_source
,
7175 ospf_redistribute_instance_source_cmd
,
7176 "redistribute <ospf|table> (1-65535) [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7178 "Open Shortest Path First\n"
7179 "Non-main Kernel Routing Table\n"
7180 "Instance ID/Table ID\n"
7181 "Metric for redistributed routes\n"
7182 "OSPF default metric\n"
7183 "OSPF exterior metric type for redistributed routes\n"
7184 "Set OSPF External Type 1 metrics\n"
7185 "Set OSPF External Type 2 metrics\n"
7186 "Route map reference\n"
7187 "Pointer to route-map entries\n")
7189 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7190 int idx_ospf_table
= 1;
7192 int idx_redist_param
= 3;
7197 struct ospf_redist
*red
;
7202 source
= proto_redistnum (AFI_IP
, argv
[idx_ospf_table
]->text
);
7204 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
7209 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
7211 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
7216 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
7218 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
7223 /* Get metric value. */
7224 if (strcmp (argv
[idx_redist_param
]->arg
, "metric") == 0)
7225 if (!str2metric (argv
[idx_redist_param
+1]->arg
, &metric
))
7228 /* Get metric type. */
7229 if (strcmp (argv
[idx_redist_param
]->arg
, "metric-type") == 0)
7230 if (!str2metric_type (argv
[idx_redist_param
+1]->arg
, &type
))
7233 red
= ospf_redist_add(ospf
, source
, instance
);
7235 if (strcmp (argv
[idx_redist_param
]->arg
, "route-map") == 0)
7236 ospf_routemap_set (red
, argv
[idx_redist_param
+1]->arg
);
7238 ospf_routemap_unset (red
);
7240 return ospf_redistribute_set (ospf
, source
, instance
, type
, metric
);
7243 DEFUN (no_ospf_redistribute_instance_source
,
7244 no_ospf_redistribute_instance_source_cmd
,
7245 "no redistribute <ospf|table> (1-65535) [<metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7248 "Open Shortest Path First\n"
7249 "Non-main Kernel Routing Table\n"
7250 "Instance ID/Table Id\n"
7251 "Metric for redistributed routes\n"
7252 "OSPF default metric\n"
7253 "OSPF exterior metric type for redistributed routes\n"
7254 "Set OSPF External Type 1 metrics\n"
7255 "Set OSPF External Type 2 metrics\n"
7256 "Route map reference\n"
7257 "Pointer to route-map entries\n")
7259 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7260 int idx_ospf_table
= 2;
7263 struct ospf_redist
*red
;
7266 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
7267 source
= ZEBRA_ROUTE_OSPF
;
7269 source
= ZEBRA_ROUTE_TABLE
;
7271 VTY_GET_INTEGER ("Instance ID", instance
, argv
[idx_number
]->arg
);
7273 if ((source
== ZEBRA_ROUTE_OSPF
) && !ospf
->instance
)
7275 vty_out (vty
, "Instance redistribution in non-instanced OSPF not allowed%s",
7280 if ((source
== ZEBRA_ROUTE_OSPF
) && (ospf
->instance
== instance
))
7282 vty_out (vty
, "Same instance OSPF redistribution not allowed%s",
7287 red
= ospf_redist_lookup(ospf
, source
, instance
);
7291 ospf_routemap_unset (red
);
7292 return ospf_redistribute_unset (ospf
, source
, instance
);
7295 DEFUN (ospf_distribute_list_out
,
7296 ospf_distribute_list_out_cmd
,
7297 "distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
7298 "Filter networks in routing updates\n"
7299 "Access-list name\n"
7301 FRR_REDIST_HELP_STR_OSPFD
)
7303 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7307 char *proto
= argv
[argc
- 1]->text
;
7309 /* Get distribute source. */
7310 source
= proto_redistnum(AFI_IP
, proto
);
7314 return ospf_distribute_list_out_set (ospf
, source
, argv
[idx_word
]->arg
);
7317 DEFUN (no_ospf_distribute_list_out
,
7318 no_ospf_distribute_list_out_cmd
,
7319 "no distribute-list WORD out " FRR_REDIST_STR_OSPFD
,
7321 "Filter networks in routing updates\n"
7322 "Access-list name\n"
7324 FRR_REDIST_HELP_STR_OSPFD
)
7326 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7330 char *proto
= argv
[argc
- 1]->text
;
7331 source
= proto_redistnum(AFI_IP
, proto
);
7335 return ospf_distribute_list_out_unset (ospf
, source
, argv
[idx_word
]->arg
);
7338 /* Default information originate. */
7339 DEFUN (ospf_default_information_originate
,
7340 ospf_default_information_originate_cmd
,
7341 "default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7342 "Control distribution of default information\n"
7343 "Distribute a default route\n"
7344 "Always advertise default route\n"
7345 "OSPF default metric\n"
7347 "OSPF metric type for default routes\n"
7348 "Set OSPF External Type 1 metrics\n"
7349 "Set OSPF External Type 2 metrics\n"
7350 "Route map reference\n"
7351 "Pointer to route-map entries\n")
7353 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7354 int default_originate
= DEFAULT_ORIGINATE_ZEBRA
;
7357 struct ospf_redist
*red
;
7360 red
= ospf_redist_add(ospf
, DEFAULT_ROUTE
, 0);
7362 /* Check whether "always" was specified */
7363 if (argv_find (argv
, argc
, "always", &idx
))
7364 default_originate
= DEFAULT_ORIGINATE_ALWAYS
;
7365 /* Get metric value */
7366 else if (argv_find (argv
, argc
, "(0-16777214)", &idx
)) {
7367 if (!str2metric (argv
[idx
]->arg
, &metric
))
7370 /* Get metric type. */
7371 else if (argv_find (argv
, argc
, "(1-2)", &idx
)) {
7372 if (!str2metric_type (argv
[idx
]->arg
, &type
))
7376 else if (argv_find (argv
, argc
, "WORD", &idx
))
7377 ospf_routemap_set (red
, argv
[idx
]->arg
);
7379 ospf_routemap_unset (red
);
7381 return ospf_redistribute_default_set (ospf
, default_originate
,
7385 DEFUN (no_ospf_default_information_originate
,
7386 no_ospf_default_information_originate_cmd
,
7387 "no default-information originate [<always|metric (0-16777214)|metric-type (1-2)|route-map WORD>]",
7389 "Control distribution of default information\n"
7390 "Distribute a default route\n"
7391 "Always advertise default route\n"
7392 "OSPF default metric\n"
7394 "OSPF metric type for default routes\n"
7395 "Set OSPF External Type 1 metrics\n"
7396 "Set OSPF External Type 2 metrics\n"
7397 "Route map reference\n"
7398 "Pointer to route-map entries\n")
7400 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7401 struct prefix_ipv4 p
;
7402 struct ospf_external
*ext
;
7403 struct ospf_redist
*red
;
7406 p
.prefix
.s_addr
= 0;
7409 ospf_external_lsa_flush (ospf
, DEFAULT_ROUTE
, &p
, 0);
7411 if ((ext
= ospf_external_lookup(DEFAULT_ROUTE
, 0)) &&
7412 EXTERNAL_INFO (ext
)) {
7413 ospf_external_info_delete (DEFAULT_ROUTE
, 0, p
);
7414 ospf_external_del (DEFAULT_ROUTE
, 0);
7417 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
7421 ospf_routemap_unset (red
);
7422 return ospf_redistribute_default_unset (ospf
);
7425 DEFUN (ospf_default_metric
,
7426 ospf_default_metric_cmd
,
7427 "default-metric (0-16777214)",
7428 "Set metric of redistributed routes\n"
7431 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7435 if (!str2metric (argv
[idx_number
]->arg
, &metric
))
7438 ospf
->default_metric
= metric
;
7443 DEFUN (no_ospf_default_metric
,
7444 no_ospf_default_metric_cmd
,
7445 "no default-metric [(0-16777214)]",
7447 "Set metric of redistributed routes\n"
7450 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7452 ospf
->default_metric
= -1;
7458 DEFUN (ospf_distance
,
7461 "Define an administrative distance\n"
7462 "OSPF Administrative distance\n")
7464 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7467 ospf
->distance_all
= atoi (argv
[idx_number
]->arg
);
7472 DEFUN (no_ospf_distance
,
7473 no_ospf_distance_cmd
,
7474 "no distance (1-255)",
7476 "Define an administrative distance\n"
7477 "OSPF Administrative distance\n")
7479 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7481 ospf
->distance_all
= 0;
7486 DEFUN (no_ospf_distance_ospf
,
7487 no_ospf_distance_ospf_cmd
,
7488 "no distance ospf [<intra-area (1-255)|inter-area (1-255)|external (1-255)>]",
7490 "Define an administrative distance\n"
7491 "OSPF Administrative distance\n"
7492 "Intra-area routes\n"
7493 "Distance for intra-area routes\n"
7494 "Inter-area routes\n"
7495 "Distance for inter-area routes\n"
7497 "Distance for external routes\n")
7499 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7500 int idx_area_distance
= 3;
7511 if (argv
[idx_area_distance
]->arg
!= NULL
)
7512 ospf
->distance_intra
= 0;
7514 if (argv
[1] != NULL
)
7515 ospf
->distance_inter
= 0;
7517 if (argv
[2] != NULL
)
7518 ospf
->distance_external
= 0;
7520 if (argv
[idx_area_distance
]->arg
|| argv
[1] || argv
[2])
7523 /* If no arguments are given, clear all distance information */
7524 ospf
->distance_intra
= 0;
7525 ospf
->distance_inter
= 0;
7526 ospf
->distance_external
= 0;
7531 DEFUN (ospf_distance_ospf
,
7532 ospf_distance_ospf_cmd
,
7533 "distance ospf [<intra-area (1-255)|inter-area (1-255)|external (1-255)>]",
7534 "Define an administrative distance\n"
7535 "OSPF Administrative distance\n"
7536 "Intra-area routes\n"
7537 "Distance for intra-area routes\n"
7538 "Inter-area routes\n"
7539 "Distance for inter-area routes\n"
7541 "Distance for external routes\n")
7543 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7544 int idx_area_distance
= 2;
7546 if (argc
< 3) /* should not happen */
7549 if (!argv
[idx_area_distance
]->arg
&& !argv
[1] && !argv
[2])
7551 vty_out(vty
, "%% Command incomplete. (Arguments required)%s",
7556 if (strcmp (argv
[idx_area_distance
]->text
, "intra") == 0)
7557 ospf
->distance_intra
= atoi(argv
[idx_area_distance
+1]->arg
);
7559 if (strcmp (argv
[idx_area_distance
]->text
, "inter") == 0)
7560 ospf
->distance_inter
= atoi(argv
[idx_area_distance
+1]->arg
);
7562 if (strcmp (argv
[idx_area_distance
]->text
, "external") == 0)
7563 ospf
->distance_external
= atoi(argv
[idx_area_distance
+1]->arg
);
7569 DEFUN (ospf_distance_source
,
7570 ospf_distance_source_cmd
,
7571 "distance (1-255) A.B.C.D/M",
7572 "Administrative distance\n"
7574 "IP source prefix\n")
7576 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7578 int idx_ipv4_prefixlen
= 2;
7583 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7588 DEFUN (no_ospf_distance_source
,
7589 no_ospf_distance_source_cmd
,
7590 "no distance (1-255) A.B.C.D/M",
7592 "Administrative distance\n"
7594 "IP source prefix\n")
7596 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7598 int idx_ipv4_prefixlen
= 3;
7603 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, NULL
);
7608 DEFUN (ospf_distance_source_access_list
,
7609 ospf_distance_source_access_list_cmd
,
7610 "distance (1-255) A.B.C.D/M WORD",
7611 "Administrative distance\n"
7613 "IP source prefix\n"
7614 "Access list name\n")
7616 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7618 int idx_ipv4_prefixlen
= 2;
7624 ospf_distance_set (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7629 DEFUN (no_ospf_distance_source_access_list
,
7630 no_ospf_distance_source_access_list_cmd
,
7631 "no distance (1-255) A.B.C.D/M WORD",
7633 "Administrative distance\n"
7635 "IP source prefix\n"
7636 "Access list name\n")
7638 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7640 int idx_ipv4_prefixlen
= 3;
7646 ospf_distance_unset (vty
, ospf
, argv
[idx_number
]->arg
, argv
[idx_ipv4_prefixlen
]->arg
, argv
[idx_word
]->arg
);
7652 DEFUN (ip_ospf_mtu_ignore
,
7653 ip_ospf_mtu_ignore_addr_cmd
,
7654 "ip ospf mtu-ignore [A.B.C.D]",
7656 "OSPF interface commands\n"
7657 "Disable MTU mismatch detection on this interface\n"
7658 "Address of interface")
7660 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7662 struct in_addr addr
;
7665 struct ospf_if_params
*params
;
7666 params
= IF_DEF_PARAMS (ifp
);
7670 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7673 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7677 params
= ospf_get_if_params (ifp
, addr
);
7678 ospf_if_update_params (ifp
, addr
);
7680 params
->mtu_ignore
= 1;
7681 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7682 SET_IF_PARAM (params
, mtu_ignore
);
7685 UNSET_IF_PARAM (params
, mtu_ignore
);
7686 if (params
!= IF_DEF_PARAMS (ifp
))
7688 ospf_free_if_params (ifp
, addr
);
7689 ospf_if_update_params (ifp
, addr
);
7695 DEFUN (no_ip_ospf_mtu_ignore
,
7696 no_ip_ospf_mtu_ignore_addr_cmd
,
7697 "no ip ospf mtu-ignore [A.B.C.D]",
7699 "OSPF interface commands\n"
7700 "Disable MTU mismatch detection on this interface\n"
7701 "Address of interface")
7703 VTY_DECLVAR_CONTEXT(interface
, ifp
);
7705 struct in_addr addr
;
7708 struct ospf_if_params
*params
;
7709 params
= IF_DEF_PARAMS (ifp
);
7713 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &addr
);
7716 vty_out (vty
, "Please specify interface address by A.B.C.D%s",
7720 params
= ospf_get_if_params (ifp
, addr
);
7721 ospf_if_update_params (ifp
, addr
);
7723 params
->mtu_ignore
= 0;
7724 if (params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
7725 SET_IF_PARAM (params
, mtu_ignore
);
7728 UNSET_IF_PARAM (params
, mtu_ignore
);
7729 if (params
!= IF_DEF_PARAMS (ifp
))
7731 ospf_free_if_params (ifp
, addr
);
7732 ospf_if_update_params (ifp
, addr
);
7739 DEFUN (ospf_max_metric_router_lsa_admin
,
7740 ospf_max_metric_router_lsa_admin_cmd
,
7741 "max-metric router-lsa administrative",
7742 "OSPF maximum / infinite-distance metric\n"
7743 "Advertise own Router-LSA with infinite distance (stub router)\n"
7744 "Administratively applied, for an indefinite period\n")
7746 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7747 struct listnode
*ln
;
7748 struct ospf_area
*area
;
7750 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7752 SET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
7754 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
))
7755 ospf_router_lsa_update_area (area
);
7758 /* Allows for areas configured later to get the property */
7759 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_SET
;
7764 DEFUN (no_ospf_max_metric_router_lsa_admin
,
7765 no_ospf_max_metric_router_lsa_admin_cmd
,
7766 "no max-metric router-lsa administrative",
7768 "OSPF maximum / infinite-distance metric\n"
7769 "Advertise own Router-LSA with infinite distance (stub router)\n"
7770 "Administratively applied, for an indefinite period\n")
7772 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7773 struct listnode
*ln
;
7774 struct ospf_area
*area
;
7776 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7778 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
);
7780 /* Don't trample on the start-up stub timer */
7781 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
)
7782 && !area
->t_stub_router
)
7784 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
7785 ospf_router_lsa_update_area (area
);
7788 ospf
->stub_router_admin_set
= OSPF_STUB_ROUTER_ADMINISTRATIVE_UNSET
;
7792 DEFUN (ospf_max_metric_router_lsa_startup
,
7793 ospf_max_metric_router_lsa_startup_cmd
,
7794 "max-metric router-lsa on-startup (5-86400)",
7795 "OSPF maximum / infinite-distance metric\n"
7796 "Advertise own Router-LSA with infinite distance (stub router)\n"
7797 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7798 "Time (seconds) to advertise self as stub-router\n")
7800 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7802 unsigned int seconds
;
7806 vty_out (vty
, "%% Must supply stub-router period");
7810 VTY_GET_INTEGER ("stub-router startup period", seconds
, argv
[idx_number
]->arg
);
7812 ospf
->stub_router_startup_time
= seconds
;
7817 DEFUN (no_ospf_max_metric_router_lsa_startup
,
7818 no_ospf_max_metric_router_lsa_startup_cmd
,
7819 "no max-metric router-lsa on-startup [(5-86400)]",
7821 "OSPF maximum / infinite-distance metric\n"
7822 "Advertise own Router-LSA with infinite distance (stub router)\n"
7823 "Automatically advertise stub Router-LSA on startup of OSPF\n"
7824 "Time (seconds) to advertise self as stub-router\n")
7826 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7827 struct listnode
*ln
;
7828 struct ospf_area
*area
;
7830 ospf
->stub_router_startup_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
7832 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7834 SET_FLAG (area
->stub_router_state
, OSPF_AREA_WAS_START_STUB_ROUTED
);
7835 OSPF_TIMER_OFF (area
->t_stub_router
);
7837 /* Don't trample on admin stub routed */
7838 if (!CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
7840 UNSET_FLAG (area
->stub_router_state
, OSPF_AREA_IS_STUB_ROUTED
);
7841 ospf_router_lsa_update_area (area
);
7848 DEFUN (ospf_max_metric_router_lsa_shutdown
,
7849 ospf_max_metric_router_lsa_shutdown_cmd
,
7850 "max-metric router-lsa on-shutdown (5-100)",
7851 "OSPF maximum / infinite-distance metric\n"
7852 "Advertise own Router-LSA with infinite distance (stub router)\n"
7853 "Advertise stub-router prior to full shutdown of OSPF\n"
7854 "Time (seconds) to wait till full shutdown\n")
7856 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7858 unsigned int seconds
;
7862 vty_out (vty
, "%% Must supply stub-router shutdown period");
7866 VTY_GET_INTEGER ("stub-router shutdown wait period", seconds
, argv
[idx_number
]->arg
);
7868 ospf
->stub_router_shutdown_time
= seconds
;
7873 DEFUN (no_ospf_max_metric_router_lsa_shutdown
,
7874 no_ospf_max_metric_router_lsa_shutdown_cmd
,
7875 "no max-metric router-lsa on-shutdown [(5-100)]",
7877 "OSPF maximum / infinite-distance metric\n"
7878 "Advertise own Router-LSA with infinite distance (stub router)\n"
7879 "Advertise stub-router prior to full shutdown of OSPF\n"
7880 "Time (seconds) to wait till full shutdown\n")
7882 VTY_DECLVAR_CONTEXT(ospf
, ospf
);
7884 ospf
->stub_router_shutdown_time
= OSPF_STUB_ROUTER_UNCONFIGURED
;
7890 config_write_stub_router (struct vty
*vty
, struct ospf
*ospf
)
7892 struct listnode
*ln
;
7893 struct ospf_area
*area
;
7895 if (ospf
->stub_router_startup_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
7896 vty_out (vty
, " max-metric router-lsa on-startup %u%s",
7897 ospf
->stub_router_startup_time
, VTY_NEWLINE
);
7898 if (ospf
->stub_router_shutdown_time
!= OSPF_STUB_ROUTER_UNCONFIGURED
)
7899 vty_out (vty
, " max-metric router-lsa on-shutdown %u%s",
7900 ospf
->stub_router_shutdown_time
, VTY_NEWLINE
);
7901 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, ln
, area
))
7903 if (CHECK_FLAG (area
->stub_router_state
, OSPF_AREA_ADMIN_STUB_ROUTED
))
7905 vty_out (vty
, " max-metric router-lsa administrative%s",
7914 show_ip_ospf_route_network (struct vty
*vty
, struct route_table
*rt
)
7916 struct route_node
*rn
;
7917 struct ospf_route
*or;
7918 struct listnode
*pnode
, *pnnode
;
7919 struct ospf_path
*path
;
7921 vty_out (vty
, "============ OSPF network routing table ============%s",
7924 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
7925 if ((or = rn
->info
) != NULL
)
7928 snprintf (buf1
, 19, "%s/%d",
7929 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
7931 switch (or->path_type
)
7933 case OSPF_PATH_INTER_AREA
:
7934 if (or->type
== OSPF_DESTINATION_NETWORK
)
7935 vty_out (vty
, "N IA %-18s [%d] area: %s%s", buf1
, or->cost
,
7936 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
7937 else if (or->type
== OSPF_DESTINATION_DISCARD
)
7938 vty_out (vty
, "D IA %-18s Discard entry%s", buf1
, VTY_NEWLINE
);
7940 case OSPF_PATH_INTRA_AREA
:
7941 vty_out (vty
, "N %-18s [%d] area: %s%s", buf1
, or->cost
,
7942 inet_ntoa (or->u
.std
.area_id
), VTY_NEWLINE
);
7948 if (or->type
== OSPF_DESTINATION_NETWORK
)
7949 for (ALL_LIST_ELEMENTS (or->paths
, pnode
, pnnode
, path
))
7951 if (if_lookup_by_index(path
->ifindex
))
7953 if (path
->nexthop
.s_addr
== 0)
7954 vty_out (vty
, "%24s directly attached to %s%s",
7955 "", ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
7957 vty_out (vty
, "%24s via %s, %s%s", "",
7958 inet_ntoa (path
->nexthop
),
7959 ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
7963 vty_out (vty
, "%s", VTY_NEWLINE
);
7967 show_ip_ospf_route_router (struct vty
*vty
, struct route_table
*rtrs
)
7969 struct route_node
*rn
;
7970 struct ospf_route
*or;
7971 struct listnode
*pnode
;
7972 struct listnode
*node
;
7973 struct ospf_path
*path
;
7975 vty_out (vty
, "============ OSPF router routing table =============%s",
7977 for (rn
= route_top (rtrs
); rn
; rn
= route_next (rn
))
7982 vty_out (vty
, "R %-15s ", inet_ntoa (rn
->p
.u
.prefix4
));
7984 for (ALL_LIST_ELEMENTS_RO ((struct list
*)rn
->info
, node
, or))
7987 vty_out (vty
, "%24s", "");
7990 vty_out (vty
, "%s [%d] area: %s",
7991 (or->path_type
== OSPF_PATH_INTER_AREA
? "IA" : " "),
7992 or->cost
, inet_ntoa (or->u
.std
.area_id
));
7994 vty_out (vty
, "%s%s%s",
7995 (or->u
.std
.flags
& ROUTER_LSA_BORDER
? ", ABR" : ""),
7996 (or->u
.std
.flags
& ROUTER_LSA_EXTERNAL
? ", ASBR" : ""),
7999 for (ALL_LIST_ELEMENTS_RO (or->paths
, pnode
, path
))
8001 if (if_lookup_by_index(path
->ifindex
))
8003 if (path
->nexthop
.s_addr
== 0)
8004 vty_out (vty
, "%24s directly attached to %s%s",
8005 "", ifindex2ifname (path
->ifindex
),
8008 vty_out (vty
, "%24s via %s, %s%s", "",
8009 inet_ntoa (path
->nexthop
),
8010 ifindex2ifname (path
->ifindex
),
8016 vty_out (vty
, "%s", VTY_NEWLINE
);
8020 show_ip_ospf_route_external (struct vty
*vty
, struct route_table
*rt
)
8022 struct route_node
*rn
;
8023 struct ospf_route
*er
;
8024 struct listnode
*pnode
, *pnnode
;
8025 struct ospf_path
*path
;
8027 vty_out (vty
, "============ OSPF external routing table ===========%s",
8029 for (rn
= route_top (rt
); rn
; rn
= route_next (rn
))
8030 if ((er
= rn
->info
) != NULL
)
8033 snprintf (buf1
, 19, "%s/%d",
8034 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
);
8036 switch (er
->path_type
)
8038 case OSPF_PATH_TYPE1_EXTERNAL
:
8039 vty_out (vty
, "N E1 %-18s [%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
,
8040 er
->cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
8042 case OSPF_PATH_TYPE2_EXTERNAL
:
8043 vty_out (vty
, "N E2 %-18s [%d/%d] tag: %"ROUTE_TAG_PRI
"%s", buf1
, er
->cost
,
8044 er
->u
.ext
.type2_cost
, er
->u
.ext
.tag
, VTY_NEWLINE
);
8048 for (ALL_LIST_ELEMENTS (er
->paths
, pnode
, pnnode
, path
))
8050 if (if_lookup_by_index(path
->ifindex
))
8052 if (path
->nexthop
.s_addr
== 0)
8053 vty_out (vty
, "%24s directly attached to %s%s",
8054 "", ifindex2ifname (path
->ifindex
), VTY_NEWLINE
);
8056 vty_out (vty
, "%24s via %s, %s%s", "",
8057 inet_ntoa (path
->nexthop
),
8058 ifindex2ifname (path
->ifindex
),
8063 vty_out (vty
, "%s", VTY_NEWLINE
);
8067 show_ip_ospf_border_routers_common (struct vty
*vty
, struct ospf
*ospf
)
8070 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
8071 VTY_NEWLINE
, VTY_NEWLINE
);
8073 if (ospf
->new_table
== NULL
)
8075 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
8079 /* Show Network routes.
8080 show_ip_ospf_route_network (vty, ospf->new_table); */
8082 /* Show Router routes. */
8083 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
8085 vty_out (vty
, "%s", VTY_NEWLINE
);
8090 DEFUN (show_ip_ospf_border_routers
,
8091 show_ip_ospf_border_routers_cmd
,
8092 "show ip ospf border-routers",
8095 "OSPF information\n"
8096 "Show all the ABR's and ASBR's\n")
8100 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
8103 return show_ip_ospf_border_routers_common(vty
, ospf
);
8106 DEFUN (show_ip_ospf_instance_border_routers
,
8107 show_ip_ospf_instance_border_routers_cmd
,
8108 "show ip ospf (1-65535) border-routers",
8111 "OSPF information\n"
8113 "Show all the ABR's and ASBR's\n")
8117 u_short instance
= 0;
8119 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
8120 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
8123 return show_ip_ospf_border_routers_common(vty
, ospf
);
8127 show_ip_ospf_route_common (struct vty
*vty
, struct ospf
*ospf
)
8130 vty_out (vty
, "%sOSPF Instance: %d%s%s", VTY_NEWLINE
, ospf
->instance
,
8131 VTY_NEWLINE
, VTY_NEWLINE
);
8133 if (ospf
->new_table
== NULL
)
8135 vty_out (vty
, "No OSPF routing information exist%s", VTY_NEWLINE
);
8139 /* Show Network routes. */
8140 show_ip_ospf_route_network (vty
, ospf
->new_table
);
8142 /* Show Router routes. */
8143 show_ip_ospf_route_router (vty
, ospf
->new_rtrs
);
8145 /* Show AS External routes. */
8146 show_ip_ospf_route_external (vty
, ospf
->old_external_route
);
8148 vty_out (vty
, "%s", VTY_NEWLINE
);
8153 DEFUN (show_ip_ospf_route
,
8154 show_ip_ospf_route_cmd
,
8155 "show ip ospf route",
8158 "OSPF information\n"
8159 "OSPF routing table\n")
8163 if ((ospf
= ospf_lookup ()) == NULL
|| !ospf
->oi_running
)
8166 return show_ip_ospf_route_common(vty
, ospf
);
8169 DEFUN (show_ip_ospf_instance_route
,
8170 show_ip_ospf_instance_route_cmd
,
8171 "show ip ospf (1-65535) route",
8174 "OSPF information\n"
8176 "OSPF routing table\n")
8180 u_short instance
= 0;
8182 VTY_GET_INTEGER ("Instance", instance
, argv
[idx_number
]->arg
);
8183 if ((ospf
= ospf_lookup_instance (instance
)) == NULL
|| !ospf
->oi_running
)
8186 return show_ip_ospf_route_common(vty
, ospf
);
8189 const char *ospf_abr_type_str
[] =
8198 const char *ospf_shortcut_mode_str
[] =
8207 area_id2str (char *buf
, int length
, struct ospf_area
*area
)
8209 memset (buf
, 0, length
);
8211 if (area
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
8212 strncpy (buf
, inet_ntoa (area
->area_id
), length
);
8214 sprintf (buf
, "%lu", (unsigned long) ntohl (area
->area_id
.s_addr
));
8218 const char *ospf_int_type_str
[] =
8220 "unknown", /* should never be used. */
8224 "point-to-multipoint",
8225 "virtual-link", /* should never be used. */
8229 /* Configuration write function for ospfd. */
8231 config_write_interface (struct vty
*vty
)
8233 struct listnode
*n1
, *n2
;
8234 struct interface
*ifp
;
8235 struct crypt_key
*ck
;
8237 struct route_node
*rn
= NULL
;
8238 struct ospf_if_params
*params
;
8239 struct ospf
*ospf
= ospf_lookup();
8241 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), n1
, ifp
))
8243 if (memcmp (ifp
->name
, "VLINK", 5) == 0)
8246 if (ifp
->ifindex
== IFINDEX_DELETED
)
8249 vty_out (vty
, "!%s", VTY_NEWLINE
);
8250 vty_out (vty
, "interface %s%s", ifp
->name
,
8253 vty_out (vty
, " description %s%s", ifp
->desc
,
8258 params
= IF_DEF_PARAMS (ifp
);
8261 /* Interface Network print. */
8262 if (OSPF_IF_PARAM_CONFIGURED (params
, type
) &&
8263 params
->type
!= OSPF_IFTYPE_LOOPBACK
)
8265 if (params
->type
!= ospf_default_iftype(ifp
))
8267 vty_out (vty
, " ip ospf network %s",
8268 ospf_int_type_str
[params
->type
]);
8269 if (params
!= IF_DEF_PARAMS (ifp
))
8270 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8271 vty_out (vty
, "%s", VTY_NEWLINE
);
8275 /* OSPF interface authentication print */
8276 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_type
) &&
8277 params
->auth_type
!= OSPF_AUTH_NOTSET
)
8279 const char *auth_str
;
8281 /* Translation tables are not that much help here due to syntax
8282 of the simple option */
8283 switch (params
->auth_type
)
8286 case OSPF_AUTH_NULL
:
8290 case OSPF_AUTH_SIMPLE
:
8294 case OSPF_AUTH_CRYPTOGRAPHIC
:
8295 auth_str
= " message-digest";
8303 vty_out (vty
, " ip ospf authentication%s", auth_str
);
8304 if (params
!= IF_DEF_PARAMS (ifp
))
8305 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8306 vty_out (vty
, "%s", VTY_NEWLINE
);
8309 /* Simple Authentication Password print. */
8310 if (OSPF_IF_PARAM_CONFIGURED (params
, auth_simple
) &&
8311 params
->auth_simple
[0] != '\0')
8313 vty_out (vty
, " ip ospf authentication-key %s",
8314 params
->auth_simple
);
8315 if (params
!= IF_DEF_PARAMS (ifp
))
8316 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8317 vty_out (vty
, "%s", VTY_NEWLINE
);
8320 /* Cryptographic Authentication Key print. */
8321 for (ALL_LIST_ELEMENTS_RO (params
->auth_crypt
, n2
, ck
))
8323 vty_out (vty
, " ip ospf message-digest-key %d md5 %s",
8324 ck
->key_id
, ck
->auth_key
);
8325 if (params
!= IF_DEF_PARAMS (ifp
))
8326 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8327 vty_out (vty
, "%s", VTY_NEWLINE
);
8330 /* Interface Output Cost print. */
8331 if (OSPF_IF_PARAM_CONFIGURED (params
, output_cost_cmd
))
8333 vty_out (vty
, " ip ospf cost %u", params
->output_cost_cmd
);
8334 if (params
!= IF_DEF_PARAMS (ifp
))
8335 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8336 vty_out (vty
, "%s", VTY_NEWLINE
);
8339 /* Hello Interval print. */
8340 if (OSPF_IF_PARAM_CONFIGURED (params
, v_hello
) &&
8341 params
->v_hello
!= OSPF_HELLO_INTERVAL_DEFAULT
)
8343 vty_out (vty
, " ip ospf hello-interval %u", params
->v_hello
);
8344 if (params
!= IF_DEF_PARAMS (ifp
))
8345 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8346 vty_out (vty
, "%s", VTY_NEWLINE
);
8350 /* Router Dead Interval print. */
8351 if (OSPF_IF_PARAM_CONFIGURED (params
, v_wait
) &&
8352 params
->v_wait
!= OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
)
8354 vty_out (vty
, " ip ospf dead-interval ");
8357 if (OSPF_IF_PARAM_CONFIGURED (params
, fast_hello
))
8358 vty_out (vty
, "minimal hello-multiplier %d",
8359 params
->fast_hello
);
8361 vty_out (vty
, "%u", params
->v_wait
);
8363 if (params
!= IF_DEF_PARAMS (ifp
))
8364 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8365 vty_out (vty
, "%s", VTY_NEWLINE
);
8368 /* Router Priority print. */
8369 if (OSPF_IF_PARAM_CONFIGURED (params
, priority
) &&
8370 params
->priority
!= OSPF_ROUTER_PRIORITY_DEFAULT
)
8372 vty_out (vty
, " ip ospf priority %u", params
->priority
);
8373 if (params
!= IF_DEF_PARAMS (ifp
))
8374 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8375 vty_out (vty
, "%s", VTY_NEWLINE
);
8378 /* Retransmit Interval print. */
8379 if (OSPF_IF_PARAM_CONFIGURED (params
, retransmit_interval
) &&
8380 params
->retransmit_interval
!= OSPF_RETRANSMIT_INTERVAL_DEFAULT
)
8382 vty_out (vty
, " ip ospf retransmit-interval %u",
8383 params
->retransmit_interval
);
8384 if (params
!= IF_DEF_PARAMS (ifp
))
8385 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8386 vty_out (vty
, "%s", VTY_NEWLINE
);
8389 /* Transmit Delay print. */
8390 if (OSPF_IF_PARAM_CONFIGURED (params
, transmit_delay
) &&
8391 params
->transmit_delay
!= OSPF_TRANSMIT_DELAY_DEFAULT
)
8393 vty_out (vty
, " ip ospf transmit-delay %u", params
->transmit_delay
);
8394 if (params
!= IF_DEF_PARAMS (ifp
))
8395 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8396 vty_out (vty
, "%s", VTY_NEWLINE
);
8400 if (OSPF_IF_PARAM_CONFIGURED (params
, if_area
))
8403 vty_out (vty
, " ip ospf %d area %s%s", ospf
->instance
,
8404 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
8406 vty_out (vty
, " ip ospf area %s%s",
8407 inet_ntoa (params
->if_area
), VTY_NEWLINE
);
8412 ospf_bfd_write_config(vty
, params
);
8414 /* MTU ignore print. */
8415 if (OSPF_IF_PARAM_CONFIGURED (params
, mtu_ignore
) &&
8416 params
->mtu_ignore
!= OSPF_MTU_IGNORE_DEFAULT
)
8418 if (params
->mtu_ignore
== 0)
8419 vty_out (vty
, " no ip ospf mtu-ignore");
8421 vty_out (vty
, " ip ospf mtu-ignore");
8422 if (params
!= IF_DEF_PARAMS (ifp
))
8423 vty_out (vty
, " %s", inet_ntoa (rn
->p
.u
.prefix4
));
8424 vty_out (vty
, "%s", VTY_NEWLINE
);
8431 rn
= route_top (IF_OIFS_PARAMS (ifp
));
8433 rn
= route_next (rn
);
8443 ospf_opaque_config_write_if (vty
, ifp
);
8450 config_write_network_area (struct vty
*vty
, struct ospf
*ospf
)
8452 struct route_node
*rn
;
8453 u_char buf
[INET_ADDRSTRLEN
];
8455 /* `network area' print. */
8456 for (rn
= route_top (ospf
->networks
); rn
; rn
= route_next (rn
))
8459 struct ospf_network
*n
= rn
->info
;
8461 memset (buf
, 0, INET_ADDRSTRLEN
);
8463 /* Create Area ID string by specified Area ID format. */
8464 if (n
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
8465 strncpy ((char *) buf
, inet_ntoa (n
->area_id
), INET_ADDRSTRLEN
);
8467 sprintf ((char *) buf
, "%lu",
8468 (unsigned long int) ntohl (n
->area_id
.s_addr
));
8470 /* Network print. */
8471 vty_out (vty
, " network %s/%d area %s%s",
8472 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
8480 config_write_ospf_area (struct vty
*vty
, struct ospf
*ospf
)
8482 struct listnode
*node
;
8483 struct ospf_area
*area
;
8484 u_char buf
[INET_ADDRSTRLEN
];
8486 /* Area configuration print. */
8487 for (ALL_LIST_ELEMENTS_RO (ospf
->areas
, node
, area
))
8489 struct route_node
*rn1
;
8491 area_id2str ((char *) buf
, INET_ADDRSTRLEN
, area
);
8493 if (area
->auth_type
!= OSPF_AUTH_NULL
)
8495 if (area
->auth_type
== OSPF_AUTH_SIMPLE
)
8496 vty_out (vty
, " area %s authentication%s", buf
, VTY_NEWLINE
);
8498 vty_out (vty
, " area %s authentication message-digest%s",
8502 if (area
->shortcut_configured
!= OSPF_SHORTCUT_DEFAULT
)
8503 vty_out (vty
, " area %s shortcut %s%s", buf
,
8504 ospf_shortcut_mode_str
[area
->shortcut_configured
],
8507 if ((area
->external_routing
== OSPF_AREA_STUB
)
8508 || (area
->external_routing
== OSPF_AREA_NSSA
)
8511 if (area
->external_routing
== OSPF_AREA_STUB
)
8512 vty_out (vty
, " area %s stub", buf
);
8513 else if (area
->external_routing
== OSPF_AREA_NSSA
)
8515 vty_out (vty
, " area %s nssa", buf
);
8516 switch (area
->NSSATranslatorRole
)
8518 case OSPF_NSSA_ROLE_NEVER
:
8519 vty_out (vty
, " translate-never");
8521 case OSPF_NSSA_ROLE_ALWAYS
:
8522 vty_out (vty
, " translate-always");
8524 case OSPF_NSSA_ROLE_CANDIDATE
:
8526 vty_out (vty
, " translate-candidate");
8530 if (area
->no_summary
)
8531 vty_out (vty
, " no-summary");
8533 vty_out (vty
, "%s", VTY_NEWLINE
);
8535 if (area
->default_cost
!= 1)
8536 vty_out (vty
, " area %s default-cost %d%s", buf
,
8537 area
->default_cost
, VTY_NEWLINE
);
8540 for (rn1
= route_top (area
->ranges
); rn1
; rn1
= route_next (rn1
))
8543 struct ospf_area_range
*range
= rn1
->info
;
8545 vty_out (vty
, " area %s range %s/%d", buf
,
8546 inet_ntoa (rn1
->p
.u
.prefix4
), rn1
->p
.prefixlen
);
8548 if (range
->cost_config
!= OSPF_AREA_RANGE_COST_UNSPEC
)
8549 vty_out (vty
, " cost %d", range
->cost_config
);
8551 if (!CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_ADVERTISE
))
8552 vty_out (vty
, " not-advertise");
8554 if (CHECK_FLAG (range
->flags
, OSPF_AREA_RANGE_SUBSTITUTE
))
8555 vty_out (vty
, " substitute %s/%d",
8556 inet_ntoa (range
->subst_addr
), range
->subst_masklen
);
8558 vty_out (vty
, "%s", VTY_NEWLINE
);
8561 if (EXPORT_NAME (area
))
8562 vty_out (vty
, " area %s export-list %s%s", buf
,
8563 EXPORT_NAME (area
), VTY_NEWLINE
);
8565 if (IMPORT_NAME (area
))
8566 vty_out (vty
, " area %s import-list %s%s", buf
,
8567 IMPORT_NAME (area
), VTY_NEWLINE
);
8569 if (PREFIX_NAME_IN (area
))
8570 vty_out (vty
, " area %s filter-list prefix %s in%s", buf
,
8571 PREFIX_NAME_IN (area
), VTY_NEWLINE
);
8573 if (PREFIX_NAME_OUT (area
))
8574 vty_out (vty
, " area %s filter-list prefix %s out%s", buf
,
8575 PREFIX_NAME_OUT (area
), VTY_NEWLINE
);
8582 config_write_ospf_nbr_nbma (struct vty
*vty
, struct ospf
*ospf
)
8584 struct ospf_nbr_nbma
*nbr_nbma
;
8585 struct route_node
*rn
;
8587 /* Static Neighbor configuration print. */
8588 for (rn
= route_top (ospf
->nbr_nbma
); rn
; rn
= route_next (rn
))
8589 if ((nbr_nbma
= rn
->info
))
8591 vty_out (vty
, " neighbor %s", inet_ntoa (nbr_nbma
->addr
));
8593 if (nbr_nbma
->priority
!= OSPF_NEIGHBOR_PRIORITY_DEFAULT
)
8594 vty_out (vty
, " priority %d", nbr_nbma
->priority
);
8596 if (nbr_nbma
->v_poll
!= OSPF_POLL_INTERVAL_DEFAULT
)
8597 vty_out (vty
, " poll-interval %d", nbr_nbma
->v_poll
);
8599 vty_out (vty
, "%s", VTY_NEWLINE
);
8606 config_write_virtual_link (struct vty
*vty
, struct ospf
*ospf
)
8608 struct listnode
*node
;
8609 struct ospf_vl_data
*vl_data
;
8610 u_char buf
[INET_ADDRSTRLEN
];
8612 /* Virtual-Link print */
8613 for (ALL_LIST_ELEMENTS_RO (ospf
->vlinks
, node
, vl_data
))
8615 struct listnode
*n2
;
8616 struct crypt_key
*ck
;
8617 struct ospf_interface
*oi
;
8619 if (vl_data
!= NULL
)
8621 memset (buf
, 0, INET_ADDRSTRLEN
);
8623 if (vl_data
->format
== OSPF_AREA_ID_FORMAT_ADDRESS
)
8624 strncpy ((char *) buf
, inet_ntoa (vl_data
->vl_area_id
), INET_ADDRSTRLEN
);
8626 sprintf ((char *) buf
, "%lu",
8627 (unsigned long int) ntohl (vl_data
->vl_area_id
.s_addr
));
8628 oi
= vl_data
->vl_oi
;
8631 if (OSPF_IF_PARAM (oi
, v_hello
) != OSPF_HELLO_INTERVAL_DEFAULT
||
8632 OSPF_IF_PARAM (oi
, v_wait
) != OSPF_ROUTER_DEAD_INTERVAL_DEFAULT
||
8633 OSPF_IF_PARAM (oi
, retransmit_interval
) != OSPF_RETRANSMIT_INTERVAL_DEFAULT
||
8634 OSPF_IF_PARAM (oi
, transmit_delay
) != OSPF_TRANSMIT_DELAY_DEFAULT
)
8635 vty_out (vty
, " area %s virtual-link %s hello-interval %d retransmit-interval %d transmit-delay %d dead-interval %d%s",
8637 inet_ntoa (vl_data
->vl_peer
),
8638 OSPF_IF_PARAM (oi
, v_hello
),
8639 OSPF_IF_PARAM (oi
, retransmit_interval
),
8640 OSPF_IF_PARAM (oi
, transmit_delay
),
8641 OSPF_IF_PARAM (oi
, v_wait
),
8644 vty_out (vty
, " area %s virtual-link %s%s", buf
,
8645 inet_ntoa (vl_data
->vl_peer
), VTY_NEWLINE
);
8647 if (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
[0] != '\0')
8648 vty_out (vty
, " area %s virtual-link %s authentication-key %s%s",
8650 inet_ntoa (vl_data
->vl_peer
),
8651 IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_simple
,
8654 for (ALL_LIST_ELEMENTS_RO (IF_DEF_PARAMS (vl_data
->vl_oi
->ifp
)->auth_crypt
,
8656 vty_out (vty
, " area %s virtual-link %s"
8657 " message-digest-key %d md5 %s%s",
8659 inet_ntoa (vl_data
->vl_peer
),
8660 ck
->key_id
, ck
->auth_key
, VTY_NEWLINE
);
8670 config_write_ospf_redistribute (struct vty
*vty
, struct ospf
*ospf
)
8674 /* redistribute print. */
8675 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
8677 struct list
*red_list
;
8678 struct listnode
*node
;
8679 struct ospf_redist
*red
;
8681 red_list
= ospf
->redist
[type
];
8685 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
))
8687 vty_out (vty
, " redistribute %s", zebra_route_string(type
));
8689 vty_out (vty
, " %d", red
->instance
);
8691 if (red
->dmetric
.value
>= 0)
8692 vty_out (vty
, " metric %d", red
->dmetric
.value
);
8694 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8695 vty_out (vty
, " metric-type 1");
8697 if (ROUTEMAP_NAME (red
))
8698 vty_out (vty
, " route-map %s", ROUTEMAP_NAME (red
));
8700 vty_out (vty
, "%s", VTY_NEWLINE
);
8708 config_write_ospf_default_metric (struct vty
*vty
, struct ospf
*ospf
)
8710 if (ospf
->default_metric
!= -1)
8711 vty_out (vty
, " default-metric %d%s", ospf
->default_metric
,
8717 config_write_ospf_distribute (struct vty
*vty
, struct ospf
*ospf
)
8720 struct ospf_redist
*red
;
8724 /* distribute-list print. */
8725 for (type
= 0; type
< ZEBRA_ROUTE_MAX
; type
++)
8726 if (DISTRIBUTE_NAME (ospf
, type
))
8727 vty_out (vty
, " distribute-list %s out %s%s",
8728 DISTRIBUTE_NAME (ospf
, type
),
8729 zebra_route_string(type
), VTY_NEWLINE
);
8731 /* default-information print. */
8732 if (ospf
->default_originate
!= DEFAULT_ORIGINATE_NONE
)
8734 vty_out (vty
, " default-information originate");
8735 if (ospf
->default_originate
== DEFAULT_ORIGINATE_ALWAYS
)
8736 vty_out (vty
, " always");
8738 red
= ospf_redist_lookup(ospf
, DEFAULT_ROUTE
, 0);
8741 if (red
->dmetric
.value
>= 0)
8742 vty_out (vty
, " metric %d",
8743 red
->dmetric
.value
);
8744 if (red
->dmetric
.type
== EXTERNAL_METRIC_TYPE_1
)
8745 vty_out (vty
, " metric-type 1");
8747 if (ROUTEMAP_NAME (red
))
8748 vty_out (vty
, " route-map %s",
8749 ROUTEMAP_NAME (red
));
8752 vty_out (vty
, "%s", VTY_NEWLINE
);
8761 config_write_ospf_distance (struct vty
*vty
, struct ospf
*ospf
)
8763 struct route_node
*rn
;
8764 struct ospf_distance
*odistance
;
8766 if (ospf
->distance_all
)
8767 vty_out (vty
, " distance %d%s", ospf
->distance_all
, VTY_NEWLINE
);
8769 if (ospf
->distance_intra
8770 || ospf
->distance_inter
8771 || ospf
->distance_external
)
8773 vty_out (vty
, " distance ospf");
8775 if (ospf
->distance_intra
)
8776 vty_out (vty
, " intra-area %d", ospf
->distance_intra
);
8777 if (ospf
->distance_inter
)
8778 vty_out (vty
, " inter-area %d", ospf
->distance_inter
);
8779 if (ospf
->distance_external
)
8780 vty_out (vty
, " external %d", ospf
->distance_external
);
8782 vty_out (vty
, "%s", VTY_NEWLINE
);
8785 for (rn
= route_top (ospf
->distance_table
); rn
; rn
= route_next (rn
))
8786 if ((odistance
= rn
->info
) != NULL
)
8788 vty_out (vty
, " distance %d %s/%d %s%s", odistance
->distance
,
8789 inet_ntoa (rn
->p
.u
.prefix4
), rn
->p
.prefixlen
,
8790 odistance
->access_list
? odistance
->access_list
: "",
8796 /* OSPF configuration write function. */
8798 ospf_config_write (struct vty
*vty
)
8801 struct interface
*ifp
;
8802 struct ospf_interface
*oi
;
8803 struct listnode
*node
;
8806 ospf
= ospf_lookup ();
8807 if (ospf
!= NULL
&& ospf
->oi_running
)
8809 /* `router ospf' print. */
8811 vty_out (vty
, "router ospf %d%s", ospf
->instance
, VTY_NEWLINE
);
8813 vty_out (vty
, "router ospf%s", VTY_NEWLINE
);
8817 if (!ospf
->networks
)
8820 /* Router ID print. */
8821 if (ospf
->router_id_static
.s_addr
!= 0)
8822 vty_out (vty
, " ospf router-id %s%s",
8823 inet_ntoa (ospf
->router_id_static
), VTY_NEWLINE
);
8825 /* ABR type print. */
8826 if (ospf
->abr_type
!= OSPF_ABR_DEFAULT
)
8827 vty_out (vty
, " ospf abr-type %s%s",
8828 ospf_abr_type_str
[ospf
->abr_type
], VTY_NEWLINE
);
8830 /* log-adjacency-changes flag print. */
8831 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_CHANGES
))
8833 if (CHECK_FLAG(ospf
->config
, OSPF_LOG_ADJACENCY_DETAIL
))
8834 vty_out(vty
, " log-adjacency-changes detail%s", VTY_NEWLINE
);
8838 vty_out(vty
, " no log-adjacency-changes%s", VTY_NEWLINE
);
8841 /* RFC1583 compatibility flag print -- Compatible with CISCO 12.1. */
8842 if (CHECK_FLAG (ospf
->config
, OSPF_RFC1583_COMPATIBLE
))
8843 vty_out (vty
, " compatible rfc1583%s", VTY_NEWLINE
);
8845 /* auto-cost reference-bandwidth configuration. */
8846 if (ospf
->ref_bandwidth
!= OSPF_DEFAULT_REF_BANDWIDTH
)
8848 vty_out (vty
, "! Important: ensure reference bandwidth "
8849 "is consistent across all routers%s", VTY_NEWLINE
);
8850 vty_out (vty
, " auto-cost reference-bandwidth %d%s",
8851 ospf
->ref_bandwidth
, VTY_NEWLINE
);
8854 /* SPF timers print. */
8855 if (ospf
->spf_delay
!= OSPF_SPF_DELAY_DEFAULT
||
8856 ospf
->spf_holdtime
!= OSPF_SPF_HOLDTIME_DEFAULT
||
8857 ospf
->spf_max_holdtime
!= OSPF_SPF_MAX_HOLDTIME_DEFAULT
)
8858 vty_out (vty
, " timers throttle spf %d %d %d%s",
8859 ospf
->spf_delay
, ospf
->spf_holdtime
,
8860 ospf
->spf_max_holdtime
, VTY_NEWLINE
);
8862 /* LSA timers print. */
8863 if (ospf
->min_ls_interval
!= OSPF_MIN_LS_INTERVAL
)
8864 vty_out (vty
, " timers throttle lsa all %d%s",
8865 ospf
->min_ls_interval
, VTY_NEWLINE
);
8866 if (ospf
->min_ls_arrival
!= OSPF_MIN_LS_ARRIVAL
)
8867 vty_out (vty
, " timers lsa min-arrival %d%s",
8868 ospf
->min_ls_arrival
, VTY_NEWLINE
);
8870 /* Write multiplier print. */
8871 if (ospf
->write_oi_count
!= OSPF_WRITE_INTERFACE_COUNT_DEFAULT
)
8872 vty_out (vty
, " ospf write-multiplier %d%s",
8873 ospf
->write_oi_count
, VTY_NEWLINE
);
8875 /* Max-metric router-lsa print */
8876 config_write_stub_router (vty
, ospf
);
8878 /* SPF refresh parameters print. */
8879 if (ospf
->lsa_refresh_interval
!= OSPF_LSA_REFRESH_INTERVAL_DEFAULT
)
8880 vty_out (vty
, " refresh timer %d%s",
8881 ospf
->lsa_refresh_interval
, VTY_NEWLINE
);
8883 /* Redistribute information print. */
8884 config_write_ospf_redistribute (vty
, ospf
);
8886 /* passive-interface print. */
8887 if (ospf
->passive_interface_default
== OSPF_IF_PASSIVE
)
8888 vty_out (vty
, " passive-interface default%s", VTY_NEWLINE
);
8890 for (ALL_LIST_ELEMENTS_RO (om
->iflist
, node
, ifp
))
8891 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (ifp
), passive_interface
)
8892 && IF_DEF_PARAMS (ifp
)->passive_interface
!=
8893 ospf
->passive_interface_default
)
8895 vty_out (vty
, " %spassive-interface %s%s",
8896 IF_DEF_PARAMS (ifp
)->passive_interface
? "" : "no ",
8897 ifp
->name
, VTY_NEWLINE
);
8899 for (ALL_LIST_ELEMENTS_RO (ospf
->oiflist
, node
, oi
))
8901 if (!OSPF_IF_PARAM_CONFIGURED (oi
->params
, passive_interface
))
8903 if (OSPF_IF_PARAM_CONFIGURED (IF_DEF_PARAMS (oi
->ifp
),
8906 if (oi
->params
->passive_interface
== IF_DEF_PARAMS (oi
->ifp
)->passive_interface
)
8909 else if (oi
->params
->passive_interface
== ospf
->passive_interface_default
)
8912 vty_out (vty
, " %spassive-interface %s %s%s",
8913 oi
->params
->passive_interface
? "" : "no ",
8915 inet_ntoa (oi
->address
->u
.prefix4
), VTY_NEWLINE
);
8918 /* Network area print. */
8919 config_write_network_area (vty
, ospf
);
8921 /* Area config print. */
8922 config_write_ospf_area (vty
, ospf
);
8924 /* static neighbor print. */
8925 config_write_ospf_nbr_nbma (vty
, ospf
);
8927 /* Virtual-Link print. */
8928 config_write_virtual_link (vty
, ospf
);
8930 /* Default metric configuration. */
8931 config_write_ospf_default_metric (vty
, ospf
);
8933 /* Distribute-list and default-information print. */
8934 config_write_ospf_distribute (vty
, ospf
);
8936 /* Distance configuration. */
8937 config_write_ospf_distance (vty
, ospf
);
8939 ospf_opaque_config_write_router (vty
, ospf
);
8946 ospf_vty_show_init (void)
8948 /* "show ip ospf" commands. */
8949 install_element (VIEW_NODE
, &show_ip_ospf_cmd
);
8951 install_element (VIEW_NODE
, &show_ip_ospf_instance_cmd
);
8953 /* "show ip ospf database" commands. */
8954 install_element (VIEW_NODE
, &show_ip_ospf_database_type_adv_router_cmd
);
8955 install_element (VIEW_NODE
, &show_ip_ospf_database_max_cmd
);
8957 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_type_adv_router_cmd
);
8958 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_cmd
);
8959 install_element (VIEW_NODE
, &show_ip_ospf_instance_database_max_cmd
);
8961 /* "show ip ospf interface" commands. */
8962 install_element (VIEW_NODE
, &show_ip_ospf_interface_cmd
);
8964 install_element (VIEW_NODE
, &show_ip_ospf_instance_interface_cmd
);
8966 /* "show ip ospf neighbor" commands. */
8967 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_detail_cmd
);
8968 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_int_cmd
);
8969 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_id_cmd
);
8970 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_all_cmd
);
8971 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_detail_cmd
);
8972 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_cmd
);
8973 install_element (VIEW_NODE
, &show_ip_ospf_neighbor_all_cmd
);
8975 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_detail_cmd
);
8976 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_int_cmd
);
8977 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_id_cmd
);
8978 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_all_cmd
);
8979 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_detail_cmd
);
8980 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_cmd
);
8981 install_element (VIEW_NODE
, &show_ip_ospf_instance_neighbor_all_cmd
);
8983 /* "show ip ospf route" commands. */
8984 install_element (VIEW_NODE
, &show_ip_ospf_route_cmd
);
8985 install_element (VIEW_NODE
, &show_ip_ospf_border_routers_cmd
);
8987 install_element (VIEW_NODE
, &show_ip_ospf_instance_route_cmd
);
8988 install_element (VIEW_NODE
, &show_ip_ospf_instance_border_routers_cmd
);
8992 /* ospfd's interface node. */
8993 static struct cmd_node interface_node
=
9000 /* Initialization of OSPF interface. */
9002 ospf_vty_if_init (void)
9004 /* Install interface node. */
9005 install_node (&interface_node
, config_write_interface
);
9008 /* "ip ospf authentication" commands. */
9009 install_element (INTERFACE_NODE
, &ip_ospf_authentication_args_addr_cmd
);
9010 install_element (INTERFACE_NODE
, &ip_ospf_authentication_addr_cmd
);
9011 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_args_addr_cmd
);
9012 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_addr_cmd
);
9013 install_element (INTERFACE_NODE
, &ip_ospf_authentication_key_addr_cmd
);
9014 install_element (INTERFACE_NODE
, &no_ip_ospf_authentication_key_authkey_addr_cmd
);
9015 install_element (INTERFACE_NODE
, &no_ospf_authentication_key_authkey_addr_cmd
);
9017 /* "ip ospf message-digest-key" commands. */
9018 install_element (INTERFACE_NODE
, &ip_ospf_message_digest_key_cmd
);
9019 install_element (INTERFACE_NODE
, &no_ip_ospf_message_digest_key_cmd
);
9021 /* "ip ospf cost" commands. */
9022 install_element (INTERFACE_NODE
, &ip_ospf_cost_cmd
);
9023 install_element (INTERFACE_NODE
, &no_ip_ospf_cost_cmd
);
9025 /* "ip ospf mtu-ignore" commands. */
9026 install_element (INTERFACE_NODE
, &ip_ospf_mtu_ignore_addr_cmd
);
9027 install_element (INTERFACE_NODE
, &no_ip_ospf_mtu_ignore_addr_cmd
);
9029 /* "ip ospf dead-interval" commands. */
9030 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_cmd
);
9031 install_element (INTERFACE_NODE
, &ip_ospf_dead_interval_minimal_addr_cmd
);
9032 install_element (INTERFACE_NODE
, &no_ip_ospf_dead_interval_cmd
);
9034 /* "ip ospf hello-interval" commands. */
9035 install_element (INTERFACE_NODE
, &ip_ospf_hello_interval_cmd
);
9036 install_element (INTERFACE_NODE
, &no_ip_ospf_hello_interval_cmd
);
9038 /* "ip ospf network" commands. */
9039 install_element (INTERFACE_NODE
, &ip_ospf_network_cmd
);
9040 install_element (INTERFACE_NODE
, &no_ip_ospf_network_cmd
);
9042 /* "ip ospf priority" commands. */
9043 install_element (INTERFACE_NODE
, &ip_ospf_priority_cmd
);
9044 install_element (INTERFACE_NODE
, &no_ip_ospf_priority_cmd
);
9046 /* "ip ospf retransmit-interval" commands. */
9047 install_element (INTERFACE_NODE
, &ip_ospf_retransmit_interval_addr_cmd
);
9048 install_element (INTERFACE_NODE
, &no_ip_ospf_retransmit_interval_addr_cmd
);
9050 /* "ip ospf transmit-delay" commands. */
9051 install_element (INTERFACE_NODE
, &ip_ospf_transmit_delay_addr_cmd
);
9052 install_element (INTERFACE_NODE
, &no_ip_ospf_transmit_delay_addr_cmd
);
9054 /* "ip ospf area" commands. */
9055 install_element (INTERFACE_NODE
, &ip_ospf_area_cmd
);
9056 install_element (INTERFACE_NODE
, &no_ip_ospf_area_cmd
);
9058 /* These commands are compatibitliy for previous version. */
9059 install_element (INTERFACE_NODE
, &ospf_authentication_key_cmd
);
9060 install_element (INTERFACE_NODE
, &ospf_message_digest_key_cmd
);
9061 install_element (INTERFACE_NODE
, &no_ospf_message_digest_key_cmd
);
9062 install_element (INTERFACE_NODE
, &ospf_dead_interval_cmd
);
9063 install_element (INTERFACE_NODE
, &no_ospf_dead_interval_cmd
);
9064 install_element (INTERFACE_NODE
, &ospf_hello_interval_cmd
);
9065 install_element (INTERFACE_NODE
, &no_ospf_hello_interval_cmd
);
9066 install_element (INTERFACE_NODE
, &ospf_cost_cmd
);
9067 install_element (INTERFACE_NODE
, &no_ospf_cost_cmd
);
9068 install_element (INTERFACE_NODE
, &ospf_network_cmd
);
9069 install_element (INTERFACE_NODE
, &no_ospf_network_cmd
);
9070 install_element (INTERFACE_NODE
, &ospf_priority_cmd
);
9071 install_element (INTERFACE_NODE
, &no_ospf_priority_cmd
);
9072 install_element (INTERFACE_NODE
, &ospf_retransmit_interval_cmd
);
9073 install_element (INTERFACE_NODE
, &no_ospf_retransmit_interval_cmd
);
9074 install_element (INTERFACE_NODE
, &ospf_transmit_delay_cmd
);
9075 install_element (INTERFACE_NODE
, &no_ospf_transmit_delay_cmd
);
9079 ospf_vty_zebra_init (void)
9081 install_element (OSPF_NODE
, &ospf_redistribute_source_cmd
);
9082 install_element (OSPF_NODE
, &no_ospf_redistribute_source_cmd
);
9083 install_element (OSPF_NODE
, &ospf_redistribute_instance_source_cmd
);
9084 install_element (OSPF_NODE
, &no_ospf_redistribute_instance_source_cmd
);
9086 install_element (OSPF_NODE
, &ospf_distribute_list_out_cmd
);
9087 install_element (OSPF_NODE
, &no_ospf_distribute_list_out_cmd
);
9089 install_element (OSPF_NODE
, &ospf_default_information_originate_cmd
);
9090 install_element (OSPF_NODE
, &no_ospf_default_information_originate_cmd
);
9092 install_element (OSPF_NODE
, &ospf_default_metric_cmd
);
9093 install_element (OSPF_NODE
, &no_ospf_default_metric_cmd
);
9095 install_element (OSPF_NODE
, &ospf_distance_cmd
);
9096 install_element (OSPF_NODE
, &no_ospf_distance_cmd
);
9097 install_element (OSPF_NODE
, &no_ospf_distance_ospf_cmd
);
9098 install_element (OSPF_NODE
, &ospf_distance_ospf_cmd
);
9100 install_element (OSPF_NODE
, &ospf_distance_source_cmd
);
9101 install_element (OSPF_NODE
, &no_ospf_distance_source_cmd
);
9102 install_element (OSPF_NODE
, &ospf_distance_source_access_list_cmd
);
9103 install_element (OSPF_NODE
, &no_ospf_distance_source_access_list_cmd
);
9107 static struct cmd_node ospf_node
=
9110 "%s(config-router)# ",
9115 ospf_interface_clear (struct interface
*ifp
)
9117 if (!if_is_operative (ifp
)) return;
9119 if (IS_DEBUG_OSPF (ism
, ISM_EVENTS
))
9120 zlog (NULL
, LOG_DEBUG
, "ISM[%s]: clear by reset", ifp
->name
);
9125 DEFUN (clear_ip_ospf_interface
,
9126 clear_ip_ospf_interface_cmd
,
9127 "clear ip ospf interface [IFNAME]",
9130 "OSPF information\n"
9131 "Interface information\n"
9135 struct interface
*ifp
;
9136 struct listnode
*node
;
9138 if (argc
== 4) /* Clear all the ospfv2 interfaces. */
9140 for (ALL_LIST_ELEMENTS_RO (vrf_iflist (VRF_DEFAULT
), node
, ifp
))
9141 ospf_interface_clear(ifp
);
9143 else /* Interface name is specified. */
9145 if ((ifp
= if_lookup_by_name (argv
[idx_ifname
]->text
)) == NULL
)
9146 vty_out (vty
, "No such interface name%s", VTY_NEWLINE
);
9148 ospf_interface_clear(ifp
);
9155 ospf_vty_clear_init (void)
9157 install_element (ENABLE_NODE
, &clear_ip_ospf_interface_cmd
);
9161 /* Install OSPF related vty commands. */
9163 ospf_vty_init (void)
9165 /* Install ospf top node. */
9166 install_node (&ospf_node
, ospf_config_write
);
9168 /* "router ospf" commands. */
9169 install_element (CONFIG_NODE
, &router_ospf_cmd
);
9170 install_element (CONFIG_NODE
, &no_router_ospf_cmd
);
9173 install_default (OSPF_NODE
);
9175 /* "ospf router-id" commands. */
9176 install_element (OSPF_NODE
, &ospf_router_id_cmd
);
9177 install_element (OSPF_NODE
, &ospf_router_id_old_cmd
);
9178 install_element (OSPF_NODE
, &no_ospf_router_id_cmd
);
9180 /* "passive-interface" commands. */
9181 install_element (OSPF_NODE
, &ospf_passive_interface_addr_cmd
);
9182 install_element (OSPF_NODE
, &no_ospf_passive_interface_addr_cmd
);
9184 /* "ospf abr-type" commands. */
9185 install_element (OSPF_NODE
, &ospf_abr_type_cmd
);
9186 install_element (OSPF_NODE
, &no_ospf_abr_type_cmd
);
9188 /* "ospf log-adjacency-changes" commands. */
9189 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_cmd
);
9190 install_element (OSPF_NODE
, &ospf_log_adjacency_changes_detail_cmd
);
9191 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_cmd
);
9192 install_element (OSPF_NODE
, &no_ospf_log_adjacency_changes_detail_cmd
);
9194 /* "ospf rfc1583-compatible" commands. */
9195 install_element (OSPF_NODE
, &ospf_compatible_rfc1583_cmd
);
9196 install_element (OSPF_NODE
, &no_ospf_compatible_rfc1583_cmd
);
9197 install_element (OSPF_NODE
, &ospf_rfc1583_flag_cmd
);
9198 install_element (OSPF_NODE
, &no_ospf_rfc1583_flag_cmd
);
9200 /* "network area" commands. */
9201 install_element (OSPF_NODE
, &ospf_network_area_cmd
);
9202 install_element (OSPF_NODE
, &no_ospf_network_area_cmd
);
9204 /* "area authentication" commands. */
9205 install_element (OSPF_NODE
, &ospf_area_authentication_message_digest_cmd
);
9206 install_element (OSPF_NODE
, &ospf_area_authentication_cmd
);
9207 install_element (OSPF_NODE
, &no_ospf_area_authentication_cmd
);
9209 /* "area range" commands. */
9210 install_element (OSPF_NODE
, &ospf_area_range_cmd
);
9211 install_element (OSPF_NODE
, &ospf_area_range_cost_cmd
);
9212 install_element (OSPF_NODE
, &ospf_area_range_not_advertise_cmd
);
9213 install_element (OSPF_NODE
, &no_ospf_area_range_cmd
);
9214 install_element (OSPF_NODE
, &ospf_area_range_substitute_cmd
);
9215 install_element (OSPF_NODE
, &no_ospf_area_range_substitute_cmd
);
9217 /* "area virtual-link" commands. */
9218 install_element (OSPF_NODE
, &ospf_area_vlink_cmd
);
9219 install_element (OSPF_NODE
, &ospf_area_vlink_intervals_cmd
);
9220 install_element (OSPF_NODE
, &no_ospf_area_vlink_cmd
);
9221 install_element (OSPF_NODE
, &no_ospf_area_vlink_intervals_cmd
);
9232 /* "area stub" commands. */
9233 install_element (OSPF_NODE
, &ospf_area_stub_no_summary_cmd
);
9234 install_element (OSPF_NODE
, &ospf_area_stub_cmd
);
9235 install_element (OSPF_NODE
, &no_ospf_area_stub_no_summary_cmd
);
9236 install_element (OSPF_NODE
, &no_ospf_area_stub_cmd
);
9238 /* "area nssa" commands. */
9239 install_element (OSPF_NODE
, &ospf_area_nssa_cmd
);
9240 install_element (OSPF_NODE
, &ospf_area_nssa_translate_no_summary_cmd
);
9241 install_element (OSPF_NODE
, &ospf_area_nssa_translate_cmd
);
9242 install_element (OSPF_NODE
, &ospf_area_nssa_no_summary_cmd
);
9243 install_element (OSPF_NODE
, &no_ospf_area_nssa_cmd
);
9245 install_element (OSPF_NODE
, &ospf_area_default_cost_cmd
);
9246 install_element (OSPF_NODE
, &no_ospf_area_default_cost_cmd
);
9248 install_element (OSPF_NODE
, &ospf_area_shortcut_cmd
);
9249 install_element (OSPF_NODE
, &no_ospf_area_shortcut_cmd
);
9251 install_element (OSPF_NODE
, &ospf_area_export_list_cmd
);
9252 install_element (OSPF_NODE
, &no_ospf_area_export_list_cmd
);
9254 install_element (OSPF_NODE
, &ospf_area_filter_list_cmd
);
9255 install_element (OSPF_NODE
, &no_ospf_area_filter_list_cmd
);
9257 install_element (OSPF_NODE
, &ospf_area_import_list_cmd
);
9258 install_element (OSPF_NODE
, &no_ospf_area_import_list_cmd
);
9260 /* SPF timer commands */
9261 install_element (OSPF_NODE
, &ospf_timers_throttle_spf_cmd
);
9262 install_element (OSPF_NODE
, &no_ospf_timers_throttle_spf_cmd
);
9264 /* LSA timers commands */
9265 install_element (OSPF_NODE
, &ospf_timers_min_ls_interval_cmd
);
9266 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_interval_cmd
);
9267 install_element (OSPF_NODE
, &ospf_timers_min_ls_arrival_cmd
);
9268 install_element (OSPF_NODE
, &no_ospf_timers_min_ls_arrival_cmd
);
9269 install_element (OSPF_NODE
, &ospf_timers_lsa_cmd
);
9270 install_element (OSPF_NODE
, &no_ospf_timers_lsa_cmd
);
9272 /* refresh timer commands */
9273 install_element (OSPF_NODE
, &ospf_refresh_timer_cmd
);
9274 install_element (OSPF_NODE
, &no_ospf_refresh_timer_val_cmd
);
9276 /* max-metric commands */
9277 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_admin_cmd
);
9278 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_admin_cmd
);
9279 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_startup_cmd
);
9280 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_startup_cmd
);
9281 install_element (OSPF_NODE
, &ospf_max_metric_router_lsa_shutdown_cmd
);
9282 install_element (OSPF_NODE
, &no_ospf_max_metric_router_lsa_shutdown_cmd
);
9284 /* reference bandwidth commands */
9285 install_element (OSPF_NODE
, &ospf_auto_cost_reference_bandwidth_cmd
);
9286 install_element (OSPF_NODE
, &no_ospf_auto_cost_reference_bandwidth_cmd
);
9288 /* "neighbor" commands. */
9289 install_element (OSPF_NODE
, &ospf_neighbor_cmd
);
9290 install_element (OSPF_NODE
, &ospf_neighbor_poll_interval_cmd
);
9291 install_element (OSPF_NODE
, &no_ospf_neighbor_cmd
);
9292 install_element (OSPF_NODE
, &no_ospf_neighbor_poll_cmd
);
9294 /* write multiplier commands */
9295 install_element (OSPF_NODE
, &ospf_write_multiplier_cmd
);
9296 install_element (OSPF_NODE
, &write_multiplier_cmd
);
9297 install_element (OSPF_NODE
, &no_ospf_write_multiplier_cmd
);
9298 install_element (OSPF_NODE
, &no_write_multiplier_cmd
);
9300 /* Init interface related vty commands. */
9301 ospf_vty_if_init ();
9303 /* Init zebra related vty commands. */
9304 ospf_vty_zebra_init ();