net/tcp: new api tcp_dataconcat() to concatenate/pack iob chain
Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
parent
b362f18d6a
commit
0e7d397553
@ -1278,6 +1278,21 @@ uint16_t tcp_datahandler(FAR struct net_driver_s *dev,
|
|||||||
FAR struct tcp_conn_s *conn,
|
FAR struct tcp_conn_s *conn,
|
||||||
uint16_t offset);
|
uint16_t offset);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: tcp_dataconcat
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Concatenate iob_s chain iob2 to iob1, if CONFIG_NET_TCP_RECV_PACK is
|
||||||
|
* endabled, pack all data in the I/O buffer chain.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* The number of bytes actually buffered is returned. This will be either
|
||||||
|
* zero or equal to iob1->io_pktlen.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
uint16_t tcp_dataconcat(FAR struct iob_s **iob1, FAR struct iob_s **iob2);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: tcp_backlogcreate
|
* Name: tcp_backlogcreate
|
||||||
*
|
*
|
||||||
|
@ -196,6 +196,43 @@ uint16_t tcp_callback(FAR struct net_driver_s *dev,
|
|||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: tcp_dataconcat
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Concatenate iob_s chain iob2 to iob1, if CONFIG_NET_TCP_RECV_PACK is
|
||||||
|
* endabled, pack all data in the I/O buffer chain.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* The number of bytes actually buffered is returned. This will be either
|
||||||
|
* zero or equal to iob->io_pktlen.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
uint16_t tcp_dataconcat(FAR struct iob_s **iob1, FAR struct iob_s **iob2)
|
||||||
|
{
|
||||||
|
if (*iob1 == NULL)
|
||||||
|
{
|
||||||
|
*iob1 = *iob2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
iob_concat(*iob1, *iob2);
|
||||||
|
}
|
||||||
|
|
||||||
|
*iob2 = NULL;
|
||||||
|
|
||||||
|
#ifdef CONFIG_NET_TCP_RECV_PACK
|
||||||
|
/* Merge an iob chain into a continuous space, thereby reducing iob
|
||||||
|
* consumption.
|
||||||
|
*/
|
||||||
|
|
||||||
|
*iob1 = iob_pack(*iob1);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return (*iob1)->io_pktlen;
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: tcp_datahandler
|
* Name: tcp_datahandler
|
||||||
*
|
*
|
||||||
@ -247,22 +284,9 @@ uint16_t tcp_datahandler(FAR struct net_driver_s *dev,
|
|||||||
|
|
||||||
/* Concat the iob to readahead */
|
/* Concat the iob to readahead */
|
||||||
|
|
||||||
if (conn->readahead == NULL)
|
tcp_dataconcat(&conn->readahead, &iob);
|
||||||
{
|
|
||||||
conn->readahead = iob;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
iob_concat(conn->readahead, iob);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef CONFIG_NET_TCP_RECV_PACK
|
/* Clear device buffer */
|
||||||
/* Merge an iob chain into a continuous space, thereby reducing iob
|
|
||||||
* consumption.
|
|
||||||
*/
|
|
||||||
|
|
||||||
conn->readahead = iob_pack(conn->readahead);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
netdev_iob_clear(dev);
|
netdev_iob_clear(dev);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user