FD.io VPP  v18.01.2-1-g9b554f3
Vector Packet Processing
api.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * api.c - message handler registration
4  *
5  * Copyright (c) 2010-2016 Cisco and/or its affiliates.
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at:
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *------------------------------------------------------------------
18  */
19 
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <string.h>
23 #include <sys/types.h>
24 #include <sys/mman.h>
25 #include <sys/stat.h>
26 #include <netinet/in.h>
27 #include <signal.h>
28 #include <pthread.h>
29 #include <unistd.h>
30 #include <time.h>
31 #include <fcntl.h>
32 #include <string.h>
33 #include <pwd.h>
34 #include <grp.h>
35 
36 #include <vppinfra/clib.h>
37 #include <vppinfra/vec.h>
38 #include <vppinfra/hash.h>
39 #include <vppinfra/bitmap.h>
40 #include <vppinfra/fifo.h>
41 #include <vppinfra/time.h>
42 #include <vppinfra/mheap.h>
43 #include <vppinfra/heap.h>
44 #include <vppinfra/pool.h>
45 #include <vppinfra/format.h>
46 #include <vppinfra/error.h>
47 
48 #include <vnet/api_errno.h>
49 #include <vnet/vnet.h>
50 
51 #include <vlib/vlib.h>
52 #include <vlib/unix/unix.h>
53 #include <vlibapi/api.h>
54 #include <vlibmemory/api.h>
55 
56 #undef BIHASH_TYPE
57 #undef __included_bihash_template_h__
58 
59 #include <vpp/stats/stats.h>
60 
61 #include <vpp/api/vpe_msg_enum.h>
62 
63 #define vl_typedefs /* define message structures */
64 #include <vpp/api/vpe_all_api_h.h>
65 #undef vl_typedefs
66 #define vl_endianfun /* define message structures */
67 #include <vpp/api/vpe_all_api_h.h>
68 #undef vl_endianfun
69 /* instantiate all the print functions we know about */
70 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
71 #define vl_printfun
72 #include <vpp/api/vpe_all_api_h.h>
73 #undef vl_printfun
75 #define foreach_vpe_api_msg \
76 _(CONTROL_PING, control_ping) \
77 _(CLI, cli) \
78 _(CLI_INBAND, cli_inband) \
79 _(GET_NODE_INDEX, get_node_index) \
80 _(ADD_NODE_NEXT, add_node_next) \
81 _(SHOW_VERSION, show_version) \
82 _(GET_NODE_GRAPH, get_node_graph) \
83 _(GET_NEXT_INDEX, get_next_index) \
84 
85 #define QUOTE_(x) #x
86 #define QUOTE(x) QUOTE_(x)
87 typedef enum
88 {
91 } resolve_t;
92 
94 
95 /* Clean up all registrations belonging to the indicated client */
96 static clib_error_t *
98 {
101  uword *p;
102  int stats_memclnt_delete_callback (u32 client_index);
103 
104  stats_memclnt_delete_callback (client_index);
105 
106 #define _(a) \
107  p = hash_get (vam->a##_registration_hash, client_index); \
108  if (p) { \
109  rp = pool_elt_at_index (vam->a##_registrations, p[0]); \
110  pool_put (vam->a##_registrations, rp); \
111  hash_unset (vam->a##_registration_hash, client_index); \
112  }
114 #undef _
115  return 0;
116 }
117 
119 
120 static void
122 {
124  int rv = 0;
125 
126  /* *INDENT-OFF* */
127  REPLY_MACRO2(VL_API_CONTROL_PING_REPLY,
128  ({
129  rmp->vpe_pid = ntohl (getpid());
130  }));
131  /* *INDENT-ON* */
132 }
133 
134 static void
135 shmem_cli_output (uword arg, u8 * buffer, uword buffer_bytes)
136 {
137  u8 **shmem_vecp = (u8 **) arg;
138  u8 *shmem_vec;
139  void *oldheap;
140  api_main_t *am = &api_main;
141  u32 offset;
142 
143  shmem_vec = *shmem_vecp;
144 
145  offset = vec_len (shmem_vec);
146 
147  pthread_mutex_lock (&am->vlib_rp->mutex);
148  oldheap = svm_push_data_heap (am->vlib_rp);
149 
150  vec_validate (shmem_vec, offset + buffer_bytes - 1);
151 
152  clib_memcpy (shmem_vec + offset, buffer, buffer_bytes);
153 
154  svm_pop_heap (oldheap);
155  pthread_mutex_unlock (&am->vlib_rp->mutex);
156 
157  *shmem_vecp = shmem_vec;
158 }
159 
160 
161 static void
163 {
164  vl_api_cli_reply_t *rp;
167  api_main_t *am = &api_main;
168  unformat_input_t input;
169  u8 *shmem_vec = 0;
170  void *oldheap;
171 
173  if (!q)
174  return;
175 
176  rp = vl_msg_api_alloc (sizeof (*rp));
177  rp->_vl_msg_id = ntohs (VL_API_CLI_REPLY);
178  rp->context = mp->context;
179 
180  unformat_init_vector (&input, (u8 *) (uword) mp->cmd_in_shmem);
181 
182  vlib_cli_input (vm, &input, shmem_cli_output, (uword) & shmem_vec);
183 
184  pthread_mutex_lock (&am->vlib_rp->mutex);
185  oldheap = svm_push_data_heap (am->vlib_rp);
186 
187  vec_add1 (shmem_vec, 0);
188 
189  svm_pop_heap (oldheap);
190  pthread_mutex_unlock (&am->vlib_rp->mutex);
191 
192  rp->reply_in_shmem = (uword) shmem_vec;
193 
194  vl_msg_api_send_shmem (q, (u8 *) & rp);
195 }
196 
197 static void
198 inband_cli_output (uword arg, u8 * buffer, uword buffer_bytes)
199 {
200  u8 **mem_vecp = (u8 **) arg;
201  u8 *mem_vec = *mem_vecp;
202  u32 offset = vec_len (mem_vec);
203 
204  vec_validate (mem_vec, offset + buffer_bytes - 1);
205  clib_memcpy (mem_vec + offset, buffer, buffer_bytes);
206  *mem_vecp = mem_vec;
207 }
208 
209 static void
211 {
213  int rv = 0;
215  unformat_input_t input;
216  u8 *out_vec = 0;
217 
218  unformat_init_string (&input, (char *) mp->cmd, ntohl (mp->length));
219  vlib_cli_input (vm, &input, inband_cli_output, (uword) & out_vec);
220 
221  u32 len = vec_len (out_vec);
222  /* *INDENT-OFF* */
223  REPLY_MACRO3(VL_API_CLI_INBAND_REPLY, len,
224  ({
225  rmp->length = htonl (len);
226  clib_memcpy (rmp->reply, out_vec, len);
227  }));
228  /* *INDENT-ON* */
229  vec_free (out_vec);
230 }
231 
232 static void
234 {
236  int rv = 0;
237  char *vpe_api_get_build_directory (void);
238  char *vpe_api_get_version (void);
239  char *vpe_api_get_build_date (void);
240 
241  /* *INDENT-OFF* */
242  REPLY_MACRO2(VL_API_SHOW_VERSION_REPLY,
243  ({
244  strncpy ((char *) rmp->program, "vpe", ARRAY_LEN(rmp->program)-1);
245  strncpy ((char *) rmp->build_directory, vpe_api_get_build_directory(),
246  ARRAY_LEN(rmp->build_directory)-1);
247  strncpy ((char *) rmp->version, vpe_api_get_version(),
248  ARRAY_LEN(rmp->version)-1);
249  strncpy ((char *) rmp->build_date, vpe_api_get_build_date(),
250  ARRAY_LEN(rmp->build_date)-1);
251  }));
252  /* *INDENT-ON* */
253 }
254 
255 static void
257 {
260  vlib_node_t *n;
261  int rv = 0;
262  u32 node_index = ~0;
263 
264  n = vlib_get_node_by_name (vm, mp->node_name);
265 
266  if (n == 0)
267  rv = VNET_API_ERROR_NO_SUCH_NODE;
268  else
269  node_index = n->index;
270 
271  /* *INDENT-OFF* */
272  REPLY_MACRO2(VL_API_GET_NODE_INDEX_REPLY,
273  ({
274  rmp->node_index = ntohl(node_index);
275  }));
276  /* *INDENT-ON* */
277 }
278 
279 static void
281 {
284  vlib_node_t *node, *next_node;
285  int rv = 0;
286  u32 next_node_index = ~0, next_index = ~0;
287  uword *p;
288 
289  node = vlib_get_node_by_name (vm, mp->node_name);
290 
291  if (node == 0)
292  {
293  rv = VNET_API_ERROR_NO_SUCH_NODE;
294  goto out;
295  }
296 
297  next_node = vlib_get_node_by_name (vm, mp->next_name);
298 
299  if (next_node == 0)
300  {
301  rv = VNET_API_ERROR_NO_SUCH_NODE2;
302  goto out;
303  }
304  else
305  next_node_index = next_node->index;
306 
307  p = hash_get (node->next_slot_by_node, next_node_index);
308 
309  if (p == 0)
310  {
311  rv = VNET_API_ERROR_NO_SUCH_ENTRY;
312  goto out;
313  }
314  else
315  next_index = p[0];
316 
317 out:
318  /* *INDENT-OFF* */
319  REPLY_MACRO2(VL_API_GET_NEXT_INDEX_REPLY,
320  ({
321  rmp->next_index = ntohl(next_index);
322  }));
323  /* *INDENT-ON* */
324 }
325 
326 static void
328 {
331  vlib_node_t *n, *next;
332  int rv = 0;
333  u32 next_index = ~0;
334 
335  n = vlib_get_node_by_name (vm, mp->node_name);
336 
337  if (n == 0)
338  {
339  rv = VNET_API_ERROR_NO_SUCH_NODE;
340  goto out;
341  }
342 
343  next = vlib_get_node_by_name (vm, mp->next_name);
344 
345  if (next == 0)
346  rv = VNET_API_ERROR_NO_SUCH_NODE2;
347  else
348  next_index = vlib_node_add_next (vm, n->index, next->index);
349 
350 out:
351  /* *INDENT-OFF* */
352  REPLY_MACRO2(VL_API_GET_NODE_INDEX_REPLY,
353  ({
354  rmp->next_index = ntohl(next_index);
355  }));
356  /* *INDENT-ON* */
357 }
358 
359 static void
361 {
362  int rv = 0;
363  u8 *vector = 0;
364  api_main_t *am = &api_main;
366  void *oldheap;
368 
369  pthread_mutex_lock (&am->vlib_rp->mutex);
370  oldheap = svm_push_data_heap (am->vlib_rp);
371 
372  /*
373  * Keep the number of memcpy ops to a minimum (e.g. 1).
374  */
375  vec_validate (vector, 16384);
376  vec_reset_length (vector);
377 
378  /* $$$$ FIXME */
379  vector = vlib_node_serialize (&vm->node_main, vector,
380  (u32) ~ 0 /* all threads */ ,
381  1 /* include nexts */ ,
382  1 /* include stats */ );
383 
384  svm_pop_heap (oldheap);
385  pthread_mutex_unlock (&am->vlib_rp->mutex);
386 
387  /* *INDENT-OFF* */
388  REPLY_MACRO2(VL_API_GET_NODE_GRAPH_REPLY,
389  ({
390  rmp->reply_in_shmem = (uword) vector;
391  }));
392  /* *INDENT-ON* */
393 }
394 
395 #define BOUNCE_HANDLER(nn) \
396 static void vl_api_##nn##_t_handler ( \
397  vl_api_##nn##_t *mp) \
398 { \
399  vpe_client_registration_t *reg; \
400  vpe_api_main_t * vam = &vpe_api_main; \
401  unix_shared_memory_queue_t * q; \
402  \
403  /* One registration only... */ \
404  pool_foreach(reg, vam->nn##_registrations, \
405  ({ \
406  q = vl_api_client_index_to_input_queue (reg->client_index); \
407  if (q) { \
408  /* \
409  * If the queue is stuffed, turf the msg and complain \
410  * It's unlikely that the intended recipient is \
411  * alive; avoid deadlock at all costs. \
412  */ \
413  if (q->cursize == q->maxsize) { \
414  clib_warning ("ERROR: receiver queue full, drop msg"); \
415  vl_msg_api_free (mp); \
416  return; \
417  } \
418  vl_msg_api_send_shmem (q, (u8 *)&mp); \
419  return; \
420  } \
421  })); \
422  vl_msg_api_free (mp); \
423 }
424 
425 static void setup_message_id_table (api_main_t * am);
426 
427 /*
428  * vpe_api_hookup
429  * Add vpe's API message handlers to the table.
430  * vlib has alread mapped shared memory and
431  * added the client registration handlers.
432  * See .../open-repo/vlib/memclnt_vlib.c:memclnt_process()
433  */
434 static clib_error_t *
436 {
437  api_main_t *am = &api_main;
438 
439 #define _(N,n) \
440  vl_msg_api_set_handlers(VL_API_##N, #n, \
441  vl_api_##n##_t_handler, \
442  vl_noop_handler, \
443  vl_api_##n##_t_endian, \
444  vl_api_##n##_t_print, \
445  sizeof(vl_api_##n##_t), 1);
447 #undef _
448 
449  /*
450  * Trace space for classifier mask+match
451  */
452  am->api_trace_cfg[VL_API_CLASSIFY_ADD_DEL_TABLE].size += 5 * sizeof (u32x4);
453  am->api_trace_cfg[VL_API_CLASSIFY_ADD_DEL_SESSION].size
454  += 5 * sizeof (u32x4);
455 
456  /*
457  * Thread-safe API messages
458  */
459  am->is_mp_safe[VL_API_IP_ADD_DEL_ROUTE] = 1;
460  am->is_mp_safe[VL_API_GET_NODE_GRAPH] = 1;
461 
462  /*
463  * Set up the (msg_name, crc, message-id) table
464  */
466 
467  return 0;
468 }
469 
471 
472 static clib_error_t *
474 {
476 
477  am->vlib_main = vm;
478  am->vnet_main = vnet_get_main ();
479 #define _(a) \
480  am->a##_registration_hash = hash_create (0, sizeof (uword));
482 #undef _
483 
484  vl_set_memory_region_name ("/vpe-api");
485  vl_enable_disable_memory_api (vm, 1 /* enable it */ );
486 
487  return 0;
488 }
489 
491 
492 
493 static clib_error_t *
495 {
496  u8 *chroot_path;
497  u64 baseva, size, pvt_heap_size;
498  int uid, gid, rv;
499  const int max_buf_size = 4096;
500  char *s, *buf;
501  struct passwd _pw, *pw;
502  struct group _grp, *grp;
503  clib_error_t *e;
504  buf = vec_new (char, 128);
506  {
507  if (unformat (input, "prefix %s", &chroot_path))
508  {
509  vec_add1 (chroot_path, 0);
510  vl_set_memory_root_path ((char *) chroot_path);
511  }
512  else if (unformat (input, "uid %d", &uid))
513  vl_set_memory_uid (uid);
514  else if (unformat (input, "gid %d", &gid))
515  vl_set_memory_gid (gid);
516  else if (unformat (input, "baseva %llx", &baseva))
518  else if (unformat (input, "global-size %lldM", &size))
519  vl_set_global_memory_size (size * (1ULL << 20));
520  else if (unformat (input, "global-size %lldG", &size))
521  vl_set_global_memory_size (size * (1ULL << 30));
522  else if (unformat (input, "global-size %lld", &size))
524  else if (unformat (input, "global-pvt-heap-size %lldM", &pvt_heap_size))
525  vl_set_global_pvt_heap_size (pvt_heap_size * (1ULL << 20));
526  else if (unformat (input, "global-pvt-heap-size size %lld",
527  &pvt_heap_size))
528  vl_set_global_pvt_heap_size (pvt_heap_size);
529  else if (unformat (input, "api-pvt-heap-size %lldM", &pvt_heap_size))
530  vl_set_api_pvt_heap_size (pvt_heap_size * (1ULL << 20));
531  else if (unformat (input, "api-pvt-heap-size size %lld",
532  &pvt_heap_size))
533  vl_set_api_pvt_heap_size (pvt_heap_size);
534  else if (unformat (input, "api-size %lldM", &size))
535  vl_set_api_memory_size (size * (1ULL << 20));
536  else if (unformat (input, "api-size %lldG", &size))
537  vl_set_api_memory_size (size * (1ULL << 30));
538  else if (unformat (input, "api-size %lld", &size))
539  vl_set_api_memory_size (size);
540  else if (unformat (input, "uid %s", &s))
541  {
542  /* lookup the username */
543  pw = NULL;
544  while (((rv =
545  getpwnam_r (s, &_pw, buf, vec_len (buf), &pw)) == ERANGE)
546  && (vec_len (buf) <= max_buf_size))
547  {
548  vec_resize (buf, vec_len (buf) * 2);
549  }
550  if (rv < 0)
551  {
552  e = clib_error_return_code (0, rv,
555  "cannot fetch username %s", s);
556  vec_free (s);
557  vec_free (buf);
558  return e;
559  }
560  if (pw == NULL)
561  {
562  e =
563  clib_error_return_fatal (0, "username %s does not exist", s);
564  vec_free (s);
565  vec_free (buf);
566  return e;
567  }
568  vec_free (s);
569  vl_set_memory_uid (pw->pw_uid);
570  }
571  else if (unformat (input, "gid %s", &s))
572  {
573  /* lookup the group name */
574  grp = NULL;
575  while (((rv =
576  getgrnam_r (s, &_grp, buf, vec_len (buf), &grp)) == ERANGE)
577  && (vec_len (buf) <= max_buf_size))
578  {
579  vec_resize (buf, vec_len (buf) * 2);
580  }
581  if (rv != 0)
582  {
583  e = clib_error_return_code (0, rv,
586  "cannot fetch group %s", s);
587  vec_free (s);
588  vec_free (buf);
589  return e;
590  }
591  if (grp == NULL)
592  {
593  e = clib_error_return_fatal (0, "group %s does not exist", s);
594  vec_free (s);
595  vec_free (buf);
596  return e;
597  }
598  vec_free (s);
599  vec_free (buf);
600  vl_set_memory_gid (grp->gr_gid);
601  }
602  else
603  return clib_error_return (0, "unknown input `%U'",
604  format_unformat_error, input);
605  }
606  return 0;
607 }
608 
610 
611 void *
613 {
614  return (void *) &unformat_vnet_sw_interface;
615 }
616 
617 static u8 *
618 format_arp_event (u8 * s, va_list * args)
619 {
620  vl_api_ip4_arp_event_t *event = va_arg (*args, vl_api_ip4_arp_event_t *);
621 
622  s = format (s, "pid %d: ", ntohl (event->pid));
623  s = format (s, "resolution for %U", format_ip4_address, &event->address);
624  return s;
625 }
626 
627 static u8 *
628 format_nd_event (u8 * s, va_list * args)
629 {
630  vl_api_ip6_nd_event_t *event = va_arg (*args, vl_api_ip6_nd_event_t *);
631 
632  s = format (s, "pid %d: ", ntohl (event->pid));
633  s = format (s, "resolution for %U", format_ip6_address, event->address);
634  return s;
635 }
636 
637 static clib_error_t *
639  unformat_input_t * input, vlib_cli_command_t * cmd)
640 {
642  vl_api_ip4_arp_event_t *arp_event;
643  vl_api_ip6_nd_event_t *nd_event;
644 
645  if (pool_elts (am->arp_events) == 0 && pool_elts (am->nd_events) == 0 &&
646  pool_elts (am->wc_ip4_arp_events_registrations) == 0 &&
647  pool_elts (am->wc_ip6_nd_events_registrations) == 0)
648  {
649  vlib_cli_output (vm, "No active arp or nd event registrations");
650  return 0;
651  }
652 
653  /* *INDENT-OFF* */
654  pool_foreach (arp_event, am->arp_events,
655  ({
656  vlib_cli_output (vm, "%U", format_arp_event, arp_event);
657  }));
658 
660  pool_foreach(reg, am->wc_ip4_arp_events_registrations,
661  ({
662  vlib_cli_output (vm, "pid %d: bd mac/ip4 binding events",
663  ntohl (reg->client_pid));
664  }));
665 
666  pool_foreach (nd_event, am->nd_events,
667  ({
668  vlib_cli_output (vm, "%U", format_nd_event, nd_event);
669  }));
670 
671  pool_foreach(reg, am->wc_ip6_nd_events_registrations,
672  ({
673  vlib_cli_output (vm, "pid %d: bd mac/ip6 binding events",
674  ntohl (reg->client_pid));
675  }));
676  /* *INDENT-ON* */
677 
678  return 0;
679 }
680 
681 /* *INDENT-OFF* */
682 VLIB_CLI_COMMAND (show_ip_arp_nd_events, static) = {
683  .path = "show arp-nd-event registrations",
684  .function = show_ip_arp_nd_events_fn,
685  .short_help = "Show ip4 arp and ip6 nd event registrations",
686 };
687 /* *INDENT-ON* */
688 
689 #define vl_msg_name_crc_list
690 #include <vpp/api/vpe_all_api_h.h>
691 #undef vl_msg_name_crc_list
692 
693 static void
695 {
696 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
697  foreach_vl_msg_name_crc_memclnt;
698  foreach_vl_msg_name_crc_vpe;
699 #undef _
700 
701 #define vl_api_version_tuple(n,mj, mi, p) \
702  vl_msg_api_add_version (am, #n, mj, mi, p);
703 #include <vpp/api/vpe_all_api_h.h>
704 #undef vl_api_version_tuple
705 }
706 
707 
708 /*
709  * fd.io coding-style-patch-verification: ON
710  *
711  * Local Variables:
712  * eval: (c-set-style "gnu")
713  * End:
714  */
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:432
void vl_set_api_memory_size(u64 size)
static clib_error_t * memclnt_delete_callback(u32 client_index)
Definition: api.c:97
vnet_main_t * vnet_main
void vl_enable_disable_memory_api(vlib_main_t *vm, int yesno)
Definition: memory_vlib.c:1231
static void svm_pop_heap(void *oldheap)
Definition: svm.h:94
Reply for get next node index.
Definition: vpe.api:236
vpe parser cli string response
Definition: vpe.api:105
#define foreach_vpe_api_msg
Definition: api.c:75
static void vl_api_cli_t_handler(vl_api_cli_t *mp)
Definition: api.c:162
void vlib_cli_input(vlib_main_t *vm, unformat_input_t *input, vlib_cli_output_function_t *function, uword function_arg)
Definition: cli.c:643
vnet_main_t * vnet_get_main(void)
Definition: misc.c:47
void vl_set_memory_gid(int gid)
Control ping from client to api server request.
Definition: vpe.api:61
int size
for sanity checking
Definition: api_common.h:79
Fixed length block allocator.
#define REPLY_MACRO2(t, body)
#define NULL
Definition: clib.h:55
u32 index
Definition: node.h:237
VLIB_API_INIT_FUNCTION(vpe_api_hookup)
static clib_error_t * api_segment_config(vlib_main_t *vm, unformat_input_t *input)
Definition: api.c:494
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:518
u8 cmd[length]
Definition: vpe.api:97
vlib_main_t * vlib_main
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
unformat_function_t unformat_vnet_sw_interface
u8 * vlib_node_serialize(vlib_node_main_t *nm, u8 *vector, u32 max_threads, int include_nexts, int include_stats)
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
Definition: node_funcs.h:1108
trace_cfg_t * api_trace_cfg
Current trace configuration.
Definition: api_common.h:245
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
Process a vpe parser cli string request.
Definition: vpe.api:86
resolve_t
Definition: api.c:87
void vl_set_memory_uid(int uid)
format_function_t format_ip4_address
Definition: format.h:79
static void vl_api_get_next_index_t_handler(vl_api_get_next_index_t *mp)
Definition: api.c:280
Get node index using name request.
Definition: vpe.api:136
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:438
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:111
static void vl_api_get_node_graph_t_handler(vl_api_get_node_graph_t *mp)
Definition: api.c:360
static void * svm_push_data_heap(svm_region_t *rp)
Definition: svm.h:86
u32 context
Definition: vpe.api:89
#define vec_new(T, N)
Create new vector of given type and length (unspecified alignment, no header).
Definition: vec.h:306
unsigned long long u32x4
Definition: ixge.c:28
struct _vl_api_ip4_arp_event * arp_events
#define clib_error_return_fatal(e, args...)
Definition: error.h:105
#define clib_error_return(e, args...)
Definition: error.h:99
svm_region_t * vlib_rp
Current binary api segment descriptor.
Definition: api_common.h:251
get_node_graph_reply
Definition: vpe.api:210
unsigned long u64
Definition: types.h:89
#define vec_resize(V, N)
Resize a vector (no header, unspecified alignment) Add N elements to end of given vector V...
Definition: vec.h:237
static clib_error_t * vpe_api_init(vlib_main_t *vm)
Definition: api.c:473
void * vl_msg_api_alloc(int nbytes)
void unformat_init_string(unformat_input_t *input, char *string, int string_len)
Definition: unformat.c:1023
u64 cmd_in_shmem
Definition: vpe.api:90
#define hash_get(h, key)
Definition: hash.h:248
static void shmem_cli_output(uword arg, u8 *buffer, uword buffer_bytes)
Definition: api.c:135
static void vl_api_get_node_index_t_handler(vl_api_get_node_index_t *mp)
Definition: api.c:256
char * vpe_api_get_version(void)
Definition: version.c:77
struct _unformat_input_t unformat_input_t
static u8 * format_nd_event(u8 *s, va_list *args)
Definition: api.c:628
Tell client about an ip4 arp resolution event.
Definition: ip.api:678
void vl_set_global_memory_baseva(u64 baseva)
u32 client_index
Definition: vpe.api:88
#define REPLY_MACRO3(t, n, body)
struct _vl_api_ip6_nd_event * nd_events
API main structure, used by both vpp and binary API clients.
Definition: api_common.h:198
IP Set the next node for a given node response.
Definition: vpe.api:162
Get node index using name request.
Definition: vpe.api:124
void unformat_init_vector(unformat_input_t *input, u8 *vector_string)
Definition: unformat.c:1031
static void vl_api_add_node_next_t_handler(vl_api_add_node_next_t *mp)
Definition: api.c:327
#define VLIB_EARLY_CONFIG_FUNCTION(x, n,...)
Definition: init.h:140
api_main_t api_main
Definition: api_shared.c:35
#define UNFORMAT_END_OF_INPUT
Definition: format.h:143
format_function_t format_ip6_address
Definition: format.h:95
vlib_main_t * vm
Definition: buffer.c:283
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:336
char * vpe_api_get_build_directory(void)
Definition: version.c:71
void vl_set_global_pvt_heap_size(u64 size)
#define clib_memcpy(a, b, c)
Definition: string.h:75
unix_shared_memory_queue_t * vl_api_client_index_to_input_queue(u32 index)
void vl_set_memory_region_name(const char *name)
Definition: memory_vlib.c:1717
static void inband_cli_output(uword arg, u8 *buffer, uword buffer_bytes)
Definition: api.c:198
static void vl_api_show_version_t_handler(vl_api_show_version_t *mp)
Definition: api.c:233
#define ARRAY_LEN(x)
Definition: clib.h:59
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
Definition: node.c:45
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:154
void vl_msg_api_send_shmem(unix_shared_memory_queue_t *q, u8 *elem)
static clib_error_t * show_ip_arp_nd_events_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: api.c:638
unsigned int u32
Definition: types.h:88
static void vl_api_cli_inband_t_handler(vl_api_cli_inband_t *mp)
Definition: api.c:210
static void setup_message_id_table(api_main_t *am)
Definition: api.c:694
int stats_memclnt_delete_callback(u32 client_index)
Definition: stats.c:2681
u64 size
Definition: vhost-user.h:76
Control ping from the client to the server response.
Definition: vpe.api:73
Bitmaps built as vectors of machine words.
Set the next node for a given node request.
Definition: vpe.api:149
uword * next_slot_by_node
Definition: node.h:302
Query relative index via node names.
Definition: vpe.api:223
show version
Definition: vpe.api:173
VL_MSG_API_REAPER_FUNCTION(memclnt_delete_callback)
void vl_set_api_pvt_heap_size(u64 size)
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:23
u64 uword
Definition: types.h:112
template key/value backing page structure
Definition: bihash_doc.h:44
u64 reply_in_shmem
Definition: vpe.api:109
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unsigned char u8
Definition: types.h:56
vlib_node_main_t node_main
Definition: main.h:129
void * get_unformat_vnet_sw_interface(void)
Definition: api.c:612
static u8 * format_arp_event(u8 *s, va_list *args)
Definition: api.c:618
show version response
Definition: vpe.api:186
vpe_api_main_t vpe_api_main
Definition: interface_api.c:49
Tell client about an ip6 nd resolution or mac/ip event.
Definition: ip.api:712
static void vl_api_control_ping_t_handler(vl_api_control_ping_t *mp)
Definition: api.c:121
struct clib_bihash_value offset
template key/value backing page structure
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
char * vpe_api_get_build_date(void)
Definition: version.c:83
u8 * is_mp_safe
Message is mp safe vector.
Definition: api_common.h:221
#define clib_error_return_code(e, code, flags, args...)
Definition: error.h:93
void vl_set_global_memory_size(u64 size)
void vl_set_memory_root_path(const char *root_path)
static clib_error_t * vpe_api_hookup(vlib_main_t *vm)
Definition: api.c:435
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:680
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:972
#define foreach_registration_hash
pthread_mutex_t mutex
Definition: svm_common.h:37
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:169
struct _unix_shared_memory_queue unix_shared_memory_queue_t
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:128