* modification, are permitted provided that the following conditions\r
* are met:\r
* 1. Redistributions of source code must retain the above copyright\r
- * notice, this list of conditions and the following disclaimer.\r
+ * notice, this list of conditions and the following disclaimer.\r
* 2. Redistributions in binary form must reproduce the above copyright\r
- * notice, this list of conditions and the following disclaimer in the\r
- * documentation and/or other materials provided with the distribution.\r
+ * notice, this list of conditions and the following disclaimer in the\r
+ * documentation and/or other materials provided with the distribution.\r
* 3. The name of the author may not be used to endorse or promote\r
- * products derived from this software without specific prior\r
- * written permission.\r
+ * products derived from this software without specific prior\r
+ * written permission.\r
*\r
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS\r
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\r
uip_sappdata = uip_appdata = &uip_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN];\r
\r
/* Check if we were invoked because of a poll request for a\r
- particular connection. */\r
+ particular connection. */\r
if( flag == UIP_POLL_REQUEST )\r
{\r
if( (uip_connr->tcpstateflags & UIP_TS_MASK) == UIP_ESTABLISHED && !uip_outstanding(uip_connr) )\r
{\r
case UIP_SYN_RCVD:\r
/* In the SYN_RCVD state, we should retransmit our\r
- SYNACK. */\r
+ SYNACK. */\r
goto tcp_send_synack;\r
\r
#if UIP_ACTIVE_OPEN\r
#endif /* UIP_CONF_IPV6 */\r
\r
/* Check the size of the packet. If the size reported to us in\r
- uip_len is smaller the size reported in the IP header, we assume\r
- that the packet has been corrupted in transit. If the size of\r
- uip_len is larger than the size reported in the IP packet header,\r
- the packet has been padded and we set uip_len to the correct\r
- value.. */\r
+ uip_len is smaller the size reported in the IP header, we assume\r
+ that the packet has been corrupted in transit. If the size of\r
+ uip_len is larger than the size reported in the IP packet header,\r
+ the packet has been padded and we set uip_len to the correct\r
+ value.. */\r
if( (BUF->len[ 0 ] << 8) + BUF->len[ 1 ] <= uip_len )\r
{\r
uip_len = ( BUF->len[ 0 ] << 8 ) + BUF->len[ 1 ];\r
#if UIP_CONF_IPV6\r
/* The length reported in the IPv6 header is the\r
- length of the payload that follows the\r
- header. However, uIP uses the uip_len variable\r
- for holding the size of the entire packet,\r
- including the IP header. For IPv4 this is not a\r
- problem as the length field in the IPv4 header\r
- contains the length of the entire packet. But\r
- for IPv6 we need to add the size of the IPv6\r
- header (40 bytes). */\r
+ length of the payload that follows the\r
+ header. However, uIP uses the uip_len variable\r
+ for holding the size of the entire packet,\r
+ including the IP header. For IPv4 this is not a\r
+ problem as the length field in the IPv4 header\r
+ contains the length of the entire packet. But\r
+ for IPv6 we need to add the size of the IPv6\r
+ header (40 bytes). */\r
uip_len += 40;\r
#endif /* UIP_CONF_IPV6 */\r
}\r
}\r
\r
/* If we didn't find and active connection that expected the packet,\r
- either this packet is an old duplicate, or this is a SYN packet\r
- destined for a connection in LISTEN. If the SYN flag isn't set,\r
- it is an old packet and we send a RST. */\r
+ either this packet is an old duplicate, or this is a SYN packet\r
+ destined for a connection in LISTEN. If the SYN flag isn't set,\r
+ it is an old packet and we send a RST. */\r
if( (BUF->flags & TCP_CTL) != TCP_SYN )\r
{\r
goto reset;\r
BUF->ackno[ 0 ] = c;\r
\r
/* We also have to increase the sequence number we are\r
- acknowledging. If the least significant byte overflowed, we need\r
- to propagate the carry to the other bytes as well. */\r
+ acknowledging. If the least significant byte overflowed, we need\r
+ to propagate the carry to the other bytes as well. */\r
if( ++BUF->ackno[ 3 ] == 0 )\r
{\r
if( ++BUF->ackno[ 2 ] == 0 )\r
goto tcp_send_noconn;\r
\r
/* This label will be jumped to if we matched the incoming packet\r
- with a connection in LISTEN. In that case, we should create a new\r
- connection and send a SYNACK in return. */\r
+ with a connection in LISTEN. In that case, we should create a new\r
+ connection and send a SYNACK in return. */\r
found_listen:\r
/* First we check if there are any connections avaliable. Unused\r
- connections are kept in the same table as used connections, but\r
- unused ones have the tcpstate set to CLOSED. Also, connections in\r
- TIME_WAIT are kept track of and we'll use the oldest one if no\r
- CLOSED connections are found. Thanks to Eddie C. Dost for a very\r
- nice algorithm for the TIME_WAIT search. */\r
+ connections are kept in the same table as used connections, but\r
+ unused ones have the tcpstate set to CLOSED. Also, connections in\r
+ TIME_WAIT are kept track of and we'll use the oldest one if no\r
+ CLOSED connections are found. Thanks to Eddie C. Dost for a very\r
+ nice algorithm for the TIME_WAIT search. */\r
uip_connr = 0;\r
for( c = 0; c < UIP_CONNS; ++c )\r
{\r
#endif /* UIP_ACTIVE_OPEN */\r
\r
/* We send out the TCP Maximum Segment Size option with our\r
- SYNACK. */\r
+ SYNACK. */\r
BUF->optdata[ 0 ] = TCP_OPT_MSS;\r
BUF->optdata[ 1 ] = TCP_OPT_MSS_LEN;\r
BUF->optdata[ 2 ] = ( UIP_TCP_MSS ) / 256;\r
uip_flags = 0;\r
\r
/* We do a very naive form of TCP reset processing; we just accept\r
- any RST and kill our connection. We should in fact check if the\r
- sequence number of this reset is wihtin our advertised window\r
- before we accept the reset. */\r
+ any RST and kill our connection. We should in fact check if the\r
+ sequence number of this reset is wihtin our advertised window\r
+ before we accept the reset. */\r
if( BUF->flags & TCP_RST )\r
{\r
uip_connr->tcpstateflags = UIP_CLOSED;\r
}\r
\r
/* Calculate the length of the data, if the application has sent\r
- any data to us. */\r
+ any data to us. */\r
c = ( BUF->tcpoffset >> 4 ) << 2;\r
\r
/* uip_len will contain the length of the actual TCP data. This is\r
- calculated by subtracing the length of the TCP header (in\r
- c) and the length of the IP header (20 bytes). */\r
+ calculated by subtracing the length of the TCP header (in\r
+ c) and the length of the IP header (20 bytes). */\r
uip_len = uip_len - c - UIP_IPH_LEN;\r
\r
/* First, check if the sequence number of the incoming packet is\r
- what we're expecting next. If not, we send out an ACK with the\r
- correct numbers in. */\r
+ what we're expecting next. If not, we send out an ACK with the\r
+ correct numbers in. */\r
if( !(((uip_connr->tcpstateflags & UIP_TS_MASK) == UIP_SYN_SENT) && ((BUF->flags & TCP_CTL) == (TCP_SYN | TCP_ACK))) )\r
{\r
if\r
}\r
\r
/* Next, check if the incoming segment acknowledges any outstanding\r
- data. If so, we update the sequence number, reset the length of\r
- the outstanding data, calculate RTT estimations, and reset the\r
- retransmission timer. */\r
+ data. If so, we update the sequence number, reset the length of\r
+ the outstanding data, calculate RTT estimations, and reset the\r
+ retransmission timer. */\r
if( (BUF->flags & TCP_ACK) && uip_outstanding(uip_connr) )\r
{\r
uip_add32( uip_connr->snd_nxt, uip_connr->len );\r
ESTABLISHED to LAST_ACK). */\r
case UIP_SYN_RCVD:\r
/* In SYN_RCVD we have sent out a SYNACK in response to a SYN, and\r
- we are waiting for an ACK that acknowledges the data we sent\r
- out the last time. Therefore, we want to have the UIP_ACKDATA\r
- flag set. If so, we enter the ESTABLISHED state. */\r
+ we are waiting for an ACK that acknowledges the data we sent\r
+ out the last time. Therefore, we want to have the UIP_ACKDATA\r
+ flag set. If so, we enter the ESTABLISHED state. */\r
if( uip_flags & UIP_ACKDATA )\r
{\r
uip_connr->tcpstateflags = UIP_ESTABLISHED;\r
if( uip_connr->len == 0 )\r
{\r
/* The application cannot send more than what is allowed by\r
- the mss (the minumum of the MSS and the available\r
- window). */\r
+ the mss (the minumum of the MSS and the available\r
+ window). */\r
if( uip_slen > uip_connr->mss )\r
{\r
uip_slen = uip_connr->mss;\r
}\r
\r
/* Remember how much data we send out now so that we know\r
- when everything has been acknowledged. */\r
+ when everything has been acknowledged. */\r
uip_connr->len = uip_slen;\r
}\r
else\r
{\r
/* If the application already had unacknowledged data, we\r
- make sure that the application does not send (i.e.,\r
- retransmit) out more than it previously sent out. */\r
+ make sure that the application does not send (i.e.,\r
+ retransmit) out more than it previously sent out. */\r
uip_slen = uip_connr->len;\r
}\r
}\r
uip_appdata = uip_sappdata;\r
\r
/* If the application has data to be sent, or if the incoming\r
- packet had new data in it, we must send out a packet. */\r
+ packet had new data in it, we must send out a packet. */\r
if( uip_slen > 0 && uip_connr->len > 0 )\r
{\r
/* Add the length of the IP and TCP headers. */\r
goto drop;\r
\r
/* We jump here when we are ready to send the packet, and just want\r
- to set the appropriate TCP sequence numbers in the TCP header. */\r
+ to set the appropriate TCP sequence numbers in the TCP header. */\r
tcp_send_ack:\r
BUF->flags = TCP_ACK;\r
\r
BUF->tcpoffset = ( UIP_TCPH_LEN / 4 ) << 4;\r
\r
/* We're done with the input processing. We are now ready to send a\r
- reply. Our job is to fill in all the fields of the TCP and IP\r
- headers before calculating the checksum and finally send the\r
- packet. */\r
+ reply. Our job is to fill in all the fields of the TCP and IP\r
+ headers before calculating the checksum and finally send the\r
+ packet. */\r
tcp_send:\r
BUF->ackno[ 0 ] = uip_connr->rcv_nxt[ 0 ];\r
BUF->ackno[ 1 ] = uip_connr->rcv_nxt[ 1 ];\r