aboutsummaryrefslogtreecommitdiffstats
path: root/vnet/vnet/interface_format.c
diff options
context:
space:
mode:
authorSean Hope <shope@cisco.com>2016-02-22 15:12:01 -0500
committerTodd Foggoa <tfoggoa@cisco.com>2016-02-29 15:41:33 -0500
commit679ea7951514736e8c8318b434ad7162b27eea84 (patch)
tree42660fc70667bd53f71eaeeea7eb1f21e96fd7a9 /vnet/vnet/interface_format.c
parent988a7c482ce1c7685816b238ac776b03c237ed8e (diff)
Add ability to override the interface name.
Export interface format functions to plugin and allow ability to show a single hardware interface index. Change-Id: If52fae2d63e97da91e1ac9a9a6fb73389b526ebc Signed-off-by: Todd Foggoa (tfoggoa) <tfoggoa@cisco.com>
Diffstat (limited to 'vnet/vnet/interface_format.c')
-rw-r--r--vnet/vnet/interface_format.c55
1 files changed, 43 insertions, 12 deletions
diff --git a/vnet/vnet/interface_format.c b/vnet/vnet/interface_format.c
index 56faea27217..1ebbfb12e06 100644
--- a/vnet/vnet/interface_format.c
+++ b/vnet/vnet/interface_format.c
@@ -128,23 +128,13 @@ u8 * format_vnet_sw_if_index_name (u8 * s, va_list * args)
vnet_get_sw_interface (vnm, sw_if_index));
}
-u8 * format_vnet_sw_interface (u8 * s, va_list * args)
+u8 * format_vnet_sw_interface_cntrs (u8 * s, vnet_interface_main_t * im,
+ vnet_sw_interface_t * si)
{
- vnet_main_t * vnm = va_arg (*args, vnet_main_t *);
- vnet_sw_interface_t * si = va_arg (*args, vnet_sw_interface_t *);
- vnet_interface_main_t * im = &vnm->interface_main;
uword indent, n_printed;
int i, j, n_counters;
static vnet_main_t ** my_vnet_mains;
- if (! si)
- return format (s, "%=32s%=5s%=16s%=16s%=16s",
- "Name", "Idx", "State", "Counter", "Count");
-
- s = format (s, "%-32U%=5d%=16U",
- format_vnet_sw_interface_name, vnm, si, si->sw_if_index,
- format_vnet_sw_interface_flags, si->flags);
-
vec_reset_length (my_vnet_mains);
indent = format_get_indent (s);
@@ -238,6 +228,47 @@ u8 * format_vnet_sw_interface (u8 * s, va_list * args)
return s;
}
+u8 * format_vnet_sw_interface (u8 * s, va_list * args)
+{
+ vnet_main_t * vnm = va_arg (*args, vnet_main_t *);
+ vnet_sw_interface_t * si = va_arg (*args, vnet_sw_interface_t *);
+ vnet_interface_main_t * im = &vnm->interface_main;
+
+ if (! si)
+ return format (s, "%=32s%=5s%=16s%=16s%=16s",
+ "Name", "Idx", "State", "Counter", "Count");
+
+ s = format (s, "%-32U%=5d%=16U",
+ format_vnet_sw_interface_name, vnm, si, si->sw_if_index,
+ format_vnet_sw_interface_flags, si->flags);
+
+ s = format_vnet_sw_interface_cntrs(s, im, si);
+
+ return s;
+}
+
+u8 * format_vnet_sw_interface_name_override (u8 * s, va_list * args)
+{
+ vnet_main_t * vnm = va_arg (*args, vnet_main_t *);
+ vnet_sw_interface_t * si = va_arg (*args, vnet_sw_interface_t *);
+ /* caller supplied display name for this interface */
+ u8* name = va_arg (*args, u8*);
+ vnet_interface_main_t * im = &vnm->interface_main;
+
+
+ if (! si)
+ return format (s, "%=32s%=5s%=16s%=16s%=16s",
+ "Name", "Idx", "State", "Counter", "Count");
+
+ s = format (s, "%-32v%=5d%=16U",
+ name, si->sw_if_index,
+ format_vnet_sw_interface_flags, si->flags);
+
+ s = format_vnet_sw_interface_cntrs(s, im, si);
+
+ return s;
+}
+
uword unformat_vnet_hw_interface (unformat_input_t * input, va_list * args)
{
vnet_main_t * vnm = va_arg (*args, vnet_main_t *);