what is your api prefix set in the vapi_connect call? is vpp using the same prefix?
Quoting Ole Troan (2018-09-13 18:35:29) > > 1、as root, install the rpm(vpp-selinux, vpp-lib, vpp-18.04, vpp-plugins), > > start service vpp and I come into vppctl. > > 2、I copy test/ext/vapi_c_test.c to main.c(a new file, a new dir). > > compile using: gcc -std=gnu99 -g -Wall -pthread -I/usr/include/ > > -lvppinfra -lvlibmemoryclient -lsvm -lpthread -lcheck -lrt -lm -lvapiclient > > -lsubunit main.c -o test > > 3、then, #./test > > But it shows vl_map_shmem:639: region init fail > > That’s an indication that it cannot connect to VPP. > Can vpp_api_test connect? > > Cheers, > Ole > > > > > > wangchuan...@163.com > > > > From: Ole Troan > > Date: 2018-09-13 21:44 > > To: wangchuan...@163.com > > CC: Klement Sekera -X (ksekera - PANTHEON TECHNOLOGIES at Cisco); Dave > > Barach (dbarach); vpp-dev > > Subject: Re: [vpp-dev] VPP's C-type-api example > > > i am be root > > > > Then you must provide more details. > > > > Cheers, > > Ole > > > > > > > > > > wangchuan...@163.com > > > > > > From: Ole Troan > > > Date: 2018-09-13 21:26 > > > To: wangchuan...@163.com > > > CC: Klement Sekera -X (ksekera - PANTHEON TECHNOLOGIES at Cisco); Dave > > > Barach (dbarach); vpp-dev > > > Subject: Re: [vpp-dev] VPP's C-type-api example > > > > But I got some error when using vapi - vapi_connect as " > > > > vl_map_shmem:639: region init fail “. > > > > > > Permission error? > > > Run client as root, or configure VPP to set permissions on API shared > > > memory. > > > > > > In VPP startup: > > > api-segment { uid <foo> gid <foo> } > > > > > > Cheers, > > > Ole > > > > > > > And my mem : MemFree: 220036 kB | > > > > HugePages_Total: 679 | HugePages_Free: 627 > > > > Help please! > > > > > > > > My code: > > > > int main() > > > > { > > > > vapi_ctx_t ctx; > > > > vapi_error_e rv = vapi_ctx_alloc (&ctx); > > > > vapi_msg_show_version *sv = vapi_alloc_show_version (ctx); > > > > rv = vapi_connect (ctx, app_name, api_prefix, > > > > max_outstanding_requests, > > > > response_queue_size, VAPI_MODE_BLOCKING); > > > > rv = vapi_send (ctx, sv); > > > > vapi_msg_show_version_reply *reply; > > > > rv = vapi_recv (ctx, (void **) &reply, NULL, 0, 0); > > > > if(reply != NULL) > > > > printf("ret[%d] program[%s] version[%s] \n build_date[%s] > > > > build_directory[%s]\n", reply->payload.retval, reply->payload.program, > > > > reply->payload.version, reply->payload.build_date, > > > > reply->payload.build_directory); > > > > else > > > > printf("show version return none\n"); > > > > rv = vapi_disconnect (ctx); > > > > vapi_ctx_free (ctx); > > > > printf("end\n"); > > > > return 0; > > > > } > > > > > > > > wangchuan...@163.com > > > > > > > > From: Klement Sekera > > > > Date: 2018-09-13 17:02 > > > > To: Ole Troan; wangchuanguo > > > > CC: Dave Barach (dbarach); vpp-dev > > > > Subject: Re: [vpp-dev] VPP's C-type-api example > > > > You can also check out the test/ext directory for vapi_c_test.c and > > > > vapi_cpp_test.cpp, which are unittests for these bindings and there is > > > > also an example of _dump API call. > > > > > > > > Regards, > > > > Klement > > > > > > > > Quoting Ole Troan (2018-09-13 09:33:14) > > > > > Hi again, > > > > > > > > > > > I am in the beginning of using-c-api. Should I not follow > > > > > > (src/vpp-api/client) ? > > > > > > Can you please show me a fun-name and a example of the higher level > > > > > > C API? > > > > > > > > > > That’s right, I wouldn’t recommend using the src/vpp-aoi/client API > > > > > unless you are building a new language binding. > > > > > > > > > > If you need a C interface you should use VAPI. > > > > > > > > > > See interface.api.vapi.h (auto-generated) for sw_interface_dump() > > > > > > > > > > static inline vapi_error_e vapi_sw_interface_dump(struct vapi_ctx_s > > > > > *ctx, > > > > > vapi_msg_sw_interface_dump *msg, > > > > > vapi_error_e (*callback)(struct vapi_ctx_s *ctx, > > > > > void *callback_ctx, > > > > > vapi_error_e rv, > > > > > bool is_last, > > > > > vapi_payload_sw_interface_details *reply), > > > > > void *callback_ctx) > > > > > > > > > > > > > > > src/vpp-api/vapi/vapi_doc.md for documentation. > > > > > > > > > > To get a feel of how the API works, at even higher level you can play > > > > > with the Python language binding. > > > > > > > > > > Best regards, > > > > > Ole > > > > > > > > > > > > > > > > > > > > -=-=-=-=-=-=-=-=-=-=-=- > > > > > Links: You receive all messages sent to this group. > > > > > > > > > > View/Reply Online (#10481): > > > > > https://lists.fd.io/g/vpp-dev/message/10481 > > > > > Mute This Topic: https://lists.fd.io/mt/25510961/675704 > > > > > Group Owner: vpp-dev+ow...@lists.fd.io > > > > > Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub [ksek...@cisco.com] > > > > > -=-=-=-=-=-=-=-=-=-=-=- >
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#10491): https://lists.fd.io/g/vpp-dev/message/10491 Mute This Topic: https://lists.fd.io/mt/25510961/21656 Group Owner: vpp-dev+ow...@lists.fd.io Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-