make the maximum number of retries configurable at compile time
using a preprocessor define like this: `CFLAGS="-Os -DNATPMP_MAX_RETRIES=4" make`. The rationale is that users might want to reduce the maximum timeout of 127.75 seconds with an invalid gateway.
This commit is contained in:
parent
6d5c0db6a0
commit
4a720773d5
2
natpmp.c
2
natpmp.c
|
@ -286,7 +286,7 @@ NATPMP_LIBSPEC int readnatpmpresponseorretry(natpmp_t * p, natpmpresp_t * respon
|
|||
gettimeofday(&now, NULL); // check errors !
|
||||
if(timercmp(&now, &p->retry_time, >=)) {
|
||||
int delay, r;
|
||||
if(p->try_number >= 9) {
|
||||
if(p->try_number >= NATPMP_MAX_RETRIES) {
|
||||
return NATPMP_ERR_NOGATEWAYSUPPORT;
|
||||
}
|
||||
/*printf("retry! %d\n", p->try_number);*/
|
||||
|
|
7
natpmp.h
7
natpmp.h
|
@ -51,6 +51,13 @@ typedef unsigned short uint16_t;
|
|||
#endif /* _WIN32 */
|
||||
#include "natpmp_declspec.h"
|
||||
|
||||
/* Set to 9 by https://tools.ietf.org/html/rfc6886#section-3.1 which leads to a
|
||||
* maximum timeout of 127.75 seconds, due to the initial 250 ms timeout doubling
|
||||
* each time, so we allow a compile-time modification here.*/
|
||||
#ifndef NATPMP_MAX_RETRIES
|
||||
#define NATPMP_MAX_RETRIES (9)
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int s; /* socket */
|
||||
in_addr_t gateway; /* default gateway (IPv4) */
|
||||
|
|
Loading…
Reference in New Issue