Session layer refactoring
[vpp.git] / src / vnet / session / session.api
1 /*
2  * Copyright (c) 2015-2016 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 /** \brief client->vpp, attach application to session layer
17     @param client_index - opaque cookie to identify the sender
18     @param context - sender context, to match reply w/ request
19     @param initial_segment_size - size of the initial shm segment to be 
20                                                           allocated
21     @param options - segment size, fifo sizes, etc.
22 */
23  define application_attach {
24     u32 client_index;
25     u32 context;
26     u32 initial_segment_size;
27     u64 options[16];
28  };
29  
30  /** \brief Application attach reply
31     @param context - sender context, to match reply w/ request
32     @param retval - return code for the request
33     @param app_event_queue_address - vpp event queue address or 0 if this 
34                                          connection shouldn't send events
35     @param segment_size - size of first shm segment
36     @param segment_name_length - length of segment name 
37     @param segment_name - name of segment client needs to attach to
38 */
39 define application_attach_reply {
40     u32 context;
41     i32 retval;
42     u64 app_event_queue_address;
43     u32 segment_size;
44     u8 segment_name_length;
45     u8 segment_name[128];
46 };
47
48  /** \brief client->vpp, attach application to session layer
49     @param client_index - opaque cookie to identify the sender
50     @param context - sender context, to match reply w/ request
51 */
52  define application_detach {
53     u32 client_index;
54     u32 context;
55  };
56  
57  /** \brief detach reply
58     @param context - sender context, to match reply w/ request
59     @param retval - return code for the request
60 */
61 define application_detach_reply {
62     u32 context;
63     i32 retval;
64 };
65  
66 /** \brief vpp->client, please map an additional shared memory segment
67     @param client_index - opaque cookie to identify the sender
68     @param context - sender context, to match reply w/ request
69     @param segment_name - 
70 */
71 define map_another_segment {
72     u32 client_index;
73     u32 context;
74     u32 segment_size;
75     u8 segment_name[128];
76 };
77
78  /** \brief Bind to a given URI
79     @param client_index - opaque cookie to identify the sender
80     @param context - sender context, to match reply w/ request
81     @param accept_cookie - sender accept cookie, to identify this bind flavor
82     @param uri - a URI, e.g. "tcp://0.0.0.0/0/80" [ipv4]
83                  "tcp://::/0/80" [ipv6] etc.
84     @param options - socket options, fifo sizes, etc.
85 */
86 define bind_uri {
87   u32 client_index;
88   u32 context;
89   u32 accept_cookie;
90   u8 uri[128];
91 };
92
93 /** \brief Unbind a given URI
94     @param client_index - opaque cookie to identify the sender
95     @param context - sender context, to match reply w/ request
96     @param uri - a URI, e.g. "tcp://0.0.0.0/0/80" [ipv4]
97                  "tcp://::/0/80" [ipv6], etc.
98     @param options - socket options, fifo sizes, etc.
99 */
100 define unbind_uri {
101   u32 client_index;
102   u32 context;
103   u8 uri[128];
104 };
105
106 /** \brief Connect to a given URI
107     @param client_index - opaque cookie to identify the sender
108     @param context - sender context, to match reply w/ request
109     @param accept_cookie - sender accept cookie, to identify this bind flavor
110     @param uri - a URI, e.g. "tcp4://0.0.0.0/0/80"
111                  "tcp6://::/0/80" [ipv6], etc.
112     @param options - socket options, fifo sizes, etc. passed by vpp to the
113                                  server when redirecting connects 
114     @param client_queue_address - binary API client queue address. Used by 
115                                                           local server when connect was redirected.
116 */
117 define connect_uri {
118   u32 client_index;
119   u32 context;
120   u8 uri[128];
121   u64 client_queue_address;
122   u64 options[16];
123 };
124
125 /** \brief Bind reply
126     @param context - sender context, to match reply w/ request
127     @param retval - return code for the request
128 */
129 define bind_uri_reply {
130     u32 context;
131     i32 retval;
132 };
133
134 /** \brief unbind reply
135     @param context - sender context, to match reply w/ request
136     @param retval - return code for the request
137 */
138 define unbind_uri_reply {
139     u32 context;
140     i32 retval;
141 };
142
143 /** \brief vpp->client, connect reply
144     @param context - sender context, to match reply w/ request
145     @param retval - return code for the request
146     @param handle - session handle
147     @param server_rx_fifo - rx (vpp -> vpp-client) fifo address 
148     @param server_tx_fifo - tx (vpp-client -> vpp) fifo address 
149     @param vpp_event_queue_address - vpp's event queue address
150     @param segment_size - size of segment to be attached. Only for redirects.
151     @param segment_name_length - non-zero if the client needs to attach to 
152                                  the fifo segment. This should only happen 
153                                  if session was redirected.
154     @param segment_name - set if the client needs to attach to the segment
155 */
156 define connect_uri_reply {
157   u32 context;
158   i32 retval;
159   u64 handle;
160   u64 server_rx_fifo;
161   u64 server_tx_fifo;
162   u64 vpp_event_queue_address;
163   u32 segment_size;
164   u8 segment_name_length;
165   u8 segment_name[128];
166 };
167
168 /** \brief client->vpp
169     @param context - sender context, to match reply w/ request
170     @param retval - return code for the request
171 */
172 define map_another_segment_reply {
173     u32 context;
174     i32 retval;
175 };
176
177 /** \brief vpp->client, accept this session
178     @param context - sender context, to match reply w/ request
179     @param listener_handle - tells client which listener this pertains to
180     @param handle - unique session identifier
181     @param session_thread_index - thread index of new session
182     @param rx_fifo_address - rx (vpp -> vpp-client) fifo address 
183     @param tx_fifo_address - tx (vpp-client -> vpp) fifo address 
184     @param vpp_event_queue_address - vpp's event queue address
185     @param port - remote port
186     @param is_ip4 - 1 if the ip is ip4
187     @param ip - remote ip
188 */
189 define accept_session {
190   u32 client_index;
191   u32 context;
192   u64 listener_handle;
193   u64 handle; 
194   u64 server_rx_fifo;
195   u64 server_tx_fifo;
196   u64 vpp_event_queue_address;
197   u16 port;
198   u8 is_ip4;
199   u8 ip[16];
200 };
201
202 /** \brief client->vpp, reply to an accept message
203     @param context - sender context, to match reply w/ request
204     @param retval - return code for the request
205     @param session_index - session index from accept_session / connect_reply
206     @param session_thread_index - thread index from accept_session /
207                                   connect_reply
208 */
209 define accept_session_reply {
210   u32 context;
211   i32 retval;
212   u64 handle;
213 };
214
215 /** \brief bidirectional disconnect API
216     @param client_index - opaque cookie to identify the sender
217                           client to vpp direction only
218     @param context - sender context, to match reply w/ request
219     @param handle - session handle obtained from accept/connect
220 */
221 define disconnect_session {
222   u32 client_index;
223   u32 context;
224   u64 handle;
225 };
226
227 /** \brief bidirectional disconnect reply API
228     @param client_index - opaque cookie to identify the sender
229                           client to vpp direction only
230     @param context - sender context, to match reply w/ request
231     @param retval - return code for the request
232     @param handle - session handle
233 */
234 define disconnect_session_reply {
235   u32 client_index;
236   u32 context;
237   i32 retval;
238   u64 handle;
239 };
240
241 /** \brief vpp->client reset session API
242     @param client_index - opaque cookie to identify the sender
243                           client to vpp direction only
244     @param context - sender context, to match reply w/ request
245     @param handle - session handle obtained via accept/connects
246 */
247 define reset_session {
248   u32 client_index;
249   u32 context;
250   u64 handle;
251 };
252
253 /** \brief client->vpp reset session reply
254     @param client_index - opaque cookie to identify the sender
255                           client to vpp direction only
256     @param context - sender context, to match reply w/ request
257     @param retval - return code for the request
258     @param handle - session handle obtained via accept/connect
259 */
260 define reset_session_reply {
261   u32 client_index;
262   u32 context;
263   i32 retval;
264   u64 handle;
265 };
266
267 /** \brief Bind to an ip:port pair for a given transport protocol
268     @param client_index - opaque cookie to identify the sender
269     @param context - sender context, to match reply w/ request
270     @param vrf - bind namespace
271     @param is_ip4 - flag that is 1 if ip address family is IPv4
272     @param ip - ip address
273     @param port - port 
274     @param proto - protocol 0 - TCP 1 - UDP
275     @param options - socket options, fifo sizes, etc.
276 */
277 define bind_sock {
278   u32 client_index;
279   u32 context;
280   u32 vrf;
281   u8 is_ip4;
282   u8 ip[16];
283   u16 port;
284   u8 proto;
285   u64 options[16];
286 };
287
288 /** \brief Unbind 
289     @param client_index - opaque cookie to identify the sender
290     @param context - sender context, to match reply w/ request
291     @param handle - bind handle obtained from bind reply
292 */
293 define unbind_sock {
294   u32 client_index;
295   u32 context;
296   u64 handle;
297 };
298
299 /** \brief Connect to a remote peer
300     @param client_index - opaque cookie to identify the sender
301     @param context - sender context, to match reply w/ request
302     @param vrf - connection namespace
303     @param is_ip4 - flag that is 1 if ip address family is IPv4
304     @param ip - ip address
305     @param port - port 
306     @param proto - protocol 0 - TCP 1 - UDP
307     @param client_queue_address - client's API queue address. Non-zero when 
308                                   used to perform redirects
309     @param options - socket options, fifo sizes, etc. when doing redirects
310 */
311 define connect_sock {
312   u32 client_index;
313   u32 context;
314   u32 vrf;
315   u8 is_ip4;
316   u8 ip[16];
317   u16 port;
318   u8 proto;
319   u64 client_queue_address;
320   u64 options[16];
321 };
322
323 /** \brief Bind reply
324     @param context - sender context, to match reply w/ request
325     @param handle - bind handle
326     @param retval - return code for the request
327     @param event_queue_address - vpp event queue address or 0 if this 
328                                  connection shouldn't send events
329     @param segment_name_length - length of segment name 
330     @param segment_name - name of segment client needs to attach to
331 */
332 define bind_sock_reply {
333   u32 context;
334   u64 handle;
335   i32 retval;
336   u64 server_event_queue_address;
337   u32 segment_size;
338   u8 segment_name_length;
339   u8 segment_name[128];
340 };
341
342 /** \brief unbind reply
343     @param context - sender context, to match reply w/ request
344     @param retval - return code for the request
345 */
346 define unbind_sock_reply {
347   u32 context;
348   i32 retval;
349 };
350
351 /** \brief vpp/server->client, connect reply
352     @param context - sender context, to match reply w/ request
353     @param retval - return code for the request
354     @param handle - connection handle
355     @param server_rx_fifo - rx (vpp -> vpp-client) fifo address 
356     @param server_tx_fifo - tx (vpp-client -> vpp) fifo address 
357     @param vpp_event_queue_address - vpp's event queue address
358     @param segment_size - size of segment to be attached. Only for redirects.
359     @param segment_name_length - non-zero if the client needs to attach to 
360                                  the fifo segment
361     @param segment_name - set if the client needs to attach to the segment
362 */
363 define connect_sock_reply {
364   u32 context;
365   i32 retval;
366   u64 handle;
367   u64 server_rx_fifo;
368   u64 server_tx_fifo;
369   u64 vpp_event_queue_address;
370   u32 segment_size;
371   u8 segment_name_length;
372   u8 segment_name[128];
373 };
374
375 /** \brief enable/disable session layer
376     @param client_index - opaque cookie to identify the sender
377                           client to vpp direction only
378     @param context - sender context, to match reply w/ request
379     @param is_enable - disable session layer if 0, enable otherwise
380 */
381 define session_enable_disable {
382   u32 client_index;
383   u32 context;
384   u8 is_enable;
385 };
386
387 /** \brief Reply for session enable/disable
388     @param context - returned sender context, to match reply w/ request
389     @param retval - return code
390 */
391 define session_enable_disable_reply {
392   u32 context;
393   i32 retval;
394 };
395
396 /*
397  * Local Variables:
398  * eval: (c-set-style "gnu")
399  * End:
400  */