mirror of
https://github.com/apache/nuttx.git
synced 2026-08-07 05:27:17 +00:00
net/icmp: add nonblocking support
Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
parent
9c1fb4c04b
commit
ae613446c8
4 changed files with 16 additions and 2 deletions
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue