shot in the dark for FSCORE-410

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14431 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2009-07-30 16:20:47 +00:00
parent 6854161e74
commit 7868054dd7
1 changed files with 23 additions and 8 deletions

View File

@ -134,12 +134,15 @@ static int get_pmp_pubaddr(char *pub_addr)
char *pubaddr = NULL;
fd_set fds;
natpmp_t natpmp;
const char *err = NULL;
if ((r = initnatpmp(&natpmp)) < 0) {
err = "init failed";
goto end;
}
initnatpmp(&natpmp);
r = sendpublicaddressrequest(&natpmp);
if (r < 0) {
if ((r = sendpublicaddressrequest(&natpmp)) < 0) {
err = "pub addr req failed";
goto end;
}
@ -150,16 +153,24 @@ static int get_pmp_pubaddr(char *pub_addr)
FD_ZERO(&fds);
FD_SET(natpmp.s, &fds);
getnatpmprequesttimeout(&natpmp, &timeout);
select(FD_SETSIZE, &fds, NULL, NULL, &timeout);
if ((r = getnatpmprequesttimeout(&natpmp, &timeout)) < 0) {
err = "get timeout failed";
goto end;
}
if ((r = select(FD_SETSIZE, &fds, NULL, NULL, &timeout)) < 0) {
err = "select failed";
goto end;
}
r = readnatpmpresponseorretry(&natpmp, &response);
} while(r == NATPMP_TRYAGAIN && i < max);
if (r < 0) {
err = "general error";
goto end;
}
pubaddr = inet_ntoa(response.pnu.publicaddress.addr);
switch_copy_string(pub_addr, pubaddr, IP_LEN);
nat_globals.nat_type = SWITCH_NAT_TYPE_PMP;
@ -168,6 +179,10 @@ static int get_pmp_pubaddr(char *pub_addr)
end:
if (err) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error checking for PMP [%s]\n", err);
}
return r;
}