mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 13:18:50 +08:00
net/icmp and icmpv6: Fix failure to poll ICMP socket issue.
This commit is contained in:
parent
40b0e98d25
commit
09c689ea15
2 changed files with 20 additions and 8 deletions
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* net/icmp/icmp_netpoll.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2017-2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -47,6 +47,7 @@
|
|||
#include <nuttx/net/net.h>
|
||||
|
||||
#include <devif/devif.h>
|
||||
#include "netdev/netdev.h"
|
||||
#include "icmp/icmp.h"
|
||||
|
||||
#ifdef CONFIG_MM_IOB
|
||||
|
@ -182,7 +183,7 @@ int icmp_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds)
|
|||
FAR struct devif_callback_s *cb;
|
||||
int ret;
|
||||
|
||||
DEBUGASSERT(conn != NULL && fds != NULL && conn->dev != NULL);
|
||||
DEBUGASSERT(conn != NULL && fds != NULL);
|
||||
|
||||
/* Allocate a container to hold the poll information */
|
||||
|
||||
|
@ -201,6 +202,11 @@ int icmp_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds)
|
|||
* dev value will be zero and there will be no NETDEV_DOWN notifications.
|
||||
*/
|
||||
|
||||
if (conn->dev == NULL)
|
||||
{
|
||||
conn->dev = netdev_default();
|
||||
}
|
||||
|
||||
/* Allocate a ICMP callback structure */
|
||||
|
||||
cb = icmp_callback_alloc(conn->dev);
|
||||
|
@ -227,12 +233,12 @@ int icmp_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds)
|
|||
|
||||
if ((info->fds->events & POLLOUT) != 0)
|
||||
{
|
||||
cb->flags |= UDP_POLL;
|
||||
cb->flags |= ICMP_POLL;
|
||||
}
|
||||
|
||||
if ((info->fds->events & POLLIN) != 0)
|
||||
{
|
||||
cb->flags |= UDP_NEWDATA;
|
||||
cb->flags |= ICMP_NEWDATA;
|
||||
}
|
||||
|
||||
if ((info->fds->events & (POLLHUP | POLLERR)) != 0)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* net/icmpv6/icmpv6_netpoll.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2017-2018 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -47,6 +47,7 @@
|
|||
#include <nuttx/net/net.h>
|
||||
|
||||
#include <devif/devif.h>
|
||||
#include "netdev/netdev.h"
|
||||
#include "icmpv6/icmpv6.h"
|
||||
|
||||
#ifdef CONFIG_MM_IOB
|
||||
|
@ -182,7 +183,7 @@ int icmpv6_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds)
|
|||
FAR struct devif_callback_s *cb;
|
||||
int ret;
|
||||
|
||||
DEBUGASSERT(conn != NULL && fds != NULL && conn->dev != NULL);
|
||||
DEBUGASSERT(conn != NULL && fds != NULL);
|
||||
|
||||
/* Allocate a container to hold the poll information */
|
||||
|
||||
|
@ -203,6 +204,11 @@ int icmpv6_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds)
|
|||
|
||||
/* Allocate a ICMP callback structure */
|
||||
|
||||
if (conn->dev == NULL)
|
||||
{
|
||||
conn->dev = netdev_default();
|
||||
}
|
||||
|
||||
cb = icmpv6_callback_alloc(conn->dev);
|
||||
if (cb == NULL)
|
||||
{
|
||||
|
@ -227,12 +233,12 @@ int icmpv6_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds)
|
|||
|
||||
if ((info->fds->events & POLLOUT) != 0)
|
||||
{
|
||||
cb->flags |= UDP_POLL;
|
||||
cb->flags |= ICMPv6_POLL;
|
||||
}
|
||||
|
||||
if ((info->fds->events & POLLIN) != 0)
|
||||
{
|
||||
cb->flags |= UDP_NEWDATA;
|
||||
cb->flags |= ICMPv6_NEWDATA;
|
||||
}
|
||||
|
||||
if ((info->fds->events & (POLLHUP | POLLERR)) != 0)
|
||||
|
|
Loading…
Reference in a new issue