session: support local sessions and deprecate redirects
[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 option version = "1.0.1";
17
18 /** \brief client->vpp, attach application to session layer
19     @param client_index - opaque cookie to identify the sender
20     @param context - sender context, to match reply w/ request
21     @param initial_segment_size - size of the initial shm segment to be 
22                                                           allocated
23     @param options - segment size, fifo sizes, etc.
24     @param namespace_id_len - length of the namespace id c-string
25     @param namespace_id - 0 terminted c-string
26 */
27  define application_attach {
28     u32 client_index;
29     u32 context;
30     u32 initial_segment_size;
31     u64 options[16];
32     u8 namespace_id_len;
33     u8 namespace_id [64];
34  };
35  
36  /** \brief Application attach reply
37     @param context - sender context, to match reply w/ request
38     @param retval - return code for the request
39     @param app_event_queue_address - vpp event queue address or 0 if this 
40                                          connection shouldn't send events
41     @param segment_size - size of first shm segment
42     @param segment_name_length - length of segment name 
43     @param segment_name - name of segment client needs to attach to
44 */
45 define application_attach_reply {
46     u32 context;
47     i32 retval;
48     u64 app_event_queue_address;
49     u32 segment_size;
50     u8 segment_name_length;
51     u8 segment_name[128];
52 };
53
54  /** \brief client->vpp, attach application to session layer
55     @param client_index - opaque cookie to identify the sender
56     @param context - sender context, to match reply w/ request
57 */
58 autoreply define application_detach {
59     u32 client_index;
60     u32 context;
61  };
62  
63 /** \brief vpp->client, please map an additional shared memory segment
64     @param client_index - opaque cookie to identify the sender
65     @param context - sender context, to match reply w/ request
66     @param segment_name - 
67 */
68 autoreply define map_another_segment {
69     u32 client_index;
70     u32 context;
71     u32 segment_size;
72     u8 segment_name[128];
73 };
74
75 /** \brief vpp->client unmap shared memory segment
76     @param client_index - opaque cookie to identify the sender
77     @param context - sender context, to match reply w/ request
78     @param segment_name - 
79 */
80 autoreply define unmap_segment {
81     u32 client_index;
82     u32 context;
83     u8 segment_name[128];
84 };
85
86  /** \brief Bind to a given URI
87     @param client_index - opaque cookie to identify the sender
88     @param context - sender context, to match reply w/ request
89     @param accept_cookie - sender accept cookie, to identify this bind flavor
90     @param uri - a URI, e.g. "tcp://0.0.0.0/0/80" [ipv4]
91                  "tcp://::/0/80" [ipv6] etc.
92     @param options - socket options, fifo sizes, etc.
93 */
94 autoreply define bind_uri {
95   u32 client_index;
96   u32 context;
97   u32 accept_cookie;
98   u8 uri[128];
99 };
100
101 /** \brief Unbind a given URI
102     @param client_index - opaque cookie to identify the sender
103     @param context - sender context, to match reply w/ request
104     @param uri - a URI, e.g. "tcp://0.0.0.0/0/80" [ipv4]
105                  "tcp://::/0/80" [ipv6], etc.
106     @param options - socket options, fifo sizes, etc.
107 */
108 autoreply define unbind_uri {
109   u32 client_index;
110   u32 context;
111   u8 uri[128];
112 };
113
114 /** \brief Connect to a given URI
115     @param client_index - opaque cookie to identify the sender
116     @param context - sender context, to match reply w/ request
117     @param client_queue_address - binary API client queue address. Used by 
118                                                           local server when connect was redirected.
119     @param options - socket options, fifo sizes, etc. passed by vpp to the
120                                  server when redirecting connects 
121     @param uri - a URI, e.g. "tcp4://0.0.0.0/0/80"
122                  "tcp6://::/0/80" [ipv6], etc.
123 */
124 autoreply define connect_uri {
125   u32 client_index;
126   u32 context;
127   u64 client_queue_address;
128   u64 options[16];
129   u8 uri[128];
130 };
131
132 /** \brief vpp->client, accept this session
133     @param context - sender context, to match reply w/ request
134     @param listener_handle - tells client which listener this pertains to
135     @param handle - unique session identifier
136     @param rx_fifo_address - rx (vpp -> vpp-client) fifo address 
137     @param tx_fifo_address - tx (vpp-client -> vpp) fifo address 
138     @param vpp_event_queue_address - vpp's event queue address or client's
139                                                                         event queue for cut through
140     @param server_event_queue_address - server's event queue address for
141                                                                            cut through sessions
142     @param port - remote port
143     @param is_ip4 - 1 if the ip is ip4
144     @param ip - remote ip
145 */
146 define accept_session {
147   u32 client_index;
148   u32 context;
149   u64 listener_handle;
150   u64 handle; 
151   u64 server_rx_fifo;
152   u64 server_tx_fifo;
153   u64 vpp_event_queue_address;
154   u64 server_event_queue_address;
155   u16 port;
156   u8 is_ip4;
157   u8 ip[16];
158 };
159
160 /** \brief client->vpp, reply to an accept message
161     @param context - sender context, to match reply w/ request
162     @param retval - return code for the request
163     @param session_index - session index from accept_session / connect_reply
164     @param session_thread_index - thread index from accept_session /
165                                   connect_reply
166 */
167 define accept_session_reply {
168   u32 context;
169   i32 retval;
170   u64 handle;
171 };
172
173 /** \brief bidirectional disconnect API
174     @param client_index - opaque cookie to identify the sender
175                           client to vpp direction only
176     @param context - sender context, to match reply w/ request
177     @param handle - session handle obtained from accept/connect
178 */
179 define disconnect_session {
180   u32 client_index;
181   u32 context;
182   u64 handle;
183 };
184
185 /** \brief bidirectional disconnect reply API
186     @param client_index - opaque cookie to identify the sender
187                           client to vpp direction only
188     @param context - sender context, to match reply w/ request
189     @param retval - return code for the request
190     @param handle - session handle
191 */
192 define disconnect_session_reply {
193   u32 context;
194   i32 retval;
195   u64 handle;
196 };
197
198 /** \brief vpp->client reset session API
199     @param client_index - opaque cookie to identify the sender
200                           client to vpp direction only
201     @param context - sender context, to match reply w/ request
202     @param handle - session handle obtained via accept/connects
203 */
204 define reset_session {
205   u32 client_index;
206   u32 context;
207   u64 handle;
208 };
209
210 /** \brief client->vpp reset session reply
211     @param client_index - opaque cookie to identify the sender
212                           client to vpp direction only
213     @param context - sender context, to match reply w/ request
214     @param retval - return code for the request
215     @param handle - session handle obtained via accept/connect
216 */
217 define reset_session_reply {
218   u32 client_index;
219   u32 context;
220   i32 retval;
221   u64 handle;
222 };
223
224 /** \brief Bind to an ip:port pair for a given transport protocol
225     @param client_index - opaque cookie to identify the sender
226     @param context - sender context, to match reply w/ request
227     @param vrf - bind namespace
228     @param is_ip4 - flag that is 1 if ip address family is IPv4
229     @param ip - ip address
230     @param port - port 
231     @param proto - protocol 0 - TCP 1 - UDP
232     @param options - socket options, fifo sizes, etc.
233 */
234 define bind_sock {
235   u32 client_index;
236   u32 context;
237   u32 vrf;
238   u8 is_ip4;
239   u8 ip[16];
240   u16 port;
241   u8 proto;
242   u64 options[16];
243 };
244
245 /** \brief Unbind 
246     @param client_index - opaque cookie to identify the sender
247     @param context - sender context, to match reply w/ request
248     @param handle - bind handle obtained from bind reply
249 */
250 autoreply define unbind_sock {
251   u32 client_index;
252   u32 context;
253   u64 handle;
254 };
255
256 /** \brief Connect to a remote peer
257     @param client_index - opaque cookie to identify the sender
258     @param context - sender context, to match reply w/ request
259     @param client_queue_address - client's API queue address. Non-zero when 
260                                   used to perform redirects
261     @param options - socket options, fifo sizes, etc. when doing redirects
262     @param vrf - connection namespace
263     @param is_ip4 - flag that is 1 if ip address family is IPv4
264     @param ip - ip address
265     @param port - port 
266     @param proto - protocol 0 - TCP 1 - UDP
267 */
268 autoreply define connect_sock {
269   u32 client_index;
270   u32 context;
271   u64 client_queue_address;
272   u64 options[16];
273   u32 vrf;
274   u8 is_ip4;
275   u8 ip[16];
276   u16 port;
277   u8 proto;
278 };
279
280 /** \brief Bind reply
281     @param context - sender context, to match reply w/ request
282     @param handle - bind handle
283     @param retval - return code for the request
284     @param event_queue_address - vpp event queue address or 0 if this 
285                                  connection shouldn't send events
286     @param segment_name_length - length of segment name 
287     @param segment_name - name of segment client needs to attach to
288 */
289 define bind_sock_reply {
290   u32 context;
291   u64 handle;
292   i32 retval;
293   u64 server_event_queue_address;
294   u8 lcl_is_ip4;
295   u8 lcl_ip[16];
296   u16 lcl_port;
297   u32 segment_size;
298   u8 segment_name_length;
299   u8 segment_name[128];
300 };
301
302 /* Dummy connect message -- needed to satisfy api generators
303 *
304 *  NEVER USED, doxygen tags elided on purpose.
305 */
306 define connect_session {
307   u32 client_index;
308   u32 context;
309 };
310
311 /** \brief vpp/server->client, connect reply -- used for all connect_* messages
312     @param context - sender context, to match reply w/ request
313     @param retval - return code for the request
314     @param handle - connection handle
315     @param server_rx_fifo - rx (vpp -> vpp-client) fifo address 
316     @param server_tx_fifo - tx (vpp-client -> vpp) fifo address 
317     @param vpp_event_queue_address - vpp's event queue address
318     @param client_event_queue_address - client's event queue address
319     @param segment_size - size of segment to be attached. Only for redirects.
320     @param segment_name_length - non-zero if the client needs to attach to 
321                                  the fifo segment
322     @param segment_name - set if the client needs to attach to the segment
323     @param lcl_ip - local ip for connection
324     @param is_ip4 - flag to indicate if ip is v4 or v6
325     @param lcl_port - local port
326 */
327 define connect_session_reply {
328   u32 context;
329   i32 retval;
330   u64 handle;
331   u64 server_rx_fifo;
332   u64 server_tx_fifo;
333   u64 vpp_event_queue_address;
334   u64 client_event_queue_address;
335   u32 segment_size;
336   u8 segment_name_length;
337   u8 segment_name[128];
338   u8 lcl_ip[16];
339   u8 is_ip4;
340   u16 lcl_port;
341 };
342
343 /** \brief enable/disable session layer
344     @param client_index - opaque cookie to identify the sender
345                           client to vpp direction only
346     @param context - sender context, to match reply w/ request
347     @param is_enable - disable session layer if 0, enable otherwise
348 */
349 autoreply define session_enable_disable {
350   u32 client_index;
351   u32 context;
352   u8 is_enable;
353 };
354
355 /** \brief add/del application namespace
356     @param client_index - opaque cookie to identify the sender
357                           client to vpp direction only
358     @param context - sender context, to match reply w/ request
359     @param secret - secret shared between app and vpp 
360     @param sw_if_index - local interface that "supports" namespace. Set to
361                                                 ~0 if no preference
362     @param ip4_fib_id - id of ip4 fib that "supports" the namespace. Ignored 
363                                                 if sw_if_index set.
364     @param ip6_fib_id - id of ip6 fib that "supports" the namespace. Ignored 
365                                                 if sw_if_index set.
366     @param namespace_id_len - length of namespace id lower
367     @param namespace_id - namespace id
368 */
369 define app_namespace_add_del {
370   u32 client_index;
371   u32 context;
372   u64 secret;
373   u32 sw_if_index;
374   u32 ip4_fib_id;
375   u32 ip6_fib_id;
376   u8 namespace_id_len;
377   u8 namespace_id[64];
378 };
379
380 /** \brief Reply for app namespace add/del
381     @param context - returned sender context, to match reply w/ request
382     @param retval - return code
383     @param appns_index - app namespace index
384 */
385 define app_namespace_add_del_reply
386 {
387   u32 context;
388   i32 retval;
389   u32 appns_index;
390 };
391
392 /** \brief add/del session rule
393     @param client_index - opaque cookie to identify the sender
394                           client to vpp direction only
395     @param context - sender context, to match reply w/ request
396     @param transport_proto - transport protocol (0 - tcp 1 - udp)
397     @param is_ip4 - flag to indicate if ip addresses are ip4 or 6
398     @param lcl_ip - local ip
399     @param lcl_plen - local prefix length
400     @param rmt_ip - remote ip
401     @param rmt_ple - remote prefix length
402     @param lcl_port - local port
403     @param rmt_port - remote port
404     @param action_index - the only action defined now is forward to 
405                                                   application with index action_index
406         @param is_add - flag to indicate if add or del
407         @param appns_index - application namespace where rule is to be applied
408                                                  to
409         @param scope - flag that indicates scope of the rule: global or local.
410                                    If 0, default is global, 1 is global 2 is local, 3 is
411                                    both
412 */
413 autoreply define session_rule_add_del {
414   u32 client_index;
415   u32 context;
416   u8 transport_proto;
417   u8 is_ip4;
418   u8 lcl_ip[16];
419   u8 lcl_plen;
420   u8 rmt_ip[16];
421   u8 rmt_plen;
422   u16 lcl_port;
423   u16 rmt_port;
424   u32 action_index;
425   u8 is_add;
426   u32 appns_index;
427   u8 scope;
428   u8 tag[64];
429 };
430
431 /** \brief Dump session rules
432     @param client_index - opaque cookie to identify the sender
433     @param context - sender context, to match reply w/ request
434  */
435 define session_rules_dump
436 {
437   u32 client_index;
438   u32 context;
439 };
440
441 /** \brief Session rules details
442         @param context - sender context, to match reply w/ request
443     @param transport_proto - transport protocol (0 - tcp 1 - udp)
444     @param is_ip4 - flag to indicate if ip addresses are ip4 or 6
445     @param lcl_ip - local ip
446     @param lcl_plen - local prefix length
447     @param rmt_ip - remote ip
448     @param rmt_ple - remote prefix length
449     @param lcl_port - local port
450     @param rmt_port - remote port
451     @param action_index - the only action defined now is forward to
452                                                   application with index action_index
453         @param appns_index - application namespace where rule is to be applied
454                                                  to
455         @param scope - flag that indicates scope of the rule: global or local.
456                                    If 0, default is global, 1 is global 2 is local, 3 is
457                                    both
458   */
459 define session_rules_details
460 {
461   u32 context;
462   u8 transport_proto;
463   u8 is_ip4;
464   u8 lcl_ip[16];
465   u8 lcl_plen;
466   u8 rmt_ip[16];
467   u8 rmt_plen;
468   u16 lcl_port;
469   u16 rmt_port;
470   u32 action_index;
471   u32 appns_index;
472   u8 scope;
473   u8 tag[64];
474 };
475
476 /*
477  * Local Variables:
478  * eval: (c-set-style "gnu")
479  * End:
480  */