FD.io VPP  v19.08-27-gf4dcae4
Vector Packet Processing
echo_server.c
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2017-2019 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>
20 #include <vnet/session/session.h>
21 
22 #define ECHO_SERVER_DBG (0)
23 #define DBG(_fmt, _args...) \
24  if (ECHO_SERVER_DBG) \
25  clib_warning (_fmt, ##_args)
26 
27 typedef struct
28 {
29  /*
30  * Server app parameters
31  */
33  svm_queue_t *vl_input_queue; /**< Sever's event queue */
34 
35  u32 app_index; /**< Server app index */
36  u32 my_client_index; /**< API client handle */
37  u32 node_index; /**< process node index for event scheduling */
38 
39  /*
40  * Config params
41  */
42  u8 no_echo; /**< Don't echo traffic */
43  u32 fifo_size; /**< Fifo size */
44  u32 rcv_buffer_size; /**< Rcv buffer size */
45  u32 prealloc_fifos; /**< Preallocate fifos */
46  u32 private_segment_count; /**< Number of private segments */
47  u32 private_segment_size; /**< Size of private segments */
48  char *server_uri; /**< Server URI */
49  u32 tls_engine; /**< TLS engine: mbedtls/openssl */
50  u8 is_dgram; /**< set if transport is dgram */
51  /*
52  * Test state
53  */
54  u8 **rx_buf; /**< Per-thread RX buffer */
58  u64 listener_handle; /**< Session handle of the root listener */
59 
62 
64 
65 int
67 {
68  DBG ("QSession %u accept w/opaque %d", s->session_index, s->opaque);
69  return 0;
70 }
71 
72 int
74 {
76  if (s->listener_handle == esm->listener_handle)
78  DBG ("SSESSION %u accept w/opaque %d", s->session_index, s->opaque);
79 
80  esm->vpp_queue[s->thread_index] =
83  esm->byte_index = 0;
84  ASSERT (vec_len (esm->rx_retries) > s->thread_index);
86  esm->rx_retries[s->thread_index][s->session_index] = 0;
87  return 0;
88 }
89 
90 int
92 {
94  esm->vpp_queue[s->thread_index] =
97  esm->byte_index = 0;
98  ASSERT (vec_len (esm->rx_retries) > s->thread_index);
100  esm->rx_retries[s->thread_index][s->session_index] = 0;
101  return 0;
102 }
103 
104 void
106 {
108  vnet_disconnect_args_t _a = { 0 }, *a = &_a;
109 
110  a->handle = session_handle (s);
111  a->app_index = esm->app_index;
113 }
114 
115 void
117 {
119  vnet_disconnect_args_t _a = { 0 }, *a = &_a;
120  clib_warning ("Reset session %U", format_session, s, 2);
121  a->handle = session_handle (s);
122  a->app_index = esm->app_index;
124 }
125 
126 int
128  session_t * s, u8 is_fail)
129 {
130  clib_warning ("called...");
131  return -1;
132 }
133 
134 int
135 echo_server_add_segment_callback (u32 client_index, u64 segment_handle)
136 {
137  /* New heaps may be added */
138  return 0;
139 }
140 
141 int
143 {
144  clib_warning ("called...");
145  return -1;
146 }
147 
148 void
149 test_bytes (echo_server_main_t * esm, int actual_transfer)
150 {
151  int i;
152  u32 my_thread_id = vlib_get_thread_index ();
153 
154  for (i = 0; i < actual_transfer; i++)
155  {
156  if (esm->rx_buf[my_thread_id][i] != ((esm->byte_index + i) & 0xff))
157  {
158  clib_warning ("at %lld expected %d got %d", esm->byte_index + i,
159  (esm->byte_index + i) & 0xff,
160  esm->rx_buf[my_thread_id][i]);
161  }
162  }
163  esm->byte_index += actual_transfer;
164 }
165 
166 /*
167  * If no-echo, just drop the data and be done with it.
168  */
169 int
171 {
172  svm_fifo_t *rx_fifo = s->rx_fifo;
174  return 0;
175 }
176 
177 int
179 {
180  u32 n_written, max_dequeue, max_enqueue, max_transfer;
181  int actual_transfer;
182  svm_fifo_t *tx_fifo, *rx_fifo;
184  u32 thread_index = vlib_get_thread_index ();
186 
187  ASSERT (s->thread_index == thread_index);
188 
189  rx_fifo = s->rx_fifo;
190  tx_fifo = s->tx_fifo;
191 
192  ASSERT (rx_fifo->master_thread_index == thread_index);
193  ASSERT (tx_fifo->master_thread_index == thread_index);
194 
195  max_enqueue = svm_fifo_max_enqueue_prod (tx_fifo);
196  if (!esm->is_dgram)
197  {
198  max_dequeue = svm_fifo_max_dequeue_cons (rx_fifo);
199  }
200  else
201  {
203  svm_fifo_peek (rx_fifo, 0, sizeof (ph), (u8 *) & ph);
204  max_dequeue = ph.data_length - ph.data_offset;
205  if (!esm->vpp_queue[s->thread_index])
206  {
207  svm_msg_q_t *mq;
209  esm->vpp_queue[s->thread_index] = mq;
210  }
211  max_enqueue -= sizeof (session_dgram_hdr_t);
212  }
213 
214  if (PREDICT_FALSE (max_dequeue == 0))
215  return 0;
216 
217  /* Number of bytes we're going to copy */
218  max_transfer = clib_min (max_dequeue, max_enqueue);
219 
220  /* No space in tx fifo */
221  if (PREDICT_FALSE (max_transfer == 0))
222  {
223  /* XXX timeout for session that are stuck */
224 
225  rx_event:
226  /* Program self-tap to retry */
227  if (svm_fifo_set_event (rx_fifo))
228  {
229  if (session_send_io_evt_to_thread (rx_fifo,
231  clib_warning ("failed to enqueue self-tap");
232 
234  if (esm->rx_retries[thread_index][s->session_index] == 500000)
235  {
236  clib_warning ("session stuck: %U", format_session, s, 2);
237  }
238  if (esm->rx_retries[thread_index][s->session_index] < 500001)
239  esm->rx_retries[thread_index][s->session_index]++;
240  }
241 
242  return 0;
243  }
244 
245  vec_validate (esm->rx_buf[thread_index], max_transfer);
246  if (!esm->is_dgram)
247  {
248  actual_transfer = app_recv_stream_raw (rx_fifo,
249  esm->rx_buf[thread_index],
250  max_transfer,
251  0 /* don't clear event */ ,
252  0 /* peek */ );
253  }
254  else
255  {
256  actual_transfer = app_recv_dgram_raw (rx_fifo,
257  esm->rx_buf[thread_index],
258  max_transfer, &at,
259  0 /* don't clear event */ ,
260  0 /* peek */ );
261  }
262  ASSERT (actual_transfer == max_transfer);
263  /* test_bytes (esm, actual_transfer); */
264 
265  /*
266  * Echo back
267  */
268 
269  if (!esm->is_dgram)
270  {
271  n_written = app_send_stream_raw (tx_fifo,
272  esm->vpp_queue[thread_index],
273  esm->rx_buf[thread_index],
274  actual_transfer, SESSION_IO_EVT_TX,
275  1 /* do_evt */ , 0);
276  }
277  else
278  {
279  n_written = app_send_dgram_raw (tx_fifo, &at,
280  esm->vpp_queue[s->thread_index],
281  esm->rx_buf[thread_index],
282  actual_transfer, SESSION_IO_EVT_TX,
283  1 /* do_evt */ , 0);
284  }
285 
286  if (n_written != max_transfer)
287  clib_warning ("short trout! written %u read %u", n_written, max_transfer);
288 
290  goto rx_event;
291 
292  return 0;
293 }
294 
296  .session_accept_callback = echo_server_session_accept_callback,
297  .session_disconnect_callback = echo_server_session_disconnect_callback,
298  .session_connected_callback = echo_server_session_connected_callback,
299  .add_segment_callback = echo_server_add_segment_callback,
300  .builtin_app_rx_callback = echo_server_rx_callback,
301  .session_reset_callback = echo_server_session_reset_callback
302 };
303 
304 /* Abuse VPP's input queue */
305 static int
307 {
309  api_main_t *am = &api_main;
310  vl_shmem_hdr_t *shmem_hdr;
311 
312  shmem_hdr = am->shmem_hdr;
313  esm->vl_input_queue = shmem_hdr->vl_input_queue;
314  esm->my_client_index = vl_api_memclnt_create_internal ("echo_server",
315  esm->vl_input_queue);
316  return 0;
317 }
318 
319 static int
320 echo_server_attach (u8 * appns_id, u64 appns_flags, u64 appns_secret)
321 {
322  vnet_app_add_tls_cert_args_t _a_cert, *a_cert = &_a_cert;
323  vnet_app_add_tls_key_args_t _a_key, *a_key = &_a_key;
325  vnet_app_attach_args_t _a, *a = &_a;
326  u64 options[APP_OPTIONS_N_OPTIONS];
327  u32 segment_size = 512 << 20;
328 
329  clib_memset (a, 0, sizeof (*a));
330  clib_memset (options, 0, sizeof (options));
331 
332  if (esm->no_echo)
333  echo_server_session_cb_vft.builtin_app_rx_callback =
335  else
336  echo_server_session_cb_vft.builtin_app_rx_callback =
339  echo_server_session_cb_vft.session_accept_callback =
341 
342  if (esm->private_segment_size)
343  segment_size = esm->private_segment_size;
344 
345  a->api_client_index = esm->my_client_index;
346  a->session_cb_vft = &echo_server_session_cb_vft;
347  a->options = options;
348  a->options[APP_OPTIONS_SEGMENT_SIZE] = segment_size;
349  a->options[APP_OPTIONS_ADD_SEGMENT_SIZE] = segment_size;
350  a->options[APP_OPTIONS_RX_FIFO_SIZE] = esm->fifo_size;
351  a->options[APP_OPTIONS_TX_FIFO_SIZE] = esm->fifo_size;
353  a->options[APP_OPTIONS_TLS_ENGINE] = esm->tls_engine;
354  a->options[APP_OPTIONS_PREALLOC_FIFO_PAIRS] =
355  esm->prealloc_fifos ? esm->prealloc_fifos : 1;
356 
357  a->options[APP_OPTIONS_FLAGS] = APP_OPTIONS_FLAGS_IS_BUILTIN;
358  if (appns_id)
359  {
360  a->namespace_id = appns_id;
361  a->options[APP_OPTIONS_FLAGS] |= appns_flags;
362  a->options[APP_OPTIONS_NAMESPACE_SECRET] = appns_secret;
363  }
364 
365  if (vnet_application_attach (a))
366  {
367  clib_warning ("failed to attach server");
368  return -1;
369  }
370  esm->app_index = a->app_index;
371 
372  clib_memset (a_cert, 0, sizeof (*a_cert));
373  a_cert->app_index = a->app_index;
374  vec_validate (a_cert->cert, test_srv_crt_rsa_len);
376  vnet_app_add_tls_cert (a_cert);
377 
378  clib_memset (a_key, 0, sizeof (*a_key));
379  a_key->app_index = a->app_index;
380  vec_validate (a_key->key, test_srv_key_rsa_len);
382  vnet_app_add_tls_key (a_key);
383  return 0;
384 }
385 
386 static int
388 {
390  vnet_app_detach_args_t _da, *da = &_da;
391  int rv;
392 
393  da->app_index = esm->app_index;
394  rv = vnet_application_detach (da);
395  esm->app_index = ~0;
396  return rv;
397 }
398 
399 static int
401 {
402  int rv;
404  vnet_listen_args_t _a, *a = &_a;
405  clib_memset (a, 0, sizeof (*a));
406  a->app_index = esm->app_index;
407  a->uri = esm->server_uri;
408  rv = vnet_bind_uri (a);
409  esm->listener_handle = a->handle;
410  return rv;
411 }
412 
413 static int
414 echo_server_create (vlib_main_t * vm, u8 * appns_id, u64 appns_flags,
415  u64 appns_secret)
416 {
419  u32 num_threads;
420  int i;
421 
422  if (esm->my_client_index == (u32) ~ 0)
423  {
424  if (create_api_loopback (vm))
425  {
426  clib_warning ("failed to create api loopback");
427  return -1;
428  }
429  }
430 
431  num_threads = 1 /* main thread */ + vtm->n_threads;
432  vec_validate (echo_server_main.vpp_queue, num_threads - 1);
433  vec_validate (esm->rx_buf, num_threads - 1);
434  vec_validate (esm->rx_retries, num_threads - 1);
435  for (i = 0; i < vec_len (esm->rx_retries); i++)
436  vec_validate (esm->rx_retries[i],
439  for (i = 0; i < num_threads; i++)
440  vec_validate (esm->rx_buf[i], esm->rcv_buffer_size);
441 
442  if (echo_server_attach (appns_id, appns_flags, appns_secret))
443  {
444  clib_warning ("failed to attach server");
445  return -1;
446  }
447  if (echo_server_listen ())
448  {
449  clib_warning ("failed to start listening");
450  if (echo_server_detach ())
451  clib_warning ("failed to detach");
452  return -1;
453  }
454  return 0;
455 }
456 
457 static clib_error_t *
459  vlib_cli_command_t * cmd)
460 {
462  u8 server_uri_set = 0, *appns_id = 0;
463  u64 tmp, appns_flags = 0, appns_secret = 0;
464  char *default_uri = "tcp://0.0.0.0/1234";
465  int rv, is_stop = 0;
467 
468  esm->no_echo = 0;
469  esm->fifo_size = 64 << 10;
470  esm->rcv_buffer_size = 128 << 10;
471  esm->prealloc_fifos = 0;
472  esm->private_segment_count = 0;
473  esm->private_segment_size = 0;
475  vec_free (esm->server_uri);
476 
478  {
479  if (unformat (input, "uri %s", &esm->server_uri))
480  server_uri_set = 1;
481  else if (unformat (input, "no-echo"))
482  esm->no_echo = 1;
483  else if (unformat (input, "fifo-size %d", &esm->fifo_size))
484  esm->fifo_size <<= 10;
485  else if (unformat (input, "rcv-buf-size %d", &esm->rcv_buffer_size))
486  ;
487  else if (unformat (input, "prealloc-fifos %d", &esm->prealloc_fifos))
488  ;
489  else if (unformat (input, "private-segment-count %d",
490  &esm->private_segment_count))
491  ;
492  else if (unformat (input, "private-segment-size %U",
493  unformat_memory_size, &tmp))
494  {
495  if (tmp >= 0x100000000ULL)
496  return clib_error_return
497  (0, "private segment size %lld (%llu) too large", tmp, tmp);
498  esm->private_segment_size = tmp;
499  }
500  else if (unformat (input, "appns %_%v%_", &appns_id))
501  ;
502  else if (unformat (input, "all-scope"))
503  appns_flags |= (APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE
504  | APP_OPTIONS_FLAGS_USE_LOCAL_SCOPE);
505  else if (unformat (input, "local-scope"))
506  appns_flags |= APP_OPTIONS_FLAGS_USE_LOCAL_SCOPE;
507  else if (unformat (input, "global-scope"))
508  appns_flags |= APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE;
509  else if (unformat (input, "secret %lu", &appns_secret))
510  ;
511  else if (unformat (input, "stop"))
512  is_stop = 1;
513  else if (unformat (input, "tls-engine %d", &esm->tls_engine))
514  ;
515  else
516  return clib_error_return (0, "failed: unknown input `%U'",
517  format_unformat_error, input);
518  }
519 
520  if (is_stop)
521  {
522  if (esm->app_index == (u32) ~ 0)
523  {
524  clib_warning ("server not running");
525  return clib_error_return (0, "failed: server not running");
526  }
527  rv = echo_server_detach ();
528  if (rv)
529  {
530  clib_warning ("failed: detach");
531  return clib_error_return (0, "failed: server detach %d", rv);
532  }
533  return 0;
534  }
535 
536  vnet_session_enable_disable (vm, 1 /* turn on TCP, etc. */ );
537 
538  if (!server_uri_set)
539  {
540  clib_warning ("No uri provided! Using default: %s", default_uri);
541  esm->server_uri = (char *) format (0, "%s%c", default_uri, 0);
542  }
543 
544  if ((rv = parse_uri ((char *) esm->server_uri, &sep)))
545  return clib_error_return (0, "Uri parse error: %d", rv);
546  esm->transport_proto = sep.transport_proto;
547  esm->is_dgram = (sep.transport_proto == TRANSPORT_PROTO_UDP);
548 
549  rv = echo_server_create (vm, appns_id, appns_flags, appns_secret);
550  vec_free (appns_id);
551  if (rv)
552  {
553  vec_free (esm->server_uri);
554  return clib_error_return (0, "failed: server_create returned %d", rv);
555  }
556 
557  return 0;
558 }
559 
560 /* *INDENT-OFF* */
561 VLIB_CLI_COMMAND (echo_server_create_command, static) =
562 {
563  .path = "test echo server",
564  .short_help = "test echo server proto <proto> [no echo][fifo-size <mbytes>]"
565  "[rcv-buf-size <bytes>][prealloc-fifos <count>]"
566  "[private-segment-count <count>][private-segment-size <bytes[m|g]>]"
567  "[uri <tcp://ip/port>]",
568  .function = echo_server_create_command_fn,
569 };
570 /* *INDENT-ON* */
571 
572 clib_error_t *
574 {
576  esm->my_client_index = ~0;
577  return 0;
578 }
579 
581 
582 /*
583 * fd.io coding-style-patch-verification: ON
584 *
585 * Local Variables:
586 * eval: (c-set-style "gnu")
587 * End:
588 */
static int echo_server_listen()
Definition: echo_server.c:400
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:439
static int app_recv_stream_raw(svm_fifo_t *f, u8 *buf, u32 len, u8 clear_evt, u8 peek)
int echo_server_session_accept_callback(session_t *s)
Definition: echo_server.c:91
#define clib_min(x, y)
Definition: clib.h:295
u32 vl_api_memclnt_create_internal(char *name, svm_queue_t *q)
Definition: memory_api.c:120
static u32 svm_fifo_max_enqueue_prod(svm_fifo_t *f)
Maximum number of bytes that can be enqueued into fifo.
Definition: svm_fifo.h:609
u8 * format_session(u8 *s, va_list *args)
Format stream session as per the following format.
Definition: session_cli.c:55
a
Definition: bitmap.h:538
svm_fifo_t * tx_fifo
session_main_t session_main
Definition: session.c:26
u32 session_index
Index in thread pool where session was allocated.
u8 no_echo
Don&#39;t echo traffic.
Definition: echo_server.c:42
unsigned long u64
Definition: types.h:89
static svm_msg_q_t * session_main_get_vpp_event_queue(u32 thread_index)
Definition: session.h:554
#define clib_memcpy_fast(a, b, c)
Definition: string.h:81
u32 fifo_size
Fifo size.
Definition: echo_server.c:43
void echo_server_session_disconnect_callback(session_t *s)
Definition: echo_server.c:105
svm_fifo_t * rx_fifo
Pointers to rx/tx buffers.
session_worker_t * wrk
Worker contexts.
Definition: session.h:130
u32 private_segment_size
Size of private segments.
Definition: echo_server.c:47
static int echo_server_detach(void)
Definition: echo_server.c:387
int svm_fifo_peek(svm_fifo_t *f, u32 offset, u32 len, u8 *dst)
Peek data from fifo.
Definition: svm_fifo.c:926
int i
clib_memset(h->entries, 0, sizeof(h->entries[0])*entries)
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
int quic_echo_server_session_accept_callback(session_t *s)
Definition: echo_server.c:73
struct _vnet_application_add_tls_cert_args_t vnet_app_add_tls_cert_args_t
u32 tls_engine
TLS engine: mbedtls/openssl.
Definition: echo_server.c:49
clib_error_t * vnet_app_add_tls_cert(vnet_app_add_tls_cert_args_t *a)
Definition: application.c:1300
unsigned char u8
Definition: types.h:56
struct _vnet_bind_args_t vnet_listen_args_t
session_t * sessions
Worker session pool.
Definition: session.h:76
static session_handle_t session_handle(session_t *s)
u32 my_client_index
API client handle.
Definition: echo_server.c:36
struct _svm_fifo svm_fifo_t
svm_msg_q_t ** vpp_queue
Definition: echo_server.c:32
int echo_server_session_connected_callback(u32 app_index, u32 api_context, session_t *s, u8 is_fail)
Definition: echo_server.c:127
u32 prealloc_fifos
Preallocate fifos.
Definition: echo_server.c:45
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:173
struct _vnet_disconnect_args_t vnet_disconnect_args_t
svm_queue_t * vl_input_queue
Sever&#39;s event queue.
Definition: echo_server.c:33
static const u32 test_srv_key_rsa_len
Definition: tls_test.h:77
static u32 svm_fifo_max_dequeue_cons(svm_fifo_t *f)
Fifo max bytes to dequeue optimized for consumer.
Definition: svm_fifo.h:489
#define clib_error_return(e, args...)
Definition: error.h:99
struct vl_shmem_hdr_ * shmem_hdr
Binary API shared-memory segment header pointer.
Definition: api_common.h:266
unsigned int u32
Definition: types.h:88
int session_send_io_evt_to_thread(svm_fifo_t *f, session_evt_type_t evt_type)
Definition: session.c:79
static int echo_server_attach(u8 *appns_id, u64 appns_flags, u64 appns_secret)
Definition: echo_server.c:320
echo_server_main_t echo_server_main
Definition: echo_server.c:63
static int app_recv_dgram_raw(svm_fifo_t *f, u8 *buf, u32 len, app_session_transport_t *at, u8 clear_evt, u8 peek)
struct _vnet_app_attach_args_t vnet_app_attach_args_t
struct _session_endpoint_cfg session_endpoint_cfg_t
clib_error_t * vnet_app_add_tls_key(vnet_app_add_tls_key_args_t *a)
Definition: application.c:1312
#define DBG(_fmt, _args...)
Definition: echo_server.c:23
struct _unformat_input_t unformat_input_t
#define PREDICT_FALSE(x)
Definition: clib.h:111
void echo_server_session_reset_callback(session_t *s)
Definition: echo_server.c:116
static const char test_srv_crt_rsa[]
Definition: tls_test.h:23
clib_error_t * vnet_session_enable_disable(vlib_main_t *vm, u8 is_en)
Definition: session.c:1543
static int app_send_dgram_raw(svm_fifo_t *f, app_session_transport_t *at, svm_msg_q_t *vpp_evt_q, u8 *data, u32 len, u8 evt_type, u8 do_evt, u8 noblock)
static clib_error_t * echo_server_create_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: echo_server.c:458
u32 app_index
Server app index.
Definition: echo_server.c:35
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:203
int vnet_application_attach(vnet_app_attach_args_t *a)
Attach application to vpp.
Definition: application.c:809
void test_bytes(echo_server_main_t *esm, int actual_transfer)
Definition: echo_server.c:149
static u8 svm_fifo_set_event(svm_fifo_t *f)
Set fifo event flag.
Definition: svm_fifo.h:739
#define UNFORMAT_END_OF_INPUT
Definition: format.h:145
session_handle_t listener_handle
Parent listener session index if the result of an accept.
static_always_inline uword vlib_get_thread_index(void)
Definition: threads.h:213
clib_error_t * echo_server_main_init(vlib_main_t *vm)
Definition: echo_server.c:573
vlib_main_t * vm
Definition: buffer.c:312
static int create_api_loopback(vlib_main_t *vm)
Definition: echo_server.c:306
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:341
#define clib_warning(format, args...)
Definition: error.h:59
struct _stream_session_cb_vft session_cb_vft_t
u32 node_index
process node index for event scheduling
Definition: echo_server.c:37
svm_queue_t * vl_input_queue
Definition: memory_shared.h:84
static const char test_srv_key_rsa[]
Definition: tls_test.h:49
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:155
#define ASSERT(truth)
int echo_server_builtin_server_rx_callback_no_echo(session_t *s)
Definition: echo_server.c:170
int echo_server_redirect_connect_callback(u32 client_index, void *mp)
Definition: echo_server.c:142
int vnet_application_detach(vnet_app_detach_args_t *a)
Detach application from vpp.
Definition: application.c:869
struct _vnet_application_add_tls_key_args_t vnet_app_add_tls_key_args_t
int echo_server_rx_callback(session_t *s)
Definition: echo_server.c:178
struct _vnet_app_detach_args_t vnet_app_detach_args_t
#define clib_max(x, y)
Definition: clib.h:288
int quic_echo_server_qsession_accept_callback(session_t *s)
Definition: echo_server.c:66
u8 thread_index
Index of the thread that allocated the session.
int parse_uri(char *uri, session_endpoint_cfg_t *sep)
int echo_server_add_segment_callback(u32 client_index, u64 segment_handle)
Definition: echo_server.c:135
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
volatile u8 session_state
State in session layer state machine.
u8 ** rx_buf
Per-thread RX buffer.
Definition: echo_server.c:54
u32 opaque
Opaque, for general use.
int vnet_bind_uri(vnet_listen_args_t *a)
static int app_send_stream_raw(svm_fifo_t *f, svm_msg_q_t *vpp_evt_q, u8 *data, u32 len, u8 evt_type, u8 do_evt, u8 noblock)
char * server_uri
Server URI.
Definition: echo_server.c:48
int vnet_disconnect_session(vnet_disconnect_args_t *a)
Definition: application.c:1064
u64 listener_handle
Session handle of the root listener.
Definition: echo_server.c:58
#define SESSION_ENDPOINT_CFG_NULL
Definition: session_types.h:74
u32 private_segment_count
Number of private segments.
Definition: echo_server.c:46
struct _svm_queue svm_queue_t
unformat_function_t unformat_memory_size
Definition: format.h:296
u8 is_dgram
set if transport is dgram
Definition: echo_server.c:50
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
static vlib_thread_main_t * vlib_get_thread_main()
Definition: global_funcs.h:32
u32 rcv_buffer_size
Rcv buffer size.
Definition: echo_server.c:44
static int echo_server_create(vlib_main_t *vm, u8 *appns_id, u64 appns_flags, u64 appns_secret)
Definition: echo_server.c:414
int svm_fifo_dequeue_drop(svm_fifo_t *f, u32 len)
Dequeue and drop bytes from fifo.
Definition: svm_fifo.c:948
api_main_t api_main
Definition: api_shared.c:35
struct session_dgram_header_ session_dgram_hdr_t
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
static session_cb_vft_t echo_server_session_cb_vft
Definition: echo_server.c:295
static const u32 test_srv_crt_rsa_len
Definition: tls_test.h:47
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:171
vlib_main_t * vlib_main
Definition: echo_server.c:60
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:128