Increase NMRP timeout to 1s

This commit is contained in:
Joseph C. Lehner 2020-08-17 12:29:58 +02:00
parent 0503ae2788
commit 25cda736e6
2 changed files with 9 additions and 5 deletions

2
main.c
View file

@ -131,7 +131,7 @@ int main(int argc, char **argv)
int c, val, max; int c, val, max;
bool list = false, have_dest_mac = false; bool list = false, have_dest_mac = false;
struct nmrpd_args args = { struct nmrpd_args args = {
.rx_timeout = 200, .rx_timeout = 1000,
.ul_timeout = 5 * 60, .ul_timeout = 5 * 60,
.tftpcmd = NULL, .tftpcmd = NULL,
.file_local = NULL, .file_local = NULL,

12
nmrp.c
View file

@ -229,7 +229,7 @@ static void msg_mkconfack(struct nmrp_msg *msg, uint32_t ipaddr, uint32_t ipmask
} }
#ifdef NMRPFLASH_FUZZ #ifdef NMRPFLASH_FUZZ
#define NMRP_INITIAL_TIMEOUT 0 #define NMRP_ADVERTISE_TIMEOUT 0
#define ethsock_create(a, b) ((struct ethsock*)1) #define ethsock_create(a, b) ((struct ethsock*)1)
#define ethsock_get_hwaddr(a) ethsock_get_hwaddr_fake(a) #define ethsock_get_hwaddr(a) ethsock_get_hwaddr_fake(a)
#define ethsock_recv(sock, buf, len) read(STDIN_FILENO, buf, len) #define ethsock_recv(sock, buf, len) read(STDIN_FILENO, buf, len)
@ -249,7 +249,7 @@ static uint8_t *ethsock_get_hwaddr_fake(struct ethsock* sock)
return hwaddr; return hwaddr;
} }
#else #else
#define NMRP_INITIAL_TIMEOUT 60 #define NMRP_ADVERTISE_TIMEOUT 60
#endif #endif
static int pkt_send(struct ethsock *sock, struct nmrp_pkt *pkt) static int pkt_send(struct ethsock *sock, struct nmrp_pkt *pkt)
@ -465,7 +465,7 @@ int nmrp_do(struct nmrpd_args *args)
} }
} }
if (ethsock_set_timeout(sock, args->rx_timeout)) { if (ethsock_set_timeout(sock, 200)) {
goto out; goto out;
} }
@ -483,7 +483,7 @@ int nmrp_do(struct nmrpd_args *args)
i = 0; i = 0;
upload_ok = 0; upload_ok = 0;
fake = 0; fake = 0;
timeout = args->blind ? 10 : NMRP_INITIAL_TIMEOUT; timeout = args->blind ? 10 : NMRP_ADVERTISE_TIMEOUT;
beg = time_monotonic(); beg = time_monotonic();
while (!g_interrupted) { while (!g_interrupted) {
@ -535,6 +535,10 @@ int nmrp_do(struct nmrpd_args *args)
goto out; goto out;
} }
if (ethsock_set_timeout(sock, args->rx_timeout)) {
goto out;
}
expect = NMRP_C_CONF_REQ; expect = NMRP_C_CONF_REQ;
ulreqs = 0; ulreqs = 0;
ka_reqs = 0; ka_reqs = 0;