Merge pull request #55 from N00byEdge/pxe_smaller_packets_fix

Don't stop download if tftp server sends packets smaller than the negotiated mtu
This commit is contained in:
mint 2020-12-02 19:08:20 +01:00 committed by GitHub
commit 60b72aee6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 2 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -61,6 +61,8 @@ int tftp_open(struct tftp_file_handle* handle, uint32_t server_ip, uint16_t serv
size_t to_transfer = handle->file_size; size_t to_transfer = handle->file_size;
size_t progress = 0; size_t progress = 0;
bool slow = false;
while (to_transfer > 0) { while (to_transfer > 0) {
volatile struct pxenv_read read = { volatile struct pxenv_read read = {
.boff = ((uint16_t)rm_off(buf)), .boff = ((uint16_t)rm_off(buf)),
@ -72,8 +74,9 @@ int tftp_open(struct tftp_file_handle* handle, uint32_t server_ip, uint16_t serv
} }
memcpy(handle->data + progress, buf, read.bsize); memcpy(handle->data + progress, buf, read.bsize);
if (read.bsize < mtu) { if (read.bsize < mtu && !slow) {
break; slow = true;
print("Server is sending the file in smaller packets (it sent %d bytes), download might take longer.\n", read.bsize);
} }
to_transfer -= read.bsize; to_transfer -= read.bsize;
progress += read.bsize; progress += read.bsize;