+ return tuple_is_set;
+}
+
+uword
+unformat_session_state (unformat_input_t * input, va_list * args)
+{
+ session_state_t *state = va_arg (*args, session_state_t *);
+ u8 *state_vec = 0;
+ int rv = 0;
+
+#define _(sym, str) \
+ if (unformat (input, str)) \
+ { \
+ *state = SESSION_STATE_ ## sym; \
+ rv = 1; \
+ goto done; \
+ }
+ foreach_session_state
+#undef _
+done:
+ vec_free (state_vec);
+ return rv;
+}
+
+uword
+unformat_session (unformat_input_t * input, va_list * args)
+{
+ session_t **result = va_arg (*args, session_t **);
+ u32 lcl_port = 0, rmt_port = 0, fib_index = 0;
+ ip46_address_t lcl, rmt;
+ session_t *s;
+ u8 proto = ~0;
+ u8 is_ip4 = 0;
+
+ if (!unformat (input, "%U", unformat_stream_session_id, &proto, &fib_index,
+ &lcl, &rmt, &lcl_port, &rmt_port, &is_ip4))
+ return 0;
+
+ if (is_ip4)
+ s = session_lookup_safe4 (fib_index, &lcl.ip4, &rmt.ip4,
+ clib_host_to_net_u16 (lcl_port),
+ clib_host_to_net_u16 (rmt_port), proto);
+ else
+ s = session_lookup_safe6 (fib_index, &lcl.ip6, &rmt.ip6,
+ clib_host_to_net_u16 (lcl_port),
+ clib_host_to_net_u16 (rmt_port), proto);
+ if (s)
+ {
+ *result = s;
+ session_pool_remove_peeker (s->thread_index);
+ return 1;
+ }
+ return 0;
+}
+
+uword
+unformat_transport_connection (unformat_input_t * input, va_list * args)
+{
+ transport_connection_t **result = va_arg (*args, transport_connection_t **);
+ u32 suggested_proto = va_arg (*args, u32);
+ transport_connection_t *tc;
+ u8 proto = ~0;
+ ip46_address_t lcl, rmt;
+ u32 lcl_port = 0, rmt_port = 0, fib_index = 0;
+ u8 is_ip4 = 0;
+
+ if (!unformat (input, "%U", unformat_stream_session_id, &fib_index, &proto,
+ &lcl, &rmt, &lcl_port, &rmt_port, &is_ip4))
+ return 0;
+
+ proto = (proto == (u8) ~ 0) ? suggested_proto : proto;
+ if (proto == (u8) ~ 0)
+ return 0;
+ if (is_ip4)
+ tc = session_lookup_connection4 (fib_index, &lcl.ip4, &rmt.ip4,
+ clib_host_to_net_u16 (lcl_port),
+ clib_host_to_net_u16 (rmt_port), proto);
+ else
+ tc = session_lookup_connection6 (fib_index, &lcl.ip6, &rmt.ip6,
+ clib_host_to_net_u16 (lcl_port),
+ clib_host_to_net_u16 (rmt_port), proto);
+
+ if (tc)
+ {
+ *result = tc;
+ return 1;
+ }
+ return 0;
+}
+
+static void
+session_cli_show_all_sessions (vlib_main_t * vm, int verbose)
+{
+ session_main_t *smm = &session_main;
+ u32 n_closed, thread_index;
+ session_t *pool, *s;
+
+ for (thread_index = 0; thread_index < vec_len (smm->wrk); thread_index++)