net/icmp: add nonblocking support

Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an 2021-05-20 18:14:54 +08:00 committed by Xiang Xiao
parent 9c1fb4c04b
commit ae613446c8
4 changed files with 16 additions and 2 deletions

View File

@ -399,6 +399,13 @@ ssize_t icmp_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,
(FAR struct sockaddr_in *)from, fromlen);
}
/* Handle non-blocking ICMP sockets */
if (_SS_ISNONBLOCK(psock->s_flags) || (flags & MSG_DONTWAIT) != 0)
{
return -EAGAIN;
}
/* Initialize the state structure */
memset(&state, 0, sizeof(struct icmp_recvfrom_s));

View File

@ -161,7 +161,7 @@ static int icmp_setup(FAR struct socket *psock, int protocol)
static sockcaps_t icmp_sockcaps(FAR struct socket *psock)
{
return 0;
return SOCKCAP_NONBLOCKING;
}
/****************************************************************************

View File

@ -406,6 +406,13 @@ ssize_t icmpv6_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,
(FAR struct sockaddr_in6 *)from, fromlen);
}
/* Handle non-blocking ICMP sockets */
if (_SS_ISNONBLOCK(psock->s_flags) || (flags & MSG_DONTWAIT) != 0)
{
return -EAGAIN;
}
/* Initialize the state structure */
memset(&state, 0, sizeof(struct icmpv6_recvfrom_s));

View File

@ -161,7 +161,7 @@ static int icmpv6_setup(FAR struct socket *psock, int protocol)
static sockcaps_t icmpv6_sockcaps(FAR struct socket *psock)
{
return 0;
return SOCKCAP_NONBLOCKING;
}
/****************************************************************************