Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions net/tcp/tcp_send.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ void tcp_send(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
void tcp_reset(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn)
{
FAR struct tcp_hdr_s *tcp;
uint32_t ackno;
uint16_t tmp16;
uint16_t acklen = 0;
uint8_t seqbyte;
Expand Down Expand Up @@ -437,7 +436,6 @@ void tcp_reset(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn)

acklen -= (tcp->tcpoffset >> 4) << 2;

tcp->flags = TCP_RST | TCP_ACK;
tcp->tcpoffset = 5 << 4;

/* Flip the seqno and ackno fields in the TCP header. */
Expand All @@ -463,9 +461,19 @@ void tcp_reset(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn)
* to propagate the carry to the other bytes as well.
*/

ackno = tcp_addsequence(tcp->ackno, acklen);

tcp_setsequence(tcp->ackno, ackno);
if ((tcp->flags & TCP_ACK) != 0)
{
tcp->flags = TCP_RST;
tcp_setsequence(tcp->ackno, 0);
}
else
{
uint32_t ackno;
tcp->flags = TCP_RST | TCP_ACK;
tcp_setsequence(tcp->seqno, 0);
ackno = tcp_addsequence(tcp->ackno, acklen);
tcp_setsequence(tcp->ackno, ackno);
}

/* Swap port numbers. */

Expand Down
Loading