mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-25 18:14:53 +00:00
TFTP server handle retransmit Data packets
Signed-off-by: goldsimon <goldsimon@gmx.de>
This commit is contained in:
parent
91bc7a02c9
commit
c34120e855
@ -294,18 +294,27 @@ recv(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16
|
|||||||
}
|
}
|
||||||
|
|
||||||
blknum = lwip_ntohs(sbuf[1]);
|
blknum = lwip_ntohs(sbuf[1]);
|
||||||
pbuf_remove_header(p, TFTP_HEADER_LENGTH);
|
if (blknum == tftp_state.blknum) {
|
||||||
|
pbuf_remove_header(p, TFTP_HEADER_LENGTH);
|
||||||
|
|
||||||
ret = tftp_state.ctx->write(tftp_state.handle, p);
|
ret = tftp_state.ctx->write(tftp_state.handle, p);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
send_error(addr, port, TFTP_ERROR_ACCESS_VIOLATION, "error writing file");
|
send_error(addr, port, TFTP_ERROR_ACCESS_VIOLATION, "error writing file");
|
||||||
close_handle();
|
close_handle();
|
||||||
} else {
|
} else {
|
||||||
|
send_ack(blknum);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (p->tot_len < TFTP_MAX_PAYLOAD_SIZE) {
|
||||||
|
close_handle();
|
||||||
|
} else {
|
||||||
|
tftp_state.blknum++;
|
||||||
|
}
|
||||||
|
} else if ((u16_t)(blknum + 1) == tftp_state.blknum) {
|
||||||
|
/* retransmit of previous block, ack again (casting to u16_t to care for overflow) */
|
||||||
send_ack(blknum);
|
send_ack(blknum);
|
||||||
}
|
} else {
|
||||||
|
send_error(addr, port, TFTP_ERROR_UNKNOWN_TRFR_ID, "Wrong block number");
|
||||||
if (p->tot_len < TFTP_MAX_PAYLOAD_SIZE) {
|
|
||||||
close_handle();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user