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/07/21 03:25:37 UTC
[incubator-nuttx] 01/02: net/wrb: add tcp/udp_inqueue_wrb_size()
interface
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
commit f52757f90a3de3da57af5ea6d7e8ad7993236dc0
Author: chao.an <an...@xiaomi.com>
AuthorDate: Wed Jul 14 17:30:44 2021 +0800
net/wrb: add tcp/udp_inqueue_wrb_size() interface
Signed-off-by: chao.an <an...@xiaomi.com>
---
net/tcp/tcp_send_buffered.c | 38 ++++++++++++++++++++++++++++++++++++++
net/udp/udp_sendto_buffered.c | 32 ++++++++++++++++++++++++++++++++
2 files changed, 70 insertions(+)
diff --git a/net/tcp/tcp_send_buffered.c b/net/tcp/tcp_send_buffered.c
index 5740ad4..364f24f 100644
--- a/net/tcp/tcp_send_buffered.c
+++ b/net/tcp/tcp_send_buffered.c
@@ -95,6 +95,44 @@
****************************************************************************/
/****************************************************************************
+ * Name: tcp_inqueue_wrb_size
+ *
+ * Description:
+ * Get the in-queued write buffer size from connection
+ *
+ * Input Parameters:
+ * conn - The TCP connection of interest
+ *
+ * Assumptions:
+ * Called from user logic with the network locked.
+ *
+ ****************************************************************************/
+
+static uint32_t tcp_inqueue_wrb_size(FAR struct tcp_conn_s *conn)
+{
+ FAR struct tcp_wrbuffer_s *wrb;
+ FAR sq_entry_t *entry;
+ uint32_t total = 0;
+
+ if (conn)
+ {
+ for (entry = sq_peek(&conn->unacked_q); entry; entry = sq_next(entry))
+ {
+ wrb = (FAR struct tcp_wrbuffer_s *)entry;
+ total += TCP_WBPKTLEN(wrb);
+ }
+
+ for (entry = sq_peek(&conn->write_q); entry; entry = sq_next(entry))
+ {
+ wrb = (FAR struct tcp_wrbuffer_s *)entry;
+ total += TCP_WBPKTLEN(wrb);
+ }
+ }
+
+ return total;
+}
+
+/****************************************************************************
* Name: psock_insert_segment
*
* Description:
diff --git a/net/udp/udp_sendto_buffered.c b/net/udp/udp_sendto_buffered.c
index cefe8a3..899b3d5 100644
--- a/net/udp/udp_sendto_buffered.c
+++ b/net/udp/udp_sendto_buffered.c
@@ -106,6 +106,38 @@ static uint16_t sendto_eventhandler(FAR struct net_driver_s *dev,
****************************************************************************/
/****************************************************************************
+ * Name: udp_inqueue_wrb_size
+ *
+ * Description:
+ * Get the in-queued write buffer size from connection
+ *
+ * Input Parameters:
+ * conn - The UDP connection of interest
+ *
+ * Assumptions:
+ * Called from user logic with the network locked.
+ *
+ ****************************************************************************/
+
+static uint32_t udp_inqueue_wrb_size(FAR struct udp_conn_s *conn)
+{
+ FAR struct udp_wrbuffer_s *wrb;
+ FAR sq_entry_t *entry;
+ uint32_t total = 0;
+
+ if (conn)
+ {
+ for (entry = sq_peek(&conn->write_q); entry; entry = sq_next(entry))
+ {
+ wrb = (FAR struct udp_wrbuffer_s *)entry;
+ total += wrb->wb_iob->io_pktlen;
+ }
+ }
+
+ return total;
+}
+
+/****************************************************************************
* Name: sendto_writebuffer_release
*
* Description: