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_APPLICATION_H_
17 #define SRC_VNET_SESSION_APPLICATION_H_
19 #include <vnet/vnet.h>
20 #include <vnet/session/session.h>
28 typedef struct _stream_session_cb_vft
30 /** Notify server of new segment */
31 int (*add_segment_callback) (u32 api_client_index, const u8 * seg_name,
34 /** Notify server of newly accepted session */
35 int (*session_accept_callback) (stream_session_t * new_session);
37 /* Connection request callback */
38 int (*session_connected_callback) (u32 api_client_index,
39 stream_session_t * s, u8 code);
41 /** Notify app that session is closing */
42 void (*session_disconnect_callback) (stream_session_t * s);
44 /** Notify app that session was reset */
45 void (*session_reset_callback) (stream_session_t * s);
47 /* Direct RX callback, for built-in servers */
48 int (*builtin_server_rx_callback) (stream_session_t * session);
50 /* Redirect connection to local server */
51 int (*redirect_connect_callback) (u32 api_client_index, void *mp);
54 typedef struct _application
56 /** Index in server pool */
62 /** Binary API connection index, ~0 if internal */
68 /** Application listens for events on this svm queue */
69 unix_shared_memory_queue_t *event_queue;
71 /** Stream session type */
74 /* Stream server mode: accept or connect */
77 u32 session_manager_index;
80 * Bind/Listen specific
83 /** Accept cookie, for multiple session flavors ($$$ maybe) */
86 /** Index of the listen session or connect session */
89 /** Session thread index for client connect sessions */
93 * Callbacks: shoulder-taps for the server/client
95 session_cb_vft_t cb_fns;
98 application_t *application_new (application_type_t type, session_type_t sst,
99 u32 api_client_index, u32 flags,
100 session_cb_vft_t * cb_fns);
101 void application_del (application_t * app);
102 application_t *application_get (u32 index);
103 application_t *application_get_if_valid (u32 index);
104 application_t *application_lookup (u32 api_client_index);
105 u32 application_get_index (application_t * app);
108 application_server_init (application_t * server, u32 segment_size,
109 u32 add_segment_size, u32 rx_fifo_size,
110 u32 tx_fifo_size, u8 ** segment_name);
111 int application_api_queue_is_full (application_t * app);
113 #endif /* SRC_VNET_SESSION_APPLICATION_H_ */
116 * fd.io coding-style-patch-verification: ON
119 * eval: (c-set-style "gnu")