hs-test: added interrupt mode tests
[vpp.git] / src / plugins / dhcp / dhcp_api.c
index c5c7a82..1458db3 100644 (file)
@@ -76,12 +76,10 @@ vl_api_dhcp_plugin_control_ping_t_handler (vl_api_dhcp_plugin_control_ping_t *
   vl_api_dhcp_plugin_control_ping_reply_t *rmp;
   int rv = 0;
 
-  /* *INDENT-OFF* */
   REPLY_MACRO2 (VL_API_DHCP_PLUGIN_CONTROL_PING_REPLY,
   ({
     rmp->vpe_pid = ntohl (getpid ());
   }));
-  /* *INDENT-ON* */
 }
 
 static void
@@ -92,7 +90,7 @@ vl_api_dhcp6_duid_ll_set_t_handler (vl_api_dhcp6_duid_ll_set_t * mp)
   int rv = 0;
 
   duid = (dhcpv6_duid_ll_string_t *) mp->duid_ll;
-  if (duid->duid_type != htonl (DHCPV6_DUID_LL))
+  if (duid->duid_type != htons (DHCPV6_DUID_LL))
     {
       rv = VNET_API_ERROR_INVALID_VALUE;
       goto reply;
@@ -279,8 +277,8 @@ dhcp_client_lease_encode (vl_api_dhcp_lease_t * lease,
 
   lease->count = vec_len (client->domain_server_address);
   for (i = 0; i < lease->count; i++)
-    clib_memcpy (&lease->domain_server[i].address,
-                (u8 *) & client->domain_server_address[i],
+    clib_memcpy (&lease->domain_server[i].address.un.ip4,
+                (u8 *) &client->domain_server_address[i],
                 sizeof (ip4_address_t));
 
   clib_memcpy (&lease->host_mac[0], client->client_hardware_address, 6);
@@ -321,7 +319,9 @@ dhcp_compl_event_callback (u32 client_index, const dhcp_client_t * client)
   if (!reg)
     return;
 
-  mp = vl_msg_api_alloc (sizeof (*mp));
+  mp = vl_msg_api_alloc (sizeof (*mp) +
+                        sizeof (vl_api_domain_server_t) *
+                          vec_len (client->domain_server_address));
   mp->client_index = client_index;
   mp->pid = client->pid;
   dhcp_client_lease_encode (&mp->lease, client);
@@ -643,6 +643,31 @@ call_dhcp6_reply_event_callbacks (void *data,
   return error;
 }
 
+static void
+vl_api_dhcp_client_detect_enable_disable_t_handler (
+  vl_api_dhcp_client_detect_enable_disable_t *mp)
+{
+  vl_api_dhcp_client_detect_enable_disable_reply_t *rmp;
+  int rv = 0;
+  VALIDATE_SW_IF_INDEX (mp);
+
+  if (mp->enable)
+    {
+      vnet_feature_enable_disable ("ip4-unicast", "ip4-dhcp-client-detect",
+                                  clib_net_to_host_u32 (mp->sw_if_index),
+                                  1 /* enable */, 0, 0);
+    }
+  else
+    {
+      vnet_feature_enable_disable ("ip4-unicast", "ip4-dhcp-client-detect",
+                                  clib_net_to_host_u32 (mp->sw_if_index),
+                                  0 /* disable */, 0, 0);
+    }
+
+  BAD_SW_IF_INDEX_LABEL;
+
+  REPLY_MACRO (VL_API_DHCP_CLIENT_DETECT_ENABLE_DISABLE_REPLY);
+}
 static uword
 dhcp6_reply_process (vlib_main_t * vm, vlib_node_runtime_t * rt,
                     vlib_frame_t * f)
@@ -699,9 +724,8 @@ dhcp6_reply_process (vlib_main_t * vm, vlib_node_runtime_t * rt,
              call_dhcp6_reply_event_callbacks (event, dcpm->functions);
 
              vpe_client_registration_t *reg;
-              /* *INDENT-OFF* */
-              pool_foreach(reg, vpe_api_main.dhcp6_reply_events_registrations,
-              ({
+              pool_foreach (reg, vpe_api_main.dhcp6_reply_events_registrations)
+               {
                 vl_api_registration_t *vl_reg;
                 vl_reg =
                   vl_api_client_index_to_registration (reg->client_index);
@@ -715,8 +739,7 @@ dhcp6_reply_process (vlib_main_t * vm, vlib_node_runtime_t * rt,
                     msg->pid = reg->client_pid;
                     vl_api_send_msg (vl_reg, (u8 *) msg);
                   }
-              }));
-              /* *INDENT-ON* */
+              }
 
              clib_mem_free (event);
            }
@@ -727,13 +750,11 @@ dhcp6_reply_process (vlib_main_t * vm, vlib_node_runtime_t * rt,
   return 0;
 }
 
-/* *INDENT-OFF* */
 VLIB_REGISTER_NODE (dhcp6_reply_process_node) = {
   .function = dhcp6_reply_process,
   .type = VLIB_NODE_TYPE_PROCESS,
   .name = "dhcp6-reply-publisher-process",
 };
-/* *INDENT-ON* */
 
 static clib_error_t *
 call_dhcp6_pd_reply_event_callbacks (void *data,
@@ -811,9 +832,8 @@ dhcp6_pd_reply_process (vlib_main_t * vm, vlib_node_runtime_t * rt,
              call_dhcp6_pd_reply_event_callbacks (event, dpcpm->functions);
 
              vpe_client_registration_t *reg;
-              /* *INDENT-OFF* */
-              pool_foreach(reg, vpe_api_main.dhcp6_pd_reply_events_registrations,
-              ({
+              pool_foreach (reg, vpe_api_main.dhcp6_pd_reply_events_registrations)
+               {
                 vl_api_registration_t *vl_reg;
                 vl_reg =
                   vl_api_client_index_to_registration (reg->client_index);
@@ -827,8 +847,7 @@ dhcp6_pd_reply_process (vlib_main_t * vm, vlib_node_runtime_t * rt,
                     msg->pid = reg->client_pid;
                     vl_api_send_msg (vl_reg, (u8 *) msg);
                   }
-              }));
-              /* *INDENT-ON* */
+              }
 
              clib_mem_free (event);
            }
@@ -839,13 +858,11 @@ dhcp6_pd_reply_process (vlib_main_t * vm, vlib_node_runtime_t * rt,
   return 0;
 }
 
-/* *INDENT-OFF* */
 VLIB_REGISTER_NODE (dhcp6_pd_reply_process_node) = {
   .function = dhcp6_pd_reply_process,
   .type = VLIB_NODE_TYPE_PROCESS,
   .name = "dhcp6-pd-reply-publisher-process",
 };
-/* *INDENT-ON* */
 
 /*
  * dhcp_api_hookup
@@ -877,12 +894,10 @@ VLIB_API_INIT_FUNCTION (dhcp_api_hookup);
 #include <vlib/unix/plugin.h>
 #include <vpp/app/version.h>
 
-/* *INDENT-OFF* */
 VLIB_PLUGIN_REGISTER () = {
     .version = VPP_BUILD_VER,
     .description = "Dynamic Host Configuration Protocol (DHCP)",
 };
-/* *INDENT-ON* */
 
 /*
  * fd.io coding-style-patch-verification: ON