FD.io VPP  v17.04.2-2-ga8f93f8
Vector Packet Processing
application.h
Go to the documentation of this file.
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 {
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 */
49  session_fifo_event_t * ep);
50 
51  /* Redirect connection to local server */
52  int (*redirect_connect_callback) (u32 api_client_index, void *mp);
54 
55 typedef struct _application
56 {
57  /** Index in server pool */
58  u32 index;
59 
60  /** Flags */
61  u32 flags;
62 
63  /** Binary API connection index, ~0 if internal */
64  u32 api_client_index;
65 
66  /* */
67  u32 api_context;
68 
69  /** Application listens for events on this svm queue */
70  unix_shared_memory_queue_t *event_queue;
71 
72  /** Stream session type */
73  u8 session_type;
74 
75  /* Stream server mode: accept or connect */
76  u8 mode;
77 
78  u32 session_manager_index;
79 
80  /*
81  * Bind/Listen specific
82  */
83 
84  /** Accept cookie, for multiple session flavors ($$$ maybe) */
85  u32 accept_cookie;
86 
87  /** Index of the listen session or connect session */
88  u32 session_index;
89 
90  /** Session thread index for client connect sessions */
91  u32 thread_index;
92 
93  /*
94  * Callbacks: shoulder-taps for the server/client
95  */
96  session_cb_vft_t cb_fns;
98 
100  u32 api_client_index, u32 flags,
101  session_cb_vft_t * cb_fns);
102 void application_del (application_t * app);
105 application_t *application_lookup (u32 api_client_index);
107 
108 int
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);
113 
114 #endif /* SRC_VNET_SESSION_APPLICATION_H_ */
115 
116 /*
117  * fd.io coding-style-patch-verification: ON
118  *
119  * Local Variables:
120  * eval: (c-set-style "gnu")
121  * End:
122  */
application_t * application_get_if_valid(u32 index)
Definition: application.c:174
application_t * application_lookup(u32 api_client_index)
Definition: application.c:60
struct _stream_session_t stream_session_t
application_type_t
Definition: application.h:22
struct _stream_session_cb_vft session_cb_vft_t
session_type_t
Definition: session.h:74
u32 application_get_index(application_t *app)
Definition: application.c:183
static int redirect_connect_callback(u32 server_api_client_index, void *mp_arg)
Redirect a connect_uri message to the indicated server.
Definition: session_api.c:397
struct _application application_t
int application_server_init(application_t *server, u32 segment_size, u32 add_segment_size, u32 rx_fifo_size, u32 tx_fifo_size, u8 **segment_name)
Definition: application.c:189
unsigned int u32
Definition: types.h:88
application_t * application_get(u32 index)
Definition: application.c:168
application_t * application_new(application_type_t type, session_type_t sst, u32 api_client_index, u32 flags, session_cb_vft_t *cb_fns)
Definition: application.c:109
int builtin_server_rx_callback(stream_session_t *s, session_fifo_event_t *e)
unsigned char u8
Definition: types.h:56
int application_api_queue_is_full(application_t *app)
Definition: application.c:30
u32 flags
Definition: vhost-user.h:78
void application_del(application_t *app)
Definition: application.c:71
struct _unix_shared_memory_queue unix_shared_memory_queue_t