size_t if_lookup_by_hwaddr(const uint8_t *hw_addr, size_t addrsz,
struct interface ***result, vrf_id_t vrf_id);
+struct vrf;
extern struct interface *if_lookup_by_name_all_vrf(const char *ifname);
+extern struct interface *if_lookup_by_name_vrf(const char *name, struct vrf *vrf);
extern struct interface *if_lookup_by_name(const char *ifname, vrf_id_t vrf_id);
extern struct interface *if_get_by_name(const char *ifname, vrf_id_t vrf_id);
extern struct interface *if_get_by_ifindex(ifindex_t ifindex, vrf_id_t vrf_id,
extern int if_is_broadcast(const struct interface *ifp);
extern int if_is_pointopoint(const struct interface *ifp);
extern int if_is_multicast(const struct interface *ifp);
-struct vrf;
extern void if_terminate(struct vrf *vrf);
extern void if_dump_all(void);
extern const char *if_flag_dump(unsigned long);
#endif
/* Show all interfaces to vty. */
DEFPY(show_interface, show_interface_cmd,
- "show interface [vrf NAME$vrf_name] [brief$brief]",
+ "show interface vrf NAME$vrf_name [brief$brief]",
SHOW_STR
"Interface status and configuration\n"
VRF_CMD_HELP_STR
{
struct vrf *vrf;
struct interface *ifp;
- vrf_id_t vrf_id = VRF_DEFAULT;
interface_update_stats();
- if (vrf_name)
- VRF_GET_ID(vrf_id, vrf_name, false);
+ vrf = vrf_lookup_by_name(vrf_name);
+ if (!vrf) {
+ vty_out(vty, "%% VRF %s not found\n", vrf_name);
+ return CMD_WARNING;
+ }
- /* All interface print. */
- vrf = vrf_lookup_by_id(vrf_id);
if (brief) {
ifs_dump_brief_vty(vty, vrf);
} else {
/* Show all interfaces to vty. */
DEFPY (show_interface_vrf_all,
show_interface_vrf_all_cmd,
- "show interface vrf all [brief$brief]",
+ "show interface [vrf all] [brief$brief]",
SHOW_STR
"Interface status and configuration\n"
VRF_ALL_CMD_HELP_STR
int idx_ifname = 2;
int idx_name = 4;
struct interface *ifp;
- vrf_id_t vrf_id;
+ struct vrf *vrf;
interface_update_stats();
- VRF_GET_ID(vrf_id, argv[idx_name]->arg, false);
+ vrf = vrf_lookup_by_name(argv[idx_name]->arg);
+ if (!vrf) {
+ vty_out(vty, "%% VRF %s not found\n", argv[idx_name]->arg);
+ return CMD_WARNING;
+ }
- /* Specified interface print. */
- ifp = if_lookup_by_name(argv[idx_ifname]->arg, vrf_id);
+ ifp = if_lookup_by_name_vrf(argv[idx_ifname]->arg, vrf);
if (ifp == NULL) {
vty_out(vty, "%% Can't find interface %s\n",
argv[idx_ifname]->arg);
VRF_ALL_CMD_HELP_STR)
{
int idx_ifname = 2;
- struct vrf *vrf;
struct interface *ifp;
- int found = 0;
interface_update_stats();
- /* All interface print. */
- RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) {
- /* Specified interface print. */
- ifp = if_lookup_by_name(argv[idx_ifname]->arg, vrf->vrf_id);
- if (ifp) {
- if_dump_vty(vty, ifp);
- found++;
- }
- }
-
- if (!found) {
+ ifp = if_lookup_by_name_all_vrf(argv[idx_ifname]->arg);
+ if (ifp == NULL) {
vty_out(vty, "%% Can't find interface %s\n",
argv[idx_ifname]->arg);
return CMD_WARNING;
}
+ if_dump_vty(vty, ifp);
return CMD_SUCCESS;
}
-
-static void if_show_description(struct vty *vty, vrf_id_t vrf_id)
+static void if_show_description(struct vty *vty, struct vrf *vrf)
{
- struct vrf *vrf = vrf_lookup_by_id(vrf_id);
struct interface *ifp;
vty_out(vty, "Interface Status Protocol Description\n");
DEFUN (show_interface_desc,
show_interface_desc_cmd,
- "show interface description [vrf NAME]",
+ "show interface description vrf NAME",
SHOW_STR
"Interface status and configuration\n"
"Interface description\n"
VRF_CMD_HELP_STR)
{
- vrf_id_t vrf_id = VRF_DEFAULT;
+ struct vrf *vrf;
- if (argc > 3)
- VRF_GET_ID(vrf_id, argv[4]->arg, false);
+ vrf = vrf_lookup_by_name(argv[4]->arg);
+ if (!vrf) {
+ vty_out(vty, "%% VRF %s not found\n", argv[4]->arg);
+ return CMD_WARNING;
+ }
- if_show_description(vty, vrf_id);
+ if_show_description(vty, vrf);
return CMD_SUCCESS;
}
DEFUN (show_interface_desc_vrf_all,
show_interface_desc_vrf_all_cmd,
- "show interface description vrf all",
+ "show interface description [vrf all]",
SHOW_STR
"Interface status and configuration\n"
"Interface description\n"
if (!RB_EMPTY(if_name_head, &vrf->ifaces_by_name)) {
vty_out(vty, "\n\tVRF %s(%u)\n\n", VRF_LOGNAME(vrf),
vrf->vrf_id);
- if_show_description(vty, vrf->vrf_id);
+ if_show_description(vty, vrf);
}
return CMD_SUCCESS;