Newer
Older
{
err = EINVAL;
goto errout;
}
/* Get the underlying socket structure */
/* Verify that the sockfd corresponds to valid, allocated socket */
psock = sockfd_socket(sockfd);
if (!psock || psock->s_crefs <= 0)
{
err = EBADF;
goto errout;
}
/* If a 'from' address has been provided, verify that it is large
* enough to hold this address family.
*/
/* Set the socket state to receiving */
psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_RECV);
/* Perform the TCP/IP or UDP recv() operation */
#if defined(CONFIG_NET_UDP) && defined(CONFIG_NET_TCP)
if (psock->s_type == SOCK_STREAM)
ret = tcp_recvfrom(psock, buf, len, infrom);
ret = udp_recvfrom(psock, buf, len, infrom);
#elif defined(CONFIG_NET_TCP)
ret = tcp_recvfrom(psock, buf, len, infrom);
#elif defined(CONFIG_NET_UDP)
ret = udp_recvfrom(psock, buf, len, infrom);
#else
ret = -ENOSYS;
/* Set the socket state to idle */
psock->s_flags = _SS_SETSTATE(psock->s_flags, _SF_IDLE);
/* Handle returned errors */
if (ret < 0)
{