1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
/*
* Copyright (c) 2017 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SRC_VNET_SESSION_APPLICATION_H_
#define SRC_VNET_SESSION_APPLICATION_H_
#include <vnet/vnet.h>
#include <vnet/session/session.h>
#include <vnet/session/segment_manager.h>
typedef enum
{
APP_SERVER,
APP_CLIENT,
APP_N_TYPES
} application_type_t;
typedef struct _stream_session_cb_vft
{
/** Notify server of new segment */
int (*add_segment_callback) (u32 api_client_index, const u8 * seg_name,
u32 seg_size);
/** Notify server of newly accepted session */
int (*session_accept_callback) (stream_session_t * new_session);
/* Connection request callback */
int (*session_connected_callback) (u32 app_index, u32 api_context,
stream_session_t * s, u8 code);
/** Notify app that session is closing */
void (*session_disconnect_callback) (stream_session_t * s);
/** Notify app that session was reset */
void (*session_reset_callback) (stream_session_t * s);
/* Direct RX callback, for built-in servers */
int (*builtin_server_rx_callback) (stream_session_t * session);
/* Redirect connection to local server */
int (*redirect_connect_callback) (u32 api_client_index, void *mp);
} session_cb_vft_t;
typedef struct _application
{
/** Index in server pool */
u32 index;
/** Flags */
u32 flags;
/*
* Binary API interface to external app
*/
/** Binary API connection index, ~0 if internal */
u32 api_client_index;
/** Application listens for events on this svm queue */
unix_shared_memory_queue_t *event_queue;
/*
* Callbacks: shoulder-taps for the server/client
*/
session_cb_vft_t cb_fns;
/*
* svm segment management
*/
u32 connects_seg_manager;
/* Lookup tables for listeners. Value is segment manager index */
uword *listeners_table;
u32 first_segment_manager;
/** Segment manager properties. Shared by all segment managers */
segment_manager_properties_t sm_properties;
} application_t;
application_t *application_new ();
int
application_init (application_t * app, u32 api_client_index, u64 * options,
session_cb_vft_t * cb_fns);
void application_del (application_t * app);
application_t *application_get (u32 index);
application_t *application_get_if_valid (u32 index);
application_t *application_lookup (u32 api_client_index);
u32 application_get_index (application_t * app);
int
application_start_listen (application_t * app, session_type_t session_type,
transport_endpoint_t * tep, u64 * handle);
int application_stop_listen (application_t * srv, u64 handle);
int
application_open_session (application_t * app, session_type_t sst,
transport_endpoint_t * tep, u32 api_context);
int application_api_queue_is_full (application_t * app);
segment_manager_t *application_get_listen_segment_manager (application_t *
app,
stream_session_t *
s);
segment_manager_t *application_get_connect_segment_manager (application_t *
app);
int application_is_proxy (application_t * app);
#endif /* SRC_VNET_SESSION_APPLICATION_H_ */
/*
* fd.io coding-style-patch-verification: ON
*
* Local Variables:
* eval: (c-set-style "gnu")
* End:
*/
|