]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
shot in the dark for FSCORE-410
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 30 Jul 2009 16:20:47 +0000 (16:20 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 30 Jul 2009 16:20:47 +0000 (16:20 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14431 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/switch_nat.c

index d88aed5cd07e2793c126bc71e615d1079b2c4519..d46c4c7f4af85772dd64d23b9ce4033c8001d048 100644 (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;
 }