mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 16:50:55 +08:00
@@ -1,7 +1,8 @@
|
||||
/****************************************************************************
|
||||
* net/socket/net_timeo.c
|
||||
*
|
||||
* Copyright (C) 2007-2009, 2011-2012, 2014 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2009, 2011-2012, 2014 Gregory Nutt.
|
||||
* All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
||||
+11
-11
@@ -263,10 +263,10 @@ static int tcp_selectport(uint8_t domain, FAR const union ip_addr_u *ipaddr,
|
||||
{
|
||||
if (portno == 0)
|
||||
{
|
||||
/* No local port assigned. Loop until we find a valid listen port number
|
||||
* that is not being used by any other connection. NOTE the following
|
||||
* loop is assumed to terminate but could not if all 32000-4096+1 ports
|
||||
* are in used (unlikely).
|
||||
/* No local port assigned. Loop until we find a valid listen port
|
||||
* number that is not being used by any other connection. NOTE the
|
||||
* following loop is assumed to terminate but could not if all
|
||||
* 32000-4096+1 ports are in used (unlikely).
|
||||
*/
|
||||
|
||||
do
|
||||
@@ -476,7 +476,7 @@ static inline int tcp_ipv4_bind(FAR struct tcp_conn_s *conn,
|
||||
return port;
|
||||
}
|
||||
|
||||
/* Save the local address in the connection structure (network byte order). */
|
||||
/* Save the local address in the connection structure (network order). */
|
||||
|
||||
conn->lport = htons(port);
|
||||
net_ipv4addr_copy(conn->u.ipv4.laddr, addr->sin_addr.s_addr);
|
||||
@@ -535,15 +535,15 @@ static inline int tcp_ipv6_bind(FAR struct tcp_conn_s *conn,
|
||||
/* The port number must be unique for this address binding */
|
||||
|
||||
port = tcp_selectport(PF_INET6,
|
||||
(FAR const union ip_addr_u *)addr->sin6_addr.in6_u.u6_addr16,
|
||||
ntohs(addr->sin6_port));
|
||||
(FAR const union ip_addr_u *)addr->sin6_addr.in6_u.u6_addr16,
|
||||
ntohs(addr->sin6_port));
|
||||
if (port < 0)
|
||||
{
|
||||
nerr("ERROR: tcp_selectport failed: %d\n", port);
|
||||
return port;
|
||||
}
|
||||
|
||||
/* Save the local address in the connection structure (network byte order). */
|
||||
/* Save the local address in the connection structure (network order). */
|
||||
|
||||
conn->lport = htons(port);
|
||||
net_ipv6addr_copy(conn->u.ipv6.laddr, addr->sin6_addr.in6_u.u6_addr16);
|
||||
@@ -637,8 +637,8 @@ FAR struct tcp_conn_s *tcp_alloc(uint8_t domain)
|
||||
|
||||
if (!conn)
|
||||
{
|
||||
/* As a fall-back, check for connection structures which can be stalled.
|
||||
*
|
||||
/* As a fall-back, check for connection structures which can be
|
||||
* stalled.
|
||||
* Search the active connection list for the oldest connection
|
||||
* that is about to be closed anyway.
|
||||
*/
|
||||
@@ -1116,7 +1116,7 @@ int tcp_connect(FAR struct tcp_conn_s *conn, FAR const struct sockaddr *addr)
|
||||
}
|
||||
|
||||
/* If the TCP port has not already been bound to a local port, then select
|
||||
* one now. We assume that the IP address has been bound to a local device,
|
||||
* one now. We assume that the IP address has been bound to a local device,
|
||||
* but the port may still be INPORT_ANY.
|
||||
*/
|
||||
|
||||
|
||||
+13
-13
@@ -127,7 +127,7 @@ static void tcp_input(FAR struct net_driver_s *dev, uint8_t domain,
|
||||
|
||||
tcpiplen = iplen + TCP_HDRLEN;
|
||||
|
||||
/* Get the size of the link layer header, the IP header, and the TCP header */
|
||||
/* Get the size of the link layer header, the IP and TCP header */
|
||||
|
||||
hdrlen = tcpiplen + NET_LL_HDRLEN(dev);
|
||||
|
||||
@@ -192,8 +192,8 @@ static void tcp_input(FAR struct net_driver_s *dev, uint8_t domain,
|
||||
* response.
|
||||
*/
|
||||
|
||||
/* First allocate a new connection structure and see if there is any
|
||||
* user application to accept it.
|
||||
/* First allocate a new connection structure and see if there is
|
||||
* any user application to accept it.
|
||||
*/
|
||||
|
||||
conn = tcp_alloc_accept(dev, tcp);
|
||||
@@ -508,9 +508,9 @@ found:
|
||||
if ((conn->tcpstateflags & TCP_STATE_MASK) == TCP_ESTABLISHED)
|
||||
{
|
||||
nwarn("WARNING: ackseq > unackseq\n");
|
||||
nwarn(" sndseq=%u tx_unacked=%u unackseq=%u ackseq=%u\n",
|
||||
tcp_getsequence(conn->sndseq), conn->tx_unacked, unackseq,
|
||||
ackseq);
|
||||
nwarn("sndseq=%u tx_unacked=%u unackseq=%u ackseq=%u\n",
|
||||
tcp_getsequence(conn->sndseq), conn->tx_unacked,
|
||||
unackseq, ackseq);
|
||||
|
||||
conn->tx_unacked = 0;
|
||||
}
|
||||
@@ -522,7 +522,7 @@ found:
|
||||
*/
|
||||
|
||||
ninfo("sndseq: %08x->%08x unackseq: %08x new tx_unacked: %d\n",
|
||||
tcp_getsequence(conn->sndseq), ackseq, unackseq, conn->tx_unacked);
|
||||
tcp_getsequence(conn->sndseq), ackseq, unackseq, conn->tx_unacked);
|
||||
tcp_setsequence(conn->sndseq, ackseq);
|
||||
|
||||
/* Do RTT estimation, unless we have done retransmissions. */
|
||||
@@ -748,8 +748,8 @@ found:
|
||||
*
|
||||
* If the incoming packet is a FIN, we should close the connection on
|
||||
* this side as well, and we send out a FIN and enter the LAST_ACK
|
||||
* state. We require that there is no outstanding data; otherwise the
|
||||
* sequence numbers will be screwed up.
|
||||
* state. We require that there is no outstanding data; otherwise
|
||||
* the sequence numbers will be screwed up.
|
||||
*/
|
||||
|
||||
if ((tcp->flags & TCP_FIN) != 0 &&
|
||||
@@ -757,8 +757,8 @@ found:
|
||||
{
|
||||
/* Needs to be investigated further.
|
||||
* Windows often sends FIN packets together with the last ACK for
|
||||
* the received data. So the socket layer has to get this ACK even
|
||||
* if the connection is going to be closed.
|
||||
* the received data. So the socket layer has to get this ACK
|
||||
* even if the connection is going to be closed.
|
||||
*/
|
||||
|
||||
#if 0
|
||||
@@ -768,8 +768,8 @@ found:
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Update the sequence number and indicate that the connection has
|
||||
* been closed.
|
||||
/* Update the sequence number and indicate that the connection
|
||||
* has been closed.
|
||||
*/
|
||||
|
||||
net_incr32(conn->rcvseq, dev->d_len + 1);
|
||||
|
||||
+3
-4
@@ -423,8 +423,7 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
|
||||
unsigned int tcpiplen;
|
||||
|
||||
/* No.. we need to send another probe.
|
||||
*
|
||||
* Get the size of the IP header and the TCP header.
|
||||
* Get the size of the IP and TCP header.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_NET_IPv4
|
||||
@@ -465,8 +464,8 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
|
||||
|
||||
tcp_setsequence(conn->sndseq, saveseq);
|
||||
|
||||
/* Increment the number of un-ACKed bytes due to the
|
||||
* dummy byte that we just sent.
|
||||
/* Increment the number of un-ACKed bytes due to
|
||||
* the dummy byte that we just sent.
|
||||
*/
|
||||
|
||||
conn->tx_unacked++;
|
||||
|
||||
Reference in New Issue
Block a user