locked VPP Socket API how to use from the application #socket-api #vpp #sock-api


RaviKiran Veldanda
 

Hi Experts,
I was trying to find out how to use socket-api instead of "VAPI" based API.
Can you please provide how to use socket-api any pointer will be a great help.
//Ravi


Ole Troan
 

Ravi,

The VPP binary API supports two transports. Shared memory and unix domain sockets.
VAPI is the C language binding for the binary API. I think it only supports shared memory now.

Other language bindings support both or only sockets.

Cheers,
Ole

On 22 Sep 2021, at 20:31, RaviKiran Veldanda <ravi.jupvpp@...> wrote:

Hi Experts,
I was trying to find out how to use socket-api instead of "VAPI" based API.
Can you please provide how to use socket-api any pointer will be a great help.
//Ravi


RaviKiran Veldanda
 

Hi Ole,
Thanks for your response, I have a question on other language, 
So we don't have any SOCKET API support for C/C++? 
The socket API support is possible with go/python right?
//Ravi


Ole Troan
 

Ravi,

Thanks for your response, I have a question on other language,
So we don't have any SOCKET API support for C/C++?
The socket API support is possible with go/python right?
Yes, contributions to VAPI for socket transport is of course welcome!

Best regards,
Ole


Venumadhav Josyula
 

Hi Ole,

Any examples for VAPI shared to use binary APIs ?

Thanks,
Regards,
Venu


On Thu, 23 Sept 2021 at 00:26, Ole Troan <otroan@...> wrote:
Ravi,

The VPP binary API supports two transports. Shared memory and unix domain sockets.
VAPI is the C language binding for the binary API. I think it only supports shared memory now.

Other language bindings support both or only sockets.

Cheers,
Ole

> On 22 Sep 2021, at 20:31, RaviKiran Veldanda <ravi.jupvpp@...> wrote:
>
> Hi Experts,
> I was trying to find out how to use socket-api instead of "VAPI" based API.
> Can you please provide how to use socket-api any pointer will be a great help.
> //Ravi
>
>




Ole Troan
 

Hi Venu,

Any examples for VAPI shared to use binary APIs ?
Try this for a start:
https://git.fd.io/vpp/tree/src/vpp-api/vapi/vapi_c_test.c

Cheers,
Ole


Venumadhav Josyula
 

Hi Ole / Others,

Thanks for your email, i getting following compilation error
[root@8f57181df3a1 vpp_c_api_examples]# gcc vpp_api_client_test3.c -o vpp_api_client_test3.o -lvlibmemoryclient -lsvm -lvppinfra -lvlib
In file included from /usr/include/vppinfra/error.h:41:0,
                 from /usr/include/vlibapi/api.h:24,
                 from vpp_api_client_test3.c:3:
/usr/include/vppinfra/clib.h:43:18: error: missing binary operator before token "("
 #if __has_include(<vppinfra/config.h>)
                  ^
In file included from /usr/include/vppinfra/mem.h:49:0,
                 from /usr/include/vppinfra/vec.h:42,
                 from /usr/include/vppinfra/error.h:53,
                 from /usr/include/vlibapi/api.h:24,
                 from vpp_api_client_test3.c:3:
/usr/include/vppinfra/string.h:92:34: error: expected ';', ',' or ')' before 'dst'
 clib_memcpy_fast (void *restrict dst, const void *restrict src, size_t n)
                                  ^
[root@8f57181df3a1 vpp_c_api_examples]# vim /usr/include/vppinfra/clib.h +43
[root@8f57181df3a1 vpp_c_api_examples]# vim /usr/include/vppinfra/clib.h +43
[root@8f57181df3a1 vpp_c_api_examples]# gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[root@8f57181df3a1 vpp_c_api_examples]#

-----------------
c -code
----------------

#include<stdio.h>
#include<stdlib.h>
#include <vlibapi/api.h>
#include <vlibmemory/api.h>
#include <vpp/api/vpe_msg_enum.h>

#define vl_typedefs
#define vl_endianfun
#include <vpp/api/vpe_all_api_h.h>
#undef vl_typedefs
#undef vl_endianfun

int main()
{
   char *name = "vpp-test-app";

   clib_mem_init_thread_safe (0, 64ULL << 20);

   if (vl_client_api_map("/vpe-api"))
   {
        printf("unable to map....\n");
        goto quit;
   }
   if (vl_client_connect("vpp-test-app", 0, 32) < 0)
   {
        printf("unable to connect \n");
        vl_client_api_unmap();
        goto quit;
   }
   printf("successfully connected... \n");
 quit:
        return 0;
}

------------

Can you please suggest what can i be doing worng ?

Thanks,
Regards,
Venu


On Thu, 30 Sept 2021 at 13:21, <otroan@...> wrote:
Hi Venu,

> Any examples for VAPI shared to use binary APIs ?

Try this for a start:
https://git.fd.io/vpp/tree/src/vpp-api/vapi/vapi_c_test.c

Cheers,
Ole


Benoit Ganne (bganne)
 

You should upgrade your compiler... GCC-4 is way too old.
Eg. use devtoolset-9 (gcc-9).

Best
ben

-----Original Message-----
From: vpp-dev@... <vpp-dev@...> On Behalf Of Venumadhav
Josyula
Sent: jeudi 30 septembre 2021 14:49
To: otroan@...
Cc: RaviKiran Veldanda <ravi.jupvpp@...>; vpp-dev <vpp-
dev@...>
Subject: Re: [vpp-dev] VPP Socket API how to use from the application
#socket-api #vpp #sock-api

Hi Ole / Others,



Thanks for your email, i getting following compilation error
[root@8f57181df3a1 vpp_c_api_examples]# gcc vpp_api_client_test3.c -o
vpp_api_client_test3.o -lvlibmemoryclient -lsvm -lvppinfra -lvlib
In file included from /usr/include/vppinfra/error.h:41:0,
from /usr/include/vlibapi/api.h:24,
from vpp_api_client_test3.c:3:
/usr/include/vppinfra/clib.h:43:18: error: missing binary operator before
token "("
#if __has_include(<vppinfra/config.h>)
^
In file included from /usr/include/vppinfra/mem.h:49:0,
from /usr/include/vppinfra/vec.h:42,
from /usr/include/vppinfra/error.h:53,
from /usr/include/vlibapi/api.h:24,
from vpp_api_client_test3.c:3:
/usr/include/vppinfra/string.h:92:34: error: expected ';', ',' or ')'
before 'dst'
clib_memcpy_fast (void *restrict dst, const void *restrict src, size_t n)
^
[root@8f57181df3a1 vpp_c_api_examples]# vim /usr/include/vppinfra/clib.h
+43
[root@8f57181df3a1 vpp_c_api_examples]# vim /usr/include/vppinfra/clib.h
+43
[root@8f57181df3a1 vpp_c_api_examples]# gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

[root@8f57181df3a1 vpp_c_api_examples]#


-----------------

c -code
----------------


#include<stdio.h>
#include<stdlib.h>
#include <vlibapi/api.h>
#include <vlibmemory/api.h>
#include <vpp/api/vpe_msg_enum.h>

#define vl_typedefs
#define vl_endianfun
#include <vpp/api/vpe_all_api_h.h>
#undef vl_typedefs
#undef vl_endianfun

int main()
{
char *name = "vpp-test-app";

clib_mem_init_thread_safe (0, 64ULL << 20);

if (vl_client_api_map("/vpe-api"))
{
printf("unable to map....\n");
goto quit;
}
if (vl_client_connect("vpp-test-app", 0, 32) < 0)
{
printf("unable to connect \n");
vl_client_api_unmap();
goto quit;
}
printf("successfully connected... \n");
quit:
return 0;
}


------------


Can you please suggest what can i be doing worng ?


Thanks,
Regards,
Venu


On Thu, 30 Sept 2021 at 13:21, <otroan@...
<mailto:otroan@...> > wrote:


Hi Venu,

> Any examples for VAPI shared to use binary APIs ?

Try this for a start:
https://git.fd.io/vpp/tree/src/vpp-api/vapi/vapi_c_test.c

Cheers,
Ole


Venumadhav Josyula
 

Hi Benoit,

Thanks for quick reply.

I have docker with following
[root@8f57181df3a1 vpp_c_api_examples]# rpm -qa | grep vpp
vpp-lib-21.06.0-4~g0d9d3a0.x86_64
vpp-api-lua-21.06.0-4~g0d9d3a0.x86_64
vpp-api-python3-21.06.0-4~g0d9d3a0.x86_64
vpp-debuginfo-21.06.0-4~g0d9d3a0.x86_64
vpp-selinux-policy-21.06.0-4~g0d9d3a0.x86_64
vpp-21.06.0-4~g0d9d3a0.x86_64
vpp-plugins-21.06.0-4~g0d9d3a0.x86_64
vpp-devel-21.06.0-4~g0d9d3a0.x86_64

This will vpp running in it.

[root@8f57181df3a1 /]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
[root@8f57181df3a1 /]#

> Eg. use devtoolset-9 (gcc-9).

How do I use it ?

Thanks,
Regards,
Venu


On Thu, 30 Sept 2021 at 18:47, Benoit Ganne (bganne) <bganne@...> wrote:
You should upgrade your compiler... GCC-4 is way too old.
Eg. use devtoolset-9 (gcc-9).

Best
ben

> -----Original Message-----
> From: vpp-dev@... <vpp-dev@...> On Behalf Of Venumadhav
> Josyula
> Sent: jeudi 30 septembre 2021 14:49
> To: otroan@...
> Cc: RaviKiran Veldanda <ravi.jupvpp@...>; vpp-dev <vpp-
> dev@...>
> Subject: Re: [vpp-dev] VPP Socket API how to use from the application
> #socket-api #vpp #sock-api
>
> Hi Ole / Others,
>
>
>
> Thanks for your email, i getting following compilation error
> [root@8f57181df3a1 vpp_c_api_examples]# gcc vpp_api_client_test3.c -o
> vpp_api_client_test3.o -lvlibmemoryclient -lsvm -lvppinfra -lvlib
> In file included from /usr/include/vppinfra/error.h:41:0,
>                  from /usr/include/vlibapi/api.h:24,
>                  from vpp_api_client_test3.c:3:
> /usr/include/vppinfra/clib.h:43:18: error: missing binary operator before
> token "("
>  #if __has_include(<vppinfra/config.h>)
>                   ^
> In file included from /usr/include/vppinfra/mem.h:49:0,
>                  from /usr/include/vppinfra/vec.h:42,
>                  from /usr/include/vppinfra/error.h:53,
>                  from /usr/include/vlibapi/api.h:24,
>                  from vpp_api_client_test3.c:3:
> /usr/include/vppinfra/string.h:92:34: error: expected ';', ',' or ')'
> before 'dst'
>  clib_memcpy_fast (void *restrict dst, const void *restrict src, size_t n)
>                                   ^
> [root@8f57181df3a1 vpp_c_api_examples]# vim /usr/include/vppinfra/clib.h
> +43
> [root@8f57181df3a1 vpp_c_api_examples]# vim /usr/include/vppinfra/clib.h
> +43
> [root@8f57181df3a1 vpp_c_api_examples]# gcc --version
> gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
> Copyright (C) 2015 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
> PURPOSE.
>
> [root@8f57181df3a1 vpp_c_api_examples]#
>
>
> -----------------
>
> c -code
> ----------------
>
>
> #include<stdio.h>
> #include<stdlib.h>
> #include <vlibapi/api.h>
> #include <vlibmemory/api.h>
> #include <vpp/api/vpe_msg_enum.h>
>
> #define vl_typedefs
> #define vl_endianfun
> #include <vpp/api/vpe_all_api_h.h>
> #undef vl_typedefs
> #undef vl_endianfun
>
> int main()
> {
>    char *name = "vpp-test-app";
>
>    clib_mem_init_thread_safe (0, 64ULL << 20);
>
>    if (vl_client_api_map("/vpe-api"))
>    {
>         printf("unable to map....\n");
>         goto quit;
>    }
>    if (vl_client_connect("vpp-test-app", 0, 32) < 0)
>    {
>         printf("unable to connect \n");
>         vl_client_api_unmap();
>         goto quit;
>    }
>    printf("successfully connected... \n");
>  quit:
>         return 0;
> }
>
>
> ------------
>
>
> Can you please suggest what can i be doing worng ?
>
>
> Thanks,
> Regards,
> Venu
>
>
> On Thu, 30 Sept 2021 at 13:21, <otroan@...
> <mailto:otroan@...> > wrote:
>
>
>       Hi Venu,
>
>       > Any examples for VAPI shared to use binary APIs ?
>
>       Try this for a start:
>       https://git.fd.io/vpp/tree/src/vpp-api/vapi/vapi_c_test.c
>
>       Cheers,
>       Ole
>
>


Akash S R
 

Hey Venu,

Try "scl enable devtoolset-9 bash" inside your docker or update your gcc version.


/Akash S R

On Thu, Sep 30, 2021, 18:54 Venumadhav Josyula <vjosyula@...> wrote:
Hi Benoit,

Thanks for quick reply.

I have docker with following
[root@8f57181df3a1 vpp_c_api_examples]# rpm -qa | grep vpp
vpp-lib-21.06.0-4~g0d9d3a0.x86_64
vpp-api-lua-21.06.0-4~g0d9d3a0.x86_64
vpp-api-python3-21.06.0-4~g0d9d3a0.x86_64
vpp-debuginfo-21.06.0-4~g0d9d3a0.x86_64
vpp-selinux-policy-21.06.0-4~g0d9d3a0.x86_64
vpp-21.06.0-4~g0d9d3a0.x86_64
vpp-plugins-21.06.0-4~g0d9d3a0.x86_64
vpp-devel-21.06.0-4~g0d9d3a0.x86_64

This will vpp running in it.

[root@8f57181df3a1 /]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
[root@8f57181df3a1 /]#

> Eg. use devtoolset-9 (gcc-9).

How do I use it ?

Thanks,
Regards,
Venu

On Thu, 30 Sept 2021 at 18:47, Benoit Ganne (bganne) <bganne@...> wrote:
You should upgrade your compiler... GCC-4 is way too old.
Eg. use devtoolset-9 (gcc-9).

Best
ben

> -----Original Message-----
> From: vpp-dev@... <vpp-dev@...> On Behalf Of Venumadhav
> Josyula
> Sent: jeudi 30 septembre 2021 14:49
> To: otroan@...
> Cc: RaviKiran Veldanda <ravi.jupvpp@...>; vpp-dev <vpp-
> dev@...>
> Subject: Re: [vpp-dev] VPP Socket API how to use from the application
> #socket-api #vpp #sock-api
>
> Hi Ole / Others,
>
>
>
> Thanks for your email, i getting following compilation error
> [root@8f57181df3a1 vpp_c_api_examples]# gcc vpp_api_client_test3.c -o
> vpp_api_client_test3.o -lvlibmemoryclient -lsvm -lvppinfra -lvlib
> In file included from /usr/include/vppinfra/error.h:41:0,
>                  from /usr/include/vlibapi/api.h:24,
>                  from vpp_api_client_test3.c:3:
> /usr/include/vppinfra/clib.h:43:18: error: missing binary operator before
> token "("
>  #if __has_include(<vppinfra/config.h>)
>                   ^
> In file included from /usr/include/vppinfra/mem.h:49:0,
>                  from /usr/include/vppinfra/vec.h:42,
>                  from /usr/include/vppinfra/error.h:53,
>                  from /usr/include/vlibapi/api.h:24,
>                  from vpp_api_client_test3.c:3:
> /usr/include/vppinfra/string.h:92:34: error: expected ';', ',' or ')'
> before 'dst'
>  clib_memcpy_fast (void *restrict dst, const void *restrict src, size_t n)
>                                   ^
> [root@8f57181df3a1 vpp_c_api_examples]# vim /usr/include/vppinfra/clib.h
> +43
> [root@8f57181df3a1 vpp_c_api_examples]# vim /usr/include/vppinfra/clib.h
> +43
> [root@8f57181df3a1 vpp_c_api_examples]# gcc --version
> gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
> Copyright (C) 2015 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
> PURPOSE.
>
> [root@8f57181df3a1 vpp_c_api_examples]#
>
>
> -----------------
>
> c -code
> ----------------
>
>
> #include<stdio.h>
> #include<stdlib.h>
> #include <vlibapi/api.h>
> #include <vlibmemory/api.h>
> #include <vpp/api/vpe_msg_enum.h>
>
> #define vl_typedefs
> #define vl_endianfun
> #include <vpp/api/vpe_all_api_h.h>
> #undef vl_typedefs
> #undef vl_endianfun
>
> int main()
> {
>    char *name = "vpp-test-app";
>
>    clib_mem_init_thread_safe (0, 64ULL << 20);
>
>    if (vl_client_api_map("/vpe-api"))
>    {
>         printf("unable to map....\n");
>         goto quit;
>    }
>    if (vl_client_connect("vpp-test-app", 0, 32) < 0)
>    {
>         printf("unable to connect \n");
>         vl_client_api_unmap();
>         goto quit;
>    }
>    printf("successfully connected... \n");
>  quit:
>         return 0;
> }
>
>
> ------------
>
>
> Can you please suggest what can i be doing worng ?
>
>
> Thanks,
> Regards,
> Venu
>
>
> On Thu, 30 Sept 2021 at 13:21, <otroan@...
> <mailto:otroan@...> > wrote:
>
>
>       Hi Venu,
>
>       > Any examples for VAPI shared to use binary APIs ?
>
>       Try this for a start:
>       https://git.fd.io/vpp/tree/src/vpp-api/vapi/vapi_c_test.c
>
>       Cheers,
>       Ole
>
>





Venumadhav Josyula
 

Hi Akash,

Thansks, now after devtoolset,

i am getting following error

[root@8f57181df3a1 vpp_c_api_examples]# gcc vpp_api_client_test3.c -o vpp_api_client_test3.o -lvlibmemoryclient -lsvm -lvppinfra -lvlib
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: /lib/../lib64/libvlib.so: undefined reference to `classify_get_trace_chain'
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: /lib/../lib64/libvlib.so: undefined reference to `stat_segment_register_gauge'
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: /lib/../lib64/libvlib.so: undefined reference to `os_exit'
collect2: error: ld returned 1 exit status
[root@8f57181df3a1 vpp_c_api_examples]#

Let me paste the code again,
#include<stdio.h>
#include<stdlib.h>
#include <vlibapi/api.h>
#include <vlibmemory/api.h>
#include <vpp/api/vpe_msg_enum.h>

#define vl_typedefs
#define vl_endianfun
#include <vpp/api/vpe_all_api_h.h>
#undef vl_typedefs
#undef vl_endianfun

int main()
{
   char *name = "vpp-test-app";

   clib_mem_init_thread_safe (0, 64ULL << 20);

   if (vl_client_api_map("/vpe-api"))
   {
        printf("unable to map....\n");
        goto quit;
   }
   if (vl_client_connect("vpp-test-app", 0, 32) < 0)
   {
        printf("unable to connect \n");
        vl_client_api_unmap();
        goto quit;
   }
   printf("successfully connected... \n");
 quit:
        return 0;
}

Is this wrong way, i am trying to use APIs ?

Thanks,
Regards
Venu


On Thu, 30 Sept 2021 at 19:00, Akash S R <akashsr.akashsr@...> wrote:
Hey Venu,

Try "scl enable devtoolset-9 bash" inside your docker or update your gcc version.


/Akash S R

On Thu, Sep 30, 2021, 18:54 Venumadhav Josyula <vjosyula@...> wrote:
Hi Benoit,

Thanks for quick reply.

I have docker with following
[root@8f57181df3a1 vpp_c_api_examples]# rpm -qa | grep vpp
vpp-lib-21.06.0-4~g0d9d3a0.x86_64
vpp-api-lua-21.06.0-4~g0d9d3a0.x86_64
vpp-api-python3-21.06.0-4~g0d9d3a0.x86_64
vpp-debuginfo-21.06.0-4~g0d9d3a0.x86_64
vpp-selinux-policy-21.06.0-4~g0d9d3a0.x86_64
vpp-21.06.0-4~g0d9d3a0.x86_64
vpp-plugins-21.06.0-4~g0d9d3a0.x86_64
vpp-devel-21.06.0-4~g0d9d3a0.x86_64

This will vpp running in it.

[root@8f57181df3a1 /]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
[root@8f57181df3a1 /]#

> Eg. use devtoolset-9 (gcc-9).

How do I use it ?

Thanks,
Regards,
Venu

On Thu, 30 Sept 2021 at 18:47, Benoit Ganne (bganne) <bganne@...> wrote:
You should upgrade your compiler... GCC-4 is way too old.
Eg. use devtoolset-9 (gcc-9).

Best
ben

> -----Original Message-----
> From: vpp-dev@... <vpp-dev@...> On Behalf Of Venumadhav
> Josyula
> Sent: jeudi 30 septembre 2021 14:49
> To: otroan@...
> Cc: RaviKiran Veldanda <ravi.jupvpp@...>; vpp-dev <vpp-
> dev@...>
> Subject: Re: [vpp-dev] VPP Socket API how to use from the application
> #socket-api #vpp #sock-api
>
> Hi Ole / Others,
>
>
>
> Thanks for your email, i getting following compilation error
> [root@8f57181df3a1 vpp_c_api_examples]# gcc vpp_api_client_test3.c -o
> vpp_api_client_test3.o -lvlibmemoryclient -lsvm -lvppinfra -lvlib
> In file included from /usr/include/vppinfra/error.h:41:0,
>                  from /usr/include/vlibapi/api.h:24,
>                  from vpp_api_client_test3.c:3:
> /usr/include/vppinfra/clib.h:43:18: error: missing binary operator before
> token "("
>  #if __has_include(<vppinfra/config.h>)
>                   ^
> In file included from /usr/include/vppinfra/mem.h:49:0,
>                  from /usr/include/vppinfra/vec.h:42,
>                  from /usr/include/vppinfra/error.h:53,
>                  from /usr/include/vlibapi/api.h:24,
>                  from vpp_api_client_test3.c:3:
> /usr/include/vppinfra/string.h:92:34: error: expected ';', ',' or ')'
> before 'dst'
>  clib_memcpy_fast (void *restrict dst, const void *restrict src, size_t n)
>                                   ^
> [root@8f57181df3a1 vpp_c_api_examples]# vim /usr/include/vppinfra/clib.h
> +43
> [root@8f57181df3a1 vpp_c_api_examples]# vim /usr/include/vppinfra/clib.h
> +43
> [root@8f57181df3a1 vpp_c_api_examples]# gcc --version
> gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
> Copyright (C) 2015 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
> PURPOSE.
>
> [root@8f57181df3a1 vpp_c_api_examples]#
>
>
> -----------------
>
> c -code
> ----------------
>
>
> #include<stdio.h>
> #include<stdlib.h>
> #include <vlibapi/api.h>
> #include <vlibmemory/api.h>
> #include <vpp/api/vpe_msg_enum.h>
>
> #define vl_typedefs
> #define vl_endianfun
> #include <vpp/api/vpe_all_api_h.h>
> #undef vl_typedefs
> #undef vl_endianfun
>
> int main()
> {
>    char *name = "vpp-test-app";
>
>    clib_mem_init_thread_safe (0, 64ULL << 20);
>
>    if (vl_client_api_map("/vpe-api"))
>    {
>         printf("unable to map....\n");
>         goto quit;
>    }
>    if (vl_client_connect("vpp-test-app", 0, 32) < 0)
>    {
>         printf("unable to connect \n");
>         vl_client_api_unmap();
>         goto quit;
>    }
>    printf("successfully connected... \n");
>  quit:
>         return 0;
> }
>
>
> ------------
>
>
> Can you please suggest what can i be doing worng ?
>
>
> Thanks,
> Regards,
> Venu
>
>
> On Thu, 30 Sept 2021 at 13:21, <otroan@...
> <mailto:otroan@...> > wrote:
>
>
>       Hi Venu,
>
>       > Any examples for VAPI shared to use binary APIs ?
>
>       Try this for a start:
>       https://git.fd.io/vpp/tree/src/vpp-api/vapi/vapi_c_test.c
>
>       Cheers,
>       Ole
>
>





Akash S R
 

Hi Venu,

can I answer this query? just asking as I have not been asked this :)

I guess you are using centos and I have good experience on this.
print LD_LIBRARY_PATH and set the path to the path it says in error. Then push all the .so and other library files of VPP into this path and try.

Also mention the path of your VPP /include directory and /library path in the compilation.


/Akash

On Thu, Sep 30, 2021, 19:39 Venumadhav Josyula <vjosyula@...> wrote:
Hi Akash,

Thansks, now after devtoolset,

i am getting following error

[root@8f57181df3a1 vpp_c_api_examples]# gcc vpp_api_client_test3.c -o vpp_api_client_test3.o -lvlibmemoryclient -lsvm -lvppinfra -lvlib
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: /lib/../lib64/libvlib.so: undefined reference to `classify_get_trace_chain'
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: /lib/../lib64/libvlib.so: undefined reference to `stat_segment_register_gauge'
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: /lib/../lib64/libvlib.so: undefined reference to `os_exit'
collect2: error: ld returned 1 exit status
[root@8f57181df3a1 vpp_c_api_examples]#

Let me paste the code again,
#include<stdio.h>
#include<stdlib.h>
#include <vlibapi/api.h>
#include <vlibmemory/api.h>
#include <vpp/api/vpe_msg_enum.h>

#define vl_typedefs
#define vl_endianfun
#include <vpp/api/vpe_all_api_h.h>
#undef vl_typedefs
#undef vl_endianfun

int main()
{
   char *name = "vpp-test-app";

   clib_mem_init_thread_safe (0, 64ULL << 20);

   if (vl_client_api_map("/vpe-api"))
   {
        printf("unable to map....\n");
        goto quit;
   }
   if (vl_client_connect("vpp-test-app", 0, 32) < 0)
   {
        printf("unable to connect \n");
        vl_client_api_unmap();
        goto quit;
   }
   printf("successfully connected... \n");
 quit:
        return 0;
}

Is this wrong way, i am trying to use APIs ?

Thanks,
Regards
Venu

On Thu, 30 Sept 2021 at 19:00, Akash S R <akashsr.akashsr@...> wrote:
Hey Venu,

Try "scl enable devtoolset-9 bash" inside your docker or update your gcc version.


/Akash S R

On Thu, Sep 30, 2021, 18:54 Venumadhav Josyula <vjosyula@...> wrote:
Hi Benoit,

Thanks for quick reply.

I have docker with following
[root@8f57181df3a1 vpp_c_api_examples]# rpm -qa | grep vpp
vpp-lib-21.06.0-4~g0d9d3a0.x86_64
vpp-api-lua-21.06.0-4~g0d9d3a0.x86_64
vpp-api-python3-21.06.0-4~g0d9d3a0.x86_64
vpp-debuginfo-21.06.0-4~g0d9d3a0.x86_64
vpp-selinux-policy-21.06.0-4~g0d9d3a0.x86_64
vpp-21.06.0-4~g0d9d3a0.x86_64
vpp-plugins-21.06.0-4~g0d9d3a0.x86_64
vpp-devel-21.06.0-4~g0d9d3a0.x86_64

This will vpp running in it.

[root@8f57181df3a1 /]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
[root@8f57181df3a1 /]#

> Eg. use devtoolset-9 (gcc-9).

How do I use it ?

Thanks,
Regards,
Venu

On Thu, 30 Sept 2021 at 18:47, Benoit Ganne (bganne) <bganne@...> wrote:
You should upgrade your compiler... GCC-4 is way too old.
Eg. use devtoolset-9 (gcc-9).

Best
ben

> -----Original Message-----
> From: vpp-dev@... <vpp-dev@...> On Behalf Of Venumadhav
> Josyula
> Sent: jeudi 30 septembre 2021 14:49
> To: otroan@...
> Cc: RaviKiran Veldanda <ravi.jupvpp@...>; vpp-dev <vpp-
> dev@...>
> Subject: Re: [vpp-dev] VPP Socket API how to use from the application
> #socket-api #vpp #sock-api
>
> Hi Ole / Others,
>
>
>
> Thanks for your email, i getting following compilation error
> [root@8f57181df3a1 vpp_c_api_examples]# gcc vpp_api_client_test3.c -o
> vpp_api_client_test3.o -lvlibmemoryclient -lsvm -lvppinfra -lvlib
> In file included from /usr/include/vppinfra/error.h:41:0,
>                  from /usr/include/vlibapi/api.h:24,
>                  from vpp_api_client_test3.c:3:
> /usr/include/vppinfra/clib.h:43:18: error: missing binary operator before
> token "("
>  #if __has_include(<vppinfra/config.h>)
>                   ^
> In file included from /usr/include/vppinfra/mem.h:49:0,
>                  from /usr/include/vppinfra/vec.h:42,
>                  from /usr/include/vppinfra/error.h:53,
>                  from /usr/include/vlibapi/api.h:24,
>                  from vpp_api_client_test3.c:3:
> /usr/include/vppinfra/string.h:92:34: error: expected ';', ',' or ')'
> before 'dst'
>  clib_memcpy_fast (void *restrict dst, const void *restrict src, size_t n)
>                                   ^
> [root@8f57181df3a1 vpp_c_api_examples]# vim /usr/include/vppinfra/clib.h
> +43
> [root@8f57181df3a1 vpp_c_api_examples]# vim /usr/include/vppinfra/clib.h
> +43
> [root@8f57181df3a1 vpp_c_api_examples]# gcc --version
> gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
> Copyright (C) 2015 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
> PURPOSE.
>
> [root@8f57181df3a1 vpp_c_api_examples]#
>
>
> -----------------
>
> c -code
> ----------------
>
>
> #include<stdio.h>
> #include<stdlib.h>
> #include <vlibapi/api.h>
> #include <vlibmemory/api.h>
> #include <vpp/api/vpe_msg_enum.h>
>
> #define vl_typedefs
> #define vl_endianfun
> #include <vpp/api/vpe_all_api_h.h>
> #undef vl_typedefs
> #undef vl_endianfun
>
> int main()
> {
>    char *name = "vpp-test-app";
>
>    clib_mem_init_thread_safe (0, 64ULL << 20);
>
>    if (vl_client_api_map("/vpe-api"))
>    {
>         printf("unable to map....\n");
>         goto quit;
>    }
>    if (vl_client_connect("vpp-test-app", 0, 32) < 0)
>    {
>         printf("unable to connect \n");
>         vl_client_api_unmap();
>         goto quit;
>    }
>    printf("successfully connected... \n");
>  quit:
>         return 0;
> }
>
>
> ------------
>
>
> Can you please suggest what can i be doing worng ?
>
>
> Thanks,
> Regards,
> Venu
>
>
> On Thu, 30 Sept 2021 at 13:21, <otroan@...
> <mailto:otroan@...> > wrote:
>
>
>       Hi Venu,
>
>       > Any examples for VAPI shared to use binary APIs ?
>
>       Try this for a start:
>       https://git.fd.io/vpp/tree/src/vpp-api/vapi/vapi_c_test.c
>
>       Cheers,
>       Ole
>
>





Venumadhav Josyula
 

Hi Akash,

Sure I can use help from anywhere.

>I guess you are using centos and I have good experience on this.
> print LD_LIBRARY_PATH and set the path to the path it says in error. Then push all the .so and other library files of VPP into this path and try.
Can you elaborate more , you mean like this
[root@8f57181df3a1 /]# find . -name libvlib.so
./usr/lib64/libvlib.so
LD_LIBRARY_PATH=/usr/lib64 gcc vpp_api_client_test3.c -o vpp_api_client_test3.o -lvlibmemoryclient -lsvm -lvppinfra -lvlib
?
>Also mention the path of your VPP /include directory and /library path in the compilation.
[root@8f57181df3a1 /]# ls -al usr/include/
total 1652
..
..
...

-rw-r--r--  1 root root   1962 Apr 28 13:34 values.h
drwxr-xr-x  2 bin  bin   12288 Sep 13 06:14 vapi
drwxr-xr-x  2 bin  bin    4096 Sep 13 06:14 vat
drwxr-xr-x  2 bin  bin    4096 Sep 13 06:14 vat2
drwxr-xr-x  2 bin  bin    4096 Sep 13 06:14 vcl

drwxr-xr-x  1 root root   4096 Sep 30 13:29 video
drwxr-xr-x  6 bin  bin    4096 Sep 13 06:14 vlib
drwxr-xr-x  2 bin  bin    4096 Sep 13 06:14 vlibapi
drwxr-xr-x  2 bin  bin    4096 Sep 13 06:14 vlibmemory
drwxr-xr-x 53 bin  bin    4096 Sep 13 06:14 vnet
drwxr-xr-x  4 bin  bin    4096 Sep 13 06:14 vpp
drwxr-xr-x  3 bin  bin    4096 Sep 13 06:14 vpp-api
drwxr-xr-x 60 bin  bin    4096 Sep 13 06:14 vpp_plugins
drwxr-xr-x  3 bin  bin    4096 Sep 30 12:57 vppinfra

-rw-r--r--  1 root root     22 Apr 28 13:34 wait.h
-rw-r--r--  1 root root  32119 Apr 28 13:34 wchar.h
-rw-r--r--  1 root root  11155 Apr 28 13:34 wctype.h
-rw-r--r--  1 root root   2529 Apr 28 13:34 wordexp.h
drwxr-xr-x  1 root root   4096 Sep 30 13:29 xen
-rw-r--r--  1 root root   1704 Apr 28 13:34 xlocale.h
[root@8f57181df3a1 /]# ls -al usr/include/^C
[root@8f57181df3a1 /]# cd -
/root/vpp_c_api_examples
[root@8f57181df3a1 vpp_c_api_examples]# LD_LIBRARY_PATH=/usr/lib64 gcc vpp_api_client_test3.c -o vpp_api_client_test3.o -lvlibmemoryclient -lsvm -lvppinfra -lvlib -I/usr/include
Thanks,
Regards,
Venu

On Thu, 30 Sept 2021 at 20:41, Akash S R <akashsr.akashsr@...> wrote:
Hi Venu,

can I answer this query? just asking as I have not been asked this :)

I guess you are using centos and I have good experience on this.
print LD_LIBRARY_PATH and set the path to the path it says in error. Then push all the .so and other library files of VPP into this path and try.

Also mention the path of your VPP /include directory and /library path in the compilation.


/Akash

On Thu, Sep 30, 2021, 19:39 Venumadhav Josyula <vjosyula@...> wrote:
Hi Akash,

Thansks, now after devtoolset,

i am getting following error

[root@8f57181df3a1 vpp_c_api_examples]# gcc vpp_api_client_test3.c -o vpp_api_client_test3.o -lvlibmemoryclient -lsvm -lvppinfra -lvlib
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: /lib/../lib64/libvlib.so: undefined reference to `classify_get_trace_chain'
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: /lib/../lib64/libvlib.so: undefined reference to `stat_segment_register_gauge'
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: /lib/../lib64/libvlib.so: undefined reference to `os_exit'
collect2: error: ld returned 1 exit status
[root@8f57181df3a1 vpp_c_api_examples]#

Let me paste the code again,
#include<stdio.h>
#include<stdlib.h>
#include <vlibapi/api.h>
#include <vlibmemory/api.h>
#include <vpp/api/vpe_msg_enum.h>

#define vl_typedefs
#define vl_endianfun
#include <vpp/api/vpe_all_api_h.h>
#undef vl_typedefs
#undef vl_endianfun

int main()
{
   char *name = "vpp-test-app";

   clib_mem_init_thread_safe (0, 64ULL << 20);

   if (vl_client_api_map("/vpe-api"))
   {
        printf("unable to map....\n");
        goto quit;
   }
   if (vl_client_connect("vpp-test-app", 0, 32) < 0)
   {
        printf("unable to connect \n");
        vl_client_api_unmap();
        goto quit;
   }
   printf("successfully connected... \n");
 quit:
        return 0;
}

Is this wrong way, i am trying to use APIs ?

Thanks,
Regards
Venu

On Thu, 30 Sept 2021 at 19:00, Akash S R <akashsr.akashsr@...> wrote:
Hey Venu,

Try "scl enable devtoolset-9 bash" inside your docker or update your gcc version.


/Akash S R

On Thu, Sep 30, 2021, 18:54 Venumadhav Josyula <vjosyula@...> wrote:
Hi Benoit,

Thanks for quick reply.

I have docker with following
[root@8f57181df3a1 vpp_c_api_examples]# rpm -qa | grep vpp
vpp-lib-21.06.0-4~g0d9d3a0.x86_64
vpp-api-lua-21.06.0-4~g0d9d3a0.x86_64
vpp-api-python3-21.06.0-4~g0d9d3a0.x86_64
vpp-debuginfo-21.06.0-4~g0d9d3a0.x86_64
vpp-selinux-policy-21.06.0-4~g0d9d3a0.x86_64
vpp-21.06.0-4~g0d9d3a0.x86_64
vpp-plugins-21.06.0-4~g0d9d3a0.x86_64
vpp-devel-21.06.0-4~g0d9d3a0.x86_64

This will vpp running in it.

[root@8f57181df3a1 /]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
[root@8f57181df3a1 /]#

> Eg. use devtoolset-9 (gcc-9).

How do I use it ?

Thanks,
Regards,
Venu

On Thu, 30 Sept 2021 at 18:47, Benoit Ganne (bganne) <bganne@...> wrote:
You should upgrade your compiler... GCC-4 is way too old.
Eg. use devtoolset-9 (gcc-9).

Best
ben

> -----Original Message-----
> From: vpp-dev@... <vpp-dev@...> On Behalf Of Venumadhav
> Josyula
> Sent: jeudi 30 septembre 2021 14:49
> To: otroan@...
> Cc: RaviKiran Veldanda <ravi.jupvpp@...>; vpp-dev <vpp-
> dev@...>
> Subject: Re: [vpp-dev] VPP Socket API how to use from the application
> #socket-api #vpp #sock-api
>
> Hi Ole / Others,
>
>
>
> Thanks for your email, i getting following compilation error
> [root@8f57181df3a1 vpp_c_api_examples]# gcc vpp_api_client_test3.c -o
> vpp_api_client_test3.o -lvlibmemoryclient -lsvm -lvppinfra -lvlib
> In file included from /usr/include/vppinfra/error.h:41:0,
>                  from /usr/include/vlibapi/api.h:24,
>                  from vpp_api_client_test3.c:3:
> /usr/include/vppinfra/clib.h:43:18: error: missing binary operator before
> token "("
>  #if __has_include(<vppinfra/config.h>)
>                   ^
> In file included from /usr/include/vppinfra/mem.h:49:0,
>                  from /usr/include/vppinfra/vec.h:42,
>                  from /usr/include/vppinfra/error.h:53,
>                  from /usr/include/vlibapi/api.h:24,
>                  from vpp_api_client_test3.c:3:
> /usr/include/vppinfra/string.h:92:34: error: expected ';', ',' or ')'
> before 'dst'
>  clib_memcpy_fast (void *restrict dst, const void *restrict src, size_t n)
>                                   ^
> [root@8f57181df3a1 vpp_c_api_examples]# vim /usr/include/vppinfra/clib.h
> +43
> [root@8f57181df3a1 vpp_c_api_examples]# vim /usr/include/vppinfra/clib.h
> +43
> [root@8f57181df3a1 vpp_c_api_examples]# gcc --version
> gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
> Copyright (C) 2015 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
> PURPOSE.
>
> [root@8f57181df3a1 vpp_c_api_examples]#
>
>
> -----------------
>
> c -code
> ----------------
>
>
> #include<stdio.h>
> #include<stdlib.h>
> #include <vlibapi/api.h>
> #include <vlibmemory/api.h>
> #include <vpp/api/vpe_msg_enum.h>
>
> #define vl_typedefs
> #define vl_endianfun
> #include <vpp/api/vpe_all_api_h.h>
> #undef vl_typedefs
> #undef vl_endianfun
>
> int main()
> {
>    char *name = "vpp-test-app";
>
>    clib_mem_init_thread_safe (0, 64ULL << 20);
>
>    if (vl_client_api_map("/vpe-api"))
>    {
>         printf("unable to map....\n");
>         goto quit;
>    }
>    if (vl_client_connect("vpp-test-app", 0, 32) < 0)
>    {
>         printf("unable to connect \n");
>         vl_client_api_unmap();
>         goto quit;
>    }
>    printf("successfully connected... \n");
>  quit:
>         return 0;
> }
>
>
> ------------
>
>
> Can you please suggest what can i be doing worng ?
>
>
> Thanks,
> Regards,
> Venu
>
>
> On Thu, 30 Sept 2021 at 13:21, <otroan@...
> <mailto:otroan@...> > wrote:
>
>
>       Hi Venu,
>
>       > Any examples for VAPI shared to use binary APIs ?
>
>       Try this for a start:
>       https://git.fd.io/vpp/tree/src/vpp-api/vapi/vapi_c_test.c
>
>       Cheers,
>       Ole
>
>





Akash S R
 

no not like this, Include the path of both in your gcc complilation line like -L/(vpp lib path) -I/(include path) and lib path like
opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld
hope this helps.

/Akash

On Thu, Sep 30, 2021, 20:54 Venumadhav Josyula <vjosyula@...> wrote:
Hi Akash,

Sure I can use help from anywhere.

>I guess you are using centos and I have good experience on this.
> print LD_LIBRARY_PATH and set the path to the path it says in error. Then push all the .so and other library files of VPP into this path and try.
Can you elaborate more , you mean like this
[root@8f57181df3a1 /]# find . -name libvlib.so
./usr/lib64/libvlib.so
LD_LIBRARY_PATH=/usr/lib64 gcc vpp_api_client_test3.c -o vpp_api_client_test3.o -lvlibmemoryclient -lsvm -lvppinfra -lvlib
?
>Also mention the path of your VPP /include directory and /library path in the compilation.
[root@8f57181df3a1 /]# ls -al usr/include/
total 1652
..
..
...

-rw-r--r--  1 root root   1962 Apr 28 13:34 values.h
drwxr-xr-x  2 bin  bin   12288 Sep 13 06:14 vapi
drwxr-xr-x  2 bin  bin    4096 Sep 13 06:14 vat
drwxr-xr-x  2 bin  bin    4096 Sep 13 06:14 vat2
drwxr-xr-x  2 bin  bin    4096 Sep 13 06:14 vcl

drwxr-xr-x  1 root root   4096 Sep 30 13:29 video
drwxr-xr-x  6 bin  bin    4096 Sep 13 06:14 vlib
drwxr-xr-x  2 bin  bin    4096 Sep 13 06:14 vlibapi
drwxr-xr-x  2 bin  bin    4096 Sep 13 06:14 vlibmemory
drwxr-xr-x 53 bin  bin    4096 Sep 13 06:14 vnet
drwxr-xr-x  4 bin  bin    4096 Sep 13 06:14 vpp
drwxr-xr-x  3 bin  bin    4096 Sep 13 06:14 vpp-api
drwxr-xr-x 60 bin  bin    4096 Sep 13 06:14 vpp_plugins
drwxr-xr-x  3 bin  bin    4096 Sep 30 12:57 vppinfra

-rw-r--r--  1 root root     22 Apr 28 13:34 wait.h
-rw-r--r--  1 root root  32119 Apr 28 13:34 wchar.h
-rw-r--r--  1 root root  11155 Apr 28 13:34 wctype.h
-rw-r--r--  1 root root   2529 Apr 28 13:34 wordexp.h
drwxr-xr-x  1 root root   4096 Sep 30 13:29 xen
-rw-r--r--  1 root root   1704 Apr 28 13:34 xlocale.h
[root@8f57181df3a1 /]# ls -al usr/include/^C
[root@8f57181df3a1 /]# cd -
/root/vpp_c_api_examples
[root@8f57181df3a1 vpp_c_api_examples]# LD_LIBRARY_PATH=/usr/lib64 gcc vpp_api_client_test3.c -o vpp_api_client_test3.o -lvlibmemoryclient -lsvm -lvppinfra -lvlib -I/usr/include
Thanks,
Regards,
Venu

On Thu, 30 Sept 2021 at 20:41, Akash S R <akashsr.akashsr@...> wrote:
Hi Venu,

can I answer this query? just asking as I have not been asked this :)

I guess you are using centos and I have good experience on this.
print LD_LIBRARY_PATH and set the path to the path it says in error. Then push all the .so and other library files of VPP into this path and try.

Also mention the path of your VPP /include directory and /library path in the compilation.


/Akash

On Thu, Sep 30, 2021, 19:39 Venumadhav Josyula <vjosyula@...> wrote:
Hi Akash,

Thansks, now after devtoolset,

i am getting following error

[root@8f57181df3a1 vpp_c_api_examples]# gcc vpp_api_client_test3.c -o vpp_api_client_test3.o -lvlibmemoryclient -lsvm -lvppinfra -lvlib
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: /lib/../lib64/libvlib.so: undefined reference to `classify_get_trace_chain'
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: /lib/../lib64/libvlib.so: undefined reference to `stat_segment_register_gauge'
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: /lib/../lib64/libvlib.so: undefined reference to `os_exit'
collect2: error: ld returned 1 exit status
[root@8f57181df3a1 vpp_c_api_examples]#

Let me paste the code again,
#include<stdio.h>
#include<stdlib.h>
#include <vlibapi/api.h>
#include <vlibmemory/api.h>
#include <vpp/api/vpe_msg_enum.h>

#define vl_typedefs
#define vl_endianfun
#include <vpp/api/vpe_all_api_h.h>
#undef vl_typedefs
#undef vl_endianfun

int main()
{
   char *name = "vpp-test-app";

   clib_mem_init_thread_safe (0, 64ULL << 20);

   if (vl_client_api_map("/vpe-api"))
   {
        printf("unable to map....\n");
        goto quit;
   }
   if (vl_client_connect("vpp-test-app", 0, 32) < 0)
   {
        printf("unable to connect \n");
        vl_client_api_unmap();
        goto quit;
   }
   printf("successfully connected... \n");
 quit:
        return 0;
}

Is this wrong way, i am trying to use APIs ?

Thanks,
Regards
Venu

On Thu, 30 Sept 2021 at 19:00, Akash S R <akashsr.akashsr@...> wrote:
Hey Venu,

Try "scl enable devtoolset-9 bash" inside your docker or update your gcc version.


/Akash S R

On Thu, Sep 30, 2021, 18:54 Venumadhav Josyula <vjosyula@...> wrote:
Hi Benoit,

Thanks for quick reply.

I have docker with following
[root@8f57181df3a1 vpp_c_api_examples]# rpm -qa | grep vpp
vpp-lib-21.06.0-4~g0d9d3a0.x86_64
vpp-api-lua-21.06.0-4~g0d9d3a0.x86_64
vpp-api-python3-21.06.0-4~g0d9d3a0.x86_64
vpp-debuginfo-21.06.0-4~g0d9d3a0.x86_64
vpp-selinux-policy-21.06.0-4~g0d9d3a0.x86_64
vpp-21.06.0-4~g0d9d3a0.x86_64
vpp-plugins-21.06.0-4~g0d9d3a0.x86_64
vpp-devel-21.06.0-4~g0d9d3a0.x86_64

This will vpp running in it.

[root@8f57181df3a1 /]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
[root@8f57181df3a1 /]#

> Eg. use devtoolset-9 (gcc-9).

How do I use it ?

Thanks,
Regards,
Venu

On Thu, 30 Sept 2021 at 18:47, Benoit Ganne (bganne) <bganne@...> wrote:
You should upgrade your compiler... GCC-4 is way too old.
Eg. use devtoolset-9 (gcc-9).

Best
ben

> -----Original Message-----
> From: vpp-dev@... <vpp-dev@...> On Behalf Of Venumadhav
> Josyula
> Sent: jeudi 30 septembre 2021 14:49
> To: otroan@...
> Cc: RaviKiran Veldanda <ravi.jupvpp@...>; vpp-dev <vpp-
> dev@...>
> Subject: Re: [vpp-dev] VPP Socket API how to use from the application
> #socket-api #vpp #sock-api
>
> Hi Ole / Others,
>
>
>
> Thanks for your email, i getting following compilation error
> [root@8f57181df3a1 vpp_c_api_examples]# gcc vpp_api_client_test3.c -o
> vpp_api_client_test3.o -lvlibmemoryclient -lsvm -lvppinfra -lvlib
> In file included from /usr/include/vppinfra/error.h:41:0,
>                  from /usr/include/vlibapi/api.h:24,
>                  from vpp_api_client_test3.c:3:
> /usr/include/vppinfra/clib.h:43:18: error: missing binary operator before
> token "("
>  #if __has_include(<vppinfra/config.h>)
>                   ^
> In file included from /usr/include/vppinfra/mem.h:49:0,
>                  from /usr/include/vppinfra/vec.h:42,
>                  from /usr/include/vppinfra/error.h:53,
>                  from /usr/include/vlibapi/api.h:24,
>                  from vpp_api_client_test3.c:3:
> /usr/include/vppinfra/string.h:92:34: error: expected ';', ',' or ')'
> before 'dst'
>  clib_memcpy_fast (void *restrict dst, const void *restrict src, size_t n)
>                                   ^
> [root@8f57181df3a1 vpp_c_api_examples]# vim /usr/include/vppinfra/clib.h
> +43
> [root@8f57181df3a1 vpp_c_api_examples]# vim /usr/include/vppinfra/clib.h
> +43
> [root@8f57181df3a1 vpp_c_api_examples]# gcc --version
> gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
> Copyright (C) 2015 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
> PURPOSE.
>
> [root@8f57181df3a1 vpp_c_api_examples]#
>
>
> -----------------
>
> c -code
> ----------------
>
>
> #include<stdio.h>
> #include<stdlib.h>
> #include <vlibapi/api.h>
> #include <vlibmemory/api.h>
> #include <vpp/api/vpe_msg_enum.h>
>
> #define vl_typedefs
> #define vl_endianfun
> #include <vpp/api/vpe_all_api_h.h>
> #undef vl_typedefs
> #undef vl_endianfun
>
> int main()
> {
>    char *name = "vpp-test-app";
>
>    clib_mem_init_thread_safe (0, 64ULL << 20);
>
>    if (vl_client_api_map("/vpe-api"))
>    {
>         printf("unable to map....\n");
>         goto quit;
>    }
>    if (vl_client_connect("vpp-test-app", 0, 32) < 0)
>    {
>         printf("unable to connect \n");
>         vl_client_api_unmap();
>         goto quit;
>    }
>    printf("successfully connected... \n");
>  quit:
>         return 0;
> }
>
>
> ------------
>
>
> Can you please suggest what can i be doing worng ?
>
>
> Thanks,
> Regards,
> Venu
>
>
> On Thu, 30 Sept 2021 at 13:21, <otroan@...
> <mailto:otroan@...> > wrote:
>
>
>       Hi Venu,
>
>       > Any examples for VAPI shared to use binary APIs ?
>
>       Try this for a start:
>       https://git.fd.io/vpp/tree/src/vpp-api/vapi/vapi_c_test.c
>
>       Cheers,
>       Ole
>
>





Benoit Ganne (bganne)
 

You should remove -lvlib it is not needed here.
If you really want to link with vlib, you must fix the link ordering: vlib depends upon vppinfra (where os_exit is defined) so you'd need link as -lvlib -lvppinfra instead of the opposite (the C linker scan libraries symbols in reverse order, so symbols declared in a library are available to libraries listed *before*).

Best
ben

-----Original Message-----
From: vpp-dev@... <vpp-dev@...> On Behalf Of Venumadhav
Josyula
Sent: jeudi 30 septembre 2021 16:09
To: Akash S R <akashsr.akashsr@...>
Cc: Benoit Ganne (bganne) <bganne@...>; Ole Troan
<otroan@...>; RaviKiran Veldanda <ravi.jupvpp@...>; vpp-
dev <vpp-dev@...>
Subject: Re: [vpp-dev] VPP Socket API how to use from the application
#socket-api #vpp #sock-api

Hi Akash,

Thansks, now after devtoolset,


@Benoit Ganne (bganne) <mailto:bganne@...> , @Ole Troan
<mailto:otroan@...>

i am getting following error

[root@8f57181df3a1 vpp_c_api_examples]# gcc vpp_api_client_test3.c -o
vpp_api_client_test3.o -lvlibmemoryclient -lsvm -lvppinfra -lvlib
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld:
/lib/../lib64/libvlib.so: undefined reference to
`classify_get_trace_chain'
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld:
/lib/../lib64/libvlib.so: undefined reference to
`stat_segment_register_gauge'
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld:
/lib/../lib64/libvlib.so: undefined reference to `os_exit'
collect2: error: ld returned 1 exit status
[root@8f57181df3a1 vpp_c_api_examples]#

Let me paste the code again,
#include<stdio.h>
#include<stdlib.h>
#include <vlibapi/api.h>
#include <vlibmemory/api.h>
#include <vpp/api/vpe_msg_enum.h>

#define vl_typedefs
#define vl_endianfun
#include <vpp/api/vpe_all_api_h.h>
#undef vl_typedefs
#undef vl_endianfun

int main()
{
char *name = "vpp-test-app";

clib_mem_init_thread_safe (0, 64ULL << 20);

if (vl_client_api_map("/vpe-api"))
{
printf("unable to map....\n");
goto quit;
}
if (vl_client_connect("vpp-test-app", 0, 32) < 0)
{
printf("unable to connect \n");
vl_client_api_unmap();
goto quit;
}
printf("successfully connected... \n");
quit:
return 0;
}

Is this wrong way, i am trying to use APIs ?

Thanks,
Regards
Venu


On Thu, 30 Sept 2021 at 19:00, Akash S R <akashsr.akashsr@...
<mailto:akashsr.akashsr@...> > wrote:


Hey Venu,

Try "scl enable devtoolset-9 bash" inside your docker or update your
gcc version.


/Akash S R

On Thu, Sep 30, 2021, 18:54 Venumadhav Josyula <vjosyula@...
<mailto:vjosyula@...> > wrote:


Hi Benoit,

Thanks for quick reply.

I have docker with following
[root@8f57181df3a1 vpp_c_api_examples]# rpm -qa | grep vpp
vpp-lib-21.06.0-4~g0d9d3a0.x86_64
vpp-api-lua-21.06.0-4~g0d9d3a0.x86_64
vpp-api-python3-21.06.0-4~g0d9d3a0.x86_64
vpp-debuginfo-21.06.0-4~g0d9d3a0.x86_64
vpp-selinux-policy-21.06.0-4~g0d9d3a0.x86_64
vpp-21.06.0-4~g0d9d3a0.x86_64
vpp-plugins-21.06.0-4~g0d9d3a0.x86_64
vpp-devel-21.06.0-4~g0d9d3a0.x86_64

This will vpp running in it.

[root@8f57181df3a1 /]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
[root@8f57181df3a1 /]#

> Eg. use devtoolset-9 (gcc-9).


How do I use it ?

Thanks,
Regards,
Venu


On Thu, 30 Sept 2021 at 18:47, Benoit Ganne (bganne)
<bganne@... <mailto:bganne@...> > wrote:


You should upgrade your compiler... GCC-4 is way too
old.
Eg. use devtoolset-9 (gcc-9).

Best
ben

> -----Original Message-----
> From: vpp-dev@... <mailto:vpp-dev@...>
<vpp-dev@... <mailto:vpp-dev@...> > On Behalf Of
Venumadhav
> Josyula
> Sent: jeudi 30 septembre 2021 14:49
> To: otroan@... <mailto:otroan@...>
> Cc: RaviKiran Veldanda <ravi.jupvpp@...
<mailto:ravi.jupvpp@...> >; vpp-dev <vpp-
> dev@... <mailto:dev@...> >
> Subject: Re: [vpp-dev] VPP Socket API how to use from
the application
> #socket-api #vpp #sock-api
>
> Hi Ole / Others,
>
>
>
> Thanks for your email, i getting following compilation
error
> [root@8f57181df3a1 vpp_c_api_examples]# gcc
vpp_api_client_test3.c -o
> vpp_api_client_test3.o -lvlibmemoryclient -lsvm -
lvppinfra -lvlib
> In file included from
/usr/include/vppinfra/error.h:41:0,
> from /usr/include/vlibapi/api.h:24,
> from vpp_api_client_test3.c:3:
> /usr/include/vppinfra/clib.h:43:18: error: missing
binary operator before
> token "("
> #if __has_include(<vppinfra/config.h>)
> ^
> In file included from
/usr/include/vppinfra/mem.h:49:0,
> from /usr/include/vppinfra/vec.h:42,
> from
/usr/include/vppinfra/error.h:53,
> from /usr/include/vlibapi/api.h:24,
> from vpp_api_client_test3.c:3:
> /usr/include/vppinfra/string.h:92:34: error: expected
';', ',' or ')'
> before 'dst'
> clib_memcpy_fast (void *restrict dst, const void
*restrict src, size_t n)
> ^
> [root@8f57181df3a1 vpp_c_api_examples]# vim
/usr/include/vppinfra/clib.h
> +43
> [root@8f57181df3a1 vpp_c_api_examples]# vim
/usr/include/vppinfra/clib.h
> +43
> [root@8f57181df3a1 vpp_c_api_examples]# gcc --version
> gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
> Copyright (C) 2015 Free Software Foundation, Inc.
> This is free software; see the source for copying
conditions. There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR
A PARTICULAR
> PURPOSE.
>
> [root@8f57181df3a1 vpp_c_api_examples]#
>
>
> -----------------
>
> c -code
> ----------------
>
>
> #include<stdio.h>
> #include<stdlib.h>
> #include <vlibapi/api.h>
> #include <vlibmemory/api.h>
> #include <vpp/api/vpe_msg_enum.h>
>
> #define vl_typedefs
> #define vl_endianfun
> #include <vpp/api/vpe_all_api_h.h>
> #undef vl_typedefs
> #undef vl_endianfun
>
> int main()
> {
> char *name = "vpp-test-app";
>
> clib_mem_init_thread_safe (0, 64ULL << 20);
>
> if (vl_client_api_map("/vpe-api"))
> {
> printf("unable to map....\n");
> goto quit;
> }
> if (vl_client_connect("vpp-test-app", 0, 32) < 0)
> {
> printf("unable to connect \n");
> vl_client_api_unmap();
> goto quit;
> }
> printf("successfully connected... \n");
> quit:
> return 0;
> }
>
>
> ------------
>
>
> Can you please suggest what can i be doing worng ?
>
>
> Thanks,
> Regards,
> Venu
>
>
> On Thu, 30 Sept 2021 at 13:21, <otroan@...
<mailto:otroan@...>
> <mailto:otroan@...
<mailto:otroan@...> > > wrote:
>
>
> Hi Venu,
>
> > Any examples for VAPI shared to use binary
APIs ?
>
> Try this for a start:
> https://git.fd.io/vpp/tree/src/vpp-
api/vapi/vapi_c_test.c
>
> Cheers,
> Ole
>
>





Ole Troan
 

Venu,

Doesn't seem like you are using the higher level C VAPI API nor the low-level API in vpp-api/client.c.
Are you sure this is what you want?

O.

On 30 Sep 2021, at 16:09, Venumadhav Josyula <vjosyula@...> wrote:

Hi Akash,

Thansks, now after devtoolset,

@Benoit Ganne (bganne) , @Ole Troan
i am getting following error

[root@8f57181df3a1 vpp_c_api_examples]# gcc vpp_api_client_test3.c -o vpp_api_client_test3.o -lvlibmemoryclient -lsvm -lvppinfra -lvlib
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: /lib/../lib64/libvlib.so: undefined reference to `classify_get_trace_chain'
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: /lib/../lib64/libvlib.so: undefined reference to `stat_segment_register_gauge'
/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: /lib/../lib64/libvlib.so: undefined reference to `os_exit'
collect2: error: ld returned 1 exit status
[root@8f57181df3a1 vpp_c_api_examples]#

Let me paste the code again,
#include<stdio.h>
#include<stdlib.h>
#include <vlibapi/api.h>
#include <vlibmemory/api.h>
#include <vpp/api/vpe_msg_enum.h>

#define vl_typedefs
#define vl_endianfun
#include <vpp/api/vpe_all_api_h.h>
#undef vl_typedefs
#undef vl_endianfun

int main()
{
char *name = "vpp-test-app";

clib_mem_init_thread_safe (0, 64ULL << 20);

if (vl_client_api_map("/vpe-api"))
{
printf("unable to map....\n");
goto quit;
}
if (vl_client_connect("vpp-test-app", 0, 32) < 0)
{
printf("unable to connect \n");
vl_client_api_unmap();
goto quit;
}
printf("successfully connected... \n");
quit:
return 0;
}

Is this wrong way, i am trying to use APIs ?

Thanks,
Regards
Venu

On Thu, 30 Sept 2021 at 19:00, Akash S R <akashsr.akashsr@...> wrote:
Hey Venu,

Try "scl enable devtoolset-9 bash" inside your docker or update your gcc version.


/Akash S R

On Thu, Sep 30, 2021, 18:54 Venumadhav Josyula <vjosyula@...> wrote:
Hi Benoit,

Thanks for quick reply.

I have docker with following
[root@8f57181df3a1 vpp_c_api_examples]# rpm -qa | grep vpp
vpp-lib-21.06.0-4~g0d9d3a0.x86_64
vpp-api-lua-21.06.0-4~g0d9d3a0.x86_64
vpp-api-python3-21.06.0-4~g0d9d3a0.x86_64
vpp-debuginfo-21.06.0-4~g0d9d3a0.x86_64
vpp-selinux-policy-21.06.0-4~g0d9d3a0.x86_64
vpp-21.06.0-4~g0d9d3a0.x86_64
vpp-plugins-21.06.0-4~g0d9d3a0.x86_64
vpp-devel-21.06.0-4~g0d9d3a0.x86_64

This will vpp running in it.

[root@8f57181df3a1 /]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
[root@8f57181df3a1 /]#

Eg. use devtoolset-9 (gcc-9).
How do I use it ?

Thanks,
Regards,
Venu

On Thu, 30 Sept 2021 at 18:47, Benoit Ganne (bganne) <bganne@...> wrote:
You should upgrade your compiler... GCC-4 is way too old.
Eg. use devtoolset-9 (gcc-9).

Best
ben

-----Original Message-----
From: vpp-dev@... <vpp-dev@...> On Behalf Of Venumadhav
Josyula
Sent: jeudi 30 septembre 2021 14:49
To: otroan@...
Cc: RaviKiran Veldanda <ravi.jupvpp@...>; vpp-dev <vpp-
dev@...>
Subject: Re: [vpp-dev] VPP Socket API how to use from the application
#socket-api #vpp #sock-api

Hi Ole / Others,



Thanks for your email, i getting following compilation error
[root@8f57181df3a1 vpp_c_api_examples]# gcc vpp_api_client_test3.c -o
vpp_api_client_test3.o -lvlibmemoryclient -lsvm -lvppinfra -lvlib
In file included from /usr/include/vppinfra/error.h:41:0,
from /usr/include/vlibapi/api.h:24,
from vpp_api_client_test3.c:3:
/usr/include/vppinfra/clib.h:43:18: error: missing binary operator before
token "("
#if __has_include(<vppinfra/config.h>)
^
In file included from /usr/include/vppinfra/mem.h:49:0,
from /usr/include/vppinfra/vec.h:42,
from /usr/include/vppinfra/error.h:53,
from /usr/include/vlibapi/api.h:24,
from vpp_api_client_test3.c:3:
/usr/include/vppinfra/string.h:92:34: error: expected ';', ',' or ')'
before 'dst'
clib_memcpy_fast (void *restrict dst, const void *restrict src, size_t n)
^
[root@8f57181df3a1 vpp_c_api_examples]# vim /usr/include/vppinfra/clib.h
+43
[root@8f57181df3a1 vpp_c_api_examples]# vim /usr/include/vppinfra/clib.h
+43
[root@8f57181df3a1 vpp_c_api_examples]# gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

[root@8f57181df3a1 vpp_c_api_examples]#


-----------------

c -code
----------------


#include<stdio.h>
#include<stdlib.h>
#include <vlibapi/api.h>
#include <vlibmemory/api.h>
#include <vpp/api/vpe_msg_enum.h>

#define vl_typedefs
#define vl_endianfun
#include <vpp/api/vpe_all_api_h.h>
#undef vl_typedefs
#undef vl_endianfun

int main()
{
char *name = "vpp-test-app";

clib_mem_init_thread_safe (0, 64ULL << 20);

if (vl_client_api_map("/vpe-api"))
{
printf("unable to map....\n");
goto quit;
}
if (vl_client_connect("vpp-test-app", 0, 32) < 0)
{
printf("unable to connect \n");
vl_client_api_unmap();
goto quit;
}
printf("successfully connected... \n");
quit:
return 0;
}


------------


Can you please suggest what can i be doing worng ?


Thanks,
Regards,
Venu


On Thu, 30 Sept 2021 at 13:21, <otroan@...
<mailto:otroan@...> > wrote:


Hi Venu,

> Any examples for VAPI shared to use binary APIs ?

Try this for a start:
https://git.fd.io/vpp/tree/src/vpp-api/vapi/vapi_c_test.c

Cheers,
Ole






Venumadhav Josyula
 

Hi Ole,

My requirement is following

i) Want to connect to vpp
ii) use that send API messages to VPP
iii) I used this example strongswan vac_create

vac_t *vac_create(char *name)
{
    private_vac_t *this;

    INIT(this,
            .public = {
                    .destroy = _destroy,
                    .send = _vac_send,
                    .send_dump = _vac_send_dump,
                    .register_event = _register_event,
            },
...

...
...

    if (vl_client_api_map("/vpe-api"))
    {
        DBG1(DBG_KNL, "vac unable to map");
        destroy(this);
        return NULL;
    }

    if (vl_client_connect(name, 0, 32) < 0)
    {
        DBG1(DBG_KNL, "vac unable to connect");
        vl_client_api_unmap();
        destroy(this);
        return NULL;
    }

....

}
iv) I have a similar requirement, as to use a PUNT socket to receive the data from vpp into our application and do certain processing. In order to use punt sockets, you need to register with VPP using VPP APIs. Could use goVPP but don't know time so want something working for our initial POC. As I am comfortable in C, I want C VPP APIs for the same.
v) So the idea is to have an API message Forwarding application. Inside Fastpath POD, receive a socket forward API request to VPP. This API message for POC is coming from some other pod.
V) Now if you suggest something to me, that would be great.


I am currently clueless.

Thanks,
Regards,
Venu

On Thu, 30 Sept 2021 at 21:14, <otroan@...> wrote:
Venu,

Doesn't seem like you are using the higher level C VAPI API nor the low-level API in vpp-api/client.c.
Are you sure this is what you want?

O.

> On 30 Sep 2021, at 16:09, Venumadhav Josyula <vjosyula@...> wrote:
>
> Hi Akash,
>
> Thansks, now after devtoolset,
>
> @Benoit Ganne (bganne) , @Ole Troan
> i am getting following error
>
> [root@8f57181df3a1 vpp_c_api_examples]# gcc vpp_api_client_test3.c -o vpp_api_client_test3.o -lvlibmemoryclient -lsvm -lvppinfra -lvlib
> /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: /lib/../lib64/libvlib.so: undefined reference to `classify_get_trace_chain'
> /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: /lib/../lib64/libvlib.so: undefined reference to `stat_segment_register_gauge'
> /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld: /lib/../lib64/libvlib.so: undefined reference to `os_exit'
> collect2: error: ld returned 1 exit status
> [root@8f57181df3a1 vpp_c_api_examples]#
>
> Let me paste the code again,
> #include<stdio.h>
> #include<stdlib.h>
> #include <vlibapi/api.h>
> #include <vlibmemory/api.h>
> #include <vpp/api/vpe_msg_enum.h>
>
> #define vl_typedefs
> #define vl_endianfun
> #include <vpp/api/vpe_all_api_h.h>
> #undef vl_typedefs
> #undef vl_endianfun
>
> int main()
> {
>    char *name = "vpp-test-app";
>
>    clib_mem_init_thread_safe (0, 64ULL << 20);
>
>    if (vl_client_api_map("/vpe-api"))
>    {
>         printf("unable to map....\n");
>         goto quit;
>    }
>    if (vl_client_connect("vpp-test-app", 0, 32) < 0)
>    {
>         printf("unable to connect \n");
>         vl_client_api_unmap();
>         goto quit;
>    }
>    printf("successfully connected... \n");
>  quit:
>         return 0;
> }
>
> Is this wrong way, i am trying to use APIs ?
>
> Thanks,
> Regards
> Venu
>
> On Thu, 30 Sept 2021 at 19:00, Akash S R <akashsr.akashsr@...> wrote:
> Hey Venu,
>
> Try "scl enable devtoolset-9 bash" inside your docker or update your gcc version.
>
>
> /Akash S R
>
> On Thu, Sep 30, 2021, 18:54 Venumadhav Josyula <vjosyula@...> wrote:
> Hi Benoit,
>
> Thanks for quick reply.
>
> I have docker with following
> [root@8f57181df3a1 vpp_c_api_examples]# rpm -qa | grep vpp
> vpp-lib-21.06.0-4~g0d9d3a0.x86_64
> vpp-api-lua-21.06.0-4~g0d9d3a0.x86_64
> vpp-api-python3-21.06.0-4~g0d9d3a0.x86_64
> vpp-debuginfo-21.06.0-4~g0d9d3a0.x86_64
> vpp-selinux-policy-21.06.0-4~g0d9d3a0.x86_64
> vpp-21.06.0-4~g0d9d3a0.x86_64
> vpp-plugins-21.06.0-4~g0d9d3a0.x86_64
> vpp-devel-21.06.0-4~g0d9d3a0.x86_64
>
> This will vpp running in it.
>
> [root@8f57181df3a1 /]# cat /etc/redhat-release
> CentOS Linux release 7.3.1611 (Core)
> [root@8f57181df3a1 /]#
>
> > Eg. use devtoolset-9 (gcc-9).
>
> How do I use it ?
>
> Thanks,
> Regards,
> Venu
>
> On Thu, 30 Sept 2021 at 18:47, Benoit Ganne (bganne) <bganne@...> wrote:
> You should upgrade your compiler... GCC-4 is way too old.
> Eg. use devtoolset-9 (gcc-9).
>
> Best
> ben
>
> > -----Original Message-----
> > From: vpp-dev@... <vpp-dev@...> On Behalf Of Venumadhav
> > Josyula
> > Sent: jeudi 30 septembre 2021 14:49
> > To: otroan@...
> > Cc: RaviKiran Veldanda <ravi.jupvpp@...>; vpp-dev <vpp-
> > dev@...>
> > Subject: Re: [vpp-dev] VPP Socket API how to use from the application
> > #socket-api #vpp #sock-api
> >
> > Hi Ole / Others,
> >
> >
> >
> > Thanks for your email, i getting following compilation error
> > [root@8f57181df3a1 vpp_c_api_examples]# gcc vpp_api_client_test3.c -o
> > vpp_api_client_test3.o -lvlibmemoryclient -lsvm -lvppinfra -lvlib
> > In file included from /usr/include/vppinfra/error.h:41:0,
> >                  from /usr/include/vlibapi/api.h:24,
> >                  from vpp_api_client_test3.c:3:
> > /usr/include/vppinfra/clib.h:43:18: error: missing binary operator before
> > token "("
> >  #if __has_include(<vppinfra/config.h>)
> >                   ^
> > In file included from /usr/include/vppinfra/mem.h:49:0,
> >                  from /usr/include/vppinfra/vec.h:42,
> >                  from /usr/include/vppinfra/error.h:53,
> >                  from /usr/include/vlibapi/api.h:24,
> >                  from vpp_api_client_test3.c:3:
> > /usr/include/vppinfra/string.h:92:34: error: expected ';', ',' or ')'
> > before 'dst'
> >  clib_memcpy_fast (void *restrict dst, const void *restrict src, size_t n)
> >                                   ^
> > [root@8f57181df3a1 vpp_c_api_examples]# vim /usr/include/vppinfra/clib.h
> > +43
> > [root@8f57181df3a1 vpp_c_api_examples]# vim /usr/include/vppinfra/clib.h
> > +43
> > [root@8f57181df3a1 vpp_c_api_examples]# gcc --version
> > gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
> > Copyright (C) 2015 Free Software Foundation, Inc.
> > This is free software; see the source for copying conditions.  There is NO
> > warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
> > PURPOSE.
> >
> > [root@8f57181df3a1 vpp_c_api_examples]#
> >
> >
> > -----------------
> >
> > c -code
> > ----------------
> >
> >
> > #include<stdio.h>
> > #include<stdlib.h>
> > #include <vlibapi/api.h>
> > #include <vlibmemory/api.h>
> > #include <vpp/api/vpe_msg_enum.h>
> >
> > #define vl_typedefs
> > #define vl_endianfun
> > #include <vpp/api/vpe_all_api_h.h>
> > #undef vl_typedefs
> > #undef vl_endianfun
> >
> > int main()
> > {
> >    char *name = "vpp-test-app";
> >
> >    clib_mem_init_thread_safe (0, 64ULL << 20);
> >
> >    if (vl_client_api_map("/vpe-api"))
> >    {
> >         printf("unable to map....\n");
> >         goto quit;
> >    }
> >    if (vl_client_connect("vpp-test-app", 0, 32) < 0)
> >    {
> >         printf("unable to connect \n");
> >         vl_client_api_unmap();
> >         goto quit;
> >    }
> >    printf("successfully connected... \n");
> >  quit:
> >         return 0;
> > }
> >
> >
> > ------------
> >
> >
> > Can you please suggest what can i be doing worng ?
> >
> >
> > Thanks,
> > Regards,
> > Venu
> >
> >
> > On Thu, 30 Sept 2021 at 13:21, <otroan@...
> > <mailto:otroan@...> > wrote:
> >
> >
> >       Hi Venu,
> >
> >       > Any examples for VAPI shared to use binary APIs ?
> >
> >       Try this for a start:
> >       https://git.fd.io/vpp/tree/src/vpp-api/vapi/vapi_c_test.c
> >
> >       Cheers,
> >       Ole
> >
> >
>
>
>
>
>
>


Venumadhav Josyula
 

Hi Ole,

So instead of the code below, I tried the code from "src/vpp-api/client/test.c". I directly copied this into my .c file. And following commands i used

compilation + linking : - gcc vpp_api_client_vac_layer.c -o vpp_api_client_vac_layer.o -lpthread -lvlibmemoryclient -lvppinfra -lvppapiclient -I/usr/include/
code is below
#include<stdio.h>
#include<stdlib.h>
#include <vnet/vnet.h>
#include <vlib/vlib.h>
#include <vlib/unix/unix.h>
#include <vlibapi/api.h>
#include <vppinfra/time.h>
#include <vpp/api/vpe_msg_enum.h>
#include <signal.h>

#include<vpp-api/client/vppapiclient.h>
#include<vpp-api/client/stat_client.h>

#define vl_typedefs             /* define message structures */
#include <vpp/api/vpe_all_api_h.h>
#undef vl_typedefs


volatile int sigterm_received = 0;
volatile u32 result_ready;
volatile u16 result_msg_id;

/* M_NOALLOC: construct, but don't yet send a message */

#define M_NOALLOC(T,t)                          \
        do {                                          \
                result_ready = 0;                           \
                clib_memset (mp, 0, sizeof (*mp));          \
                mp->_vl_msg_id = ntohs (VL_API_##T);        \
                mp->client_index = am->my_client_index;     \
        } while(0);

void
wrap_vac_callback (unsigned char *data, int len)
{
        result_ready = 1;
        result_msg_id = ntohs(*((u16 *)data));
}

        static void
test_connect ()
{
        static int i;
        int rv = vac_connect("vac_client", NULL, wrap_vac_callback, 32 /* rx queue-length*/);
        if (rv != 0) {
                printf("Connect failed: %d\n", rv);
                exit(rv);
        }
        printf(".");
        vac_disconnect();
        i++;
}

static void test_messages (void)
{
        api_main_t * am = vlibapi_get_main();
        vl_api_show_version_t message;
        vl_api_show_version_t *mp;
        int async = 1;

        int rv = vac_connect("vac_client", NULL, wrap_vac_callback, 32 /* rx queue-length*/);
        if (rv != 0) {
                printf("Connect failed: %d\n", rv);
                exit(rv);
        }

        double timestamp_start = unix_time_now_nsec() * 1e-6;

        /*
         * Test vpe_api_write and vpe_api_read to send and recv message for an
         * API
         */
        int i;
        long int no_msgs = 10000;
        mp = &message;

        for (i = 0; i < no_msgs; i++) {
                /* Construct the API message */
                M_NOALLOC(SHOW_VERSION, show_version);
                vac_write((char *)mp, sizeof(*mp));
#ifndef __COVERITY__
                /* As given, async is always 1. Shut up Coverity about it */
                if (!async)
                        while (result_ready == 0);
#endif
        }
        if (async) {
                vl_api_control_ping_t control;
                vl_api_control_ping_t *mp;
                mp = &control;
                M_NOALLOC(CONTROL_PING, control_ping);
                vac_write((char *)mp, sizeof(*mp));

                while (result_msg_id != VL_API_CONTROL_PING_REPLY);
        }

        double timestamp_end = unix_time_now_nsec() * 1e-6;
        printf("\nTook %.2f msec, %.0f msgs/msec \n", (timestamp_end - timestamp_start),
                        no_msgs/(timestamp_end - timestamp_start));
        printf("Exiting...\n");
        vac_disconnect();
}


int main (int argc, char ** argv)
{
#if 0
        clib_mem_init (0, 3ULL << 30);
        test_stats();
#endif

        int i;

        for (i = 0; i < 1000; i++) {
                test_connect();
        }

        test_messages();
        exit (0);
}

It compiled successfully, i got following assert for heap
[root@8f57181df3a1 vpp_c_api_examples]# gdb ./vpp_api_client_vac_layer.o
GNU gdb (GDB) Red Hat Enterprise Linux 8.3-3.el7
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./vpp_api_client_vac_layer.o...
(No debugging symbols found in ./vpp_api_client_vac_layer.o)
(gdb) r
Starting program: /root/vpp_c_api_examples/vpp_api_client_vac_layer.o
Missing separate debuginfos, use: debuginfo-install glibc-2.17-324.el7_9.x86_64
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
vpp_api_client_vac_layer.o: /vpp/build-root/rpmbuild/vpp-21.06.0/src/vpp-api/client/client.c:295: vac_connect: Assertion `clib_mem_get_heap ()' failed.

Program received signal SIGABRT, Aborted.
0x00007ffff7827387 in raise () from /lib64/libc.so.6
(gdb) bt
#0  0x00007ffff7827387 in raise () from /lib64/libc.so.6
#1  0x00007ffff7828a78 in abort () from /lib64/libc.so.6
#2  0x00007ffff78201a6 in __assert_fail_base () from /lib64/libc.so.6
#3  0x00007ffff7820252 in __assert_fail () from /lib64/libc.so.6
#4  0x00007ffff7f57bcd in vac_connect (name=0x402010 "vac_client", chroot_prefix=0x0, cb=0x4011d2 <wrap_vac_callback>, rx_qlen=32)
    at /usr/src/debug/vpp-21.06.0/src/vpp-api/client/client.c:314
#5  0x0000000000401227 in test_connect ()
#6  0x0000000000401687 in main ()
(gdb)

Startup.conf
[root@8f57181df3a1 vpp_c_api_examples]# cat /etc/vpp/startup.conf
unix {
  #nodaemon
  #interactive
  log /var/log/vpp/vpp.log
  cli-listen /run/vpp/cli.sock
  gid vpp
  #exec /etc/ipsec-setup.txt
}

cpu {
  main-core 2
}

dpdk {
  dev default {
     num-rx-desc 512
     num-tx-desc 512
  }
  socket-mem 1024
  dev 0000:00:04.0
  uio-driver uio_pci_generic
}

logging {
  default-log-level debug
  default-syslog-log-level info
}
[root@8f57181df3a1 vpp_c_api_examples]#
I
Is there some setting  i need to do in the startup.conf ?

Please suggest a way to fix this assert.

Thanks,
Regards
Venu


On Thu, 30 Sept 2021 at 21:08, Benoit Ganne (bganne) <bganne@...> wrote:
You should remove -lvlib it is not needed here.
If you really want to link with vlib, you must fix the link ordering: vlib depends upon vppinfra (where os_exit is defined) so you'd need link as -lvlib -lvppinfra instead of the opposite (the C linker scan libraries symbols in reverse order, so symbols declared in a library are available to libraries listed *before*).

Best
ben

> -----Original Message-----
> From: vpp-dev@... <vpp-dev@...> On Behalf Of Venumadhav
> Josyula
> Sent: jeudi 30 septembre 2021 16:09
> To: Akash S R <akashsr.akashsr@...>
> Cc: Benoit Ganne (bganne) <bganne@...>; Ole Troan
> <otroan@...>; RaviKiran Veldanda <ravi.jupvpp@...>; vpp-
> dev <vpp-dev@...>
> Subject: Re: [vpp-dev] VPP Socket API how to use from the application
> #socket-api #vpp #sock-api
>
> Hi Akash,
>
> Thansks, now after devtoolset,
>
>
> @Benoit Ganne (bganne) <mailto:bganne@...>  , @Ole Troan
> <mailto:otroan@...>
>
> i am getting following error
>
> [root@8f57181df3a1 vpp_c_api_examples]# gcc vpp_api_client_test3.c -o
> vpp_api_client_test3.o -lvlibmemoryclient -lsvm -lvppinfra -lvlib
> /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld:
> /lib/../lib64/libvlib.so: undefined reference to
> `classify_get_trace_chain'
> /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld:
> /lib/../lib64/libvlib.so: undefined reference to
> `stat_segment_register_gauge'
> /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld:
> /lib/../lib64/libvlib.so: undefined reference to `os_exit'
> collect2: error: ld returned 1 exit status
> [root@8f57181df3a1 vpp_c_api_examples]#
>
> Let me paste the code again,
> #include<stdio.h>
> #include<stdlib.h>
> #include <vlibapi/api.h>
> #include <vlibmemory/api.h>
> #include <vpp/api/vpe_msg_enum.h>
>
> #define vl_typedefs
> #define vl_endianfun
> #include <vpp/api/vpe_all_api_h.h>
> #undef vl_typedefs
> #undef vl_endianfun
>
> int main()
> {
>    char *name = "vpp-test-app";
>
>    clib_mem_init_thread_safe (0, 64ULL << 20);
>
>    if (vl_client_api_map("/vpe-api"))
>    {
>         printf("unable to map....\n");
>         goto quit;
>    }
>    if (vl_client_connect("vpp-test-app", 0, 32) < 0)
>    {
>         printf("unable to connect \n");
>         vl_client_api_unmap();
>         goto quit;
>    }
>    printf("successfully connected... \n");
>  quit:
>         return 0;
> }
>
> Is this wrong way, i am trying to use APIs ?
>
> Thanks,
> Regards
> Venu
>
>
> On Thu, 30 Sept 2021 at 19:00, Akash S R <akashsr.akashsr@...
> <mailto:akashsr.akashsr@...> > wrote:
>
>
>       Hey Venu,
>
>       Try "scl enable devtoolset-9 bash" inside your docker or update your
> gcc version.
>
>
>       /Akash S R
>
>       On Thu, Sep 30, 2021, 18:54 Venumadhav Josyula <vjosyula@...
> <mailto:vjosyula@...> > wrote:
>
>
>               Hi Benoit,
>
>               Thanks for quick reply.
>
>               I have docker with following
>               [root@8f57181df3a1 vpp_c_api_examples]# rpm -qa | grep vpp
>               vpp-lib-21.06.0-4~g0d9d3a0.x86_64
>               vpp-api-lua-21.06.0-4~g0d9d3a0.x86_64
>               vpp-api-python3-21.06.0-4~g0d9d3a0.x86_64
>               vpp-debuginfo-21.06.0-4~g0d9d3a0.x86_64
>               vpp-selinux-policy-21.06.0-4~g0d9d3a0.x86_64
>               vpp-21.06.0-4~g0d9d3a0.x86_64
>               vpp-plugins-21.06.0-4~g0d9d3a0.x86_64
>               vpp-devel-21.06.0-4~g0d9d3a0.x86_64
>
>               This will vpp running in it.
>
>               [root@8f57181df3a1 /]# cat /etc/redhat-release
>               CentOS Linux release 7.3.1611 (Core)
>               [root@8f57181df3a1 /]#
>
>               > Eg. use devtoolset-9 (gcc-9).
>
>
>               How do I use it ?
>
>               Thanks,
>               Regards,
>               Venu
>
>
>               On Thu, 30 Sept 2021 at 18:47, Benoit Ganne (bganne)
> <bganne@... <mailto:bganne@...> > wrote:
>
>
>                       You should upgrade your compiler... GCC-4 is way too
> old.
>                       Eg. use devtoolset-9 (gcc-9).
>
>                       Best
>                       ben
>
>                       > -----Original Message-----
>                       > From: vpp-dev@... <mailto:vpp-dev@...>
> <vpp-dev@... <mailto:vpp-dev@...> > On Behalf Of
> Venumadhav
>                       > Josyula
>                       > Sent: jeudi 30 septembre 2021 14:49
>                       > To: otroan@... <mailto:otroan@...>
>                       > Cc: RaviKiran Veldanda <ravi.jupvpp@...
> <mailto:ravi.jupvpp@...> >; vpp-dev <vpp-
>                       > dev@... <mailto:dev@...> >
>                       > Subject: Re: [vpp-dev] VPP Socket API how to use from
> the application
>                       > #socket-api #vpp #sock-api
>                       >
>                       > Hi Ole / Others,
>                       >
>                       >
>                       >
>                       > Thanks for your email, i getting following compilation
> error
>                       > [root@8f57181df3a1 vpp_c_api_examples]# gcc
> vpp_api_client_test3.c -o
>                       > vpp_api_client_test3.o -lvlibmemoryclient -lsvm -
> lvppinfra -lvlib
>                       > In file included from
> /usr/include/vppinfra/error.h:41:0,
>                       >                  from /usr/include/vlibapi/api.h:24,
>                       >                  from vpp_api_client_test3.c:3:
>                       > /usr/include/vppinfra/clib.h:43:18: error: missing
> binary operator before
>                       > token "("
>                       >  #if __has_include(<vppinfra/config.h>)
>                       >                   ^
>                       > In file included from
> /usr/include/vppinfra/mem.h:49:0,
>                       >                  from /usr/include/vppinfra/vec.h:42,
>                       >                  from
> /usr/include/vppinfra/error.h:53,
>                       >                  from /usr/include/vlibapi/api.h:24,
>                       >                  from vpp_api_client_test3.c:3:
>                       > /usr/include/vppinfra/string.h:92:34: error: expected
> ';', ',' or ')'
>                       > before 'dst'
>                       >  clib_memcpy_fast (void *restrict dst, const void
> *restrict src, size_t n)
>                       >                                   ^
>                       > [root@8f57181df3a1 vpp_c_api_examples]# vim
> /usr/include/vppinfra/clib.h
>                       > +43
>                       > [root@8f57181df3a1 vpp_c_api_examples]# vim
> /usr/include/vppinfra/clib.h
>                       > +43
>                       > [root@8f57181df3a1 vpp_c_api_examples]# gcc --version
>                       > gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
>                       > Copyright (C) 2015 Free Software Foundation, Inc.
>                       > This is free software; see the source for copying
> conditions.  There is NO
>                       > warranty; not even for MERCHANTABILITY or FITNESS FOR
> A PARTICULAR
>                       > PURPOSE.
>                       >
>                       > [root@8f57181df3a1 vpp_c_api_examples]#
>                       >
>                       >
>                       > -----------------
>                       >
>                       > c -code
>                       > ----------------
>                       >
>                       >
>                       > #include<stdio.h>
>                       > #include<stdlib.h>
>                       > #include <vlibapi/api.h>
>                       > #include <vlibmemory/api.h>
>                       > #include <vpp/api/vpe_msg_enum.h>
>                       >
>                       > #define vl_typedefs
>                       > #define vl_endianfun
>                       > #include <vpp/api/vpe_all_api_h.h>
>                       > #undef vl_typedefs
>                       > #undef vl_endianfun
>                       >
>                       > int main()
>                       > {
>                       >    char *name = "vpp-test-app";
>                       >
>                       >    clib_mem_init_thread_safe (0, 64ULL << 20);
>                       >
>                       >    if (vl_client_api_map("/vpe-api"))
>                       >    {
>                       >         printf("unable to map....\n");
>                       >         goto quit;
>                       >    }
>                       >    if (vl_client_connect("vpp-test-app", 0, 32) < 0)
>                       >    {
>                       >         printf("unable to connect \n");
>                       >         vl_client_api_unmap();
>                       >         goto quit;
>                       >    }
>                       >    printf("successfully connected... \n");
>                       >  quit:
>                       >         return 0;
>                       > }
>                       >
>                       >
>                       > ------------
>                       >
>                       >
>                       > Can you please suggest what can i be doing worng ?
>                       >
>                       >
>                       > Thanks,
>                       > Regards,
>                       > Venu
>                       >
>                       >
>                       > On Thu, 30 Sept 2021 at 13:21, <otroan@...
> <mailto:otroan@...>
>                       > <mailto:otroan@...
> <mailto:otroan@...> > > wrote:
>                       >
>                       >
>                       >       Hi Venu,
>                       >
>                       >       > Any examples for VAPI shared to use binary
> APIs ?
>                       >
>                       >       Try this for a start:
>                       >       https://git.fd.io/vpp/tree/src/vpp-
> api/vapi/vapi_c_test.c
>                       >
>                       >       Cheers,
>                       >       Ole
>                       >
>                       >
>
>
>
>
>


Stanislav Zaikin
 

You need to uncomment clib_mem_init


On Fri, 1 Oct 2021 at 10:01, Venumadhav Josyula <vjosyula@...> wrote:
Hi Ole,

So instead of the code below, I tried the code from "src/vpp-api/client/test.c". I directly copied this into my .c file. And following commands i used

compilation + linking : - gcc vpp_api_client_vac_layer.c -o vpp_api_client_vac_layer.o -lpthread -lvlibmemoryclient -lvppinfra -lvppapiclient -I/usr/include/
code is below
#include<stdio.h>
#include<stdlib.h>
#include <vnet/vnet.h>
#include <vlib/vlib.h>
#include <vlib/unix/unix.h>
#include <vlibapi/api.h>
#include <vppinfra/time.h>
#include <vpp/api/vpe_msg_enum.h>
#include <signal.h>

#include<vpp-api/client/vppapiclient.h>
#include<vpp-api/client/stat_client.h>

#define vl_typedefs             /* define message structures */
#include <vpp/api/vpe_all_api_h.h>
#undef vl_typedefs


volatile int sigterm_received = 0;
volatile u32 result_ready;
volatile u16 result_msg_id;

/* M_NOALLOC: construct, but don't yet send a message */

#define M_NOALLOC(T,t)                          \
        do {                                          \
                result_ready = 0;                           \
                clib_memset (mp, 0, sizeof (*mp));          \
                mp->_vl_msg_id = ntohs (VL_API_##T);        \
                mp->client_index = am->my_client_index;     \
        } while(0);

void
wrap_vac_callback (unsigned char *data, int len)
{
        result_ready = 1;
        result_msg_id = ntohs(*((u16 *)data));
}

        static void
test_connect ()
{
        static int i;
        int rv = vac_connect("vac_client", NULL, wrap_vac_callback, 32 /* rx queue-length*/);
        if (rv != 0) {
                printf("Connect failed: %d\n", rv);
                exit(rv);
        }
        printf(".");
        vac_disconnect();
        i++;
}

static void test_messages (void)
{
        api_main_t * am = vlibapi_get_main();
        vl_api_show_version_t message;
        vl_api_show_version_t *mp;
        int async = 1;

        int rv = vac_connect("vac_client", NULL, wrap_vac_callback, 32 /* rx queue-length*/);
        if (rv != 0) {
                printf("Connect failed: %d\n", rv);
                exit(rv);
        }

        double timestamp_start = unix_time_now_nsec() * 1e-6;

        /*
         * Test vpe_api_write and vpe_api_read to send and recv message for an
         * API
         */
        int i;
        long int no_msgs = 10000;
        mp = &message;

        for (i = 0; i < no_msgs; i++) {
                /* Construct the API message */
                M_NOALLOC(SHOW_VERSION, show_version);
                vac_write((char *)mp, sizeof(*mp));
#ifndef __COVERITY__
                /* As given, async is always 1. Shut up Coverity about it */
                if (!async)
                        while (result_ready == 0);
#endif
        }
        if (async) {
                vl_api_control_ping_t control;
                vl_api_control_ping_t *mp;
                mp = &control;
                M_NOALLOC(CONTROL_PING, control_ping);
                vac_write((char *)mp, sizeof(*mp));

                while (result_msg_id != VL_API_CONTROL_PING_REPLY);
        }

        double timestamp_end = unix_time_now_nsec() * 1e-6;
        printf("\nTook %.2f msec, %.0f msgs/msec \n", (timestamp_end - timestamp_start),
                        no_msgs/(timestamp_end - timestamp_start));
        printf("Exiting...\n");
        vac_disconnect();
}


int main (int argc, char ** argv)
{
#if 0
        clib_mem_init (0, 3ULL << 30);
        test_stats();
#endif

        int i;

        for (i = 0; i < 1000; i++) {
                test_connect();
        }

        test_messages();
        exit (0);
}

It compiled successfully, i got following assert for heap
[root@8f57181df3a1 vpp_c_api_examples]# gdb ./vpp_api_client_vac_layer.o
GNU gdb (GDB) Red Hat Enterprise Linux 8.3-3.el7
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./vpp_api_client_vac_layer.o...
(No debugging symbols found in ./vpp_api_client_vac_layer.o)
(gdb) r
Starting program: /root/vpp_c_api_examples/vpp_api_client_vac_layer.o
Missing separate debuginfos, use: debuginfo-install glibc-2.17-324.el7_9.x86_64
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
vpp_api_client_vac_layer.o: /vpp/build-root/rpmbuild/vpp-21.06.0/src/vpp-api/client/client.c:295: vac_connect: Assertion `clib_mem_get_heap ()' failed.

Program received signal SIGABRT, Aborted.
0x00007ffff7827387 in raise () from /lib64/libc.so.6
(gdb) bt
#0  0x00007ffff7827387 in raise () from /lib64/libc.so.6
#1  0x00007ffff7828a78 in abort () from /lib64/libc.so.6
#2  0x00007ffff78201a6 in __assert_fail_base () from /lib64/libc.so.6
#3  0x00007ffff7820252 in __assert_fail () from /lib64/libc.so.6
#4  0x00007ffff7f57bcd in vac_connect (name=0x402010 "vac_client", chroot_prefix=0x0, cb=0x4011d2 <wrap_vac_callback>, rx_qlen=32)
    at /usr/src/debug/vpp-21.06.0/src/vpp-api/client/client.c:314
#5  0x0000000000401227 in test_connect ()
#6  0x0000000000401687 in main ()
(gdb)

Startup.conf
[root@8f57181df3a1 vpp_c_api_examples]# cat /etc/vpp/startup.conf
unix {
  #nodaemon
  #interactive
  log /var/log/vpp/vpp.log
  cli-listen /run/vpp/cli.sock
  gid vpp
  #exec /etc/ipsec-setup.txt
}

cpu {
  main-core 2
}

dpdk {
  dev default {
     num-rx-desc 512
     num-tx-desc 512
  }
  socket-mem 1024
  dev 0000:00:04.0
  uio-driver uio_pci_generic
}

logging {
  default-log-level debug
  default-syslog-log-level info
}
[root@8f57181df3a1 vpp_c_api_examples]#
I
Is there some setting  i need to do in the startup.conf ?

Please suggest a way to fix this assert.

Thanks,
Regards
Venu

On Thu, 30 Sept 2021 at 21:08, Benoit Ganne (bganne) <bganne@...> wrote:
You should remove -lvlib it is not needed here.
If you really want to link with vlib, you must fix the link ordering: vlib depends upon vppinfra (where os_exit is defined) so you'd need link as -lvlib -lvppinfra instead of the opposite (the C linker scan libraries symbols in reverse order, so symbols declared in a library are available to libraries listed *before*).

Best
ben

> -----Original Message-----
> From: vpp-dev@... <vpp-dev@...> On Behalf Of Venumadhav
> Josyula
> Sent: jeudi 30 septembre 2021 16:09
> To: Akash S R <akashsr.akashsr@...>
> Cc: Benoit Ganne (bganne) <bganne@...>; Ole Troan
> <otroan@...>; RaviKiran Veldanda <ravi.jupvpp@...>; vpp-
> dev <vpp-dev@...>
> Subject: Re: [vpp-dev] VPP Socket API how to use from the application
> #socket-api #vpp #sock-api
>
> Hi Akash,
>
> Thansks, now after devtoolset,
>
>
> @Benoit Ganne (bganne) <mailto:bganne@...>  , @Ole Troan
> <mailto:otroan@...>
>
> i am getting following error
>
> [root@8f57181df3a1 vpp_c_api_examples]# gcc vpp_api_client_test3.c -o
> vpp_api_client_test3.o -lvlibmemoryclient -lsvm -lvppinfra -lvlib
> /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld:
> /lib/../lib64/libvlib.so: undefined reference to
> `classify_get_trace_chain'
> /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld:
> /lib/../lib64/libvlib.so: undefined reference to
> `stat_segment_register_gauge'
> /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld:
> /lib/../lib64/libvlib.so: undefined reference to `os_exit'
> collect2: error: ld returned 1 exit status
> [root@8f57181df3a1 vpp_c_api_examples]#
>
> Let me paste the code again,
> #include<stdio.h>
> #include<stdlib.h>
> #include <vlibapi/api.h>
> #include <vlibmemory/api.h>
> #include <vpp/api/vpe_msg_enum.h>
>
> #define vl_typedefs
> #define vl_endianfun
> #include <vpp/api/vpe_all_api_h.h>
> #undef vl_typedefs
> #undef vl_endianfun
>
> int main()
> {
>    char *name = "vpp-test-app";
>
>    clib_mem_init_thread_safe (0, 64ULL << 20);
>
>    if (vl_client_api_map("/vpe-api"))
>    {
>         printf("unable to map....\n");
>         goto quit;
>    }
>    if (vl_client_connect("vpp-test-app", 0, 32) < 0)
>    {
>         printf("unable to connect \n");
>         vl_client_api_unmap();
>         goto quit;
>    }
>    printf("successfully connected... \n");
>  quit:
>         return 0;
> }
>
> Is this wrong way, i am trying to use APIs ?
>
> Thanks,
> Regards
> Venu
>
>
> On Thu, 30 Sept 2021 at 19:00, Akash S R <akashsr.akashsr@...
> <mailto:akashsr.akashsr@...> > wrote:
>
>
>       Hey Venu,
>
>       Try "scl enable devtoolset-9 bash" inside your docker or update your
> gcc version.
>
>
>       /Akash S R
>
>       On Thu, Sep 30, 2021, 18:54 Venumadhav Josyula <vjosyula@...
> <mailto:vjosyula@...> > wrote:
>
>
>               Hi Benoit,
>
>               Thanks for quick reply.
>
>               I have docker with following
>               [root@8f57181df3a1 vpp_c_api_examples]# rpm -qa | grep vpp
>               vpp-lib-21.06.0-4~g0d9d3a0.x86_64
>               vpp-api-lua-21.06.0-4~g0d9d3a0.x86_64
>               vpp-api-python3-21.06.0-4~g0d9d3a0.x86_64
>               vpp-debuginfo-21.06.0-4~g0d9d3a0.x86_64
>               vpp-selinux-policy-21.06.0-4~g0d9d3a0.x86_64
>               vpp-21.06.0-4~g0d9d3a0.x86_64
>               vpp-plugins-21.06.0-4~g0d9d3a0.x86_64
>               vpp-devel-21.06.0-4~g0d9d3a0.x86_64
>
>               This will vpp running in it.
>
>               [root@8f57181df3a1 /]# cat /etc/redhat-release
>               CentOS Linux release 7.3.1611 (Core)
>               [root@8f57181df3a1 /]#
>
>               > Eg. use devtoolset-9 (gcc-9).
>
>
>               How do I use it ?
>
>               Thanks,
>               Regards,
>               Venu
>
>
>               On Thu, 30 Sept 2021 at 18:47, Benoit Ganne (bganne)
> <bganne@... <mailto:bganne@...> > wrote:
>
>
>                       You should upgrade your compiler... GCC-4 is way too
> old.
>                       Eg. use devtoolset-9 (gcc-9).
>
>                       Best
>                       ben
>
>                       > -----Original Message-----
>                       > From: vpp-dev@... <mailto:vpp-dev@...>
> <vpp-dev@... <mailto:vpp-dev@...> > On Behalf Of
> Venumadhav
>                       > Josyula
>                       > Sent: jeudi 30 septembre 2021 14:49
>                       > To: otroan@... <mailto:otroan@...>
>                       > Cc: RaviKiran Veldanda <ravi.jupvpp@...
> <mailto:ravi.jupvpp@...> >; vpp-dev <vpp-
>                       > dev@... <mailto:dev@...> >
>                       > Subject: Re: [vpp-dev] VPP Socket API how to use from
> the application
>                       > #socket-api #vpp #sock-api
>                       >
>                       > Hi Ole / Others,
>                       >
>                       >
>                       >
>                       > Thanks for your email, i getting following compilation
> error
>                       > [root@8f57181df3a1 vpp_c_api_examples]# gcc
> vpp_api_client_test3.c -o
>                       > vpp_api_client_test3.o -lvlibmemoryclient -lsvm -
> lvppinfra -lvlib
>                       > In file included from
> /usr/include/vppinfra/error.h:41:0,
>                       >                  from /usr/include/vlibapi/api.h:24,
>                       >                  from vpp_api_client_test3.c:3:
>                       > /usr/include/vppinfra/clib.h:43:18: error: missing
> binary operator before
>                       > token "("
>                       >  #if __has_include(<vppinfra/config.h>)
>                       >                   ^
>                       > In file included from
> /usr/include/vppinfra/mem.h:49:0,
>                       >                  from /usr/include/vppinfra/vec.h:42,
>                       >                  from
> /usr/include/vppinfra/error.h:53,
>                       >                  from /usr/include/vlibapi/api.h:24,
>                       >                  from vpp_api_client_test3.c:3:
>                       > /usr/include/vppinfra/string.h:92:34: error: expected
> ';', ',' or ')'
>                       > before 'dst'
>                       >  clib_memcpy_fast (void *restrict dst, const void
> *restrict src, size_t n)
>                       >                                   ^
>                       > [root@8f57181df3a1 vpp_c_api_examples]# vim
> /usr/include/vppinfra/clib.h
>                       > +43
>                       > [root@8f57181df3a1 vpp_c_api_examples]# vim
> /usr/include/vppinfra/clib.h
>                       > +43
>                       > [root@8f57181df3a1 vpp_c_api_examples]# gcc --version
>                       > gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
>                       > Copyright (C) 2015 Free Software Foundation, Inc.
>                       > This is free software; see the source for copying
> conditions.  There is NO
>                       > warranty; not even for MERCHANTABILITY or FITNESS FOR
> A PARTICULAR
>                       > PURPOSE.
>                       >
>                       > [root@8f57181df3a1 vpp_c_api_examples]#
>                       >
>                       >
>                       > -----------------
>                       >
>                       > c -code
>                       > ----------------
>                       >
>                       >
>                       > #include<stdio.h>
>                       > #include<stdlib.h>
>                       > #include <vlibapi/api.h>
>                       > #include <vlibmemory/api.h>
>                       > #include <vpp/api/vpe_msg_enum.h>
>                       >
>                       > #define vl_typedefs
>                       > #define vl_endianfun
>                       > #include <vpp/api/vpe_all_api_h.h>
>                       > #undef vl_typedefs
>                       > #undef vl_endianfun
>                       >
>                       > int main()
>                       > {
>                       >    char *name = "vpp-test-app";
>                       >
>                       >    clib_mem_init_thread_safe (0, 64ULL << 20);
>                       >
>                       >    if (vl_client_api_map("/vpe-api"))
>                       >    {
>                       >         printf("unable to map....\n");
>                       >         goto quit;
>                       >    }
>                       >    if (vl_client_connect("vpp-test-app", 0, 32) < 0)
>                       >    {
>                       >         printf("unable to connect \n");
>                       >         vl_client_api_unmap();
>                       >         goto quit;
>                       >    }
>                       >    printf("successfully connected... \n");
>                       >  quit:
>                       >         return 0;
>                       > }
>                       >
>                       >
>                       > ------------
>                       >
>                       >
>                       > Can you please suggest what can i be doing worng ?
>                       >
>                       >
>                       > Thanks,
>                       > Regards,
>                       > Venu
>                       >
>                       >
>                       > On Thu, 30 Sept 2021 at 13:21, <otroan@...
> <mailto:otroan@...>
>                       > <mailto:otroan@...
> <mailto:otroan@...> > > wrote:
>                       >
>                       >
>                       >       Hi Venu,
>                       >
>                       >       > Any examples for VAPI shared to use binary
> APIs ?
>                       >
>                       >       Try this for a start:
>                       >       https://git.fd.io/vpp/tree/src/vpp-
> api/vapi/vapi_c_test.c
>                       >
>                       >       Cheers,
>                       >       Ole
>                       >
>                       >
>
>
>
>
>






--
Best regards
Stanislav Zaikin


Venumadhav Josyula
 

Thanks, my mistake, it worked...


On Fri, 1 Oct 2021 at 13:34, Stanislav Zaikin <zstaseg@...> wrote:
You need to uncomment clib_mem_init

On Fri, 1 Oct 2021 at 10:01, Venumadhav Josyula <vjosyula@...> wrote:
Hi Ole,

So instead of the code below, I tried the code from "src/vpp-api/client/test.c". I directly copied this into my .c file. And following commands i used

compilation + linking : - gcc vpp_api_client_vac_layer.c -o vpp_api_client_vac_layer.o -lpthread -lvlibmemoryclient -lvppinfra -lvppapiclient -I/usr/include/
code is below
#include<stdio.h>
#include<stdlib.h>
#include <vnet/vnet.h>
#include <vlib/vlib.h>
#include <vlib/unix/unix.h>
#include <vlibapi/api.h>
#include <vppinfra/time.h>
#include <vpp/api/vpe_msg_enum.h>
#include <signal.h>

#include<vpp-api/client/vppapiclient.h>
#include<vpp-api/client/stat_client.h>

#define vl_typedefs             /* define message structures */
#include <vpp/api/vpe_all_api_h.h>
#undef vl_typedefs


volatile int sigterm_received = 0;
volatile u32 result_ready;
volatile u16 result_msg_id;

/* M_NOALLOC: construct, but don't yet send a message */

#define M_NOALLOC(T,t)                          \
        do {                                          \
                result_ready = 0;                           \
                clib_memset (mp, 0, sizeof (*mp));          \
                mp->_vl_msg_id = ntohs (VL_API_##T);        \
                mp->client_index = am->my_client_index;     \
        } while(0);

void
wrap_vac_callback (unsigned char *data, int len)
{
        result_ready = 1;
        result_msg_id = ntohs(*((u16 *)data));
}

        static void
test_connect ()
{
        static int i;
        int rv = vac_connect("vac_client", NULL, wrap_vac_callback, 32 /* rx queue-length*/);
        if (rv != 0) {
                printf("Connect failed: %d\n", rv);
                exit(rv);
        }
        printf(".");
        vac_disconnect();
        i++;
}

static void test_messages (void)
{
        api_main_t * am = vlibapi_get_main();
        vl_api_show_version_t message;
        vl_api_show_version_t *mp;
        int async = 1;

        int rv = vac_connect("vac_client", NULL, wrap_vac_callback, 32 /* rx queue-length*/);
        if (rv != 0) {
                printf("Connect failed: %d\n", rv);
                exit(rv);
        }

        double timestamp_start = unix_time_now_nsec() * 1e-6;

        /*
         * Test vpe_api_write and vpe_api_read to send and recv message for an
         * API
         */
        int i;
        long int no_msgs = 10000;
        mp = &message;

        for (i = 0; i < no_msgs; i++) {
                /* Construct the API message */
                M_NOALLOC(SHOW_VERSION, show_version);
                vac_write((char *)mp, sizeof(*mp));
#ifndef __COVERITY__
                /* As given, async is always 1. Shut up Coverity about it */
                if (!async)
                        while (result_ready == 0);
#endif
        }
        if (async) {
                vl_api_control_ping_t control;
                vl_api_control_ping_t *mp;
                mp = &control;
                M_NOALLOC(CONTROL_PING, control_ping);
                vac_write((char *)mp, sizeof(*mp));

                while (result_msg_id != VL_API_CONTROL_PING_REPLY);
        }

        double timestamp_end = unix_time_now_nsec() * 1e-6;
        printf("\nTook %.2f msec, %.0f msgs/msec \n", (timestamp_end - timestamp_start),
                        no_msgs/(timestamp_end - timestamp_start));
        printf("Exiting...\n");
        vac_disconnect();
}


int main (int argc, char ** argv)
{
#if 0
        clib_mem_init (0, 3ULL << 30);
        test_stats();
#endif

        int i;

        for (i = 0; i < 1000; i++) {
                test_connect();
        }

        test_messages();
        exit (0);
}

It compiled successfully, i got following assert for heap
[root@8f57181df3a1 vpp_c_api_examples]# gdb ./vpp_api_client_vac_layer.o
GNU gdb (GDB) Red Hat Enterprise Linux 8.3-3.el7
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./vpp_api_client_vac_layer.o...
(No debugging symbols found in ./vpp_api_client_vac_layer.o)
(gdb) r
Starting program: /root/vpp_c_api_examples/vpp_api_client_vac_layer.o
Missing separate debuginfos, use: debuginfo-install glibc-2.17-324.el7_9.x86_64
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
vpp_api_client_vac_layer.o: /vpp/build-root/rpmbuild/vpp-21.06.0/src/vpp-api/client/client.c:295: vac_connect: Assertion `clib_mem_get_heap ()' failed.

Program received signal SIGABRT, Aborted.
0x00007ffff7827387 in raise () from /lib64/libc.so.6
(gdb) bt
#0  0x00007ffff7827387 in raise () from /lib64/libc.so.6
#1  0x00007ffff7828a78 in abort () from /lib64/libc.so.6
#2  0x00007ffff78201a6 in __assert_fail_base () from /lib64/libc.so.6
#3  0x00007ffff7820252 in __assert_fail () from /lib64/libc.so.6
#4  0x00007ffff7f57bcd in vac_connect (name=0x402010 "vac_client", chroot_prefix=0x0, cb=0x4011d2 <wrap_vac_callback>, rx_qlen=32)
    at /usr/src/debug/vpp-21.06.0/src/vpp-api/client/client.c:314
#5  0x0000000000401227 in test_connect ()
#6  0x0000000000401687 in main ()
(gdb)

Startup.conf
[root@8f57181df3a1 vpp_c_api_examples]# cat /etc/vpp/startup.conf
unix {
  #nodaemon
  #interactive
  log /var/log/vpp/vpp.log
  cli-listen /run/vpp/cli.sock
  gid vpp
  #exec /etc/ipsec-setup.txt
}

cpu {
  main-core 2
}

dpdk {
  dev default {
     num-rx-desc 512
     num-tx-desc 512
  }
  socket-mem 1024
  dev 0000:00:04.0
  uio-driver uio_pci_generic
}

logging {
  default-log-level debug
  default-syslog-log-level info
}
[root@8f57181df3a1 vpp_c_api_examples]#
I
Is there some setting  i need to do in the startup.conf ?

Please suggest a way to fix this assert.

Thanks,
Regards
Venu

On Thu, 30 Sept 2021 at 21:08, Benoit Ganne (bganne) <bganne@...> wrote:
You should remove -lvlib it is not needed here.
If you really want to link with vlib, you must fix the link ordering: vlib depends upon vppinfra (where os_exit is defined) so you'd need link as -lvlib -lvppinfra instead of the opposite (the C linker scan libraries symbols in reverse order, so symbols declared in a library are available to libraries listed *before*).

Best
ben

> -----Original Message-----
> From: vpp-dev@... <vpp-dev@...> On Behalf Of Venumadhav
> Josyula
> Sent: jeudi 30 septembre 2021 16:09
> To: Akash S R <akashsr.akashsr@...>
> Cc: Benoit Ganne (bganne) <bganne@...>; Ole Troan
> <otroan@...>; RaviKiran Veldanda <ravi.jupvpp@...>; vpp-
> dev <vpp-dev@...>
> Subject: Re: [vpp-dev] VPP Socket API how to use from the application
> #socket-api #vpp #sock-api
>
> Hi Akash,
>
> Thansks, now after devtoolset,
>
>
> @Benoit Ganne (bganne) <mailto:bganne@...>  , @Ole Troan
> <mailto:otroan@...>
>
> i am getting following error
>
> [root@8f57181df3a1 vpp_c_api_examples]# gcc vpp_api_client_test3.c -o
> vpp_api_client_test3.o -lvlibmemoryclient -lsvm -lvppinfra -lvlib
> /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld:
> /lib/../lib64/libvlib.so: undefined reference to
> `classify_get_trace_chain'
> /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld:
> /lib/../lib64/libvlib.so: undefined reference to
> `stat_segment_register_gauge'
> /opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/ld:
> /lib/../lib64/libvlib.so: undefined reference to `os_exit'
> collect2: error: ld returned 1 exit status
> [root@8f57181df3a1 vpp_c_api_examples]#
>
> Let me paste the code again,
> #include<stdio.h>
> #include<stdlib.h>
> #include <vlibapi/api.h>
> #include <vlibmemory/api.h>
> #include <vpp/api/vpe_msg_enum.h>
>
> #define vl_typedefs
> #define vl_endianfun
> #include <vpp/api/vpe_all_api_h.h>
> #undef vl_typedefs
> #undef vl_endianfun
>
> int main()
> {
>    char *name = "vpp-test-app";
>
>    clib_mem_init_thread_safe (0, 64ULL << 20);
>
>    if (vl_client_api_map("/vpe-api"))
>    {
>         printf("unable to map....\n");
>         goto quit;
>    }
>    if (vl_client_connect("vpp-test-app", 0, 32) < 0)
>    {
>         printf("unable to connect \n");
>         vl_client_api_unmap();
>         goto quit;
>    }
>    printf("successfully connected... \n");
>  quit:
>         return 0;
> }
>
> Is this wrong way, i am trying to use APIs ?
>
> Thanks,
> Regards
> Venu
>
>
> On Thu, 30 Sept 2021 at 19:00, Akash S R <akashsr.akashsr@...
> <mailto:akashsr.akashsr@...> > wrote:
>
>
>       Hey Venu,
>
>       Try "scl enable devtoolset-9 bash" inside your docker or update your
> gcc version.
>
>
>       /Akash S R
>
>       On Thu, Sep 30, 2021, 18:54 Venumadhav Josyula <vjosyula@...
> <mailto:vjosyula@...> > wrote:
>
>
>               Hi Benoit,
>
>               Thanks for quick reply.
>
>               I have docker with following
>               [root@8f57181df3a1 vpp_c_api_examples]# rpm -qa | grep vpp
>               vpp-lib-21.06.0-4~g0d9d3a0.x86_64
>               vpp-api-lua-21.06.0-4~g0d9d3a0.x86_64
>               vpp-api-python3-21.06.0-4~g0d9d3a0.x86_64
>               vpp-debuginfo-21.06.0-4~g0d9d3a0.x86_64
>               vpp-selinux-policy-21.06.0-4~g0d9d3a0.x86_64
>               vpp-21.06.0-4~g0d9d3a0.x86_64
>               vpp-plugins-21.06.0-4~g0d9d3a0.x86_64
>               vpp-devel-21.06.0-4~g0d9d3a0.x86_64
>
>               This will vpp running in it.
>
>               [root@8f57181df3a1 /]# cat /etc/redhat-release
>               CentOS Linux release 7.3.1611 (Core)
>               [root@8f57181df3a1 /]#
>
>               > Eg. use devtoolset-9 (gcc-9).
>
>
>               How do I use it ?
>
>               Thanks,
>               Regards,
>               Venu
>
>
>               On Thu, 30 Sept 2021 at 18:47, Benoit Ganne (bganne)
> <bganne@... <mailto:bganne@...> > wrote:
>
>
>                       You should upgrade your compiler... GCC-4 is way too
> old.
>                       Eg. use devtoolset-9 (gcc-9).
>
>                       Best
>                       ben
>
>                       > -----Original Message-----
>                       > From: vpp-dev@... <mailto:vpp-dev@...>
> <vpp-dev@... <mailto:vpp-dev@...> > On Behalf Of
> Venumadhav
>                       > Josyula
>                       > Sent: jeudi 30 septembre 2021 14:49
>                       > To: otroan@... <mailto:otroan@...>
>                       > Cc: RaviKiran Veldanda <ravi.jupvpp@...
> <mailto:ravi.jupvpp@...> >; vpp-dev <vpp-
>                       > dev@... <mailto:dev@...> >
>                       > Subject: Re: [vpp-dev] VPP Socket API how to use from
> the application
>                       > #socket-api #vpp #sock-api
>                       >
>                       > Hi Ole / Others,
>                       >
>                       >
>                       >
>                       > Thanks for your email, i getting following compilation
> error
>                       > [root@8f57181df3a1 vpp_c_api_examples]# gcc
> vpp_api_client_test3.c -o
>                       > vpp_api_client_test3.o -lvlibmemoryclient -lsvm -
> lvppinfra -lvlib
>                       > In file included from
> /usr/include/vppinfra/error.h:41:0,
>                       >                  from /usr/include/vlibapi/api.h:24,
>                       >                  from vpp_api_client_test3.c:3:
>                       > /usr/include/vppinfra/clib.h:43:18: error: missing
> binary operator before
>                       > token "("
>                       >  #if __has_include(<vppinfra/config.h>)
>                       >                   ^
>                       > In file included from
> /usr/include/vppinfra/mem.h:49:0,
>                       >                  from /usr/include/vppinfra/vec.h:42,
>                       >                  from
> /usr/include/vppinfra/error.h:53,
>                       >                  from /usr/include/vlibapi/api.h:24,
>                       >                  from vpp_api_client_test3.c:3:
>                       > /usr/include/vppinfra/string.h:92:34: error: expected
> ';', ',' or ')'
>                       > before 'dst'
>                       >  clib_memcpy_fast (void *restrict dst, const void
> *restrict src, size_t n)
>                       >                                   ^
>                       > [root@8f57181df3a1 vpp_c_api_examples]# vim
> /usr/include/vppinfra/clib.h
>                       > +43
>                       > [root@8f57181df3a1 vpp_c_api_examples]# vim
> /usr/include/vppinfra/clib.h
>                       > +43
>                       > [root@8f57181df3a1 vpp_c_api_examples]# gcc --version
>                       > gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
>                       > Copyright (C) 2015 Free Software Foundation, Inc.
>                       > This is free software; see the source for copying
> conditions.  There is NO
>                       > warranty; not even for MERCHANTABILITY or FITNESS FOR
> A PARTICULAR
>                       > PURPOSE.
>                       >
>                       > [root@8f57181df3a1 vpp_c_api_examples]#
>                       >
>                       >
>                       > -----------------
>                       >
>                       > c -code
>                       > ----------------
>                       >
>                       >
>                       > #include<stdio.h>
>                       > #include<stdlib.h>
>                       > #include <vlibapi/api.h>
>                       > #include <vlibmemory/api.h>
>                       > #include <vpp/api/vpe_msg_enum.h>
>                       >
>                       > #define vl_typedefs
>                       > #define vl_endianfun
>                       > #include <vpp/api/vpe_all_api_h.h>
>                       > #undef vl_typedefs
>                       > #undef vl_endianfun
>                       >
>                       > int main()
>                       > {
>                       >    char *name = "vpp-test-app";
>                       >
>                       >    clib_mem_init_thread_safe (0, 64ULL << 20);
>                       >
>                       >    if (vl_client_api_map("/vpe-api"))
>                       >    {
>                       >         printf("unable to map....\n");
>                       >         goto quit;
>                       >    }
>                       >    if (vl_client_connect("vpp-test-app", 0, 32) < 0)
>                       >    {
>                       >         printf("unable to connect \n");
>                       >         vl_client_api_unmap();
>                       >         goto quit;
>                       >    }
>                       >    printf("successfully connected... \n");
>                       >  quit:
>                       >         return 0;
>                       > }
>                       >
>                       >
>                       > ------------
>                       >
>                       >
>                       > Can you please suggest what can i be doing worng ?
>                       >
>                       >
>                       > Thanks,
>                       > Regards,
>                       > Venu
>                       >
>                       >
>                       > On Thu, 30 Sept 2021 at 13:21, <otroan@...
> <mailto:otroan@...>
>                       > <mailto:otroan@...
> <mailto:otroan@...> > > wrote:
>                       >
>                       >
>                       >       Hi Venu,
>                       >
>                       >       > Any examples for VAPI shared to use binary
> APIs ?
>                       >
>                       >       Try this for a start:
>                       >       https://git.fd.io/vpp/tree/src/vpp-
> api/vapi/vapi_c_test.c
>                       >
>                       >       Cheers,
>                       >       Ole
>                       >
>                       >
>
>
>
>
>






--
Best regards
Stanislav Zaikin