vat: session_rules_dump missing network to host conversion
[vpp.git] / src / vat / api_format.c
index f27d51a..eee5c74 100644 (file)
@@ -5305,7 +5305,8 @@ _(tcp_configure_src_addresses_reply)                      \
 _(app_namespace_add_del_reply)                          \
 _(dns_enable_disable_reply)                             \
 _(dns_name_server_add_del_reply)                       \
-_(session_rule_add_del_reply)
+_(session_rule_add_del_reply)                          \
+_(ip_container_proxy_add_del_reply)
 
 #define _(n)                                    \
     static void vl_api_##n##_t_handler          \
@@ -5627,7 +5628,8 @@ _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply)           \
 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply)                      \
 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply)                          \
 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply)              \
-_(SESSION_RULES_DETAILS, session_rules_details)
+_(SESSION_RULES_DETAILS, session_rules_details)                                \
+_(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply)  \
 
 #define foreach_standalone_reply_msg                                   \
 _(SW_INTERFACE_EVENT, sw_interface_event)                               \
@@ -21560,19 +21562,23 @@ vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
 
   if (mp->is_ip4)
     {
-      print (vam->ofp, "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d",
-            mp->appns_index, mp->transport_proto, mp->scope,
-            format_ip4_address, &mp->lcl_ip, mp->lcl_plen, mp->lcl_port,
-            format_ip4_address, &mp->rmt_ip, mp->rmt_plen, mp->rmt_port,
-            mp->action_index);
+      print (vam->ofp,
+            "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
+            clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
+            mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
+            clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
+            &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
+            clib_net_to_host_u32 (mp->action_index), mp->tag);
     }
   else
     {
-      print (vam->ofp, "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d",
-            mp->appns_index, mp->transport_proto, mp->scope,
-            format_ip6_address, &mp->lcl_ip, mp->lcl_plen, mp->lcl_port,
-            format_ip6_address, &mp->rmt_ip, mp->rmt_plen, mp->rmt_port,
-            mp->action_index);
+      print (vam->ofp,
+            "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
+            clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
+            mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
+            clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
+            &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
+            clib_net_to_host_u32 (mp->action_index), mp->tag);
     }
 }
 
@@ -21606,6 +21612,7 @@ vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
                            clib_net_to_host_u16 (mp->rmt_port));
   vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
   vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
+  vat_json_object_add_string_copy (node, "tag", mp->tag);
   if (mp->is_ip4)
     {
       clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
@@ -21632,7 +21639,7 @@ api_session_rule_add_del (vat_main_t * vam)
   ip4_address_t lcl_ip4, rmt_ip4;
   ip6_address_t lcl_ip6, rmt_ip6;
   u8 is_ip4 = 1, conn_set = 0;
-  u8 is_add = 1;
+  u8 is_add = 1, *tag = 0;
   int ret;
 
   while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
@@ -21649,6 +21656,8 @@ api_session_rule_add_del (vat_main_t * vam)
        ;
       else if (unformat (i, "scope %d", &scope))
        ;
+      else if (unformat (i, "tag %_%v%_", &tag))
+       ;
       else
        if (unformat
            (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
@@ -21688,8 +21697,10 @@ api_session_rule_add_del (vat_main_t * vam)
 
   mp->is_ip4 = is_ip4;
   mp->transport_proto = proto;
-  mp->lcl_plen = clib_host_to_net_u16 (lcl_plen);
-  mp->rmt_plen = clib_host_to_net_u16 (rmt_plen);
+  mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
+  mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
+  mp->lcl_plen = lcl_plen;
+  mp->rmt_plen = rmt_plen;
   mp->action_index = clib_host_to_net_u32 (action);
   mp->appns_index = clib_host_to_net_u32 (appns_index);
   mp->scope = scope;
@@ -21704,6 +21715,11 @@ api_session_rule_add_del (vat_main_t * vam)
       clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
       clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
     }
+  if (tag)
+    {
+      clib_memcpy (mp->tag, tag, vec_len (tag));
+      vec_free (tag);
+    }
 
   S (mp);
   W (ret);
@@ -21735,6 +21751,61 @@ api_session_rules_dump (vat_main_t * vam)
   return ret;
 }
 
+static int
+api_ip_container_proxy_add_del (vat_main_t * vam)
+{
+  vl_api_ip_container_proxy_add_del_t *mp;
+  unformat_input_t *i = vam->input;
+  u32 plen = ~0, sw_if_index = ~0;
+  ip4_address_t ip4;
+  ip6_address_t ip6;
+  u8 is_ip4 = 1;
+  u8 is_add = 1;
+  int ret;
+
+  while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+    {
+      if (unformat (i, "del"))
+       is_add = 0;
+      else if (unformat (i, "add"))
+       ;
+      if (unformat (i, "%U", unformat_ip4_address, &ip4))
+       {
+         is_ip4 = 1;
+         plen = 32;
+       }
+      else if (unformat (i, "%U", unformat_ip6_address, &ip6))
+       {
+         is_ip4 = 0;
+         plen = 128;
+       }
+      else if (unformat (i, "sw_if_index %u", &sw_if_index))
+       ;
+      else
+       break;
+    }
+  if (sw_if_index == ~0 || plen == ~0)
+    {
+      errmsg ("address and sw_if_index must be set");
+      return -99;
+    }
+
+  M (IP_CONTAINER_PROXY_ADD_DEL, mp);
+
+  mp->is_ip4 = is_ip4;
+  mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
+  mp->plen = plen;
+  mp->is_add = is_add;
+  if (is_ip4)
+    clib_memcpy (mp->ip, &ip4, sizeof (ip4));
+  else
+    clib_memcpy (mp->ip, &ip6, sizeof (ip6));
+
+  S (mp);
+  W (ret);
+  return ret;
+}
+
 static int
 q_or_quit (vat_main_t * vam)
 {
@@ -22546,6 +22617,7 @@ _(dns_resolve_name, "<hostname>")                                       \
 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> "   \
   "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>")                 \
 _(session_rules_dump, "")                                              \
+_(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>")     \
 
 /* List of command functions, CLI names map directly to functions */
 #define foreach_cli_function                                    \