diff --git a/net/tcp/tcp_send_buffered.c b/net/tcp/tcp_send_buffered.c index a8218d7922a..fc49cb9a731 100644 --- a/net/tcp/tcp_send_buffered.c +++ b/net/tcp/tcp_send_buffered.c @@ -94,6 +94,44 @@ * Private Functions ****************************************************************************/ +/**************************************************************************** + * 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 * diff --git a/net/udp/udp_sendto_buffered.c b/net/udp/udp_sendto_buffered.c index cefe8a30cda..899b3d5e9aa 100644 --- a/net/udp/udp_sendto_buffered.c +++ b/net/udp/udp_sendto_buffered.c @@ -105,6 +105,38 @@ static uint16_t sendto_eventhandler(FAR struct net_driver_s *dev, * Private Functions ****************************************************************************/ +/**************************************************************************** + * 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 *