summaryrefslogtreecommitdiffstats
path: root/src/vnet/session
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
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')
-rw-r--r--src/vnet/session/session_cli.c52
-rw-r--r--src/vnet/session/session_types.h21
2 files changed, 68 insertions, 5 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)
{
diff --git a/src/vnet/session/session_types.h b/src/vnet/session/session_types.h
index 4b187a69480..6d7f84f4c3f 100644
--- a/src/vnet/session/session_types.h
+++ b/src/vnet/session/session_types.h
@@ -147,12 +147,25 @@ typedef enum
SESSION_N_STATES,
} session_state_t;
+#define foreach_session_flag \
+ _(RX_EVT, "rx-event") \
+ _(PROXY, "proxy") \
+ _(CUSTOM_TX, "custom-tx") \
+ _(IS_MIGRATING, "migrating") \
+
+typedef enum session_flags_bits_
+{
+#define _(sym, str) SESSION_F_BIT_ ## sym,
+ foreach_session_flag
+#undef _
+ SESSION_N_FLAGS
+} session_flag_bits_t;
+
typedef enum session_flags_
{
- SESSION_F_RX_EVT = 1,
- SESSION_F_PROXY = (1 << 1),
- SESSION_F_CUSTOM_TX = (1 << 2),
- SESSION_F_IS_MIGRATING = (1 << 3),
+#define _(sym, str) SESSION_F_ ## sym = 1 << SESSION_F_BIT_ ## sym,
+ foreach_session_flag
+#undef _
} session_flags_t;
typedef struct session_