Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 Cisco and/or its affiliates. |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. |
| 14 | */ |
| 15 | #ifndef __included_session_h__ |
| 16 | #define __included_session_h__ |
| 17 | |
| 18 | #include <vnet/session/transport.h> |
| 19 | #include <vlibmemory/unix_shared_memory_queue.h> |
| 20 | #include <vlibmemory/api.h> |
| 21 | #include <vppinfra/sparse_vec.h> |
| 22 | #include <svm/svm_fifo_segment.h> |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 23 | #include <vnet/session/session_debug.h> |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame^] | 24 | #include <vnet/session/segment_manager.h> |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 25 | |
| 26 | #define HALF_OPEN_LOOKUP_INVALID_VALUE ((u64)~0) |
| 27 | #define INVALID_INDEX ((u32)~0) |
| 28 | |
| 29 | /* TODO decide how much since we have pre-data as well */ |
| 30 | #define MAX_HDRS_LEN 100 /* Max number of bytes for headers */ |
| 31 | |
| 32 | typedef enum |
| 33 | { |
| 34 | FIFO_EVENT_SERVER_RX, |
| 35 | FIFO_EVENT_SERVER_TX, |
| 36 | FIFO_EVENT_TIMEOUT, |
| 37 | FIFO_EVENT_SERVER_EXIT, |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 38 | FIFO_EVENT_BUILTIN_RX |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 39 | } fifo_event_type_t; |
| 40 | |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 41 | #define foreach_session_input_error \ |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 42 | _(NO_SESSION, "No session drops") \ |
| 43 | _(NO_LISTENER, "No listener for dst port drops") \ |
| 44 | _(ENQUEUED, "Packets pushed into rx fifo") \ |
| 45 | _(NOT_READY, "Session not ready packets") \ |
| 46 | _(FIFO_FULL, "Packets dropped for lack of rx fifo space") \ |
| 47 | _(EVENT_FIFO_FULL, "Events not sent for lack of event fifo space") \ |
| 48 | _(API_QUEUE_FULL, "Sessions not created for lack of API queue space") \ |
| 49 | _(NEW_SEG_NO_SPACE, "Created segment, couldn't allocate a fifo pair") \ |
| 50 | _(NO_SPACE, "Couldn't allocate a fifo pair") |
| 51 | |
| 52 | typedef enum |
| 53 | { |
| 54 | #define _(sym,str) SESSION_ERROR_##sym, |
| 55 | foreach_session_input_error |
| 56 | #undef _ |
| 57 | SESSION_N_ERROR, |
| 58 | } session_error_t; |
| 59 | |
| 60 | /* Event queue input node static next indices */ |
| 61 | typedef enum |
| 62 | { |
| 63 | SESSION_QUEUE_NEXT_DROP, |
| 64 | SESSION_QUEUE_NEXT_TCP_IP4_OUTPUT, |
| 65 | SESSION_QUEUE_NEXT_IP4_LOOKUP, |
| 66 | SESSION_QUEUE_NEXT_TCP_IP6_OUTPUT, |
| 67 | SESSION_QUEUE_NEXT_IP6_LOOKUP, |
| 68 | SESSION_QUEUE_N_NEXT, |
| 69 | } session_queue_next_t; |
| 70 | |
| 71 | #define foreach_session_type \ |
| 72 | _(IP4_TCP, ip4_tcp) \ |
| 73 | _(IP4_UDP, ip4_udp) \ |
| 74 | _(IP6_TCP, ip6_tcp) \ |
| 75 | _(IP6_UDP, ip6_udp) |
| 76 | |
| 77 | typedef enum |
| 78 | { |
| 79 | #define _(A, a) SESSION_TYPE_##A, |
| 80 | foreach_session_type |
| 81 | #undef _ |
| 82 | SESSION_N_TYPES, |
| 83 | } session_type_t; |
| 84 | |
| 85 | /* |
| 86 | * Application session state |
| 87 | */ |
| 88 | typedef enum |
| 89 | { |
| 90 | SESSION_STATE_LISTENING, |
| 91 | SESSION_STATE_CONNECTING, |
| 92 | SESSION_STATE_READY, |
| 93 | SESSION_STATE_CLOSED, |
| 94 | SESSION_STATE_N_STATES, |
| 95 | } stream_session_state_t; |
| 96 | |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 97 | /* *INDENT-OFF* */ |
| 98 | typedef CLIB_PACKED (struct { |
| 99 | svm_fifo_t * fifo; |
| 100 | u8 event_type; |
| 101 | u16 event_id; |
| 102 | }) session_fifo_event_t; |
| 103 | /* *INDENT-ON* */ |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 104 | |
| 105 | typedef struct _stream_session_t |
| 106 | { |
Florin Coras | d79b41e | 2017-03-04 05:37:52 -0800 | [diff] [blame] | 107 | /** fifo pointers. Once allocated, these do not move */ |
| 108 | svm_fifo_t *server_rx_fifo; |
| 109 | svm_fifo_t *server_tx_fifo; |
| 110 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame^] | 111 | /** svm segment index where fifos were allocated */ |
| 112 | u32 svm_segment_index; |
| 113 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 114 | /** Type */ |
| 115 | u8 session_type; |
| 116 | |
| 117 | /** State */ |
| 118 | u8 session_state; |
| 119 | |
Florin Coras | d79b41e | 2017-03-04 05:37:52 -0800 | [diff] [blame] | 120 | u8 thread_index; |
| 121 | |
| 122 | /** used during unbind processing */ |
| 123 | u8 is_deleted; |
| 124 | |
| 125 | /** To avoid n**2 "one event per frame" check */ |
| 126 | u8 enqueue_epoch; |
| 127 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 128 | /** Session index in per_thread pool */ |
| 129 | u32 session_index; |
| 130 | |
| 131 | /** Transport specific */ |
| 132 | u32 connection_index; |
| 133 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 134 | /** Application specific */ |
| 135 | u32 pid; |
| 136 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 137 | /** stream server pool index */ |
| 138 | u32 app_index; |
| 139 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame^] | 140 | /** Parent listener session if the result of an accept */ |
| 141 | u32 listener_index; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 142 | } stream_session_t; |
| 143 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 144 | /* Forward definition */ |
| 145 | typedef struct _session_manager_main session_manager_main_t; |
| 146 | |
| 147 | typedef int |
| 148 | (session_fifo_rx_fn) (vlib_main_t * vm, vlib_node_runtime_t * node, |
| 149 | session_manager_main_t * smm, |
| 150 | session_fifo_event_t * e0, stream_session_t * s0, |
| 151 | u32 thread_index, int *n_tx_pkts); |
| 152 | |
Florin Coras | d79b41e | 2017-03-04 05:37:52 -0800 | [diff] [blame] | 153 | extern session_fifo_rx_fn session_tx_fifo_peek_and_snd; |
| 154 | extern session_fifo_rx_fn session_tx_fifo_dequeue_and_snd; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 155 | |
| 156 | struct _session_manager_main |
| 157 | { |
| 158 | /** Lookup tables for established sessions and listeners */ |
| 159 | clib_bihash_16_8_t v4_session_hash; |
| 160 | clib_bihash_48_8_t v6_session_hash; |
| 161 | |
| 162 | /** Lookup tables for half-open sessions */ |
| 163 | clib_bihash_16_8_t v4_half_open_hash; |
| 164 | clib_bihash_48_8_t v6_half_open_hash; |
| 165 | |
| 166 | /** Per worker thread session pools */ |
| 167 | stream_session_t **sessions; |
| 168 | |
| 169 | /** Pool of listen sessions. Same type as stream sessions to ease lookups */ |
| 170 | stream_session_t *listen_sessions[SESSION_N_TYPES]; |
| 171 | |
| 172 | /** Sparse vector to map dst port to stream server */ |
| 173 | u16 *stream_server_by_dst_port[SESSION_N_TYPES]; |
| 174 | |
| 175 | /** per-worker enqueue epoch counters */ |
| 176 | u8 *current_enqueue_epoch; |
| 177 | |
| 178 | /** Per-worker thread vector of sessions to enqueue */ |
| 179 | u32 **session_indices_to_enqueue_by_thread; |
| 180 | |
| 181 | /** per-worker tx buffer free lists */ |
| 182 | u32 **tx_buffers; |
| 183 | |
| 184 | /** Per worker-thread vector of partially read events */ |
| 185 | session_fifo_event_t **evts_partially_read; |
| 186 | |
| 187 | /** per-worker active event vectors */ |
| 188 | session_fifo_event_t **fifo_events; |
| 189 | |
| 190 | /** vpp fifo event queue */ |
| 191 | unix_shared_memory_queue_t **vpp_event_queues; |
| 192 | |
| 193 | /** Unique segment name counter */ |
| 194 | u32 unique_segment_name_counter; |
| 195 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 196 | /** Per transport rx function that can either dequeue or peek */ |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 197 | session_fifo_rx_fn *session_tx_fns[SESSION_N_TYPES]; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 198 | |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 199 | u8 is_enabled; |
| 200 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 201 | /* Convenience */ |
| 202 | vlib_main_t *vlib_main; |
| 203 | vnet_main_t *vnet_main; |
Florin Coras | 3e350af | 2017-03-30 02:54:28 -0700 | [diff] [blame] | 204 | |
| 205 | #if SESSION_DBG |
| 206 | /** |
| 207 | * last event poll time by thread |
| 208 | * Debug only. Will cause false cache-line sharing as-is |
| 209 | */ |
| 210 | f64 *last_event_poll_by_thread; |
| 211 | #endif |
| 212 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 213 | }; |
| 214 | |
| 215 | extern session_manager_main_t session_manager_main; |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 216 | extern vlib_node_registration_t session_queue_node; |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 217 | |
| 218 | /* |
| 219 | * Session manager function |
| 220 | */ |
| 221 | always_inline session_manager_main_t * |
| 222 | vnet_get_session_manager_main () |
| 223 | { |
| 224 | return &session_manager_main; |
| 225 | } |
| 226 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 227 | /* |
| 228 | * Stream session functions |
| 229 | */ |
| 230 | |
| 231 | stream_session_t *stream_session_lookup_listener4 (ip4_address_t * lcl, |
| 232 | u16 lcl_port, u8 proto); |
| 233 | stream_session_t *stream_session_lookup4 (ip4_address_t * lcl, |
| 234 | ip4_address_t * rmt, u16 lcl_port, |
| 235 | u16 rmt_port, u8 proto, |
| 236 | u32 thread_index); |
| 237 | stream_session_t *stream_session_lookup_listener6 (ip6_address_t * lcl, |
| 238 | u16 lcl_port, u8 proto); |
| 239 | stream_session_t *stream_session_lookup6 (ip6_address_t * lcl, |
| 240 | ip6_address_t * rmt, u16 lcl_port, |
| 241 | u16 rmt_port, u8, u32 thread_index); |
| 242 | transport_connection_t |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 243 | * stream_session_lookup_transport4 (ip4_address_t * lcl, |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 244 | ip4_address_t * rmt, u16 lcl_port, |
| 245 | u16 rmt_port, u8 proto, |
| 246 | u32 thread_index); |
| 247 | transport_connection_t |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 248 | * stream_session_lookup_transport6 (ip6_address_t * lcl, |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 249 | ip6_address_t * rmt, u16 lcl_port, |
| 250 | u16 rmt_port, u8 proto, |
| 251 | u32 thread_index); |
| 252 | stream_session_t *stream_session_lookup_listener (ip46_address_t * lcl, |
| 253 | u16 lcl_port, u8 proto); |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame^] | 254 | void stream_session_table_add_for_tc (transport_connection_t * tc, u64 value); |
| 255 | int stream_session_table_del_for_tc (transport_connection_t * tc); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 256 | |
| 257 | always_inline stream_session_t * |
| 258 | stream_session_get_tsi (u64 ti_and_si, u32 thread_index) |
| 259 | { |
| 260 | ASSERT ((u32) (ti_and_si >> 32) == thread_index); |
| 261 | return pool_elt_at_index (session_manager_main.sessions[thread_index], |
| 262 | ti_and_si & 0xFFFFFFFFULL); |
| 263 | } |
| 264 | |
| 265 | always_inline stream_session_t * |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame^] | 266 | stream_session_get (u32 si, u32 thread_index) |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 267 | { |
| 268 | return pool_elt_at_index (session_manager_main.sessions[thread_index], si); |
| 269 | } |
| 270 | |
| 271 | always_inline stream_session_t * |
| 272 | stream_session_get_if_valid (u64 si, u32 thread_index) |
| 273 | { |
| 274 | if (thread_index >= vec_len (session_manager_main.sessions)) |
| 275 | return 0; |
| 276 | |
| 277 | if (pool_is_free_index (session_manager_main.sessions[thread_index], si)) |
| 278 | return 0; |
| 279 | |
| 280 | return pool_elt_at_index (session_manager_main.sessions[thread_index], si); |
| 281 | } |
| 282 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame^] | 283 | always_inline u64 |
| 284 | stream_session_handle (stream_session_t * s) |
| 285 | { |
| 286 | return ((u64) s->thread_index << 32) | (u64) s->session_index; |
| 287 | } |
| 288 | |
| 289 | always_inline u32 |
| 290 | stream_session_index_from_handle (u64 handle) |
| 291 | { |
| 292 | return handle & 0xFFFFFFFF; |
| 293 | } |
| 294 | |
| 295 | always_inline u32 |
| 296 | stream_session_thread_from_handle (u64 handle) |
| 297 | { |
| 298 | return handle >> 32; |
| 299 | } |
| 300 | |
| 301 | always_inline void |
| 302 | stream_session_parse_handle (u64 handle, u32 * index, u32 * thread_index) |
| 303 | { |
| 304 | *index = stream_session_index_from_handle (handle); |
| 305 | *thread_index = stream_session_thread_from_handle (handle); |
| 306 | } |
| 307 | |
| 308 | always_inline stream_session_t * |
| 309 | stream_session_get_from_handle (u64 handle) |
| 310 | { |
| 311 | session_manager_main_t *smm = &session_manager_main; |
| 312 | return pool_elt_at_index (smm->sessions[stream_session_thread_from_handle |
| 313 | (handle)], |
| 314 | stream_session_index_from_handle (handle)); |
| 315 | } |
| 316 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 317 | always_inline stream_session_t * |
| 318 | stream_session_listener_get (u8 sst, u64 si) |
| 319 | { |
| 320 | return pool_elt_at_index (session_manager_main.listen_sessions[sst], si); |
| 321 | } |
| 322 | |
| 323 | always_inline u32 |
| 324 | stream_session_get_index (stream_session_t * s) |
| 325 | { |
| 326 | if (s->session_state == SESSION_STATE_LISTENING) |
| 327 | return s - session_manager_main.listen_sessions[s->session_type]; |
| 328 | |
| 329 | return s - session_manager_main.sessions[s->thread_index]; |
| 330 | } |
| 331 | |
| 332 | always_inline u32 |
Florin Coras | 6792ec0 | 2017-03-13 03:49:51 -0700 | [diff] [blame] | 333 | stream_session_max_rx_enqueue (transport_connection_t * tc) |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 334 | { |
| 335 | stream_session_t *s = stream_session_get (tc->s_index, tc->thread_index); |
| 336 | return svm_fifo_max_enqueue (s->server_rx_fifo); |
| 337 | } |
| 338 | |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 339 | always_inline u32 |
| 340 | stream_session_fifo_size (transport_connection_t * tc) |
| 341 | { |
| 342 | stream_session_t *s = stream_session_get (tc->s_index, tc->thread_index); |
| 343 | return s->server_rx_fifo->nitems; |
| 344 | } |
| 345 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 346 | int |
| 347 | stream_session_enqueue_data (transport_connection_t * tc, u8 * data, u16 len, |
| 348 | u8 queue_event); |
| 349 | u32 |
| 350 | stream_session_peek_bytes (transport_connection_t * tc, u8 * buffer, |
| 351 | u32 offset, u32 max_bytes); |
| 352 | u32 stream_session_dequeue_drop (transport_connection_t * tc, u32 max_bytes); |
| 353 | |
| 354 | void |
| 355 | stream_session_connect_notify (transport_connection_t * tc, u8 sst, |
| 356 | u8 is_fail); |
Florin Coras | e69f495 | 2017-03-07 10:06:24 -0800 | [diff] [blame] | 357 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 358 | void stream_session_accept_notify (transport_connection_t * tc); |
| 359 | void stream_session_disconnect_notify (transport_connection_t * tc); |
| 360 | void stream_session_delete_notify (transport_connection_t * tc); |
| 361 | void stream_session_reset_notify (transport_connection_t * tc); |
| 362 | int |
| 363 | stream_session_accept (transport_connection_t * tc, u32 listener_index, |
| 364 | u8 sst, u8 notify); |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame^] | 365 | int |
| 366 | stream_session_open (u32 app_index, session_type_t st, |
| 367 | transport_endpoint_t * tep, |
| 368 | transport_connection_t ** tc); |
| 369 | int stream_session_listen (stream_session_t * s, transport_endpoint_t * tep); |
| 370 | int stream_session_stop_listen (stream_session_t * s); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 371 | void stream_session_disconnect (stream_session_t * s); |
| 372 | void stream_session_cleanup (stream_session_t * s); |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 373 | |
| 374 | u8 *format_stream_session (u8 * s, va_list * args); |
| 375 | |
| 376 | void session_register_transport (u8 type, const transport_proto_vft_t * vft); |
| 377 | transport_proto_vft_t *session_get_transport_vft (u8 type); |
| 378 | |
Florin Coras | e04c299 | 2017-03-01 08:17:34 -0800 | [diff] [blame] | 379 | clib_error_t *vnet_session_enable_disable (vlib_main_t * vm, u8 is_en); |
| 380 | |
Florin Coras | 6cf30ad | 2017-04-04 23:08:23 -0700 | [diff] [blame^] | 381 | always_inline unix_shared_memory_queue_t * |
| 382 | session_manager_get_vpp_event_queue (u32 thread_index) |
| 383 | { |
| 384 | return session_manager_main.vpp_event_queues[thread_index]; |
| 385 | } |
| 386 | |
| 387 | int session_manager_flush_enqueue_events (u32 thread_index); |
| 388 | |
| 389 | always_inline u64 |
| 390 | listen_session_get_handle (stream_session_t * s) |
| 391 | { |
| 392 | ASSERT (s->session_state == SESSION_STATE_LISTENING); |
| 393 | return ((u64) s->session_type << 32) | s->session_index; |
| 394 | } |
| 395 | |
| 396 | always_inline stream_session_t * |
| 397 | listen_session_get_from_handle (u64 handle) |
| 398 | { |
| 399 | session_manager_main_t *smm = &session_manager_main; |
| 400 | stream_session_t *s; |
| 401 | u32 type, index; |
| 402 | type = handle >> 32; |
| 403 | index = handle & 0xFFFFFFFF; |
| 404 | |
| 405 | if (pool_is_free_index (smm->listen_sessions[type], index)) |
| 406 | return 0; |
| 407 | |
| 408 | s = pool_elt_at_index (smm->listen_sessions[type], index); |
| 409 | ASSERT (s->session_state == SESSION_STATE_LISTENING); |
| 410 | return s; |
| 411 | } |
| 412 | |
| 413 | always_inline stream_session_t * |
| 414 | listen_session_new (session_type_t type) |
| 415 | { |
| 416 | stream_session_t *s; |
| 417 | pool_get (session_manager_main.listen_sessions[type], s); |
| 418 | memset (s, 0, sizeof (*s)); |
| 419 | |
| 420 | s->session_type = type; |
| 421 | s->session_state = SESSION_STATE_LISTENING; |
| 422 | s->session_index = s - session_manager_main.listen_sessions[type]; |
| 423 | |
| 424 | return s; |
| 425 | } |
| 426 | |
| 427 | always_inline stream_session_t * |
| 428 | listen_session_get (session_type_t type, u32 index) |
| 429 | { |
| 430 | return pool_elt_at_index (session_manager_main.listen_sessions[type], |
| 431 | index); |
| 432 | } |
| 433 | |
| 434 | always_inline void |
| 435 | listen_session_del (stream_session_t * s) |
| 436 | { |
| 437 | pool_put (session_manager_main.listen_sessions[s->session_type], s); |
| 438 | } |
| 439 | |
| 440 | always_inline u8 |
| 441 | session_manager_is_enabled () |
| 442 | { |
| 443 | return session_manager_main.is_enabled == 1; |
| 444 | } |
| 445 | |
Dave Barach | 68b0fb0 | 2017-02-28 15:15:56 -0500 | [diff] [blame] | 446 | #endif /* __included_session_h__ */ |
| 447 | |
| 448 | /* |
| 449 | * fd.io coding-style-patch-verification: ON |
| 450 | * |
| 451 | * Local Variables: |
| 452 | * eval: (c-set-style "gnu") |
| 453 | * End: |
| 454 | */ |