来自 魅族 MX4 Pro -------- 原始邮件 -------- 发件人:重新开始 <15803846...@qq.com> 时间:周日 10月15日 21:46 收件人:"Klement Sekera -X (ksekera - PA" <ksek...@cisco.com> 主题:转发:the vapi test problem when i send [want_vpncrack_decrypt_info] msg, why i receive [delete_subif_reply] msg ? why i can not receive [want_vpncrack_decrypt_info_reply] msg ? ------------------ 原始邮件 ------------------ 发件人: "重新开始";<15803846...@qq.com>; 发送时间: 2017年10月15日(星期天) 下午5:13 收件人: "Klement Sekera -X (ksekera - PA"<ksek...@cisco.com>; 主题: the vapi test problem Hi, Klement The fllowing is the my plugin vapi test result. Can you explain why ? Thank you very much! vpp@vpp-VirtualBox:~/test$ sudo ./test DBG:vapi.c:316:vapi_connect():client api map `/vpe-api' DBG:vapi.c:321:vapi_connect():connect client `test' DBG:vapi.c:371:vapi_connect():Message `test_fake_msg_reply_cafebafe' not available DBG:vapi.c:371:vapi_connect():Message `test_fake_msg_cafebafe' not available DBG:vapi.c:371:vapi_connect():Message `test_fake_details_cafebafe' not available DBG:vapi.c:371:vapi_connect():Message `test_fake_dump_cafebafe' not available vapi connect success! rv0 = 0 --- Receive stats using generic blocking API --- ws->payload.pid = 3496 DBG:vapi.c:435:vapi_send():send msg@0x3007c2f4:665[want_vpncrack_decrypt_info] DBG:vapi.c:455:vapi_send():vapi_send() rv = 0 DBG:vapi.c:131:vapi_store_request():stored@0: context:80000001 (start is @0) --- 222222 --- DBG:vapi.c:700:vapi_dispatch_one():vapi_dispatch_one() DBG:vapi.c:521:vapi_recv():doing shm queue sub DBG:vapi.c:545:vapi_recv():recv msg@0x3004a454:7[delete_subif_reply] DBG:vapi.c:740:vapi_dispatch_one():dispatch, context is 0 DBG:vapi.c:685:vapi_dispatch_event():No handler/generic handler for msg id 0[delete_subif_reply], message ignored DBG:vapi.c:700:vapi_dispatch_one():vapi_dispatch_one() DBG:vapi.c:521:vapi_recv():doing shm queue sub ------------------ 原始邮件 ------------------ 发件人: "Klement Sekera -X (ksekera - PA";<ksek...@cisco.com>; 发送时间: 2017年10月13日(星期五) 下午5:17 收件人: "重新开始"<15803846...@qq.com>; 主题: Re: 回复: why my plugin api can not generate vapi_want_..andvapi_alloc_want... functions? Oh, I probably see the issue. The VPP API is poorly designed and the message types are guessed based on names. Your want_XYZ_event message is recognized as `event' based on the `_event' suffix. Since events are not to be allocated and sent by client, the vapi_alloc* functions are not generated for them. Currently, you'll have to respect the naming convention if you want the generator to work correctly. So, please only use _event suffix for actual events. Change the want_XYZ messages so that they don't end with _event and everything should work fine. Regards, Klement Quoting 重新开始 (2017-10-13 11:10:45) > This is the init vapi.h file. The pre vapi.h file is modified by me. I try > to write the vapi_alloc_want ... and vapi_want. .. functions referening > the other functions. But the writen apis do not work. > ------------------ 原始邮件 ------------------ > 发件人: "Klement Sekera -X (ksekera - PA";<ksek...@cisco.com>; > 发送时间: 2017年10月13日(星期五) 下午4:53 > 收件人: "重新开始"<15803846...@qq.com>; > 主题: Re: why my plugin api can not generate > vapi_want_..andvapi_alloc_want... functions? > Hi 重新开始, > > I can't help you because you didn't provide the API nor mentioned any > error messages. Simply stating "it doesn't work, why?" is not enough to > debug the issue ;-) > > Cheers, > Klement > > Quoting 重新开始 (2017-10-13 10:45:32) > > Hi, Klement > > I use src/vpp-api/vapi/vapi_c_gen.py test.json to generate > > test.api.vapi.h. and the fllowing is ok > > static inline vapi_msg_vpncrack_pwh_update* > > vapi_alloc_vpncrack_pwh_update(struct vapi_ctx_s *ctx) > > { > > vapi_msg_vpncrack_pwh_update *msg = NULL; > > const size_t size = sizeof(vapi_msg_vpncrack_pwh_update); > > /* cast here required to play nicely with C++ world ... */ > > msg = (vapi_msg_vpncrack_pwh_update*)vapi_msg_alloc(ctx, size); > > if (!msg) { > > return NULL; > > } > > msg->header.client_index = vapi_get_client_index(ctx); > > msg->header.context = 0; > > msg->header._vl_msg_id = vapi_lookup_vl_msg_id(ctx, > > vapi_msg_id_vpncrack_pwh_update); > > return msg; > > } > > static inline vapi_error_e vapi_vpncrack_pwh_update(struct vapi_ctx_s > > *ctx, > > vapi_msg_vpncrack_pwh_update *msg, > > vapi_error_e (*callback)(struct vapi_ctx_s *ctx, > > void *callback_ctx, > > vapi_error_e rv, > > bool is_last, > > vapi_payload_vpncrack_pwh_update_reply > *reply), > > void *callback_ctx) > > { > > if (!msg || !callback) { > > return VAPI_EINVAL; > > } > > if (vapi_is_nonblocking(ctx) && vapi_requests_full(ctx)) { > > return VAPI_EAGAIN; > > } > > vapi_error_e rv; > > if (VAPI_OK != (rv = vapi_producer_lock (ctx))) { > > return rv; > > } > > u32 req_context = vapi_gen_req_context(ctx); > > msg->header.context = req_context; > > vapi_msg_vpncrack_pwh_update_hton(msg); > > if (VAPI_OK == (rv = vapi_send (ctx, msg))) { > > vapi_store_request(ctx, req_context, false, (vapi_cb_t)callback, > > callback_ctx); > > if (VAPI_OK != vapi_producer_unlock (ctx)) { > > abort (); /* this really shouldn't happen */ > > } > > if (vapi_is_nonblocking(ctx)) { > > rv = VAPI_OK; > > } else { > > rv = vapi_dispatch(ctx); > > } > > } else { > > vapi_msg_vpncrack_pwh_update_ntoh(msg); > > if (VAPI_OK != vapi_producer_unlock (ctx)) { > > abort (); /* this really shouldn't happen */ > > } > > } > > return rv; > > } > > But , the event type api can not generate vapi functions, why? > > ------------------ 原始邮件 ------------------ > > 发件人: "Klement Sekera -X (ksekera - PA";<ksek...@cisco.com>; > > 发送时间: 2017年10月3日(星期二) 晚上6:21 > > 收件人: "重新开 > 始"<15803846...@qq.com>;"vpp-dev"<vpp-dev@lists.fd.io>; > > 主题: Re: 回复: 回复: undefined reference to `vapi_register_msg' > > You can, assuming that your .api file is named test.api: > > > > 1.) first you need to invoke vppapigen to generate JSON from your > .api > > file. For in-tree files, rules in src/suffix-rules.mk apply, so you > can > > mimick them by doing e.g. > > > > gcc -E -P -C -x c test.api | ./build-root/tools/bin/vppapigen --input > - > > --json test.json > > > > 2.) now you need to generate vapi bindings based on the json: > > > > src/vpp-api/vapi/vapi_c_gen.py test.json > > > > This will then generate test.vapi.h, which you can #include in your > > source code. The header file will also contain a macro named > > DEFINE_VAPI_MSG_IDS_TEST_JSON > > ^^^^ > > this is based on the name of the API > > > > You need to specify this macro *once* in one of your source files > (e.g. > > the test.c you mention in your email) > > > > Regards, > > Klement > > > > Quoting 重新开始 (2017-10-03 11:42:05) > > > Thank you! Klement. > > > Yes, I am not good at makeflie. After init study, i make > success. But > > i > > > have a problem. I hope that you can answer me. If i write a > plugin > > for vpp > > > and define some apis. The question si : could I call the apis > through > > vapi > > > method? > > > ------------------ 原始邮件 ------------------ > > > 发件人: "Klement Sekera -X (ksekera - PA";<ksek...@cisco.com>; > > > 发送时间: 2017年10月3日(星期二) 下午5:01 > > > 收件人: "重新开 > > 始"<15803846...@qq.com>;"vpp-dev"<vpp-dev@lists.fd.io>; > > > 主题: Re: 回复: undefined reference to `vapi_register_msg' > > > I don't see them in the compile command > > > > > > > cc -std=gnu99 -g -Wall -pthread -I/home/vpp/vpp/src > > > > -Ihome//vpp/vpp/build-root/install-vpp-native/vpp/include > > > > -I/home/test > > > > test.c -o test > > > > > > I strongly suggest you learn how gcc & make works... > > > > > > Quoting 重新开始 (2017-10-03 10:38:19) > > > > Hi, > > > > link libraries are same with test/ext/Makefile binaries. > any > > other > > > > libraries needed? > > > > ------------------ 原始邮件 ------------------ > > > > 发件人: "Klement Sekera -X (ksekera - > PA";<ksek...@cisco.com>; > > > > 发送时间: 2017年10月3日(星期二) 下午4:30 > > > > 收件人: "重新开 > > > 始"<15803846...@qq.com>;"vpp-dev"<vpp-dev@lists.fd.io>; > > > > 主题: Re: undefined reference to `vapi_register_msg' > > > > Hi, > > > > > > > > link against the same libraries as test/ext/Makefile > binaries > > do: > > > > > > > > -lvppinfra -lvlibmemoryclient -lsvm -lvapiclient > > > > > > > > Regards, > > > > Klement > > > > > > > > Quoting 重新开始 (2017-10-03 10:17:24) > > > > > HI, i make the vapi test program, and make output the > > flowing > > > errors. > > > > > Maybe, any *.so should i add? > > > > > vpp@vpp-VirtualBox:~/test$ make > > > > > cc -std=gnu99 -g -Wall -pthread -I/home/vpp/vpp/src > > > > > > -Ihome//vpp/vpp/build-root/install-vpp-native/vpp/include > > > > -I/home/test > > > > > test.c -o test > > > > > /tmp/ccq6LqEu.o: In function > > > `__vapi_constructor_delete_subif_reply': > > > > > /usr/include/vapi/vpe.api.vapi.h:6548: undefined > reference > > to > > > > > `vapi_register_msg' > > > > > /tmp/ccq6LqEu.o: In function > > `__vapi_constructor_ip6_nd_event': > > > > > /usr/include/vapi/vpe.api.vapi.h:6570: undefined > reference > > to > > > > > `vapi_register_msg' > > > > > /tmp/ccq6LqEu.o: In function > > > > > `__vapi_constructor_pg_create_interface_reply': > > > > > /usr/include/vapi/vpe.api.vapi.h:6592: undefined > reference > > to > > > > > `vapi_register_msg' > > > > > /tmp/ccq6LqEu.o: In function > > > `__vapi_constructor_pg_capture_reply': > > > > > /usr/include/vapi/vpe.api.vapi.h:6614: undefined > reference > > to > > > > > `vapi_register_msg' > > > > > /tmp/ccq6LqEu.o: In function > > > > > `__vapi_constructor_sw_interface_set_vpath_reply': > > > > > /usr/include/vapi/vpe.api.vapi.h:6636: undefined > reference > > to > > > > > `vapi_register_msg' > > > > > /tmp/ccq6LqEu.o:/usr/include/vapi/vpe.api.vapi.h:6658: > more > > > undefined > > > > > references to `vapi_register_msg' follow > > > > > /tmp/ccq6LqEu.o: In function `test_connect': > > > > > /home/vpp/test/test.c:46: undefined reference to > > > `vapi_ctx_alloc' > > > > > /home/vpp/test/test.c:48: undefined reference to > > `vapi_connect' > > > > > /home/vpp/test/test.c:51: undefined reference to > > > `vapi_disconnect' > > > > > /home/vpp/test/test.c:53: undefined reference to > > `vapi_ctx_free' > > > > > collect2: error: ld returned 1 exit status > > > > > <builtin>: recipe for target 'test' failed > > > > > make: *** [test] Error 1
test.c
Description: Binary data
vpncrack.api.vapi.h
Description: Binary data
_______________________________________________ vpp-dev mailing list vpp-dev@lists.fd.io https://lists.fd.io/mailman/listinfo/vpp-dev