Hi there, Is there any reason you don’t want to use the higher level C API? VAPI.
That has an API call for dumping interfaces. Then you don’t need to interact with the shared memory rings directly. Cheers Ole > On 12 Sep 2018, at 14:28, "[email protected]" <[email protected]> wrote: > > Hi Dave, > Thanks for your help! > In the test.c , I see "if (async) { *send-ping* ". > And vac_connect's 3rd input-param set to NULL, I want the operation-by-c-api > to be synch. > > Even no change, it (src/vpp-api/client) can not work successfully. > Is there something wrong? > > Maybe, should I follow another example? > Can you give me a example that can dump sw_interfaces? > Be deeply grateful. > > [email protected] > > From: Dave Barach (dbarach) > Date: 2018-09-11 21:10 > To: [email protected]; [email protected] > Subject: RE: [vpp-dev] VPP's C-type-api example > The typical coding pattern to use when you don’t know how many messages will > come back: send a dump request, followed by an echo-ping. > > When the ping reply shows up, the dump is complete... > > HTH... Dave > > From: [email protected] <[email protected]> On Behalf Of > [email protected] > Sent: Tuesday, September 11, 2018 4:34 AM > To: vpp-dev <[email protected]> > Subject: [vpp-dev] VPP's C-type-api example > > Hi all, > I code my example following src/vpp-api/client, but do {vac_read}while(1) > often block when the results-num does not know. > It shows pthread_cond_wait when gdb. > Help please! > Thanks very much! > > void printIntefaces() > { > api_main_t * am = &api_main; > vl_api_sw_interface_dump_t message; > M_NOALLOC(SW_INTERFACE_DUMP); > message.name_filter_valid = 0; > strcpy(message.name_filter, "Gigabit"); > vac_write((char *)&message, sizeof(message)); > char* pMsg = NULL; > int nLen = 0; > int ret = 0; > int nCount = 0; > do { > printf("begin interface read .. \n"); > ret = vac_read(&pMsg, &nLen, 1); > printf("begin interface end .. \n"); > if(ret != -1) > { > vl_api_sw_interface_details_t* pSV = (vl_api_sw_interface_details_t*)pMsg; > printf("%lu:%s \n", ntohl(pSV->sw_if_index), pSV->interface_name); > vac_free(pMsg); > nCount += 1; > } > else{ > break; > } > }while(1); > printf("get real count[%d] \n", nCount); > } > > [email protected] > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > > View/Reply Online (#10475): https://lists.fd.io/g/vpp-dev/message/10475 > Mute This Topic: https://lists.fd.io/mt/25510961/675193 > Group Owner: [email protected] > Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub [[email protected]] > -=-=-=-=-=-=-=-=-=-=-=-
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#10476): https://lists.fd.io/g/vpp-dev/message/10476 Mute This Topic: https://lists.fd.io/mt/25510961/21656 Group Owner: [email protected] Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
