mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-11-16 12:34:34 +00:00
Compare commits
8 Commits
STABLE-1_3
...
STABLE-1_3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd96db8c9f | ||
|
|
0b75917121 | ||
|
|
fa2dbc2b1b | ||
|
|
3a6165f0b9 | ||
|
|
62c27f7fce | ||
|
|
7feb116bae | ||
|
|
730a938912 | ||
|
|
3553efb75e |
@@ -115,6 +115,15 @@ HISTORY
|
||||
|
||||
|
||||
++ Bugfixes:
|
||||
2009-08-12 Kieran Mansley
|
||||
* tcp_in.c, tcp.c: Fix bug #27209: handle trimming of segments when
|
||||
out of window or out of order properly
|
||||
|
||||
2009-08-12 Kieran Mansley
|
||||
* tcp_in.c: Fix bug #27199: use snd_wl2 instead of snd_wl1
|
||||
|
||||
2009-07-28 Simon Goldschmidt
|
||||
* mem.h: Fixed bug #27105: "realloc() cannot replace mem_realloc()"s
|
||||
|
||||
2009-07-27 Kieran Mansley
|
||||
* api.h api_msg.h netdb.h sockets.h: add missing #include directives
|
||||
|
||||
@@ -42,6 +42,9 @@
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/api.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/** helper struct for gethostbyname_r to access the char* buffer */
|
||||
struct gethostbyname_r_helper {
|
||||
struct ip_addr *addrs;
|
||||
|
||||
@@ -41,6 +41,8 @@
|
||||
#include "lwip/inet_chksum.h"
|
||||
#include "lwip/inet.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/* These are some reference implementations of the checksum algorithm, with the
|
||||
* aim of being simple, correct and fully portable. Checksumming is the
|
||||
* first thing you would want to optimize for your platform. If you create
|
||||
|
||||
@@ -56,6 +56,8 @@
|
||||
#include "lwip/stats.h"
|
||||
#include "arch/perf.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/**
|
||||
* The interface that provided the packet for the current callback
|
||||
* invocation.
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
#include "lwip/memp.h"
|
||||
#include "lwip/snmp.h"
|
||||
#include "lwip/tcp.h"
|
||||
#include "lwip/debug.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -423,6 +424,9 @@ tcp_recved(struct tcp_pcb *pcb, u16_t len)
|
||||
{
|
||||
int wnd_inflation;
|
||||
|
||||
LWIP_ASSERT("tcp_recved: len would wrap rcv_wnd\n",
|
||||
len <= 0xffff - pcb->rcv_wnd );
|
||||
|
||||
pcb->rcv_wnd += len;
|
||||
if (pcb->rcv_wnd > TCP_WND)
|
||||
pcb->rcv_wnd = TCP_WND;
|
||||
@@ -1399,6 +1403,7 @@ tcp_debug_print_flags(u8_t flags)
|
||||
if (flags & TCP_CWR) {
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("CWR "));
|
||||
}
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("\n"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -408,6 +408,7 @@ tcp_listen_input(struct tcp_pcb_listen *pcb)
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("TCP connection request %"U16_F" -> %"U16_F".\n", tcphdr->src, tcphdr->dest));
|
||||
#if TCP_LISTEN_BACKLOG
|
||||
if (pcb->accepts_pending >= pcb->backlog) {
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("tcp_listen_input: listen backlog exceeded for port %"U16_F"\n", tcphdr->dest));
|
||||
return ERR_ABRT;
|
||||
}
|
||||
#endif /* TCP_LISTEN_BACKLOG */
|
||||
@@ -737,7 +738,7 @@ tcp_receive(struct tcp_pcb *pcb)
|
||||
u8_t accepted_inseq = 0;
|
||||
|
||||
if (flags & TCP_ACK) {
|
||||
right_wnd_edge = pcb->snd_wnd + pcb->snd_wl1;
|
||||
right_wnd_edge = pcb->snd_wnd + pcb->snd_wl2;
|
||||
|
||||
/* Update window. */
|
||||
if (TCP_SEQ_LT(pcb->snd_wl1, seqno) ||
|
||||
@@ -764,7 +765,7 @@ tcp_receive(struct tcp_pcb *pcb)
|
||||
if (pcb->lastack == ackno) {
|
||||
pcb->acked = 0;
|
||||
|
||||
if (pcb->snd_wl1 + pcb->snd_wnd == right_wnd_edge){
|
||||
if (pcb->snd_wl2 + pcb->snd_wnd == right_wnd_edge){
|
||||
++pcb->dupacks;
|
||||
if (pcb->dupacks >= 3 && pcb->unacked != NULL) {
|
||||
if (!(pcb->flags & TF_INFR)) {
|
||||
@@ -801,7 +802,7 @@ tcp_receive(struct tcp_pcb *pcb)
|
||||
}
|
||||
} else {
|
||||
LWIP_DEBUGF(TCP_FR_DEBUG, ("tcp_receive: dupack averted %"U32_F" %"U32_F"\n",
|
||||
pcb->snd_wl1 + pcb->snd_wnd, right_wnd_edge));
|
||||
pcb->snd_wl2 + pcb->snd_wnd, right_wnd_edge));
|
||||
}
|
||||
} else if (TCP_SEQ_BETWEEN(ackno, pcb->lastack+1, pcb->snd_nxt)){
|
||||
/* We come here when the ACK acknowledges new data. */
|
||||
@@ -1054,35 +1055,73 @@ tcp_receive(struct tcp_pcb *pcb)
|
||||
/* The incoming segment is the next in sequence. We check if
|
||||
we have to trim the end of the segment and update rcv_nxt
|
||||
and pass the data to the application. */
|
||||
tcplen = TCP_TCPLEN(&inseg);
|
||||
|
||||
if (tcplen > pcb->rcv_wnd) {
|
||||
LWIP_DEBUGF(TCP_INPUT_DEBUG,
|
||||
("tcp_receive: other end overran receive window"
|
||||
"seqno %"U32_F" len %"U32_F" right edge %"U32_F"\n",
|
||||
seqno, tcplen, pcb->rcv_nxt + pcb->rcv_wnd));
|
||||
if (TCPH_FLAGS(inseg.tcphdr) & TCP_FIN) {
|
||||
/* Must remove the FIN from the header as we're trimming
|
||||
* that byte of sequence-space from the packet */
|
||||
TCPH_FLAGS_SET(inseg.tcphdr, TCPH_FLAGS(inseg.tcphdr) &~ TCP_FIN);
|
||||
}
|
||||
/* Adjust length of segment to fit in the window. */
|
||||
inseg.len = pcb->rcv_wnd;
|
||||
if (TCPH_FLAGS(inseg.tcphdr) & TCP_SYN) {
|
||||
inseg.len -= 1;
|
||||
}
|
||||
pbuf_realloc(inseg.p, inseg.len);
|
||||
tcplen = TCP_TCPLEN(&inseg);
|
||||
LWIP_ASSERT("tcp_receive: segment not trimmed correctly to rcv_wnd\n",
|
||||
(seqno + tcplen) == (pcb->rcv_nxt + pcb->rcv_wnd));
|
||||
}
|
||||
#if TCP_QUEUE_OOSEQ
|
||||
if (pcb->ooseq != NULL &&
|
||||
TCP_SEQ_LEQ(pcb->ooseq->tcphdr->seqno, seqno + inseg.len)) {
|
||||
if (pcb->ooseq->len > 0) {
|
||||
/* We have to trim the second edge of the incoming
|
||||
segment. */
|
||||
inseg.len = (u16_t)(pcb->ooseq->tcphdr->seqno - seqno);
|
||||
pbuf_realloc(inseg.p, inseg.len);
|
||||
} else {
|
||||
/* does the ooseq segment contain only flags that are in inseg also? */
|
||||
if ((TCPH_FLAGS(inseg.tcphdr) & (TCP_FIN|TCP_SYN)) ==
|
||||
(TCPH_FLAGS(pcb->ooseq->tcphdr) & (TCP_FIN|TCP_SYN))) {
|
||||
if (pcb->ooseq != NULL) {
|
||||
if (TCPH_FLAGS(inseg.tcphdr) & TCP_FIN) {
|
||||
LWIP_DEBUGF(TCP_INPUT_DEBUG,
|
||||
("tcp_receive: received in-order FIN, binning ooseq queue\n"));
|
||||
/* Received in-order FIN means anything that was received
|
||||
* out of order must now have been received in-order, so
|
||||
* bin the ooseq queue */
|
||||
while (pcb->ooseq != NULL) {
|
||||
struct tcp_seg *old_ooseq = pcb->ooseq;
|
||||
pcb->ooseq = pcb->ooseq->next;
|
||||
memp_free(MEMP_TCP_SEG, old_ooseq);
|
||||
}
|
||||
} else if (TCP_SEQ_LEQ(pcb->ooseq->tcphdr->seqno, seqno + tcplen)) {
|
||||
if (pcb->ooseq->len > 0) {
|
||||
/* We have to trim the second edge of the incoming segment. */
|
||||
LWIP_ASSERT("tcp_receive: trimmed segment would have zero length\n",
|
||||
TCP_SEQ_GT(pcb->ooseq->tcphdr->seqno, seqno));
|
||||
/* FIN in inseg already handled by dropping whole ooseq queue */
|
||||
inseg.len = (u16_t)(pcb->ooseq->tcphdr->seqno - seqno);
|
||||
if (TCPH_FLAGS(inseg.tcphdr) & TCP_SYN) {
|
||||
inseg.len -= 1;
|
||||
}
|
||||
pbuf_realloc(inseg.p, inseg.len);
|
||||
tcplen = TCP_TCPLEN(&inseg);
|
||||
LWIP_ASSERT("tcp_receive: segment not trimmed correctly to ooseq queue\n",
|
||||
(seqno + tcplen) == pcb->ooseq->tcphdr->seqno);
|
||||
} else {
|
||||
/* does the ooseq segment contain only flags that are in inseg also? */
|
||||
if ((TCPH_FLAGS(inseg.tcphdr) & (TCP_FIN|TCP_SYN)) ==
|
||||
(TCPH_FLAGS(pcb->ooseq->tcphdr) & (TCP_FIN|TCP_SYN))) {
|
||||
struct tcp_seg *old_ooseq = pcb->ooseq;
|
||||
pcb->ooseq = pcb->ooseq->next;
|
||||
memp_free(MEMP_TCP_SEG, old_ooseq);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* TCP_QUEUE_OOSEQ */
|
||||
|
||||
tcplen = TCP_TCPLEN(&inseg);
|
||||
pcb->rcv_nxt = seqno + tcplen;
|
||||
|
||||
/* Update the receiver's (our) window. */
|
||||
if (pcb->rcv_wnd < tcplen) {
|
||||
pcb->rcv_wnd = 0;
|
||||
} else {
|
||||
pcb->rcv_wnd -= tcplen;
|
||||
}
|
||||
LWIP_ASSERT("tcp_receive: tcplen > rcv_wnd\n", pcb->rcv_wnd >= tcplen);
|
||||
pcb->rcv_wnd -= tcplen;
|
||||
|
||||
tcp_update_rcv_ann_wnd(pcb);
|
||||
|
||||
@@ -1117,11 +1156,9 @@ tcp_receive(struct tcp_pcb *pcb)
|
||||
seqno = pcb->ooseq->tcphdr->seqno;
|
||||
|
||||
pcb->rcv_nxt += TCP_TCPLEN(cseg);
|
||||
if (pcb->rcv_wnd < TCP_TCPLEN(cseg)) {
|
||||
pcb->rcv_wnd = 0;
|
||||
} else {
|
||||
pcb->rcv_wnd -= TCP_TCPLEN(cseg);
|
||||
}
|
||||
LWIP_ASSERT("tcp_receive: ooseq tcplen > rcv_wnd\n",
|
||||
pcb->rcv_wnd >= TCP_TCPLEN(cseg));
|
||||
pcb->rcv_wnd -= TCP_TCPLEN(cseg);
|
||||
|
||||
tcp_update_rcv_ann_wnd(pcb);
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ extern "C" {
|
||||
/** For release candidates, this is set to 1..254
|
||||
* For official releases, this is set to 255 (LWIP_RC_RELEASE)
|
||||
* For development versions (CVS), this is set to 0 (LWIP_RC_DEVELOPMENT) */
|
||||
#define LWIP_VERSION_RC 2U
|
||||
#define LWIP_VERSION_RC 255U
|
||||
|
||||
/** LWIP_VERSION_RC is set to LWIP_RC_RELEASE for official releases */
|
||||
#define LWIP_RC_RELEASE 255U
|
||||
|
||||
@@ -59,7 +59,11 @@ typedef size_t mem_size_t;
|
||||
#define mem_calloc calloc
|
||||
#endif
|
||||
#ifndef mem_realloc
|
||||
#define mem_realloc realloc
|
||||
static void *mem_realloc(void *mem, mem_size_t size)
|
||||
{
|
||||
LWIP_UNUSED_ARG(size);
|
||||
return mem;
|
||||
}
|
||||
#endif
|
||||
#else /* MEM_LIBC_MALLOC */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user