fix upnpc invocation for port mapping with upnpc
authorChristian Grothoff <christian@grothoff.org>
Sat, 24 Dec 2016 23:35:59 +0000 (00:35 +0100)
committerChristian Grothoff <christian@grothoff.org>
Sat, 24 Dec 2016 23:35:59 +0000 (00:35 +0100)
src/nat/gnunet-service-nat.c
src/nat/gnunet-service-nat_mini.c

index bf3867ff2fe50525e7e3557a17ee7ac4afb15ed0..9ad8db45a38541f1cd4c8b80779d78e5e3a7f324 100644 (file)
@@ -1059,10 +1059,31 @@ upnp_addr_change_cb (void *cls,
     break;
   case GNUNET_NAT_ERROR_UPNPC_FAILED:
   case GNUNET_NAT_ERROR_UPNPC_TIMEOUT:
+  case GNUNET_NAT_ERROR_IPC_FAILURE:
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                "Running upnpc failed: %d\n",
                result);
     return;
+  case GNUNET_NAT_ERROR_EXTERNAL_IP_UTILITY_NOT_FOUND:
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+               "external-ip binary not found\n");
+    return;
+  case GNUNET_NAT_ERROR_EXTERNAL_IP_UTILITY_FAILED:
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+               "external-ip binary could not be run\n");
+    return;
+  case GNUNET_NAT_ERROR_UPNPC_PORTMAP_FAILED:
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+               "upnpc failed to create port mapping\n");
+    return;
+  case GNUNET_NAT_ERROR_EXTERNAL_IP_UTILITY_OUTPUT_INVALID:
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+               "Invalid output from upnpc\n");
+    return;
+  case GNUNET_NAT_ERROR_EXTERNAL_IP_ADDRESS_INVALID:
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+               "Invalid address returned by upnpc\n");
+    return;
   default:
     GNUNET_break (0); /* should not be possible */
     return;
@@ -1823,6 +1844,16 @@ shutdown_task (void *cls)
     GNUNET_SCHEDULER_cancel (se->timeout_task);
     GNUNET_free (se);
   }
+  if (NULL != probe_external_ip_task)
+  {
+    GNUNET_SCHEDULER_cancel (probe_external_ip_task);
+    probe_external_ip_task = NULL;
+  }
+  if (NULL != probe_external_ip_op)
+  {
+    GNUNET_NAT_mini_get_external_ipv4_cancel_ (probe_external_ip_op);
+    probe_external_ip_op = NULL;
+  }
   if (NULL != scan_task)
   {
     GNUNET_SCHEDULER_cancel (scan_task);
index efdc0988b22496c41e32751aa7e47798cf3cad9a..e5b9d021bf3136ce459d035bd2d8caf7588a054f 100644 (file)
@@ -139,7 +139,7 @@ read_external_ipv4 (void *cls)
                        eh->buf,
                        &addr))
     {
-      if (0 != addr.s_addr)
+      if (0 == addr.s_addr)
         eh->ret = GNUNET_NAT_ERROR_EXTERNAL_IP_ADDRESS_INVALID;       /* got 0.0.0.0 */
       else
         eh->ret = GNUNET_NAT_ERROR_SUCCESS;
@@ -578,7 +578,8 @@ process_map_output (void *cls,
     if (GNUNET_YES != mini->did_map)
       mini->ac (mini->ac_cls,
                 GNUNET_SYSERR,
-                NULL, 0,
+                NULL,
+               0,
                 GNUNET_NAT_ERROR_UPNPC_PORTMAP_FAILED);
     if (NULL == mini->refresh_task)
       mini->refresh_task