diff options
Diffstat (limited to 'nuttx/net/uip')
-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 |
5 files changed, 80 insertions, 45 deletions
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 */ |