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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef SRC_VNET_SESSION_STREAM_SESSION_H_
17 #define SRC_VNET_SESSION_STREAM_SESSION_H_
19 #include <vnet/vnet.h>
20 #include <svm/svm_fifo.h>
21 #include <vnet/session/transport.h>
23 #define foreach_session_type \
31 #define _(A, a) SESSION_TYPE_##A,
38 * Application session state
42 SESSION_STATE_LISTENING,
43 SESSION_STATE_CONNECTING,
44 SESSION_STATE_ACCEPTING,
47 SESSION_STATE_N_STATES,
48 } stream_session_state_t;
50 typedef struct _stream_session_t
52 /** fifo pointers. Once allocated, these do not move */
53 svm_fifo_t *server_rx_fifo;
54 svm_fifo_t *server_tx_fifo;
60 volatile u8 session_state;
64 /** To avoid n**2 "one event per frame" check */
67 /** svm segment index where fifos were allocated */
68 u32 svm_segment_index;
70 /** Session index in per_thread pool */
73 /** Transport specific */
76 /** stream server pool index */
79 /** Parent listener session if the result of an accept */
82 CLIB_CACHE_LINE_ALIGN_MARK (pad);
85 typedef struct _session_endpoint
90 #define _(type, name) type name;
91 foreach_transport_connection_fields
96 u8 transport_proto; /**< transport protocol for session */
99 #define SESSION_IP46_ZERO \
105 #define SESSION_ENDPOINT_NULL \
107 .sw_if_index = ENDPOINT_INVALID_INDEX, \
108 .ip = SESSION_IP46_ZERO, \
109 .fib_index = ENDPOINT_INVALID_INDEX, \
112 .transport_proto = 0, \
115 #define session_endpoint_to_transport(_sep) ((transport_endpoint_t *)_sep)
118 session_endpoint_fib_proto (session_endpoint_t * sep)
120 return sep->is_ip4 ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6;
123 #endif /* SRC_VNET_SESSION_STREAM_SESSION_H_ */
126 * fd.io coding-style-patch-verification: ON
129 * eval: (c-set-style "gnu")