2005-06-08 Leon Woestenberg <leon.woestenberg@gmx.net>

* tcp_in.c: Send reset on unexpected ACK in two cases. Fix submitted by olaf.peters@technolution.
This commit is contained in:
likewise 2005-06-08 18:57:05 +00:00
parent f9355136d8
commit baf377679a

View File

@ -538,6 +538,7 @@ tcp_process(struct tcp_pcb *pcb)
case SYN_SENT:
LWIP_DEBUGF(TCP_INPUT_DEBUG, ("SYN-SENT: ackno %lu pcb->snd_nxt %lu unacked %lu\n", ackno,
pcb->snd_nxt, ntohl(pcb->unacked->tcphdr->seqno)));
/* received SYN ACK with expected sequence number? */
if ((flags & TCP_ACK) && (flags & TCP_SYN)
&& ackno == ntohl(pcb->unacked->tcphdr->seqno) + 1) {
pcb->snd_buf++;
@ -561,12 +562,17 @@ tcp_process(struct tcp_pcb *pcb)
TCP_EVENT_CONNECTED(pcb, ERR_OK, err);
tcp_ack(pcb);
}
/* received ACK? possibly a half-open connection */
else if (flags & TCP_ACK) {
/* send a RST to bring the other side in a non-synchronized state. */
tcp_rst(ackno, seqno + tcplen, &(iphdr->dest), &(iphdr->src),
tcphdr->dest, tcphdr->src);
}
break;
case SYN_RCVD:
if (flags & TCP_ACK &&
!(flags & TCP_RST)) {
/*if (TCP_SEQ_LT(pcb->lastack, ackno) &&
TCP_SEQ_LEQ(ackno, pcb->snd_nxt)) { */
/* expected ACK number? */
if (TCP_SEQ_BETWEEN(ackno, pcb->lastack+1, pcb->snd_nxt)) {
pcb->state = ESTABLISHED;
LWIP_DEBUGF(TCP_DEBUG, ("TCP connection established %u -> %u.\n", inseg.tcphdr->src, inseg.tcphdr->dest));
@ -586,6 +592,12 @@ tcp_process(struct tcp_pcb *pcb)
tcp_receive(pcb);
pcb->cwnd = pcb->mss;
}
/* incorrect ACK number */
else {
/* send RST */
tcp_rst(ackno, seqno + tcplen, &(iphdr->dest), &(iphdr->src),
tcphdr->dest, tcphdr->src);
}
}
break;
case CLOSE_WAIT:
@ -649,7 +661,6 @@ tcp_process(struct tcp_pcb *pcb)
default:
break;
}
return ERR_OK;
}