LCOV - code coverage report
Current view: top level - plugins/lisp/lisp-cp - lisp_cp_test.c (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 0 920 0.0 %
Date: 2023-07-05 22:20:52 Functions: 0 53 0.0 %

          Line data    Source code
       1             : /*
       2             :  * Copyright (c) 2015 Cisco and/or its affiliates.
       3             :  * Licensed under the Apache License, Version 2.0 (the "License");
       4             :  * you may not use this file except in compliance with the License.
       5             :  * You may obtain a copy of the License at:
       6             :  *
       7             :  *     http://www.apache.org/licenses/LICENSE-2.0
       8             :  *
       9             :  * Unless required by applicable law or agreed to in writing, software
      10             :  * distributed under the License is distributed on an "AS IS" BASIS,
      11             :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      12             :  * See the License for the specific language governing permissions and
      13             :  * limitations under the License.
      14             :  */
      15             : 
      16             : #include <vat/vat.h>
      17             : #include <vlibapi/api.h>
      18             : #include <vlibmemory/api.h>
      19             : #include <vppinfra/error.h>
      20             : 
      21             : #include <vnet/ip/ip_format_fns.h>
      22             : #include <vnet/ethernet/ethernet_format_fns.h>
      23             : #include <vnet/ethernet/mac_address.h>
      24             : #include <lisp/lisp-cp/lisp_types.h>
      25             : 
      26             : /* define message IDs */
      27             : #include <lisp/lisp-cp/lisp.api_enum.h>
      28             : #include <lisp/lisp-cp/lisp.api_types.h>
      29             : #include <vlibmemory/vlib.api_types.h>
      30             : 
      31             : typedef struct
      32             : {
      33             :   /* API message ID base */
      34             :   u16 msg_id_base;
      35             :   vat_main_t *vat_main;
      36             :   u32 ping_id;
      37             : } lisp_test_main_t;
      38             : 
      39             : lisp_test_main_t lisp_test_main;
      40             : 
      41             : #define __plugin_msg_base lisp_test_main.msg_id_base
      42             : #include <vlibapi/vat_helper_macros.h>
      43             : 
      44             : #define FINISH                                                                \
      45             :   vec_add1 (s, 0);                                                            \
      46             :   vlib_cli_output (handle, (char *) s);                                       \
      47             :   vec_free (s);                                                               \
      48             :   return handle;
      49             : 
      50             : typedef struct
      51             : {
      52             :   u32 spi;
      53             :   u8 si;
      54             : } __attribute__ ((__packed__)) lisp_nsh_api_t;
      55             : 
      56             : #define LISP_PING(_lm, mp_ping)                                         \
      57             :   if (!(_lm)->ping_id)                                                  \
      58             :     (_lm)->ping_id = vl_msg_api_get_msg_index ((u8 *) (VL_API_CONTROL_PING_CRC)); \
      59             :   mp_ping = vl_msg_api_alloc_as_if_client (sizeof (*mp_ping));          \
      60             :   mp_ping->_vl_msg_id = htons ((_lm)->ping_id);                         \
      61             :   mp_ping->client_index = vam->my_client_index;                         \
      62             :   fformat (vam->ofp, "Sending ping id=%d\n", (_lm)->ping_id);           \
      63             :   vam->result_ready = 0;                                                \
      64             : 
      65             : uword
      66           0 : unformat_nsh_address (unformat_input_t * input, va_list * args)
      67             : {
      68           0 :   lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
      69           0 :   return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
      70             : }
      71             : 
      72             : static u8 *
      73           0 : format_nsh_address_vat (u8 * s, va_list * args)
      74             : {
      75           0 :   nsh_t *a = va_arg (*args, nsh_t *);
      76           0 :   return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
      77             : }
      78             : 
      79             : static u8 *
      80           0 : format_lisp_flat_eid (u8 * s, va_list * args)
      81             : {
      82           0 :   vl_api_eid_t *eid = va_arg (*args, vl_api_eid_t *);
      83             : 
      84           0 :   switch (eid->type)
      85             :     {
      86           0 :     case EID_TYPE_API_PREFIX:
      87           0 :       if (eid->address.prefix.address.af)
      88           0 :         return format (s, "%U/%d", format_ip6_address,
      89           0 :                        eid->address.prefix.address.un.ip6,
      90           0 :                        eid->address.prefix.len);
      91           0 :       return format (s, "%U/%d", format_ip4_address,
      92           0 :                      eid->address.prefix.address.un.ip4,
      93           0 :                      eid->address.prefix.len);
      94           0 :     case EID_TYPE_API_MAC:
      95           0 :       return format (s, "%U", format_ethernet_address, eid->address.mac);
      96           0 :     case EID_TYPE_API_NSH:
      97           0 :       return format (s, "%U", format_nsh_address_vat, eid->address.nsh);
      98             :     }
      99           0 :   return 0;
     100             : }
     101             : 
     102             : static u8 *
     103           0 : format_lisp_eid_vat (u8 * s, va_list * args)
     104             : {
     105           0 :   vl_api_eid_t *deid = va_arg (*args, vl_api_eid_t *);
     106           0 :   vl_api_eid_t *seid = va_arg (*args, vl_api_eid_t *);
     107           0 :   u8 is_src_dst = (u8) va_arg (*args, int);
     108             : 
     109           0 :   if (is_src_dst)
     110           0 :     s = format (s, "%U|", format_lisp_flat_eid, seid);
     111             : 
     112           0 :   s = format (s, "%U", format_lisp_flat_eid, deid);
     113             : 
     114           0 :   return s;
     115             : }
     116             : 
     117             : 
     118             : 
     119             : /* *INDENT-OFF* */
     120             : /** Used for parsing LISP eids */
     121             : typedef struct lisp_eid_vat_t_
     122             : {
     123             :   union {
     124             :     ip46_address_t ip;
     125             :     mac_address_t mac;
     126             :     lisp_nsh_api_t nsh;
     127             :   } addr;
     128             :   /**< prefix length if IP */
     129             :   u32 len;
     130             :   /**< type of eid */
     131             :   u8 type;
     132             : } __clib_packed lisp_eid_vat_t;
     133             : /* *INDENT-ON* */
     134             : 
     135             : static uword
     136           0 : unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
     137             : {
     138           0 :   lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
     139             : 
     140           0 :   clib_memset (a, 0, sizeof (a[0]));
     141             : 
     142           0 :   if (unformat (input, "%U/%d", unformat_ip46_address, a->addr.ip, &a->len))
     143             :     {
     144           0 :       a->type = 0;           /* ip prefix type */
     145             :     }
     146           0 :   else if (unformat (input, "%U", unformat_ethernet_address, &a->addr.mac))
     147             :     {
     148           0 :       a->type = 1;           /* mac type */
     149             :     }
     150           0 :   else if (unformat (input, "%U", unformat_nsh_address, a->addr.nsh))
     151             :     {
     152           0 :       a->type = 2;           /* NSH type */
     153           0 :       a->addr.nsh.spi = clib_host_to_net_u32 (a->addr.nsh.spi);
     154             :     }
     155             :   else
     156             :     {
     157           0 :       return 0;
     158             :     }
     159             : 
     160           0 :   if (a->type == 0)
     161             :     {
     162           0 :       if (ip46_address_is_ip4 (&a->addr.ip))
     163           0 :         return a->len > 32 ? 1 : 0;
     164             :       else
     165           0 :         return a->len > 128 ? 1 : 0;
     166             :     }
     167             : 
     168           0 :   return 1;
     169             : }
     170             : 
     171             : static void
     172           0 : lisp_eid_put_vat (vl_api_eid_t * eid, const lisp_eid_vat_t * vat_eid)
     173             : {
     174           0 :   eid->type = vat_eid->type;
     175           0 :   switch (eid->type)
     176             :     {
     177           0 :     case EID_TYPE_API_PREFIX:
     178           0 :       if (ip46_address_is_ip4 (&vat_eid->addr.ip))
     179             :         {
     180           0 :           clib_memcpy (&eid->address.prefix.address.un.ip4,
     181             :                        &vat_eid->addr.ip.ip4, 4);
     182           0 :           eid->address.prefix.address.af = ADDRESS_IP4;
     183           0 :           eid->address.prefix.len = vat_eid->len;
     184             :         }
     185             :       else
     186             :         {
     187           0 :           clib_memcpy (&eid->address.prefix.address.un.ip6,
     188             :                        &vat_eid->addr.ip.ip6, 16);
     189           0 :           eid->address.prefix.address.af = ADDRESS_IP6;
     190           0 :           eid->address.prefix.len = vat_eid->len;
     191             :         }
     192           0 :       return;
     193           0 :     case EID_TYPE_API_MAC:
     194           0 :       clib_memcpy (&eid->address.mac, &vat_eid->addr.mac,
     195             :                    sizeof (eid->address.mac));
     196           0 :       return;
     197           0 :     case EID_TYPE_API_NSH:
     198           0 :       clib_memcpy (&eid->address.nsh, &vat_eid->addr.nsh,
     199             :                    sizeof (eid->address.nsh));
     200           0 :       return;
     201           0 :     default:
     202           0 :       ASSERT (0);
     203           0 :       return;
     204             :     }
     205             : }
     206             : 
     207             : static int
     208           0 : api_lisp_add_del_locator_set (vat_main_t * vam)
     209             : {
     210           0 :   unformat_input_t *input = vam->input;
     211             :   vl_api_lisp_add_del_locator_set_t *mp;
     212           0 :   u8 is_add = 1;
     213           0 :   u8 *locator_set_name = NULL;
     214           0 :   u8 locator_set_name_set = 0;
     215           0 :   vl_api_local_locator_t locator, *locators = 0;
     216             :   u32 sw_if_index, priority, weight;
     217           0 :   u32 data_len = 0;
     218             : 
     219             :   int ret;
     220             :   /* Parse args required to build the message */
     221           0 :   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
     222             :     {
     223           0 :       if (unformat (input, "del"))
     224             :         {
     225           0 :           is_add = 0;
     226             :         }
     227           0 :       else if (unformat (input, "locator-set %s", &locator_set_name))
     228             :         {
     229           0 :           locator_set_name_set = 1;
     230             :         }
     231           0 :       else if (unformat (input, "sw_if_index %u p %u w %u",
     232             :                          &sw_if_index, &priority, &weight))
     233             :         {
     234           0 :           locator.sw_if_index = htonl (sw_if_index);
     235           0 :           locator.priority = priority;
     236           0 :           locator.weight = weight;
     237           0 :           vec_add1 (locators, locator);
     238             :         }
     239             :       else
     240           0 :         if (unformat
     241             :             (input, "iface %U p %u w %u", unformat_sw_if_index, vam,
     242             :              &sw_if_index, &priority, &weight))
     243             :         {
     244           0 :           locator.sw_if_index = htonl (sw_if_index);
     245           0 :           locator.priority = priority;
     246           0 :           locator.weight = weight;
     247           0 :           vec_add1 (locators, locator);
     248             :         }
     249             :       else
     250           0 :         break;
     251             :     }
     252             : 
     253           0 :   if (locator_set_name_set == 0)
     254             :     {
     255           0 :       errmsg ("missing locator-set name");
     256           0 :       vec_free (locators);
     257           0 :       return -99;
     258             :     }
     259             : 
     260           0 :   if (vec_len (locator_set_name) > 64)
     261             :     {
     262           0 :       errmsg ("locator-set name too long");
     263           0 :       vec_free (locator_set_name);
     264           0 :       vec_free (locators);
     265           0 :       return -99;
     266             :     }
     267           0 :   vec_add1 (locator_set_name, 0);
     268             : 
     269           0 :   data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
     270             : 
     271             :   /* Construct the API message */
     272           0 :   M2 (LISP_ADD_DEL_LOCATOR_SET, mp, data_len);
     273             : 
     274           0 :   mp->is_add = is_add;
     275           0 :   clib_memcpy (mp->locator_set_name, locator_set_name,
     276             :                vec_len (locator_set_name));
     277           0 :   vec_free (locator_set_name);
     278             : 
     279           0 :   mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
     280           0 :   if (locators)
     281           0 :     clib_memcpy (mp->locators, locators, data_len);
     282           0 :   vec_free (locators);
     283             : 
     284             :   /* send it... */
     285           0 :   S (mp);
     286             : 
     287             :   /* Wait for a reply... */
     288           0 :   W (ret);
     289           0 :   return ret;
     290             : }
     291             : 
     292             : static int
     293           0 : api_lisp_add_del_locator (vat_main_t * vam)
     294             : {
     295           0 :   unformat_input_t *input = vam->input;
     296             :   vl_api_lisp_add_del_locator_t *mp;
     297           0 :   u32 tmp_if_index = ~0;
     298           0 :   u32 sw_if_index = ~0;
     299           0 :   u8 sw_if_index_set = 0;
     300           0 :   u8 sw_if_index_if_name_set = 0;
     301           0 :   u32 priority = ~0;
     302           0 :   u8 priority_set = 0;
     303           0 :   u32 weight = ~0;
     304           0 :   u8 weight_set = 0;
     305           0 :   u8 is_add = 1;
     306           0 :   u8 *locator_set_name = NULL;
     307           0 :   u8 locator_set_name_set = 0;
     308             :   int ret;
     309             : 
     310             :   /* Parse args required to build the message */
     311           0 :   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
     312             :     {
     313           0 :       if (unformat (input, "del"))
     314             :         {
     315           0 :           is_add = 0;
     316             :         }
     317           0 :       else if (unformat (input, "locator-set %s", &locator_set_name))
     318             :         {
     319           0 :           locator_set_name_set = 1;
     320             :         }
     321           0 :       else if (unformat (input, "iface %U", unformat_sw_if_index, vam,
     322             :                          &tmp_if_index))
     323             :         {
     324           0 :           sw_if_index_if_name_set = 1;
     325           0 :           sw_if_index = tmp_if_index;
     326             :         }
     327           0 :       else if (unformat (input, "sw_if_index %d", &tmp_if_index))
     328             :         {
     329           0 :           sw_if_index_set = 1;
     330           0 :           sw_if_index = tmp_if_index;
     331             :         }
     332           0 :       else if (unformat (input, "p %d", &priority))
     333             :         {
     334           0 :           priority_set = 1;
     335             :         }
     336           0 :       else if (unformat (input, "w %d", &weight))
     337             :         {
     338           0 :           weight_set = 1;
     339             :         }
     340             :       else
     341           0 :         break;
     342             :     }
     343             : 
     344           0 :   if (locator_set_name_set == 0)
     345             :     {
     346           0 :       errmsg ("missing locator-set name");
     347           0 :       return -99;
     348             :     }
     349             : 
     350           0 :   if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
     351             :     {
     352           0 :       errmsg ("missing sw_if_index");
     353           0 :       vec_free (locator_set_name);
     354           0 :       return -99;
     355             :     }
     356             : 
     357           0 :   if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
     358             :     {
     359           0 :       errmsg ("cannot use both params interface name and sw_if_index");
     360           0 :       vec_free (locator_set_name);
     361           0 :       return -99;
     362             :     }
     363             : 
     364           0 :   if (priority_set == 0)
     365             :     {
     366           0 :       errmsg ("missing locator-set priority");
     367           0 :       vec_free (locator_set_name);
     368           0 :       return -99;
     369             :     }
     370             : 
     371           0 :   if (weight_set == 0)
     372             :     {
     373           0 :       errmsg ("missing locator-set weight");
     374           0 :       vec_free (locator_set_name);
     375           0 :       return -99;
     376             :     }
     377             : 
     378           0 :   if (vec_len (locator_set_name) > 64)
     379             :     {
     380           0 :       errmsg ("locator-set name too long");
     381           0 :       vec_free (locator_set_name);
     382           0 :       return -99;
     383             :     }
     384           0 :   vec_add1 (locator_set_name, 0);
     385             : 
     386             :   /* Construct the API message */
     387           0 :   M (LISP_ADD_DEL_LOCATOR, mp);
     388             : 
     389           0 :   mp->is_add = is_add;
     390           0 :   mp->sw_if_index = ntohl (sw_if_index);
     391           0 :   mp->priority = priority;
     392           0 :   mp->weight = weight;
     393           0 :   clib_memcpy (mp->locator_set_name, locator_set_name,
     394             :                vec_len (locator_set_name));
     395           0 :   vec_free (locator_set_name);
     396             : 
     397             :   /* send it... */
     398           0 :   S (mp);
     399             : 
     400             :   /* Wait for a reply... */
     401           0 :   W (ret);
     402           0 :   return ret;
     403             : }
     404             : 
     405             : static int
     406           0 : api_lisp_add_del_local_eid (vat_main_t * vam)
     407             : {
     408           0 :   unformat_input_t *input = vam->input;
     409             :   vl_api_lisp_add_del_local_eid_t *mp;
     410           0 :   u8 is_add = 1;
     411           0 :   u8 eid_set = 0;
     412           0 :   lisp_eid_vat_t _eid, *eid = &_eid;
     413           0 :   u8 *locator_set_name = 0;
     414           0 :   u8 locator_set_name_set = 0;
     415           0 :   u32 vni = 0;
     416           0 :   u16 key_id = 0;
     417           0 :   u8 *key = 0;
     418             :   int ret;
     419             : 
     420             :   /* Parse args required to build the message */
     421           0 :   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
     422             :     {
     423           0 :       if (unformat (input, "del"))
     424             :         {
     425           0 :           is_add = 0;
     426             :         }
     427           0 :       else if (unformat (input, "vni %d", &vni))
     428             :         {
     429             :           ;
     430             :         }
     431           0 :       else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
     432             :         {
     433           0 :           eid_set = 1;
     434             :         }
     435           0 :       else if (unformat (input, "locator-set %s", &locator_set_name))
     436             :         {
     437           0 :           locator_set_name_set = 1;
     438             :         }
     439           0 :       else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
     440             :         ;
     441           0 :       else if (unformat (input, "secret-key %_%v%_", &key))
     442             :         ;
     443             :       else
     444           0 :         break;
     445             :     }
     446             : 
     447           0 :   if (locator_set_name_set == 0)
     448             :     {
     449           0 :       errmsg ("missing locator-set name");
     450           0 :       return -99;
     451             :     }
     452             : 
     453           0 :   if (0 == eid_set)
     454             :     {
     455           0 :       errmsg ("EID address not set!");
     456           0 :       vec_free (locator_set_name);
     457           0 :       return -99;
     458             :     }
     459             : 
     460           0 :   if (key && (0 == key_id))
     461             :     {
     462           0 :       errmsg ("invalid key_id!");
     463           0 :       return -99;
     464             :     }
     465             : 
     466           0 :   if (vec_len (key) > 64)
     467             :     {
     468           0 :       errmsg ("key too long");
     469           0 :       vec_free (key);
     470           0 :       return -99;
     471             :     }
     472             : 
     473           0 :   if (vec_len (locator_set_name) > 64)
     474             :     {
     475           0 :       errmsg ("locator-set name too long");
     476           0 :       vec_free (locator_set_name);
     477           0 :       return -99;
     478             :     }
     479           0 :   vec_add1 (locator_set_name, 0);
     480             : 
     481             :   /* Construct the API message */
     482           0 :   M (LISP_ADD_DEL_LOCAL_EID, mp);
     483             : 
     484           0 :   mp->is_add = is_add;
     485           0 :   lisp_eid_put_vat (&mp->eid, eid);
     486           0 :   mp->vni = clib_host_to_net_u32 (vni);
     487           0 :   mp->key.id = key_id;
     488           0 :   clib_memcpy (mp->locator_set_name, locator_set_name,
     489             :                vec_len (locator_set_name));
     490           0 :   clib_memcpy (mp->key.key, key, vec_len (key));
     491             : 
     492           0 :   vec_free (locator_set_name);
     493           0 :   vec_free (key);
     494             : 
     495             :   /* send it... */
     496           0 :   S (mp);
     497             : 
     498             :   /* Wait for a reply... */
     499           0 :   W (ret);
     500           0 :   return ret;
     501             : }
     502             : 
     503             : static int
     504           0 : api_lisp_add_del_map_server (vat_main_t * vam)
     505             : {
     506           0 :   unformat_input_t *input = vam->input;
     507             :   vl_api_lisp_add_del_map_server_t *mp;
     508           0 :   u8 is_add = 1;
     509           0 :   u8 ipv4_set = 0;
     510           0 :   u8 ipv6_set = 0;
     511             :   ip4_address_t ipv4;
     512             :   ip6_address_t ipv6;
     513             :   int ret;
     514             : 
     515             :   /* Parse args required to build the message */
     516           0 :   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
     517             :     {
     518           0 :       if (unformat (input, "del"))
     519             :         {
     520           0 :           is_add = 0;
     521             :         }
     522           0 :       else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
     523             :         {
     524           0 :           ipv4_set = 1;
     525             :         }
     526           0 :       else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
     527             :         {
     528           0 :           ipv6_set = 1;
     529             :         }
     530             :       else
     531           0 :         break;
     532             :     }
     533             : 
     534           0 :   if (ipv4_set && ipv6_set)
     535             :     {
     536           0 :       errmsg ("both eid v4 and v6 addresses set");
     537           0 :       return -99;
     538             :     }
     539             : 
     540           0 :   if (!ipv4_set && !ipv6_set)
     541             :     {
     542           0 :       errmsg ("eid addresses not set");
     543           0 :       return -99;
     544             :     }
     545             : 
     546             :   /* Construct the API message */
     547           0 :   M (LISP_ADD_DEL_MAP_SERVER, mp);
     548             : 
     549           0 :   mp->is_add = is_add;
     550           0 :   if (ipv6_set)
     551             :     {
     552           0 :       mp->ip_address.af = 1;
     553           0 :       clib_memcpy (mp->ip_address.un.ip6, &ipv6, sizeof (ipv6));
     554             :     }
     555             :   else
     556             :     {
     557           0 :       mp->ip_address.af = 0;
     558           0 :       clib_memcpy (mp->ip_address.un.ip4, &ipv4, sizeof (ipv4));
     559             :     }
     560             : 
     561             :   /* send it... */
     562           0 :   S (mp);
     563             : 
     564             :   /* Wait for a reply... */
     565           0 :   W (ret);
     566           0 :   return ret;
     567             : }
     568             : 
     569             : static int
     570           0 : api_lisp_add_del_map_resolver (vat_main_t * vam)
     571             : {
     572           0 :   unformat_input_t *input = vam->input;
     573             :   vl_api_lisp_add_del_map_resolver_t *mp;
     574           0 :   u8 is_add = 1;
     575           0 :   u8 ipv4_set = 0;
     576           0 :   u8 ipv6_set = 0;
     577             :   ip4_address_t ipv4;
     578             :   ip6_address_t ipv6;
     579             :   int ret;
     580             : 
     581             :   /* Parse args required to build the message */
     582           0 :   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
     583             :     {
     584           0 :       if (unformat (input, "del"))
     585             :         {
     586           0 :           is_add = 0;
     587             :         }
     588           0 :       else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
     589             :         {
     590           0 :           ipv4_set = 1;
     591             :         }
     592           0 :       else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
     593             :         {
     594           0 :           ipv6_set = 1;
     595             :         }
     596             :       else
     597           0 :         break;
     598             :     }
     599             : 
     600           0 :   if (ipv4_set && ipv6_set)
     601             :     {
     602           0 :       errmsg ("both eid v4 and v6 addresses set");
     603           0 :       return -99;
     604             :     }
     605             : 
     606           0 :   if (!ipv4_set && !ipv6_set)
     607             :     {
     608           0 :       errmsg ("eid addresses not set");
     609           0 :       return -99;
     610             :     }
     611             : 
     612             :   /* Construct the API message */
     613           0 :   M (LISP_ADD_DEL_MAP_RESOLVER, mp);
     614             : 
     615           0 :   mp->is_add = is_add;
     616           0 :   if (ipv6_set)
     617             :     {
     618           0 :       mp->ip_address.af = 1;
     619           0 :       clib_memcpy (mp->ip_address.un.ip6, &ipv6, sizeof (ipv6));
     620             :     }
     621             :   else
     622             :     {
     623           0 :       mp->ip_address.af = 0;
     624           0 :       clib_memcpy (mp->ip_address.un.ip6, &ipv4, sizeof (ipv4));
     625             :     }
     626             : 
     627             :   /* send it... */
     628           0 :   S (mp);
     629             : 
     630             :   /* Wait for a reply... */
     631           0 :   W (ret);
     632           0 :   return ret;
     633             : }
     634             : 
     635             : static int
     636           0 : api_lisp_enable_disable (vat_main_t * vam)
     637             : {
     638           0 :   unformat_input_t *input = vam->input;
     639             :   vl_api_lisp_enable_disable_t *mp;
     640           0 :   u8 is_set = 0;
     641           0 :   u8 is_enable = 0;
     642             :   int ret;
     643             : 
     644             :   /* Parse args required to build the message */
     645           0 :   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
     646             :     {
     647           0 :       if (unformat (input, "enable"))
     648             :         {
     649           0 :           is_set = 1;
     650           0 :           is_enable = 1;
     651             :         }
     652           0 :       else if (unformat (input, "disable"))
     653             :         {
     654           0 :           is_set = 1;
     655             :         }
     656             :       else
     657           0 :         break;
     658             :     }
     659             : 
     660           0 :   if (!is_set)
     661             :     {
     662           0 :       errmsg ("Value not set");
     663           0 :       return -99;
     664             :     }
     665             : 
     666             :   /* Construct the API message */
     667           0 :   M (LISP_ENABLE_DISABLE, mp);
     668             : 
     669           0 :   mp->is_enable = is_enable;
     670             : 
     671             :   /* send it... */
     672           0 :   S (mp);
     673             : 
     674             :   /* Wait for a reply... */
     675           0 :   W (ret);
     676           0 :   return ret;
     677             : }
     678             : 
     679             : /**
     680             :  * Enable/disable LISP proxy ITR.
     681             :  *
     682             :  * @param vam vpp API test context
     683             :  * @return return code
     684             :  */
     685             : static int
     686           0 : api_lisp_pitr_set_locator_set (vat_main_t * vam)
     687             : {
     688           0 :   u8 ls_name_set = 0;
     689           0 :   unformat_input_t *input = vam->input;
     690             :   vl_api_lisp_pitr_set_locator_set_t *mp;
     691           0 :   u8 is_add = 1;
     692           0 :   u8 *ls_name = 0;
     693             :   int ret;
     694             : 
     695             :   /* Parse args required to build the message */
     696           0 :   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
     697             :     {
     698           0 :       if (unformat (input, "del"))
     699           0 :         is_add = 0;
     700           0 :       else if (unformat (input, "locator-set %s", &ls_name))
     701           0 :         ls_name_set = 1;
     702             :       else
     703             :         {
     704           0 :           errmsg ("parse error '%U'", format_unformat_error, input);
     705           0 :           return -99;
     706             :         }
     707             :     }
     708             : 
     709           0 :   if (!ls_name_set)
     710             :     {
     711           0 :       errmsg ("locator-set name not set!");
     712           0 :       return -99;
     713             :     }
     714             : 
     715           0 :   M (LISP_PITR_SET_LOCATOR_SET, mp);
     716             : 
     717           0 :   mp->is_add = is_add;
     718           0 :   clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
     719           0 :   vec_free (ls_name);
     720             : 
     721             :   /* send */
     722           0 :   S (mp);
     723             : 
     724             :   /* wait for reply */
     725           0 :   W (ret);
     726           0 :   return ret;
     727             : }
     728             : 
     729             : static int
     730           0 : api_lisp_use_petr (vat_main_t * vam)
     731             : {
     732           0 :   unformat_input_t *input = vam->input;
     733             :   vl_api_lisp_use_petr_t *mp;
     734           0 :   u8 is_add = 0;
     735             :   ip_address_t ip;
     736             :   int ret;
     737             : 
     738           0 :   clib_memset (&ip, 0, sizeof (ip));
     739             : 
     740             :   /* Parse args required to build the message */
     741           0 :   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
     742             :     {
     743           0 :       if (unformat (input, "disable"))
     744           0 :         is_add = 0;
     745             :       else
     746           0 :         if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
     747             :         {
     748           0 :           is_add = 1;
     749           0 :           ip_addr_version (&ip) = AF_IP4;
     750             :         }
     751             :       else
     752           0 :         if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
     753             :         {
     754           0 :           is_add = 1;
     755           0 :           ip_addr_version (&ip) = AF_IP6;
     756             :         }
     757             :       else
     758             :         {
     759           0 :           errmsg ("parse error '%U'", format_unformat_error, input);
     760           0 :           return -99;
     761             :         }
     762             :     }
     763             : 
     764           0 :   M (LISP_USE_PETR, mp);
     765             : 
     766           0 :   mp->is_add = is_add;
     767           0 :   if (is_add)
     768             :     {
     769           0 :       mp->ip_address.af = ip_addr_version (&ip) == AF_IP4 ? 0 : 1;
     770           0 :       if (mp->ip_address.af)
     771           0 :         clib_memcpy (mp->ip_address.un.ip6, &ip, 16);
     772             :       else
     773           0 :         clib_memcpy (mp->ip_address.un.ip4, &ip, 4);
     774             :     }
     775             : 
     776             :   /* send */
     777           0 :   S (mp);
     778             : 
     779             :   /* wait for reply */
     780           0 :   W (ret);
     781           0 :   return ret;
     782             : }
     783             : 
     784             : static void
     785           0 :   vl_api_show_lisp_use_petr_reply_t_handler
     786             :   (vl_api_show_lisp_use_petr_reply_t * mp)
     787             : {
     788           0 :   vat_main_t *vam = &vat_main;
     789           0 :   i32 retval = ntohl (mp->retval);
     790             : 
     791           0 :   if (0 <= retval)
     792             :     {
     793           0 :       print (vam->ofp, "%s\n", mp->is_petr_enable ? "enabled" : "disabled");
     794           0 :       if (mp->is_petr_enable)
     795             :         {
     796           0 :           print (vam->ofp, "Proxy-ETR address; %U",
     797           0 :                  mp->ip_address.af ? format_ip6_address : format_ip4_address,
     798             :                  mp->ip_address.un);
     799             :         }
     800             :     }
     801             : 
     802           0 :   vam->retval = retval;
     803           0 :   vam->result_ready = 1;
     804           0 : }
     805             : 
     806             : static int
     807           0 : api_show_lisp_use_petr (vat_main_t * vam)
     808             : {
     809             :   vl_api_show_lisp_use_petr_t *mp;
     810             :   int ret;
     811             : 
     812           0 :   if (!vam->json_output)
     813             :     {
     814           0 :       print (vam->ofp, "%=20s", "Proxy-ETR status:");
     815             :     }
     816             : 
     817           0 :   M (SHOW_LISP_USE_PETR, mp);
     818             :   /* send it... */
     819           0 :   S (mp);
     820             : 
     821             :   /* Wait for a reply... */
     822           0 :   W (ret);
     823           0 :   return ret;
     824             : }
     825             : 
     826             : static void
     827           0 :   vl_api_show_lisp_rloc_probe_state_reply_t_handler
     828             :   (vl_api_show_lisp_rloc_probe_state_reply_t * mp)
     829             : {
     830           0 :   vat_main_t *vam = &vat_main;
     831           0 :   int retval = clib_net_to_host_u32 (mp->retval);
     832             : 
     833           0 :   if (retval)
     834           0 :     goto end;
     835             : 
     836           0 :   print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
     837           0 : end:
     838           0 :   vam->retval = retval;
     839           0 :   vam->result_ready = 1;
     840           0 : }
     841             : 
     842             : static int
     843           0 : api_show_lisp_map_register_state (vat_main_t * vam)
     844             : {
     845             :   vl_api_show_lisp_map_register_state_t *mp;
     846             :   int ret;
     847             : 
     848           0 :   M (SHOW_LISP_MAP_REGISTER_STATE, mp);
     849             : 
     850             :   /* send */
     851           0 :   S (mp);
     852             : 
     853             :   /* wait for reply */
     854           0 :   W (ret);
     855           0 :   return ret;
     856             : }
     857             : 
     858             : static int
     859           0 : api_show_lisp_rloc_probe_state (vat_main_t * vam)
     860             : {
     861             :   vl_api_show_lisp_rloc_probe_state_t *mp;
     862             :   int ret;
     863             : 
     864           0 :   M (SHOW_LISP_RLOC_PROBE_STATE, mp);
     865             : 
     866             :   /* send */
     867           0 :   S (mp);
     868             : 
     869             :   /* wait for reply */
     870           0 :   W (ret);
     871           0 :   return ret;
     872             : }
     873             : 
     874             : static int
     875           0 : api_lisp_rloc_probe_enable_disable (vat_main_t * vam)
     876             : {
     877           0 :   unformat_input_t *input = vam->input;
     878             :   vl_api_lisp_rloc_probe_enable_disable_t *mp;
     879           0 :   u8 is_set = 0;
     880           0 :   u8 is_enable = 0;
     881             :   int ret;
     882             : 
     883             :   /* Parse args required to build the message */
     884           0 :   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
     885             :     {
     886           0 :       if (unformat (input, "enable"))
     887             :         {
     888           0 :           is_set = 1;
     889           0 :           is_enable = 1;
     890             :         }
     891           0 :       else if (unformat (input, "disable"))
     892           0 :         is_set = 1;
     893             :       else
     894           0 :         break;
     895             :     }
     896             : 
     897           0 :   if (!is_set)
     898             :     {
     899           0 :       errmsg ("Value not set");
     900           0 :       return -99;
     901             :     }
     902             : 
     903             :   /* Construct the API message */
     904           0 :   M (LISP_RLOC_PROBE_ENABLE_DISABLE, mp);
     905             : 
     906           0 :   mp->is_enable = is_enable;
     907             : 
     908             :   /* send it... */
     909           0 :   S (mp);
     910             : 
     911             :   /* Wait for a reply... */
     912           0 :   W (ret);
     913           0 :   return ret;
     914             : }
     915             : 
     916             : static int
     917           0 : api_lisp_map_register_enable_disable (vat_main_t * vam)
     918             : {
     919           0 :   unformat_input_t *input = vam->input;
     920             :   vl_api_lisp_map_register_enable_disable_t *mp;
     921           0 :   u8 is_set = 0;
     922           0 :   u8 is_enable = 0;
     923             :   int ret;
     924             : 
     925             :   /* Parse args required to build the message */
     926           0 :   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
     927             :     {
     928           0 :       if (unformat (input, "enable"))
     929             :         {
     930           0 :           is_set = 1;
     931           0 :           is_enable = 1;
     932             :         }
     933           0 :       else if (unformat (input, "disable"))
     934           0 :         is_set = 1;
     935             :       else
     936           0 :         break;
     937             :     }
     938             : 
     939           0 :   if (!is_set)
     940             :     {
     941           0 :       errmsg ("Value not set");
     942           0 :       return -99;
     943             :     }
     944             : 
     945             :   /* Construct the API message */
     946           0 :   M (LISP_MAP_REGISTER_ENABLE_DISABLE, mp);
     947             : 
     948           0 :   mp->is_enable = is_enable;
     949             : 
     950             :   /* send it... */
     951           0 :   S (mp);
     952             : 
     953             :   /* Wait for a reply... */
     954           0 :   W (ret);
     955           0 :   return ret;
     956             : }
     957             : 
     958             : static void
     959           0 :   vl_api_show_lisp_map_request_mode_reply_t_handler
     960             :   (vl_api_show_lisp_map_request_mode_reply_t * mp)
     961             : {
     962           0 :   vat_main_t *vam = &vat_main;
     963           0 :   i32 retval = ntohl (mp->retval);
     964             : 
     965           0 :   if (0 <= retval)
     966             :     {
     967           0 :       print (vam->ofp, "map_request_mode: %s",
     968           0 :              mp->is_src_dst ? "src-dst" : "dst-only");
     969             :     }
     970             : 
     971           0 :   vam->retval = retval;
     972           0 :   vam->result_ready = 1;
     973           0 : }
     974             : 
     975             : static void
     976           0 :   vl_api_show_lisp_map_register_state_reply_t_handler
     977             :   (vl_api_show_lisp_map_register_state_reply_t * mp)
     978             : {
     979           0 :   vat_main_t *vam = &vat_main;
     980           0 :   int retval = clib_net_to_host_u32 (mp->retval);
     981             : 
     982           0 :   print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
     983             : 
     984           0 :   vam->retval = retval;
     985           0 :   vam->result_ready = 1;
     986           0 : }
     987             : 
     988             : static void
     989           0 : vl_api_lisp_locator_details_t_handler (vl_api_lisp_locator_details_t * mp)
     990             : {
     991           0 :   vat_main_t *vam = &vat_main;
     992           0 :   u8 *s = 0;
     993             : 
     994           0 :   if (mp->local)
     995             :     {
     996           0 :       s = format (s, "%=16d%=16d%=16d",
     997           0 :                   ntohl (mp->sw_if_index), mp->priority, mp->weight);
     998             :     }
     999             :   else
    1000             :     {
    1001           0 :       s = format (s, "%=16U%=16d%=16d",
    1002             :                   format_ip46_address,
    1003           0 :                   mp->ip_address, mp->priority, mp->weight);
    1004             :     }
    1005             : 
    1006           0 :   print (vam->ofp, "%v", s);
    1007           0 :   vec_free (s);
    1008           0 : }
    1009             : 
    1010             : static void
    1011           0 : vl_api_lisp_locator_set_details_t_handler (vl_api_lisp_locator_set_details_t *
    1012             :                                            mp)
    1013             : {
    1014           0 :   vat_main_t *vam = &vat_main;
    1015           0 :   u8 *ls_name = 0;
    1016             : 
    1017           0 :   ls_name = format (0, "%s", mp->ls_name);
    1018             : 
    1019           0 :   print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
    1020             :          ls_name);
    1021           0 :   vec_free (ls_name);
    1022           0 : }
    1023             : 
    1024           0 : static void vl_api_lisp_add_del_locator_set_reply_t_handler
    1025             :   (vl_api_lisp_add_del_locator_set_reply_t * mp)
    1026             : {
    1027           0 :   vat_main_t *vam = &vat_main;
    1028           0 :   i32 retval = ntohl (mp->retval);
    1029           0 :   if (vam->async_mode)
    1030             :     {
    1031           0 :       vam->async_errors += (retval < 0);
    1032             :     }
    1033             :   else
    1034             :     {
    1035           0 :       vam->retval = retval;
    1036           0 :       vam->result_ready = 1;
    1037             :     }
    1038           0 : }
    1039             : 
    1040             : 
    1041             : static void
    1042           0 : vl_api_lisp_eid_table_details_t_handler (vl_api_lisp_eid_table_details_t * mp)
    1043             : {
    1044           0 :   vat_main_t *vam = &vat_main;
    1045           0 :   u8 *s = 0, *eid = 0;
    1046             : 
    1047           0 :   if (~0 == mp->locator_set_index)
    1048           0 :     s = format (0, "action: %d", mp->action);
    1049             :   else
    1050           0 :     s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
    1051             : 
    1052           0 :   eid = format (0, "%U", format_lisp_eid_vat,
    1053           0 :                 &mp->deid, &mp->seid, mp->is_src_dst);
    1054           0 :   vec_add1 (eid, 0);
    1055             : 
    1056           0 :   print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
    1057             :          clib_net_to_host_u32 (mp->vni),
    1058             :          eid,
    1059           0 :          mp->is_local ? "local" : "remote",
    1060           0 :          s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
    1061           0 :          clib_net_to_host_u16 (mp->key.id), mp->key.key);
    1062             : 
    1063           0 :   vec_free (s);
    1064           0 :   vec_free (eid);
    1065           0 : }
    1066             : 
    1067             : static void
    1068           0 :   vl_api_lisp_eid_table_map_details_t_handler
    1069             :   (vl_api_lisp_eid_table_map_details_t * mp)
    1070             : {
    1071           0 :   vat_main_t *vam = &vat_main;
    1072             : 
    1073           0 :   u8 *line = format (0, "%=10d%=10d",
    1074             :                      clib_net_to_host_u32 (mp->vni),
    1075             :                      clib_net_to_host_u32 (mp->dp_table));
    1076           0 :   print (vam->ofp, "%v", line);
    1077           0 :   vec_free (line);
    1078           0 : }
    1079             : 
    1080             : static void
    1081           0 :   vl_api_lisp_eid_table_vni_details_t_handler
    1082             :   (vl_api_lisp_eid_table_vni_details_t * mp)
    1083             : {
    1084           0 :   vat_main_t *vam = &vat_main;
    1085             : 
    1086           0 :   u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
    1087           0 :   print (vam->ofp, "%v", line);
    1088           0 :   vec_free (line);
    1089           0 : }
    1090             : 
    1091             : static void
    1092           0 :   vl_api_lisp_adjacencies_get_reply_t_handler
    1093             :   (vl_api_lisp_adjacencies_get_reply_t * mp)
    1094             : {
    1095           0 :   vat_main_t *vam = &vat_main;
    1096             :   u32 i, n;
    1097           0 :   int retval = clib_net_to_host_u32 (mp->retval);
    1098             :   vl_api_lisp_adjacency_t *a;
    1099             : 
    1100           0 :   if (retval)
    1101           0 :     goto end;
    1102             : 
    1103           0 :   n = clib_net_to_host_u32 (mp->count);
    1104             : 
    1105           0 :   for (i = 0; i < n; i++)
    1106             :     {
    1107           0 :       a = &mp->adjacencies[i];
    1108           0 :       print (vam->ofp, "%U %40U",
    1109             :              format_lisp_flat_eid, a->leid, format_lisp_flat_eid, a->reid);
    1110             :     }
    1111             : 
    1112           0 : end:
    1113           0 :   vam->retval = retval;
    1114           0 :   vam->result_ready = 1;
    1115           0 : }
    1116             : 
    1117             : static void
    1118           0 : vl_api_lisp_map_server_details_t_handler (vl_api_lisp_map_server_details_t *
    1119             :                                           mp)
    1120             : {
    1121           0 :   vat_main_t *vam = &vat_main;
    1122             : 
    1123           0 :   print (vam->ofp, "%=20U",
    1124           0 :          mp->ip_address.af ? format_ip6_address : format_ip4_address,
    1125             :          mp->ip_address.un);
    1126           0 : }
    1127             : 
    1128             : static void
    1129           0 : vl_api_lisp_map_resolver_details_t_handler (vl_api_lisp_map_resolver_details_t
    1130             :                                             * mp)
    1131             : {
    1132           0 :   vat_main_t *vam = &vat_main;
    1133             : 
    1134           0 :   print (vam->ofp, "%=20U",
    1135           0 :          mp->ip_address.af ? format_ip6_address : format_ip4_address,
    1136             :          mp->ip_address.un);
    1137           0 : }
    1138             : 
    1139             : static void
    1140           0 : vl_api_show_lisp_status_reply_t_handler (vl_api_show_lisp_status_reply_t * mp)
    1141             : {
    1142           0 :   vat_main_t *vam = &vat_main;
    1143           0 :   i32 retval = ntohl (mp->retval);
    1144             : 
    1145           0 :   if (0 <= retval)
    1146             :     {
    1147           0 :       print (vam->ofp, "feature: %s\ngpe: %s",
    1148           0 :              mp->is_lisp_enabled ? "enabled" : "disabled",
    1149           0 :              mp->is_gpe_enabled ? "enabled" : "disabled");
    1150             :     }
    1151             : 
    1152           0 :   vam->retval = retval;
    1153           0 :   vam->result_ready = 1;
    1154           0 : }
    1155             : 
    1156             : static void
    1157           0 :   vl_api_lisp_get_map_request_itr_rlocs_reply_t_handler
    1158             :   (vl_api_lisp_get_map_request_itr_rlocs_reply_t * mp)
    1159             : {
    1160           0 :   vat_main_t *vam = &vat_main;
    1161           0 :   i32 retval = ntohl (mp->retval);
    1162             : 
    1163           0 :   if (retval >= 0)
    1164             :     {
    1165           0 :       print (vam->ofp, "%=20s", mp->locator_set_name);
    1166             :     }
    1167             : 
    1168           0 :   vam->retval = retval;
    1169           0 :   vam->result_ready = 1;
    1170           0 : }
    1171             : 
    1172             : static void
    1173           0 : vl_api_show_lisp_pitr_reply_t_handler (vl_api_show_lisp_pitr_reply_t * mp)
    1174             : {
    1175           0 :   vat_main_t *vam = &vat_main;
    1176           0 :   i32 retval = ntohl (mp->retval);
    1177             : 
    1178           0 :   if (0 <= retval)
    1179             :     {
    1180           0 :       print (vam->ofp, "%-20s%-16s",
    1181           0 :              mp->is_enabled ? "enabled" : "disabled",
    1182           0 :              mp->is_enabled ? (char *) mp->locator_set_name : "");
    1183             :     }
    1184             : 
    1185           0 :   vam->retval = retval;
    1186           0 :   vam->result_ready = 1;
    1187           0 : }
    1188             : 
    1189             : uword
    1190           0 : unformat_hmac_key_id (unformat_input_t * input, va_list * args)
    1191             : {
    1192           0 :   u32 *key_id = va_arg (*args, u32 *);
    1193           0 :   u8 *s = 0;
    1194             : 
    1195           0 :   if (unformat (input, "%s", &s))
    1196             :     {
    1197           0 :       if (!strcmp ((char *) s, "sha1"))
    1198           0 :         key_id[0] = HMAC_SHA_1_96;
    1199           0 :       else if (!strcmp ((char *) s, "sha256"))
    1200           0 :         key_id[0] = HMAC_SHA_256_128;
    1201             :       else
    1202             :         {
    1203           0 :           clib_warning ("invalid key_id: '%s'", s);
    1204           0 :           key_id[0] = HMAC_NO_KEY;
    1205             :         }
    1206             :     }
    1207             :   else
    1208           0 :     return 0;
    1209             : 
    1210           0 :   vec_free (s);
    1211           0 :   return 1;
    1212             : }
    1213             : 
    1214             : 
    1215             : 
    1216             : static int
    1217           0 : api_show_lisp_map_request_mode (vat_main_t * vam)
    1218             : {
    1219             :   vl_api_show_lisp_map_request_mode_t *mp;
    1220             :   int ret;
    1221             : 
    1222           0 :   M (SHOW_LISP_MAP_REQUEST_MODE, mp);
    1223             : 
    1224             :   /* send */
    1225           0 :   S (mp);
    1226             : 
    1227             :   /* wait for reply */
    1228           0 :   W (ret);
    1229           0 :   return ret;
    1230             : }
    1231             : 
    1232             : static int
    1233           0 : api_lisp_map_request_mode (vat_main_t * vam)
    1234             : {
    1235           0 :   unformat_input_t *input = vam->input;
    1236             :   vl_api_lisp_map_request_mode_t *mp;
    1237           0 :   u8 mode = 0;
    1238             :   int ret;
    1239             : 
    1240             :   /* Parse args required to build the message */
    1241           0 :   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
    1242             :     {
    1243           0 :       if (unformat (input, "dst-only"))
    1244           0 :         mode = 0;
    1245           0 :       else if (unformat (input, "src-dst"))
    1246           0 :         mode = 1;
    1247             :       else
    1248             :         {
    1249           0 :           errmsg ("parse error '%U'", format_unformat_error, input);
    1250           0 :           return -99;
    1251             :         }
    1252             :     }
    1253             : 
    1254           0 :   M (LISP_MAP_REQUEST_MODE, mp);
    1255             : 
    1256           0 :   mp->is_src_dst = mode == 1;
    1257             : 
    1258             :   /* send */
    1259           0 :   S (mp);
    1260             : 
    1261             :   /* wait for reply */
    1262           0 :   W (ret);
    1263           0 :   return ret;
    1264             : }
    1265             : 
    1266             : static int
    1267           0 : api_show_lisp_pitr (vat_main_t * vam)
    1268             : {
    1269             :   vl_api_show_lisp_pitr_t *mp;
    1270             :   int ret;
    1271             : 
    1272           0 :   if (!vam->json_output)
    1273             :     {
    1274           0 :       print (vam->ofp, "%=20s", "lisp status:");
    1275             :     }
    1276             : 
    1277           0 :   M (SHOW_LISP_PITR, mp);
    1278             :   /* send it... */
    1279           0 :   S (mp);
    1280             : 
    1281             :   /* Wait for a reply... */
    1282           0 :   W (ret);
    1283           0 :   return ret;
    1284             : }
    1285             : 
    1286             : /**
    1287             :  * Add/delete mapping between vni and vrf
    1288             :  */
    1289             : static int
    1290           0 : api_lisp_eid_table_add_del_map (vat_main_t * vam)
    1291             : {
    1292           0 :   unformat_input_t *input = vam->input;
    1293             :   vl_api_lisp_eid_table_add_del_map_t *mp;
    1294           0 :   u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
    1295             :   u32 vni, vrf, bd_index;
    1296             :   int ret;
    1297             : 
    1298             :   /* Parse args required to build the message */
    1299           0 :   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
    1300             :     {
    1301           0 :       if (unformat (input, "del"))
    1302           0 :         is_add = 0;
    1303           0 :       else if (unformat (input, "vrf %d", &vrf))
    1304           0 :         vrf_set = 1;
    1305           0 :       else if (unformat (input, "bd_index %d", &bd_index))
    1306           0 :         bd_index_set = 1;
    1307           0 :       else if (unformat (input, "vni %d", &vni))
    1308           0 :         vni_set = 1;
    1309             :       else
    1310           0 :         break;
    1311             :     }
    1312             : 
    1313           0 :   if (!vni_set || (!vrf_set && !bd_index_set))
    1314             :     {
    1315           0 :       errmsg ("missing arguments!");
    1316           0 :       return -99;
    1317             :     }
    1318             : 
    1319           0 :   if (vrf_set && bd_index_set)
    1320             :     {
    1321           0 :       errmsg ("error: both vrf and bd entered!");
    1322           0 :       return -99;
    1323             :     }
    1324             : 
    1325           0 :   M (LISP_EID_TABLE_ADD_DEL_MAP, mp);
    1326             : 
    1327           0 :   mp->is_add = is_add;
    1328           0 :   mp->vni = htonl (vni);
    1329           0 :   mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
    1330           0 :   mp->is_l2 = bd_index_set;
    1331             : 
    1332             :   /* send */
    1333           0 :   S (mp);
    1334             : 
    1335             :   /* wait for reply */
    1336           0 :   W (ret);
    1337           0 :   return ret;
    1338             : }
    1339             : 
    1340             : /**
    1341             :  * Add/del remote mapping to/from LISP control plane
    1342             :  *
    1343             :  * @param vam vpp API test context
    1344             :  * @return return code
    1345             :  */
    1346             : static int
    1347           0 : api_lisp_add_del_remote_mapping (vat_main_t * vam)
    1348             : {
    1349           0 :   unformat_input_t *input = vam->input;
    1350             :   vl_api_lisp_add_del_remote_mapping_t *mp;
    1351           0 :   u32 vni = 0;
    1352           0 :   lisp_eid_vat_t _eid, *eid = &_eid;
    1353           0 :   lisp_eid_vat_t _seid, *seid = &_seid;
    1354           0 :   u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
    1355           0 :   u32 action = ~0, p, w, data_len;
    1356             :   ip4_address_t rloc4;
    1357             :   ip6_address_t rloc6;
    1358           0 :   vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
    1359             :   int ret;
    1360             : 
    1361           0 :   clib_memset (&rloc, 0, sizeof (rloc));
    1362             : 
    1363             :   /* Parse args required to build the message */
    1364           0 :   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
    1365             :     {
    1366           0 :       if (unformat (input, "del-all"))
    1367             :         {
    1368           0 :           del_all = 1;
    1369             :         }
    1370           0 :       else if (unformat (input, "del"))
    1371             :         {
    1372           0 :           is_add = 0;
    1373             :         }
    1374           0 :       else if (unformat (input, "add"))
    1375             :         {
    1376           0 :           is_add = 1;
    1377             :         }
    1378           0 :       else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
    1379             :         {
    1380           0 :           eid_set = 1;
    1381             :         }
    1382           0 :       else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
    1383             :         {
    1384           0 :           seid_set = 1;
    1385             :         }
    1386           0 :       else if (unformat (input, "vni %d", &vni))
    1387             :         {
    1388             :           ;
    1389             :         }
    1390           0 :       else if (unformat (input, "p %d w %d", &p, &w))
    1391             :         {
    1392           0 :           if (!curr_rloc)
    1393             :             {
    1394           0 :               errmsg ("No RLOC configured for setting priority/weight!");
    1395           0 :               return -99;
    1396             :             }
    1397           0 :           curr_rloc->priority = p;
    1398           0 :           curr_rloc->weight = w;
    1399             :         }
    1400           0 :       else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
    1401             :         {
    1402           0 :           rloc.ip_address.af = 0;
    1403           0 :           clib_memcpy (&rloc.ip_address.un.ip6, &rloc6, sizeof (rloc6));
    1404           0 :           vec_add1 (rlocs, rloc);
    1405           0 :           curr_rloc = &rlocs[vec_len (rlocs) - 1];
    1406             :         }
    1407           0 :       else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
    1408             :         {
    1409           0 :           rloc.ip_address.af = 1;
    1410           0 :           clib_memcpy (&rloc.ip_address.un.ip4, &rloc4, sizeof (rloc4));
    1411           0 :           vec_add1 (rlocs, rloc);
    1412           0 :           curr_rloc = &rlocs[vec_len (rlocs) - 1];
    1413             :         }
    1414           0 :       else if (unformat (input, "action %U",
    1415             :                          unformat_negative_mapping_action, &action))
    1416             :         {
    1417             :           ;
    1418             :         }
    1419             :       else
    1420             :         {
    1421           0 :           clib_warning ("parse error '%U'", format_unformat_error, input);
    1422           0 :           return -99;
    1423             :         }
    1424             :     }
    1425             : 
    1426           0 :   if (0 == eid_set)
    1427             :     {
    1428           0 :       errmsg ("missing params!");
    1429           0 :       return -99;
    1430             :     }
    1431             : 
    1432           0 :   if (is_add && (~0 == action) && 0 == vec_len (rlocs))
    1433             :     {
    1434           0 :       errmsg ("no action set for negative map-reply!");
    1435           0 :       return -99;
    1436             :     }
    1437             : 
    1438           0 :   data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
    1439             : 
    1440           0 :   M2 (LISP_ADD_DEL_REMOTE_MAPPING, mp, data_len);
    1441           0 :   mp->is_add = is_add;
    1442           0 :   mp->vni = htonl (vni);
    1443           0 :   mp->action = (u8) action;
    1444           0 :   mp->is_src_dst = seid_set;
    1445           0 :   mp->del_all = del_all;
    1446           0 :   lisp_eid_put_vat (&mp->deid, eid);
    1447           0 :   lisp_eid_put_vat (&mp->seid, seid);
    1448             : 
    1449           0 :   mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
    1450           0 :   clib_memcpy (mp->rlocs, rlocs, data_len);
    1451           0 :   vec_free (rlocs);
    1452             : 
    1453             :   /* send it... */
    1454           0 :   S (mp);
    1455             : 
    1456             :   /* Wait for a reply... */
    1457           0 :   W (ret);
    1458           0 :   return ret;
    1459             : }
    1460             : 
    1461             : /**
    1462             :  * Add/del LISP adjacency. Saves mapping in LISP control plane and updates
    1463             :  * forwarding entries in data-plane accordingly.
    1464             :  *
    1465             :  * @param vam vpp API test context
    1466             :  * @return return code
    1467             :  */
    1468             : static int
    1469           0 : api_lisp_add_del_adjacency (vat_main_t * vam)
    1470             : {
    1471           0 :   unformat_input_t *input = vam->input;
    1472             :   vl_api_lisp_add_del_adjacency_t *mp;
    1473           0 :   u32 vni = 0;
    1474           0 :   u8 is_add = 1;
    1475             :   int ret;
    1476             :   lisp_eid_vat_t leid, reid;
    1477             : 
    1478           0 :   leid.type = reid.type = (u8) ~ 0;
    1479             : 
    1480             :   /* Parse args required to build the message */
    1481           0 :   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
    1482             :     {
    1483           0 :       if (unformat (input, "del"))
    1484             :         {
    1485           0 :           is_add = 0;
    1486             :         }
    1487           0 :       else if (unformat (input, "add"))
    1488             :         {
    1489           0 :           is_add = 1;
    1490             :         }
    1491           0 :       else if (unformat (input, "reid %U/%d", unformat_ip46_address,
    1492             :                          &reid.addr.ip, &reid.len))
    1493             :         {
    1494           0 :           reid.type = 0;        /* ipv4 */
    1495             :         }
    1496           0 :       else if (unformat (input, "reid %U", unformat_ethernet_address,
    1497             :                          &reid.addr.mac))
    1498             :         {
    1499           0 :           reid.type = 1;        /* mac */
    1500             :         }
    1501           0 :       else if (unformat (input, "leid %U/%d", unformat_ip46_address,
    1502             :                          &leid.addr.ip, &leid.len))
    1503             :         {
    1504           0 :           leid.type = 0;        /* ipv4 */
    1505             :         }
    1506           0 :       else if (unformat (input, "leid %U", unformat_ethernet_address,
    1507             :                          &leid.addr.mac))
    1508             :         {
    1509           0 :           leid.type = 1;        /* mac */
    1510             :         }
    1511           0 :       else if (unformat (input, "vni %d", &vni))
    1512             :         {
    1513             :           ;
    1514             :         }
    1515             :       else
    1516             :         {
    1517           0 :           errmsg ("parse error '%U'", format_unformat_error, input);
    1518           0 :           return -99;
    1519             :         }
    1520             :     }
    1521             : 
    1522           0 :   if ((u8) ~ 0 == reid.type)
    1523             :     {
    1524           0 :       errmsg ("missing params!");
    1525           0 :       return -99;
    1526             :     }
    1527             : 
    1528           0 :   if (leid.type != reid.type)
    1529             :     {
    1530           0 :       errmsg ("remote and local EIDs are of different types!");
    1531           0 :       return -99;
    1532             :     }
    1533             : 
    1534           0 :   M (LISP_ADD_DEL_ADJACENCY, mp);
    1535           0 :   mp->is_add = is_add;
    1536           0 :   mp->vni = htonl (vni);
    1537           0 :   lisp_eid_put_vat (&mp->leid, &leid);
    1538           0 :   lisp_eid_put_vat (&mp->reid, &reid);
    1539             : 
    1540             :   /* send it... */
    1541           0 :   S (mp);
    1542             : 
    1543             :   /* Wait for a reply... */
    1544           0 :   W (ret);
    1545           0 :   return ret;
    1546             : }
    1547             : 
    1548             : /**
    1549             :  * Add/del map request itr rlocs from LISP control plane and updates
    1550             :  *
    1551             :  * @param vam vpp API test context
    1552             :  * @return return code
    1553             :  */
    1554             : static int
    1555           0 : api_lisp_add_del_map_request_itr_rlocs (vat_main_t * vam)
    1556             : {
    1557           0 :   unformat_input_t *input = vam->input;
    1558             :   vl_api_lisp_add_del_map_request_itr_rlocs_t *mp;
    1559           0 :   u8 *locator_set_name = 0;
    1560           0 :   u8 locator_set_name_set = 0;
    1561           0 :   u8 is_add = 1;
    1562             :   int ret;
    1563             : 
    1564             :   /* Parse args required to build the message */
    1565           0 :   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
    1566             :     {
    1567           0 :       if (unformat (input, "del"))
    1568             :         {
    1569           0 :           is_add = 0;
    1570             :         }
    1571           0 :       else if (unformat (input, "%_%v%_", &locator_set_name))
    1572             :         {
    1573           0 :           locator_set_name_set = 1;
    1574             :         }
    1575             :       else
    1576             :         {
    1577           0 :           clib_warning ("parse error '%U'", format_unformat_error, input);
    1578           0 :           return -99;
    1579             :         }
    1580             :     }
    1581             : 
    1582           0 :   if (is_add && !locator_set_name_set)
    1583             :     {
    1584           0 :       errmsg ("itr-rloc is not set!");
    1585           0 :       return -99;
    1586             :     }
    1587             : 
    1588           0 :   if (is_add && vec_len (locator_set_name) > 64)
    1589             :     {
    1590           0 :       errmsg ("itr-rloc locator-set name too long");
    1591           0 :       vec_free (locator_set_name);
    1592           0 :       return -99;
    1593             :     }
    1594             : 
    1595           0 :   M (LISP_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
    1596           0 :   mp->is_add = is_add;
    1597           0 :   if (is_add)
    1598             :     {
    1599           0 :       clib_memcpy (mp->locator_set_name, locator_set_name,
    1600             :                    vec_len (locator_set_name));
    1601             :     }
    1602             :   else
    1603             :     {
    1604           0 :       clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
    1605             :     }
    1606           0 :   vec_free (locator_set_name);
    1607             : 
    1608             :   /* send it... */
    1609           0 :   S (mp);
    1610             : 
    1611             :   /* Wait for a reply... */
    1612           0 :   W (ret);
    1613           0 :   return ret;
    1614             : }
    1615             : 
    1616             : static int
    1617           0 : api_lisp_locator_dump (vat_main_t * vam)
    1618             : {
    1619           0 :   unformat_input_t *input = vam->input;
    1620             :   vl_api_lisp_locator_dump_t *mp;
    1621             :   vl_api_control_ping_t *mp_ping;
    1622           0 :   u8 is_index_set = 0, is_name_set = 0;
    1623           0 :   u8 *ls_name = 0;
    1624           0 :   u32 ls_index = ~0;
    1625             :   int ret;
    1626             : 
    1627             :   /* Parse args required to build the message */
    1628           0 :   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
    1629             :     {
    1630           0 :       if (unformat (input, "ls_name %_%v%_", &ls_name))
    1631             :         {
    1632           0 :           is_name_set = 1;
    1633             :         }
    1634           0 :       else if (unformat (input, "ls_index %d", &ls_index))
    1635             :         {
    1636           0 :           is_index_set = 1;
    1637             :         }
    1638             :       else
    1639             :         {
    1640           0 :           errmsg ("parse error '%U'", format_unformat_error, input);
    1641           0 :           return -99;
    1642             :         }
    1643             :     }
    1644             : 
    1645           0 :   if (!is_index_set && !is_name_set)
    1646             :     {
    1647           0 :       errmsg ("error: expected lisp of index or name!");
    1648           0 :       return -99;
    1649             :     }
    1650             : 
    1651           0 :   if (is_index_set && is_name_set)
    1652             :     {
    1653           0 :       errmsg ("error: only lisp param expected!");
    1654           0 :       return -99;
    1655             :     }
    1656             : 
    1657           0 :   if (vec_len (ls_name) > 62)
    1658             :     {
    1659           0 :       errmsg ("error: locator set name too long!");
    1660           0 :       return -99;
    1661             :     }
    1662             : 
    1663           0 :   if (!vam->json_output)
    1664             :     {
    1665           0 :       print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
    1666             :     }
    1667             : 
    1668           0 :   M (LISP_LOCATOR_DUMP, mp);
    1669           0 :   mp->is_index_set = is_index_set;
    1670             : 
    1671           0 :   if (is_index_set)
    1672           0 :     mp->ls_index = clib_host_to_net_u32 (ls_index);
    1673             :   else
    1674             :     {
    1675           0 :       vec_add1 (ls_name, 0);
    1676           0 :       strncpy ((char *) mp->ls_name, (char *) ls_name,
    1677             :                sizeof (mp->ls_name) - 1);
    1678             :     }
    1679             : 
    1680             :   /* send it... */
    1681           0 :   S (mp);
    1682             : 
    1683             :   /* Use a control ping for synchronization */
    1684           0 :   if (!lisp_test_main.ping_id)
    1685           0 :     lisp_test_main.ping_id =
    1686           0 :       vl_msg_api_get_msg_index ((u8 *) (VL_API_CONTROL_PING_CRC));
    1687           0 :   mp_ping = vl_msg_api_alloc_as_if_client (sizeof (*mp_ping));
    1688           0 :   mp_ping->_vl_msg_id = htons (lisp_test_main.ping_id);
    1689           0 :   mp_ping->client_index = vam->my_client_index;
    1690             : 
    1691           0 :   fformat (vam->ofp, "Sending ping id=%d\n", lisp_test_main.ping_id);
    1692             : 
    1693           0 :   vam->result_ready = 0;
    1694           0 :   S (mp_ping);
    1695             : 
    1696             :   /* Wait for a reply... */
    1697           0 :   W (ret);
    1698           0 :   return ret;
    1699             : }
    1700             : 
    1701             : static int
    1702           0 : api_lisp_locator_set_dump (vat_main_t * vam)
    1703             : {
    1704             :   vl_api_lisp_locator_set_dump_t *mp;
    1705             :   vl_api_control_ping_t *mp_ping;
    1706           0 :   unformat_input_t *input = vam->input;
    1707           0 :   u8 filter = 0;
    1708             :   int ret;
    1709             : 
    1710             :   /* Parse args required to build the message */
    1711           0 :   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
    1712             :     {
    1713           0 :       if (unformat (input, "local"))
    1714             :         {
    1715           0 :           filter = 1;
    1716             :         }
    1717           0 :       else if (unformat (input, "remote"))
    1718             :         {
    1719           0 :           filter = 2;
    1720             :         }
    1721             :       else
    1722             :         {
    1723           0 :           errmsg ("parse error '%U'", format_unformat_error, input);
    1724           0 :           return -99;
    1725             :         }
    1726             :     }
    1727             : 
    1728           0 :   if (!vam->json_output)
    1729             :     {
    1730           0 :       print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
    1731             :     }
    1732             : 
    1733           0 :   M (LISP_LOCATOR_SET_DUMP, mp);
    1734             : 
    1735           0 :   mp->filter = filter;
    1736             : 
    1737             :   /* send it... */
    1738           0 :   S (mp);
    1739             : 
    1740             :   /* Use a control ping for synchronization */
    1741           0 :   LISP_PING (&lisp_test_main, mp_ping);
    1742           0 :   S (mp_ping);
    1743             : 
    1744             :   /* Wait for a reply... */
    1745           0 :   W (ret);
    1746           0 :   return ret;
    1747             : }
    1748             : 
    1749             : static int
    1750           0 : api_lisp_eid_table_map_dump (vat_main_t * vam)
    1751             : {
    1752           0 :   u8 is_l2 = 0;
    1753           0 :   u8 mode_set = 0;
    1754           0 :   unformat_input_t *input = vam->input;
    1755             :   vl_api_lisp_eid_table_map_dump_t *mp;
    1756             :   vl_api_control_ping_t *mp_ping;
    1757             :   int ret;
    1758             : 
    1759             :   /* Parse args required to build the message */
    1760           0 :   while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
    1761             :     {
    1762           0 :       if (unformat (input, "l2"))
    1763             :         {
    1764           0 :           is_l2 = 1;
    1765           0 :           mode_set = 1;
    1766             :         }
    1767           0 :       else if (unformat (input, "l3"))
    1768             :         {
    1769           0 :           is_l2 = 0;
    1770           0 :           mode_set = 1;
    1771             :         }
    1772             :       else
    1773             :         {
    1774           0 :           errmsg ("parse error '%U'", format_unformat_error, input);
    1775           0 :           return -99;
    1776             :         }
    1777             :     }
    1778             : 
    1779           0 :   if (!mode_set)
    1780             :     {
    1781           0 :       errmsg ("expected lisp of 'l2' or 'l3' parameter!");
    1782           0 :       return -99;
    1783             :     }
    1784             : 
    1785           0 :   if (!vam->json_output)
    1786             :     {
    1787           0 :       print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
    1788             :     }
    1789             : 
    1790           0 :   M (LISP_EID_TABLE_MAP_DUMP, mp);
    1791           0 :   mp->is_l2 = is_l2;
    1792             : 
    1793             :   /* send it... */
    1794           0 :   S (mp);
    1795             : 
    1796             :   /* Use a control ping for synchronization */
    1797           0 :   LISP_PING (&lisp_test_main, mp_ping);
    1798           0 :   S (mp_ping);
    1799             : 
    1800             :   /* Wait for a reply... */
    1801           0 :   W (ret);
    1802           0 :   return ret;
    1803             : }
    1804             : 
    1805             : static int
    1806           0 : api_lisp_eid_table_vni_dump (vat_main_t * vam)
    1807             : {
    1808             :   vl_api_lisp_eid_table_vni_dump_t *mp;
    1809             :   vl_api_control_ping_t *mp_ping;
    1810             :   int ret;
    1811             : 
    1812           0 :   if (!vam->json_output)
    1813             :     {
    1814           0 :       print (vam->ofp, "VNI");
    1815             :     }
    1816             : 
    1817           0 :   M (LISP_EID_TABLE_VNI_DUMP, mp);
    1818             : 
    1819             :   /* send it... */
    1820           0 :   S (mp);
    1821             : 
    1822             :   /* Use a control ping for synchronization */
    1823           0 :   LISP_PING (&lisp_test_main, mp_ping);
    1824           0 :   S (mp_ping);
    1825             : 
    1826             :   /* Wait for a reply... */
    1827           0 :   W (ret);
    1828           0 :   return ret;
    1829             : }
    1830             : 
    1831             : static int
    1832           0 : api_lisp_eid_table_dump (vat_main_t * vam)
    1833             : {
    1834           0 :   unformat_input_t *i = vam->input;
    1835             :   vl_api_lisp_eid_table_dump_t *mp;
    1836             :   vl_api_control_ping_t *mp_ping;
    1837           0 :   u8 filter = 0;
    1838             :   int ret;
    1839           0 :   u32 vni, t = 0;
    1840             :   lisp_eid_vat_t eid;
    1841           0 :   u8 eid_set = 0;
    1842             : 
    1843           0 :   while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
    1844             :     {
    1845           0 :       if (unformat
    1846             :           (i, "eid %U/%d", unformat_ip46_address, &eid.addr.ip, &eid.len))
    1847             :         {
    1848           0 :           eid_set = 1;
    1849           0 :           eid.type = 0;
    1850             :         }
    1851             :       else
    1852           0 :         if (unformat (i, "eid %U", unformat_ethernet_address, &eid.addr.mac))
    1853             :         {
    1854           0 :           eid_set = 1;
    1855           0 :           eid.type = 1;
    1856             :         }
    1857           0 :       else if (unformat (i, "eid %U", unformat_nsh_address, &eid.addr.nsh))
    1858             :         {
    1859           0 :           eid_set = 1;
    1860           0 :           eid.type = 2;
    1861             :         }
    1862           0 :       else if (unformat (i, "vni %d", &t))
    1863             :         {
    1864           0 :           vni = t;
    1865             :         }
    1866           0 :       else if (unformat (i, "local"))
    1867             :         {
    1868           0 :           filter = 1;
    1869             :         }
    1870           0 :       else if (unformat (i, "remote"))
    1871             :         {
    1872           0 :           filter = 2;
    1873             :         }
    1874             :       else
    1875             :         {
    1876           0 :           errmsg ("parse error '%U'", format_unformat_error, i);
    1877           0 :           return -99;
    1878             :         }
    1879             :     }
    1880             : 
    1881           0 :   if (!vam->json_output)
    1882             :     {
    1883           0 :       print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
    1884             :              "type", "ls_index", "ttl", "authoritative", "key_id", "key");
    1885             :     }
    1886             : 
    1887           0 :   M (LISP_EID_TABLE_DUMP, mp);
    1888             : 
    1889           0 :   mp->filter = filter;
    1890           0 :   if (eid_set)
    1891             :     {
    1892           0 :       mp->eid_set = 1;
    1893           0 :       mp->vni = htonl (vni);
    1894           0 :       lisp_eid_put_vat (&mp->eid, &eid);
    1895             :     }
    1896             : 
    1897             :   /* send it... */
    1898           0 :   S (mp);
    1899             : 
    1900             :   /* Use a control ping for synchronization */
    1901           0 :   LISP_PING (&lisp_test_main, mp_ping);
    1902           0 :   S (mp_ping);
    1903             : 
    1904             :   /* Wait for a reply... */
    1905           0 :   W (ret);
    1906           0 :   return ret;
    1907             : }
    1908             : 
    1909             : 
    1910             : static int
    1911           0 : api_lisp_adjacencies_get (vat_main_t * vam)
    1912             : {
    1913           0 :   unformat_input_t *i = vam->input;
    1914             :   vl_api_lisp_adjacencies_get_t *mp;
    1915           0 :   u8 vni_set = 0;
    1916           0 :   u32 vni = ~0;
    1917             :   int ret;
    1918             : 
    1919           0 :   while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
    1920             :     {
    1921           0 :       if (unformat (i, "vni %d", &vni))
    1922             :         {
    1923           0 :           vni_set = 1;
    1924             :         }
    1925             :       else
    1926             :         {
    1927           0 :           errmsg ("parse error '%U'", format_unformat_error, i);
    1928           0 :           return -99;
    1929             :         }
    1930             :     }
    1931             : 
    1932           0 :   if (!vni_set)
    1933             :     {
    1934           0 :       errmsg ("vni not set!");
    1935           0 :       return -99;
    1936             :     }
    1937             : 
    1938           0 :   if (!vam->json_output)
    1939             :     {
    1940           0 :       print (vam->ofp, "%s %40s", "leid", "reid");
    1941             :     }
    1942             : 
    1943           0 :   M (LISP_ADJACENCIES_GET, mp);
    1944           0 :   mp->vni = clib_host_to_net_u32 (vni);
    1945             : 
    1946             :   /* send it... */
    1947           0 :   S (mp);
    1948             : 
    1949             :   /* Wait for a reply... */
    1950           0 :   W (ret);
    1951           0 :   return ret;
    1952             : }
    1953             : 
    1954             : static int
    1955           0 : api_lisp_map_server_dump (vat_main_t * vam)
    1956             : {
    1957             :   vl_api_lisp_map_server_dump_t *mp;
    1958             :   vl_api_control_ping_t *mp_ping;
    1959             :   int ret;
    1960             : 
    1961           0 :   if (!vam->json_output)
    1962             :     {
    1963           0 :       print (vam->ofp, "%=20s", "Map server");
    1964             :     }
    1965             : 
    1966           0 :   M (LISP_MAP_SERVER_DUMP, mp);
    1967             :   /* send it... */
    1968           0 :   S (mp);
    1969             : 
    1970             :   /* Use a control ping for synchronization */
    1971           0 :   LISP_PING (&lisp_test_main, mp_ping);
    1972           0 :   S (mp_ping);
    1973             : 
    1974             :   /* Wait for a reply... */
    1975           0 :   W (ret);
    1976           0 :   return ret;
    1977             : }
    1978             : 
    1979             : static int
    1980           0 : api_lisp_map_resolver_dump (vat_main_t * vam)
    1981             : {
    1982             :   vl_api_lisp_map_resolver_dump_t *mp;
    1983             :   vl_api_control_ping_t *mp_ping;
    1984             :   int ret;
    1985             : 
    1986           0 :   if (!vam->json_output)
    1987             :     {
    1988           0 :       print (vam->ofp, "%=20s", "Map resolver");
    1989             :     }
    1990             : 
    1991           0 :   M (LISP_MAP_RESOLVER_DUMP, mp);
    1992             :   /* send it... */
    1993           0 :   S (mp);
    1994             : 
    1995             :   /* Use a control ping for synchronization */
    1996           0 :   LISP_PING (&lisp_test_main, mp_ping);
    1997           0 :   S (mp_ping);
    1998             : 
    1999             :   /* Wait for a reply... */
    2000           0 :   W (ret);
    2001           0 :   return ret;
    2002             : }
    2003             : 
    2004             : static int
    2005           0 : api_show_lisp_status (vat_main_t * vam)
    2006             : {
    2007             :   vl_api_show_lisp_status_t *mp;
    2008             :   int ret;
    2009             : 
    2010           0 :   if (!vam->json_output)
    2011             :     {
    2012           0 :       print (vam->ofp, "%-20s%-16s", "LISP status", "locator-set");
    2013             :     }
    2014             : 
    2015           0 :   M (SHOW_LISP_STATUS, mp);
    2016             :   /* send it... */
    2017           0 :   S (mp);
    2018             :   /* Wait for a reply... */
    2019           0 :   W (ret);
    2020           0 :   return ret;
    2021             : }
    2022             : 
    2023             : static int
    2024           0 : api_lisp_get_map_request_itr_rlocs (vat_main_t * vam)
    2025             : {
    2026             :   vl_api_lisp_get_map_request_itr_rlocs_t *mp;
    2027             :   int ret;
    2028             : 
    2029           0 :   if (!vam->json_output)
    2030             :     {
    2031           0 :       print (vam->ofp, "%=20s", "itr-rlocs:");
    2032             :     }
    2033             : 
    2034           0 :   M (LISP_GET_MAP_REQUEST_ITR_RLOCS, mp);
    2035             :   /* send it... */
    2036           0 :   S (mp);
    2037             :   /* Wait for a reply... */
    2038           0 :   W (ret);
    2039           0 :   return ret;
    2040             : }
    2041             : 
    2042             : #define vat_plugin_register vat_plugin_register_cp
    2043             : #include <lisp/lisp-cp/lisp.api_test.c>
    2044             : 
    2045             : /*
    2046             :  * fd.io coding-style-patch-verification: ON
    2047             :  *
    2048             :  * Local Variables:
    2049             :  * eval: (c-set-style "gnu")
    2050             :  * End:
    2051             :  */

Generated by: LCOV version 1.14