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>
21 #include <vnet/session/segment_manager.h>
30 typedef struct _stream_session_cb_vft
32 /** Notify server of new segment */
33 int (*add_segment_callback) (u32 api_client_index, const u8 * seg_name,
36 /** Notify server of newly accepted session */
37 int (*session_accept_callback) (stream_session_t * new_session);
39 /* Connection request callback */
40 int (*session_connected_callback) (u32 app_index, u32 api_context,
41 stream_session_t * s, u8 code);
43 /** Notify app that session is closing */
44 void (*session_disconnect_callback) (stream_session_t * s);
46 /** Notify app that session was reset */
47 void (*session_reset_callback) (stream_session_t * s);
49 /* Direct RX callback, for built-in servers */
50 int (*builtin_server_rx_callback) (stream_session_t * session);
52 /* Redirect connection to local server */
53 int (*redirect_connect_callback) (u32 api_client_index, void *mp);
56 typedef struct _application
58 /** Index in server pool */
65 * Binary API interface to external app
68 /** Binary API connection index, ~0 if internal */
71 /** Application listens for events on this svm queue */
72 unix_shared_memory_queue_t *event_queue;
75 * Callbacks: shoulder-taps for the server/client
78 session_cb_vft_t cb_fns;
81 * svm segment management
83 u32 connects_seg_manager;
85 /* Lookup tables for listeners. Value is segment manager index */
86 uword *listeners_table;
88 u32 first_segment_manager;
90 /** Segment manager properties. Shared by all segment managers */
91 segment_manager_properties_t sm_properties;
94 application_t *application_new ();
96 application_init (application_t * app, u32 api_client_index, u64 * options,
97 session_cb_vft_t * cb_fns);
98 void application_del (application_t * app);
99 application_t *application_get (u32 index);
100 application_t *application_get_if_valid (u32 index);
101 application_t *application_lookup (u32 api_client_index);
102 u32 application_get_index (application_t * app);
105 application_start_listen (application_t * app, session_type_t session_type,
106 transport_endpoint_t * tep, u64 * handle);
107 int application_stop_listen (application_t * srv, u64 handle);
109 application_open_session (application_t * app, session_type_t sst,
110 transport_endpoint_t * tep, u32 api_context);
111 int application_api_queue_is_full (application_t * app);
113 segment_manager_t *application_get_listen_segment_manager (application_t *
117 segment_manager_t *application_get_connect_segment_manager (application_t *
120 #endif /* SRC_VNET_SESSION_APPLICATION_H_ */
123 * fd.io coding-style-patch-verification: ON
126 * eval: (c-set-style "gnu")