diff --git a/net/icmp/icmp.h b/net/icmp/icmp.h index ebb2a23d9a..77aa832f8f 100644 --- a/net/icmp/icmp.h +++ b/net/icmp/icmp.h @@ -90,10 +90,6 @@ struct icmp_conn_s struct iob_queue_s readahead; /* Read-ahead buffering */ #endif - - /* Defines the list of IPPROTO_ICMP callbacks */ - - struct devif_callback_s *list; }; #endif diff --git a/net/icmp/icmp_input.c b/net/icmp/icmp_input.c index 8d26f491ef..23c92b3dc0 100644 --- a/net/icmp/icmp_input.c +++ b/net/icmp/icmp_input.c @@ -287,7 +287,7 @@ void icmp_input(FAR struct net_driver_s *dev) { uint16_t flags; - flags = devif_conn_event(dev, ipicmp, ICMP_ECHOREPLY, dev->d_conncb); + flags = devif_conn_event(dev, NULL, ICMP_ECHOREPLY, dev->d_conncb); if ((flags & ICMP_ECHOREPLY) != 0) { FAR struct icmp_conn_s *conn; diff --git a/net/icmp/icmp_netpoll.c b/net/icmp/icmp_netpoll.c index aad9f8f33d..2e6663c82f 100644 --- a/net/icmp/icmp_netpoll.c +++ b/net/icmp/icmp_netpoll.c @@ -59,7 +59,8 @@ struct icmp_poll_s { - struct pollfd *fds; /* Needed to handle poll events */ + FAR struct socket *psock; /* IPPROTO_ICMP socket structure */ + FAR struct pollfd *fds; /* Needed to handle poll events */ FAR struct devif_callback_s *cb; /* Needed to teardown the poll */ }; @@ -92,7 +93,8 @@ static uint16_t icmp_poll_eventhandler(FAR struct net_driver_s *dev, FAR void *pvpriv, uint16_t flags) { FAR struct icmp_poll_s *info = (FAR struct icmp_poll_s *)pvpriv; - FAR struct icmp_conn_s *conn = (FAR struct icmp_conn_s *)pvconn; + FAR struct icmp_conn_s *conn; + FAR struct socket *psock; pollevent_t eventset; ninfo("flags: %04x\n", flags); @@ -104,8 +106,21 @@ static uint16_t icmp_poll_eventhandler(FAR struct net_driver_s *dev, * sent out on. */ - if (info != NULL && dev == conn->dev) + if (info != NULL) { + /* Is this a response on the same device that we sent the request out + * on? + */ + + psock = info->psock; + DEBUGASSERT(psock != NULL && psock->s_conn != NULL); + conn = psock->s_conn; + if (dev != conn->dev) + { + ninfo("Wrong device\n"); + return flags; + } + /* Check for data or connection availability events. */ eventset = 0; @@ -197,8 +212,9 @@ int icmp_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds) /* Initialize the poll info container */ - info->fds = fds; - info->cb = cb; + info->psock = psock; + info->fds = fds; + info->cb = cb; /* Initialize the callback structure. Save the reference to the info * structure as callback private data so that it will be available during