ipsec: provide stat index in sa details
[vpp.git] / src / vat / api_format.c
index 009a0a4..a84a67e 100644 (file)
@@ -9325,10 +9325,8 @@ api_sr_localsid_add_del (vat_main_t * vam)
   u8 behavior = ~0;
   u32 sw_if_index;
   u32 fib_table = ~(u32) 0;
-  ip6_address_t nh_addr6;
-  ip4_address_t nh_addr4;
-  clib_memset (&nh_addr6, 0, sizeof (ip6_address_t));
-  clib_memset (&nh_addr4, 0, sizeof (ip4_address_t));
+  ip46_address_t nh_addr;
+  clib_memset (&nh_addr, 0, sizeof (ip46_address_t));
 
   bool nexthop_set = 0;
 
@@ -9339,9 +9337,7 @@ api_sr_localsid_add_del (vat_main_t * vam)
       if (unformat (i, "del"))
        is_del = 1;
       else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
-      else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
-       nexthop_set = 1;
-      else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
+      else if (unformat (i, "next-hop %U", unformat_ip46_address, &nh_addr))
        nexthop_set = 1;
       else if (unformat (i, "behavior %u", &behavior));
       else if (unformat (i, "sw_if_index %u", &sw_if_index));
@@ -9353,12 +9349,11 @@ api_sr_localsid_add_del (vat_main_t * vam)
 
   M (SR_LOCALSID_ADD_DEL, mp);
 
-  clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
+  clib_memcpy (mp->localsid, &localsid, sizeof (mp->localsid));
 
   if (nexthop_set)
     {
-      clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
-      clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
+      clib_memcpy (&mp->nh_addr.un, &nh_addr, sizeof (mp->nh_addr.un));
     }
   mp->behavior = behavior;
   mp->sw_if_index = ntohl (sw_if_index);
@@ -13809,7 +13804,7 @@ vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
         "crypto_key %U integ_alg %u integ_key %U flags %x "
         "tunnel_src_addr %U tunnel_dst_addr %U "
         "salt %u seq_outbound %lu last_seq_inbound %lu "
-        "replay_window %lu\n",
+        "replay_window %lu stat_index %u\n",
         ntohl (mp->entry.sad_id),
         ntohl (mp->sw_if_index),
         ntohl (mp->entry.spi),
@@ -13823,7 +13818,7 @@ vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
         &mp->entry.tunnel_dst, ntohl (mp->salt),
         clib_net_to_host_u64 (mp->seq_outbound),
         clib_net_to_host_u64 (mp->last_seq_inbound),
-        clib_net_to_host_u64 (mp->replay_window));
+        clib_net_to_host_u64 (mp->replay_window), ntohl (mp->stat_index));
 }
 
 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
@@ -13871,6 +13866,7 @@ static void vl_api_ipsec_sa_details_t_handler_json
   vat_json_object_add_address (node, "dst", &mp->entry.tunnel_dst);
   vat_json_object_add_uint (node, "replay_window",
                            clib_net_to_host_u64 (mp->replay_window));
+  vat_json_object_add_uint (node, "stat_index", ntohl (mp->stat_index));
 }
 
 static int
@@ -17554,7 +17550,7 @@ format_fib_api_path_nh_proto (u8 * s, va_list * args)
 static u8 *
 format_vl_api_ip_address_union (u8 * s, va_list * args)
 {
-  vl_api_address_family_t af = va_arg (*args, vl_api_address_family_t);
+  vl_api_address_family_t af = va_arg (*args, int);
   const vl_api_address_union_t *u = va_arg (*args, vl_api_address_union_t *);
 
   switch (af)
@@ -17641,7 +17637,7 @@ vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
       clib_memcpy (&ip4, &fp->nh.address.ip4, sizeof (ip4));
       vat_json_object_add_ip4 (node, "next_hop", ip4);
     }
-  else if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
+  else if (fp->proto == FIB_API_PATH_NH_PROTO_IP6)
     {
       clib_memcpy (&ip6, &fp->nh.address.ip6, sizeof (ip6));
       vat_json_object_add_ip6 (node, "next_hop", ip6);