LLDP: Add Management Address TLV
[vpp.git] / src / vat / api_format.c
index ba1a791..ae1db41 100644 (file)
@@ -5116,7 +5116,8 @@ _(p2p_ethernet_add_reply)                               \
 _(p2p_ethernet_del_reply)                               \
 _(lldp_config_reply)                                    \
 _(sw_interface_set_lldp_reply)                         \
-_(tcp_configure_src_addresses_reply)
+_(tcp_configure_src_addresses_reply)                   \
+_(app_namespace_add_del_reply)
 
 #define _(n)                                    \
     static void vl_api_##n##_t_handler          \
@@ -5420,7 +5421,8 @@ _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply)                       \
 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply)                       \
 _(LLDP_CONFIG_REPLY, lldp_config_reply)                                 \
 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply)            \
-_(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply)
+_(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply)        \
+_(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply)
 
 #define foreach_standalone_reply_msg                                   \
 _(SW_INTERFACE_EVENT, sw_interface_event)                               \
@@ -18349,10 +18351,10 @@ api_policer_add_del (vat_main_t * vam)
   clib_memcpy (mp->name, name, vec_len (name));
   vec_free (name);
   mp->is_add = is_add;
-  mp->cir = cir;
-  mp->eir = eir;
-  mp->cb = cb;
-  mp->eb = eb;
+  mp->cir = ntohl (cir);
+  mp->eir = ntohl (eir);
+  mp->cb = clib_net_to_host_u64 (cb);
+  mp->eb = clib_net_to_host_u64 (eb);
   mp->rate_type = rate_type;
   mp->round_type = round_type;
   mp->type = type;
@@ -20631,9 +20633,14 @@ api_sw_interface_set_lldp (vat_main_t * vam)
   vl_api_sw_interface_set_lldp_t *mp;
   u32 sw_if_index = ~0;
   u32 enable = 1;
-  u8 *port_desc = NULL;
+  u8 *port_desc = NULL, *mgmt_oid = NULL;
+  ip4_address_t ip4_addr;
+  ip6_address_t ip6_addr;
   int ret;
 
+  memset (&ip4_addr, 0, sizeof (ip4_addr));
+  memset (&ip6_addr, 0, sizeof (ip6_addr));
+
   while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
     {
       if (unformat (i, "disable"))
@@ -20645,6 +20652,12 @@ api_sw_interface_set_lldp (vat_main_t * vam)
        ;
       else if (unformat (i, "port-desc %s", &port_desc))
        ;
+      else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
+       ;
+      else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
+       ;
+      else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
+       ;
       else
        break;
     }
@@ -20657,11 +20670,16 @@ api_sw_interface_set_lldp (vat_main_t * vam)
 
   /* Construct the API message */
   vec_add1 (port_desc, 0);
+  vec_add1 (mgmt_oid, 0);
   M (SW_INTERFACE_SET_LLDP, mp);
   mp->sw_if_index = ntohl (sw_if_index);
   mp->enable = enable;
   clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
+  clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
+  clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
+  clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
   vec_free (port_desc);
+  vec_free (mgmt_oid);
 
   S (mp);
   W (ret);
@@ -20735,6 +20753,55 @@ api_tcp_configure_src_addresses (vat_main_t * vam)
   return ret;
 }
 
+static int
+api_app_namespace_add_del (vat_main_t * vam)
+{
+  vl_api_app_namespace_add_del_t *mp;
+  unformat_input_t *i = vam->input;
+  u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
+  u32 sw_if_index, ip4_fib_id, ip6_fib_id;
+  u64 secret;
+  int ret;
+
+  while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
+    {
+      if (unformat (i, "id %_%v%_", &ns_id))
+       ;
+      else if (unformat (i, "secret %lu", &secret))
+       secret_set = 1;
+      else if (unformat (i, "sw_if_index %d", &sw_if_index))
+       sw_if_index_set = 1;
+      else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
+       ;
+      else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
+       ;
+      else
+       break;
+    }
+  if (!ns_id || !secret_set || !sw_if_index_set)
+    {
+      errmsg ("namespace id, secret and sw_if_index must be set");
+      return -99;
+    }
+  if (vec_len (ns_id) > 64)
+    {
+      errmsg ("namespace id too long");
+      return -99;
+    }
+  M (APP_NAMESPACE_ADD_DEL, mp);
+
+  clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
+  mp->namespace_id_len = vec_len (ns_id);
+  mp->secret = secret;
+  mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
+  mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
+  mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
+  vec_free (ns_id);
+  S (mp);
+  W (ret);
+  return ret;
+}
+
 static int
 api_memfd_segment_create (vat_main_t * vam)
 {
@@ -21549,9 +21616,11 @@ _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")          \
 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
-_(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>] [disable]") \
+_(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
+  " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]")  \
-_(memfd_segment_create,"size <nnn>")
+_(memfd_segment_create,"size <nnn>")                                   \
+_(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
 
 /* List of command functions, CLI names map directly to functions */
 #define foreach_cli_function                                    \