diff options
Diffstat (limited to 'lib/if.c')
| -rw-r--r-- | lib/if.c | 103 |
1 files changed, 52 insertions, 51 deletions
@@ -671,25 +671,23 @@ if_dump_all (void) if_dump (p); } -DEFUN (interface_desc, +DEFUN (interface_desc, interface_desc_cmd, - "description .LINE", + "description LINE...", "Interface specific description\n" "Characters describing this interface\n") { + int idx_line = 1; VTY_DECLVAR_CONTEXT (interface, ifp); - if (argc == 0) - return CMD_SUCCESS; - if (ifp->desc) XFREE (MTYPE_TMP, ifp->desc); - ifp->desc = argv_concat(argv, argc, 0); + ifp->desc = argv_concat(argv, argc, idx_line); return CMD_SUCCESS; } -DEFUN (no_interface_desc, +DEFUN (no_interface_desc, no_interface_desc_cmd, "no description", NO_STR @@ -748,69 +746,72 @@ if_sunwzebra_get (const char *name, size_t nlen, vrf_id_t vrf_id) DEFUN (interface, interface_cmd, - "interface IFNAME", + "interface IFNAME [vrf NAME]", "Select an interface to configure\n" - "Interface's name\n") + "Interface's name\n" + VRF_CMD_HELP_STR) { + int idx_ifname = 1; + int idx_vrf = 3; + const char *ifname = argv[idx_ifname]->arg; + const char *vrfname = (argc > 2) ? argv[idx_vrf]->arg : NULL; + struct interface *ifp; size_t sl; vrf_id_t vrf_id = VRF_DEFAULT; - if ((sl = strlen(argv[0])) > INTERFACE_NAMSIZ) + if ((sl = strlen(ifname)) > INTERFACE_NAMSIZ) { vty_out (vty, "%% Interface name %s is invalid: length exceeds " "%d characters%s", - argv[0], INTERFACE_NAMSIZ, VTY_NEWLINE); + ifname, INTERFACE_NAMSIZ, VTY_NEWLINE); return CMD_WARNING; } /*Pending: need proper vrf name based lookup/(possible creation of VRF) Imagine forward reference of a vrf by name in this interface config */ - if (argc > 1) - VRF_GET_ID (vrf_id, argv[1]); + if (vrfname) + VRF_GET_ID (vrf_id, vrfname); #ifdef SUNOS_5 - ifp = if_sunwzebra_get (argv[0], sl, vrf_id); + ifp = if_sunwzebra_get (ifname, sl, vrf_id); #else - ifp = if_get_by_name_len_vrf (argv[0], sl, vrf_id, 1); + ifp = if_get_by_name_len_vrf (ifname, sl, vrf_id, 1); #endif /* SUNOS_5 */ if (!ifp) { - vty_out (vty, "%% interface %s not in %s%s", argv[0], argv[1], VTY_NEWLINE); + vty_out (vty, "%% interface %s not in %s%s", ifname, vrfname, VTY_NEWLINE); return CMD_WARNING; } - VTY_PUSH_CONTEXT_COMPAT (INTERFACE_NODE, ifp); + VTY_PUSH_CONTEXT (INTERFACE_NODE, ifp); return CMD_SUCCESS; } -ALIAS (interface, - interface_vrf_cmd, - "interface IFNAME " VRF_CMD_STR, - "Select an interface to configure\n" - "Interface's name\n" - VRF_CMD_HELP_STR) - DEFUN_NOSH (no_interface, no_interface_cmd, - "no interface IFNAME", + "no interface IFNAME [vrf NAME]", NO_STR "Delete a pseudo interface's configuration\n" - "Interface's name\n") + "Interface's name\n" + VRF_CMD_HELP_STR) { + const char *ifname = argv[2]->arg; + const char *vrfname = (argc > 3) ? argv[3]->arg : NULL; + // deleting interface struct interface *ifp; vrf_id_t vrf_id = VRF_DEFAULT; - if (argc > 1) - VRF_GET_ID (vrf_id, argv[1]); + if (argc > 3) + VRF_GET_ID (vrf_id, vrfname); - ifp = if_lookup_by_name_vrf (argv[0], vrf_id); + ifp = if_lookup_by_name_vrf (ifname, vrf_id); if (ifp == NULL) { - vty_out (vty, "%% Interface %s does not exist%s", argv[0], VTY_NEWLINE); + vty_out (vty, "%% Interface %s does not exist%s", ifname, VTY_NEWLINE); return CMD_WARNING; } @@ -826,21 +827,27 @@ DEFUN_NOSH (no_interface, return CMD_SUCCESS; } -ALIAS (no_interface, - no_interface_vrf_cmd, - "no interface IFNAME " VRF_CMD_STR, - NO_STR - "Delete a pseudo interface's configuration\n" - "Interface's name\n" - VRF_CMD_HELP_STR) +void +if_cmd_init (void) +{ + install_element (CONFIG_NODE, &interface_cmd); + install_element (CONFIG_NODE, &no_interface_cmd); + + install_default (INTERFACE_NODE); + install_element (INTERFACE_NODE, &interface_desc_cmd); + install_element (INTERFACE_NODE, &no_interface_desc_cmd); +} +#if 0 /* For debug purpose. */ DEFUN (show_address, show_address_cmd, - "show address", + "show address [vrf NAME]", SHOW_STR - "address\n") + "address\n" + VRF_CMD_HELP_STR) { + int idx_vrf = 3; struct listnode *node; struct listnode *node2; struct interface *ifp; @@ -848,8 +855,8 @@ DEFUN (show_address, struct prefix *p; vrf_id_t vrf_id = VRF_DEFAULT; - if (argc > 0) - VRF_GET_ID (vrf_id, argv[0]); + if (argc > 2) + VRF_GET_ID (vrf_id, argv[idx_vrf]->arg); for (ALL_LIST_ELEMENTS_RO (vrf_iflist (vrf_id), node, ifp)) { @@ -865,16 +872,9 @@ DEFUN (show_address, return CMD_SUCCESS; } -ALIAS (show_address, - show_address_vrf_cmd, - "show address " VRF_CMD_STR, - SHOW_STR - "address\n" - VRF_CMD_HELP_STR) - DEFUN (show_address_vrf_all, show_address_vrf_all_cmd, - "show address " VRF_ALL_CMD_STR, + "show address vrf all", SHOW_STR "address\n" VRF_ALL_CMD_HELP_STR) @@ -908,6 +908,7 @@ DEFUN (show_address_vrf_all, } return CMD_SUCCESS; } +#endif /* Allocate connected structure. */ struct connected * @@ -1301,7 +1302,7 @@ if_link_params_get (struct interface *ifp) sizeof (struct if_link_params)); if (iflp == NULL) return NULL; - /* Set TE metric == standard metric */ + /* Set TE metric equal to standard metric */ iflp->te_metric = ifp->metric; /* Compute default bandwidth based on interface */ @@ -1315,7 +1316,7 @@ if_link_params_get (struct interface *ifp) iflp->unrsv_bw[i] = iflp->default_bw; /* Update Link parameters status */ - iflp->lp_status = LP_TE | LP_MAX_BW | LP_MAX_RSV_BW | LP_UNRSV_BW; + iflp->lp_status = LP_TE_METRIC | LP_MAX_BW | LP_MAX_RSV_BW | LP_UNRSV_BW; /* Finally attach newly created Link Parameters */ ifp->link_params = iflp; |
