LCOV - code coverage report
Current view: top level - plugins/lisp/lisp-cp - one_api.c (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 4 730 0.5 %
Date: 2023-07-05 22:20:52 Functions: 3 68 4.4 %

          Line data    Source code
       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 <lisp/lisp-cp/control.h>
      26             : #include <lisp/lisp-gpe/lisp_gpe.h>
      27             : 
      28             : #include <vnet/ip/ip_types_api.h>
      29             : #include <vnet/ethernet/ethernet_types_api.h>
      30             : 
      31             : /* define message IDs */
      32             : #include <vnet/format_fns.h>
      33             : #include <lisp/lisp-cp/one.api_enum.h>
      34             : #include <lisp/lisp-cp/one.api_types.h>
      35             : 
      36             : /**
      37             :  * Base message ID fot the plugin
      38             :  */
      39             : static u32 one_base_msg_id;
      40             : #define REPLY_MSG_ID_BASE one_base_msg_id
      41             : 
      42             : #include <vlibapi/api_helper_macros.h>
      43             : 
      44             : #define REPLY_DETAILS(t, body)                                          \
      45             : do {                                                                    \
      46             :     vl_api_registration_t * reg;                                        \
      47             :     rv = vl_msg_api_pd_handler (mp, rv);                                \
      48             :     reg = vl_api_client_index_to_registration (mp->client_index);    \
      49             :     if (!reg)                                                           \
      50             :       return;                                                           \
      51             :                                                                   \
      52             :     rmp = vl_msg_api_alloc (sizeof (*rmp));                             \
      53             :     rmp->_vl_msg_id = ntohs((t));                                    \
      54             :     rmp->context = mp->context;                                   \
      55             :     do {body;} while (0);                                               \
      56             :     vl_api_send_msg (reg, (u8 *)&rmp);                                      \
      57             : } while(0);
      58             : 
      59             : #define foreach_vpe_api_msg                                                     \
      60             : _(ONE_ADD_DEL_LOCATOR_SET, one_add_del_locator_set)                     \
      61             : _(ONE_ADD_DEL_LOCATOR, one_add_del_locator)                             \
      62             : _(ONE_ADD_DEL_LOCAL_EID, one_add_del_local_eid)                         \
      63             : _(ONE_ADD_DEL_MAP_RESOLVER, one_add_del_map_resolver)                   \
      64             : _(ONE_ADD_DEL_MAP_SERVER, one_add_del_map_server)                       \
      65             : _(ONE_ENABLE_DISABLE, one_enable_disable)                               \
      66             : _(ONE_RLOC_PROBE_ENABLE_DISABLE, one_rloc_probe_enable_disable)         \
      67             : _(ONE_MAP_REGISTER_ENABLE_DISABLE, one_map_register_enable_disable)     \
      68             : _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD,                                  \
      69             :   one_map_register_fallback_threshold)                                  \
      70             : _(ONE_ADD_DEL_REMOTE_MAPPING, one_add_del_remote_mapping)               \
      71             : _(ONE_ADD_DEL_ADJACENCY, one_add_del_adjacency)                         \
      72             : _(ONE_PITR_SET_LOCATOR_SET, one_pitr_set_locator_set)                   \
      73             : _(ONE_NSH_SET_LOCATOR_SET, one_nsh_set_locator_set)                     \
      74             : _(ONE_MAP_REQUEST_MODE, one_map_request_mode)                           \
      75             : _(ONE_EID_TABLE_ADD_DEL_MAP, one_eid_table_add_del_map)                 \
      76             : _(ONE_LOCATOR_SET_DUMP, one_locator_set_dump)                           \
      77             : _(ONE_LOCATOR_DUMP, one_locator_dump)                                   \
      78             : _(ONE_EID_TABLE_DUMP, one_eid_table_dump)                               \
      79             : _(ONE_MAP_RESOLVER_DUMP, one_map_resolver_dump)                         \
      80             : _(ONE_MAP_SERVER_DUMP, one_map_server_dump)                             \
      81             : _(ONE_EID_TABLE_MAP_DUMP, one_eid_table_map_dump)                       \
      82             : _(ONE_EID_TABLE_VNI_DUMP, one_eid_table_vni_dump)                       \
      83             : _(ONE_ADJACENCIES_GET, one_adjacencies_get)                             \
      84             : _(ONE_MAP_REGISTER_SET_TTL, one_map_register_set_ttl)                   \
      85             : _(SHOW_ONE_NSH_MAPPING, show_one_nsh_mapping)                           \
      86             : _(SHOW_ONE_RLOC_PROBE_STATE, show_one_rloc_probe_state)                 \
      87             : _(SHOW_ONE_MAP_REGISTER_STATE, show_one_map_register_state)             \
      88             : _(SHOW_ONE_MAP_REGISTER_TTL, show_one_map_register_ttl)                 \
      89             : _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD,                             \
      90             :   show_one_map_register_fallback_threshold)                             \
      91             : _(SHOW_ONE_STATUS, show_one_status)                                     \
      92             : _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS,                                    \
      93             :   one_add_del_map_request_itr_rlocs)                                    \
      94             : _(ONE_GET_MAP_REQUEST_ITR_RLOCS, one_get_map_request_itr_rlocs)         \
      95             : _(SHOW_ONE_PITR, show_one_pitr)                                         \
      96             : _(SHOW_ONE_MAP_REQUEST_MODE, show_one_map_request_mode)                 \
      97             : _(ONE_USE_PETR, one_use_petr)                                           \
      98             : _(SHOW_ONE_USE_PETR, show_one_use_petr)                                 \
      99             : _(SHOW_ONE_STATS_ENABLE_DISABLE, show_one_stats_enable_disable)         \
     100             : _(ONE_STATS_ENABLE_DISABLE, one_stats_enable_disable)                   \
     101             : _(ONE_STATS_DUMP, one_stats_dump)                                       \
     102             : _(ONE_STATS_FLUSH, one_stats_flush)                                     \
     103             : _(ONE_L2_ARP_BD_GET, one_l2_arp_bd_get)                                 \
     104             : _(ONE_L2_ARP_ENTRIES_GET, one_l2_arp_entries_get)                       \
     105             : _(ONE_ADD_DEL_L2_ARP_ENTRY, one_add_del_l2_arp_entry)                   \
     106             : _(ONE_ADD_DEL_NDP_ENTRY, one_add_del_ndp_entry)                         \
     107             : _(ONE_NDP_BD_GET, one_ndp_bd_get)                                       \
     108             : _(ONE_NDP_ENTRIES_GET, one_ndp_entries_get)                             \
     109             : _(ONE_SET_TRANSPORT_PROTOCOL, one_set_transport_protocol)               \
     110             : _(ONE_GET_TRANSPORT_PROTOCOL, one_get_transport_protocol)               \
     111             : _(ONE_ENABLE_DISABLE_XTR_MODE, one_enable_disable_xtr_mode)             \
     112             : _(ONE_SHOW_XTR_MODE, one_show_xtr_mode)                                 \
     113             : _(ONE_ENABLE_DISABLE_PITR_MODE, one_enable_disable_pitr_mode)           \
     114             : _(ONE_SHOW_PITR_MODE, one_show_pitr_mode)                               \
     115             : _(ONE_ENABLE_DISABLE_PETR_MODE, one_enable_disable_petr_mode)           \
     116             : _(ONE_SHOW_PETR_MODE, one_show_petr_mode)                               \
     117             : 
     118             : 
     119             : static locator_t *
     120           0 : unformat_one_locs (vl_api_remote_locator_t * rmt_locs, u32 rloc_num)
     121             : {
     122             :   u32 i;
     123           0 :   locator_t *locs = 0, loc;
     124             :   vl_api_remote_locator_t *r;
     125             : 
     126           0 :   for (i = 0; i < rloc_num; i++)
     127             :     {
     128             :       /* remote locators */
     129           0 :       r = &rmt_locs[i];
     130           0 :       clib_memset (&loc, 0, sizeof (loc));
     131           0 :       ip_address_decode2 (&r->ip_address, &loc.address.ippref.addr);
     132           0 :       loc.address.ippref.len =
     133           0 :         ip_address_max_len (loc.address.ippref.addr.version);
     134             : 
     135           0 :       loc.priority = r->priority;
     136           0 :       loc.weight = r->weight;
     137             : 
     138           0 :       vec_add1 (locs, loc);
     139             :     }
     140           0 :   return locs;
     141             : }
     142             : 
     143             : static void
     144           0 : vl_api_one_map_register_set_ttl_t_handler (vl_api_one_map_register_set_ttl_t *
     145             :                                            mp)
     146             : {
     147             :   vl_api_one_map_register_set_ttl_reply_t *rmp;
     148           0 :   int rv = 0;
     149             : 
     150           0 :   mp->ttl = clib_net_to_host_u32 (mp->ttl);
     151           0 :   rv = vnet_lisp_map_register_set_ttl (mp->ttl);
     152             : 
     153           0 :   REPLY_MACRO (VL_API_ONE_MAP_REGISTER_SET_TTL_REPLY);
     154             : }
     155             : 
     156             : static void
     157           0 :   vl_api_show_one_map_register_ttl_t_handler
     158             :   (vl_api_show_one_map_register_ttl_t * mp)
     159             : {
     160             :   vl_api_show_one_map_register_ttl_reply_t *rmp;
     161           0 :   int rv = 0;
     162             : 
     163           0 :   u32 ttl = vnet_lisp_map_register_get_ttl ();
     164             :   /* *INDENT-OFF* */
     165           0 :   REPLY_MACRO2 (VL_API_SHOW_ONE_MAP_REGISTER_TTL_REPLY,
     166             :   ({
     167             :     rmp->ttl = clib_host_to_net_u32 (ttl);
     168             :   }));
     169             :   /* *INDENT-ON* */
     170             : }
     171             : 
     172             : static void
     173           0 : vl_api_one_add_del_locator_set_t_handler (vl_api_one_add_del_locator_set_t *
     174             :                                           mp)
     175             : {
     176             :   vl_api_one_add_del_locator_set_reply_t *rmp;
     177           0 :   int rv = 0;
     178           0 :   vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
     179             :   locator_t locator;
     180             :   vl_api_local_locator_t *ls_loc;
     181           0 :   u32 ls_index = ~0, locator_num;
     182           0 :   u8 *locator_name = NULL;
     183             :   int i;
     184             : 
     185           0 :   clib_memset (a, 0, sizeof (a[0]));
     186             : 
     187           0 :   mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
     188           0 :   locator_name = format (0, "%s", mp->locator_set_name);
     189           0 :   vec_terminate_c_string (locator_name);
     190             : 
     191           0 :   a->name = locator_name;
     192           0 :   a->is_add = mp->is_add;
     193           0 :   a->local = 1;
     194           0 :   locator_num = clib_net_to_host_u32 (mp->locator_num);
     195             : 
     196           0 :   clib_memset (&locator, 0, sizeof (locator));
     197           0 :   for (i = 0; i < locator_num; i++)
     198             :     {
     199           0 :       ls_loc = &mp->locators[i];
     200           0 :       VALIDATE_SW_IF_INDEX (ls_loc);
     201             : 
     202           0 :       locator.sw_if_index = htonl (ls_loc->sw_if_index);
     203           0 :       locator.priority = ls_loc->priority;
     204           0 :       locator.weight = ls_loc->weight;
     205           0 :       locator.local = 1;
     206           0 :       vec_add1 (a->locators, locator);
     207             :     }
     208             : 
     209           0 :   rv = vnet_lisp_add_del_locator_set (a, &ls_index);
     210             : 
     211           0 :   BAD_SW_IF_INDEX_LABEL;
     212             : 
     213           0 :   vec_free (locator_name);
     214           0 :   vec_free (a->locators);
     215             : 
     216             :   /* *INDENT-OFF* */
     217           0 :   REPLY_MACRO2 (VL_API_ONE_ADD_DEL_LOCATOR_SET_REPLY,
     218             :   ({
     219             :     rmp->ls_index = clib_host_to_net_u32 (ls_index);
     220             :   }));
     221             :   /* *INDENT-ON* */
     222             : }
     223             : 
     224             : static void
     225           0 : vl_api_one_add_del_locator_t_handler (vl_api_one_add_del_locator_t * mp)
     226             : {
     227             :   vl_api_one_add_del_locator_reply_t *rmp;
     228           0 :   int rv = 0;
     229           0 :   locator_t locator, *locators = NULL;
     230           0 :   vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
     231           0 :   u32 ls_index = ~0;
     232           0 :   u8 *locator_name = NULL;
     233             : 
     234           0 :   clib_memset (&locator, 0, sizeof (locator));
     235           0 :   clib_memset (a, 0, sizeof (a[0]));
     236             : 
     237           0 :   locator.sw_if_index = ntohl (mp->sw_if_index);
     238           0 :   locator.priority = mp->priority;
     239           0 :   locator.weight = mp->weight;
     240           0 :   locator.local = 1;
     241           0 :   vec_add1 (locators, locator);
     242             : 
     243           0 :   mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
     244           0 :   locator_name = format (0, "%s", mp->locator_set_name);
     245           0 :   vec_terminate_c_string (locator_name);
     246             : 
     247           0 :   a->name = locator_name;
     248           0 :   a->locators = locators;
     249           0 :   a->is_add = mp->is_add;
     250           0 :   a->local = 1;
     251             : 
     252           0 :   rv = vnet_lisp_add_del_locator (a, NULL, &ls_index);
     253             : 
     254           0 :   vec_free (locators);
     255           0 :   vec_free (locator_name);
     256             : 
     257           0 :   REPLY_MACRO (VL_API_ONE_ADD_DEL_LOCATOR_REPLY);
     258             : }
     259             : 
     260             : typedef struct
     261             : {
     262             :   u32 spi;
     263             :   u8 si;
     264             : } __attribute__ ((__packed__)) lisp_nsh_api_t;
     265             : 
     266             : static int
     267           0 : unformat_one_eid_api (gid_address_t * dst, u32 vni, vl_api_eid_t * eid)
     268             : {
     269             :   fib_prefix_t prefix;
     270             : 
     271           0 :   switch (eid->type)
     272             :     {
     273           0 :     case EID_TYPE_API_PREFIX:
     274           0 :       ip_prefix_decode (&eid->address.prefix, &prefix);
     275           0 :       gid_address_type (dst) = GID_ADDR_IP_PREFIX;
     276           0 :       if (prefix.fp_proto == FIB_PROTOCOL_IP4)
     277           0 :         gid_address_ip_set (dst, &prefix.fp_addr.ip4, AF_IP4);
     278           0 :       if (prefix.fp_proto == FIB_PROTOCOL_IP6)
     279           0 :         gid_address_ip_set (dst, &prefix.fp_addr.ip6, AF_IP6);
     280           0 :       gid_address_ippref_len (dst) = prefix.fp_len;
     281           0 :       ip_prefix_normalize (&gid_address_ippref (dst));
     282           0 :       break;
     283           0 :     case EID_TYPE_API_MAC:
     284           0 :       gid_address_type (dst) = GID_ADDR_MAC;
     285           0 :       mac_address_decode (eid->address.mac,
     286           0 :                           (mac_address_t *) & gid_address_mac (dst));
     287           0 :       break;
     288           0 :     case EID_TYPE_API_NSH:
     289           0 :       gid_address_type (dst) = GID_ADDR_NSH;
     290           0 :       gid_address_nsh_spi (dst) = clib_net_to_host_u32 (eid->address.nsh.spi);
     291           0 :       gid_address_nsh_si (dst) = eid->address.nsh.si;
     292           0 :       break;
     293           0 :     default:
     294             :       /* unknown type */
     295           0 :       return VNET_API_ERROR_INVALID_VALUE;
     296             :     }
     297             : 
     298           0 :   gid_address_vni (dst) = vni;
     299             : 
     300           0 :   return 0;
     301             : }
     302             : 
     303             : static void
     304           0 : fid_to_api_eid (fid_address_t * fid, vl_api_eid_t * eid)
     305             : {
     306             :   fib_prefix_t fib_prefix;
     307             :   u32 eid_type;
     308             : 
     309           0 :   switch (fid_addr_type (fid))
     310             :     {
     311           0 :     case FID_ADDR_IP_PREF:
     312           0 :       eid_type = EID_TYPE_API_PREFIX;
     313           0 :       ip_prefix_to_fib_prefix (&fid_addr_ippref (fid), &fib_prefix);
     314           0 :       ip_prefix_encode (&fib_prefix, &eid->address.prefix);
     315           0 :       break;
     316           0 :     case FID_ADDR_MAC:
     317           0 :       eid_type = EID_TYPE_API_MAC;
     318           0 :       mac_address_encode ((mac_address_t *) fid_addr_mac (fid),
     319           0 :                           eid->address.mac);
     320           0 :       break;
     321           0 :     default:
     322             :       /* unknown type */
     323           0 :       return;
     324             :     }
     325             : 
     326           0 :   eid->type = eid_type;
     327             : }
     328             : 
     329             : static void
     330           0 : vl_api_one_add_del_local_eid_t_handler (vl_api_one_add_del_local_eid_t * mp)
     331             : {
     332             :   vl_api_one_add_del_local_eid_reply_t *rmp;
     333           0 :   lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
     334           0 :   int rv = 0;
     335           0 :   gid_address_t _eid, *eid = &_eid;
     336           0 :   uword *p = NULL;
     337           0 :   u32 locator_set_index = ~0, map_index = ~0;
     338           0 :   vnet_lisp_add_del_mapping_args_t _a, *a = &_a;
     339           0 :   u8 *name = NULL, *key = NULL;
     340           0 :   clib_memset (a, 0, sizeof (a[0]));
     341           0 :   clib_memset (eid, 0, sizeof (eid[0]));
     342             : 
     343           0 :   rv = unformat_one_eid_api (eid, clib_net_to_host_u32 (mp->vni), &mp->eid);
     344           0 :   if (rv)
     345           0 :     goto out;
     346             : 
     347           0 :   if (gid_address_type (eid) == GID_ADDR_NSH)
     348             :     {
     349           0 :       rv = VNET_API_ERROR_INVALID_VALUE;
     350           0 :       goto out;
     351             :     }
     352             : 
     353           0 :   mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
     354           0 :   name = format (0, "%s", mp->locator_set_name);
     355           0 :   vec_terminate_c_string (name);
     356           0 :   p = hash_get_mem (lcm->locator_set_index_by_name, name);
     357           0 :   if (!p)
     358             :     {
     359           0 :       rv = VNET_API_ERROR_INVALID_VALUE;
     360           0 :       goto out;
     361             :     }
     362           0 :   locator_set_index = p[0];
     363             : 
     364           0 :   if (mp->key.id != KEY_ID_API_HMAC_NO_KEY)
     365           0 :     key = format (0, "%s", mp->key.key);
     366             : 
     367             :   /* XXX treat batch configuration */
     368           0 :   a->is_add = mp->is_add;
     369           0 :   gid_address_copy (&a->eid, eid);
     370           0 :   a->locator_set_index = locator_set_index;
     371           0 :   a->local = 1;
     372           0 :   a->key = key;
     373           0 :   a->key_id = mp->key.id;
     374             : 
     375           0 :   rv = vnet_lisp_add_del_local_mapping (a, &map_index);
     376             : 
     377           0 : out:
     378           0 :   vec_free (name);
     379           0 :   vec_free (key);
     380           0 :   gid_address_free (&a->eid);
     381             : 
     382           0 :   REPLY_MACRO (VL_API_ONE_ADD_DEL_LOCAL_EID_REPLY);
     383             : }
     384             : 
     385             : static void
     386           0 :   vl_api_one_eid_table_add_del_map_t_handler
     387             :   (vl_api_one_eid_table_add_del_map_t * mp)
     388             : {
     389             :   vl_api_one_eid_table_add_del_map_reply_t *rmp;
     390           0 :   int rv = 0;
     391           0 :   rv = vnet_lisp_eid_table_map (clib_net_to_host_u32 (mp->vni),
     392             :                                 clib_net_to_host_u32 (mp->dp_table),
     393           0 :                                 mp->is_l2, mp->is_add);
     394           0 : REPLY_MACRO (VL_API_ONE_EID_TABLE_ADD_DEL_MAP_REPLY)}
     395             : 
     396             : static void
     397           0 : vl_api_one_add_del_map_server_t_handler (vl_api_one_add_del_map_server_t * mp)
     398             : {
     399             :   vl_api_one_add_del_map_server_reply_t *rmp;
     400           0 :   int rv = 0;
     401             :   ip_address_t addr;
     402             : 
     403           0 :   clib_memset (&addr, 0, sizeof (addr));
     404             : 
     405           0 :   ip_address_decode2 (&mp->ip_address, &addr);
     406             : 
     407           0 :   rv = vnet_lisp_add_del_map_server (&addr, mp->is_add);
     408             : 
     409           0 :   REPLY_MACRO (VL_API_ONE_ADD_DEL_MAP_SERVER_REPLY);
     410             : }
     411             : 
     412             : static void
     413           0 : vl_api_one_add_del_map_resolver_t_handler (vl_api_one_add_del_map_resolver_t
     414             :                                            * mp)
     415             : {
     416             :   vl_api_one_add_del_map_resolver_reply_t *rmp;
     417           0 :   int rv = 0;
     418           0 :   vnet_lisp_add_del_map_resolver_args_t _a, *a = &_a;
     419             : 
     420           0 :   clib_memset (a, 0, sizeof (a[0]));
     421             : 
     422           0 :   ip_address_decode2 (&mp->ip_address, &a->address);
     423             : 
     424           0 :   a->is_add = mp->is_add;
     425             : 
     426           0 :   rv = vnet_lisp_add_del_map_resolver (a);
     427             : 
     428           0 :   REPLY_MACRO (VL_API_ONE_ADD_DEL_MAP_RESOLVER_REPLY);
     429             : }
     430             : 
     431             : static void
     432           0 :   vl_api_one_map_register_enable_disable_t_handler
     433             :   (vl_api_one_map_register_enable_disable_t * mp)
     434             : {
     435             :   vl_api_one_map_register_enable_disable_reply_t *rmp;
     436           0 :   int rv = 0;
     437             : 
     438           0 :   vnet_lisp_map_register_enable_disable (mp->is_enable);
     439           0 :   REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
     440             : }
     441             : 
     442             : static void
     443           0 :   vl_api_one_rloc_probe_enable_disable_t_handler
     444             :   (vl_api_one_rloc_probe_enable_disable_t * mp)
     445             : {
     446             :   vl_api_one_rloc_probe_enable_disable_reply_t *rmp;
     447           0 :   int rv = 0;
     448             : 
     449           0 :   vnet_lisp_rloc_probe_enable_disable (mp->is_enable);
     450           0 :   REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
     451             : }
     452             : 
     453             : static void
     454           0 : vl_api_one_enable_disable_t_handler (vl_api_one_enable_disable_t * mp)
     455             : {
     456             :   vl_api_one_enable_disable_reply_t *rmp;
     457           0 :   int rv = 0;
     458             : 
     459           0 :   vnet_lisp_enable_disable (mp->is_enable);
     460           0 :   REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
     461             : }
     462             : 
     463             : static void
     464           0 :   vl_api_show_one_map_request_mode_t_handler
     465             :   (vl_api_show_one_map_request_mode_t * mp)
     466             : {
     467           0 :   int rv = 0;
     468             :   vl_api_show_one_map_request_mode_reply_t *rmp;
     469             : 
     470             :   /* *INDENT-OFF* */
     471           0 :   REPLY_MACRO2(VL_API_SHOW_ONE_MAP_REQUEST_MODE_REPLY,
     472             :   ({
     473             :     rmp->mode = vnet_lisp_get_map_request_mode ();
     474             :   }));
     475             :   /* *INDENT-ON* */
     476             : }
     477             : 
     478             : static void
     479           0 : vl_api_one_map_request_mode_t_handler (vl_api_one_map_request_mode_t * mp)
     480             : {
     481             :   vl_api_one_map_request_mode_reply_t *rmp;
     482           0 :   int rv = 0;
     483             : 
     484           0 :   rv = vnet_lisp_set_map_request_mode (mp->mode);
     485             : 
     486           0 :   REPLY_MACRO (VL_API_ONE_MAP_REQUEST_MODE_REPLY);
     487             : }
     488             : 
     489             : static void
     490           0 : vl_api_one_nsh_set_locator_set_t_handler (vl_api_one_nsh_set_locator_set_t
     491             :                                           * mp)
     492             : {
     493             :   vl_api_one_nsh_set_locator_set_reply_t *rmp;
     494           0 :   int rv = 0;
     495           0 :   u8 *ls_name = 0;
     496             : 
     497           0 :   mp->ls_name[sizeof (mp->ls_name) - 1] = 0;
     498           0 :   ls_name = format (0, "%s", mp->ls_name);
     499           0 :   vec_terminate_c_string (ls_name);
     500           0 :   rv = vnet_lisp_nsh_set_locator_set (ls_name, mp->is_add);
     501           0 :   vec_free (ls_name);
     502             : 
     503           0 :   REPLY_MACRO (VL_API_ONE_PITR_SET_LOCATOR_SET_REPLY);
     504             : }
     505             : 
     506             : static void
     507           0 : vl_api_one_pitr_set_locator_set_t_handler (vl_api_one_pitr_set_locator_set_t
     508             :                                            * mp)
     509             : {
     510             :   vl_api_one_pitr_set_locator_set_reply_t *rmp;
     511           0 :   int rv = 0;
     512           0 :   u8 *ls_name = 0;
     513             : 
     514           0 :   mp->ls_name[sizeof (mp->ls_name) - 1] = 0;
     515           0 :   ls_name = format (0, "%s", mp->ls_name);
     516           0 :   vec_terminate_c_string (ls_name);
     517           0 :   rv = vnet_lisp_pitr_set_locator_set (ls_name, mp->is_add);
     518           0 :   vec_free (ls_name);
     519             : 
     520           0 :   REPLY_MACRO (VL_API_ONE_PITR_SET_LOCATOR_SET_REPLY);
     521             : }
     522             : 
     523             : static void
     524           0 : vl_api_one_use_petr_t_handler (vl_api_one_use_petr_t * mp)
     525             : {
     526             :   vl_api_one_use_petr_reply_t *rmp;
     527           0 :   int rv = 0;
     528             :   ip_address_t addr;
     529             : 
     530           0 :   ip_address_decode2 (&mp->ip_address, &addr);
     531             : 
     532           0 :   rv = vnet_lisp_use_petr (&addr, mp->is_add);
     533             : 
     534           0 :   REPLY_MACRO (VL_API_ONE_USE_PETR_REPLY);
     535             : }
     536             : 
     537             : static void
     538           0 : vl_api_show_one_use_petr_t_handler (vl_api_show_one_use_petr_t * mp)
     539             : {
     540           0 :   vl_api_show_one_use_petr_reply_t *rmp = NULL;
     541           0 :   lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
     542             :   mapping_t *m;
     543           0 :   locator_set_t *ls = 0;
     544           0 :   int rv = 0;
     545           0 :   locator_t *loc = 0;
     546           0 :   u8 status = 0;
     547             :   gid_address_t addr;
     548             : 
     549           0 :   clib_memset (&addr, 0, sizeof (addr));
     550           0 :   status = lcm->flags & LISP_FLAG_USE_PETR;
     551           0 :   if (status)
     552             :     {
     553           0 :       m = pool_elt_at_index (lcm->mapping_pool, lcm->petr_map_index);
     554           0 :       if (~0 != m->locator_set_index)
     555             :         {
     556           0 :           ls =
     557           0 :             pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index);
     558           0 :           loc = pool_elt_at_index (lcm->locator_pool, ls->locator_indices[0]);
     559           0 :           gid_address_copy (&addr, &loc->address);
     560             :         }
     561             :     }
     562             : 
     563             :   /* *INDENT-OFF* */
     564           0 :   REPLY_MACRO2 (VL_API_SHOW_ONE_USE_PETR_REPLY,
     565             :   {
     566             :     rmp->status = status;
     567             :     ip_address_t *ip = &gid_address_ip (&addr);
     568             : 
     569             :     ip_address_encode2 (ip, &rmp->ip_address);
     570             :   });
     571             :   /* *INDENT-ON* */
     572             : }
     573             : 
     574             : static void
     575           0 :   vl_api_one_add_del_map_request_itr_rlocs_t_handler
     576             :   (vl_api_one_add_del_map_request_itr_rlocs_t * mp)
     577             : {
     578             :   vl_api_one_add_del_map_request_itr_rlocs_reply_t *rmp;
     579           0 :   int rv = 0;
     580           0 :   u8 *locator_set_name = NULL;
     581           0 :   vnet_lisp_add_del_mreq_itr_rloc_args_t _a, *a = &_a;
     582             : 
     583           0 :   mp->locator_set_name[sizeof (mp->locator_set_name) - 1] = 0;
     584           0 :   locator_set_name = format (0, "%s", mp->locator_set_name);
     585           0 :   vec_terminate_c_string (locator_set_name);
     586             : 
     587           0 :   a->is_add = mp->is_add;
     588           0 :   a->locator_set_name = locator_set_name;
     589             : 
     590           0 :   rv = vnet_lisp_add_del_mreq_itr_rlocs (a);
     591             : 
     592           0 :   vec_free (locator_set_name);
     593             : 
     594           0 :   REPLY_MACRO (VL_API_ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY);
     595             : }
     596             : 
     597             : static void
     598           0 :   vl_api_one_add_del_remote_mapping_t_handler
     599             :   (vl_api_one_add_del_remote_mapping_t * mp)
     600             : {
     601           0 :   locator_t *rlocs = 0;
     602             :   vl_api_one_add_del_remote_mapping_reply_t *rmp;
     603           0 :   int rv = 0;
     604           0 :   gid_address_t _eid, *eid = &_eid;
     605           0 :   u32 rloc_num = clib_net_to_host_u32 (mp->rloc_num);
     606             : 
     607           0 :   clib_memset (eid, 0, sizeof (eid[0]));
     608             : 
     609           0 :   rv = unformat_one_eid_api (eid, clib_net_to_host_u32 (mp->vni), &mp->deid);
     610           0 :   if (rv)
     611           0 :     goto send_reply;
     612             : 
     613           0 :   rlocs = unformat_one_locs (mp->rlocs, rloc_num);
     614             : 
     615           0 :   if (!mp->is_add)
     616             :     {
     617           0 :       vnet_lisp_add_del_adjacency_args_t _a, *a = &_a;
     618           0 :       clib_memset (a, 0, sizeof (a[0]));
     619           0 :       gid_address_copy (&a->reid, eid);
     620           0 :       a->is_add = 0;
     621           0 :       rv = vnet_lisp_add_del_adjacency (a);
     622           0 :       if (rv)
     623             :         {
     624           0 :           goto out;
     625             :         }
     626             :     }
     627             : 
     628             :   /* NOTE: for now this works as a static remote mapping, i.e.,
     629             :    * not authoritative and ttl infinite. */
     630           0 :   if (mp->is_add)
     631             :     {
     632           0 :       vnet_lisp_add_del_mapping_args_t _m_args, *m_args = &_m_args;
     633           0 :       clib_memset (m_args, 0, sizeof (m_args[0]));
     634           0 :       gid_address_copy (&m_args->eid, eid);
     635           0 :       m_args->action = mp->action;
     636           0 :       m_args->is_static = 1;
     637           0 :       m_args->ttl = ~0;
     638           0 :       m_args->authoritative = 0;
     639           0 :       rv = vnet_lisp_add_mapping (m_args, rlocs, NULL, NULL);
     640             :     }
     641             :   else
     642           0 :     rv = vnet_lisp_del_mapping (eid, NULL);
     643             : 
     644           0 :   if (mp->del_all)
     645           0 :     vnet_lisp_clear_all_remote_adjacencies ();
     646             : 
     647           0 : out:
     648           0 :   vec_free (rlocs);
     649           0 : send_reply:
     650           0 :   REPLY_MACRO (VL_API_ONE_ADD_DEL_REMOTE_MAPPING_REPLY);
     651             : }
     652             : 
     653             : static void
     654           0 : vl_api_one_add_del_adjacency_t_handler (vl_api_one_add_del_adjacency_t * mp)
     655             : {
     656             :   vl_api_one_add_del_adjacency_reply_t *rmp;
     657           0 :   vnet_lisp_add_del_adjacency_args_t _a, *a = &_a;
     658             : 
     659           0 :   int rv = 0;
     660           0 :   clib_memset (a, 0, sizeof (a[0]));
     661             : 
     662             :   rv =
     663           0 :     unformat_one_eid_api (&a->leid, clib_net_to_host_u32 (mp->vni),
     664             :                           &mp->leid);
     665           0 :   rv |=
     666           0 :     unformat_one_eid_api (&a->reid, clib_net_to_host_u32 (mp->vni),
     667             :                           &mp->reid);
     668             : 
     669           0 :   if (rv)
     670           0 :     goto send_reply;
     671             : 
     672           0 :   a->is_add = mp->is_add;
     673           0 :   rv = vnet_lisp_add_del_adjacency (a);
     674             : 
     675           0 : send_reply:
     676           0 :   REPLY_MACRO (VL_API_ONE_ADD_DEL_ADJACENCY_REPLY);
     677             : }
     678             : 
     679             : static void
     680           0 : send_one_locator_details (lisp_cp_main_t * lcm,
     681             :                           locator_t * loc, vl_api_registration_t * reg,
     682             :                           u32 context)
     683             : {
     684             :   vl_api_one_locator_details_t *rmp;
     685             : 
     686           0 :   rmp = vl_msg_api_alloc (sizeof (*rmp));
     687           0 :   clib_memset (rmp, 0, sizeof (*rmp));
     688           0 :   rmp->_vl_msg_id = ntohs (VL_API_ONE_LOCATOR_DETAILS);
     689           0 :   rmp->context = context;
     690             : 
     691           0 :   rmp->local = loc->local;
     692           0 :   if (loc->local)
     693             :     {
     694           0 :       rmp->sw_if_index = ntohl (loc->sw_if_index);
     695             :     }
     696             :   else
     697             :     {
     698           0 :       ip_address_encode2 (&loc->address.ippref.addr, &rmp->ip_address);
     699             :     }
     700           0 :   rmp->priority = loc->priority;
     701           0 :   rmp->weight = loc->weight;
     702             : 
     703           0 :   vl_api_send_msg (reg, (u8 *) rmp);
     704           0 : }
     705             : 
     706             : static void
     707           0 : vl_api_one_locator_dump_t_handler (vl_api_one_locator_dump_t * mp)
     708             : {
     709           0 :   u8 *ls_name = 0;
     710             :   vl_api_registration_t *reg;
     711           0 :   lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
     712           0 :   locator_set_t *lsit = 0;
     713           0 :   locator_t *loc = 0;
     714           0 :   u32 ls_index = ~0, *locit = 0;
     715           0 :   uword *p = 0;
     716             : 
     717           0 :   reg = vl_api_client_index_to_registration (mp->client_index);
     718           0 :   if (!reg)
     719           0 :     return;
     720             : 
     721           0 :   if (mp->is_index_set)
     722           0 :     ls_index = htonl (mp->ls_index);
     723             :   else
     724             :     {
     725             :       /* make sure we get a proper C-string */
     726           0 :       mp->ls_name[sizeof (mp->ls_name) - 1] = 0;
     727           0 :       ls_name = format (0, "%s", mp->ls_name);
     728           0 :       vec_terminate_c_string (ls_name);
     729           0 :       p = hash_get_mem (lcm->locator_set_index_by_name, ls_name);
     730           0 :       if (!p)
     731           0 :         goto out;
     732           0 :       ls_index = p[0];
     733             :     }
     734             : 
     735           0 :   if (pool_is_free_index (lcm->locator_set_pool, ls_index))
     736           0 :     return;
     737             : 
     738           0 :   lsit = pool_elt_at_index (lcm->locator_set_pool, ls_index);
     739             : 
     740           0 :   vec_foreach (locit, lsit->locator_indices)
     741             :   {
     742           0 :     loc = pool_elt_at_index (lcm->locator_pool, locit[0]);
     743           0 :     send_one_locator_details (lcm, loc, reg, mp->context);
     744             :   };
     745           0 : out:
     746           0 :   vec_free (ls_name);
     747             : }
     748             : 
     749             : static void
     750           0 : send_one_locator_set_details (lisp_cp_main_t * lcm,
     751             :                               locator_set_t * lsit,
     752             :                               vl_api_registration_t * reg, u32 context,
     753             :                               u32 ls_index)
     754             : {
     755             :   vl_api_one_locator_set_details_t *rmp;
     756           0 :   u8 *str = 0;
     757             : 
     758           0 :   rmp = vl_msg_api_alloc (sizeof (*rmp));
     759           0 :   clib_memset (rmp, 0, sizeof (*rmp));
     760           0 :   rmp->_vl_msg_id = ntohs (VL_API_ONE_LOCATOR_SET_DETAILS);
     761           0 :   rmp->context = context;
     762             : 
     763           0 :   rmp->ls_index = htonl (ls_index);
     764           0 :   if (lsit->local)
     765             :     {
     766           0 :       ASSERT (lsit->name != NULL);
     767           0 :       strncpy ((char *) rmp->ls_name, (char *) lsit->name,
     768           0 :                vec_len (lsit->name));
     769             :     }
     770             :   else
     771             :     {
     772           0 :       str = format (0, "<remote-%d>", ls_index);
     773           0 :       strncpy ((char *) rmp->ls_name, (char *) str, vec_len (str));
     774           0 :       vec_free (str);
     775             :     }
     776             : 
     777           0 :   vl_api_send_msg (reg, (u8 *) rmp);
     778           0 : }
     779             : 
     780             : static void
     781           0 : vl_api_one_locator_set_dump_t_handler (vl_api_one_locator_set_dump_t * mp)
     782             : {
     783             :   vl_api_registration_t *reg;
     784           0 :   lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
     785           0 :   locator_set_t *lsit = NULL;
     786             :   u8 filter;
     787             : 
     788           0 :   reg = vl_api_client_index_to_registration (mp->client_index);
     789           0 :   if (!reg)
     790           0 :     return;
     791             : 
     792           0 :   filter = mp->filter;
     793             :   /* *INDENT-OFF* */
     794           0 :   pool_foreach (lsit, lcm->locator_set_pool)
     795             :    {
     796           0 :     if (filter && !((1 == filter && lsit->local) ||
     797           0 :                     (2 == filter && !lsit->local)))
     798             :       {
     799           0 :         continue;
     800             :       }
     801           0 :     send_one_locator_set_details (lcm, lsit, reg, mp->context,
     802           0 :                                    lsit - lcm->locator_set_pool);
     803             :   }
     804             :   /* *INDENT-ON* */
     805             : }
     806             : 
     807             : static void
     808           0 : send_one_eid_table_details (mapping_t * mapit,
     809             :                             vl_api_registration_t * reg, u32 context,
     810             :                             u8 filter)
     811             : {
     812           0 :   lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
     813           0 :   locator_set_t *ls = 0;
     814           0 :   vl_api_one_eid_table_details_t *rmp = NULL;
     815           0 :   gid_address_t *gid = NULL;
     816             :   u32 eid_type;
     817             :   fib_prefix_t fib_prefix;
     818             : 
     819           0 :   if (mapit->pitr_set || mapit->nsh_set)
     820           0 :     return;
     821             : 
     822           0 :   switch (filter)
     823             :     {
     824           0 :     case ONE_FILTER_API_ALL:    /* all mappings */
     825           0 :       break;
     826             : 
     827           0 :     case ONE_FILTER_API_LOCAL:  /* local only */
     828           0 :       if (!mapit->local)
     829           0 :         return;
     830           0 :       break;
     831           0 :     case ONE_FILTER_API_REMOTE: /* remote only */
     832           0 :       if (mapit->local)
     833           0 :         return;
     834           0 :       break;
     835           0 :     default:
     836           0 :       clib_warning ("Filter error, unknown filter: %d", filter);
     837           0 :       return;
     838             :     }
     839             : 
     840           0 :   gid = &mapit->eid;
     841             : 
     842           0 :   rmp = vl_msg_api_alloc (sizeof (*rmp));
     843           0 :   clib_memset (rmp, 0, sizeof (*rmp));
     844           0 :   rmp->_vl_msg_id = ntohs (VL_API_ONE_EID_TABLE_DETAILS);
     845             : 
     846           0 :   ls = pool_elt_at_index (lcm->locator_set_pool, mapit->locator_set_index);
     847           0 :   if (vec_len (ls->locator_indices) == 0)
     848           0 :     rmp->locator_set_index = ~0;
     849             :   else
     850           0 :     rmp->locator_set_index = clib_host_to_net_u32 (mapit->locator_set_index);
     851             : 
     852           0 :   rmp->is_local = mapit->local;
     853           0 :   rmp->ttl = clib_host_to_net_u32 (mapit->ttl);
     854           0 :   rmp->action = mapit->action;
     855           0 :   rmp->authoritative = mapit->authoritative;
     856             : 
     857           0 :   switch (gid_address_type (gid))
     858             :     {
     859           0 :     case GID_ADDR_SRC_DST:
     860           0 :       fid_to_api_eid (&gid_address_sd_src (gid), &rmp->seid);
     861           0 :       fid_to_api_eid (&gid_address_sd_dst (gid), &rmp->deid);
     862           0 :       break;
     863           0 :     case GID_ADDR_IP_PREFIX:
     864           0 :       eid_type = EID_TYPE_API_PREFIX;
     865           0 :       rmp->seid.type = eid_type;
     866           0 :       ip_prefix_to_fib_prefix (&gid_address_ippref (gid), &fib_prefix);
     867           0 :       ip_prefix_encode (&fib_prefix, &rmp->seid.address.prefix);
     868           0 :       break;
     869           0 :     case GID_ADDR_MAC:
     870           0 :       eid_type = EID_TYPE_API_MAC;
     871           0 :       rmp->seid.type = eid_type;
     872           0 :       mac_address_encode ((mac_address_t *) gid_address_mac (gid),
     873           0 :                           rmp->seid.address.mac);
     874           0 :       break;
     875           0 :     case GID_ADDR_NSH:
     876           0 :       eid_type = EID_TYPE_API_NSH;
     877           0 :       rmp->seid.type = eid_type;
     878           0 :       rmp->seid.address.nsh.spi =
     879           0 :         clib_host_to_net_u32 (gid_address_nsh_spi (gid));
     880           0 :       rmp->seid.address.nsh.si = gid_address_nsh_si (gid);
     881           0 :       break;
     882           0 :     default:
     883             :       /* unknown type */
     884           0 :       return;
     885             :     }
     886             : 
     887           0 :   rmp->context = context;
     888           0 :   rmp->vni = clib_host_to_net_u32 (gid_address_vni (gid));
     889           0 :   rmp->key.id = mapit->key_id;
     890           0 :   memcpy (rmp->key.key, mapit->key, vec_len (mapit->key));
     891           0 :   vl_api_send_msg (reg, (u8 *) rmp);
     892             : }
     893             : 
     894             : static void
     895           0 : vl_api_one_eid_table_dump_t_handler (vl_api_one_eid_table_dump_t * mp)
     896             : {
     897             :   u32 mi;
     898             :   vl_api_registration_t *reg;
     899           0 :   lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
     900           0 :   mapping_t *mapit = NULL;
     901           0 :   gid_address_t _eid, *eid = &_eid;
     902             : 
     903           0 :   reg = vl_api_client_index_to_registration (mp->client_index);
     904           0 :   if (!reg)
     905           0 :     return;
     906             : 
     907           0 :   if (mp->eid_set)
     908             :     {
     909           0 :       clib_memset (eid, 0, sizeof (*eid));
     910             : 
     911           0 :       unformat_one_eid_api (eid, clib_net_to_host_u32 (mp->vni), &mp->eid);
     912             : 
     913           0 :       mi = gid_dictionary_lookup (&lcm->mapping_index_by_gid, eid);
     914           0 :       if ((u32) ~ 0 == mi)
     915           0 :         return;
     916             : 
     917           0 :       mapit = pool_elt_at_index (lcm->mapping_pool, mi);
     918           0 :       send_one_eid_table_details (mapit, reg, mp->context,
     919             :                                   0 /* ignore filter */ );
     920             :     }
     921             :   else
     922             :     {
     923             :       /* *INDENT-OFF* */
     924           0 :       pool_foreach (mapit, lcm->mapping_pool)
     925             :        {
     926           0 :         send_one_eid_table_details(mapit, reg, mp->context,
     927           0 :                                     mp->filter);
     928             :       }
     929             :       /* *INDENT-ON* */
     930             :     }
     931             : }
     932             : 
     933             : static void
     934           0 : send_one_map_server_details (ip_address_t * ip, vl_api_registration_t * reg,
     935             :                              u32 context)
     936             : {
     937           0 :   vl_api_one_map_server_details_t *rmp = NULL;
     938             : 
     939           0 :   rmp = vl_msg_api_alloc (sizeof (*rmp));
     940           0 :   clib_memset (rmp, 0, sizeof (*rmp));
     941           0 :   rmp->_vl_msg_id = ntohs (VL_API_ONE_MAP_SERVER_DETAILS);
     942             : 
     943             : 
     944           0 :   ip_address_encode2 (ip, &rmp->ip_address);
     945             : 
     946           0 :   rmp->context = context;
     947             : 
     948           0 :   vl_api_send_msg (reg, (u8 *) rmp);
     949           0 : }
     950             : 
     951             : static void
     952           0 : vl_api_one_map_server_dump_t_handler (vl_api_one_map_server_dump_t * mp)
     953             : {
     954             :   vl_api_registration_t *reg;
     955           0 :   lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
     956             :   lisp_msmr_t *mr;
     957             : 
     958           0 :   reg = vl_api_client_index_to_registration (mp->client_index);
     959           0 :   if (!reg)
     960           0 :     return;
     961             : 
     962           0 :   vec_foreach (mr, lcm->map_servers)
     963             :   {
     964           0 :     send_one_map_server_details (&mr->address, reg, mp->context);
     965             :   }
     966             : }
     967             : 
     968             : static void
     969           0 : send_one_map_resolver_details (ip_address_t * ip,
     970             :                                vl_api_registration_t * reg, u32 context)
     971             : {
     972           0 :   vl_api_one_map_resolver_details_t *rmp = NULL;
     973             : 
     974           0 :   rmp = vl_msg_api_alloc (sizeof (*rmp));
     975           0 :   clib_memset (rmp, 0, sizeof (*rmp));
     976           0 :   rmp->_vl_msg_id = ntohs (VL_API_ONE_MAP_RESOLVER_DETAILS);
     977             : 
     978           0 :   ip_address_encode2 (ip, &rmp->ip_address);
     979           0 :   rmp->context = context;
     980             : 
     981           0 :   vl_api_send_msg (reg, (u8 *) rmp);
     982           0 : }
     983             : 
     984             : static void
     985           0 : vl_api_one_map_resolver_dump_t_handler (vl_api_one_map_resolver_dump_t * mp)
     986             : {
     987             :   vl_api_registration_t *reg;
     988           0 :   lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
     989             :   lisp_msmr_t *mr;
     990             : 
     991           0 :   reg = vl_api_client_index_to_registration (mp->client_index);
     992           0 :   if (!reg)
     993           0 :     return;
     994             : 
     995           0 :   vec_foreach (mr, lcm->map_resolvers)
     996             :   {
     997           0 :     send_one_map_resolver_details (&mr->address, reg, mp->context);
     998             :   }
     999             : }
    1000             : 
    1001             : static void
    1002           0 : send_eid_table_map_pair (hash_pair_t * p, vl_api_registration_t * reg,
    1003             :                          u32 context)
    1004             : {
    1005           0 :   vl_api_one_eid_table_map_details_t *rmp = NULL;
    1006             : 
    1007           0 :   rmp = vl_msg_api_alloc (sizeof (*rmp));
    1008           0 :   clib_memset (rmp, 0, sizeof (*rmp));
    1009           0 :   rmp->_vl_msg_id = ntohs (VL_API_ONE_EID_TABLE_MAP_DETAILS);
    1010             : 
    1011           0 :   rmp->vni = clib_host_to_net_u32 (p->key);
    1012           0 :   rmp->dp_table = clib_host_to_net_u32 (p->value[0]);
    1013           0 :   rmp->context = context;
    1014           0 :   vl_api_send_msg (reg, (u8 *) rmp);
    1015           0 : }
    1016             : 
    1017             : static void
    1018           0 : vl_api_one_eid_table_map_dump_t_handler (vl_api_one_eid_table_map_dump_t * mp)
    1019             : {
    1020             :   vl_api_registration_t *reg;
    1021           0 :   lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
    1022             :   hash_pair_t *p;
    1023           0 :   uword *vni_table = 0;
    1024             : 
    1025           0 :   reg = vl_api_client_index_to_registration (mp->client_index);
    1026           0 :   if (!reg)
    1027           0 :     return;
    1028             : 
    1029           0 :   if (mp->is_l2)
    1030             :     {
    1031           0 :       vni_table = lcm->bd_id_by_vni;
    1032             :     }
    1033             :   else
    1034             :     {
    1035           0 :       vni_table = lcm->table_id_by_vni;
    1036             :     }
    1037             : 
    1038             :   /* *INDENT-OFF* */
    1039           0 :   hash_foreach_pair (p, vni_table,
    1040             :   ({
    1041             :     send_eid_table_map_pair (p, reg, mp->context);
    1042             :   }));
    1043             :   /* *INDENT-ON* */
    1044             : }
    1045             : 
    1046             : static void
    1047           0 : send_eid_table_vni (u32 vni, vl_api_registration_t * reg, u32 context)
    1048             : {
    1049           0 :   vl_api_one_eid_table_vni_details_t *rmp = 0;
    1050             : 
    1051           0 :   rmp = vl_msg_api_alloc (sizeof (*rmp));
    1052           0 :   clib_memset (rmp, 0, sizeof (*rmp));
    1053           0 :   rmp->_vl_msg_id = ntohs (VL_API_ONE_EID_TABLE_VNI_DETAILS);
    1054           0 :   rmp->context = context;
    1055           0 :   rmp->vni = clib_host_to_net_u32 (vni);
    1056           0 :   vl_api_send_msg (reg, (u8 *) rmp);
    1057           0 : }
    1058             : 
    1059             : static void
    1060           0 : one_adjacency_copy (vl_api_one_adjacency_t * dst, lisp_adjacency_t * adjs)
    1061             : {
    1062             :   lisp_adjacency_t *adj;
    1063             :   vl_api_one_adjacency_t a;
    1064           0 :   u32 i, n = vec_len (adjs);
    1065             :   fib_prefix_t rfib_prefix, lfib_prefix;
    1066             :   u32 eid_type;
    1067             : 
    1068           0 :   for (i = 0; i < n; i++)
    1069             :     {
    1070           0 :       adj = vec_elt_at_index (adjs, i);
    1071           0 :       clib_memset (&a, 0, sizeof (a));
    1072             : 
    1073           0 :       switch (gid_address_type (&adj->reid))
    1074             :         {
    1075           0 :         case GID_ADDR_IP_PREFIX:
    1076           0 :           eid_type = EID_TYPE_API_PREFIX;
    1077           0 :           ip_prefix_to_fib_prefix (&gid_address_ippref (&adj->reid),
    1078             :                                    &rfib_prefix);
    1079           0 :           ip_prefix_to_fib_prefix (&gid_address_ippref (&adj->leid),
    1080             :                                    &lfib_prefix);
    1081           0 :           ip_prefix_encode (&rfib_prefix, &a.reid.address.prefix);
    1082           0 :           ip_prefix_encode (&lfib_prefix, &a.leid.address.prefix);
    1083           0 :           break;
    1084           0 :         case GID_ADDR_MAC:
    1085           0 :           eid_type = EID_TYPE_API_PREFIX;
    1086           0 :           mac_address_encode ((mac_address_t *) gid_address_mac (&adj->reid),
    1087             :                               a.reid.address.mac);
    1088           0 :           mac_address_encode ((mac_address_t *) gid_address_mac (&adj->leid),
    1089             :                               a.leid.address.mac);
    1090           0 :           break;
    1091           0 :         case GID_ADDR_NSH:
    1092           0 :           eid_type = EID_TYPE_API_PREFIX;
    1093           0 :           a.reid.address.nsh.spi =
    1094           0 :             clib_host_to_net_u32 (gid_address_nsh_spi (&adj->reid));
    1095           0 :           a.reid.address.nsh.si = gid_address_nsh_si (&adj->reid);
    1096           0 :           a.leid.address.nsh.spi =
    1097           0 :             clib_host_to_net_u32 (gid_address_nsh_spi (&adj->leid));
    1098           0 :           a.leid.address.nsh.si = gid_address_nsh_si (&adj->leid);
    1099           0 :           break;
    1100           0 :         default:
    1101           0 :           ALWAYS_ASSERT (0);
    1102             :         }
    1103           0 :       a.reid.type = eid_type;
    1104           0 :       a.leid.type = eid_type;
    1105           0 :       dst[i] = a;
    1106             :     }
    1107           0 : }
    1108             : 
    1109             : static void
    1110           0 :   vl_api_show_one_rloc_probe_state_t_handler
    1111             :   (vl_api_show_one_rloc_probe_state_t * mp)
    1112             : {
    1113           0 :   vl_api_show_one_rloc_probe_state_reply_t *rmp = 0;
    1114           0 :   int rv = 0;
    1115             : 
    1116             :   /* *INDENT-OFF* */
    1117           0 :   REPLY_MACRO2 (VL_API_SHOW_ONE_RLOC_PROBE_STATE_REPLY,
    1118             :   {
    1119             :     rmp->is_enable = vnet_lisp_rloc_probe_state_get ();
    1120             :   });
    1121             :   /* *INDENT-ON* */
    1122             : }
    1123             : 
    1124             : static void
    1125           0 :   vl_api_show_one_map_register_state_t_handler
    1126             :   (vl_api_show_one_map_register_state_t * mp)
    1127             : {
    1128           0 :   vl_api_show_one_map_register_state_reply_t *rmp = 0;
    1129           0 :   int rv = 0;
    1130             : 
    1131             :   /* *INDENT-OFF* */
    1132           0 :   REPLY_MACRO2 (VL_API_SHOW_ONE_MAP_REGISTER_STATE_REPLY,
    1133             :   {
    1134             :     rmp->is_enable = vnet_lisp_map_register_state_get ();
    1135             :   });
    1136             :   /* *INDENT-ON* */
    1137             : }
    1138             : 
    1139             : static void
    1140           0 : vl_api_one_adjacencies_get_t_handler (vl_api_one_adjacencies_get_t * mp)
    1141             : {
    1142           0 :   vl_api_one_adjacencies_get_reply_t *rmp = 0;
    1143           0 :   lisp_adjacency_t *adjs = 0;
    1144           0 :   int rv = 0;
    1145           0 :   u32 size = ~0;
    1146           0 :   u32 vni = clib_net_to_host_u32 (mp->vni);
    1147             : 
    1148           0 :   adjs = vnet_lisp_adjacencies_get_by_vni (vni);
    1149           0 :   size = vec_len (adjs) * sizeof (vl_api_one_adjacency_t);
    1150             : 
    1151             :   /* *INDENT-OFF* */
    1152           0 :   REPLY_MACRO4 (VL_API_ONE_ADJACENCIES_GET_REPLY, size,
    1153             :   {
    1154             :     rmp->count = clib_host_to_net_u32 (vec_len (adjs));
    1155             :     one_adjacency_copy (rmp->adjacencies, adjs);
    1156             :   });
    1157             :   /* *INDENT-ON* */
    1158             : 
    1159           0 :   vec_free (adjs);
    1160             : }
    1161             : 
    1162             : static void
    1163           0 : vl_api_one_eid_table_vni_dump_t_handler (vl_api_one_eid_table_vni_dump_t * mp)
    1164             : {
    1165             :   hash_pair_t *p;
    1166           0 :   u32 *vnis = 0;
    1167             :   vl_api_registration_t *reg;
    1168           0 :   lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
    1169             : 
    1170           0 :   reg = vl_api_client_index_to_registration (mp->client_index);
    1171           0 :   if (!reg)
    1172           0 :     return;
    1173             : 
    1174             :   /* *INDENT-OFF* */
    1175           0 :   hash_foreach_pair (p, lcm->table_id_by_vni,
    1176             :   ({
    1177             :     hash_set (vnis, p->key, 0);
    1178             :   }));
    1179             : 
    1180           0 :   hash_foreach_pair (p, lcm->bd_id_by_vni,
    1181             :   ({
    1182             :     hash_set (vnis, p->key, 0);
    1183             :   }));
    1184             : 
    1185           0 :   hash_foreach_pair (p, vnis,
    1186             :   ({
    1187             :     send_eid_table_vni (p->key, reg, mp->context);
    1188             :   }));
    1189             :   /* *INDENT-ON* */
    1190             : 
    1191           0 :   hash_free (vnis);
    1192             : }
    1193             : 
    1194             : static void
    1195           0 : vl_api_show_one_status_t_handler (vl_api_show_one_status_t * mp)
    1196             : {
    1197           0 :   vl_api_show_one_status_reply_t *rmp = NULL;
    1198           0 :   int rv = 0;
    1199             : 
    1200             :   /* *INDENT-OFF* */
    1201           0 :   REPLY_MACRO2(VL_API_SHOW_ONE_STATUS_REPLY,
    1202             :   ({
    1203             :     rmp->gpe_status = vnet_lisp_gpe_enable_disable_status ();
    1204             :     rmp->feature_status = vnet_lisp_enable_disable_status ();
    1205             :   }));
    1206             :   /* *INDENT-ON* */
    1207             : }
    1208             : 
    1209             : static void
    1210           0 :   vl_api_one_get_map_request_itr_rlocs_t_handler
    1211             :   (vl_api_one_get_map_request_itr_rlocs_t * mp)
    1212             : {
    1213           0 :   vl_api_one_get_map_request_itr_rlocs_reply_t *rmp = NULL;
    1214           0 :   lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
    1215           0 :   locator_set_t *loc_set = 0;
    1216           0 :   u8 *tmp_str = 0;
    1217           0 :   int rv = 0;
    1218             : 
    1219           0 :   if (~0 == lcm->mreq_itr_rlocs)
    1220             :     {
    1221           0 :       tmp_str = format (0, " ");
    1222             :     }
    1223             :   else
    1224             :     {
    1225           0 :       loc_set =
    1226           0 :         pool_elt_at_index (lcm->locator_set_pool, lcm->mreq_itr_rlocs);
    1227           0 :       tmp_str = format (0, "%s", loc_set->name);
    1228             :     }
    1229             : 
    1230             :   /* *INDENT-OFF* */
    1231           0 :   REPLY_MACRO2(VL_API_ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY,
    1232             :   ({
    1233             :     strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
    1234             :             ARRAY_LEN(rmp->locator_set_name) - 1);
    1235             :   }));
    1236             :   /* *INDENT-ON* */
    1237             : 
    1238           0 :   vec_free (tmp_str);
    1239             : }
    1240             : 
    1241             : static void
    1242           0 : vl_api_show_one_nsh_mapping_t_handler (vl_api_show_one_nsh_mapping_t * mp)
    1243             : {
    1244           0 :   vl_api_show_one_nsh_mapping_reply_t *rmp = NULL;
    1245           0 :   lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
    1246             :   mapping_t *m;
    1247           0 :   locator_set_t *ls = 0;
    1248           0 :   u8 *tmp_str = 0;
    1249           0 :   u8 is_set = 0;
    1250           0 :   int rv = 0;
    1251             : 
    1252           0 :   if (lcm->nsh_map_index == (u32) ~ 0)
    1253             :     {
    1254           0 :       tmp_str = format (0, "N/A");
    1255             :     }
    1256             :   else
    1257             :     {
    1258           0 :       m = pool_elt_at_index (lcm->mapping_pool, lcm->nsh_map_index);
    1259           0 :       if (~0 != m->locator_set_index)
    1260             :         {
    1261           0 :           ls =
    1262           0 :             pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index);
    1263           0 :           tmp_str = format (0, "%s", ls->name);
    1264           0 :           is_set = 1;
    1265             :         }
    1266             :       else
    1267             :         {
    1268           0 :           tmp_str = format (0, "N/A");
    1269             :         }
    1270             :     }
    1271           0 :   vec_add1 (tmp_str, 0);
    1272             : 
    1273             :   /* *INDENT-OFF* */
    1274           0 :   REPLY_MACRO2(VL_API_SHOW_ONE_NSH_MAPPING_REPLY,
    1275             :   ({
    1276             :     rmp->is_set = is_set;
    1277             :     strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
    1278             :             ARRAY_LEN(rmp->locator_set_name) - 1);
    1279             :   }));
    1280             :   /* *INDENT-ON* */
    1281             : }
    1282             : 
    1283             : static void
    1284           0 : vl_api_show_one_pitr_t_handler (vl_api_show_one_pitr_t * mp)
    1285             : {
    1286           0 :   vl_api_show_one_pitr_reply_t *rmp = NULL;
    1287           0 :   lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
    1288             :   mapping_t *m;
    1289           0 :   locator_set_t *ls = 0;
    1290           0 :   u8 *tmp_str = 0;
    1291           0 :   int rv = 0;
    1292             : 
    1293           0 :   u8 is_enable = (lcm->flags & LISP_FLAG_PITR_MODE)
    1294           0 :     && lcm->pitr_map_index != ~0;
    1295             : 
    1296           0 :   if (!is_enable)
    1297             :     {
    1298           0 :       tmp_str = format (0, "N/A");
    1299             :     }
    1300             :   else
    1301             :     {
    1302           0 :       m = pool_elt_at_index (lcm->mapping_pool, lcm->pitr_map_index);
    1303           0 :       if (~0 != m->locator_set_index)
    1304             :         {
    1305           0 :           ls =
    1306           0 :             pool_elt_at_index (lcm->locator_set_pool, m->locator_set_index);
    1307           0 :           tmp_str = format (0, "%s", ls->name);
    1308             :         }
    1309             :       else
    1310             :         {
    1311           0 :           tmp_str = format (0, "N/A");
    1312             :         }
    1313             :     }
    1314           0 :   vec_add1 (tmp_str, 0);
    1315             : 
    1316             :   /* *INDENT-OFF* */
    1317           0 :   REPLY_MACRO2(VL_API_SHOW_ONE_PITR_REPLY,
    1318             :   ({
    1319             :     rmp->status = lcm->flags & LISP_FLAG_PITR_MODE;
    1320             :     strncpy((char *) rmp->locator_set_name, (char *) tmp_str,
    1321             :             ARRAY_LEN(rmp->locator_set_name) - 1);
    1322             :   }));
    1323             :   /* *INDENT-ON* */
    1324             : }
    1325             : 
    1326             : static void
    1327           0 :   vl_api_show_one_stats_enable_disable_t_handler
    1328             :   (vl_api_show_one_stats_enable_disable_t * mp)
    1329             : {
    1330           0 :   vl_api_show_one_stats_enable_disable_reply_t *rmp = NULL;
    1331           0 :   vnet_api_error_t rv = 0;
    1332             : 
    1333             :   /* *INDENT-OFF* */
    1334           0 :   REPLY_MACRO2 (VL_API_SHOW_ONE_STATS_ENABLE_DISABLE_REPLY,
    1335             :   ({
    1336             :     rmp->is_enable = vnet_lisp_stats_enable_disable_state ();
    1337             :   }));
    1338             :   /* *INDENT-ON* */
    1339             : }
    1340             : 
    1341             : static void
    1342           0 :   vl_api_one_stats_enable_disable_t_handler
    1343             :   (vl_api_one_stats_enable_disable_t * mp)
    1344             : {
    1345           0 :   vl_api_one_enable_disable_reply_t *rmp = NULL;
    1346             : 
    1347           0 :   vnet_api_error_t rv = vnet_lisp_stats_enable_disable (mp->is_enable);
    1348           0 :   REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_REPLY);
    1349             : }
    1350             : 
    1351             : static void
    1352           0 : vl_api_one_stats_flush_t_handler (vl_api_one_stats_flush_t * mp)
    1353             : {
    1354             :   vl_api_one_stats_flush_reply_t *rmp;
    1355             :   u8 rv;
    1356             : 
    1357           0 :   rv = vnet_lisp_flush_stats ();
    1358           0 :   REPLY_MACRO (VL_API_ONE_STATS_FLUSH_REPLY);
    1359             : }
    1360             : 
    1361             : static void
    1362           0 : vl_api_one_stats_dump_t_handler (vl_api_one_stats_dump_t * mp)
    1363             : {
    1364             :   vl_api_one_stats_details_t *rmp;
    1365             :   lisp_api_stats_t *stats, *stat;
    1366           0 :   u8 rv = 0;
    1367             : 
    1368           0 :   stats = vnet_lisp_get_stats ();
    1369           0 :   vec_foreach (stat, stats)
    1370             :   {
    1371             :       /* *INDENT-OFF* */
    1372           0 :       REPLY_DETAILS (VL_API_ONE_STATS_DETAILS,
    1373             :       ({
    1374             :         fid_to_api_eid (&stat->deid, &rmp->deid);
    1375             :         fid_to_api_eid (&stat->seid, &rmp->seid);
    1376             :         rmp->vni = clib_host_to_net_u32 (stat->vni);
    1377             : 
    1378             :         ip_address_encode2 (&stat->rmt_rloc, &rmp->rloc);
    1379             :         ip_address_encode2 (&stat->loc_rloc, &rmp->lloc);
    1380             : 
    1381             :         rmp->pkt_count = clib_host_to_net_u32 (stat->counters.packets);
    1382             :         rmp->bytes = clib_host_to_net_u32 (stat->counters.bytes);
    1383             :       }));
    1384             :       /* *INDENT-ON* */
    1385             :   }
    1386             : }
    1387             : 
    1388             : static void
    1389           0 :   vl_api_one_add_del_l2_arp_entry_t_handler
    1390             :   (vl_api_one_add_del_l2_arp_entry_t * mp)
    1391             : {
    1392             :   vl_api_one_add_del_l2_arp_entry_reply_t *rmp;
    1393           0 :   int rv = 0;
    1394           0 :   gid_address_t _arp, *arp = &_arp;
    1395             :   ip4_address_t ip4;
    1396             :   mac_address_t mac;
    1397           0 :   clib_memset (arp, 0, sizeof (*arp));
    1398             : 
    1399           0 :   gid_address_type (arp) = GID_ADDR_ARP;
    1400           0 :   gid_address_arp_bd (arp) = clib_net_to_host_u32 (mp->bd);
    1401             : 
    1402           0 :   ip4_address_decode (mp->entry.ip4, &ip4);
    1403           0 :   ip_address_set (&gid_address_arp_ndp_ip (arp), &ip4, AF_IP4);
    1404           0 :   mac_address_decode (mp->entry.mac, &mac);
    1405             : 
    1406           0 :   rv = vnet_lisp_add_del_l2_arp_ndp_entry (arp, mac.bytes, mp->is_add);
    1407             : 
    1408           0 :   REPLY_MACRO (VL_API_ONE_ADD_DEL_L2_ARP_ENTRY_REPLY);
    1409             : }
    1410             : 
    1411             : static void
    1412           0 : vl_api_one_add_del_ndp_entry_t_handler (vl_api_one_add_del_ndp_entry_t * mp)
    1413             : {
    1414             :   vl_api_one_add_del_ndp_entry_reply_t *rmp;
    1415           0 :   int rv = 0;
    1416           0 :   gid_address_t _g, *g = &_g;
    1417             :   ip6_address_t ip6;
    1418             :   mac_address_t mac;
    1419           0 :   clib_memset (g, 0, sizeof (*g));
    1420             : 
    1421           0 :   gid_address_type (g) = GID_ADDR_NDP;
    1422           0 :   gid_address_ndp_bd (g) = clib_net_to_host_u32 (mp->bd);
    1423             : 
    1424           0 :   ip6_address_decode (mp->entry.ip6, &ip6);
    1425           0 :   ip_address_set (&gid_address_arp_ndp_ip (g), &ip6, AF_IP6);
    1426           0 :   mac_address_decode (mp->entry.mac, &mac);
    1427             : 
    1428           0 :   rv = vnet_lisp_add_del_l2_arp_ndp_entry (g, mac.bytes, mp->is_add);
    1429             : 
    1430           0 :   REPLY_MACRO (VL_API_ONE_ADD_DEL_NDP_ENTRY_REPLY);
    1431             : }
    1432             : 
    1433             : static void
    1434           0 : vl_api_one_ndp_bd_get_t_handler (vl_api_one_ndp_bd_get_t * mp)
    1435             : {
    1436             :   vl_api_one_ndp_bd_get_reply_t *rmp;
    1437           0 :   int rv = 0;
    1438           0 :   u32 i = 0;
    1439             :   hash_pair_t *p;
    1440             : 
    1441           0 :   u32 *bds = vnet_lisp_ndp_bds_get ();
    1442           0 :   u32 size = hash_elts (bds) * sizeof (u32);
    1443             : 
    1444             :   /* *INDENT-OFF* */
    1445           0 :   REPLY_MACRO4 (VL_API_ONE_NDP_BD_GET_REPLY, size,
    1446             :   {
    1447             :     rmp->count = clib_host_to_net_u32 (hash_elts (bds));
    1448             :     hash_foreach_pair (p, bds,
    1449             :     ({
    1450             :       rmp->bridge_domains[i++] = clib_host_to_net_u32 (p->key);
    1451             :     }));
    1452             :   });
    1453             :   /* *INDENT-ON* */
    1454             : 
    1455           0 :   hash_free (bds);
    1456             : }
    1457             : 
    1458             : static void
    1459           0 : vl_api_one_l2_arp_bd_get_t_handler (vl_api_one_l2_arp_bd_get_t * mp)
    1460             : {
    1461             :   vl_api_one_l2_arp_bd_get_reply_t *rmp;
    1462           0 :   int rv = 0;
    1463           0 :   u32 i = 0;
    1464             :   hash_pair_t *p;
    1465             : 
    1466           0 :   u32 *bds = vnet_lisp_l2_arp_bds_get ();
    1467           0 :   u32 size = hash_elts (bds) * sizeof (u32);
    1468             : 
    1469             :   /* *INDENT-OFF* */
    1470           0 :   REPLY_MACRO4 (VL_API_ONE_L2_ARP_BD_GET_REPLY, size,
    1471             :   {
    1472             :     rmp->count = clib_host_to_net_u32 (hash_elts (bds));
    1473             :     hash_foreach_pair (p, bds,
    1474             :     ({
    1475             :       rmp->bridge_domains[i++] = clib_host_to_net_u32 (p->key);
    1476             :     }));
    1477             :   });
    1478             :   /* *INDENT-ON* */
    1479             : 
    1480           0 :   hash_free (bds);
    1481             : }
    1482             : 
    1483             : static void
    1484           0 : vl_api_one_l2_arp_entries_get_t_handler (vl_api_one_l2_arp_entries_get_t * mp)
    1485             : {
    1486             :   vl_api_one_l2_arp_entries_get_reply_t *rmp;
    1487           0 :   lisp_api_l2_arp_entry_t *entries = 0, *e;
    1488           0 :   u32 i = 0;
    1489           0 :   int rv = 0;
    1490             : 
    1491           0 :   u32 bd = clib_net_to_host_u32 (mp->bd);
    1492             : 
    1493           0 :   entries = vnet_lisp_l2_arp_entries_get_by_bd (bd);
    1494           0 :   u32 size = vec_len (entries) * sizeof (vl_api_one_l2_arp_entry_t);
    1495             : 
    1496             :   /* *INDENT-OFF* */
    1497           0 :   REPLY_MACRO4 (VL_API_ONE_L2_ARP_ENTRIES_GET_REPLY, size,
    1498             :   {
    1499             :     rmp->count = clib_host_to_net_u32 (vec_len (entries));
    1500             :     vec_foreach (e, entries)
    1501             :       {
    1502             :         mac_address_encode ((mac_address_t *) e->mac, rmp->entries[i].mac);
    1503             :         ip4_address_encode ((ip4_address_t *) &e->ip4, rmp->entries[i].ip4);
    1504             :         i++;
    1505             :       }
    1506             :   });
    1507             :   /* *INDENT-ON* */
    1508             : 
    1509           0 :   vec_free (entries);
    1510             : }
    1511             : 
    1512             : static void
    1513           0 :   vl_api_one_map_register_fallback_threshold_t_handler
    1514             :   (vl_api_one_map_register_fallback_threshold_t * mp)
    1515             : {
    1516             :   vl_api_one_map_register_fallback_threshold_reply_t *rmp;
    1517           0 :   int rv = 0;
    1518             : 
    1519           0 :   mp->value = clib_net_to_host_u32 (mp->value);
    1520           0 :   rv = vnet_lisp_map_register_fallback_threshold_set (mp->value);
    1521           0 :   REPLY_MACRO (VL_API_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY);
    1522             : }
    1523             : 
    1524             : static void
    1525           0 :   vl_api_show_one_map_register_fallback_threshold_t_handler
    1526             :   (vl_api_show_one_map_register_fallback_threshold_t * mp)
    1527             : {
    1528             :   vl_api_show_one_map_register_fallback_threshold_reply_t *rmp;
    1529           0 :   int rv = 0;
    1530             : 
    1531           0 :   u32 value = vnet_lisp_map_register_fallback_threshold_get ();
    1532             : 
    1533             :   /* *INDENT-OFF* */
    1534           0 :   REPLY_MACRO2 (VL_API_SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY,
    1535             :   ({
    1536             :     rmp->value = clib_host_to_net_u32 (value);
    1537             :   }));
    1538             :   /* *INDENT-ON* */
    1539             : }
    1540             : 
    1541             : static void
    1542           0 :   vl_api_one_set_transport_protocol_t_handler
    1543             :   (vl_api_one_set_transport_protocol_t * mp)
    1544             : {
    1545             :   vl_api_one_set_transport_protocol_reply_t *rmp;
    1546           0 :   int rv = 0;
    1547             : 
    1548           0 :   rv = vnet_lisp_set_transport_protocol (mp->protocol);
    1549             : 
    1550           0 :   REPLY_MACRO (VL_API_ONE_SET_TRANSPORT_PROTOCOL_REPLY);
    1551             : }
    1552             : 
    1553             : static void
    1554           0 :   vl_api_one_get_transport_protocol_t_handler
    1555             :   (vl_api_one_get_transport_protocol_t * mp)
    1556             : {
    1557             :   vl_api_one_get_transport_protocol_reply_t *rmp;
    1558           0 :   int rv = 0;
    1559           0 :   u8 proto = (u8) vnet_lisp_get_transport_protocol ();
    1560             : 
    1561             :   /* *INDENT-OFF* */
    1562           0 :   REPLY_MACRO2 (VL_API_ONE_GET_TRANSPORT_PROTOCOL_REPLY,
    1563             :   ({
    1564             :     rmp->protocol = proto;
    1565             :   }));
    1566             :   /* *INDENT-ON* */
    1567             : }
    1568             : 
    1569             : static void
    1570           0 : vl_api_one_ndp_entries_get_t_handler (vl_api_one_ndp_entries_get_t * mp)
    1571             : {
    1572           0 :   vl_api_one_ndp_entries_get_reply_t *rmp = 0;
    1573           0 :   lisp_api_ndp_entry_t *entries = 0, *e;
    1574           0 :   u32 i = 0;
    1575           0 :   int rv = 0;
    1576             : 
    1577           0 :   u32 bd = clib_net_to_host_u32 (mp->bd);
    1578             : 
    1579           0 :   entries = vnet_lisp_ndp_entries_get_by_bd (bd);
    1580           0 :   u32 size = vec_len (entries) * sizeof (vl_api_one_ndp_entry_t);
    1581             : 
    1582             :   /* *INDENT-OFF* */
    1583           0 :   REPLY_MACRO4 (VL_API_ONE_NDP_ENTRIES_GET_REPLY, size,
    1584             :   {
    1585             :     rmp->count = clib_host_to_net_u32 (vec_len (entries));
    1586             :     vec_foreach (e, entries)
    1587             :       {
    1588             :         mac_address_encode ((mac_address_t *) e->mac, rmp->entries[i].mac);
    1589             :         ip6_address_encode ((ip6_address_t *) &e->ip6, rmp->entries[i].ip6);
    1590             :         i++;
    1591             :       }
    1592             :   });
    1593             :   /* *INDENT-ON* */
    1594             : 
    1595           0 :   vec_free (entries);
    1596             : }
    1597             : 
    1598             : static void
    1599           0 :   vl_api_one_enable_disable_xtr_mode_t_handler
    1600             :   (vl_api_one_enable_disable_xtr_mode_t * mp)
    1601             : {
    1602           0 :   vl_api_one_enable_disable_xtr_mode_reply_t *rmp = 0;
    1603           0 :   int rv = vnet_lisp_enable_disable_xtr_mode (mp->is_enable);
    1604             : 
    1605           0 :   REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_XTR_MODE_REPLY);
    1606             : }
    1607             : 
    1608             : static void
    1609           0 : vl_api_one_show_xtr_mode_t_handler (vl_api_one_show_xtr_mode_t * mp)
    1610             : {
    1611           0 :   vl_api_one_show_xtr_mode_reply_t *rmp = 0;
    1612           0 :   int rv = 0;
    1613             : 
    1614             :   /* *INDENT-OFF* */
    1615           0 :   REPLY_MACRO2 (VL_API_ONE_SHOW_XTR_MODE_REPLY,
    1616             :   {
    1617             :     rmp->is_enable = vnet_lisp_get_xtr_mode ();
    1618             :   });
    1619             :   /* *INDENT-ON* */
    1620             : }
    1621             : 
    1622             : static void
    1623           0 :   vl_api_one_enable_disable_pitr_mode_t_handler
    1624             :   (vl_api_one_enable_disable_pitr_mode_t * mp)
    1625             : {
    1626           0 :   vl_api_one_enable_disable_pitr_mode_reply_t *rmp = 0;
    1627           0 :   int rv = vnet_lisp_enable_disable_pitr_mode (mp->is_enable);
    1628             : 
    1629           0 :   REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_PITR_MODE_REPLY);
    1630             : }
    1631             : 
    1632             : static void
    1633           0 : vl_api_one_show_pitr_mode_t_handler (vl_api_one_show_pitr_mode_t * mp)
    1634             : {
    1635           0 :   vl_api_one_show_pitr_mode_reply_t *rmp = 0;
    1636           0 :   int rv = 0;
    1637             : 
    1638             :   /* *INDENT-OFF* */
    1639           0 :   REPLY_MACRO2 (VL_API_ONE_SHOW_PITR_MODE_REPLY,
    1640             :   {
    1641             :     rmp->is_enable = vnet_lisp_get_pitr_mode ();
    1642             :   });
    1643             :   /* *INDENT-ON* */
    1644             : }
    1645             : 
    1646             : static void
    1647           0 :   vl_api_one_enable_disable_petr_mode_t_handler
    1648             :   (vl_api_one_enable_disable_petr_mode_t * mp)
    1649             : {
    1650           0 :   vl_api_one_enable_disable_petr_mode_reply_t *rmp = 0;
    1651           0 :   int rv = vnet_lisp_enable_disable_petr_mode (mp->is_enable);
    1652             : 
    1653           0 :   REPLY_MACRO (VL_API_ONE_ENABLE_DISABLE_PETR_MODE_REPLY);
    1654             : }
    1655             : 
    1656             : static void
    1657           0 : vl_api_one_show_petr_mode_t_handler (vl_api_one_show_petr_mode_t * mp)
    1658             : {
    1659           0 :   vl_api_one_show_petr_mode_reply_t *rmp = 0;
    1660           0 :   int rv = 0;
    1661             : 
    1662             :   /* *INDENT-OFF* */
    1663           0 :   REPLY_MACRO2 (VL_API_ONE_SHOW_PETR_MODE_REPLY,
    1664             :   {
    1665             :     rmp->is_enable = vnet_lisp_get_petr_mode ();
    1666             :   });
    1667             :   /* *INDENT-ON* */
    1668             : }
    1669             : 
    1670             : /*
    1671             :  * one_api_hookup
    1672             :  * Add vpe's API message handlers to the table.
    1673             :  * vlib has already mapped shared memory and
    1674             :  * added the client registration handlers.
    1675             :  * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
    1676             :  */
    1677             : #include <lisp/lisp-cp/one.api.c>
    1678             : 
    1679             : static clib_error_t *
    1680         559 : one_api_hookup (vlib_main_t * vm)
    1681             : {
    1682         559 :   one_base_msg_id = setup_message_id_table ();
    1683             : 
    1684         559 :   return 0;
    1685             : }
    1686             : 
    1687        1119 : VLIB_API_INIT_FUNCTION (one_api_hookup);
    1688             : 
    1689             : #include <vlib/unix/plugin.h>
    1690             : #include <vpp/app/version.h>
    1691             : 
    1692             : /* *INDENT-OFF* */
    1693             : VLIB_PLUGIN_REGISTER () = {
    1694             :     .version = VPP_BUILD_VER,
    1695             :     .description = "Locator ID Separation Protocol (LISP)",
    1696             : };
    1697             : /* *INDENT-ON* */
    1698             : 
    1699             : /*
    1700             :  * fd.io coding-style-patch-verification: ON
    1701             :  *
    1702             :  * Local Variables:
    1703             :  * eval: (c-set-style "gnu")
    1704             :  * End:
    1705             :  */

Generated by: LCOV version 1.14