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