Unfortunately, you missed a number of key details. It’s no surprise that the 
code you sent along won’t work. First obvious issue: you need to ask vpp for 
the base of the message ID block assigned to your data plane plugin.

  name = format (0, "sample_%08x%c", api_version, 0);
  sm->msg_id_base = vl_client_get_first_plugin_msg_id ((char *) name);

vl_msg_api_set_handlers(...) need to register handlers for (sm->msg_id_base + 
CONFIG_NAT44_MAX_USER_REPLY), not CONFIG_NAT44_MAX_USER_REPLY.

Many of the relevant details are shown in 
src/examples/sample-plugin/sample/sample_test.c, a DLL / plugin loaded into 
vpe_api_test.

I sincerely hope that your data plane plugin follows the relevant patterns 
carefully. Otherwise, you’ll end up debugging both sides of the conversation. 
I’m not sure that you wouldn’t have better luck by starting over: refactor a 
known-good example, mix in your code, etc.

When I build plugins, I use the emacs M-x siri-make-me-a-plugin code in 
.../extras/emacs-lisp/all-skel.el. Other folks copy a working plugin [such as 
the sample plugin] and refactor...

By the way, I wouldn’t be in a hurry to invent another NAT plugin. The code in 
.../src/plugins/nat is quite good already. It will take you a year or more to 
match it.

HTH... Dave

From: vpp-dev@lists.fd.io <vpp-dev@lists.fd.io> On Behalf Of Seyyed Mojtaba 
Rezvani via Lists.Fd.Io
Sent: Saturday, June 9, 2018 4:04 AM
To: vpp-dev@lists.fd.io
Cc: vpp-dev@lists.fd.io
Subject: [vpp-dev] #vpp Failed to call a vpp plugin api

Dear guys and gals
I have composed a plugin called cgnat and I was trying hard to call the plugin 
from a C program to make a portable interface.
I would be very thankful if anyone could help me by providing a sample program 
which could communicate with a vpp plugin or finds my fault in my program.
I got no compilation or linking error.
All values like max_user or retval are defined in plugin.
The plugin has a .so file in /usr/lib/vpp_plugins.
Here I attached my main.c file and my Makefile.
Any help would be appreciated because I got one and a half month of my life 
trying different methods.
By the way I have worked with python API and it works just fine but I want to 
call the plugin from C API.
Thank you very much
Seyyed Mojtaba Rezvani


-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#9575): https://lists.fd.io/g/vpp-dev/message/9575
Mute This Topic: https://lists.fd.io/mt/21929043/21656
Mute #vpp: https://lists.fd.io/mk?hashtag=vpp&subid=1480452
Group Owner: vpp-dev+ow...@lists.fd.io
Leave: https://lists.fd.io/g/vpp-dev/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to