From 21fbcd668581c72ebb7bdc01908a4cdb11ad3d25 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 25 Dec 2016 00:35:59 +0100 Subject: [PATCH] fix upnpc invocation for port mapping with upnpc --- src/nat/gnunet-service-nat.c | 31 +++++++++++++++++++++++++++++++ src/nat/gnunet-service-nat_mini.c | 5 +++-- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/src/nat/gnunet-service-nat.c b/src/nat/gnunet-service-nat.c index bf3867ff2..9ad8db45a 100644 --- a/src/nat/gnunet-service-nat.c +++ b/src/nat/gnunet-service-nat.c @@ -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); diff --git a/src/nat/gnunet-service-nat_mini.c b/src/nat/gnunet-service-nat_mini.c index efdc0988b..e5b9d021b 100644 --- a/src/nat/gnunet-service-nat_mini.c +++ b/src/nat/gnunet-service-nat_mini.c @@ -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 -- 2.25.1