TFTP server handle retransmit Data packets

Signed-off-by: goldsimon <goldsimon@gmx.de>
This commit is contained in:
Jens Nielsen 2018-04-23 16:04:11 +02:00 committed by goldsimon
parent 91bc7a02c9
commit c34120e855

View File

@ -294,6 +294,7 @@ recv(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16
}
blknum = lwip_ntohs(sbuf[1]);
if (blknum == tftp_state.blknum) {
pbuf_remove_header(p, TFTP_HEADER_LENGTH);
ret = tftp_state.ctx->write(tftp_state.handle, p);
@ -306,6 +307,14 @@ recv(void *arg, struct udp_pcb *upcb, struct pbuf *p, const ip_addr_t *addr, u16
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);
} else {
send_error(addr, port, TFTP_ERROR_UNKNOWN_TRFR_ID, "Wrong block number");
}
break;
}