diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-11-15 22:38:32 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-11-15 22:38:32 +0000 |
commit | d6100fb0fad57df531e0774793d188e899943852 (patch) | |
tree | 0f7204a066a470ffde437f8c1a1dfcfd78575736 /nuttx/net | |
parent | c7bd005fd19b6ab3d548613495f6f5a0a955387f (diff) | |
download | px4-nuttx-d6100fb0fad57df531e0774793d188e899943852.tar.gz px4-nuttx-d6100fb0fad57df531e0774793d188e899943852.tar.bz2 px4-nuttx-d6100fb0fad57df531e0774793d188e899943852.zip |
Fix probably where packets dropped because there was no recv() in place were being ACKed
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@381 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/net')
-rw-r--r-- | nuttx/net/connect.c | 3 | ||||
-rw-r--r-- | nuttx/net/recvfrom.c | 6 | ||||
-rw-r--r-- | nuttx/net/send.c | 3 | ||||
-rw-r--r-- | nuttx/net/uip/uip-icmpinput.c | 4 | ||||
-rw-r--r-- | nuttx/net/uip/uip-tcpappsend.c | 75 | ||||
-rw-r--r-- | nuttx/net/uip/uip-tcpcallback.c | 42 | ||||
-rw-r--r-- | nuttx/net/uip/uip-tcpsend.c | 2 | ||||
-rw-r--r-- | nuttx/net/uip/uip-udpconn.c | 2 |
8 files changed, 89 insertions, 48 deletions
diff --git a/nuttx/net/connect.c b/nuttx/net/connect.c index 56aee612c..d4f40b30f 100644 --- a/nuttx/net/connect.c +++ b/nuttx/net/connect.c @@ -259,7 +259,8 @@ static uint8 tcp_connect_interrupt(struct uip_driver_s *dev, sem_post(&pstate->tc_sem); } - return 0; + + return flags; } /**************************************************************************** diff --git a/nuttx/net/recvfrom.c b/nuttx/net/recvfrom.c index 579013913..b0c9a223f 100644 --- a/nuttx/net/recvfrom.c +++ b/nuttx/net/recvfrom.c @@ -123,6 +123,10 @@ static void recvfrom_newdata(struct uip_driver_s *dev, struct recvfrom_s *pstate pstate->rf_recvlen += recvlen; pstate->rf_buffer += recvlen; pstate->rf_buflen -= recvlen; + + /* Indicate no data in the buffer */ + + dev->d_len = 0; } /**************************************************************************** @@ -313,7 +317,7 @@ static uint8 recvfrom_tcpinterrupt(struct uip_driver_s *dev, } #endif /* CONFIG_NET_SOCKOPTS && !CONFIG_DISABLE_CLOCK */ } - return 0; + return flags; } /**************************************************************************** diff --git a/nuttx/net/send.c b/nuttx/net/send.c index 98dcec352..c758b8eba 100644 --- a/nuttx/net/send.c +++ b/nuttx/net/send.c @@ -180,7 +180,8 @@ static uint8 send_interrupt(struct uip_driver_s *dev, struct uip_conn *conn, uin sem_post(&pstate->snd_sem); } - return 0; + + return flags; } /**************************************************************************** diff --git a/nuttx/net/uip/uip-icmpinput.c b/nuttx/net/uip/uip-icmpinput.c index b6eace772..8dd276330 100644 --- a/nuttx/net/uip/uip-icmpinput.c +++ b/nuttx/net/uip/uip-icmpinput.c @@ -185,7 +185,7 @@ typeerr: ICMPBUF->reserved1 = ICMPBUF->reserved2 = ICMPBUF->reserved3 = 0; uiphdr_ipaddr_copy(ICMPBUF->destipaddr, ICMPBUF->srcipaddr); - uiphdr_ipaddr_copy(ICMPBUF->srcipaddr, dev->d_ipaddr); + uiphdr_ipaddr_copy(ICMPBUF->srcipaddr, &dev->d_ipaddr); ICMPBUF->options[0] = ICMP6_OPTION_TARGET_LINK_ADDRESS; ICMPBUF->options[1] = 1; /* Options length, 1 = 8 bytes. */ memcpy(&(ICMPBUF->options[2]), &dev->d_mac, IFHWADDRLEN); @@ -207,7 +207,7 @@ typeerr: ICMPBUF->type = ICMP6_ECHO_REPLY; uiphdr_ipaddr_copy(ICMPBUF->destipaddr, ICMPBUF->srcipaddr); - uiphdr_ipaddr_copy(ICMPBUF->srcipaddr, dev->d_ipaddr); + uiphdr_ipaddr_copy(ICMPBUF->srcipaddr, &dev->d_ipaddr); ICMPBUF->icmpchksum = 0; ICMPBUF->icmpchksum = ~uip_icmp6chksum(dev); } diff --git a/nuttx/net/uip/uip-tcpappsend.c b/nuttx/net/uip/uip-tcpappsend.c index 63bad3fbd..fa19c23f0 100644 --- a/nuttx/net/uip/uip-tcpappsend.c +++ b/nuttx/net/uip/uip-tcpappsend.c @@ -100,6 +100,8 @@ void uip_tcpappsend(struct uip_driver_s *dev, struct uip_conn *conn, uint8 resul vdbg("result: %02x\n", result); + /* Check for connection aborted */ + if (result & UIP_ABORT) { dev->d_sndlen = 0; @@ -109,6 +111,8 @@ void uip_tcpappsend(struct uip_driver_s *dev, struct uip_conn *conn, uint8 resul uip_tcpsend(dev, conn, TCP_RST | TCP_ACK, UIP_IPTCPH_LEN); } + /* Check for connection closed */ + else if (result & UIP_CLOSE) { conn->tcpstateflags = UIP_FIN_WAIT_1; @@ -120,51 +124,56 @@ void uip_tcpappsend(struct uip_driver_s *dev, struct uip_conn *conn, uint8 resul uip_tcpsend(dev, conn, TCP_FIN | TCP_ACK, UIP_IPTCPH_LEN); } - /* If d_sndlen > 0, the application has data to be sent. */ + /* None of the above */ - else if (dev->d_sndlen > 0) + else { - /* If the connection has acknowledged data, the contents of - * the ->len variable should be discarded. - */ - - if (result & UIP_ACKDATA) - { - conn->len = 0; - } + /* If d_sndlen > 0, the application has data to be sent. */ - /* If the ->len variable is non-zero the connection has - * already data in transit and cannot send anymore right - * now. - */ - - if (conn->len == 0) + if (dev->d_sndlen > 0) { - /* The application cannot send more than what is - * allowed by the mss (the minumum of the MSS and the - * available window). + /* If the connection has acknowledged data, the contents of + * the ->len variable should be discarded. */ - if (dev->d_sndlen > conn->mss) + if (result & UIP_ACKDATA) { - dev->d_sndlen = conn->mss; + conn->len = 0; } - /* Remember how much data we send out now so that we - * know when everything has been acknowledged. + /* If the ->len variable is non-zero the connection has + * already data in transit and cannot send anymore right + * now. */ - conn->len = dev->d_sndlen; - } - else - { - /* If the application already had unacknowledged data, - * we make sure that the application does not send - * (i.e., retransmit) out more than it previously sent - * out. - */ + if (conn->len == 0) + { + /* The application cannot send more than what is + * allowed by the mss (the minumum of the MSS and the + * available window). + */ + + if (dev->d_sndlen > conn->mss) + { + dev->d_sndlen = conn->mss; + } + + /* Remember how much data we send out now so that we + * know when everything has been acknowledged. + */ - dev->d_sndlen = conn->len; + conn->len = dev->d_sndlen; + } + else + { + /* If the application already had unacknowledged data, + * we make sure that the application does not send + * (i.e., retransmit) out more than it previously sent + * out. + */ + + dev->d_sndlen = conn->len; + } } /* Then handle the rest of the operation just as for the rexmit case */ diff --git a/nuttx/net/uip/uip-tcpcallback.c b/nuttx/net/uip/uip-tcpcallback.c index 72fae7736..761283bb0 100644 --- a/nuttx/net/uip/uip-tcpcallback.c +++ b/nuttx/net/uip/uip-tcpcallback.c @@ -75,11 +75,13 @@ uint8 uip_tcpcallback(struct uip_driver_s *dev, struct uip_conn *conn, uint8 flags) { - /* Preserve the UIP_ACKDATA & UIP_NEWDATA in the response. These are - * needed by uIP to handle ACKing and buffer state. + /* Preserve the UIP_ACKDATA, UIP_CLOSE, and UIP_ABORT in the response. + * These is needed by uIP to handle responses and buffer state. The + * UIP_NEWDATA indication will trigger the ACK response, but must be + * explicitly set in the callback. */ - uint8 ret = flags & (UIP_ACKDATA|UIP_NEWDATA); + uint8 ret = flags; vdbg("flags: %02x\n", flags); @@ -87,13 +89,37 @@ uint8 uip_tcpcallback(struct uip_driver_s *dev, struct uip_conn *conn, uint8 fla if (conn->data_event) { - /* Perform the callback. Callback function may return on of: - * UIP_CLOSE - Gracefully close the current connection - * UIP_ABORT - Abort (reset) the current connection on an error that - * prevents UIP_CLOSE from working. + /* Perform the callback. Callback function normally returns the input flags, + * however, the implemenation may set one of the following: + * + * UIP_CLOSE - Gracefully close the current connection + * UIP_ABORT - Abort (reset) the current connection on an error that + * prevents UIP_CLOSE from working. + * + * Or clear the following: + * + * UIP_NEWDATA - May be cleared to suppress returning the ACK response. + * (dev->d_len should also be set to zero in this case). */ - ret |= conn->data_event(dev, conn, flags); + ret = conn->data_event(dev, conn, flags); + } + else if ((flags & UIP_CONN_EVENTS) == 0) + { + /* There is no handler to receive new data in place and this is not a + * connection event (which may also include new data that must be ACKed). + * In this case, clear the UIP_NEWDATA bit so that no ACK will be sent + * and drop the packet. + */ + + dbg("No listener on connection\n"); + +#ifdef CONFIG_NET_STATISTICS + uip_stat.tcp.drop++; +#endif + + ret &= ~UIP_NEWDATA; + dev->d_len = 0; } /* Check if there is a connection-related event and a connection diff --git a/nuttx/net/uip/uip-tcpsend.c b/nuttx/net/uip/uip-tcpsend.c index 9c367159d..31766d202 100644 --- a/nuttx/net/uip/uip-tcpsend.c +++ b/nuttx/net/uip/uip-tcpsend.c @@ -316,7 +316,7 @@ void uip_tcpreset(struct uip_driver_s *dev) /* Swap IP addresses. */ uiphdr_ipaddr_copy(BUF->destipaddr, BUF->srcipaddr); - uiphdr_ipaddr_copy(BUF->srcipaddr, dev->d_ipaddr); + uiphdr_ipaddr_copy(BUF->srcipaddr, &dev->d_ipaddr); /* And send out the RST packet */ diff --git a/nuttx/net/uip/uip-udpconn.c b/nuttx/net/uip/uip-udpconn.c index f5779453a..87ca3f8a6 100644 --- a/nuttx/net/uip/uip-udpconn.c +++ b/nuttx/net/uip/uip-udpconn.c @@ -249,7 +249,7 @@ struct uip_udp_conn *uip_udpactive(struct uip_udpip_hdr *buf) (conn->rport == 0 || buf->srcport == conn->rport) && (uip_ipaddr_cmp(conn->ripaddr, all_zeroes_addr) || uip_ipaddr_cmp(conn->ripaddr, all_ones_addr) || - uiphdr_ipaddr_cmp(buf->srcipaddr, conn->ripaddr))) + uiphdr_ipaddr_cmp(buf->srcipaddr, &conn->ripaddr))) { /* Matching connection found.. return a reference to it */ |