aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/session/session_cli.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-10-23 19:28:08 -0700
committerDave Barach <openvpp@barachs.net>2019-11-19 15:06:13 +0000
commit91f90d0826e1789de2b2344686bd393115167e89 (patch)
tree661cc04c247d220bd815e7a29befcc97623f7271 /src/vnet/session/session_cli.c
parent1b81e6ef66cbce15ba1b05904732f92251d531cd (diff)
session: more show cli output
Type: feature Change-Id: I7f64fb1a13d90fa1679ca2ca35206092682f0c8f Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet/session/session_cli.c')
-rw-r--r--src/vnet/session/session_cli.c52
1 files changed, 51 insertions, 1 deletions
diff --git a/src/vnet/session/session_cli.c b/src/vnet/session/session_cli.c
index b03353e564a..9264f47cca7 100644
--- a/src/vnet/session/session_cli.c
+++ b/src/vnet/session/session_cli.c
@@ -43,6 +43,52 @@ format_session_fifos (u8 * s, va_list * args)
return s;
}
+const char *session_state_str[] = {
+#define _(sym, str) str,
+ foreach_session_state
+#undef _
+};
+
+u8 *
+format_session_state (u8 * s, va_list * args)
+{
+ session_t *ss = va_arg (*args, session_t *);
+
+ if (ss->session_state < SESSION_N_STATES)
+ s = format (s, "%s", session_state_str[ss->session_state]);
+ else
+ s = format (s, "UNKNOWN STATE (%d)", ss->session_state);
+
+ return s;
+}
+
+const char *session_flags_str[] = {
+#define _(sym, str) str,
+ foreach_session_flag
+#undef _
+};
+
+u8 *
+format_session_flags (u8 * s, va_list * args)
+{
+ session_t *ss = va_arg (*args, session_t *);
+ int i, last = -1;
+
+ for (i = 0; i < SESSION_N_FLAGS; i++)
+ if (ss->flags & (1 << i))
+ last = i;
+
+ for (i = 0; i < last; i++)
+ {
+ if (ss->flags & (1 << i))
+ s = format (s, "%s, ", session_flags_str[i]);
+ }
+ if (last >= 0)
+ s = format (s, "%s", session_flags_str[last]);
+
+ return s;
+}
+
/**
* Format stream session as per the following format
*
@@ -85,7 +131,11 @@ format_session (u8 * s, va_list * args)
if (verbose == 1)
s = format (s, "%v", str);
if (verbose > 1)
- s = format (s, "%U", format_session_fifos, ss, verbose);
+ {
+ s = format (s, "%U", format_session_fifos, ss, verbose);
+ s = format (s, " session: state: %U flags: %U\n",
+ format_session_state, ss, format_session_flags, ss);
+ }
}
else if (ss->session_state == SESSION_STATE_LISTENING)
{