mirror of
https://github.com/apache/nuttx.git
synced 2026-05-27 03:05:40 +08:00
tcp_reset: Modify RST packet responses to comply with RFC 793.
Build Documentation / build-html (push) Has been cancelled
Build Documentation / build-html (push) Has been cancelled
According to RFC793, the flags of TCP reply packet should be as follows: 1. `RST` if flags of request packet has `ACK` 2. `RST|ACK` if flags of request packet has no `ACK`, at the same time, the sequence should be set to zero. Signed-off-by: wenquan1 <wenquan1@xiaomi.com>
This commit is contained in:
+13
-5
@@ -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)
|
void tcp_reset(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn)
|
||||||
{
|
{
|
||||||
FAR struct tcp_hdr_s *tcp;
|
FAR struct tcp_hdr_s *tcp;
|
||||||
uint32_t ackno;
|
|
||||||
uint16_t tmp16;
|
uint16_t tmp16;
|
||||||
uint16_t acklen = 0;
|
uint16_t acklen = 0;
|
||||||
uint8_t seqbyte;
|
uint8_t seqbyte;
|
||||||
@@ -437,7 +436,6 @@ void tcp_reset(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn)
|
|||||||
|
|
||||||
acklen -= (tcp->tcpoffset >> 4) << 2;
|
acklen -= (tcp->tcpoffset >> 4) << 2;
|
||||||
|
|
||||||
tcp->flags = TCP_RST | TCP_ACK;
|
|
||||||
tcp->tcpoffset = 5 << 4;
|
tcp->tcpoffset = 5 << 4;
|
||||||
|
|
||||||
/* Flip the seqno and ackno fields in the TCP header. */
|
/* Flip the seqno and ackno fields in the TCP header. */
|
||||||
@@ -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.
|
* to propagate the carry to the other bytes as well.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ackno = tcp_addsequence(tcp->ackno, acklen);
|
if ((tcp->flags & TCP_ACK) != 0)
|
||||||
|
{
|
||||||
tcp_setsequence(tcp->ackno, ackno);
|
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. */
|
/* Swap port numbers. */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user