tcp: Use the tcp seq macros in some obvious places

This commit is contained in:
YAMAMOTO Takashi 2021-06-03 16:42:02 +09:00 committed by Xiang Xiao
parent 433a2b27d9
commit eb00e00e48
3 changed files with 10 additions and 10 deletions

View File

@ -429,7 +429,7 @@ found:
ackseq = tcp_getsequence(tcp->seqno);
rcvseq = tcp_getsequence(conn->rcvseq);
if (ackseq < rcvseq)
if (TCP_SEQ_LT(ackseq, rcvseq))
{
/* Send a "normal" acknowledgment of the KeepAlive probe */
@ -492,7 +492,7 @@ found:
* new sequence number.
*/
if (ackseq <= unackseq)
if (TCP_SEQ_LTE(ackseq, unackseq))
{
/* Calculate the new number of outstanding, unacknowledged bytes */

View File

@ -407,7 +407,7 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
* the write buffer has been ACKed.
*/
if (ackno > TCP_WBSEQNO(wrb))
if (TCP_SEQ_GT(ackno, TCP_WBSEQNO(wrb)))
{
/* Get the sequence number at the end of the data */
@ -419,7 +419,7 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
/* Has the entire buffer been ACKed? */
if (ackno >= lastseq)
if (TCP_SEQ_GTE(ackno, lastseq))
{
ninfo("ACK: wrb=%p Freeing write buffer\n", wrb);
@ -449,7 +449,7 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
* buffers in the chain.
*/
trimlen = ackno - TCP_WBSEQNO(wrb);
trimlen = TCP_SEQ_SUB(ackno, TCP_WBSEQNO(wrb));
if (trimlen > TCP_WBSENT(wrb))
{
/* More data has been ACKed then we have sent? */
@ -504,13 +504,13 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
*/
wrb = (FAR struct tcp_wrbuffer_s *)sq_peek(&conn->write_q);
if (wrb && TCP_WBSENT(wrb) > 0 && ackno > TCP_WBSEQNO(wrb))
if (wrb && TCP_WBSENT(wrb) > 0 && TCP_SEQ_GT(ackno, TCP_WBSEQNO(wrb)))
{
uint32_t nacked;
/* Number of bytes that were ACKed */
nacked = ackno - TCP_WBSEQNO(wrb);
nacked = TCP_SEQ_SUB(ackno, TCP_WBSEQNO(wrb));
if (nacked > TCP_WBSENT(wrb))
{
/* More data has been ACKed then we have sent? ASSERT? */
@ -811,8 +811,7 @@ static uint16_t psock_send_eventhandler(FAR struct net_driver_s *dev,
predicted_seqno = tcp_getsequence(conn->sndseq) + sndlen;
if ((predicted_seqno > conn->sndseq_max) ||
(tcp_getsequence(conn->sndseq) > predicted_seqno)) /* overflow */
if (TCP_SEQ_GT(predicted_seqno, conn->sndseq_max))
{
conn->sndseq_max = predicted_seqno;
}

View File

@ -220,7 +220,8 @@ static uint16_t tcpsend_eventhandler(FAR struct net_driver_s *dev,
* of bytes to be acknowledged.
*/
pstate->snd_acked = tcp_getsequence(tcp->ackno) - pstate->snd_isn;
pstate->snd_acked = TCP_SEQ_SUB(tcp_getsequence(tcp->ackno),
pstate->snd_isn);
ninfo("ACK: acked=%" PRId32 " sent=%zd buflen=%zd\n",
pstate->snd_acked, pstate->snd_sent, pstate->snd_buflen);