session: API cleanup

Use consistent API types.

Type: fix

Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
Change-Id: Ib752a3425c076eb53bc5255a48039cbb74b1fcce
Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
diff --git a/src/vcl/test/test_vcl.py b/src/vcl/test/test_vcl.py
index d7a44ed..d9346ba 100644
--- a/src/vcl/test/test_vcl.py
+++ b/src/vcl/test/test_vcl.py
@@ -120,9 +120,9 @@
             table_id += 1
 
         # Configure namespaces
-        self.vapi.app_namespace_add_del(namespace_id=b"1", secret=1234,
+        self.vapi.app_namespace_add_del(namespace_id="1", secret=1234,
                                         sw_if_index=self.loop0.sw_if_index)
-        self.vapi.app_namespace_add_del(namespace_id=b"2", secret=5678,
+        self.vapi.app_namespace_add_del(namespace_id="2", secret=5678,
                                         sw_if_index=self.loop1.sw_if_index)
 
         # Add inter-table routes
@@ -161,9 +161,9 @@
             table_id += 1
 
         # Configure namespaces
-        self.vapi.app_namespace_add_del(namespace_id=b"1", secret=1234,
+        self.vapi.app_namespace_add_del(namespace_id="1", secret=1234,
                                         sw_if_index=self.loop0.sw_if_index)
-        self.vapi.app_namespace_add_del(namespace_id=b"2", secret=5678,
+        self.vapi.app_namespace_add_del(namespace_id="2", secret=5678,
                                         sw_if_index=self.loop1.sw_if_index)
 
         # Add inter-table routes
diff --git a/src/vcl/vcl_bapi.c b/src/vcl/vcl_bapi.c
index efa5cc1..af2eb03 100644
--- a/src/vcl/vcl_bapi.c
+++ b/src/vcl/vcl_bapi.c
@@ -73,8 +73,9 @@
   vcl_worker_t *wrk = vcl_worker_get (0);
   svm_msg_q_t *ctrl_mq;
   u64 segment_handle;
-  int *fds = 0, i;
+  int *fds = 0, i, rv;
   u32 n_fds = 0;
+  char *segment_name = 0;
 
   if (mp->retval)
     {
@@ -108,9 +109,16 @@
 	  goto failed;
 
       if (mp->fd_flags & SESSION_FD_F_MEMFD_SEGMENT)
-	if (vcl_segment_attach (segment_handle, (char *) mp->segment_name,
-				SSVM_SEGMENT_MEMFD, fds[n_fds++]))
-	  goto failed;
+	{
+	  segment_name = vl_api_from_api_to_new_c_string (&mp->segment_name);
+	  rv =
+	    vcl_segment_attach (segment_handle, segment_name,
+				SSVM_SEGMENT_MEMFD, fds[n_fds++]);
+	  vec_free (segment_name);
+	  if (rv != 0)
+	    goto failed;
+	}
+
 
       if (mp->fd_flags & SESSION_FD_F_MQ_EVENTFD)
 	{
@@ -123,8 +131,12 @@
     }
   else
     {
-      if (vcl_segment_attach (segment_handle, (char *) mp->segment_name,
-			      SSVM_SEGMENT_SHM, -1))
+      segment_name = vl_api_from_api_to_new_c_string (&mp->segment_name);
+      rv =
+	vcl_segment_attach (segment_handle, segment_name, SSVM_SEGMENT_SHM,
+			    -1);
+      vec_free (segment_name);
+      if (rv != 0)
 	goto failed;
     }
 
@@ -143,10 +155,11 @@
 vl_api_app_worker_add_del_reply_t_handler (vl_api_app_worker_add_del_reply_t *
 					   mp)
 {
-  int n_fds = 0, *fds = 0, i;
+  int n_fds = 0, *fds = 0, i, rv;
   u64 segment_handle;
   vcl_worker_t *wrk;
   u32 wrk_index;
+  char *segment_name = 0;
 
   if (mp->retval)
     {
@@ -189,9 +202,15 @@
 	  goto failed;
 
       if (mp->fd_flags & SESSION_FD_F_MEMFD_SEGMENT)
-	if (vcl_segment_attach (segment_handle, (char *) mp->segment_name,
-				SSVM_SEGMENT_MEMFD, fds[n_fds++]))
-	  goto failed;
+	{
+	  segment_name = vl_api_from_api_to_new_c_string (&mp->segment_name);
+	  rv =
+	    vcl_segment_attach (segment_handle, segment_name,
+				SSVM_SEGMENT_MEMFD, fds[n_fds++]);
+	  vec_free (segment_name);
+	  if (rv != 0)
+	    goto failed;
+	}
 
       if (mp->fd_flags & SESSION_FD_F_MQ_EVENTFD)
 	{
@@ -204,8 +223,12 @@
     }
   else
     {
-      if (vcl_segment_attach (segment_handle, (char *) mp->segment_name,
-			      SSVM_SEGMENT_SHM, -1))
+      segment_name = vl_api_from_api_to_new_c_string (&mp->segment_name);
+      rv =
+	vcl_segment_attach (segment_handle, segment_name, SSVM_SEGMENT_SHM,
+			    -1);
+      vec_free (segment_name);
+      if (rv != 0)
 	goto failed;
     }
   vcm->app_state = STATE_APP_READY;
@@ -313,8 +336,7 @@
   bmp->options[APP_OPTIONS_TLS_ENGINE] = tls_engine;
   if (nsid_len)
     {
-      bmp->namespace_id_len = nsid_len;
-      clib_memcpy_fast (bmp->namespace_id, vcm->cfg.namespace_id, nsid_len);
+      vl_api_vec_to_api_string (vcm->cfg.namespace_id, &bmp->namespace_id);
       bmp->options[APP_OPTIONS_NAMESPACE_SECRET] = vcm->cfg.namespace_secret;
     }
   vl_msg_api_send_shmem (wrk->vl_input_queue, (u8 *) & bmp);
diff --git a/src/vcl/vcl_private.c b/src/vcl/vcl_private.c
index f041a86..3cb76c6 100644
--- a/src/vcl/vcl_private.c
+++ b/src/vcl/vcl_private.c
@@ -383,7 +383,7 @@
   int rv;
 
   memset (a, 0, sizeof (*a));
-  a->segment_name = (char *) name;
+  a->segment_name = name;
   a->segment_type = type;
 
   if (type == SSVM_SEGMENT_MEMFD)