mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 10:58:49 +08:00
NET: Rename TCP state values: UIP_ -> TCP_
This commit is contained in:
parent
ea6daaec6c
commit
b77fda2c95
14 changed files with 123 additions and 123 deletions
|
@ -232,11 +232,11 @@
|
|||
|
||||
/* How long a connection should stay in the TIME_WAIT state.
|
||||
*
|
||||
* This configiration option has no real implication, and it should be
|
||||
* This configuration option has no real implication, and it should be
|
||||
* left untouched. Units: half second.
|
||||
*/
|
||||
|
||||
#define UIP_TIME_WAIT_TIMEOUT (60*2)
|
||||
#define TCP_TIME_WAIT_TIMEOUT (60*2)
|
||||
|
||||
/* ARP configuration options */
|
||||
|
||||
|
|
|
@ -64,46 +64,46 @@
|
|||
|
||||
/* TCP definitions */
|
||||
|
||||
#define TCP_FIN 0x01
|
||||
#define TCP_SYN 0x02
|
||||
#define TCP_RST 0x04
|
||||
#define TCP_PSH 0x08
|
||||
#define TCP_ACK 0x10
|
||||
#define TCP_URG 0x20
|
||||
#define TCP_CTL 0x3f
|
||||
#define TCP_FIN 0x01
|
||||
#define TCP_SYN 0x02
|
||||
#define TCP_RST 0x04
|
||||
#define TCP_PSH 0x08
|
||||
#define TCP_ACK 0x10
|
||||
#define TCP_URG 0x20
|
||||
#define TCP_CTL 0x3f
|
||||
|
||||
#define TCP_OPT_END 0 /* End of TCP options list */
|
||||
#define TCP_OPT_NOOP 1 /* "No-operation" TCP option */
|
||||
#define TCP_OPT_MSS 2 /* Maximum segment size TCP option */
|
||||
#define TCP_OPT_END 0 /* End of TCP options list */
|
||||
#define TCP_OPT_NOOP 1 /* "No-operation" TCP option */
|
||||
#define TCP_OPT_MSS 2 /* Maximum segment size TCP option */
|
||||
|
||||
#define TCP_OPT_MSS_LEN 4 /* Length of TCP MSS option. */
|
||||
#define TCP_OPT_MSS_LEN 4 /* Length of TCP MSS option. */
|
||||
|
||||
/* The TCP states used in the struct tcp_conn_s tcpstateflags field */
|
||||
|
||||
#define UIP_TS_MASK 0x0f /* Bits 0-3: TCP state */
|
||||
#define UIP_CLOSED 0x00 /* The connection is not in use and available */
|
||||
#define UIP_ALLOCATED 0x01 /* The connection is allocated, but not yet initialized */
|
||||
#define UIP_SYN_RCVD 0x02
|
||||
#define UIP_SYN_SENT 0x03
|
||||
#define UIP_ESTABLISHED 0x04
|
||||
#define UIP_FIN_WAIT_1 0x05
|
||||
#define UIP_FIN_WAIT_2 0x06
|
||||
#define UIP_CLOSING 0x07
|
||||
#define UIP_TIME_WAIT 0x08
|
||||
#define UIP_LAST_ACK 0x09
|
||||
#define UIP_STOPPED 0x10 /* Bit 4: stopped */
|
||||
/* Bit 5-7: Unused, but not available */
|
||||
#define TCP_STATE_MASK 0x0f /* Bits 0-3: TCP state */
|
||||
# define TCP_CLOSED 0x00 /* The connection is not in use and available */
|
||||
# define TCP_ALLOCATED 0x01 /* The connection is allocated, but not yet initialized */
|
||||
# define TCP_SYN_RCVD 0x02
|
||||
# define TCP_SYN_SENT 0x03
|
||||
# define TCP_ESTABLISHED 0x04
|
||||
# define TCP_FIN_WAIT_1 0x05
|
||||
# define TCP_FIN_WAIT_2 0x06
|
||||
# define TCP_CLOSING 0x07
|
||||
# define TCP_TIME_WAIT 0x08
|
||||
# define TCP_LAST_ACK 0x09
|
||||
# define TCP_STOPPED 0x10 /* Bit 4: stopped */
|
||||
/* Bit 5-7: Unused, but not available */
|
||||
|
||||
/* Flag bits in 16-bit flags+ipoffset IPv4 TCP header field */
|
||||
|
||||
#define UIP_TCPFLAG_RESERVED 0x8000
|
||||
#define UIP_TCPFLAG_DONTFRAG 0x4000
|
||||
#define UIP_TCPFLAG_MOREFRAGS 0x2000
|
||||
#define TCPFLAG_RESERVED 0x8000
|
||||
#define TCPFLAG_DONTFRAG 0x4000
|
||||
#define TCPFLAG_MOREFRAGS 0x2000
|
||||
|
||||
/* TCP header sizes */
|
||||
|
||||
#define TCP_HDRLEN 20 /* Size of TCP header */
|
||||
#define IPTCP_HDRLEN (TCP_HDRLEN + IP_HDRLEN) /* Size of IP + TCP header */
|
||||
#define TCP_HDRLEN 20 /* Size of TCP header */
|
||||
#define IPTCP_HDRLEN (TCP_HDRLEN + IP_HDRLEN) /* Size of IP + TCP header */
|
||||
|
||||
/* Initial minimum MSS according to RFC 879
|
||||
*
|
||||
|
|
|
@ -136,8 +136,8 @@ void icmp_send(FAR struct net_driver_s *dev, FAR net_ipaddr_t *destaddr)
|
|||
++g_ipid;
|
||||
picmp->ipid[0] = g_ipid >> 8;
|
||||
picmp->ipid[1] = g_ipid & 0xff;
|
||||
picmp->ipoffset[0] = UIP_TCPFLAG_DONTFRAG >> 8;
|
||||
picmp->ipoffset[1] = UIP_TCPFLAG_DONTFRAG & 0xff;
|
||||
picmp->ipoffset[0] = TCPFLAG_DONTFRAG >> 8;
|
||||
picmp->ipoffset[1] = TCPFLAG_DONTFRAG & 0xff;
|
||||
picmp->ttl = UIP_TTL;
|
||||
picmp->proto = IP_PROTO_ICMP;
|
||||
|
||||
|
|
|
@ -150,8 +150,8 @@ void igmp_send(FAR struct net_driver_s *dev, FAR struct igmp_group_s *group,
|
|||
++g_ipid;
|
||||
IGMPBUF->ipid[0] = g_ipid >> 8;
|
||||
IGMPBUF->ipid[1] = g_ipid & 0xff;
|
||||
IGMPBUF->ipoffset[0] = UIP_TCPFLAG_DONTFRAG >> 8;
|
||||
IGMPBUF->ipoffset[1] = UIP_TCPFLAG_DONTFRAG & 0xff;
|
||||
IGMPBUF->ipoffset[0] = TCPFLAG_DONTFRAG >> 8;
|
||||
IGMPBUF->ipoffset[1] = TCPFLAG_DONTFRAG & 0xff;
|
||||
IGMPBUF->ttl = IGMP_TTL;
|
||||
IGMPBUF->proto = IP_PROTO_IGMP;
|
||||
|
||||
|
|
|
@ -310,7 +310,7 @@ static inline int netclose_disconnect(FAR struct socket *psock)
|
|||
|
||||
/* Check for the case where the host beat us and disconnected first */
|
||||
|
||||
if (conn->tcpstateflags == UIP_ESTABLISHED &&
|
||||
if (conn->tcpstateflags == TCP_ESTABLISHED &&
|
||||
(state.cl_cb = tcp_callback_alloc(conn)) != NULL)
|
||||
{
|
||||
/* Set up to receive TCP data event callbacks */
|
||||
|
|
|
@ -141,8 +141,8 @@ int net_startmonitor(FAR struct socket *psock)
|
|||
* the monitoring callback.)
|
||||
*/
|
||||
|
||||
if (!(conn->tcpstateflags == UIP_ESTABLISHED ||
|
||||
conn->tcpstateflags == UIP_SYN_RCVD))
|
||||
if (!(conn->tcpstateflags == TCP_ESTABLISHED ||
|
||||
conn->tcpstateflags == TCP_SYN_RCVD))
|
||||
{
|
||||
connection_event(conn, UIP_CLOSE);
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ struct tcp_conn_s
|
|||
sq_queue_t write_q; /* Write buffering for segments */
|
||||
sq_queue_t unacked_q; /* Write buffering for un-ACKed segments */
|
||||
uint16_t expired; /* Number segments retransmitted but not yet ACKed,
|
||||
* it can only be updated at UIP_ESTABLISHED state */
|
||||
* it can only be updated at TCP_ESTABLISHED state */
|
||||
uint16_t sent; /* The number of bytes sent (ACKed and un-ACKed) */
|
||||
uint32_t isn; /* Initial sequence number */
|
||||
#endif
|
||||
|
|
|
@ -109,8 +109,8 @@ void tcp_appsend(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
|
|||
if ((result & UIP_ABORT) != 0)
|
||||
{
|
||||
dev->d_sndlen = 0;
|
||||
conn->tcpstateflags = UIP_CLOSED;
|
||||
nllvdbg("TCP state: UIP_CLOSED\n");
|
||||
conn->tcpstateflags = TCP_CLOSED;
|
||||
nllvdbg("TCP state: TCP_CLOSED\n");
|
||||
|
||||
tcp_send(dev, conn, TCP_RST | TCP_ACK, IPTCP_HDRLEN);
|
||||
}
|
||||
|
@ -119,10 +119,10 @@ void tcp_appsend(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
|
|||
|
||||
else if ((result & UIP_CLOSE) != 0)
|
||||
{
|
||||
conn->tcpstateflags = UIP_FIN_WAIT_1;
|
||||
conn->tcpstateflags = TCP_FIN_WAIT_1;
|
||||
conn->unacked = 1;
|
||||
conn->nrtx = 0;
|
||||
nllvdbg("TCP state: UIP_FIN_WAIT_1\n");
|
||||
nllvdbg("TCP state: TCP_FIN_WAIT_1\n");
|
||||
|
||||
dev->d_sndlen = 0;
|
||||
tcp_send(dev, conn, TCP_FIN | TCP_ACK, IPTCP_HDRLEN);
|
||||
|
|
|
@ -186,7 +186,7 @@ void tcp_initialize(void)
|
|||
{
|
||||
/* Mark the connection closed and move it to the free list */
|
||||
|
||||
g_tcp_connections[i].tcpstateflags = UIP_CLOSED;
|
||||
g_tcp_connections[i].tcpstateflags = TCP_CLOSED;
|
||||
dq_addlast(&g_tcp_connections[i].node, &g_free_tcp_connections);
|
||||
}
|
||||
|
||||
|
@ -244,11 +244,11 @@ FAR struct tcp_conn_s *tcp_alloc(void)
|
|||
* in the socket layer.
|
||||
*/
|
||||
|
||||
if (tmp->tcpstateflags == UIP_CLOSING ||
|
||||
tmp->tcpstateflags == UIP_FIN_WAIT_1 ||
|
||||
tmp->tcpstateflags == UIP_FIN_WAIT_2 ||
|
||||
tmp->tcpstateflags == UIP_TIME_WAIT ||
|
||||
tmp->tcpstateflags == UIP_LAST_ACK)
|
||||
if (tmp->tcpstateflags == TCP_CLOSING ||
|
||||
tmp->tcpstateflags == TCP_FIN_WAIT_1 ||
|
||||
tmp->tcpstateflags == TCP_FIN_WAIT_2 ||
|
||||
tmp->tcpstateflags == TCP_TIME_WAIT ||
|
||||
tmp->tcpstateflags == TCP_LAST_ACK)
|
||||
{
|
||||
/* Yes.. Is it the oldest one we have seen so far? */
|
||||
|
||||
|
@ -300,7 +300,7 @@ FAR struct tcp_conn_s *tcp_alloc(void)
|
|||
if (conn)
|
||||
{
|
||||
memset(conn, 0, sizeof(struct tcp_conn_s));
|
||||
conn->tcpstateflags = UIP_ALLOCATED;
|
||||
conn->tcpstateflags = TCP_ALLOCATED;
|
||||
}
|
||||
|
||||
return conn;
|
||||
|
@ -342,11 +342,11 @@ void tcp_free(FAR struct tcp_conn_s *conn)
|
|||
tcp_callback_free(conn, cb);
|
||||
}
|
||||
|
||||
/* UIP_ALLOCATED means that that the connection is not in the active list
|
||||
/* TCP_ALLOCATED means that that the connection is not in the active list
|
||||
* yet.
|
||||
*/
|
||||
|
||||
if (conn->tcpstateflags != UIP_ALLOCATED)
|
||||
if (conn->tcpstateflags != TCP_ALLOCATED)
|
||||
{
|
||||
/* Remove the connection from the active list */
|
||||
|
||||
|
@ -393,7 +393,7 @@ void tcp_free(FAR struct tcp_conn_s *conn)
|
|||
|
||||
/* Mark the connection available and put it into the free list */
|
||||
|
||||
conn->tcpstateflags = UIP_CLOSED;
|
||||
conn->tcpstateflags = TCP_CLOSED;
|
||||
dq_addlast(&conn->node, &g_free_tcp_connections);
|
||||
net_unlock(flags);
|
||||
}
|
||||
|
@ -419,7 +419,7 @@ FAR struct tcp_conn_s *tcp_active(struct tcp_iphdr_s *buf)
|
|||
{
|
||||
/* Find an open connection matching the tcp input */
|
||||
|
||||
if (conn->tcpstateflags != UIP_CLOSED &&
|
||||
if (conn->tcpstateflags != TCP_CLOSED &&
|
||||
buf->destport == conn->lport && buf->srcport == conn->rport &&
|
||||
net_ipaddr_cmp(srcipaddr, conn->ripaddr))
|
||||
{
|
||||
|
@ -484,7 +484,7 @@ FAR struct tcp_conn_s *tcp_listener(uint16_t portno)
|
|||
for (i = 0; i < CONFIG_NET_TCP_CONNS; i++)
|
||||
{
|
||||
conn = &g_tcp_connections[i];
|
||||
if (conn->tcpstateflags != UIP_CLOSED && conn->lport == portno)
|
||||
if (conn->tcpstateflags != TCP_CLOSED && conn->lport == portno)
|
||||
{
|
||||
/* The port number is in use, return the connection */
|
||||
|
||||
|
@ -524,7 +524,7 @@ FAR struct tcp_conn_s *tcp_alloc_accept(FAR struct tcp_iphdr_s *buf)
|
|||
conn->rport = buf->srcport;
|
||||
conn->mss = TCP_INITIAL_MSS;
|
||||
net_ipaddr_copy(conn->ripaddr, net_ip4addr_conv32(buf->srcipaddr));
|
||||
conn->tcpstateflags = UIP_SYN_RCVD;
|
||||
conn->tcpstateflags = TCP_SYN_RCVD;
|
||||
|
||||
tcp_initsequence(conn->sndseq);
|
||||
conn->unacked = 1;
|
||||
|
@ -647,12 +647,12 @@ int tcp_connect(FAR struct tcp_conn_s *conn,
|
|||
net_lock_t flags;
|
||||
int port;
|
||||
|
||||
/* The connection is expected to be in the UIP_ALLOCATED state.. i.e.,
|
||||
/* The connection is expected to be in the TCP_ALLOCATED state.. i.e.,
|
||||
* allocated via up_tcpalloc(), but not yet put into the active connections
|
||||
* list.
|
||||
*/
|
||||
|
||||
if (!conn || conn->tcpstateflags != UIP_ALLOCATED)
|
||||
if (!conn || conn->tcpstateflags != TCP_ALLOCATED)
|
||||
{
|
||||
return -EISCONN;
|
||||
}
|
||||
|
@ -672,7 +672,7 @@ int tcp_connect(FAR struct tcp_conn_s *conn,
|
|||
|
||||
/* Initialize and return the connection structure, bind it to the port number */
|
||||
|
||||
conn->tcpstateflags = UIP_SYN_SENT;
|
||||
conn->tcpstateflags = TCP_SYN_SENT;
|
||||
tcp_initsequence(conn->sndseq);
|
||||
|
||||
conn->mss = TCP_INITIAL_MSS;
|
||||
|
|
|
@ -137,12 +137,12 @@ void tcp_input(FAR struct net_driver_s *dev)
|
|||
if (conn)
|
||||
{
|
||||
/* We found an active connection.. Check for the subsequent SYN
|
||||
* arriving in UIP_SYN_RCVD state after the SYNACK packet was
|
||||
* arriving in TCP_SYN_RCVD state after the SYNACK packet was
|
||||
* lost. To avoid other issues, reset any active connection
|
||||
* where a SYN arrives in a state != UIP_SYN_RCVD.
|
||||
* where a SYN arrives in a state != TCP_SYN_RCVD.
|
||||
*/
|
||||
|
||||
if ((conn->tcpstateflags & UIP_TS_MASK) != UIP_SYN_RCVD &&
|
||||
if ((conn->tcpstateflags & TCP_STATE_MASK) != TCP_SYN_RCVD &&
|
||||
(BUF->flags & TCP_CTL) == TCP_SYN)
|
||||
{
|
||||
goto reset;
|
||||
|
@ -306,8 +306,8 @@ found:
|
|||
|
||||
if ((pbuf->flags & TCP_RST) != 0)
|
||||
{
|
||||
conn->tcpstateflags = UIP_CLOSED;
|
||||
nlldbg("RESET - TCP state: UIP_CLOSED\n");
|
||||
conn->tcpstateflags = TCP_CLOSED;
|
||||
nlldbg("RESET - TCP state: TCP_CLOSED\n");
|
||||
|
||||
(void)tcp_callback(dev, conn, UIP_ABORT);
|
||||
goto drop;
|
||||
|
@ -333,9 +333,9 @@ found:
|
|||
* (which is done further down).
|
||||
*/
|
||||
|
||||
if (!((((conn->tcpstateflags & UIP_TS_MASK) == UIP_SYN_SENT) &&
|
||||
if (!((((conn->tcpstateflags & TCP_STATE_MASK) == TCP_SYN_SENT) &&
|
||||
((pbuf->flags & TCP_CTL) == (TCP_SYN | TCP_ACK))) ||
|
||||
(((conn->tcpstateflags & UIP_TS_MASK) == UIP_SYN_RCVD) &&
|
||||
(((conn->tcpstateflags & TCP_STATE_MASK) == TCP_SYN_RCVD) &&
|
||||
((pbuf->flags & TCP_CTL) == TCP_SYN))))
|
||||
{
|
||||
if ((dev->d_len > 0 || ((pbuf->flags & (TCP_SYN | TCP_FIN)) != 0)) &&
|
||||
|
@ -395,7 +395,7 @@ found:
|
|||
* bytes
|
||||
*/
|
||||
|
||||
if ((conn->tcpstateflags & UIP_TS_MASK) == UIP_ESTABLISHED)
|
||||
if ((conn->tcpstateflags & TCP_STATE_MASK) == TCP_ESTABLISHED)
|
||||
{
|
||||
nlldbg("ERROR: conn->sndseq %d, conn->unacked %d\n",
|
||||
tcp_getsequence(conn->sndseq), conn->unacked);
|
||||
|
@ -444,7 +444,7 @@ found:
|
|||
|
||||
/* Do different things depending on in what state the connection is. */
|
||||
|
||||
switch (conn->tcpstateflags & UIP_TS_MASK)
|
||||
switch (conn->tcpstateflags & TCP_STATE_MASK)
|
||||
{
|
||||
/* CLOSED and LISTEN are not handled here. CLOSE_WAIT is not
|
||||
* implemented, since we force the application to close when the
|
||||
|
@ -452,7 +452,7 @@ found:
|
|||
* ESTABLISHED to LAST_ACK).
|
||||
*/
|
||||
|
||||
case UIP_SYN_RCVD:
|
||||
case TCP_SYN_RCVD:
|
||||
/* In SYN_RCVD we have sent out a SYNACK in response to a SYN, and
|
||||
* we are waiting for an ACK that acknowledges the data we sent
|
||||
* out the last time. Therefore, we want to have the UIP_ACKDATA
|
||||
|
@ -461,7 +461,7 @@ found:
|
|||
|
||||
if ((flags & UIP_ACKDATA) != 0)
|
||||
{
|
||||
conn->tcpstateflags = UIP_ESTABLISHED;
|
||||
conn->tcpstateflags = TCP_ESTABLISHED;
|
||||
|
||||
#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
|
||||
conn->isn = tcp_getsequence(pbuf->ackno);
|
||||
|
@ -470,7 +470,7 @@ found:
|
|||
#endif
|
||||
conn->unacked = 0;
|
||||
flags = UIP_CONNECTED;
|
||||
nllvdbg("TCP state: UIP_ESTABLISHED\n");
|
||||
nllvdbg("TCP state: TCP_ESTABLISHED\n");
|
||||
|
||||
if (dev->d_len > 0)
|
||||
{
|
||||
|
@ -494,7 +494,7 @@ found:
|
|||
|
||||
goto drop;
|
||||
|
||||
case UIP_SYN_SENT:
|
||||
case TCP_SYN_SENT:
|
||||
/* In SYN_SENT, we wait for a SYNACK that is sent in response to
|
||||
* our SYN. The rcvseq is set to sequence number in the SYNACK
|
||||
* plus one, and we send an ACK. We move into the ESTABLISHED
|
||||
|
@ -555,7 +555,7 @@ found:
|
|||
}
|
||||
}
|
||||
|
||||
conn->tcpstateflags = UIP_ESTABLISHED;
|
||||
conn->tcpstateflags = TCP_ESTABLISHED;
|
||||
memcpy(conn->rcvseq, pbuf->seqno, 4);
|
||||
|
||||
net_incr32(conn->rcvseq, 1);
|
||||
|
@ -568,7 +568,7 @@ found:
|
|||
dev->d_len = 0;
|
||||
dev->d_sndlen = 0;
|
||||
|
||||
nllvdbg("TCP state: UIP_ESTABLISHED\n");
|
||||
nllvdbg("TCP state: TCP_ESTABLISHED\n");
|
||||
result = tcp_callback(dev, conn, UIP_CONNECTED | UIP_NEWDATA);
|
||||
tcp_appsend(dev, conn, result);
|
||||
return;
|
||||
|
@ -580,8 +580,8 @@ found:
|
|||
|
||||
/* The connection is closed after we send the RST */
|
||||
|
||||
conn->tcpstateflags = UIP_CLOSED;
|
||||
nllvdbg("Connection failed - TCP state: UIP_CLOSED\n");
|
||||
conn->tcpstateflags = TCP_CLOSED;
|
||||
nllvdbg("Connection failed - TCP state: TCP_CLOSED\n");
|
||||
|
||||
/* We do not send resets in response to resets. */
|
||||
|
||||
|
@ -593,7 +593,7 @@ found:
|
|||
tcp_reset(dev);
|
||||
return;
|
||||
|
||||
case UIP_ESTABLISHED:
|
||||
case TCP_ESTABLISHED:
|
||||
/* In the ESTABLISHED state, we call upon the application to feed
|
||||
* data into the d_buf. If the UIP_ACKDATA flag is set, the
|
||||
* application should put new data into the buffer, otherwise we are
|
||||
|
@ -606,7 +606,7 @@ found:
|
|||
* sequence numbers will be screwed up.
|
||||
*/
|
||||
|
||||
if ((pbuf->flags & TCP_FIN) != 0 && (conn->tcpstateflags & UIP_STOPPED) == 0)
|
||||
if ((pbuf->flags & TCP_FIN) != 0 && (conn->tcpstateflags & TCP_STOPPED) == 0)
|
||||
{
|
||||
/* Needs to be investigated further.
|
||||
* Windows often sends FIN packets together with the last ACK for
|
||||
|
@ -634,10 +634,10 @@ found:
|
|||
|
||||
(void)tcp_callback(dev, conn, flags);
|
||||
|
||||
conn->tcpstateflags = UIP_LAST_ACK;
|
||||
conn->tcpstateflags = TCP_LAST_ACK;
|
||||
conn->unacked = 1;
|
||||
conn->nrtx = 0;
|
||||
nllvdbg("TCP state: UIP_LAST_ACK\n");
|
||||
nllvdbg("TCP state: TCP_LAST_ACK\n");
|
||||
|
||||
tcp_send(dev, conn, TCP_FIN | TCP_ACK, IPTCP_HDRLEN);
|
||||
return;
|
||||
|
@ -674,11 +674,11 @@ found:
|
|||
|
||||
/* If d_len > 0 we have TCP data in the packet, and we flag this
|
||||
* by setting the UIP_NEWDATA flag. If the application has stopped
|
||||
* the data flow using UIP_STOPPED, we must not accept any data
|
||||
* the data flow using TCP_STOPPED, we must not accept any data
|
||||
* packets from the remote host.
|
||||
*/
|
||||
|
||||
if (dev->d_len > 0 && (conn->tcpstateflags & UIP_STOPPED) == 0)
|
||||
if (dev->d_len > 0 && (conn->tcpstateflags & TCP_STOPPED) == 0)
|
||||
{
|
||||
flags |= UIP_NEWDATA;
|
||||
}
|
||||
|
@ -736,21 +736,21 @@ found:
|
|||
|
||||
goto drop;
|
||||
|
||||
case UIP_LAST_ACK:
|
||||
case TCP_LAST_ACK:
|
||||
/* We can close this connection if the peer has acknowledged our
|
||||
* FIN. This is indicated by the UIP_ACKDATA flag.
|
||||
*/
|
||||
|
||||
if ((flags & UIP_ACKDATA) != 0)
|
||||
{
|
||||
conn->tcpstateflags = UIP_CLOSED;
|
||||
nllvdbg("UIP_LAST_ACK TCP state: UIP_CLOSED\n");
|
||||
conn->tcpstateflags = TCP_CLOSED;
|
||||
nllvdbg("TCP_LAST_ACK TCP state: TCP_CLOSED\n");
|
||||
|
||||
(void)tcp_callback(dev, conn, UIP_CLOSE);
|
||||
}
|
||||
break;
|
||||
|
||||
case UIP_FIN_WAIT_1:
|
||||
case TCP_FIN_WAIT_1:
|
||||
/* The application has closed the connection, but the remote host
|
||||
* hasn't closed its end yet. Thus we stay in the FIN_WAIT_1 state
|
||||
* until we receive a FIN from the remote.
|
||||
|
@ -765,15 +765,15 @@ found:
|
|||
{
|
||||
if ((flags & UIP_ACKDATA) != 0)
|
||||
{
|
||||
conn->tcpstateflags = UIP_TIME_WAIT;
|
||||
conn->tcpstateflags = TCP_TIME_WAIT;
|
||||
conn->timer = 0;
|
||||
conn->unacked = 0;
|
||||
nllvdbg("TCP state: UIP_TIME_WAIT\n");
|
||||
nllvdbg("TCP state: TCP_TIME_WAIT\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
conn->tcpstateflags = UIP_CLOSING;
|
||||
nllvdbg("TCP state: UIP_CLOSING\n");
|
||||
conn->tcpstateflags = TCP_CLOSING;
|
||||
nllvdbg("TCP state: TCP_CLOSING\n");
|
||||
}
|
||||
|
||||
net_incr32(conn->rcvseq, 1);
|
||||
|
@ -783,9 +783,9 @@ found:
|
|||
}
|
||||
else if ((flags & UIP_ACKDATA) != 0)
|
||||
{
|
||||
conn->tcpstateflags = UIP_FIN_WAIT_2;
|
||||
conn->tcpstateflags = TCP_FIN_WAIT_2;
|
||||
conn->unacked = 0;
|
||||
nllvdbg("TCP state: UIP_FIN_WAIT_2\n");
|
||||
nllvdbg("TCP state: TCP_FIN_WAIT_2\n");
|
||||
goto drop;
|
||||
}
|
||||
|
||||
|
@ -797,7 +797,7 @@ found:
|
|||
|
||||
goto drop;
|
||||
|
||||
case UIP_FIN_WAIT_2:
|
||||
case TCP_FIN_WAIT_2:
|
||||
if (dev->d_len > 0)
|
||||
{
|
||||
net_incr32(conn->rcvseq, dev->d_len);
|
||||
|
@ -805,9 +805,9 @@ found:
|
|||
|
||||
if ((pbuf->flags & TCP_FIN) != 0)
|
||||
{
|
||||
conn->tcpstateflags = UIP_TIME_WAIT;
|
||||
conn->tcpstateflags = TCP_TIME_WAIT;
|
||||
conn->timer = 0;
|
||||
nllvdbg("TCP state: UIP_TIME_WAIT\n");
|
||||
nllvdbg("TCP state: TCP_TIME_WAIT\n");
|
||||
|
||||
net_incr32(conn->rcvseq, 1);
|
||||
(void)tcp_callback(dev, conn, UIP_CLOSE);
|
||||
|
@ -823,16 +823,16 @@ found:
|
|||
|
||||
goto drop;
|
||||
|
||||
case UIP_TIME_WAIT:
|
||||
case TCP_TIME_WAIT:
|
||||
tcp_send(dev, conn, TCP_ACK, IPTCP_HDRLEN);
|
||||
return;
|
||||
|
||||
case UIP_CLOSING:
|
||||
case TCP_CLOSING:
|
||||
if ((flags & UIP_ACKDATA) != 0)
|
||||
{
|
||||
conn->tcpstateflags = UIP_TIME_WAIT;
|
||||
conn->tcpstateflags = TCP_TIME_WAIT;
|
||||
conn->timer = 0;
|
||||
nllvdbg("TCP state: UIP_TIME_WAIT\n");
|
||||
nllvdbg("TCP state: TCP_TIME_WAIT\n");
|
||||
}
|
||||
|
||||
default:
|
||||
|
|
|
@ -99,7 +99,7 @@ void tcp_poll(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn)
|
|||
|
||||
/* Verify that the connection is established */
|
||||
|
||||
if ((conn->tcpstateflags & UIP_TS_MASK) == UIP_ESTABLISHED)
|
||||
if ((conn->tcpstateflags & TCP_STATE_MASK) == TCP_ESTABLISHED)
|
||||
{
|
||||
/* Set up for the callback */
|
||||
|
||||
|
|
|
@ -190,9 +190,9 @@ static void tcp_sendcommon(FAR struct net_driver_s *dev,
|
|||
net_ipaddr_hdrcopy(pbuf->srcipaddr, &dev->d_ipaddr);
|
||||
net_ipaddr_hdrcopy(pbuf->destipaddr, &conn->ripaddr);
|
||||
|
||||
if (conn->tcpstateflags & UIP_STOPPED)
|
||||
if (conn->tcpstateflags & TCP_STOPPED)
|
||||
{
|
||||
/* If the connection has issued UIP_STOPPED, we advertise a zero
|
||||
/* If the connection has issued TCP_STOPPED, we advertise a zero
|
||||
* window so that the remote host will stop sending data.
|
||||
*/
|
||||
|
||||
|
|
|
@ -429,7 +429,7 @@ static uint16_t psock_send_interrupt(FAR struct net_driver_s *dev,
|
|||
* retransmitted, and un-ACKed, if expired is not zero, the
|
||||
* connection will be closed.
|
||||
*
|
||||
* field expired can only be updated at UIP_ESTABLISHED state
|
||||
* field expired can only be updated at TCP_ESTABLISHED state
|
||||
*/
|
||||
|
||||
conn->expired++;
|
||||
|
@ -486,7 +486,7 @@ static uint16_t psock_send_interrupt(FAR struct net_driver_s *dev,
|
|||
* retransmitted, and un-ACKed, if expired is not zero, the
|
||||
* connection will be closed.
|
||||
*
|
||||
* field expired can only be updated at UIP_ESTABLISHED state
|
||||
* field expired can only be updated at TCP_ESTABLISHED state
|
||||
*/
|
||||
|
||||
conn->expired++;
|
||||
|
@ -526,7 +526,7 @@ static uint16_t psock_send_interrupt(FAR struct net_driver_s *dev,
|
|||
* next polling cycle.
|
||||
*/
|
||||
|
||||
if ((conn->tcpstateflags & UIP_ESTABLISHED) &&
|
||||
if ((conn->tcpstateflags & TCP_ESTABLISHED) &&
|
||||
(flags & (UIP_POLL | UIP_REXMIT)) &&
|
||||
!(sq_empty(&conn->write_q)))
|
||||
{
|
||||
|
|
|
@ -118,24 +118,24 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
|
|||
* out.
|
||||
*/
|
||||
|
||||
if (conn->tcpstateflags == UIP_TIME_WAIT ||
|
||||
conn->tcpstateflags == UIP_FIN_WAIT_2)
|
||||
if (conn->tcpstateflags == TCP_TIME_WAIT ||
|
||||
conn->tcpstateflags == TCP_FIN_WAIT_2)
|
||||
{
|
||||
/* Increment the connection timer */
|
||||
|
||||
conn->timer += hsec;
|
||||
if (conn->timer >= UIP_TIME_WAIT_TIMEOUT)
|
||||
if (conn->timer >= TCP_TIME_WAIT_TIMEOUT)
|
||||
{
|
||||
conn->tcpstateflags = UIP_CLOSED;
|
||||
conn->tcpstateflags = TCP_CLOSED;
|
||||
|
||||
/* Notify upper layers about the timeout */
|
||||
|
||||
result = tcp_callback(dev, conn, UIP_TIMEDOUT);
|
||||
|
||||
nllvdbg("TCP state: UIP_CLOSED\n");
|
||||
nllvdbg("TCP state: TCP_CLOSED\n");
|
||||
}
|
||||
}
|
||||
else if (conn->tcpstateflags != UIP_CLOSED)
|
||||
else if (conn->tcpstateflags != TCP_CLOSED)
|
||||
{
|
||||
/* If the connection has outstanding data, we increase the connection's
|
||||
* timer and see if it has reached the RTO value in which case we
|
||||
|
@ -166,13 +166,13 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
|
|||
#else
|
||||
conn->nrtx == UIP_MAXRTX ||
|
||||
#endif
|
||||
((conn->tcpstateflags == UIP_SYN_SENT ||
|
||||
conn->tcpstateflags == UIP_SYN_RCVD) &&
|
||||
((conn->tcpstateflags == TCP_SYN_SENT ||
|
||||
conn->tcpstateflags == TCP_SYN_RCVD) &&
|
||||
conn->nrtx == UIP_MAXSYNRTX)
|
||||
)
|
||||
{
|
||||
conn->tcpstateflags = UIP_CLOSED;
|
||||
nllvdbg("TCP state: UIP_CLOSED\n");
|
||||
conn->tcpstateflags = TCP_CLOSED;
|
||||
nllvdbg("TCP state: TCP_CLOSED\n");
|
||||
|
||||
/* We call tcp_callback() with UIP_TIMEDOUT to
|
||||
* inform the application that the connection has
|
||||
|
@ -203,9 +203,9 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
|
|||
#ifdef CONFIG_NET_STATISTICS
|
||||
g_netstats.tcp.rexmit++;
|
||||
#endif
|
||||
switch(conn->tcpstateflags & UIP_TS_MASK)
|
||||
switch (conn->tcpstateflags & TCP_STATE_MASK)
|
||||
{
|
||||
case UIP_SYN_RCVD:
|
||||
case TCP_SYN_RCVD:
|
||||
/* In the SYN_RCVD state, we should retransmit our
|
||||
* SYNACK.
|
||||
*/
|
||||
|
@ -213,13 +213,13 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
|
|||
tcp_ack(dev, conn, TCP_ACK | TCP_SYN);
|
||||
goto done;
|
||||
|
||||
case UIP_SYN_SENT:
|
||||
case TCP_SYN_SENT:
|
||||
/* In the SYN_SENT state, we retransmit out SYN. */
|
||||
|
||||
tcp_ack(dev, conn, TCP_SYN);
|
||||
goto done;
|
||||
|
||||
case UIP_ESTABLISHED:
|
||||
case TCP_ESTABLISHED:
|
||||
/* In the ESTABLISHED state, we call upon the application
|
||||
* to do the actual retransmit after which we jump into
|
||||
* the code for sending out the packet.
|
||||
|
@ -229,9 +229,9 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
|
|||
tcp_rexmit(dev, conn, result);
|
||||
goto done;
|
||||
|
||||
case UIP_FIN_WAIT_1:
|
||||
case UIP_CLOSING:
|
||||
case UIP_LAST_ACK:
|
||||
case TCP_FIN_WAIT_1:
|
||||
case TCP_CLOSING:
|
||||
case TCP_LAST_ACK:
|
||||
/* In all these states we should retransmit a FINACK. */
|
||||
|
||||
tcp_send(dev, conn, TCP_FIN | TCP_ACK, IPTCP_HDRLEN);
|
||||
|
@ -242,7 +242,7 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn,
|
|||
|
||||
/* The connection does not have outstanding data */
|
||||
|
||||
else if ((conn->tcpstateflags & UIP_TS_MASK) == UIP_ESTABLISHED)
|
||||
else if ((conn->tcpstateflags & TCP_STATE_MASK) == TCP_ESTABLISHED)
|
||||
{
|
||||
/* If there was no need for a retransmission, we poll the
|
||||
* application for new data.
|
||||
|
|
Loading…
Reference in a new issue