diff --git a/net/icmp/icmp_recvmsg.c b/net/icmp/icmp_recvmsg.c index 4f2577d97e..6fa661f2b1 100644 --- a/net/icmp/icmp_recvmsg.c +++ b/net/icmp/icmp_recvmsg.c @@ -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)); diff --git a/net/icmp/icmp_sockif.c b/net/icmp/icmp_sockif.c index be9b719936..6985ada6da 100644 --- a/net/icmp/icmp_sockif.c +++ b/net/icmp/icmp_sockif.c @@ -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; } /**************************************************************************** diff --git a/net/icmpv6/icmpv6_recvmsg.c b/net/icmpv6/icmpv6_recvmsg.c index a4678e8f69..ac8839f386 100644 --- a/net/icmpv6/icmpv6_recvmsg.c +++ b/net/icmpv6/icmpv6_recvmsg.c @@ -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)); diff --git a/net/icmpv6/icmpv6_sockif.c b/net/icmpv6/icmpv6_sockif.c index 8593f40234..a0a5456673 100644 --- a/net/icmpv6/icmpv6_sockif.c +++ b/net/icmpv6/icmpv6_sockif.c @@ -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; } /****************************************************************************