eigrpd: Cleanup cli

The eigrp cli was using a define that was causing some issues
surrounding interface names and detailed information.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2017-04-15 14:20:57 -04:00
parent f9e5c9ca06
commit dbc56a10d4
2 changed files with 43 additions and 63 deletions

View File

@ -159,15 +159,6 @@ enum eigrp_fsm_states {
#define EIGRP_FSM_EVENT_LR_FCN 6 /*last reply, FC not satisfied with current value of FDij*/ #define EIGRP_FSM_EVENT_LR_FCN 6 /*last reply, FC not satisfied with current value of FDij*/
#define EIGRP_FSM_KEEP_STATE 7 /*state not changed, usually by receiving not last reply */ #define EIGRP_FSM_KEEP_STATE 7 /*state not changed, usually by receiving not last reply */
#define INT_TYPES_CMD_STR \
"detail|fastethernet|loopback|static"
#define INT_TYPES_DESC \
"Virtual Ethernet interface\n" \
"FastEthernet IEEE 802.3\n" \
"Loopback interface\n" \
"Show static peer information\n"
/** /**
* External routes originate from some other protocol - these are them * External routes originate from some other protocol - these are them
*/ */

View File

@ -240,9 +240,9 @@ DEFUN (no_eigrp_router_id,
DEFUN (eigrp_passive_interface, DEFUN (eigrp_passive_interface,
eigrp_passive_interface_cmd, eigrp_passive_interface_cmd,
"passive-interface <" INT_TYPES_CMD_STR ">", "passive-interface IFNAME",
"Suppress routing updates on an interface\n" "Suppress routing updates on an interface\n"
INT_TYPES_DESC) "Interface to suppress on\n")
{ {
//struct eigrp *eigrp = vty->index; //struct eigrp *eigrp = vty->index;
/*TODO: */ /*TODO: */
@ -252,10 +252,10 @@ DEFUN (eigrp_passive_interface,
DEFUN (no_eigrp_passive_interface, DEFUN (no_eigrp_passive_interface,
no_eigrp_passive_interface_cmd, no_eigrp_passive_interface_cmd,
"no passive-interface <" INT_TYPES_CMD_STR ">", "no passive-interface IFNAME",
NO_STR NO_STR
"Suppress routing updates on an interface\n" "Suppress routing updates on an interface\n"
INT_TYPES_DESC) "Interface to suppress on\n")
{ {
//struct eigrp *eigrp = vty->index; //struct eigrp *eigrp = vty->index;
/*TODO: */ /*TODO: */
@ -378,10 +378,9 @@ DEFUN (no_eigrp_network,
DEFUN (eigrp_neighbor, DEFUN (eigrp_neighbor,
eigrp_neighbor_cmd, eigrp_neighbor_cmd,
"neighbor A.B.C.D <" INT_TYPES_CMD_STR ">", "neighbor A.B.C.D",
"Specify a neighbor router\n" "Specify a neighbor router\n"
"Neighbor address\n" "Neighbor address\n")
INT_TYPES_DESC)
{ {
//struct eigrp *eigrp = vty->index; //struct eigrp *eigrp = vty->index;
@ -390,11 +389,10 @@ DEFUN (eigrp_neighbor,
DEFUN (no_eigrp_neighbor, DEFUN (no_eigrp_neighbor,
no_eigrp_neighbor_cmd, no_eigrp_neighbor_cmd,
"no neighbor A.B.C.D <" INT_TYPES_CMD_STR ">", "no neighbor A.B.C.D",
NO_STR NO_STR
"Specify a neighbor router\n" "Specify a neighbor router\n"
"Neighbor address\n" "Neighbor address\n")
INT_TYPES_DESC)
{ {
//struct eigrp *eigrp = vty->index; //struct eigrp *eigrp = vty->index;
@ -486,15 +484,20 @@ ALIAS (show_ip_eigrp_topology,
DEFUN (show_ip_eigrp_interfaces, DEFUN (show_ip_eigrp_interfaces,
show_ip_eigrp_interfaces_cmd, show_ip_eigrp_interfaces_cmd,
"show ip eigrp interfaces", "show ip eigrp interfaces [IFNAME] [detail]",
SHOW_STR SHOW_STR
IP_STR IP_STR
"IP-EIGRP show commands\n" "IP-EIGRP show commands\n"
"IP-EIGRP interfaces\n") "IP-EIGRP interfaces\n"
"Interface name to look at\n"
"Detailed information\n")
{ {
struct eigrp_interface *ei; struct eigrp_interface *ei;
struct eigrp *eigrp; struct eigrp *eigrp;
struct listnode *node; struct listnode *node;
int idx = 0;
bool detail = false;
const char *ifname = NULL;
eigrp = eigrp_lookup (); eigrp = eigrp_lookup ();
if (eigrp == NULL) if (eigrp == NULL)
@ -503,23 +506,21 @@ DEFUN (show_ip_eigrp_interfaces,
return CMD_SUCCESS; return CMD_SUCCESS;
} }
if (argc !=3) if (argv_find (argv, argc, "IFNAME", &idx))
{ ifname = argv[idx]->arg;
show_ip_eigrp_interface_header (vty, eigrp);
} if (argv_find (argv, argc, "detail", &idx))
detail = true;
if (!ifname)
show_ip_eigrp_interface_header (vty, eigrp);
int idx = 0;
for (ALL_LIST_ELEMENTS_RO (eigrp->eiflist, node, ei)) for (ALL_LIST_ELEMENTS_RO (eigrp->eiflist, node, ei))
{ {
if (argv_find (argv, argc, "detail", &idx)) if (!ifname || strcmp (ei->ifp->name, ifname) == 0)
{ {
show_ip_eigrp_interface_header (vty, eigrp);
}
show_ip_eigrp_interface_sub (vty, eigrp, ei); show_ip_eigrp_interface_sub (vty, eigrp, ei);
idx = 0; if (detail)
if (argv_find (argv, argc, "detail", &idx))
{
show_ip_eigrp_interface_detail (vty, eigrp, ei); show_ip_eigrp_interface_detail (vty, eigrp, ei);
} }
} }
@ -527,29 +528,23 @@ DEFUN (show_ip_eigrp_interfaces,
return CMD_SUCCESS; return CMD_SUCCESS;
} }
ALIAS (show_ip_eigrp_interfaces,
show_ip_eigrp_interfaces_detail_cmd,
"show ip eigrp interfaces <" INT_TYPES_CMD_STR ">",
SHOW_STR
IP_STR
"IP-EIGRP show commands\n"
"IP-EIGRP interfaces\n"
INT_TYPES_DESC)
DEFUN (show_ip_eigrp_neighbors, DEFUN (show_ip_eigrp_neighbors,
show_ip_eigrp_neighbors_cmd, show_ip_eigrp_neighbors_cmd,
"show ip eigrp neighbors", "show ip eigrp neighbors [IFNAME] [detail]",
SHOW_STR SHOW_STR
IP_STR IP_STR
"IP-EIGRP show commands\n" "IP-EIGRP show commands\n"
"IP-EIGRP neighbors\n") "IP-EIGRP neighbors\n"
"Interface to show on\n"
"Detailed Information\n")
{ {
struct eigrp *eigrp; struct eigrp *eigrp;
struct eigrp_interface *ei; struct eigrp_interface *ei;
struct listnode *node, *node2, *nnode2; struct listnode *node, *node2, *nnode2;
struct eigrp_neighbor *nbr; struct eigrp_neighbor *nbr;
int detail = FALSE; bool detail = false;
int idx = 0; int idx = 0;
const char *ifname = NULL;
eigrp = eigrp_lookup (); eigrp = eigrp_lookup ();
if (eigrp == NULL) if (eigrp == NULL)
@ -558,10 +553,16 @@ DEFUN (show_ip_eigrp_neighbors,
return CMD_SUCCESS; return CMD_SUCCESS;
} }
if (argv_find(argv, argc, "IFNAME", &idx))
ifname = argv[idx]->arg;
detail = (argv_find(argv, argc, "detail", &idx)); detail = (argv_find(argv, argc, "detail", &idx));
show_ip_eigrp_neighbor_header (vty, eigrp); show_ip_eigrp_neighbor_header (vty, eigrp);
for (ALL_LIST_ELEMENTS_RO (eigrp->eiflist, node, ei)) for (ALL_LIST_ELEMENTS_RO (eigrp->eiflist, node, ei))
{
if (!ifname || strcmp(ei->ifp->name, ifname) == 0)
{ {
for (ALL_LIST_ELEMENTS (ei->nbrs, node2, nnode2, nbr)) for (ALL_LIST_ELEMENTS (ei->nbrs, node2, nnode2, nbr))
{ {
@ -569,19 +570,11 @@ DEFUN (show_ip_eigrp_neighbors,
show_ip_eigrp_neighbor_sub (vty, nbr, detail); show_ip_eigrp_neighbor_sub (vty, nbr, detail);
} }
} }
}
return CMD_SUCCESS; return CMD_SUCCESS;
} }
ALIAS (show_ip_eigrp_neighbors,
show_ip_eigrp_neighbors_detail_cmd,
"show ip eigrp neighbors <" INT_TYPES_CMD_STR ">",
SHOW_STR
IP_STR
"IP-EIGRP show commands\n"
"IP-EIGRP neighbors\n"
INT_TYPES_DESC)
DEFUN (eigrp_if_delay, DEFUN (eigrp_if_delay,
eigrp_if_delay_cmd, eigrp_if_delay_cmd,
"delay (1-16777215)", "delay (1-16777215)",
@ -1474,10 +1467,6 @@ eigrp_vty_show_init (void)
install_element (VIEW_NODE, &show_ip_eigrp_topology_cmd); install_element (VIEW_NODE, &show_ip_eigrp_topology_cmd);
install_element (VIEW_NODE, &show_ip_eigrp_neighbors_detail_cmd);
install_element (VIEW_NODE, &show_ip_eigrp_interfaces_detail_cmd);
install_element (VIEW_NODE, &show_ip_eigrp_topology_all_links_cmd); install_element (VIEW_NODE, &show_ip_eigrp_topology_all_links_cmd);
install_element (VIEW_NODE, &show_ip_eigrp_topology_detail_cmd); install_element (VIEW_NODE, &show_ip_eigrp_topology_detail_cmd);