blob: 35caae85dbb6d8ca15c76bd2affc7d7aa7e2bb60 [file] [log] [blame]
Dave Barach68b0fb02017-02-28 15:15:56 -05001/*
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:
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
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.
14 */
15
16#ifndef SRC_VNET_SESSION_APPLICATION_H_
17#define SRC_VNET_SESSION_APPLICATION_H_
18
19#include <vnet/vnet.h>
20#include <vnet/session/session.h>
Florin Coras6cf30ad2017-04-04 23:08:23 -070021#include <vnet/session/segment_manager.h>
Dave Barach68b0fb02017-02-28 15:15:56 -050022
23typedef enum
24{
25 APP_SERVER,
Florin Coras6cf30ad2017-04-04 23:08:23 -070026 APP_CLIENT,
27 APP_N_TYPES
Dave Barach68b0fb02017-02-28 15:15:56 -050028} application_type_t;
29
30typedef struct _stream_session_cb_vft
31{
32 /** Notify server of new segment */
33 int (*add_segment_callback) (u32 api_client_index, const u8 * seg_name,
34 u32 seg_size);
35
36 /** Notify server of newly accepted session */
37 int (*session_accept_callback) (stream_session_t * new_session);
38
39 /* Connection request callback */
Florin Coras6cf30ad2017-04-04 23:08:23 -070040 int (*session_connected_callback) (u32 app_index, u32 api_context,
Dave Barach68b0fb02017-02-28 15:15:56 -050041 stream_session_t * s, u8 code);
42
43 /** Notify app that session is closing */
44 void (*session_disconnect_callback) (stream_session_t * s);
45
46 /** Notify app that session was reset */
47 void (*session_reset_callback) (stream_session_t * s);
48
49 /* Direct RX callback, for built-in servers */
Florin Coras6792ec02017-03-13 03:49:51 -070050 int (*builtin_server_rx_callback) (stream_session_t * session);
Dave Barach68b0fb02017-02-28 15:15:56 -050051
52 /* Redirect connection to local server */
53 int (*redirect_connect_callback) (u32 api_client_index, void *mp);
54} session_cb_vft_t;
55
56typedef struct _application
57{
58 /** Index in server pool */
59 u32 index;
60
61 /** Flags */
62 u32 flags;
63
Florin Coras6cf30ad2017-04-04 23:08:23 -070064 /*
65 * Binary API interface to external app
66 */
67
Dave Barach68b0fb02017-02-28 15:15:56 -050068 /** Binary API connection index, ~0 if internal */
69 u32 api_client_index;
70
Dave Barach68b0fb02017-02-28 15:15:56 -050071 /** Application listens for events on this svm queue */
72 unix_shared_memory_queue_t *event_queue;
73
Dave Barach68b0fb02017-02-28 15:15:56 -050074 /*
75 * Callbacks: shoulder-taps for the server/client
76 */
Florin Coras6cf30ad2017-04-04 23:08:23 -070077
Dave Barach68b0fb02017-02-28 15:15:56 -050078 session_cb_vft_t cb_fns;
Florin Coras6cf30ad2017-04-04 23:08:23 -070079
80 /*
81 * svm segment management
82 */
83 u32 connects_seg_manager;
84
85 /* Lookup tables for listeners. Value is segment manager index */
86 uword *listeners_table;
87
88 u32 first_segment_manager;
89
90 /** Segment manager properties. Shared by all segment managers */
91 segment_manager_properties_t sm_properties;
Dave Barach68b0fb02017-02-28 15:15:56 -050092} application_t;
93
Florin Coras6cf30ad2017-04-04 23:08:23 -070094application_t *application_new ();
95int
96application_init (application_t * app, u32 api_client_index, u64 * options,
97 session_cb_vft_t * cb_fns);
Dave Barach68b0fb02017-02-28 15:15:56 -050098void application_del (application_t * app);
99application_t *application_get (u32 index);
Florin Corase04c2992017-03-01 08:17:34 -0800100application_t *application_get_if_valid (u32 index);
Dave Barach68b0fb02017-02-28 15:15:56 -0500101application_t *application_lookup (u32 api_client_index);
102u32 application_get_index (application_t * app);
103
104int
Florin Coras6cf30ad2017-04-04 23:08:23 -0700105application_start_listen (application_t * app, session_type_t session_type,
106 transport_endpoint_t * tep, u64 * handle);
107int application_stop_listen (application_t * srv, u64 handle);
108int
109application_open_session (application_t * app, session_type_t sst,
110 transport_endpoint_t * tep, u32 api_context);
Dave Barach68b0fb02017-02-28 15:15:56 -0500111int application_api_queue_is_full (application_t * app);
112
Florin Coras6cf30ad2017-04-04 23:08:23 -0700113segment_manager_t *application_get_listen_segment_manager (application_t *
114 app,
115 stream_session_t *
116 s);
117segment_manager_t *application_get_connect_segment_manager (application_t *
118 app);
119
Dave Barach68b0fb02017-02-28 15:15:56 -0500120#endif /* SRC_VNET_SESSION_APPLICATION_H_ */
121
122/*
123 * fd.io coding-style-patch-verification: ON
124 *
125 * Local Variables:
126 * eval: (c-set-style "gnu")
127 * End:
128 */