You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/06/04 02:33:18 UTC
[incubator-nuttx] branch master updated: tcp: Move
buffered/unbuffered common code to tcp_send.c
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 69b3f03 tcp: Move buffered/unbuffered common code to tcp_send.c
69b3f03 is described below
commit 69b3f034a4ac677c0150d281f020e636b6c2cdb7
Author: YAMAMOTO Takashi <ya...@midokura.com>
AuthorDate: Tue Jun 1 17:03:57 2021 +0900
tcp: Move buffered/unbuffered common code to tcp_send.c
---
net/tcp/tcp.h | 19 +++++++++++++++++
net/tcp/tcp_send.c | 49 +++++++++++++++++++++++++++++++++++++++++++
net/tcp/tcp_send_buffered.c | 49 +------------------------------------------
net/tcp/tcp_send_unbuffered.c | 49 +------------------------------------------
4 files changed, 70 insertions(+), 96 deletions(-)
diff --git a/net/tcp/tcp.h b/net/tcp/tcp.h
index 863f7b1..fc43dd6 100644
--- a/net/tcp/tcp.h
+++ b/net/tcp/tcp.h
@@ -1022,6 +1022,25 @@ void tcp_rexmit(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
uint16_t result);
/****************************************************************************
+ * Name: tcp_send_txnotify
+ *
+ * Description:
+ * Notify the appropriate device driver that we are have data ready to
+ * be send (TCP)
+ *
+ * Input Parameters:
+ * psock - Socket state structure
+ * conn - The TCP connection structure
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+void tcp_send_txnotify(FAR struct socket *psock,
+ FAR struct tcp_conn_s *conn);
+
+/****************************************************************************
* Name: tcp_ipv4_input
*
* Description:
diff --git a/net/tcp/tcp_send.c b/net/tcp/tcp_send.c
index 190d4e6..050fd80 100644
--- a/net/tcp/tcp_send.c
+++ b/net/tcp/tcp_send.c
@@ -45,6 +45,7 @@
#include <nuttx/config.h>
#if defined(CONFIG_NET) && defined(CONFIG_NET_TCP)
+#include <assert.h>
#include <stdint.h>
#include <string.h>
#include <debug.h>
@@ -55,6 +56,7 @@
#include <nuttx/net/ip.h>
#include <nuttx/net/tcp.h>
+#include "netdev/netdev.h"
#include "devif/devif.h"
#include "inet/inet.h"
#include "tcp/tcp.h"
@@ -630,4 +632,51 @@ void tcp_synack(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
tcp_sendcommon(dev, conn, tcp);
}
+/****************************************************************************
+ * Name: tcp_send_txnotify
+ *
+ * Description:
+ * Notify the appropriate device driver that we are have data ready to
+ * be send (TCP)
+ *
+ * Input Parameters:
+ * psock - Socket state structure
+ * conn - The TCP connection structure
+ *
+ * Returned Value:
+ * None
+ *
+ ****************************************************************************/
+
+void tcp_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->s_domain == PF_INET)
+#endif
+ {
+ /* Notify the device driver that send data is available */
+
+ netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
+ }
+#endif /* CONFIG_NET_IPv4 */
+
+#ifdef CONFIG_NET_IPv6
+#ifdef CONFIG_NET_IPv4
+ else /* if (psock->s_domain == PF_INET6) */
+#endif /* CONFIG_NET_IPv4 */
+ {
+ /* Notify the device driver that send data is available */
+
+ DEBUGASSERT(psock->s_domain == PF_INET6);
+ netdev_ipv6_txnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr);
+ }
+#endif /* CONFIG_NET_IPv6 */
+}
+
#endif /* CONFIG_NET && CONFIG_NET_TCP */
diff --git a/net/tcp/tcp_send_buffered.c b/net/tcp/tcp_send_buffered.c
index 954cb28..053361f 100644
--- a/net/tcp/tcp_send_buffered.c
+++ b/net/tcp/tcp_send_buffered.c
@@ -862,53 +862,6 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
}
/****************************************************************************
- * Name: send_txnotify
- *
- * Description:
- * Notify the appropriate device driver that we are have data ready to
- * be send (TCP)
- *
- * Input 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->s_domain == PF_INET)
-#endif
- {
- /* Notify the device driver that send data is available */
-
- netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
- }
-#endif /* CONFIG_NET_IPv4 */
-
-#ifdef CONFIG_NET_IPv6
-#ifdef CONFIG_NET_IPv4
- else /* if (psock->s_domain == PF_INET6) */
-#endif /* CONFIG_NET_IPv4 */
- {
- /* Notify the device driver that send data is available */
-
- DEBUGASSERT(psock->s_domain == PF_INET6);
- netdev_ipv6_txnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr);
- }
-#endif /* CONFIG_NET_IPv6 */
-}
-
-/****************************************************************************
* Name: tcp_max_wrb_size
*
* Description:
@@ -1244,7 +1197,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf,
/* Notify the device driver of the availability of TX data */
- send_txnotify(psock, conn);
+ tcp_send_txnotify(psock, conn);
net_unlock();
if (chunk_result == 0)
diff --git a/net/tcp/tcp_send_unbuffered.c b/net/tcp/tcp_send_unbuffered.c
index baf0378..31e735d 100644
--- a/net/tcp/tcp_send_unbuffered.c
+++ b/net/tcp/tcp_send_unbuffered.c
@@ -462,53 +462,6 @@ end_wait:
}
/****************************************************************************
- * Name: send_txnotify
- *
- * Description:
- * Notify the appropriate device driver that we are have data ready to
- * be send (TCP)
- *
- * Input 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->s_domain == PF_INET)
-#endif
- {
- /* Notify the device driver that send data is available */
-
- netdev_ipv4_txnotify(conn->u.ipv4.laddr, conn->u.ipv4.raddr);
- }
-#endif /* CONFIG_NET_IPv4 */
-
-#ifdef CONFIG_NET_IPv6
-#ifdef CONFIG_NET_IPv4
- else /* if (psock->s_domain == PF_INET6) */
-#endif /* CONFIG_NET_IPv4 */
- {
- /* Notify the device driver that send data is available */
-
- DEBUGASSERT(psock->s_domain == PF_INET6);
- netdev_ipv6_txnotify(conn->u.ipv6.laddr, conn->u.ipv6.raddr);
- }
-#endif /* CONFIG_NET_IPv6 */
-}
-
-/****************************************************************************
* Public Functions
****************************************************************************/
@@ -679,7 +632,7 @@ ssize_t psock_tcp_send(FAR struct socket *psock,
/* Notify the device driver of the availability of TX data */
- send_txnotify(psock, conn);
+ tcp_send_txnotify(psock, conn);
/* Wait for the send to complete or an error to occur: NOTES:
* net_lockedwait will also terminate if a signal is received.