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 typedef u8 session_type_t;
26 * Application session state
30 SESSION_STATE_LISTENING,
31 SESSION_STATE_CONNECTING,
32 SESSION_STATE_ACCEPTING,
34 SESSION_STATE_CONNECTING_READY,
36 SESSION_STATE_N_STATES,
37 } stream_session_state_t;
39 /* TODO convert to macro once cleanup completed */
40 typedef struct app_session_
42 /** fifo pointers. Once allocated, these do not move */
43 svm_fifo_t *server_rx_fifo;
44 svm_fifo_t *server_tx_fifo;
47 session_type_t session_type;
50 volatile u8 session_state;
52 /** Session index in owning pool */
55 /** Application index */
59 typedef struct _stream_session_t
61 /** fifo pointers. Once allocated, these do not move */
62 svm_fifo_t *server_rx_fifo;
63 svm_fifo_t *server_tx_fifo;
66 session_type_t session_type;
69 volatile u8 session_state;
71 /** Session index in per_thread pool */
74 /** stream server pool index */
79 /** To avoid n**2 "one event per frame" check */
82 /** svm segment index where fifos were allocated */
83 u32 svm_segment_index;
85 /** Transport specific */
90 /** Parent listener session if the result of an accept */
92 /** Opaque, for general use */
96 CLIB_CACHE_LINE_ALIGN_MARK (pad);
99 typedef struct local_session_
101 /** fifo pointers. Once allocated, these do not move */
102 svm_fifo_t *server_rx_fifo;
103 svm_fifo_t *server_tx_fifo;
106 session_type_t session_type;
109 volatile u8 session_state;
117 /** Segment index where fifos were allocated */
118 u32 svm_segment_index;
122 /** Port for connection */
125 /** Has transport embedded when listener not purely local */
126 session_type_t listener_session_type;
127 u32 transport_listener_index;
138 CLIB_CACHE_LINE_ALIGN_MARK (pad);
141 #define foreach_session_endpoint_fields \
142 foreach_transport_connection_fields \
143 _(u8, transport_proto) \
145 typedef struct _session_endpoint
147 #define _(type, name) type name;
148 foreach_session_endpoint_fields
150 } session_endpoint_t;
152 typedef struct _session_endpoint_extended
154 #define _(type, name) type name;
155 foreach_session_endpoint_fields
160 } session_endpoint_extended_t;
162 #define SESSION_IP46_ZERO \
168 #define SESSION_ENDPOINT_NULL \
170 .sw_if_index = ENDPOINT_INVALID_INDEX, \
171 .ip = SESSION_IP46_ZERO, \
172 .fib_index = ENDPOINT_INVALID_INDEX, \
175 .transport_proto = 0, \
177 #define SESSION_ENDPOINT_EXT_NULL \
179 .sw_if_index = ENDPOINT_INVALID_INDEX, \
180 .ip = SESSION_IP46_ZERO, \
181 .fib_index = ENDPOINT_INVALID_INDEX, \
184 .transport_proto = 0, \
185 .app_index = ENDPOINT_INVALID_INDEX, \
186 .opaque = ENDPOINT_INVALID_INDEX, \
190 #define session_endpoint_to_transport(_sep) ((transport_endpoint_t *)_sep)
193 session_endpoint_fib_proto (session_endpoint_t * sep)
195 return sep->is_ip4 ? FIB_PROTOCOL_IP4 : FIB_PROTOCOL_IP6;
198 #endif /* SRC_VNET_SESSION_STREAM_SESSION_H_ */
201 * fd.io coding-style-patch-verification: ON
204 * eval: (c-set-style "gnu")