fib: fib api updates
[vpp.git] / src / plugins / abf / abf_api.c
index bf25669..a14c900 100644 (file)
@@ -72,24 +72,20 @@ static void
 vl_api_abf_plugin_get_version_t_handler (vl_api_abf_plugin_get_version_t * mp)
 {
   vl_api_abf_plugin_get_version_reply_t *rmp;
-  int msg_size = sizeof (*rmp);
-  unix_shared_memory_queue_t *q;
+  vl_api_registration_t *rp;
 
-  q = vl_api_client_index_to_input_queue (mp->client_index);
-  if (q == 0)
-    {
-      return;
-    }
+  rp = vl_api_client_index_to_registration (mp->client_index);
+  if (rp == 0)
+    return;
 
-  rmp = vl_msg_api_alloc (msg_size);
-  clib_memset (rmp, 0, msg_size);
+  rmp = vl_msg_api_alloc (sizeof (*rmp));
   rmp->_vl_msg_id =
     ntohs (VL_API_ABF_PLUGIN_GET_VERSION_REPLY + abf_base_msg_id);
   rmp->context = mp->context;
   rmp->major = htonl (ABF_PLUGIN_VERSION_MAJOR);
   rmp->minor = htonl (ABF_PLUGIN_VERSION_MINOR);
 
-  vl_msg_api_send_shmem (q, (u8 *) & rmp);
+  vl_api_send_msg (rp, (u8 *) rmp);
 }
 
 static void
@@ -105,7 +101,7 @@ vl_api_abf_policy_add_del_t_handler (vl_api_abf_policy_add_del_t * mp)
   for (pi = 0; pi < mp->policy.n_paths; pi++)
     {
       path = &paths[pi];
-      rv = fib_path_api_parse (&mp->policy.paths[pi], path);
+      rv = fib_api_path_decode (&mp->policy.paths[pi], path);
 
       if (0 != rv)
        {
@@ -115,12 +111,12 @@ vl_api_abf_policy_add_del_t_handler (vl_api_abf_policy_add_del_t * mp)
 
   if (mp->is_add)
     {
-      abf_policy_update (ntohl (mp->policy.policy_id),
-                        ntohl (mp->policy.acl_index), paths);
+      rv = abf_policy_update (ntohl (mp->policy.policy_id),
+                             ntohl (mp->policy.acl_index), paths);
     }
   else
     {
-      abf_policy_delete (ntohl (mp->policy.policy_id), paths);
+      rv = abf_policy_delete (ntohl (mp->policy.policy_id), paths);
     }
 done:
   vec_free (paths);
@@ -155,16 +151,19 @@ vl_api_abf_itf_attach_add_del_t_handler (vl_api_abf_itf_attach_add_del_t * mp)
 
 typedef struct abf_dump_walk_ctx_t_
 {
-  unix_shared_memory_queue_t *q;
+  vl_api_registration_t *rp;
   u32 context;
 } abf_dump_walk_ctx_t;
 
 static int
 abf_policy_send_details (u32 api, void *args)
 {
-  fib_route_path_encode_t *api_rpaths = NULL, *api_rpath;
+  fib_path_encode_ctx_t walk_ctx = {
+    .rpaths = NULL,
+  };
   vl_api_abf_policy_details_t *mp;
   abf_dump_walk_ctx_t *ctx;
+  fib_route_path_t *rpath;
   vl_api_fib_path_t *fp;
   size_t msg_size;
   abf_policy_t *ap;
@@ -185,16 +184,18 @@ abf_policy_send_details (u32 api, void *args)
   mp->policy.acl_index = htonl (ap->ap_acl);
   mp->policy.policy_id = htonl (ap->ap_id);
 
-  fib_path_list_walk_w_ext (ap->ap_pl, NULL, fib_path_encode, &api_rpaths);
+  fib_path_list_walk_w_ext (ap->ap_pl, NULL, fib_path_encode, &walk_ctx);
 
   fp = mp->policy.paths;
-  vec_foreach (api_rpath, api_rpaths)
+  vec_foreach (rpath, walk_ctx.rpaths)
   {
-    fib_api_path_encode (api_rpath, fp);
+    fib_api_path_encode (rpath, fp);
     fp++;
   }
 
-  vl_msg_api_send_shmem (ctx->q, (u8 *) & mp);
+  vl_api_send_msg (ctx->rp, (u8 *) mp);
+
+  vec_free (walk_ctx.rpaths);
 
   return (1);
 }
@@ -202,16 +203,14 @@ abf_policy_send_details (u32 api, void *args)
 static void
 vl_api_abf_policy_dump_t_handler (vl_api_abf_policy_dump_t * mp)
 {
-  unix_shared_memory_queue_t *q;
+  vl_api_registration_t *rp;
 
-  q = vl_api_client_index_to_input_queue (mp->client_index);
-  if (q == 0)
-    {
-      return;
-    }
+  rp = vl_api_client_index_to_registration (mp->client_index);
+  if (rp == 0)
+    return;
 
   abf_dump_walk_ctx_t ctx = {
-    .q = q,
+    .rp = rp,
     .context = mp->context,
   };
 
@@ -239,7 +238,7 @@ abf_itf_attach_send_details (u32 aiai, void *args)
   mp->attach.priority = htonl (aia->aia_prio);
   mp->attach.is_ipv6 = (aia->aia_proto == FIB_PROTOCOL_IP6);
 
-  vl_msg_api_send_shmem (ctx->q, (u8 *) & mp);
+  vl_api_send_msg (ctx->rp, (u8 *) mp);
 
   return (1);
 }
@@ -247,16 +246,14 @@ abf_itf_attach_send_details (u32 aiai, void *args)
 static void
 vl_api_abf_itf_attach_dump_t_handler (vl_api_abf_itf_attach_dump_t * mp)
 {
-  unix_shared_memory_queue_t *q;
+  vl_api_registration_t *rp;
 
-  q = vl_api_client_index_to_input_queue (mp->client_index);
-  if (q == 0)
-    {
-      return;
-    }
+  rp = vl_api_client_index_to_registration (mp->client_index);
+  if (rp == 0)
+    return;
 
   abf_dump_walk_ctx_t ctx = {
-    .q = q,
+    .rp = rp,
     .context = mp->context,
   };
 
@@ -320,7 +317,7 @@ VLIB_INIT_FUNCTION (abf_api_init);
 /* *INDENT-OFF* */
 VLIB_PLUGIN_REGISTER () = {
     .version = VPP_BUILD_VER,
-    .description = "ACL based Forwarding",
+    .description = "Access Control List (ACL) Based Forwarding",
 };
 /* *INDENT-ON* */