FD.io VPP  v17.07-30-g839fa73
Vector Packet Processing
session_api.c
Go to the documentation of this file.
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 #include <vnet/vnet.h>
17 #include <vlibmemory/api.h>
19 
20 #include <vnet/vnet_msg_enum.h>
21 #include "application_interface.h"
22 
23 #define vl_typedefs /* define message structures */
24 #include <vnet/vnet_all_api_h.h>
25 #undef vl_typedefs
26 
27 #define vl_endianfun /* define message structures */
28 #include <vnet/vnet_all_api_h.h>
29 #undef vl_endianfun
30 
31 /* instantiate all the print functions we know about */
32 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
33 #define vl_printfun
34 #include <vnet/vnet_all_api_h.h>
35 #undef vl_printfun
36 
38 
39 #define foreach_session_api_msg \
40 _(MAP_ANOTHER_SEGMENT_REPLY, map_another_segment_reply) \
41 _(APPLICATION_ATTACH, application_attach) \
42 _(APPLICATION_DETACH, application_detach) \
43 _(BIND_URI, bind_uri) \
44 _(UNBIND_URI, unbind_uri) \
45 _(CONNECT_URI, connect_uri) \
46 _(DISCONNECT_SESSION, disconnect_session) \
47 _(DISCONNECT_SESSION_REPLY, disconnect_session_reply) \
48 _(ACCEPT_SESSION_REPLY, accept_session_reply) \
49 _(RESET_SESSION_REPLY, reset_session_reply) \
50 _(BIND_SOCK, bind_sock) \
51 _(UNBIND_SOCK, unbind_sock) \
52 _(CONNECT_SOCK, connect_sock) \
53 _(SESSION_ENABLE_DISABLE, session_enable_disable) \
54 
55 static int
56 send_add_segment_callback (u32 api_client_index, const u8 * segment_name,
57  u32 segment_size)
58 {
61 
62  q = vl_api_client_index_to_input_queue (api_client_index);
63 
64  if (!q)
65  return -1;
66 
67  mp = vl_msg_api_alloc (sizeof (*mp));
68  memset (mp, 0, sizeof (*mp));
69  mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_MAP_ANOTHER_SEGMENT);
70  mp->segment_size = segment_size;
71  strncpy ((char *) mp->segment_name, (char *) segment_name,
72  sizeof (mp->segment_name) - 1);
73 
74  vl_msg_api_send_shmem (q, (u8 *) & mp);
75 
76  return 0;
77 }
78 
79 static int
81 {
83  unix_shared_memory_queue_t *q, *vpp_queue;
84  application_t *server = application_get (s->app_index);
86  transport_proto_vft_t *tp_vft;
87  stream_session_t *listener;
88 
89  q = vl_api_client_index_to_input_queue (server->api_client_index);
90  vpp_queue = session_manager_get_vpp_event_queue (s->thread_index);
91 
92  if (!q)
93  return -1;
94 
95  mp = vl_msg_api_alloc (sizeof (*mp));
96  memset (mp, 0, sizeof (*mp));
97 
98  mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_ACCEPT_SESSION);
99  mp->context = server->index;
100  listener = listen_session_get (s->session_type, s->listener_index);
101  tp_vft = session_get_transport_vft (s->session_type);
102  tc = tp_vft->get_connection (s->connection_index, s->thread_index);
104  mp->handle = stream_session_handle (s);
105  mp->server_rx_fifo = pointer_to_uword (s->server_rx_fifo);
106  mp->server_tx_fifo = pointer_to_uword (s->server_tx_fifo);
107  mp->vpp_event_queue_address = pointer_to_uword (vpp_queue);
108  mp->port = tc->rmt_port;
109  mp->is_ip4 = tc->is_ip4;
110  clib_memcpy (&mp->ip, &tc->rmt_ip, sizeof (tc->rmt_ip));
111  vl_msg_api_send_shmem (q, (u8 *) & mp);
112 
113  return 0;
114 }
115 
116 static void
118 {
121  application_t *app = application_get (s->app_index);
122 
123  q = vl_api_client_index_to_input_queue (app->api_client_index);
124 
125  if (!q)
126  return;
127 
128  mp = vl_msg_api_alloc (sizeof (*mp));
129  memset (mp, 0, sizeof (*mp));
130  mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_DISCONNECT_SESSION);
131  mp->handle = stream_session_handle (s);
132  vl_msg_api_send_shmem (q, (u8 *) & mp);
133 }
134 
135 static void
137 {
140  application_t *app = application_get (s->app_index);
141 
142  q = vl_api_client_index_to_input_queue (app->api_client_index);
143 
144  if (!q)
145  return;
146 
147  mp = vl_msg_api_alloc (sizeof (*mp));
148  memset (mp, 0, sizeof (*mp));
149  mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_RESET_SESSION);
150  mp->handle = stream_session_handle (s);
151  vl_msg_api_send_shmem (q, (u8 *) & mp);
152 }
153 
154 int
155 send_session_connected_callback (u32 app_index, u32 api_context,
156  stream_session_t * s, u8 is_fail)
157 {
160  application_t *app;
161  unix_shared_memory_queue_t *vpp_queue;
162 
163  app = application_get (app_index);
164  q = vl_api_client_index_to_input_queue (app->api_client_index);
165 
166  if (!q)
167  return -1;
168 
169  mp = vl_msg_api_alloc (sizeof (*mp));
170  mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_CONNECT_URI_REPLY);
171  mp->context = api_context;
172  if (!is_fail)
173  {
174  vpp_queue = session_manager_get_vpp_event_queue (s->thread_index);
175  mp->server_rx_fifo = pointer_to_uword (s->server_rx_fifo);
176  mp->server_tx_fifo = pointer_to_uword (s->server_tx_fifo);
177  mp->handle = stream_session_handle (s);
178  mp->vpp_event_queue_address = pointer_to_uword (vpp_queue);
179  mp->retval = 0;
180  }
181  else
182  {
183  mp->retval = clib_host_to_net_u32 (VNET_API_ERROR_SESSION_CONNECT_FAIL);
184  }
185 
186  vl_msg_api_send_shmem (q, (u8 *) & mp);
187 
188  /* Remove client if connect failed */
189  if (!is_fail)
190  {
191  s->session_state = SESSION_STATE_READY;
192  }
193 
194  return 0;
195 }
196 
197 /**
198  * Redirect a connect_uri message to the indicated server.
199  * Only sent if the server has bound the related port with
200  * URI_OPTIONS_FLAGS_USE_FIFO
201  */
202 static int
203 redirect_connect_callback (u32 server_api_client_index, void *mp_arg)
204 {
205  vl_api_connect_uri_t *mp = mp_arg;
206  unix_shared_memory_queue_t *server_q, *client_q;
207  vlib_main_t *vm = vlib_get_main ();
208  f64 timeout = vlib_time_now (vm) + 0.5;
209  application_t *app;
210  int rv = 0;
211 
212  server_q = vl_api_client_index_to_input_queue (server_api_client_index);
213 
214  if (!server_q)
215  {
216  rv = VNET_API_ERROR_INVALID_VALUE;
217  goto out;
218  }
219 
221  if (!client_q)
222  {
223  rv = VNET_API_ERROR_INVALID_VALUE_2;
224  goto out;
225  }
226 
227  /* Tell the server the client's API queue address, so it can reply */
228  mp->client_queue_address = pointer_to_uword (client_q);
229  app = application_lookup (mp->client_index);
230  if (!app)
231  {
232  clib_warning ("no client application");
233  return -1;
234  }
235 
236  mp->options[SESSION_OPTIONS_RX_FIFO_SIZE] = app->sm_properties.rx_fifo_size;
237  mp->options[SESSION_OPTIONS_TX_FIFO_SIZE] = app->sm_properties.tx_fifo_size;
238 
239  /*
240  * Bounce message handlers MUST NOT block the data-plane.
241  * Spin waiting for the queue lock, but
242  */
243 
244  while (vlib_time_now (vm) < timeout)
245  {
246  rv =
247  unix_shared_memory_queue_add (server_q, (u8 *) & mp, 1 /*nowait */ );
248  switch (rv)
249  {
250  /* correctly enqueued */
251  case 0:
253 
254  /* continue spinning, wait for pthread_mutex_trylock to work */
255  case -1:
256  continue;
257 
258  /* queue stuffed, drop the msg */
259  case -2:
260  rv = VNET_API_ERROR_QUEUE_FULL;
261  goto out;
262  }
263  }
264 out:
265  /* Dispose of the message */
266  vl_msg_api_free (mp);
267  return rv;
268 }
269 
271  .session_accept_callback = send_session_accept_callback,
272  .session_disconnect_callback = send_session_disconnect_callback,
273  .session_connected_callback = send_session_connected_callback,
274  .session_reset_callback = send_session_reset_callback,
275  .add_segment_callback = send_add_segment_callback,
276  .redirect_connect_callback = redirect_connect_callback
277 };
278 
279 static void
281 {
282  vl_api_session_enable_disable_reply_t *rmp;
283  vlib_main_t *vm = vlib_get_main ();
284  int rv = 0;
285 
287  REPLY_MACRO (VL_API_SESSION_ENABLE_DISABLE_REPLY);
288 }
289 
290 static void
292 {
294  vnet_app_attach_args_t _a, *a = &_a;
295  int rv;
296 
297  if (session_manager_is_enabled () == 0)
298  {
299  rv = VNET_API_ERROR_FEATURE_DISABLED;
300  goto done;
301  }
302 
304  sizeof (mp->options),
305  "Out of options, fix api message definition");
306 
307  memset (a, 0, sizeof (*a));
308 
309  a->api_client_index = mp->client_index;
310  a->options = mp->options;
311  a->session_cb_vft = &uri_session_cb_vft;
312 
313  rv = vnet_application_attach (a);
314 
315 done:
316 
317  /* *INDENT-OFF* */
318  REPLY_MACRO2 (VL_API_APPLICATION_ATTACH_REPLY, ({
319  if (!rv)
320  {
321  rmp->segment_name_length = 0;
322  /* $$$$ policy? */
323  rmp->segment_size = a->segment_size;
324  if (a->segment_name_length)
325  {
326  memcpy (rmp->segment_name, a->segment_name,
327  a->segment_name_length);
328  rmp->segment_name_length = a->segment_name_length;
329  }
330  rmp->app_event_queue_address = a->app_event_queue_address;
331  }
332  }));
333  /* *INDENT-ON* */
334 }
335 
336 static void
338 {
339  vl_api_application_detach_reply_t *rmp;
340  int rv = VNET_API_ERROR_INVALID_VALUE_2;
341  vnet_app_detach_args_t _a, *a = &_a;
342  application_t *app;
343 
344  if (session_manager_is_enabled () == 0)
345  {
346  rv = VNET_API_ERROR_FEATURE_DISABLED;
347  goto done;
348  }
349 
350  app = application_lookup (mp->client_index);
351  if (app)
352  {
353  a->app_index = app->index;
354  rv = vnet_application_detach (a);
355  }
356 
357 done:
358  REPLY_MACRO (VL_API_APPLICATION_DETACH_REPLY);
359 }
360 
361 static void
363 {
364  vl_api_bind_uri_reply_t *rmp;
365  vnet_bind_args_t _a, *a = &_a;
366  application_t *app;
367  int rv;
368 
369  if (session_manager_is_enabled () == 0)
370  {
371  rv = VNET_API_ERROR_FEATURE_DISABLED;
372  goto done;
373  }
374 
375  app = application_lookup (mp->client_index);
376  if (app)
377  {
378  memset (a, 0, sizeof (*a));
379  a->uri = (char *) mp->uri;
380  a->app_index = app->index;
381  rv = vnet_bind_uri (a);
382  }
383  else
384  {
385  rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
386  }
387 
388 done:
389  REPLY_MACRO (VL_API_BIND_URI_REPLY);
390 }
391 
392 static void
394 {
395  vl_api_unbind_uri_reply_t *rmp;
396  application_t *app;
397  vnet_unbind_args_t _a, *a = &_a;
398  int rv;
399 
400  if (session_manager_is_enabled () == 0)
401  {
402  rv = VNET_API_ERROR_FEATURE_DISABLED;
403  goto done;
404  }
405 
406  app = application_lookup (mp->client_index);
407  if (app)
408  {
409  a->uri = (char *) mp->uri;
410  a->app_index = app->index;
411  rv = vnet_unbind_uri (a);
412  }
413  else
414  {
415  rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
416  }
417 
418 done:
419  REPLY_MACRO (VL_API_UNBIND_URI_REPLY);
420 }
421 
422 static void
424 {
426  vnet_connect_args_t _a, *a = &_a;
427  application_t *app;
428  int rv;
429 
430  if (session_manager_is_enabled () == 0)
431  {
432  rv = VNET_API_ERROR_FEATURE_DISABLED;
433  goto done;
434  }
435 
436  app = application_lookup (mp->client_index);
437  if (app)
438  {
439  a->uri = (char *) mp->uri;
440  a->api_context = mp->context;
441  a->app_index = app->index;
442  a->mp = mp;
443  rv = vnet_connect_uri (a);
444  }
445  else
446  {
447  rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
448  }
449 
450  if (rv == 0 || rv == VNET_CONNECT_REDIRECTED)
451  return;
452 
453  /* Got some error, relay it */
454 
455 done:
456  /* *INDENT-OFF* */
457  REPLY_MACRO (VL_API_CONNECT_URI_REPLY);
458  /* *INDENT-ON* */
459 }
460 
461 static void
463 {
465  vnet_disconnect_args_t _a, *a = &_a;
466  application_t *app;
467  int rv = 0;
468 
469  if (session_manager_is_enabled () == 0)
470  {
471  rv = VNET_API_ERROR_FEATURE_DISABLED;
472  goto done;
473  }
474 
475  app = application_lookup (mp->client_index);
476  if (app)
477  {
478  a->handle = mp->handle;
479  a->app_index = app->index;
480  rv = vnet_disconnect_session (a);
481  }
482  else
483  {
484  rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
485  }
486 
487 done:
488  REPLY_MACRO (VL_API_DISCONNECT_SESSION_REPLY);
489 }
490 
491 static void
493  mp)
494 {
495  vnet_disconnect_args_t _a, *a = &_a;
496  application_t *app;
497 
498  /* Client objected to disconnecting the session, log and continue */
499  if (mp->retval)
500  {
501  clib_warning ("client retval %d", mp->retval);
502  return;
503  }
504 
505  /* Disconnect has been confirmed. Confirm close to transport */
506  app = application_lookup (mp->client_index);
507  if (app)
508  {
509  a->handle = mp->handle;
510  a->app_index = app->index;
512  }
513 }
514 
515 static void
517 {
518  application_t *app;
519  stream_session_t *s;
520  u32 index, thread_index;
521 
522  app = application_lookup (mp->client_index);
523  if (!app)
524  return;
525 
526  stream_session_parse_handle (mp->handle, &index, &thread_index);
527  s = stream_session_get_if_valid (index, thread_index);
528  if (s == 0 || app->index != s->app_index)
529  {
530  clib_warning ("Invalid session!");
531  return;
532  }
533 
534  /* Client objected to resetting the session, log and continue */
535  if (mp->retval)
536  {
537  clib_warning ("client retval %d", mp->retval);
538  return;
539  }
540 
541  /* This comes as a response to a reset, transport only waiting for
542  * confirmation to remove connection state, no need to disconnect */
544 }
545 
546 static void
548 {
549  stream_session_t *s;
550  u32 session_index, thread_index;
551  vnet_disconnect_args_t _a, *a = &_a;
552 
553  /* Server isn't interested, kill the session */
554  if (mp->retval)
555  {
556  a->app_index = mp->context;
557  a->handle = mp->handle;
559  }
560  else
561  {
562  stream_session_parse_handle (mp->handle, &session_index, &thread_index);
563  s = stream_session_get_if_valid (session_index, thread_index);
564  if (!s)
565  {
566  clib_warning ("session doesn't exist");
567  return;
568  }
569  if (s->app_index != mp->context)
570  {
571  clib_warning ("app doesn't own session");
572  return;
573  }
574  /* XXX volatile? */
575  s->session_state = SESSION_STATE_READY;
576  }
577 }
578 
579 static void
580 vl_api_map_another_segment_reply_t_handler (vl_api_map_another_segment_reply_t
581  * mp)
582 {
583  clib_warning ("not implemented");
584 }
585 
586 static void
588 {
590  vnet_bind_args_t _a, *a = &_a;
591  int rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
592  application_t *app;
593 
594  if (session_manager_is_enabled () == 0)
595  {
596  rv = VNET_API_ERROR_FEATURE_DISABLED;
597  goto done;
598  }
599 
600  app = application_lookup (mp->client_index);
601  if (app)
602  {
603  memset (a, 0, sizeof (*a));
604  clib_memcpy (&a->tep.ip, mp->ip, (mp->is_ip4 ?
605  sizeof (ip4_address_t) :
606  sizeof (ip6_address_t)));
607  a->tep.is_ip4 = mp->is_ip4;
608  a->tep.port = mp->port;
609  a->tep.vrf = mp->vrf;
610  a->app_index = app->index;
611 
612  rv = vnet_bind (a);
613  }
614 done:
615  REPLY_MACRO (VL_API_BIND_SOCK_REPLY);
616 }
617 
618 static void
620 {
621  vl_api_unbind_sock_reply_t *rmp;
622  vnet_unbind_args_t _a, *a = &_a;
623  application_t *app;
624  int rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
625 
626  if (session_manager_is_enabled () == 0)
627  {
628  rv = VNET_API_ERROR_FEATURE_DISABLED;
629  goto done;
630  }
631 
632  app = application_lookup (mp->client_index);
633  if (app)
634  {
635  a->app_index = mp->client_index;
636  a->handle = mp->handle;
637  rv = vnet_unbind (a);
638  }
639 
640 done:
641  REPLY_MACRO (VL_API_UNBIND_SOCK_REPLY);
642 }
643 
644 static void
646 {
648  vnet_connect_args_t _a, *a = &_a;
649  application_t *app;
650  int rv;
651 
652  if (session_manager_is_enabled () == 0)
653  {
654  rv = VNET_API_ERROR_FEATURE_DISABLED;
655  goto done;
656  }
657 
658  app = application_lookup (mp->client_index);
659  if (app)
660  {
661  unix_shared_memory_queue_t *client_q;
662  u8 *ip = mp->is_ip4 ? (u8 *) & a->tep.ip.ip4 : (u8 *) & a->tep.ip;
663 
665  mp->client_queue_address = pointer_to_uword (client_q);
666  a->tep.is_ip4 = mp->is_ip4;
667  a->tep.port = mp->port;
668 
669  clib_memcpy (ip, mp->ip,
670  (mp->is_ip4 ? sizeof (ip4_address_t) :
671  sizeof (ip6_address_t)));
672  a->api_context = mp->context;
673  a->app_index = app->index;
674  a->proto = mp->proto;
675  a->mp = mp;
676  rv = vnet_connect (a);
677  }
678  else
679  {
680  rv = VNET_API_ERROR_APPLICATION_NOT_ATTACHED;
681  }
682 
683  if (rv == 0 || rv == VNET_CONNECT_REDIRECTED)
684  return;
685 
686  /* Got some error, relay it */
687 
688 done:
689  REPLY_MACRO (VL_API_CONNECT_SOCK_REPLY);
690 }
691 
692 static clib_error_t *
694 {
695  application_t *app = application_lookup (client_index);
696  vnet_app_detach_args_t _a, *a = &_a;
697  if (app)
698  {
699  a->app_index = app->index;
701  }
702  return 0;
703 }
704 
706 
707 #define vl_msg_name_crc_list
708 #include <vnet/vnet_all_api_h.h>
709 #undef vl_msg_name_crc_list
710 
711 static void
713 {
714 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
715  foreach_vl_msg_name_crc_session;
716 #undef _
717 }
718 
719 /*
720  * session_api_hookup
721  * Add uri's API message handlers to the table.
722  * vlib has alread mapped shared memory and
723  * added the client registration handlers.
724  * See .../open-repo/vlib/memclnt_vlib.c:memclnt_process()
725  */
726 static clib_error_t *
728 {
729  api_main_t *am = &api_main;
730 
731 #define _(N,n) \
732  vl_msg_api_set_handlers(VL_API_##N, #n, \
733  vl_api_##n##_t_handler, \
734  vl_noop_handler, \
735  vl_api_##n##_t_endian, \
736  vl_api_##n##_t_print, \
737  sizeof(vl_api_##n##_t), 1);
739 #undef _
740 
741  /*
742  * Messages which bounce off the data-plane to
743  * an API client. Simply tells the message handling infra not
744  * to free the message.
745  *
746  * Bounced message handlers MUST NOT block the data plane
747  */
748  am->message_bounce[VL_API_CONNECT_URI] = 1;
749  am->message_bounce[VL_API_CONNECT_SOCK] = 1;
750 
751  /*
752  * Set up the (msg_name, crc, message-id) table
753  */
755 
756  return 0;
757 }
758 
760 
761 /*
762  * fd.io coding-style-patch-verification: ON
763  *
764  * Local Variables:
765  * eval: (c-set-style "gnu")
766  * End:
767  */
static void vl_api_disconnect_session_reply_t_handler(vl_api_disconnect_session_reply_t *mp)
Definition: session_api.c:492
static clib_error_t * session_api_hookup(vlib_main_t *vm)
Definition: session_api.c:727
vpp->client reset session API
Definition: session.api:211
a
Definition: bitmap.h:516
VL_MSG_API_REAPER_FUNCTION(application_reaper_cb)
struct _transport_connection transport_connection_t
struct _vnet_connect_args vnet_connect_args_t
int vnet_bind_uri(vnet_bind_args_t *a)
#define REPLY_MACRO2(t, body)
static f64 vlib_time_now(vlib_main_t *vm)
Definition: main.h:192
u8 * message_bounce
Definition: api_common.h:176
static void vl_api_map_another_segment_reply_t_handler(vl_api_map_another_segment_reply_t *mp)
Definition: session_api.c:580
Bind to an ip:port pair for a given transport protocol.
Definition: session.api:241
client->vpp, reply to an accept message
Definition: session.api:173
application_t * application_lookup(u32 api_client_index)
Definition: application.c:66
static void vl_api_unbind_sock_t_handler(vl_api_unbind_sock_t *mp)
Definition: session_api.c:619
#define foreach_session_api_msg
Definition: session_api.c:39
static u8 session_manager_is_enabled()
Definition: session.h:466
struct _stream_session_t stream_session_t
#define VNET_CONNECT_REDIRECTED
Server can handle delegated connect requests from local clients.
static void vl_api_connect_uri_t_handler(vl_api_connect_uri_t *mp)
Definition: session_api.c:423
int vnet_unbind_uri(vnet_unbind_args_t *a)
static void vl_api_session_enable_disable_t_handler(vl_api_session_enable_disable_t *mp)
Definition: session_api.c:280
struct _vnet_disconnect_args_t vnet_disconnect_args_t
int vnet_bind(vnet_bind_args_t *a)
static void send_session_reset_callback(stream_session_t *s)
Definition: session_api.c:136
struct _stream_session_cb_vft session_cb_vft_t
struct _vnet_unbind_args_t vnet_unbind_args_t
unsigned long u64
Definition: types.h:89
void stream_session_cleanup(stream_session_t *s)
Cleanup transport and session state.
Definition: session.c:1025
static uword pointer_to_uword(const void *p)
Definition: types.h:131
void * vl_msg_api_alloc(int nbytes)
struct _vnet_app_attach_args_t vnet_app_attach_args_t
struct _transport_proto_vft transport_proto_vft_t
int unix_shared_memory_queue_add(unix_shared_memory_queue_t *q, u8 *elem, int nowait)
static session_cb_vft_t uri_session_cb_vft
Definition: session_api.c:270
static void vl_api_accept_session_reply_t_handler(vl_api_accept_session_reply_t *mp)
Definition: session_api.c:547
client->vpp, attach application to session layer
Definition: session.api:23
static void vl_api_disconnect_session_t_handler(vl_api_disconnect_session_t *mp)
Definition: session_api.c:462
void vl_msg_api_free(void *)
#define REPLY_MACRO(t)
static clib_error_t * application_reaper_cb(u32 client_index)
Definition: session_api.c:693
Unbind a given URI.
Definition: session.api:91
clib_error_t * vnet_session_enable_disable(vlib_main_t *vm, u8 is_en)
Definition: session.c:1179
vpp->client, accept this session
Definition: session.api:153
int send_session_connected_callback(u32 app_index, u32 api_context, stream_session_t *s, u8 is_fail)
Definition: session_api.c:155
static int send_session_accept_callback(stream_session_t *s)
Definition: session_api.c:80
static unix_shared_memory_queue_t * session_manager_get_vpp_event_queue(u32 thread_index)
Definition: session.h:406
api_main_t api_main
Definition: api_shared.c:35
vpp->client, connect reply
Definition: session.api:129
#define clib_warning(format, args...)
Definition: error.h:59
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:203
#define clib_memcpy(a, b, c)
Definition: string.h:69
unix_shared_memory_queue_t * vl_api_client_index_to_input_queue(u32 index)
struct _application application_t
int vnet_disconnect_session(vnet_disconnect_args_t *a)
static stream_session_t * stream_session_get_if_valid(u64 si, u32 thread_index)
Definition: session.h:287
Application attach reply.
Definition: session.api:39
int vnet_application_attach(vnet_app_attach_args_t *a)
Attaches application.
void vl_msg_api_send_shmem(unix_shared_memory_queue_t *q, u8 *elem)
static void stream_session_parse_handle(u64 handle, u32 *index, u32 *thread_index)
Definition: session.h:317
unsigned int u32
Definition: types.h:88
enable/disable session layer
Definition: session.api:340
static void vl_api_connect_sock_t_handler(vl_api_connect_sock_t *mp)
Definition: session_api.c:645
client->vpp, attach application to session layer
Definition: session.api:52
static void vl_api_bind_sock_t_handler(vl_api_bind_sock_t *mp)
Definition: session_api.c:587
vpp->client, please map an additional shared memory segment
Definition: session.api:62
struct _vnet_app_detach_args_t vnet_app_detach_args_t
Connect to a remote peer.
Definition: session.api:276
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
static void vl_api_application_attach_t_handler(vl_api_application_attach_t *mp)
Definition: session_api.c:291
transport_proto_vft_t * session_get_transport_vft(u8 type)
Definition: session.c:1055
static void setup_message_id_table(api_main_t *am)
Definition: session_api.c:712
static u64 stream_session_handle(stream_session_t *s)
Definition: session.h:299
bidirectional disconnect API
Definition: session.api:185
double f64
Definition: types.h:142
static stream_session_t * listen_session_get(session_type_t type, u32 index)
Definition: session.h:453
unsigned char u8
Definition: types.h:56
Bind to a given URI.
Definition: session.api:77
#define STATIC_ASSERT(truth,...)
application_t * application_get(u32 index)
Definition: application.c:189
int vnet_connect(vnet_connect_args_t *a)
int vnet_unbind(vnet_unbind_args_t *a)
VLIB_API_INIT_FUNCTION(session_api_hookup)
static int send_add_segment_callback(u32 api_client_index, const u8 *segment_name, u32 segment_size)
Definition: session_api.c:56
static void send_session_disconnect_callback(stream_session_t *s)
Definition: session_api.c:117
static void vl_api_application_detach_t_handler(vl_api_application_detach_t *mp)
Definition: session_api.c:337
vpp/server->client, connect reply
Definition: session.api:321
client->vpp reset session reply
Definition: session.api:224
Connect to a given URI.
Definition: session.api:108
bidirectional disconnect reply API
Definition: session.api:198
int vnet_connect_uri(vnet_connect_args_t *a)
int vnet_application_detach(vnet_app_detach_args_t *a)
struct _vnet_bind_args_t vnet_bind_args_t
static u64 listen_session_get_handle(stream_session_t *s)
Definition: session.h:414
static void vl_api_bind_uri_t_handler(vl_api_bind_uri_t *mp)
Definition: session_api.c:362
static void vl_api_reset_session_reply_t_handler(vl_api_reset_session_reply_t *mp)
Definition: session_api.c:516
struct _unix_shared_memory_queue unix_shared_memory_queue_t
static void vl_api_unbind_uri_t_handler(vl_api_unbind_uri_t *mp)
Definition: session_api.c:393