From 36337a6de76d53842c1f6e172d124ebcbf2d1069 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 19 Jun 2017 11:17:57 -0400 Subject: [PATCH] ospfd: Fix 'advanced' type data base show Two things: 1) Some advanced 'show ip ospf database'... code was not working properly. Fix the cli to handle this appropriately 2) Consolidate two cli functions into one. Signed-off-by: Donald Sharp --- ospfd/ospf_vty.c | 40 +++++++++++----------------------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index b136a752f26a..799214c9c519 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -5463,9 +5463,6 @@ show_ip_ospf_database_type_adv_router_common (struct vty *vty, struct ospf *ospf vty_out (vty, "%s OSPF Router with ID (%s)%s%s", VTYNL, inet_ntoa (ospf->router_id), VTYNL, VTYNL); - if (argc != arg_base + 7) - return CMD_WARNING; - /* Set database type to show. */ if (strncmp (argv[arg_base + idx_type]->text, "r", 1) == 0) type = OSPF_ROUTER_LSA; @@ -5503,29 +5500,9 @@ show_ip_ospf_database_type_adv_router_common (struct vty *vty, struct ospf *ospf return CMD_SUCCESS; } -DEFUN (show_ip_ospf_database_type_adv_router, - show_ip_ospf_database_type_adv_router_cmd, - "show ip ospf database ", - SHOW_STR - IP_STR - "OSPF information\n" - "Database summary\n" - OSPF_LSA_TYPES_DESC - "Advertising Router link states\n" - "Advertising Router (as an IP address)\n" - "Self-originated link states\n") -{ - struct ospf *ospf; - - if ((ospf = ospf_lookup()) == NULL || !ospf->oi_running) - return CMD_SUCCESS; - - return (show_ip_ospf_database_type_adv_router_common(vty, ospf, 0, argc, argv)); -} - DEFUN (show_ip_ospf_instance_database_type_adv_router, show_ip_ospf_instance_database_type_adv_router_cmd, - "show ip ospf (1-65535) database ", + "show ip ospf [(1-65535)] database ", SHOW_STR IP_STR "OSPF information\n" @@ -5536,16 +5513,22 @@ DEFUN (show_ip_ospf_instance_database_type_adv_router, "Advertising Router (as an IP address)\n" "Self-originated link states\n") { - int idx_number = 3; struct ospf *ospf; u_short instance = 0; + int idx = 0; - instance = strtoul(argv[idx_number]->arg, NULL, 10); + if (argv_find(argv, argc, "(1-65535)", &idx)) + { + instance = strtoul(argv[idx]->arg, NULL, 10); + ospf = ospf_lookup_instance(instance); + } + else + ospf = ospf_lookup(); - if ((ospf = ospf_lookup_instance (instance)) == NULL || !ospf->oi_running) + if (!ospf || !ospf->oi_running) return CMD_SUCCESS; - return (show_ip_ospf_database_type_adv_router_common(vty, ospf, 1, argc, argv)); + return (show_ip_ospf_database_type_adv_router_common(vty, ospf, idx ? 1 : 0, argc, argv)); } DEFUN (ip_ospf_authentication_args, @@ -8930,7 +8913,6 @@ ospf_vty_show_init (void) install_element (VIEW_NODE, &show_ip_ospf_instance_cmd); /* "show ip ospf database" commands. */ - install_element (VIEW_NODE, &show_ip_ospf_database_type_adv_router_cmd); install_element (VIEW_NODE, &show_ip_ospf_database_max_cmd); install_element (VIEW_NODE, &show_ip_ospf_instance_database_type_adv_router_cmd);