+ u32 session_index, thread_index;
+ session_parse_handle (handle, &session_index, &thread_index);
+ return pool_elt_at_index (smm->sessions[thread_index], session_index);
+}
+
+always_inline stream_session_t *
+session_get_from_handle_if_valid (session_handle_t handle)
+{
+ u32 session_index, thread_index;
+ session_parse_handle (handle, &session_index, &thread_index);
+ return session_get_if_valid (session_index, thread_index);
+}
+
+always_inline u8
+session_handle_is_local (session_handle_t handle)
+{
+ if ((handle >> 32) == SESSION_LOCAL_TABLE_PREFIX)
+ return 1;
+ return 0;
+}
+
+always_inline transport_proto_t
+session_type_transport_proto (session_type_t st)
+{
+ return (st >> 1);
+}
+
+always_inline transport_proto_t
+session_get_transport_proto (stream_session_t * s)
+{
+ return (s->session_type >> 1);
+}
+
+always_inline fib_protocol_t
+session_get_fib_proto (stream_session_t * s)
+{
+ u8 is_ip4 = s->session_type & 1;
+ return (is_ip4 ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6);
+}
+
+always_inline session_type_t
+session_type_from_proto_and_ip (transport_proto_t proto, u8 is_ip4)
+{
+ return (proto << 1 | is_ip4);
+}
+
+always_inline u8
+session_has_transport (stream_session_t * s)
+{
+ return (session_get_transport_proto (s) != TRANSPORT_PROTO_NONE);