Skip to content

Commit

Permalink
Merge pull request #740 from donaldsharp/ospf_commands
Browse files Browse the repository at this point in the history
ospfd: Fix 'advanced' type data base show
  • Loading branch information
Jafaral authored Jun 30, 2017
2 parents 4a19f83 + 36337a6 commit 5fca4e3
Showing 1 changed file with 11 additions and 29 deletions.
40 changes: 11 additions & 29 deletions ospfd/ospf_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 <asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as> <adv-router A.B.C.D|self-originate>",
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 <asbr-summary|external|network|router|summary|nssa-external|opaque-link|opaque-area|opaque-as> <adv-router A.B.C.D|self-originate>",
"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>",
SHOW_STR
IP_STR
"OSPF information\n"
Expand All @@ -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,
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 5fca4e3

Please sign in to comment.