dhcp: Move to plugin
[vpp.git] / src / vat / api_format.c
index 16abf45..4c1a85f 100644 (file)
@@ -51,7 +51,6 @@
 #include <vnet/policer/policer.h>
 #include <vnet/policer/police.h>
 #include <vnet/mfib/mfib_types.h>
-#include <vnet/dhcp/dhcp_proxy.h>
 #include <vnet/bonding/node.h>
 #include <vnet/qos/qos_types.h>
 #include <vnet/ethernet/ethernet_types_api.h>
@@ -2666,33 +2665,6 @@ vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
                           clib_net_to_host_u32 (mp->sw_if_index));
 }
 
-static void
-vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
-{
-  u8 *s, i;
-
-  s = format (0, "DHCP compl event: pid %d hostname %s host_addr %U "
-             "host_mac %U router_addr %U",
-             ntohl (mp->pid), mp->lease.hostname,
-             format_ip4_address, mp->lease.host_address,
-             format_ethernet_address, mp->lease.host_mac,
-             format_ip4_address, mp->lease.router_address);
-
-  for (i = 0; i < mp->lease.count; i++)
-    s =
-      format (s, " domain_server_addr %U", format_ip4_address,
-             mp->lease.domain_server[i].address);
-
-  errmsg ((char *) s);
-  vec_free (s);
-}
-
-static void vl_api_dhcp_compl_event_t_handler_json
-  (vl_api_dhcp_compl_event_t * mp)
-{
-  /* JSON output not supported */
-}
-
 static void vl_api_get_first_msg_id_reply_t_handler
   (vl_api_get_first_msg_id_reply_t * mp)
 {
@@ -5108,9 +5080,6 @@ _(proxy_arp_intfc_enable_disable_reply)                 \
 _(sw_interface_set_unnumbered_reply)                    \
 _(ip_neighbor_add_del_reply)                            \
 _(reset_fib_reply)                                      \
-_(dhcp_proxy_config_reply)                              \
-_(dhcp_proxy_set_vss_reply)                             \
-_(dhcp_client_config_reply)                             \
 _(set_ip_flow_hash_reply)                               \
 _(sw_interface_ip6_enable_disable_reply)                \
 _(ip6nd_proxy_add_del_reply)                            \
@@ -5313,10 +5282,6 @@ _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply)                 \
 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply)                     \
 _(CREATE_SUBIF_REPLY, create_subif_reply)                              \
 _(RESET_FIB_REPLY, reset_fib_reply)                                     \
-_(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply)                     \
-_(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply)                   \
-_(DHCP_PROXY_DETAILS, dhcp_proxy_details)                               \
-_(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply)                   \
 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply)                       \
 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY,                                \
   sw_interface_ip6_enable_disable_reply)                                \
@@ -5392,7 +5357,6 @@ _(DELETE_LOOPBACK_REPLY, delete_loopback_reply)                         \
 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply)                     \
 _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply)                         \
 _(BD_IP_MAC_DETAILS, bd_ip_mac_details)                                 \
-_(DHCP_COMPL_EVENT, dhcp_compl_event)                                   \
 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply)             \
 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply)                      \
 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
@@ -9278,358 +9242,6 @@ api_reset_fib (vat_main_t * vam)
   return ret;
 }
 
-static int
-api_dhcp_proxy_config (vat_main_t * vam)
-{
-  unformat_input_t *i = vam->input;
-  vl_api_dhcp_proxy_config_t *mp;
-  u32 rx_vrf_id = 0;
-  u32 server_vrf_id = 0;
-  u8 is_add = 1;
-  u8 v4_address_set = 0;
-  u8 v6_address_set = 0;
-  ip4_address_t v4address;
-  ip6_address_t v6address;
-  u8 v4_src_address_set = 0;
-  u8 v6_src_address_set = 0;
-  ip4_address_t v4srcaddress;
-  ip6_address_t v6srcaddress;
-  int ret;
-
-  /* Parse args required to build the message */
-  while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
-    {
-      if (unformat (i, "del"))
-       is_add = 0;
-      else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
-       ;
-      else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
-       ;
-      else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
-       v4_address_set = 1;
-      else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
-       v6_address_set = 1;
-      else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
-       v4_src_address_set = 1;
-      else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
-       v6_src_address_set = 1;
-      else
-       break;
-    }
-
-  if (v4_address_set && v6_address_set)
-    {
-      errmsg ("both v4 and v6 server addresses set");
-      return -99;
-    }
-  if (!v4_address_set && !v6_address_set)
-    {
-      errmsg ("no server addresses set");
-      return -99;
-    }
-
-  if (v4_src_address_set && v6_src_address_set)
-    {
-      errmsg ("both v4 and v6  src addresses set");
-      return -99;
-    }
-  if (!v4_src_address_set && !v6_src_address_set)
-    {
-      errmsg ("no src addresses set");
-      return -99;
-    }
-
-  if (!(v4_src_address_set && v4_address_set) &&
-      !(v6_src_address_set && v6_address_set))
-    {
-      errmsg ("no matching server and src addresses set");
-      return -99;
-    }
-
-  /* Construct the API message */
-  M (DHCP_PROXY_CONFIG, mp);
-
-  mp->is_add = is_add;
-  mp->rx_vrf_id = ntohl (rx_vrf_id);
-  mp->server_vrf_id = ntohl (server_vrf_id);
-  if (v6_address_set)
-    {
-      clib_memcpy (&mp->dhcp_server.un, &v6address, sizeof (v6address));
-      clib_memcpy (&mp->dhcp_src_address.un, &v6srcaddress,
-                  sizeof (v6address));
-    }
-  else
-    {
-      clib_memcpy (&mp->dhcp_server.un, &v4address, sizeof (v4address));
-      clib_memcpy (&mp->dhcp_src_address.un, &v4srcaddress,
-                  sizeof (v4address));
-    }
-
-  /* send it... */
-  S (mp);
-
-  /* Wait for a reply, return good/bad news  */
-  W (ret);
-  return ret;
-}
-
-#define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
-#define vl_api_dhcp_proxy_details_t_print vl_noop_handler
-
-static void
-vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
-{
-  vat_main_t *vam = &vat_main;
-  u32 i, count = mp->count;
-  vl_api_dhcp_server_t *s;
-
-  if (mp->is_ipv6)
-    print (vam->ofp,
-          "RX Table-ID %d, Source Address %U, VSS Type %d, "
-          "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
-          ntohl (mp->rx_vrf_id),
-          format_ip6_address, mp->dhcp_src_address,
-          mp->vss_type, mp->vss_vpn_ascii_id,
-          ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
-  else
-    print (vam->ofp,
-          "RX Table-ID %d, Source Address %U, VSS Type %d, "
-          "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
-          ntohl (mp->rx_vrf_id),
-          format_ip4_address, mp->dhcp_src_address,
-          mp->vss_type, mp->vss_vpn_ascii_id,
-          ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
-
-  for (i = 0; i < count; i++)
-    {
-      s = &mp->servers[i];
-
-      if (mp->is_ipv6)
-       print (vam->ofp,
-              " Server Table-ID %d, Server Address %U",
-              ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
-      else
-       print (vam->ofp,
-              " Server Table-ID %d, Server Address %U",
-              ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
-    }
-}
-
-static void vl_api_dhcp_proxy_details_t_handler_json
-  (vl_api_dhcp_proxy_details_t * mp)
-{
-  vat_main_t *vam = &vat_main;
-  vat_json_node_t *node = NULL;
-  u32 i, count = mp->count;
-  struct in_addr ip4;
-  struct in6_addr ip6;
-  vl_api_dhcp_server_t *s;
-
-  if (VAT_JSON_ARRAY != vam->json_tree.type)
-    {
-      ASSERT (VAT_JSON_NONE == vam->json_tree.type);
-      vat_json_init_array (&vam->json_tree);
-    }
-  node = vat_json_array_add (&vam->json_tree);
-
-  vat_json_init_object (node);
-  vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
-  vat_json_object_add_uint (node, "vss-type", ntohl (mp->vss_type));
-  vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
-                                  mp->vss_vpn_ascii_id);
-  vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
-  vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
-
-  if (mp->is_ipv6)
-    {
-      clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
-      vat_json_object_add_ip6 (node, "src_address", ip6);
-    }
-  else
-    {
-      clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
-      vat_json_object_add_ip4 (node, "src_address", ip4);
-    }
-
-  for (i = 0; i < count; i++)
-    {
-      s = &mp->servers[i];
-
-      vat_json_object_add_uint (node, "server-table-id",
-                               ntohl (s->server_vrf_id));
-
-      if (mp->is_ipv6)
-       {
-         clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
-         vat_json_object_add_ip4 (node, "src_address", ip4);
-       }
-      else
-       {
-         clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
-         vat_json_object_add_ip6 (node, "server_address", ip6);
-       }
-    }
-}
-
-static int
-api_dhcp_proxy_dump (vat_main_t * vam)
-{
-  unformat_input_t *i = vam->input;
-  vl_api_control_ping_t *mp_ping;
-  vl_api_dhcp_proxy_dump_t *mp;
-  u8 is_ipv6 = 0;
-  int ret;
-
-  while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
-    {
-      if (unformat (i, "ipv6"))
-       is_ipv6 = 1;
-      else
-       {
-         clib_warning ("parse error '%U'", format_unformat_error, i);
-         return -99;
-       }
-    }
-
-  M (DHCP_PROXY_DUMP, mp);
-
-  mp->is_ip6 = is_ipv6;
-  S (mp);
-
-  /* Use a control ping for synchronization */
-  MPING (CONTROL_PING, mp_ping);
-  S (mp_ping);
-
-  W (ret);
-  return ret;
-}
-
-static int
-api_dhcp_proxy_set_vss (vat_main_t * vam)
-{
-  unformat_input_t *i = vam->input;
-  vl_api_dhcp_proxy_set_vss_t *mp;
-  u8 is_ipv6 = 0;
-  u8 is_add = 1;
-  u32 tbl_id = ~0;
-  u8 vss_type = VSS_TYPE_DEFAULT;
-  u8 *vpn_ascii_id = 0;
-  u32 oui = 0;
-  u32 fib_id = 0;
-  int ret;
-
-  while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
-    {
-      if (unformat (i, "tbl_id %d", &tbl_id))
-       ;
-      else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
-       vss_type = VSS_TYPE_ASCII;
-      else if (unformat (i, "fib_id %d", &fib_id))
-       vss_type = VSS_TYPE_VPN_ID;
-      else if (unformat (i, "oui %d", &oui))
-       vss_type = VSS_TYPE_VPN_ID;
-      else if (unformat (i, "ipv6"))
-       is_ipv6 = 1;
-      else if (unformat (i, "del"))
-       is_add = 0;
-      else
-       break;
-    }
-
-  if (tbl_id == ~0)
-    {
-      errmsg ("missing tbl_id ");
-      vec_free (vpn_ascii_id);
-      return -99;
-    }
-
-  if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
-    {
-      errmsg ("vpn_ascii_id cannot be longer than 128 ");
-      vec_free (vpn_ascii_id);
-      return -99;
-    }
-
-  M (DHCP_PROXY_SET_VSS, mp);
-  mp->tbl_id = ntohl (tbl_id);
-  mp->vss_type = vss_type;
-  if (vpn_ascii_id)
-    {
-      clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
-      mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
-    }
-  mp->vpn_index = ntohl (fib_id);
-  mp->oui = ntohl (oui);
-  mp->is_ipv6 = is_ipv6;
-  mp->is_add = is_add;
-
-  S (mp);
-  W (ret);
-
-  vec_free (vpn_ascii_id);
-  return ret;
-}
-
-static int
-api_dhcp_client_config (vat_main_t * vam)
-{
-  unformat_input_t *i = vam->input;
-  vl_api_dhcp_client_config_t *mp;
-  u32 sw_if_index;
-  u8 sw_if_index_set = 0;
-  u8 is_add = 1;
-  u8 *hostname = 0;
-  u8 disable_event = 0;
-  int ret;
-
-  /* Parse args required to build the message */
-  while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
-    {
-      if (unformat (i, "del"))
-       is_add = 0;
-      else
-       if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
-       sw_if_index_set = 1;
-      else if (unformat (i, "sw_if_index %d", &sw_if_index))
-       sw_if_index_set = 1;
-      else if (unformat (i, "hostname %s", &hostname))
-       ;
-      else if (unformat (i, "disable_event"))
-       disable_event = 1;
-      else
-       break;
-    }
-
-  if (sw_if_index_set == 0)
-    {
-      errmsg ("missing interface name or sw_if_index");
-      return -99;
-    }
-
-  if (vec_len (hostname) > 63)
-    {
-      errmsg ("hostname too long");
-    }
-  vec_add1 (hostname, 0);
-
-  /* Construct the API message */
-  M (DHCP_CLIENT_CONFIG, mp);
-
-  mp->is_add = is_add;
-  mp->client.sw_if_index = htonl (sw_if_index);
-  clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
-  vec_free (hostname);
-  mp->client.want_dhcp_event = disable_event ? 0 : 1;
-  mp->client.pid = htonl (getpid ());
-
-  /* send it... */
-  S (mp);
-
-  /* Wait for a reply, return good/bad news  */
-  W (ret);
-  return ret;
-}
-
 static int
 api_set_ip_flow_hash (vat_main_t * vam)
 {
@@ -21829,14 +21441,6 @@ _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n"               \
   "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n"    \
   "[outer_vlan_id_any][inner_vlan_id_any]")                             \
 _(reset_fib, "vrf <n> [ipv6]")                                          \
-_(dhcp_proxy_config,                                                    \
-  "svr <v46-address> src <v46-address>\n"                               \
-   "rx_vrf_id <nn> server_vrf_id <nn>  [del]")                          \
-_(dhcp_proxy_set_vss,                                                   \
-  "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
-_(dhcp_proxy_dump, "ip6")                                               \
-_(dhcp_client_config,                                                   \
-  "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
 _(set_ip_flow_hash,                                                     \
   "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]")       \
 _(sw_interface_ip6_enable_disable,                                      \