VPP-356: Fix wrong byte order in LISP API
[vpp.git] / vpp / vpp-api / api.c
index b10baf0..8bf6d30 100644 (file)
@@ -5126,7 +5126,7 @@ vl_api_lisp_add_del_locator_set_t_handler (vl_api_lisp_add_del_locator_set_t *
   vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
   locator_t locator;
   ls_locator_t *ls_loc;
-  u32 ls_index = ~0;
+  u32 ls_index = ~0, locator_num;
   u8 *locator_name = NULL;
   int i;
 
@@ -5137,9 +5137,10 @@ vl_api_lisp_add_del_locator_set_t_handler (vl_api_lisp_add_del_locator_set_t *
   a->name = locator_name;
   a->is_add = mp->is_add;
   a->local = 1;
+  locator_num = clib_net_to_host_u32 (mp->locator_num);
 
   memset (&locator, 0, sizeof (locator));
-  for (i = 0; i < mp->locator_num; i++)
+  for (i = 0; i < locator_num; i++)
     {
       ls_loc = &((ls_locator_t *) mp->locators)[i];
       VALIDATE_SW_IF_INDEX (ls_loc);
@@ -5487,7 +5488,7 @@ static void
   if (rv)
     goto send_reply;
 
-  rlocs = unformat_lisp_locs (mp->rlocs, mp->rloc_num);
+  rlocs = unformat_lisp_locs (mp->rlocs, clib_net_to_host_u32 (mp->rloc_num));
   if (0 == rlocs)
     goto send_reply;
 
@@ -5896,7 +5897,7 @@ send_eid_table_map_pair (hash_pair_t * p,
   rmp->_vl_msg_id = ntohs (VL_API_LISP_EID_TABLE_MAP_DETAILS);
 
   rmp->vni = clib_host_to_net_u32 (p->key);
-  rmp->vrf = clib_host_to_net_u32 (p->value[0]);
+  rmp->dp_table = clib_host_to_net_u32 (p->value[0]);
   rmp->context = context;
   vl_msg_api_send_shmem (q, (u8 *) & rmp);
 }
@@ -5908,14 +5909,25 @@ vl_api_lisp_eid_table_map_dump_t_handler (vl_api_lisp_eid_table_map_dump_t *
   unix_shared_memory_queue_t *q = NULL;
   lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
   hash_pair_t *p;
+  uword *vni_table = 0;
 
   q = vl_api_client_index_to_input_queue (mp->client_index);
   if (q == 0)
     {
       return;
     }
+
+  if (mp->is_l2)
+    {
+      vni_table = lcm->bd_id_by_vni;
+    }
+  else
+    {
+      vni_table = lcm->table_id_by_vni;
+    }
+
   /* *INDENT-OFF* */
-  hash_foreach_pair (p, lcm->table_id_by_vni,
+  hash_foreach_pair (p, vni_table,
   ({
     send_eid_table_map_pair (p, q, mp->context);
   }));