{
case VPPCOM_ATTR_GET_NREAD:
rv = vppcom_session_read_ready (session, session_index);
- if (VPPCOM_DEBUG > 0)
+ if (VPPCOM_DEBUG > 1)
clib_warning ("VPPCOM_ATTR_GET_NREAD: nread = %d", rv);
break;
{
*flags = O_RDWR | ((session->is_nonblocking) ? O_NONBLOCK : 0);
*buflen = sizeof (*flags);
- if (VPPCOM_DEBUG > 0)
+ if (VPPCOM_DEBUG > 1)
clib_warning ("VPPCOM_ATTR_GET_FLAGS: flags = 0x%08x, "
"is_nonblocking = %u", *flags,
session->is_nonblocking);
if (buffer && buflen && (*buflen >= sizeof (*flags)))
{
session->is_nonblocking = (*flags & O_NONBLOCK) ? 1 : 0;
- if (VPPCOM_DEBUG > 0)
+ if (VPPCOM_DEBUG > 1)
clib_warning ("VPPCOM_ATTR_SET_FLAGS: flags = 0x%08x, "
"is_nonblocking = %u", *flags,
session->is_nonblocking);
clib_memcpy (ep->ip, &session->peer_addr.ip46.ip6,
sizeof (ip6_address_t));
*buflen = sizeof (*ep);
- if (VPPCOM_DEBUG > 0)
+ if (VPPCOM_DEBUG > 1)
clib_warning ("VPPCOM_ATTR_GET_PEER_ADDR: sid %u is_ip4 = %u, "
"addr = %U, port %u", session_index,
ep->is_ip4, format_ip46_address,
clib_memcpy (ep->ip, &session->lcl_addr.ip46.ip6,
sizeof (ip6_address_t));
*buflen = sizeof (*ep);
- if (VPPCOM_DEBUG > 0)
+ if (VPPCOM_DEBUG > 1)
clib_warning ("VPPCOM_ATTR_GET_LCL_ADDR: sid %u is_ip4 = %u, "
"addr = %U port %d", session_index,
ep->is_ip4, format_ip46_address,
if (VPPCOM_DEBUG > 0)
clib_warning ("[%d] invalid session, sid (%u) has been closed!",
vcm->my_pid, session_index);
- rv = VPPCOM_EINVAL;
+ rv = VPPCOM_EBADFD;
+ clib_spinlock_unlock (&vcm->sessions_lockp);
+ goto done;
}
ep->vrf = session->vrf;
ep->is_ip4 = session->peer_addr.is_ip4;
rv = VPPCOM_EAFNOSUPPORT;
}
+done:
return rv;
}
vppcom_session_sendto (uint32_t session_index, void *buffer,
uint32_t buflen, int flags, vppcom_endpt_t * ep)
{
+ vppcom_main_t *vcm = &vppcom_main;
+
+ if (!buffer)
+ return VPPCOM_EINVAL;
+
if (ep)
- // TBD
- return -1;
- else if (flags == 0)
- return (vppcom_session_write (session_index, buffer, buflen));
- else if (flags)
- // TBD check the flags and do the right thing
- return (vppcom_session_write (session_index, buffer, buflen));
-
- return -1;
+ {
+ // TBD
+ return VPPCOM_EINVAL;
+ }
+
+ if (flags)
+ {
+ // TBD check the flags and do the right thing
+ if (VPPCOM_DEBUG > 2)
+ clib_warning ("[%d] handling flags 0x%u (%d) not implemented yet.",
+ vcm->my_pid, flags, flags);
+ }
+
+ return (vppcom_session_write (session_index, buffer, buflen));
}
/*