FD.io VPP  v17.07.01-10-g3be13f0
Vector Packet Processing
one_api.c
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * one_api.c - Overlay Network Engine API
4  *
5  * Copyright (c) 2016-2017 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 <vnet/vnet.h>
21 #include <vlibmemory/api.h>
22 
23 #include <vnet/interface.h>
24 #include <vnet/api_errno.h>
25 #include <vnet/lisp-cp/control.h>
26 #include <vnet/lisp-gpe/lisp_gpe.h>
27 
28 #include <vnet/vnet_msg_enum.h>
29 
30 #define vl_api_one_remote_locator_t_endian vl_noop_handler
31 #define vl_api_one_remote_locator_t_print vl_noop_handler
32 #define vl_api_one_local_locator_t_endian vl_noop_handler
33 #define vl_api_one_local_locator_t_print vl_noop_handler
34 
35 #define vl_api_one_add_del_locator_set_t_endian vl_noop_handler
36 #define vl_api_one_add_del_locator_set_t_print vl_noop_handler
37 #define vl_api_one_add_del_remote_mapping_t_endian vl_noop_handler
38 #define vl_api_one_add_del_remote_mapping_t_print vl_noop_handler
39 
40 #define vl_api_one_add_del_locator_set_t_endian vl_noop_handler
41 #define vl_api_one_add_del_locator_set_t_print vl_noop_handler
42 #define vl_api_one_add_del_remote_mapping_t_endian vl_noop_handler
43 #define vl_api_one_add_del_remote_mapping_t_print vl_noop_handler
44 
45 #define vl_api_one_l2_arp_entry_t_endian vl_noop_handler
46 #define vl_api_one_l2_arp_entry_t_print vl_noop_handler
47 #define vl_api_one_add_del_l2_arp_entry vl_noop_handler
48 #define vl_api_one_l2_arp_bd_get vl_noop_handler
49 
50 #define vl_typedefs /* define message structures */
51 #include <vnet/vnet_all_api_h.h>
52 #undef vl_typedefs
53 
54 #define vl_endianfun /* define message structures */
55 #include <vnet/vnet_all_api_h.h>
56 #undef vl_endianfun
57 
58 /* instantiate all the print functions we know about */
59 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
60 #define vl_printfun
61 #include <vnet/vnet_all_api_h.h>
62 #undef vl_printfun
63 
65 
66 #define REPLY_DETAILS(t, body) \
67 do { \
68  unix_shared_memory_queue_t * q; \
69  rv = vl_msg_api_pd_handler (mp, rv); \
70  q = vl_api_client_index_to_input_queue (mp->client_index); \
71  if (!q) \
72  return; \
73  \
74  rmp = vl_msg_api_alloc (sizeof (*rmp)); \
75  rmp->_vl_msg_id = ntohs((t)); \
76  rmp->context = mp->context; \
77  do {body;} while (0); \
78  vl_msg_api_send_shmem (q, (u8 *)&rmp); \
79 } while(0);
80 
81 #define foreach_vpe_api_msg \
82 _(ONE_ADD_DEL_LOCATOR_SET, one_add_del_locator_set) \
83 _(ONE_ADD_DEL_LOCATOR, one_add_del_locator) \
84 _(ONE_ADD_DEL_LOCAL_EID, one_add_del_local_eid) \
85 _(ONE_ADD_DEL_MAP_RESOLVER, one_add_del_map_resolver) \
86 _(ONE_ADD_DEL_MAP_SERVER, one_add_del_map_server) \
87 _(ONE_ENABLE_DISABLE, one_enable_disable) \
88 _(ONE_RLOC_PROBE_ENABLE_DISABLE, one_rloc_probe_enable_disable) \
89 _(ONE_MAP_REGISTER_ENABLE_DISABLE, one_map_register_enable_disable) \
90 _(ONE_ADD_DEL_REMOTE_MAPPING, one_add_del_remote_mapping) \
91 _(ONE_ADD_DEL_ADJACENCY, one_add_del_adjacency) \
92 _(ONE_PITR_SET_LOCATOR_SET, one_pitr_set_locator_set) \
93 _(ONE_NSH_SET_LOCATOR_SET, one_nsh_set_locator_set) \
94 _(ONE_MAP_REQUEST_MODE, one_map_request_mode) \
95 _(ONE_EID_TABLE_ADD_DEL_MAP, one_eid_table_add_del_map) \
96 _(ONE_LOCATOR_SET_DUMP, one_locator_set_dump) \
97 _(ONE_LOCATOR_DUMP, one_locator_dump) \
98 _(ONE_EID_TABLE_DUMP, one_eid_table_dump) \
99 _(ONE_MAP_RESOLVER_DUMP, one_map_resolver_dump) \
100 _(ONE_MAP_SERVER_DUMP, one_map_server_dump) \
101 _(ONE_EID_TABLE_MAP_DUMP, one_eid_table_map_dump) \
102 _(ONE_EID_TABLE_VNI_DUMP, one_eid_table_vni_dump) \
103 _(ONE_ADJACENCIES_GET, one_adjacencies_get) \
104 _(SHOW_ONE_NSH_MAPPING, show_one_nsh_mapping) \
105 _(SHOW_ONE_RLOC_PROBE_STATE, show_one_rloc_probe_state) \
106 _(SHOW_ONE_MAP_REGISTER_STATE, show_one_map_register_state) \
107 _(SHOW_ONE_STATUS, show_one_status) \
108 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, \
109  one_add_del_map_request_itr_rlocs) \
110 _(ONE_GET_MAP_REQUEST_ITR_RLOCS, one_get_map_request_itr_rlocs) \
111 _(SHOW_ONE_PITR, show_one_pitr) \
112 _(SHOW_ONE_MAP_REQUEST_MODE, show_one_map_request_mode) \
113 _(ONE_USE_PETR, one_use_petr) \
114 _(SHOW_ONE_USE_PETR, show_one_use_petr) \
115 _(SHOW_ONE_STATS_ENABLE_DISABLE, show_one_stats_enable_disable) \
116 _(ONE_STATS_ENABLE_DISABLE, one_stats_enable_disable) \
117 _(ONE_STATS_DUMP, one_stats_dump) \
118 _(ONE_STATS_FLUSH, one_stats_flush) \
119 _(ONE_L2_ARP_BD_GET, one_l2_arp_bd_get) \
120 _(ONE_L2_ARP_ENTRIES_GET, one_l2_arp_entries_get) \
121 _(ONE_ADD_DEL_L2_ARP_ENTRY, one_add_del_l2_arp_entry) \
122 
123 
124 static locator_t *
126 {
127  u32 i;
128  locator_t *locs = 0, loc;
130 
131  for (i = 0; i < rloc_num; i++)
132  {
133  /* remote locators */
134  r = &rmt_locs[i];
135  memset (&loc, 0, sizeof (loc));
136  gid_address_ip_set (&loc.address, &r->addr, r->is_ip4 ? IP4 : IP6);
137 
138  loc.priority = r->priority;
139  loc.weight = r->weight;
140 
141  vec_add1 (locs, loc);
142  }
143  return locs;
144 }
145 
146 static void
148  mp)
149 {
151  int rv = 0;
153  locator_t locator;
155  u32 ls_index = ~0, locator_num;
156  u8 *locator_name = NULL;
157  int i;
158 
159  memset (a, 0, sizeof (a[0]));
160 
161  locator_name = format (0, "%s", mp->locator_set_name);
162 
163  a->name = locator_name;
164  a->is_add = mp->is_add;
165  a->local = 1;
166  locator_num = clib_net_to_host_u32 (mp->locator_num);
167 
168  memset (&locator, 0, sizeof (locator));
169  for (i = 0; i < locator_num; i++)
170  {
171  ls_loc = &mp->locators[i];
172  VALIDATE_SW_IF_INDEX (ls_loc);
173 
174  locator.sw_if_index = htonl (ls_loc->sw_if_index);
175  locator.priority = ls_loc->priority;
176  locator.weight = ls_loc->weight;
177  locator.local = 1;
178  vec_add1 (a->locators, locator);
179  }
180 
181  rv = vnet_lisp_add_del_locator_set (a, &ls_index);
182 
184 
185  vec_free (locator_name);
186  vec_free (a->locators);
187 
188  /* *INDENT-OFF* */
189  REPLY_MACRO2 (VL_API_ONE_ADD_DEL_LOCATOR_SET_REPLY,
190  ({
191  rmp->ls_index = clib_host_to_net_u32 (ls_index);
192  }));
193  /* *INDENT-ON* */
194 }
195 
196 static void
198 {
199  vl_api_one_add_del_locator_reply_t *rmp;
200  int rv = 0;
201  locator_t locator, *locators = NULL;
203  u32 ls_index = ~0;
204  u8 *locator_name = NULL;
205 
206  memset (&locator, 0, sizeof (locator));
207  memset (a, 0, sizeof (a[0]));
208 
209  locator.sw_if_index = ntohl (mp->sw_if_index);
210  locator.priority = mp->priority;
211  locator.weight = mp->weight;
212  locator.local = 1;
213  vec_add1 (locators, locator);
214 
215  locator_name = format (0, "%s", mp->locator_set_name);
216 
217  a->name = locator_name;
218  a->locators = locators;
219  a->is_add = mp->is_add;
220  a->local = 1;
221 
222  rv = vnet_lisp_add_del_locator (a, NULL, &ls_index);
223 
224  vec_free (locators);
225  vec_free (locator_name);
226 
227  REPLY_MACRO (VL_API_ONE_ADD_DEL_LOCATOR_REPLY);
228 }
229 
230 typedef struct
231 {
234 } __attribute__ ((__packed__)) lisp_nsh_api_t;
235 
236 static int
237 unformat_one_eid_api (gid_address_t * dst, u32 vni, u8 type, void *src,
238  u8 len)
239 {
240  lisp_nsh_api_t *nsh;
241 
242  switch (type)
243  {
244  case 0: /* ipv4 */
246  gid_address_ip_set (dst, src, IP4);
247  gid_address_ippref_len (dst) = len;
249  break;
250  case 1: /* ipv6 */
252  gid_address_ip_set (dst, src, IP6);
253  gid_address_ippref_len (dst) = len;
255  break;
256  case 2: /* l2 mac */
258  clib_memcpy (&gid_address_mac (dst), src, 6);
259  break;
260  case 3: /* NSH */
262  nsh = src;
263  gid_address_nsh_spi (dst) = clib_net_to_host_u32 (nsh->spi);
264  gid_address_nsh_si (dst) = nsh->si;
265  break;
266  default:
267  /* unknown type */
268  return VNET_API_ERROR_INVALID_VALUE;
269  }
270 
271  gid_address_vni (dst) = vni;
272 
273  return 0;
274 }
275 
276 static void
278 {
279  vl_api_one_add_del_local_eid_reply_t *rmp;
281  int rv = 0;
282  gid_address_t _eid, *eid = &_eid;
283  uword *p = NULL;
284  u32 locator_set_index = ~0, map_index = ~0;
286  u8 *name = NULL, *key = NULL;
287  memset (a, 0, sizeof (a[0]));
288  memset (eid, 0, sizeof (eid[0]));
289 
290  rv = unformat_one_eid_api (eid, clib_net_to_host_u32 (mp->vni),
291  mp->eid_type, mp->eid, mp->prefix_len);
292  if (rv)
293  goto out;
294 
295  if (gid_address_type (eid) == GID_ADDR_NSH)
296  {
297  rv = VNET_API_ERROR_INVALID_VALUE;
298  goto out;
299  }
300 
301  name = format (0, "%s", mp->locator_set_name);
302  p = hash_get_mem (lcm->locator_set_index_by_name, name);
303  if (!p)
304  {
305  rv = VNET_API_ERROR_INVALID_VALUE;
306  goto out;
307  }
308  locator_set_index = p[0];
309 
310  if (*mp->key)
311  key = format (0, "%s", mp->key);
312 
313  /* XXX treat batch configuration */
314  a->is_add = mp->is_add;
315  gid_address_copy (&a->eid, eid);
316  a->locator_set_index = locator_set_index;
317  a->local = 1;
318  a->key = key;
319  a->key_id = clib_net_to_host_u16 (mp->key_id);
320 
321  rv = vnet_lisp_add_del_local_mapping (a, &map_index);
322 
323 out:
324  vec_free (name);
325  vec_free (key);
326  gid_address_free (&a->eid);
327 
328  REPLY_MACRO (VL_API_ONE_ADD_DEL_LOCAL_EID_REPLY);
329 }
330 
331 static void
334 {
335  vl_api_one_eid_table_add_del_map_reply_t *rmp;
336  int rv = 0;
337  rv = vnet_lisp_eid_table_map (clib_net_to_host_u32 (mp->vni),
338  clib_net_to_host_u32 (mp->dp_table),
339  mp->is_l2, mp->is_add);
340 REPLY_MACRO (VL_API_ONE_EID_TABLE_ADD_DEL_MAP_REPLY)}
341 
342 static void
344 {
345  vl_api_one_add_del_map_server_reply_t *rmp;
346  int rv = 0;
347  ip_address_t addr;
348 
349  memset (&addr, 0, sizeof (addr));
350 
351  ip_address_set (&addr, mp->ip_address, mp->is_ipv6 ? IP6 : IP4);
352  rv = vnet_lisp_add_del_map_server (&addr, mp->is_add);
353 
354  REPLY_MACRO (VL_API_ONE_ADD_DEL_MAP_SERVER_REPLY);
355 }
356 
357 static void
359  * mp)
360 {
361  vl_api_one_add_del_map_resolver_reply_t *rmp;
362  int rv = 0;
364 
365  memset (a, 0, sizeof (a[0]));
366 
367  a->is_add = mp->is_add;
368  ip_address_set (&a->address, mp->ip_address, mp->is_ipv6 ? IP6 : IP4);
369 
371 
372  REPLY_MACRO (VL_API_ONE_ADD_DEL_MAP_RESOLVER_REPLY);
373 }
374 
375 static void
378 {
379  vl_api_one_map_register_enable_disable_reply_t *rmp;
380  int rv = 0;
381 
383  REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
384 }
385 
386 static void
389 {
390  vl_api_one_rloc_probe_enable_disable_reply_t *rmp;
391  int rv = 0;
392 
394  REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
395 }
396 
397 static void
399 {
400  vl_api_one_enable_disable_reply_t *rmp;
401  int rv = 0;
402 
404  REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
405 }
406 
407 static void
410 {
411  int rv = 0;
413 
414  /* *INDENT-OFF* */
415  REPLY_MACRO2(VL_API_SHOW_ONE_MAP_REQUEST_MODE_REPLY,
416  ({
418  }));
419  /* *INDENT-ON* */
420 }
421 
422 static void
424 {
425  vl_api_one_map_request_mode_reply_t *rmp;
426  int rv = 0;
427 
429 
430  REPLY_MACRO (VL_API_ONE_MAP_REQUEST_MODE_REPLY);
431 }
432 
433 static void
435  * mp)
436 {
437  vl_api_one_nsh_set_locator_set_reply_t *rmp;
438  int rv = 0;
439  u8 *ls_name = 0;
440 
441  ls_name = format (0, "%s", mp->ls_name);
442  rv = vnet_lisp_nsh_set_locator_set (ls_name, mp->is_add);
443  vec_free (ls_name);
444 
445  REPLY_MACRO (VL_API_ONE_PITR_SET_LOCATOR_SET_REPLY);
446 }
447 
448 static void
450  * mp)
451 {
452  vl_api_one_pitr_set_locator_set_reply_t *rmp;
453  int rv = 0;
454  u8 *ls_name = 0;
455 
456  ls_name = format (0, "%s", mp->ls_name);
457  rv = vnet_lisp_pitr_set_locator_set (ls_name, mp->is_add);
458  vec_free (ls_name);
459 
460  REPLY_MACRO (VL_API_ONE_PITR_SET_LOCATOR_SET_REPLY);
461 }
462 
463 static void
465 {
466  vl_api_one_use_petr_reply_t *rmp;
467  int rv = 0;
468  ip_address_t addr;
469 
470  ip_address_set (&addr, &mp->address, mp->is_ip4 ? IP4 : IP6);
471  rv = vnet_lisp_use_petr (&addr, mp->is_add);
472 
473  REPLY_MACRO (VL_API_ONE_USE_PETR_REPLY);
474 }
475 
476 static void
478 {
482  mapping_t *m;
483  locator_set_t *ls = 0;
484  int rv = 0;
485  locator_t *loc = 0;
486  u8 status = 0;
488 
490  if (q == 0)
491  {
492  return;
493  }
494 
495  memset (&addr, 0, sizeof (addr));
496  status = lcm->flags & LISP_FLAG_USE_PETR;
497  if (status)
498  {
500  if (~0 != m->locator_set_index)
501  {
502  ls =
504  loc = pool_elt_at_index (lcm->locator_pool, ls->locator_indices[0]);
505  gid_address_copy (&addr, &loc->address);
506  }
507  }
508 
509  /* *INDENT-OFF* */
510  REPLY_MACRO2 (VL_API_SHOW_ONE_USE_PETR_REPLY,
511  {
512  rmp->status = status;
513  ip_address_t *ip = &gid_address_ip (&addr);
514  switch (ip_addr_version (ip))
515  {
516  case IP4:
517  clib_memcpy (rmp->address, &ip_addr_v4 (ip),
518  sizeof (ip_addr_v4 (ip)));
519  break;
520 
521  case IP6:
522  clib_memcpy (rmp->address, &ip_addr_v6 (ip),
523  sizeof (ip_addr_v6 (ip)));
524  break;
525 
526  default:
527  ASSERT (0);
528  }
529  rmp->is_ip4 = (gid_address_ip_version (&addr) == IP4);
530  });
531  /* *INDENT-ON* */
532 }
533 
534 static void
537 {
538  vl_api_one_add_del_map_request_itr_rlocs_reply_t *rmp;
539  int rv = 0;
540  u8 *locator_set_name = NULL;
542 
543  locator_set_name = format (0, "%s", mp->locator_set_name);
544 
545  a->is_add = mp->is_add;
546  a->locator_set_name = locator_set_name;
547 
549 
550  vec_free (locator_set_name);
551 
552  REPLY_MACRO (VL_API_ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY);
553 }
554 
555 static void
558 {
559  locator_t *rlocs = 0;
560  vl_api_one_add_del_remote_mapping_reply_t *rmp;
561  int rv = 0;
562  gid_address_t _eid, *eid = &_eid;
563  u32 rloc_num = clib_net_to_host_u32 (mp->rloc_num);
564 
565  memset (eid, 0, sizeof (eid[0]));
566 
567  rv = unformat_one_eid_api (eid, clib_net_to_host_u32 (mp->vni),
568  mp->eid_type, mp->eid, mp->eid_len);
569  if (rv)
570  goto send_reply;
571 
572  rlocs = unformat_one_locs (mp->rlocs, rloc_num);
573 
574  if (!mp->is_add)
575  {
577  gid_address_copy (&a->reid, eid);
578  a->is_add = 0;
580  if (rv)
581  {
582  goto out;
583  }
584  }
585 
586  /* NOTE: for now this works as a static remote mapping, i.e.,
587  * not authoritative and ttl infinite. */
588  rv = vnet_lisp_add_del_mapping (eid, rlocs, mp->action, 0, ~0,
589  mp->is_add, 1 /* is_static */ , 0);
590 
591  if (mp->del_all)
593 
594 out:
595  vec_free (rlocs);
596 send_reply:
597  REPLY_MACRO (VL_API_ONE_ADD_DEL_REMOTE_MAPPING_REPLY);
598 }
599 
600 static void
602 {
603  vl_api_one_add_del_adjacency_reply_t *rmp;
605 
606  int rv = 0;
607  memset (a, 0, sizeof (a[0]));
608 
609  rv = unformat_one_eid_api (&a->leid, clib_net_to_host_u32 (mp->vni),
610  mp->eid_type, mp->leid, mp->leid_len);
611  rv |= unformat_one_eid_api (&a->reid, clib_net_to_host_u32 (mp->vni),
612  mp->eid_type, mp->reid, mp->reid_len);
613 
614  if (rv)
615  goto send_reply;
616 
617  a->is_add = mp->is_add;
619 
620 send_reply:
621  REPLY_MACRO (VL_API_ONE_ADD_DEL_ADJACENCY_REPLY);
622 }
623 
624 static void
626  locator_t * loc,
627  unix_shared_memory_queue_t * q, u32 context)
628 {
630 
631  rmp = vl_msg_api_alloc (sizeof (*rmp));
632  memset (rmp, 0, sizeof (*rmp));
633  rmp->_vl_msg_id = ntohs (VL_API_ONE_LOCATOR_DETAILS);
634  rmp->context = context;
635 
636  rmp->local = loc->local;
637  if (loc->local)
638  {
639  rmp->sw_if_index = ntohl (loc->sw_if_index);
640  }
641  else
642  {
643  rmp->is_ipv6 = gid_address_ip_version (&loc->address);
645  }
646  rmp->priority = loc->priority;
647  rmp->weight = loc->weight;
648 
649  vl_msg_api_send_shmem (q, (u8 *) & rmp);
650 }
651 
652 static void
654 {
655  u8 *ls_name = 0;
658  locator_set_t *lsit = 0;
659  locator_t *loc = 0;
660  u32 ls_index = ~0, *locit = 0;
661  uword *p = 0;
662 
664  if (q == 0)
665  {
666  return;
667  }
668 
669  if (mp->is_index_set)
670  ls_index = htonl (mp->ls_index);
671  else
672  {
673  /* make sure we get a proper C-string */
674  mp->ls_name[sizeof (mp->ls_name) - 1] = 0;
675  ls_name = format (0, "%s", mp->ls_name);
676  p = hash_get_mem (lcm->locator_set_index_by_name, ls_name);
677  if (!p)
678  goto out;
679  ls_index = p[0];
680  }
681 
682  if (pool_is_free_index (lcm->locator_set_pool, ls_index))
683  return;
684 
685  lsit = pool_elt_at_index (lcm->locator_set_pool, ls_index);
686 
687  vec_foreach (locit, lsit->locator_indices)
688  {
689  loc = pool_elt_at_index (lcm->locator_pool, locit[0]);
690  send_one_locator_details (lcm, loc, q, mp->context);
691  };
692 out:
693  vec_free (ls_name);
694 }
695 
696 static void
698  locator_set_t * lsit,
700  u32 context, u32 ls_index)
701 {
703  u8 *str = 0;
704 
705  rmp = vl_msg_api_alloc (sizeof (*rmp));
706  memset (rmp, 0, sizeof (*rmp));
707  rmp->_vl_msg_id = ntohs (VL_API_ONE_LOCATOR_SET_DETAILS);
708  rmp->context = context;
709 
710  rmp->ls_index = htonl (ls_index);
711  if (lsit->local)
712  {
713  ASSERT (lsit->name != NULL);
714  strncpy ((char *) rmp->ls_name, (char *) lsit->name,
715  vec_len (lsit->name));
716  }
717  else
718  {
719  str = format (0, "<remote-%d>", ls_index);
720  strncpy ((char *) rmp->ls_name, (char *) str, vec_len (str));
721  vec_free (str);
722  }
723 
724  vl_msg_api_send_shmem (q, (u8 *) & rmp);
725 }
726 
727 static void
729 {
732  locator_set_t *lsit = NULL;
733  u8 filter;
734 
736  if (q == 0)
737  {
738  return;
739  }
740 
741  filter = mp->filter;
742  /* *INDENT-OFF* */
743  pool_foreach (lsit, lcm->locator_set_pool,
744  ({
745  if (filter && !((1 == filter && lsit->local) ||
746  (2 == filter && !lsit->local)))
747  {
748  continue;
749  }
750  send_one_locator_set_details (lcm, lsit, q, mp->context,
751  lsit - lcm->locator_set_pool);
752  }));
753  /* *INDENT-ON* */
754 }
755 
756 static void
757 one_fid_put_api (u8 * dst, fid_address_t * src, u8 * prefix_length)
758 {
759  ASSERT (prefix_length);
760  ip_prefix_t *ippref = &fid_addr_ippref (src);
761 
762  switch (fid_addr_type (src))
763  {
764  case FID_ADDR_IP_PREF:
765  if (ip_prefix_version (ippref) == IP4)
766  clib_memcpy (dst, &ip_prefix_v4 (ippref), 4);
767  else
768  clib_memcpy (dst, &ip_prefix_v6 (ippref), 16);
769  prefix_length[0] = ip_prefix_len (ippref);
770  break;
771 
772  case FID_ADDR_MAC:
773  prefix_length[0] = 0;
774  clib_memcpy (dst, fid_addr_mac (src), 6);
775  break;
776 
777  default:
778  clib_warning ("Unknown FID type %d!", fid_addr_type (src));
779  break;
780  }
781 }
782 
783 static u8
785 {
786  ip_prefix_t *ippref;
787 
788  switch (fid_addr_type (fid))
789  {
790  case FID_ADDR_IP_PREF:
791  ippref = &fid_addr_ippref (fid);
792  if (ip_prefix_version (ippref) == IP4)
793  return 0;
794  else if (ip_prefix_version (ippref) == IP6)
795  return 1;
796  else
797  return ~0;
798 
799  case FID_ADDR_MAC:
800  return 2;
801  case FID_ADDR_NSH:
802  return 3;
803  }
804 
805  return ~0;
806 }
807 
808 static void
811  u32 context, u8 filter)
812 {
813  fid_address_t *fid;
815  locator_set_t *ls = 0;
817  gid_address_t *gid = NULL;
818  u8 *mac = 0;
819  ip_prefix_t *ip_prefix = NULL;
820 
821  if (mapit->pitr_set || mapit->nsh_set)
822  return;
823 
824  switch (filter)
825  {
826  case 0: /* all mappings */
827  break;
828 
829  case 1: /* local only */
830  if (!mapit->local)
831  return;
832  break;
833  case 2: /* remote only */
834  if (mapit->local)
835  return;
836  break;
837  default:
838  clib_warning ("Filter error, unknown filter: %d", filter);
839  return;
840  }
841 
842  gid = &mapit->eid;
843  ip_prefix = &gid_address_ippref (gid);
844  mac = gid_address_mac (gid);
845 
846  rmp = vl_msg_api_alloc (sizeof (*rmp));
847  memset (rmp, 0, sizeof (*rmp));
848  rmp->_vl_msg_id = ntohs (VL_API_ONE_EID_TABLE_DETAILS);
849 
851  if (vec_len (ls->locator_indices) == 0)
852  rmp->locator_set_index = ~0;
853  else
854  rmp->locator_set_index = clib_host_to_net_u32 (mapit->locator_set_index);
855 
856  rmp->is_local = mapit->local;
857  rmp->ttl = clib_host_to_net_u32 (mapit->ttl);
858  rmp->action = mapit->action;
859  rmp->authoritative = mapit->authoritative;
860 
861  switch (gid_address_type (gid))
862  {
863  case GID_ADDR_SRC_DST:
864  rmp->is_src_dst = 1;
865  fid = &gid_address_sd_src (gid);
866  rmp->eid_type = fid_type_to_api_type (fid);
868  &rmp->seid_prefix_len);
869  one_fid_put_api (rmp->eid, &gid_address_sd_dst (gid),
870  &rmp->eid_prefix_len);
871  break;
872  case GID_ADDR_IP_PREFIX:
873  rmp->eid_prefix_len = ip_prefix_len (ip_prefix);
874  if (ip_prefix_version (ip_prefix) == IP4)
875  {
876  rmp->eid_type = 0; /* ipv4 type */
877  clib_memcpy (rmp->eid, &ip_prefix_v4 (ip_prefix),
878  sizeof (ip_prefix_v4 (ip_prefix)));
879  }
880  else
881  {
882  rmp->eid_type = 1; /* ipv6 type */
883  clib_memcpy (rmp->eid, &ip_prefix_v6 (ip_prefix),
884  sizeof (ip_prefix_v6 (ip_prefix)));
885  }
886  break;
887  case GID_ADDR_MAC:
888  rmp->eid_type = 2; /* l2 mac type */
889  clib_memcpy (rmp->eid, mac, 6);
890  break;
891  case GID_ADDR_NSH:
892  rmp->eid_type = 3; /* NSH type */
893  lisp_nsh_api_t nsh;
894  nsh.spi = clib_host_to_net_u32 (gid_address_nsh_spi (gid));
895  nsh.si = gid_address_nsh_si (gid);
896  clib_memcpy (rmp->eid, &nsh, sizeof (nsh));
897  break;
898  default:
899  ASSERT (0);
900  }
901  rmp->context = context;
902  rmp->vni = clib_host_to_net_u32 (gid_address_vni (gid));
903  rmp->key_id = clib_host_to_net_u16 (mapit->key_id);
904  memcpy (rmp->key, mapit->key, vec_len (mapit->key));
905  vl_msg_api_send_shmem (q, (u8 *) & rmp);
906 }
907 
908 static void
910 {
911  u32 mi;
914  mapping_t *mapit = NULL;
915  gid_address_t _eid, *eid = &_eid;
916 
918  if (q == 0)
919  {
920  return;
921  }
922 
923  if (mp->eid_set)
924  {
925  memset (eid, 0, sizeof (*eid));
926 
927  unformat_one_eid_api (eid, clib_net_to_host_u32 (mp->vni),
928  mp->eid_type, mp->eid, mp->prefix_length);
929 
931  if ((u32) ~ 0 == mi)
932  return;
933 
934  mapit = pool_elt_at_index (lcm->mapping_pool, mi);
935  send_one_eid_table_details (mapit, q, mp->context,
936  0 /* ignore filter */ );
937  }
938  else
939  {
940  /* *INDENT-OFF* */
941  pool_foreach (mapit, lcm->mapping_pool,
942  ({
943  send_one_eid_table_details(mapit, q, mp->context,
944  mp->filter);
945  }));
946  /* *INDENT-ON* */
947  }
948 }
949 
950 static void
951 send_one_map_server_details (ip_address_t * ip,
952  unix_shared_memory_queue_t * q, u32 context)
953 {
955 
956  rmp = vl_msg_api_alloc (sizeof (*rmp));
957  memset (rmp, 0, sizeof (*rmp));
958  rmp->_vl_msg_id = ntohs (VL_API_ONE_MAP_SERVER_DETAILS);
959 
960  switch (ip_addr_version (ip))
961  {
962  case IP4:
963  rmp->is_ipv6 = 0;
964  clib_memcpy (rmp->ip_address, &ip_addr_v4 (ip),
965  sizeof (ip_addr_v4 (ip)));
966  break;
967 
968  case IP6:
969  rmp->is_ipv6 = 1;
970  clib_memcpy (rmp->ip_address, &ip_addr_v6 (ip),
971  sizeof (ip_addr_v6 (ip)));
972  break;
973 
974  default:
975  ASSERT (0);
976  }
977  rmp->context = context;
978 
979  vl_msg_api_send_shmem (q, (u8 *) & rmp);
980 }
981 
982 static void
984 {
987  lisp_msmr_t *mr;
988 
990  if (q == 0)
991  {
992  return;
993  }
994 
995  vec_foreach (mr, lcm->map_servers)
996  {
998  }
999 }
1000 
1001 static void
1003  unix_shared_memory_queue_t * q, u32 context)
1004 {
1006 
1007  rmp = vl_msg_api_alloc (sizeof (*rmp));
1008  memset (rmp, 0, sizeof (*rmp));
1009  rmp->_vl_msg_id = ntohs (VL_API_ONE_MAP_RESOLVER_DETAILS);
1010 
1011  switch (ip_addr_version (ip))
1012  {
1013  case IP4:
1014  rmp->is_ipv6 = 0;
1015  clib_memcpy (rmp->ip_address, &ip_addr_v4 (ip),
1016  sizeof (ip_addr_v4 (ip)));
1017  break;
1018 
1019  case IP6:
1020  rmp->is_ipv6 = 1;
1021  clib_memcpy (rmp->ip_address, &ip_addr_v6 (ip),
1022  sizeof (ip_addr_v6 (ip)));
1023  break;
1024 
1025  default:
1026  ASSERT (0);
1027  }
1028  rmp->context = context;
1029 
1030  vl_msg_api_send_shmem (q, (u8 *) & rmp);
1031 }
1032 
1033 static void
1035 {
1038  lisp_msmr_t *mr;
1039 
1041  if (q == 0)
1042  {
1043  return;
1044  }
1045 
1046  vec_foreach (mr, lcm->map_resolvers)
1047  {
1049  }
1050 }
1051 
1052 static void
1054  unix_shared_memory_queue_t * q, u32 context)
1055 {
1057 
1058  rmp = vl_msg_api_alloc (sizeof (*rmp));
1059  memset (rmp, 0, sizeof (*rmp));
1060  rmp->_vl_msg_id = ntohs (VL_API_ONE_EID_TABLE_MAP_DETAILS);
1061 
1062  rmp->vni = clib_host_to_net_u32 (p->key);
1063  rmp->dp_table = clib_host_to_net_u32 (p->value[0]);
1064  rmp->context = context;
1065  vl_msg_api_send_shmem (q, (u8 *) & rmp);
1066 }
1067 
1068 static void
1070 {
1073  hash_pair_t *p;
1074  uword *vni_table = 0;
1075 
1077  if (q == 0)
1078  {
1079  return;
1080  }
1081 
1082  if (mp->is_l2)
1083  {
1084  vni_table = lcm->bd_id_by_vni;
1085  }
1086  else
1087  {
1088  vni_table = lcm->table_id_by_vni;
1089  }
1090 
1091  /* *INDENT-OFF* */
1092  hash_foreach_pair (p, vni_table,
1093  ({
1094  send_eid_table_map_pair (p, q, mp->context);
1095  }));
1096  /* *INDENT-ON* */
1097 }
1098 
1099 static void
1101 {
1103 
1104  rmp = vl_msg_api_alloc (sizeof (*rmp));
1105  memset (rmp, 0, sizeof (*rmp));
1106  rmp->_vl_msg_id = ntohs (VL_API_ONE_EID_TABLE_VNI_DETAILS);
1107  rmp->context = context;
1108  rmp->vni = clib_host_to_net_u32 (vni);
1109  vl_msg_api_send_shmem (q, (u8 *) & rmp);
1110 }
1111 
1112 static void
1114 {
1115  lisp_adjacency_t *adj;
1117  u32 i, n = vec_len (adjs);
1118  lisp_nsh_api_t nsh;
1119 
1120  for (i = 0; i < n; i++)
1121  {
1122  adj = vec_elt_at_index (adjs, i);
1123  memset (&a, 0, sizeof (a));
1124 
1125  switch (gid_address_type (&adj->reid))
1126  {
1127  case GID_ADDR_IP_PREFIX:
1130  if (gid_address_ip_version (&adj->reid) == IP4)
1131  {
1132  a.eid_type = 0; /* ipv4 type */
1133  clib_memcpy (a.reid, &gid_address_ip (&adj->reid), 4);
1134  clib_memcpy (a.leid, &gid_address_ip (&adj->leid), 4);
1135  }
1136  else
1137  {
1138  a.eid_type = 1; /* ipv6 type */
1139  clib_memcpy (a.reid, &gid_address_ip (&adj->reid), 16);
1140  clib_memcpy (a.leid, &gid_address_ip (&adj->leid), 16);
1141  }
1142  break;
1143  case GID_ADDR_MAC:
1144  a.eid_type = 2; /* l2 mac type */
1145  mac_copy (a.reid, gid_address_mac (&adj->reid));
1146  mac_copy (a.leid, gid_address_mac (&adj->leid));
1147  break;
1148  case GID_ADDR_NSH:
1149  a.eid_type = 3; /* NSH type */
1150  nsh.spi = clib_host_to_net_u32 (gid_address_nsh_spi (&adj->reid));
1151  nsh.si = gid_address_nsh_si (&adj->reid);
1152  clib_memcpy (a.reid, &nsh, sizeof (nsh));
1153 
1154  nsh.spi = clib_host_to_net_u32 (gid_address_nsh_spi (&adj->leid));
1155  nsh.si = gid_address_nsh_si (&adj->leid);
1156  clib_memcpy (a.leid, &nsh, sizeof (nsh));
1157  break;
1158  default:
1159  ASSERT (0);
1160  }
1161  dst[i] = a;
1162  }
1163 }
1164 
1165 static void
1168 {
1170  int rv = 0;
1171 
1172  /* *INDENT-OFF* */
1173  REPLY_MACRO2 (VL_API_SHOW_ONE_RLOC_PROBE_STATE_REPLY,
1174  {
1176  });
1177  /* *INDENT-ON* */
1178 }
1179 
1180 static void
1183 {
1185  int rv = 0;
1186 
1187  /* *INDENT-OFF* */
1188  REPLY_MACRO2 (VL_API_SHOW_ONE_MAP_REGISTER_STATE_REPLY,
1189  {
1191  });
1192  /* *INDENT-ON* */
1193 }
1194 
1195 static void
1197 {
1199  lisp_adjacency_t *adjs = 0;
1200  int rv = 0;
1201  u32 size = ~0;
1202  u32 vni = clib_net_to_host_u32 (mp->vni);
1203 
1204  adjs = vnet_lisp_adjacencies_get_by_vni (vni);
1205  size = vec_len (adjs) * sizeof (vl_api_one_adjacency_t);
1206 
1207  /* *INDENT-OFF* */
1208  REPLY_MACRO4 (VL_API_ONE_ADJACENCIES_GET_REPLY, size,
1209  {
1210  rmp->count = clib_host_to_net_u32 (vec_len (adjs));
1211  one_adjacency_copy (rmp->adjacencies, adjs);
1212  });
1213  /* *INDENT-ON* */
1214 
1215  vec_free (adjs);
1216 }
1217 
1218 static void
1220 {
1221  hash_pair_t *p;
1222  u32 *vnis = 0;
1225 
1227  if (q == 0)
1228  {
1229  return;
1230  }
1231 
1232  /* *INDENT-OFF* */
1234  ({
1235  hash_set (vnis, p->key, 0);
1236  }));
1237 
1239  ({
1240  hash_set (vnis, p->key, 0);
1241  }));
1242 
1243  hash_foreach_pair (p, vnis,
1244  ({
1245  send_eid_table_vni (p->key, q, mp->context);
1246  }));
1247  /* *INDENT-ON* */
1248 
1249  hash_free (vnis);
1250 }
1251 
1252 static void
1254 {
1257  int rv = 0;
1258 
1260  if (q == 0)
1261  {
1262  return;
1263  }
1264 
1265  /* *INDENT-OFF* */
1266  REPLY_MACRO2(VL_API_SHOW_ONE_STATUS_REPLY,
1267  ({
1270  }));
1271  /* *INDENT-ON* */
1272 }
1273 
1274 static void
1277 {
1281  locator_set_t *loc_set = 0;
1282  u8 *tmp_str = 0;
1283  int rv = 0;
1284 
1286  if (q == 0)
1287  {
1288  return;
1289  }
1290 
1291  if (~0 == lcm->mreq_itr_rlocs)
1292  {
1293  tmp_str = format (0, " ");
1294  }
1295  else
1296  {
1297  loc_set =
1299  tmp_str = format (0, "%s", loc_set->name);
1300  }
1301 
1302  /* *INDENT-OFF* */
1303  REPLY_MACRO2(VL_API_ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY,
1304  ({
1305  strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
1306  ARRAY_LEN(rmp->locator_set_name) - 1);
1307  }));
1308  /* *INDENT-ON* */
1309 
1310  vec_free (tmp_str);
1311 }
1312 
1313 static void
1315 {
1319  mapping_t *m;
1320  locator_set_t *ls = 0;
1321  u8 *tmp_str = 0;
1322  u8 is_set = 0;
1323  int rv = 0;
1324 
1326  if (q == 0)
1327  {
1328  return;
1329  }
1330 
1331  if (lcm->nsh_map_index == (u32) ~ 0)
1332  {
1333  tmp_str = format (0, "N/A");
1334  }
1335  else
1336  {
1337  m = pool_elt_at_index (lcm->mapping_pool, lcm->nsh_map_index);
1338  if (~0 != m->locator_set_index)
1339  {
1340  ls =
1342  tmp_str = format (0, "%s", ls->name);
1343  is_set = 1;
1344  }
1345  else
1346  {
1347  tmp_str = format (0, "N/A");
1348  }
1349  }
1350  vec_add1 (tmp_str, 0);
1351 
1352  /* *INDENT-OFF* */
1353  REPLY_MACRO2(VL_API_SHOW_ONE_NSH_MAPPING_REPLY,
1354  ({
1355  rmp->is_set = is_set;
1356  strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
1357  ARRAY_LEN(rmp->locator_set_name) - 1);
1358  }));
1359  /* *INDENT-ON* */
1360 }
1361 
1362 static void
1364 {
1368  mapping_t *m;
1369  locator_set_t *ls = 0;
1370  u8 *tmp_str = 0;
1371  int rv = 0;
1372 
1374  if (q == 0)
1375  {
1376  return;
1377  }
1378 
1379  if (!lcm->lisp_pitr)
1380  {
1381  tmp_str = format (0, "N/A");
1382  }
1383  else
1384  {
1386  if (~0 != m->locator_set_index)
1387  {
1388  ls =
1390  tmp_str = format (0, "%s", ls->name);
1391  }
1392  else
1393  {
1394  tmp_str = format (0, "N/A");
1395  }
1396  }
1397  vec_add1 (tmp_str, 0);
1398 
1399  /* *INDENT-OFF* */
1400  REPLY_MACRO2(VL_API_SHOW_ONE_PITR_REPLY,
1401  ({
1402  rmp->status = lcm->lisp_pitr;
1403  strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
1404  ARRAY_LEN(rmp->locator_set_name) - 1);
1405  }));
1406  /* *INDENT-ON* */
1407 }
1408 
1409 static void
1412 {
1414  vnet_api_error_t rv = 0;
1415 
1416  /* *INDENT-OFF* */
1417  REPLY_MACRO2 (VL_API_SHOW_ONE_STATS_ENABLE_DISABLE_REPLY,
1418  ({
1420  }));
1421  /* *INDENT-ON* */
1422 }
1423 
1424 static void
1427 {
1428  vl_api_one_enable_disable_reply_t *rmp = NULL;
1429 
1431  REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
1432 }
1433 
1434 static void
1435 lisp_fid_addr_to_api (fid_address_t * fid, u8 * dst, u8 * api_eid_type,
1436  u8 * prefix_length)
1437 {
1438  switch (fid_addr_type (fid))
1439  {
1440  case FID_ADDR_IP_PREF:
1441  *prefix_length = fid_addr_prefix_length (fid);
1442  if (fid_addr_ip_version (fid) == IP4)
1443  {
1444  *api_eid_type = 0; /* ipv4 type */
1445  clib_memcpy (dst, &fid_addr_ippref (fid), 4);
1446  }
1447  else
1448  {
1449  *api_eid_type = 1; /* ipv6 type */
1450  clib_memcpy (dst, &fid_addr_ippref (fid), 16);
1451  }
1452  break;
1453  case FID_ADDR_MAC:
1454  *api_eid_type = 2; /* l2 mac type */
1455  mac_copy (dst, fid_addr_mac (fid));
1456  break;
1457  default:
1458  ASSERT (0);
1459  }
1460 }
1461 
1462 static void
1464 {
1465  vl_api_one_stats_flush_reply_t *rmp;
1466  u8 rv;
1467 
1468  rv = vnet_lisp_flush_stats ();
1469  REPLY_MACRO (VL_API_ONE_STATS_FLUSH_REPLY);
1470 }
1471 
1472 static void
1474 {
1476  lisp_api_stats_t *stats, *stat;
1477  u8 rv = 0;
1478 
1479  stats = vnet_lisp_get_stats ();
1480  vec_foreach (stat, stats)
1481  {
1482  /* *INDENT-OFF* */
1483  REPLY_DETAILS (VL_API_ONE_STATS_DETAILS,
1484  ({
1485  lisp_fid_addr_to_api (&stat->deid, rmp->deid, &rmp->eid_type,
1486  &rmp->deid_pref_len);
1487  lisp_fid_addr_to_api (&stat->seid, rmp->seid, &rmp->eid_type,
1488  &rmp->seid_pref_len);
1489  rmp->vni = clib_host_to_net_u32 (stat->vni);
1490 
1491  rmp->is_ip4 = ip_addr_version (&stat->rmt_rloc) == IP4 ? 1 : 0;
1492  ip_address_copy_addr (rmp->rloc, &stat->rmt_rloc);
1493  ip_address_copy_addr (rmp->lloc, &stat->loc_rloc);
1494 
1495  rmp->pkt_count = clib_host_to_net_u32 (stat->counters.packets);
1496  rmp->bytes = clib_host_to_net_u32 (stat->counters.bytes);
1497  }));
1498  /* *INDENT-ON* */
1499  }
1500 }
1501 
1502 static void
1505 {
1506  vl_api_one_add_del_l2_arp_entry_reply_t *rmp;
1507  int rv = 0;
1508  gid_address_t _arp, *arp = &_arp;
1509  memset (arp, 0, sizeof (*arp));
1510 
1512  gid_address_arp_bd (arp) = clib_net_to_host_u32 (mp->bd);
1513 
1514  /* vpp keeps ip4 addresses in network byte order */
1515  clib_memcpy (&gid_address_arp_ip4 (arp), &mp->ip4, 4);
1516 
1517  rv = vnet_lisp_add_del_l2_arp_entry (arp, mp->mac, mp->is_add);
1518 
1519  REPLY_MACRO (VL_API_ONE_ADD_DEL_L2_ARP_ENTRY_REPLY);
1520 }
1521 
1522 static void
1524 {
1526  int rv = 0;
1527  u32 i = 0;
1528  hash_pair_t *p;
1529 
1530  u32 *bds = vnet_lisp_l2_arp_bds_get ();
1531  u32 size = hash_elts (bds) * sizeof (u32);
1532 
1533  /* *INDENT-OFF* */
1534  REPLY_MACRO4 (VL_API_ONE_L2_ARP_BD_GET_REPLY, size,
1535  {
1536  rmp->count = clib_host_to_net_u32 (hash_elts (bds));
1537  hash_foreach_pair (p, bds,
1538  ({
1539  rmp->bridge_domains[i++] = clib_host_to_net_u32 (p->key);
1540  }));
1541  });
1542  /* *INDENT-ON* */
1543 
1544  hash_free (bds);
1545 }
1546 
1547 static void
1549 {
1551  lisp_api_l2_arp_entry_t *entries = 0, *e;
1552  u32 i = 0;
1553  int rv = 0;
1554 
1555  u32 bd = clib_net_to_host_u32 (mp->bd);
1556 
1557  entries = vnet_lisp_l2_arp_entries_get_by_bd (bd);
1558  u32 size = vec_len (entries) * sizeof (vl_api_one_l2_arp_entry_t);
1559 
1560  /* *INDENT-OFF* */
1561  REPLY_MACRO4 (VL_API_ONE_L2_ARP_ENTRIES_GET_REPLY, size,
1562  {
1563  rmp->count = clib_host_to_net_u32 (vec_len (entries));
1564  vec_foreach (e, entries)
1565  {
1566  mac_copy (rmp->entries[i].mac, e->mac);
1567  rmp->entries[i].ip4 = e->ip4;
1568  i++;
1569  }
1570  });
1571  /* *INDENT-ON* */
1572 
1573  vec_free (entries);
1574 }
1575 
1576 /*
1577  * one_api_hookup
1578  * Add vpe's API message handlers to the table.
1579  * vlib has alread mapped shared memory and
1580  * added the client registration handlers.
1581  * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
1582  */
1583 #define vl_msg_name_crc_list
1584 #include <vnet/vnet_all_api_h.h>
1585 #undef vl_msg_name_crc_list
1586 
1587 static void
1589 {
1590 #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
1591  foreach_vl_msg_name_crc_one;
1592 #undef _
1593 }
1594 
1595 static clib_error_t *
1597 {
1598  api_main_t *am = &api_main;
1599 
1600 #define _(N,n) \
1601  vl_msg_api_set_handlers(VL_API_##N, #n, \
1602  vl_api_##n##_t_handler, \
1603  vl_noop_handler, \
1604  vl_api_##n##_t_endian, \
1605  vl_api_##n##_t_print, \
1606  sizeof(vl_api_##n##_t), 1);
1608 #undef _
1609 
1610  /*
1611  * Set up the (msg_name, crc, message-id) table
1612  */
1614 
1615  return 0;
1616 }
1617 
1619 
1620 /*
1621  * fd.io coding-style-patch-verification: ON
1622  *
1623  * Local Variables:
1624  * eval: (c-set-style "gnu")
1625  * End:
1626  */
#define ip_prefix_v4(_a)
Definition: lisp_types.h:74
static void one_fid_put_api(u8 *dst, fid_address_t *src, u8 *prefix_length)
Definition: one_api.c:757
static void vl_api_one_eid_table_dump_t_handler(vl_api_one_eid_table_dump_t *mp)
Definition: one_api.c:909
u8 mac[6]
Definition: one.api:384
static void vl_api_one_eid_table_add_del_map_t_handler(vl_api_one_eid_table_add_del_map_t *mp)
Definition: one_api.c:333
Add/delete L2 ARP entries.
Definition: one.api:379
#define gid_address_ip_version(_a)
Definition: lisp_types.h:261
#define gid_address_arp_bd(_a)
Definition: lisp_types.h:280
Get ONE map request itr rlocs status.
Definition: one.api:801
u32 pitr_map_index
Definition: control.h:214
vnet_api_error_t
Definition: api_errno.h:117
gid_address_t leid
Definition: control.h:63
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:337
#define gid_address_type(_a)
Definition: lisp_types.h:257
Status of ONE PITR, enable or disable.
Definition: one.api:854
enable or disable ONE feature
Definition: one.api:142
static void vl_api_one_rloc_probe_enable_disable_t_handler(vl_api_one_rloc_probe_enable_disable_t *mp)
Definition: one_api.c:388
a
Definition: bitmap.h:516
u8 vnet_lisp_gpe_enable_disable_status(void)
Check if LISP-GPE is enabled.
Definition: lisp_gpe.c:184
lisp_api_l2_arp_entry_t * vnet_lisp_l2_arp_entries_get_by_bd(u32 bd)
Definition: control.c:882
add or delete map request itr rlocs
Definition: one.api:475
Reply with list of bridge domains used by L2 ARP table.
Definition: one.api:436
lisp_msmr_t * map_resolvers
Definition: control.h:186
static void vl_api_one_stats_enable_disable_t_handler(vl_api_one_stats_enable_disable_t *mp)
Definition: one_api.c:1426
configure or delete ONE NSH mapping
Definition: one.api:155
static void vl_api_one_add_del_local_eid_t_handler(vl_api_one_add_del_local_eid_t *mp)
Definition: one_api.c:277
#define REPLY_MACRO4(t, n, body)
uword * table_id_by_vni
Definition: control.h:203
add or delete locator_set
Definition: one.api:31
ONE adjacency.
Definition: one.api:654
static void vl_api_one_add_del_map_server_t_handler(vl_api_one_add_del_map_server_t *mp)
Definition: one_api.c:343
#define REPLY_MACRO2(t, body)
#define NULL
Definition: clib.h:55
Request for ONE status.
Definition: one.api:778
enable/disable ONE map-register
Definition: one.api:257
locator_t * locator_pool
Definition: control.h:152
dp_address_t seid
Definition: lisp_gpe.h:103
static void setup_message_id_table(api_main_t *am)
Definition: one_api.c:1588
u8 vnet_lisp_get_map_request_mode(void)
Definition: control.c:52
#define ip_prefix_len(_a)
Definition: lisp_types.h:73
reply to one_eid_table_vni_dump
Definition: one.api:725
ip_address_t loc_rloc
Definition: lisp_gpe.h:104
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:522
add or delete ONE eid-table
Definition: one.api:91
int vnet_lisp_add_del_l2_arp_entry(gid_address_t *key, u8 *mac, u8 is_add)
Definition: control.c:897
static void send_one_locator_details(lisp_cp_main_t *lcm, locator_t *loc, unix_shared_memory_queue_t *q, u32 context)
Definition: one_api.c:625
static void vl_api_one_locator_dump_t_handler(vl_api_one_locator_dump_t *mp)
Definition: one_api.c:653
Request for map server summary status.
Definition: one.api:768
#define foreach_vpe_api_msg
Definition: one_api.c:81
u32 nsh_map_index
Definition: control.h:223
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
static void vl_api_show_one_status_t_handler(vl_api_show_one_status_t *mp)
Definition: one_api.c:1253
ip_address_t address
Definition: control.h:78
vnet_api_error_t vnet_lisp_stats_enable_disable(u8 enable)
Definition: control.c:4260
void ip_address_set(ip_address_t *dst, const void *src, u8 version)
Definition: lisp_types.c:900
Reply for ONE NSH mapping.
Definition: one.api:831
static void vl_api_show_one_map_request_mode_t_handler(vl_api_show_one_map_request_mode_t *mp)
Definition: one_api.c:409
static clib_error_t * one_api_hookup(vlib_main_t *vm)
Definition: one_api.c:1596
#define ip_prefix_version(_a)
Definition: lisp_types.h:72
u8 vnet_lisp_stats_enable_disable_state(void)
Definition: control.c:4276
#define fid_addr_mac(_a)
Definition: lisp_types.h:133
u8 vnet_lisp_map_register_state_get(void)
Definition: control.c:417
static void send_one_map_server_details(ip_address_t *ip, unix_shared_memory_queue_t *q, u32 context)
Definition: one_api.c:951
int vnet_lisp_set_map_request_mode(u8 mode)
Definition: control.c:1384
int vnet_lisp_add_del_adjacency(vnet_lisp_add_del_adjacency_args_t *a)
Adds adjacency or removes forwarding entry associated to remote mapping.
Definition: control.c:1323
configure or disable use of PETR
Definition: one.api:184
uword value[0]
Definition: hash.h:164
Request for L2 ARP entries from specified bridge domain.
Definition: one.api:394
Request for map request itr rlocs summary status.
Definition: one.api:809
ONE locator_set status.
Definition: one.api:523
lisp_msmr_t * map_servers
Definition: control.h:189
u32 ip4
Definition: one.api:386
static void vl_api_one_adjacencies_get_t_handler(vl_api_one_adjacencies_get_t *mp)
Definition: one_api.c:1196
static void vl_api_one_l2_arp_bd_get_t_handler(vl_api_one_l2_arp_bd_get_t *mp)
Definition: one_api.c:1523
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
Definition: pool.h:376
static void vl_api_one_get_map_request_itr_rlocs_t_handler(vl_api_one_get_map_request_itr_rlocs_t *mp)
Definition: one_api.c:1276
Request for ONE map-request mode.
Definition: one.api:304
u8 * key
Definition: lisp_types.h:364
Request for ONE adjacencies.
Definition: one.api:680
ip_address_t rmt_rloc
Definition: lisp_gpe.h:105
Request for one_eid_table_map_details.
Definition: one.api:703
int vnet_lisp_flush_stats(void)
#define gid_address_sd_src(_a)
Definition: lisp_types.h:274
static void vl_api_one_add_del_map_resolver_t_handler(vl_api_one_add_del_map_resolver_t *mp)
Definition: one_api.c:358
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
u32 ip4
Definition: one.api:404
int vnet_lisp_eid_table_map(u32 vni, u32 dp_id, u8 is_l2, u8 is_add)
Definition: control.c:936
Dumps all VNIs used in mappings.
Definition: one.api:714
static void vl_api_one_enable_disable_t_handler(vl_api_one_enable_disable_t *mp)
Definition: one_api.c:398
static void vl_api_one_add_del_adjacency_t_handler(vl_api_one_add_del_adjacency_t *mp)
Definition: one_api.c:601
uword * bd_id_by_vni
Definition: control.h:207
#define ip_addr_v4(_a)
Definition: lisp_types.h:54
static void vl_api_one_map_resolver_dump_t_handler(vl_api_one_map_resolver_dump_t *mp)
Definition: one_api.c:1034
static lisp_cp_main_t * vnet_lisp_cp_get_main()
Definition: control.h:257
static int unformat_one_eid_api(gid_address_t *dst, u32 vni, u8 type, void *src, u8 len)
Definition: one_api.c:237
add or delete ONE adjacency adjacency
Definition: one.api:456
u32 bd
Definition: one.api:385
void * vl_msg_api_alloc(int nbytes)
vl_api_one_local_locator_t locators[locator_num]
Definition: one.api:38
u32 petr_map_index
Proxy ETR map index.
Definition: control.h:217
#define ip_addr_version(_a)
Definition: lisp_types.h:56
static void vl_api_one_add_del_map_request_itr_rlocs_t_handler(vl_api_one_add_del_map_request_itr_rlocs_t *mp)
Definition: one_api.c:536
clib_error_t * vnet_lisp_enable_disable(u8 is_enable)
Definition: control.c:1981
static void vl_api_one_map_register_enable_disable_t_handler(vl_api_one_map_register_enable_disable_t *mp)
Definition: one_api.c:377
void ip_address_copy_addr(void *dst, const ip_address_t *src)
Definition: lisp_types.c:894
int vnet_lisp_pitr_set_locator_set(u8 *locator_set_name, u8 is_add)
Definition: control.c:1456
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:397
u8 vnet_lisp_rloc_probe_state_get(void)
Definition: control.c:424
counter_t packets
packet counter
Definition: counter.h:141
static void vl_api_one_eid_table_vni_dump_t_handler(vl_api_one_eid_table_vni_dump_t *mp)
Definition: one_api.c:1219
static void send_one_map_resolver_details(ip_address_t *ip, unix_shared_memory_queue_t *q, u32 context)
Definition: one_api.c:1002
#define gid_address_mac(_a)
Definition: lisp_types.h:263
#define ip_prefix_v6(_a)
Definition: lisp_types.h:75
static u8 fid_type_to_api_type(fid_address_t *fid)
Definition: one_api.c:784
int vnet_lisp_add_del_local_mapping(vnet_lisp_add_del_mapping_args_t *a, u32 *map_index_result)
Add/update/delete mapping to/in/from map-cache.
Definition: control.c:809
Request for ONE PITR status.
Definition: one.api:843
#define hash_free(h)
Definition: hash.h:286
void gid_address_free(gid_address_t *a)
Definition: lisp_types.c:842
static void vl_api_one_add_del_remote_mapping_t_handler(vl_api_one_add_del_remote_mapping_t *mp)
Definition: one_api.c:557
u8 authoritative
Definition: lisp_types.h:355
Request for ONE PETR status.
Definition: one.api:197
lisp_api_stats_t * vnet_lisp_get_stats(void)
Definition: control.c:4043
#define REPLY_MACRO(t)
set ONE map-request mode.
Definition: one.api:293
Reply for show_one_rloc_probe_state.
Definition: one.api:233
int vnet_lisp_add_del_mapping(gid_address_t *eid, locator_t *rlocs, u8 action, u8 authoritative, u32 ttl, u8 is_add, u8 is_static, u32 *res_map_index)
Adds/removes/updates mapping.
Definition: control.c:1139
add or delete map-resolver
Definition: one.api:128
void ip_prefix_normalize(ip_prefix_t *a)
Definition: lisp_types.c:980
VLIB_API_INIT_FUNCTION(one_api_hookup)
#define ip_addr_v6(_a)
Definition: lisp_types.h:55
#define gid_address_ippref(_a)
Definition: lisp_types.h:258
Definition: one.api:401
dp_address_t deid
Definition: lisp_gpe.h:102
lisp_adjacency_t * vnet_lisp_adjacencies_get_by_vni(u32 vni)
Returns vector of adjacencies.
Definition: control.c:595
#define BAD_SW_IF_INDEX_LABEL
u32 sw_if_index
Definition: lisp_types.h:316
ONE map server details.
Definition: one.api:757
Request for map one locator status.
Definition: one.api:507
api_main_t api_main
Definition: api_shared.c:35
int vnet_lisp_add_del_mreq_itr_rlocs(vnet_lisp_add_del_mreq_itr_rloc_args_t *a)
Definition: control.c:2078
Shows relationship between vni and vrf/bd.
Definition: one.api:691
vlib_counter_t counters
Definition: lisp_gpe.h:107
Dump ONE eid-table.
Definition: one.api:588
vl_api_one_remote_locator_t rlocs[rloc_num]
Definition: one.api:368
static void vl_api_one_use_petr_t_handler(vl_api_one_use_petr_t *mp)
Definition: one_api.c:464
void gid_address_ip_set(gid_address_t *dst, void *src, u8 version)
Definition: lisp_types.c:1552
Get state of ONE map-register.
Definition: one.api:268
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:340
Request for ONE NSH mapping.
Definition: one.api:820
#define gid_address_ippref_len(_a)
Definition: lisp_types.h:259
Request for list of bridge domains used by L2 ARP table.
Definition: one.api:425
ONE adjacency reply.
Definition: one.api:667
#define clib_warning(format, args...)
Definition: error.h:59
u32 locator_set_index
Definition: lisp_types.h:348
static void send_eid_table_vni(u32 vni, unix_shared_memory_queue_t *q, u32 context)
Definition: one_api.c:1100
#define clib_memcpy(a, b, c)
Definition: string.h:69
unix_shared_memory_queue_t * vl_api_client_index_to_input_queue(u32 index)
vl_api_one_l2_arp_entry_t entries[count]
Definition: one.api:418
#define fid_addr_ip_version(_a)
Definition: lisp_types.h:132
int vnet_lisp_map_register_enable_disable(u8 is_enable)
Definition: control.c:1972
Reply for show_one_map_request_mode.
Definition: one.api:315
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:238
#define ARRAY_LEN(x)
Definition: clib.h:59
lisp_key_type_t key_id
Definition: lisp_types.h:365
#define gid_address_nsh_si(_a)
Definition: lisp_types.h:266
static void vl_api_show_one_rloc_probe_state_t_handler(vl_api_show_one_rloc_probe_state_t *mp)
Definition: one_api.c:1167
static void vl_api_show_one_stats_enable_disable_t_handler(vl_api_show_one_stats_enable_disable_t *mp)
Definition: one_api.c:1411
#define fid_addr_ippref(_a)
Definition: lisp_types.h:130
u8 vnet_lisp_enable_disable_status(void)
Definition: control.c:2023
Reply with L2 ARP entries from specified bridge domain.
Definition: one.api:413
struct _gid_address_t gid_address_t
void vl_msg_api_send_shmem(unix_shared_memory_queue_t *q, u8 *elem)
int vnet_lisp_add_del_map_server(ip_address_t *addr, u8 is_add)
Definition: control.c:649
static uword hash_elts(void *v)
Definition: hash.h:117
#define ASSERT(truth)
#define fid_addr_type(_a)
Definition: lisp_types.h:135
unsigned int u32
Definition: types.h:88
static void vl_api_show_one_map_register_state_t_handler(vl_api_show_one_map_register_state_t *mp)
Definition: one_api.c:1182
u8 is_add
Definition: one.api:383
int vnet_lisp_clear_all_remote_adjacencies(void)
Definition: control.c:1272
map/unmap vni/bd_index to vrf
Definition: one.api:490
#define gid_address_sd_dst(_a)
Definition: lisp_types.h:275
gid_dictionary_t mapping_index_by_gid
Definition: control.h:143
#define REPLY_DETAILS(t, body)
Definition: one_api.c:66
u64 size
Definition: vhost-user.h:75
locator_set_t * locator_set_pool
Definition: control.h:155
static void vl_api_one_nsh_set_locator_set_t_handler(vl_api_one_nsh_set_locator_set_t *mp)
Definition: one_api.c:434
static void vl_api_one_add_del_l2_arp_entry_t_handler(vl_api_one_add_del_l2_arp_entry_t *mp)
Definition: one_api.c:1504
int vnet_lisp_rloc_probe_enable_disable(u8 is_enable)
Definition: control.c:1963
static void vl_api_one_locator_set_dump_t_handler(vl_api_one_locator_set_dump_t *mp)
Definition: one_api.c:728
Get state of ONE RLOC probing.
Definition: one.api:222
Add/delete map server.
Definition: one.api:112
ONE PETR status, enable or disable.
Definition: one.api:209
u64 gid_dictionary_lookup(gid_dictionary_t *db, gid_address_t *key)
static void vl_api_one_stats_dump_t_handler(vl_api_one_stats_dump_t *mp)
Definition: one_api.c:1473
Definition: control.h:90
u64 uword
Definition: types.h:112
add or delete remote static mapping
Definition: one.api:353
static void vl_api_one_eid_table_map_dump_t_handler(vl_api_one_eid_table_map_dump_t *mp)
Definition: one_api.c:1069
counter_t bytes
byte counter
Definition: counter.h:142
int vnet_lisp_add_del_locator_set(vnet_lisp_add_del_locator_set_args_t *a, u32 *ls_result)
Definition: control.c:1823
#define gid_address_ip(_a)
Definition: lisp_types.h:260
#define gid_address_vni(_a)
Definition: lisp_types.h:267
static void vl_api_show_one_nsh_mapping_t_handler(vl_api_show_one_nsh_mapping_t *mp)
Definition: one_api.c:1314
add or delete locator for locator set
Definition: one.api:62
static void vl_api_one_add_del_locator_set_t_handler(vl_api_one_add_del_locator_set_t *mp)
Definition: one_api.c:147
Reply for locator_set add/del.
Definition: one.api:46
Request for map resolver summary status.
Definition: one.api:747
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unsigned char u8
Definition: types.h:56
#define hash_foreach_pair(p, v, body)
Iterate over hash pairs.
Definition: hash.h:349
static void vl_api_one_add_del_locator_t_handler(vl_api_one_add_del_locator_t *mp)
Definition: one_api.c:197
enable/disable ONE RLOC probing
Definition: one.api:245
#define gid_address_nsh_spi(_a)
Definition: lisp_types.h:265
u32 * vnet_lisp_l2_arp_bds_get(void)
Definition: control.c:851
int vnet_lisp_add_del_locator(vnet_lisp_add_del_locator_set_args_t *a, locator_set_t *ls, u32 *ls_result)
Definition: control.c:1719
mapping_t * mapping_pool
Definition: control.h:146
uword * locator_set_index_by_name
Definition: control.h:161
int vnet_lisp_nsh_set_locator_set(u8 *locator_set_name, u8 is_add)
Definition: control.c:1405
void gid_address_copy(gid_address_t *dst, gid_address_t *src)
Definition: lisp_types.c:1487
static void vl_api_one_map_request_mode_t_handler(vl_api_one_map_request_mode_t *mp)
Definition: one_api.c:423
Definition: lisp_types.h:37
gid_address_t eid
Definition: lisp_types.h:343
gid_address_t reid
Definition: control.h:64
static void vl_api_one_pitr_set_locator_set_t_handler(vl_api_one_pitr_set_locator_set_t *mp)
Definition: one_api.c:449
gid_address_t address
Definition: lisp_types.h:317
static void vl_api_one_l2_arp_entries_get_t_handler(vl_api_one_l2_arp_entries_get_t *mp)
Definition: one_api.c:1548
#define hash_get_mem(h, key)
Definition: hash.h:268
void mac_copy(void *dst, void *src)
Definition: lisp_types.c:1043
ONE locator_set status.
Definition: one.api:539
int vnet_lisp_add_del_map_resolver(vnet_lisp_add_del_map_resolver_args_t *a)
Definition: control.c:2030
static void vl_api_show_one_pitr_t_handler(vl_api_show_one_pitr_t *mp)
Definition: one_api.c:1363
#define vec_foreach(var, vec)
Vector iterator.
#define fid_addr_prefix_length(_a)
Definition: lisp_types.h:131
static void vl_api_show_one_use_petr_t_handler(vl_api_show_one_use_petr_t *mp)
Definition: one_api.c:477
Request for eid table summary status.
Definition: one.api:632
vhost_vring_addr_t addr
Definition: vhost-user.h:82
#define gid_address_arp_ip4(_a)
Definition: lisp_types.h:279
u8 mac[6]
Definition: one.api:403
Request for locator_set summary status.
Definition: one.api:555
Definition: lisp_types.h:38
static void vl_api_one_stats_flush_t_handler(vl_api_one_stats_flush_t *mp)
Definition: one_api.c:1463
static void send_one_locator_set_details(lisp_cp_main_t *lcm, locator_set_t *lsit, unix_shared_memory_queue_t *q, u32 context, u32 ls_index)
Definition: one_api.c:697
int vnet_lisp_use_petr(ip_address_t *ip, u8 is_add)
Configure Proxy-ETR.
Definition: control.c:1508
ONE map resolver status.
Definition: one.api:736
static void send_eid_table_map_pair(hash_pair_t *p, unix_shared_memory_queue_t *q, u32 context)
Definition: one_api.c:1053
u32 mreq_itr_rlocs
Definition: control.h:200
u32 * locator_indices
Definition: lisp_types.h:337
static locator_t * unformat_one_locs(vl_api_one_remote_locator_t *rmt_locs, u32 rloc_num)
Definition: one_api.c:125
Reply for show_one_map_register_state.
Definition: one.api:278
static void lisp_fid_addr_to_api(fid_address_t *fid, u8 *dst, u8 *api_eid_type, u8 *prefix_length)
Definition: one_api.c:1435
uword key
Definition: hash.h:161
LISP-GPE definitions.
configure or disable ONE PITR node
Definition: one.api:169
#define VALIDATE_SW_IF_INDEX(mp)
struct _unix_shared_memory_queue unix_shared_memory_queue_t
vl_api_one_adjacency_t adjacencies[count]
Definition: one.api:672
static void one_adjacency_copy(vl_api_one_adjacency_t *dst, lisp_adjacency_t *adjs)
Definition: one_api.c:1113
static void vl_api_one_map_server_dump_t_handler(vl_api_one_map_server_dump_t *mp)
Definition: one_api.c:983
static void send_one_eid_table_details(mapping_t *mapit, unix_shared_memory_queue_t *q, u32 context, u8 filter)
Definition: one_api.c:809