Don't use -t timeout for TFTP transfers

This commit is contained in:
Joseph C. Lehner 2020-03-02 08:34:44 +01:00
parent 4c376a76f8
commit 9a9abfc07c
2 changed files with 7 additions and 1 deletions

View file

@ -62,6 +62,10 @@
#define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif #endif
#ifndef MAX
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif
#ifndef PACKED #ifndef PACKED
#define PACKED __attribute__((packed)) #define PACKED __attribute__((packed))
#endif #endif

4
tftp.c
View file

@ -315,6 +315,7 @@ int tftp_put(struct nmrpd_args *args)
const char *file_remote = args->file_remote; const char *file_remote = args->file_remote;
char *val, *end; char *val, *end;
bool rollover; bool rollover;
unsigned rx_timeout = MAX(args->rx_timeout / 200, 1);
sock = -1; sock = -1;
ret = -1; ret = -1;
@ -367,6 +368,7 @@ int tftp_put(struct nmrpd_args *args)
xperror("inet_addr"); xperror("inet_addr");
goto cleanup; goto cleanup;
} }
addr.sin_port = htons(args->port); addr.sin_port = htons(args->port);
blksize = 512; blksize = 512;
@ -447,7 +449,7 @@ int tftp_put(struct nmrpd_args *args)
} }
} }
ret = tftp_recvfrom(sock, rx, &port, args->rx_timeout, blksize + 4); ret = tftp_recvfrom(sock, rx, &port, rx_timeout, blksize + 4);
if (ret < 0) { if (ret < 0) {
goto cleanup; goto cleanup;
} else if (!ret) { } else if (!ret) {