From: Joseph C. Lehner Date: Mon, 2 Mar 2020 07:34:44 +0000 (+0100) Subject: Don't use -t timeout for TFTP transfers X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=9a9abfc07cccdfbcdb3d1479938de8ed7c504359;p=oweals%2Fnmrpflash.git Don't use -t timeout for TFTP transfers --- diff --git a/nmrpd.h b/nmrpd.h index 086d2af..d65c811 100644 --- a/nmrpd.h +++ b/nmrpd.h @@ -62,6 +62,10 @@ #define MIN(a, b) ((a) < (b) ? (a) : (b)) #endif +#ifndef MAX +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#endif + #ifndef PACKED #define PACKED __attribute__((packed)) #endif diff --git a/tftp.c b/tftp.c index b6f5ce7..9fd361a 100644 --- a/tftp.c +++ b/tftp.c @@ -315,6 +315,7 @@ int tftp_put(struct nmrpd_args *args) const char *file_remote = args->file_remote; char *val, *end; bool rollover; + unsigned rx_timeout = MAX(args->rx_timeout / 200, 1); sock = -1; ret = -1; @@ -367,6 +368,7 @@ int tftp_put(struct nmrpd_args *args) xperror("inet_addr"); goto cleanup; } + addr.sin_port = htons(args->port); 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) { goto cleanup; } else if (!ret) {