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,
49 session_fifo_event_t * ep);
51 /* Redirect connection to local server */
52 int (*redirect_connect_callback) (u32 api_client_index, void *mp);
55 typedef struct _application
57 /** Index in server pool */
63 /** Binary API connection index, ~0 if internal */
69 /** Application listens for events on this svm queue */
70 unix_shared_memory_queue_t *event_queue;
72 /** Stream session type */
75 /* Stream server mode: accept or connect */
78 u32 session_manager_index;
81 * Bind/Listen specific
84 /** Accept cookie, for multiple session flavors ($$$ maybe) */
87 /** Index of the listen session or connect session */
90 /** Session thread index for client connect sessions */
94 * Callbacks: shoulder-taps for the server/client
96 session_cb_vft_t cb_fns;
99 application_t *application_new (application_type_t type, session_type_t sst,
100 u32 api_client_index, u32 flags,
101 session_cb_vft_t * cb_fns);
102 void application_del (application_t * app);
103 application_t *application_get (u32 index);
104 application_t *application_get_if_valid (u32 index);
105 application_t *application_lookup (u32 api_client_index);
106 u32 application_get_index (application_t * app);
109 application_server_init (application_t * server, u32 segment_size,
110 u32 add_segment_size, u32 rx_fifo_size,
111 u32 tx_fifo_size, u8 ** segment_name);
112 int application_api_queue_is_full (application_t * app);
114 #endif /* SRC_VNET_SESSION_APPLICATION_H_ */
117 * fd.io coding-style-patch-verification: ON
120 * eval: (c-set-style "gnu")