Hi

I'm trying to use vppcom_session_sendto function in order to send UDP traffic.
According to code:

int
vppcom_session_sendto (uint32_t session_handle, void *buffer,
uint32_t buflen, int flags, vppcom_endpt_t * ep)
{
vcl_worker_t *wrk = vcl_worker_get_current ();
vcl_session_t *s;

s = vcl_session_get_w_handle (wrk, session_handle);
if (!s)
return VPPCOM_EBADFD;

if (!buffer)
return VPPCOM_EINVAL;

if (ep)
{
if (s->session_type != VPPCOM_PROTO_UDP
|| (s->flags & VCL_SESSION_F_CONNECTED))
return VPPCOM_EINVAL;

/* Session not connected/bound in vpp. Create it by 'connecting' it */
if (PREDICT_FALSE (s->session_state == STATE_CLOSED))
{
vcl_send_session_connect (wrk, s);
}
else
{
s->transport.is_ip4 = ep->is_ip4;
s->transport.rmt_port = ep->port;
vcl_ip_copy_from_ep (&s->transport.rmt_ip, ep);
}
}

if (flags)
{
// TBD check the flags and do the right thing
VDBG (2, "handling flags 0x%u (%d) not implemented yet.", flags, flags);
}

return (vppcom_session_write_inline (wrk, s, buffer, buflen, 1,
s->is_dgram ? 1 : 0));
}

session which is used in sendto must be closed because of "s->flags & 
VCL_SESSION_F_CONNECTED" condition. If i give connected session i receive the 
following:

[root@5g-control-1 ~]# VCL_DEBUG=2 VCL_CONFIG=/etc/vpp/vcl1.conf 
/root/client-server/build/vcl-client-app u 192.168.2.1 1000
VCL<6204>: configured VCL debug level (2) from VCL_DEBUG!
VCL<6204>: allocated VCL heap = 0x7efe90561010, size 1073741824 (0x40000000)
VCL<6204>: configured heapsize 1073741824
VCL<6204>: configured rx_fifo_size 40000000 (0x2625a00)
VCL<6204>: configured tx_fifo_size 40000000 (0x2625a00)
VCL<6204>: configured api-socket-name (/tmp/vpp-api1.sock)
VCL<6204>: completed parsing vppcom config!
vppcom_connect_to_vpp:502: vcl<6204:0>: app (server-app) is connected to VPP!
vppcom_app_create:1201: vcl<6204:0>: sending session enable
vppcom_app_create:1209: vcl<6204:0>: sending app attach
vppcom_app_create:1217: vcl<6204:0>: app_name 'server-app', my_client_index 0 
(0x0)
vppcom_session_create:1280: vcl<6204:0>: created session 0
vppcom_session_connect:1731: vcl<6204:0>: session handle 0 (STATE_CLOSED): 
connecting to peer IPv4 192.168.2.1 port 6000 proto UDP
vcl_session_connected_handler:503: vcl<6204:0>: session 0 [0x0] connected! 
rx_fifo 0x244019900, refcnt 1, tx_fifo 0x244019800, refcnt 1
vppcom_session_connect:1753: vcl<6204:0>: session 0 [0x0]: connect succeeded!
ERROR when calling vppcom_session_sendto(): Invalid argument

ERROR: vppcom_session_sendto() failed (errno = 22)!

At the same time if i give closed session it returns error "Transport endpoint 
is not connected".

VCL<40088>: configured VCL debug level (2) from VCL_DEBUG!
VCL<40088>: allocated VCL heap = 0x7f98d8678010, size 1073741824 (0x40000000)
VCL<40088>: configured heapsize 1073741824
VCL<40088>: configured rx_fifo_size 40000000 (0x2625a00)
VCL<40088>: configured tx_fifo_size 40000000 (0x2625a00)
VCL<40088>: configured api-socket-name (/tmp/vpp-api1.sock)
VCL<40088>: completed parsing vppcom config!
vppcom_connect_to_vpp:502: vcl<40088:0>: app (server-app) is connected to VPP!
vppcom_app_create:1201: vcl<40088:0>: sending session enable
vppcom_app_create:1209: vcl<40088:0>: sending app attach
vppcom_app_create:1217: vcl<40088:0>: app_name 'server-app', my_client_index 
256 (0x100)
vppcom_session_create:1280: vcl<40088:0>: created session 0
vppcom_session_write_inline:2053: vcl<40088:0>: session 0 [0xffffffffffffffff]: 
is not open! state 0x0 (STATE_CLOSED)
ERROR when calling vppcom_session_sendto(): Transport endpoint is not connected
ERROR: vppcom_session_sendto() failed (errno = 107)!
vl_client_disconnect:323: queue drain: 531

Maybe i'm using it in a wrong way. Can you please assist?

Best Regards,
Igor
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#16597): https://lists.fd.io/g/vpp-dev/message/16597
Mute This Topic: https://lists.fd.io/mt/74604071/21656
Mute #vpp-hoststack: https://lists.fd.io/mk?hashtag=vpp-hoststack&subid=1480452
Mute #vnet: https://lists.fd.io/mk?hashtag=vnet&subid=1480452
Group Owner: [email protected]
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub  [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to