miniupnpd/natpmp.c: avoid hang when all external ports in use

reorganize a bit
This commit is contained in:
Thomas Bernard 2014-02-28 13:34:46 +01:00
parent c6a8879c87
commit 3c90f6a30d
2 changed files with 30 additions and 28 deletions

View File

@ -1,5 +1,8 @@
$Id: Changelog.txt,v 1.352 2014/02/24 18:41:23 nanard Exp $
2014/02/28:
natpmp : avoid hang when all external ports in use
2014/02/24:
Defaulting to SSDP_RESPOND_SAME_VERSION

View File

@ -205,7 +205,6 @@ void ProcessIncomingNATPMPPacket(int s, unsigned char *msg_buff, int len,
int proto;
char iaddr_old[16];
unsigned short iport_old;
unsigned short eport_first;
unsigned int timestamp;
iport = ntohs(*((uint16_t *)(req+4)));
@ -268,6 +267,8 @@ void ProcessIncomingNATPMPPacket(int s, unsigned char *msg_buff, int len,
|| !check_upnp_rule_against_permissions(upnppermlist, num_upnpperm, eport, senderaddr->sin_addr, iport)) {
resp[3] = 2; /* Not Authorized/Refused */
} else {
unsigned short eport_first;
char desc[64];
eport_first = eport;
do {
r = get_redirect_rule(ext_if_name, eport, proto,
@ -296,8 +297,7 @@ void ProcessIncomingNATPMPPacket(int s, unsigned char *msg_buff, int len,
continue;
}
}
{ /* do the redirection */
char desc[64];
/* do the redirection */
#if 0
timestamp = (unsigned)(time(NULL) - startup_time)
+ lifetime;
@ -323,7 +323,6 @@ void ProcessIncomingNATPMPPacket(int s, unsigned char *msg_buff, int len,
#endif
}
break;
}
} while(r==0);
}
*((uint16_t *)(resp+8)) = htons(iport); /* private port */