FD.io VPP  v17.10-9-gd594711
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>
22 
23 typedef enum
24 {
29 
30 typedef 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 */
40  int (*session_connected_callback) (u32 app_index, u32 opaque,
41  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 */
51 
52  /* Redirect connection to local server */
53  int (*redirect_connect_callback) (u32 api_client_index, void *mp);
55 
56 typedef struct _application
57 {
58  /** Index in server pool */
59  u32 index;
60 
61  /** Flags */
62  u32 flags;
63 
64  /*
65  * Binary API interface to external app
66  */
67 
68  /** Binary API connection index, ~0 if internal */
69  u32 api_client_index;
70 
71  /** Application listens for events on this svm queue */
72  unix_shared_memory_queue_t *event_queue;
73 
74  /*
75  * Callbacks: shoulder-taps for the server/client
76  */
77 
78  session_cb_vft_t cb_fns;
79 
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  /** First segment manager has in the the first segment the application's
89  * event fifo. Depending on what the app does, it may be either used for
90  * a listener or for connects. */
91  u32 first_segment_manager;
92  u8 first_segment_manager_in_use;
93 
94  /** Segment manager properties. Shared by all segment managers */
95  segment_manager_properties_t sm_properties;
97 
98 #define APP_INVALID_SEGMENT_MANAGER_INDEX ((u32) ~0)
99 
101 int
102 application_init (application_t * app, u32 api_client_index, u64 * options,
103  session_cb_vft_t * cb_fns);
104 void application_del (application_t * app);
107 application_t *application_lookup (u32 api_client_index);
109 
110 int
112  transport_endpoint_t * tep, u64 * handle);
113 int application_stop_listen (application_t * srv, u64 handle);
114 int
116  transport_endpoint_t * tep, u32 api_context);
118 
120  app,
122  s);
124  app);
126 int application_add_segment_notify (u32 app_index, u32 fifo_segment_index);
127 
128 #endif /* SRC_VNET_SESSION_APPLICATION_H_ */
129 
130 /*
131  * fd.io coding-style-patch-verification: ON
132  *
133  * Local Variables:
134  * eval: (c-set-style "gnu")
135  * End:
136  */
segment_manager_t * application_get_listen_segment_manager(application_t *app, stream_session_t *s)
Definition: application.c:378
struct _segment_manager_properties segment_manager_properties_t
application_t * application_get_if_valid(u32 index)
Definition: application.c:230
application_t * application_lookup(u32 api_client_index)
Definition: application.c:66
application_type_t
Definition: application.h:23
struct _stream_session_cb_vft session_cb_vft_t
unsigned long u64
Definition: types.h:89
struct _stream_session_t stream_session_t
application_t * application_new()
Definition: application.c:77
session_type_t
segment_manager_t * application_get_connect_segment_manager(application_t *app)
Definition: application.c:371
u32 application_get_index(application_t *app)
Definition: application.c:239
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:196
struct _application application_t
int application_add_segment_notify(u32 app_index, u32 fifo_segment_index)
Definition: application.c:409
int application_init(application_t *app, u32 api_client_index, u64 *options, session_cb_vft_t *cb_fns)
Definition: application.c:171
unsigned int u32
Definition: types.h:88
application_t * application_get(u32 index)
Definition: application.c:224
int builtin_server_rx_callback(stream_session_t *s)
int application_is_proxy(application_t *app)
Definition: application.c:403
u64 uword
Definition: types.h:112
unsigned char u8
Definition: types.h:56
struct _transport_endpoint transport_endpoint_t
struct _segment_manager segment_manager_t
int application_api_queue_is_full(application_t *app)
Definition: application.c:36
int application_start_listen(application_t *app, session_type_t session_type, transport_endpoint_t *tep, u64 *handle)
Start listening local transport endpoint for requested transport.
Definition: application.c:272
int application_open_session(application_t *app, session_type_t sst, transport_endpoint_t *tep, u32 api_context)
Definition: application.c:344
u32 flags
Definition: vhost-user.h:77
void application_del(application_t *app)
Definition: application.c:91
int application_stop_listen(application_t *srv, u64 handle)
Stop listening on session associated to handle.
Definition: application.c:308
struct _unix_shared_memory_queue unix_shared_memory_queue_t