summaryrefslogtreecommitdiff
path: root/nuttx/net/uip/uip_tcpinput.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-12-19 22:05:12 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2009-12-19 22:05:12 +0000
commit9f6ea5af87d527ee2e8b4a125881bcf0741aabad (patch)
treecffda222cfdd6e55ebd5ad9372ea4ef81f5f0e9d /nuttx/net/uip/uip_tcpinput.c
parent6082f71dcfd8f55b731a32ef27abf441ddee0b3c (diff)
downloadpx4-nuttx-9f6ea5af87d527ee2e8b4a125881bcf0741aabad.tar.gz
px4-nuttx-9f6ea5af87d527ee2e8b4a125881bcf0741aabad.tar.bz2
px4-nuttx-9f6ea5af87d527ee2e8b4a125881bcf0741aabad.zip
Fix an error in the handling of TCP/IP sequence numbers
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2392 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/net/uip/uip_tcpinput.c')
-rw-r--r--nuttx/net/uip/uip_tcpinput.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/nuttx/net/uip/uip_tcpinput.c b/nuttx/net/uip/uip_tcpinput.c
index e3a8196f6..f882ed1b9 100644
--- a/nuttx/net/uip/uip_tcpinput.c
+++ b/nuttx/net/uip/uip_tcpinput.c
@@ -328,16 +328,28 @@ found:
if ((pbuf->flags & TCP_ACK) && uip_outstanding(conn))
{
- /* Temporary variables. */
+ uint32_t seqno;
+ uint32_t ackno;
- uint8_t acc32[4];
- uip_add32(conn->snd_nxt, conn->len, acc32);
+ /* The next sequence number is equal to the current sequence
+ * number (snd_nxt) plus the size of the oustanding data (len).
+ */
+
+ seqno = uip_tcpaddsequence(conn->snd_nxt, conn->len);
+
+ /* Check if all of the outstanding bytes have been acknowledged. For
+ * a "generic" send operation, this should always be true. However,
+ * the send() API sends data ahead when it can without waiting for
+ * the ACK. In this case, the 'ackno' could be less than then the
+ * new sequence number.
+ */
- if (memcmp(pbuf->ackno, acc32, 4) == 0)
+ ackno = uip_tcpgetsequence(pbuf->ackno);
+ if (ackno <= seqno)
{
/* Update sequence number. */
- memcpy(conn->snd_nxt, acc32, 4);
+ uip_tcpsetsequence(conn->snd_nxt, seqno);
/* Do RTT estimation, unless we have done retransmissions. */