diff --git a/net/socket/net_close.c b/net/socket/net_close.c index 618c1f7f50f..4a8c2d464ad 100644 --- a/net/socket/net_close.c +++ b/net/socket/net_close.c @@ -257,6 +257,61 @@ end_wait: } #endif /* CONFIG_NET_TCP */ +/**************************************************************************** + * Function: netclose_txnotify + * + * Description: + * Notify the appropriate device driver that we are have data ready to + * be send (TCP) + * + * Parameters: + * psock - Socket state structure + * conn - The TCP connection structure + * + * Returned Value: + * None + * + ****************************************************************************/ + +static inline void netclose_txnotify(FAR struct socket *psock, + FAR struct tcp_conn_s *conn) +{ +#ifdef CONFIG_NET_IPv4 +#ifdef CONFIG_NET_IPv6 + /* If both IPv4 and IPv6 support are enabled, then we will need to select + * the device driver using the appropriate IP domain. + */ + + if (psock->domain == PF_INET) +#endif + { + /* Notify the device driver that send data is available */ + +#ifdef CONFIG_NET_MULTILINK + netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr); +#else + netdev_ipv4_txnotify(conn->u.ipv4.raddr); +#endif + } +#endif /* CONFIG_NET_IPv4 */ + +#ifdef CONFIG_NET_IPv6 +#ifdef CONFIG_NET_IPv4 + else /* if (psock->domain == PF_INET6) */ +#endif /* CONFIG_NET_IPv4 */ + { + /* Notify the device driver that send data is available */ + + DEBUGASSERT(psock->domain == PF_INET6); +#ifdef CONFIG_NET_MULTILINK + netdev_ipv6_txnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr); +#else + netdev_ipv6_txnotify(conn->u.ipv6.raddr); +#endif + } +#endif /* CONFIG_NET_IPv6 */ +} + /**************************************************************************** * Function: netclose_disconnect * @@ -357,11 +412,7 @@ static inline int netclose_disconnect(FAR struct socket *psock) /* Notify the device driver of the availability of TX data */ -#ifdef CONFIG_NET_MULTILINK - netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr); -#else - netdev_ipv4_txnotify(conn->u.ipv4.raddr); -#endif + netclose_txnotify(psock, conn); #ifdef CONFIG_NET_SOLINGER /* Wait only if we are lingering */ diff --git a/net/socket/net_sendfile.c b/net/socket/net_sendfile.c index 5274eb4ede4..df72cecef79 100644 --- a/net/socket/net_sendfile.c +++ b/net/socket/net_sendfile.c @@ -386,6 +386,61 @@ wait: return flags; } +/**************************************************************************** + * Function: sendfile_txnotify + * + * Description: + * Notify the appropriate device driver that we are have data ready to + * be send (TCP) + * + * Parameters: + * psock - Socket state structure + * conn - The TCP connection structure + * + * Returned Value: + * None + * + ****************************************************************************/ + +static inline void sendfile_txnotify(FAR struct socket *psock, + FAR struct tcp_conn_s *conn) +{ +#ifdef CONFIG_NET_IPv4 +#ifdef CONFIG_NET_IPv6 + /* If both IPv4 and IPv6 support are enabled, then we will need to select + * the device driver using the appropriate IP domain. + */ + + if (psock->domain == PF_INET) +#endif + { + /* Notify the device driver that send data is available */ + +#ifdef CONFIG_NET_MULTILINK + netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr); +#else + netdev_ipv4_txnotify(conn->u.ipv4.raddr); +#endif + } +#endif /* CONFIG_NET_IPv4 */ + +#ifdef CONFIG_NET_IPv6 +#ifdef CONFIG_NET_IPv4 + else /* if (psock->domain == PF_INET6) */ +#endif /* CONFIG_NET_IPv4 */ + { + /* Notify the device driver that send data is available */ + + DEBUGASSERT(psock->domain == PF_INET6); +#ifdef CONFIG_NET_MULTILINK + netdev_ipv6_txnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr); +#else + netdev_ipv6_txnotify(conn->u.ipv6.raddr); +#endif + } +#endif /* CONFIG_NET_IPv6 */ +} + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -564,11 +619,7 @@ ssize_t net_sendfile(int outfd, struct file *infile, off_t *offset, /* Notify the device driver of the availability of TX data */ -#ifdef CONFIG_NET_MULTILINK - netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr); -#else - netdev_ipv4_txnotify(conn->u.ipv4.raddr); -#endif + sendfile_txnotify(psock, conn); net_lockedwait(&state.snd_sem); } while (state.snd_sent >= 0 && state.snd_acked < state.snd_flen); diff --git a/net/socket/recvfrom.c b/net/socket/recvfrom.c index af633fbb232..4cc8d827558 100644 --- a/net/socket/recvfrom.c +++ b/net/socket/recvfrom.c @@ -1039,6 +1039,83 @@ static ssize_t recvfrom_result(int result, struct recvfrom_s *pstate) } #endif /* CONFIG_NET_UDP || CONFIG_NET_TCP */ +/**************************************************************************** + * Function: recvfromo_pkt_rxnotify + * + * Description: + * Notify the appropriate device driver that we are ready to receive a + * packet (PKT) + * + * Parameters: + * conn - The PKT connection structure + * + * Returned Value: + * None + * + ****************************************************************************/ + +#if 0 /* Not implemented */ +static void recvfromo_pkt_rxnotify(FAR struct pkt_conn_s *conn) +{ +# warning Missing logic +} +#endif + +/**************************************************************************** + * Function: recvfrom_udp_rxnotify + * + * Description: + * Notify the appropriate device driver that we are ready to receive a + * packet (UDP) + * + * Parameters: + * psock - Socket state structure + * conn - The UDP connection structure + * + * Returned Value: + * None + * + ****************************************************************************/ + +static inline void recvfrom_udp_rxnotify(FAR struct socket *psock, + FAR struct udp_conn_s *conn) +{ +#ifdef CONFIG_NET_IPv4 +#ifdef CONFIG_NET_IPv6 + /* If both IPv4 and IPv6 support are enabled, then we will need to select + * the device driver using the appropriate IP domain. + */ + + if (psock->domain == PF_INET) +#endif + { + /* Notify the device driver of the receive ready */ + +#ifdef CONFIG_NET_MULTILINK + netdev_ipv4_rxnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr); +#else + netdev_ipv4_rxnotify(conn->u.ipv4.raddr); +#endif + } +#endif /* CONFIG_NET_IPv4 */ + +#ifdef CONFIG_NET_IPv6 +#ifdef CONFIG_NET_IPv4 + else /* if (psock->domain == PF_INET6) */ +#endif /* CONFIG_NET_IPv4 */ + { + /* Notify the device driver of the receive ready */ + + DEBUGASSERT(psock->domain == PF_INET6); +#ifdef CONFIG_NET_MULTILINK + netdev_ipv6_rxnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr); +#else + netdev_ipv6_rxnotify(conn->u.ipv6.raddr); +#endif + } +#endif /* CONFIG_NET_IPv6 */ +} + /**************************************************************************** * Function: pkt_recvfrom * @@ -1095,12 +1172,8 @@ static ssize_t pkt_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, /* Notify the device driver of the receive call */ -#if 0 /* No */ -#ifdef CONFIG_NET_MULTILINK - netdev_ipv4_rxnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr); -#else - netdev_ipv4_rxnotify(conn->u.ipv4.raddr); -#endif +#if 0 /* Not implemented */ + recvfromo_pkt_rxnotify(conn); #endif /* Wait for either the receive to complete or for an error/timeout to occur. @@ -1195,11 +1268,7 @@ static ssize_t udp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t len, /* Notify the device driver of the receive call */ -#ifdef CONFIG_NET_MULTILINK - netdev_ipv4_rxnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr); -#else - netdev_ipv4_rxnotify(conn->u.ipv4.raddr); -#endif + recvfrom_udp_rxnotify(psock, conn); /* Wait for either the receive to complete or for an error/timeout to occur. * NOTES: (1) net_lockedwait will also terminate if a signal is received, (2) diff --git a/net/socket/sendto.c b/net/socket/sendto.c index c8e40c2ef8a..bced1ea8259 100644 --- a/net/socket/sendto.c +++ b/net/socket/sendto.c @@ -295,7 +295,62 @@ static uint16_t sendto_interrupt(FAR struct net_driver_s *dev, FAR void *conn, #endif /**************************************************************************** - * Global Functions + * Function: sendto_txnotify + * + * Description: + * Notify the appropriate device driver that we are have data ready to + * be send (UDP) + * + * Parameters: + * psock - Socket state structure + * conn - The UDP connection structure + * + * Returned Value: + * None + * + ****************************************************************************/ + +static inline void sendto_txnotify(FAR struct socket *psock, + FAR struct udp_conn_s *conn) +{ +#ifdef CONFIG_NET_IPv4 +#ifdef CONFIG_NET_IPv6 + /* If both IPv4 and IPv6 support are enabled, then we will need to select + * the device driver using the appropriate IP domain. + */ + + if (psock->domain == PF_INET) +#endif + { + /* Notify the device driver that send data is available */ + +#ifdef CONFIG_NET_MULTILINK + netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr); +#else + netdev_ipv4_txnotify(conn->u.ipv4.raddr); +#endif + } +#endif /* CONFIG_NET_IPv4 */ + +#ifdef CONFIG_NET_IPv6 +#ifdef CONFIG_NET_IPv4 + else /* if (psock->domain == PF_INET6) */ +#endif /* CONFIG_NET_IPv4 */ + { + /* Notify the device driver that send data is available */ + + DEBUGASSERT(psock->domain == PF_INET6); +#ifdef CONFIG_NET_MULTILINK + netdev_ipv6_txnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr); +#else + netdev_ipv6_txnotify(conn->u.ipv6.raddr); +#endif + } +#endif /* CONFIG_NET_IPv6 */ +} + +/**************************************************************************** + * Public Functions ****************************************************************************/ /**************************************************************************** @@ -492,11 +547,7 @@ ssize_t psock_sendto(FAR struct socket *psock, FAR const void *buf, /* Notify the device driver of the availability of TX data */ -#ifdef CONFIG_NET_MULTILINK - netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr); -#else - netdev_ipv4_txnotify(conn->u.ipv4.raddr); -#endif + sendto_txnotify(psock, conn); /* Wait for either the receive to complete or for an error/timeout to occur. * NOTES: (1) net_lockedwait will also terminate if a signal is received, (2) diff --git a/net/tcp/tcp_send_buffered.c b/net/tcp/tcp_send_buffered.c index 4efae569f36..ce71c0e0b54 100644 --- a/net/tcp/tcp_send_buffered.c +++ b/net/tcp/tcp_send_buffered.c @@ -725,6 +725,61 @@ static uint16_t psock_send_interrupt(FAR struct net_driver_s *dev, return flags; } +/**************************************************************************** + * Function: send_txnotify + * + * Description: + * Notify the appropriate device driver that we are have data ready to + * be send (TCP) + * + * Parameters: + * psock - Socket state structure + * conn - The TCP connection structure + * + * Returned Value: + * None + * + ****************************************************************************/ + +static inline void send_txnotify(FAR struct socket *psock, + FAR struct tcp_conn_s *conn) +{ +#ifdef CONFIG_NET_IPv4 +#ifdef CONFIG_NET_IPv6 + /* If both IPv4 and IPv6 support are enabled, then we will need to select + * the device driver using the appropriate IP domain. + */ + + if (psock->domain == PF_INET) +#endif + { + /* Notify the device driver that send data is available */ + +#ifdef CONFIG_NET_MULTILINK + netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr); +#else + netdev_ipv4_txnotify(conn->u.ipv4.raddr); +#endif + } +#endif /* CONFIG_NET_IPv4 */ + +#ifdef CONFIG_NET_IPv6 +#ifdef CONFIG_NET_IPv4 + else /* if (psock->domain == PF_INET6) */ +#endif /* CONFIG_NET_IPv4 */ + { + /* Notify the device driver that send data is available */ + + DEBUGASSERT(psock->domain == PF_INET6); +#ifdef CONFIG_NET_MULTILINK + netdev_ipv6_txnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr); +#else + netdev_ipv6_txnotify(conn->u.ipv6.raddr); +#endif + } +#endif /* CONFIG_NET_IPv6 */ +} + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -887,11 +942,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf, /* Notify the device driver of the availability of TX data */ -#ifdef CONFIG_NET_MULTILINK - netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr); -#else - netdev_ipv4_txnotify(conn->u.ipv4.raddr); -#endif + send_txnotify(psock, conn); result = len; } diff --git a/net/tcp/tcp_send_unbuffered.c b/net/tcp/tcp_send_unbuffered.c index decd83a4e63..b685838b807 100644 --- a/net/tcp/tcp_send_unbuffered.c +++ b/net/tcp/tcp_send_unbuffered.c @@ -508,6 +508,61 @@ end_wait: return flags; } +/**************************************************************************** + * Function: send_txnotify + * + * Description: + * Notify the appropriate device driver that we are have data ready to + * be send (TCP) + * + * Parameters: + * psock - Socket state structure + * conn - The TCP connection structure + * + * Returned Value: + * None + * + ****************************************************************************/ + +static inline void send_txnotify(FAR struct socket *psock, + FAR struct tcp_conn_s *conn) +{ +#ifdef CONFIG_NET_IPv4 +#ifdef CONFIG_NET_IPv6 + /* If both IPv4 and IPv6 support are enabled, then we will need to select + * the device driver using the appropriate IP domain. + */ + + if (psock->domain == PF_INET) +#endif + { + /* Notify the device driver that send data is available */ + +#ifdef CONFIG_NET_MULTILINK + netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr); +#else + netdev_ipv4_txnotify(conn->u.ipv4.raddr); +#endif + } +#endif /* CONFIG_NET_IPv4 */ + +#ifdef CONFIG_NET_IPv6 +#ifdef CONFIG_NET_IPv4 + else /* if (psock->domain == PF_INET6) */ +#endif /* CONFIG_NET_IPv4 */ + { + /* Notify the device driver that send data is available */ + + DEBUGASSERT(psock->domain == PF_INET6); +#ifdef CONFIG_NET_MULTILINK + netdev_ipv6_txnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr); +#else + netdev_ipv6_txnotify(conn->u.ipv6.raddr); +#endif + } +#endif /* CONFIG_NET_IPv6 */ +} + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -658,11 +713,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, /* Notify the device driver of the availability of TX data */ -#ifdef CONFIG_NET_MULTILINK - netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr); -#else - netdev_ipv4_txnotify(conn->u.ipv4.raddr); -#endif + send_txnotify(psock, conn); /* Wait for the send to complete or an error to occur: NOTES: (1) * net_lockedwait will also terminate if a signal is received, (2) interrupts