net/tcp: change the tcp optdata to dynamic arrays
Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
parent
87bffc190c
commit
a5cdc4e69b
|
@ -171,7 +171,7 @@ struct tcp_hdr_s
|
|||
uint8_t wnd[2];
|
||||
uint16_t tcpchksum;
|
||||
uint8_t urgp[2];
|
||||
uint8_t optdata[4];
|
||||
uint8_t optdata[0];
|
||||
};
|
||||
|
||||
/* The structure holding the TCP/IP statistics that are gathered if
|
||||
|
|
|
@ -628,6 +628,7 @@ void tcp_synack(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
|
|||
{
|
||||
struct tcp_hdr_s *tcp;
|
||||
uint16_t tcp_mss;
|
||||
int16_t optlen = 0;
|
||||
|
||||
/* Get values that vary with the underlying IP domain */
|
||||
|
||||
|
@ -642,7 +643,7 @@ void tcp_synack(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
|
|||
|
||||
/* Set the packet length for the TCP Maximum Segment Size */
|
||||
|
||||
dev->d_len = IPv6TCP_HDRLEN + TCP_OPT_MSS_LEN;
|
||||
dev->d_len = IPv6TCP_HDRLEN;
|
||||
}
|
||||
#endif /* CONFIG_NET_IPv6 */
|
||||
|
||||
|
@ -657,7 +658,7 @@ void tcp_synack(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
|
|||
|
||||
/* Set the packet length for the TCP Maximum Segment Size */
|
||||
|
||||
dev->d_len = IPv4TCP_HDRLEN + TCP_OPT_MSS_LEN;
|
||||
dev->d_len = IPv4TCP_HDRLEN;
|
||||
}
|
||||
#endif /* CONFIG_NET_IPv4 */
|
||||
|
||||
|
@ -669,11 +670,12 @@ void tcp_synack(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
|
|||
|
||||
/* We send out the TCP Maximum Segment Size option with our ACK. */
|
||||
|
||||
tcp->optdata[0] = TCP_OPT_MSS;
|
||||
tcp->optdata[1] = TCP_OPT_MSS_LEN;
|
||||
tcp->optdata[2] = tcp_mss >> 8;
|
||||
tcp->optdata[3] = tcp_mss & 0xff;
|
||||
tcp->tcpoffset = ((TCP_HDRLEN + TCP_OPT_MSS_LEN) / 4) << 4;
|
||||
tcp->optdata[optlen++] = TCP_OPT_MSS;
|
||||
tcp->optdata[optlen++] = TCP_OPT_MSS_LEN;
|
||||
tcp->optdata[optlen++] = tcp_mss >> 8;
|
||||
tcp->optdata[optlen++] = tcp_mss & 0xff;
|
||||
tcp->tcpoffset = ((TCP_HDRLEN + optlen) / 4) << 4;
|
||||
dev->d_len += optlen;
|
||||
|
||||
/* Complete the common portions of the TCP message */
|
||||
|
||||
|
|
Loading…
Reference in New Issue