Cleanup URI code and TCP bugfixing
[vpp.git] / src / vnet / session / application.h
1 /*
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>
21
22 typedef enum
23 {
24   APP_SERVER,
25   APP_CLIENT
26 } application_type_t;
27
28 typedef struct _stream_session_cb_vft
29 {
30   /** Notify server of new segment */
31   int (*add_segment_callback) (u32 api_client_index, const u8 * seg_name,
32                                u32 seg_size);
33
34   /** Notify server of newly accepted session */
35   int (*session_accept_callback) (stream_session_t * new_session);
36
37   /* Connection request callback */
38   int (*session_connected_callback) (u32 api_client_index,
39                                      stream_session_t * s, u8 code);
40
41   /** Notify app that session is closing */
42   void (*session_disconnect_callback) (stream_session_t * s);
43
44   /** Notify app that session was reset */
45   void (*session_reset_callback) (stream_session_t * s);
46
47   /* Direct RX callback, for built-in servers */
48   int (*builtin_server_rx_callback) (stream_session_t * session);
49
50   /* Redirect connection to local server */
51   int (*redirect_connect_callback) (u32 api_client_index, void *mp);
52 } session_cb_vft_t;
53
54 typedef struct _application
55 {
56   /** Index in server pool */
57   u32 index;
58
59   /** Flags */
60   u32 flags;
61
62   /** Binary API connection index, ~0 if internal */
63   u32 api_client_index;
64
65   /* */
66   u32 api_context;
67
68   /** Application listens for events on this svm queue */
69   unix_shared_memory_queue_t *event_queue;
70
71   /** Stream session type */
72   u8 session_type;
73
74   /* Stream server mode: accept or connect */
75   u8 mode;
76
77   u32 session_manager_index;
78
79   /*
80    * Bind/Listen specific
81    */
82
83   /** Accept cookie, for multiple session flavors ($$$ maybe) */
84   u32 accept_cookie;
85
86   /** Index of the listen session or connect session */
87   u32 session_index;
88
89   /** Session thread index for client connect sessions */
90   u32 thread_index;
91
92   /*
93    * Callbacks: shoulder-taps for the server/client
94    */
95   session_cb_vft_t cb_fns;
96 } application_t;
97
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);
106
107 int
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);
112
113 #endif /* SRC_VNET_SESSION_APPLICATION_H_ */
114
115 /*
116  * fd.io coding-style-patch-verification: ON
117  *
118  * Local Variables:
119  * eval: (c-set-style "gnu")
120  * End:
121  */