From f24861f1b06362d683841e07bde180f34f738a10 Mon Sep 17 00:00:00 2001 From: Christian Fuchs Date: Tue, 24 Jun 2014 10:18:59 +0000 Subject: - added more debug messages to status2string - added remaining functionality to GNUNET_NAT_test_stop --- src/nat/nat.c | 52 +++++++++++++++++++++++++++++++++++++++++++++------- src/nat/nat_test.c | 10 +++++++--- 2 files changed, 52 insertions(+), 10 deletions(-) diff --git a/src/nat/nat.c b/src/nat/nat.c index 61ca5eab7..85d069e07 100644 --- a/src/nat/nat.c +++ b/src/nat/nat.c @@ -1560,22 +1560,60 @@ GNUNET_NAT_test_address (struct GNUNET_NAT_Handle *h, return GNUNET_NO; } - /** * Converts enum GNUNET_NAT_StatusCode to a string * * @param err error code to resolve to a string - * @return point to a static string containing the error code + * @return pointer to a static string containing the error code */ const char * -GNUNET_NAT_status2string (enum GNUNET_NAT_StatusCode err){ - switch (err){ +GNUNET_NAT_status2string (enum GNUNET_NAT_StatusCode err) +{ + switch (err) + { case GNUNET_NAT_ERROR_SUCCESS: - return _("Operation Successful"); - + return _ ("Operation Successful"); + case GNUNET_NAT_ERROR_IPC_FAILURE: + return _ ("Internal Failure (IPC, ...)"); + case GNUNET_NAT_ERROR_INTERNAL_NETWORK_ERROR: + return _ ("Failure in network subsystem, check permissions."); + case GNUNET_NAT_ERROR_TIMEOUT: + return _ ("Encountered timeout while performing operation"); + case GNUNET_NAT_ERROR_NOT_ONLINE: + return _ ("detected that we are offline"); + case GNUNET_NAT_ERROR_UPNPC_NOT_FOUND: + return _ ("`upnpc` command not found"); + case GNUNET_NAT_ERROR_UPNPC_FAILED: + return _ ("Failed to run `upnpc` command"); + case GNUNET_NAT_ERROR_UPNPC_TIMEOUT: + return _ ("`upnpc' command took too long, process killed"); + case GNUNET_NAT_ERROR_UPNPC_PORTMAP_FAILED: + return _ ("`upnpc' command failed to establish port mapping"); + case GNUNET_NAT_ERROR_EXTERNAL_IP_UTILITY_NOT_FOUND: + return _ ("`external-ip' command not found"); + case GNUNET_NAT_ERROR_EXTERNAL_IP_UTILITY_FAILED: + return _ ("Failed to run `external-ip` command"); + case GNUNET_NAT_ERROR_EXTERNAL_IP_UTILITY_OUTPUT_INVALID: + return _ ("`external-ip' command output invalid"); + case GNUNET_NAT_ERROR_EXTERNAL_IP_ADDRESS_INVALID: + return _ ("no valid address was returned by `external-ip'"); + case GNUNET_NAT_ERROR_NO_VALID_IF_IP_COMBO: + return _ ("Could not determine interface with internal/local network address"); + case GNUNET_NAT_ERROR_HELPER_NAT_SERVER_NOT_FOUND: + return _ ("No functioning gnunet-helper-nat-server installation found"); + case GNUNET_NAT_ERROR_NAT_TEST_START_FAILED: + return _ ("NAT test could not be initialized"); + case GNUNET_NAT_ERROR_NAT_TEST_TIMEOUT: + return _ ("NAT test timeout reached"); + case GNUNET_NAT_ERROR_NAT_REGISTER_FAILED: + return _ ("could not register NAT"); + case GNUNET_NAT_ERROR_HELPER_NAT_CLIENT_NOT_FOUND: + return _ ("No working gnunet-helper-nat-client installation found"); +/* case: + return _ ("");*/ default: return "unknown status code"; - } + } } /* end of nat.c */ diff --git a/src/nat/nat_test.c b/src/nat/nat_test.c index 860c51b26..90f06be5c 100644 --- a/src/nat/nat_test.c +++ b/src/nat/nat_test.c @@ -406,7 +406,7 @@ do_timeout (void *cls, * @param timeout delay after which the test should be aborted * @param report function to call with the result of the test * @param report_cls closure for @a report - * @return handle to cancel NAT test or NULL. The error is indicated through the report callback + * @return handle to cancel NAT test or NULL. The error is always indicated via the report callback */ struct GNUNET_NAT_Test * GNUNET_NAT_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, @@ -489,10 +489,14 @@ GNUNET_NAT_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, { LOG (GNUNET_ERROR_TYPE_ERROR, _("NAT test failed to start NAT library\n")); - if (GNUNET_SCHEDULER_NO_TASK != nh->ltask) + if (GNUNET_SCHEDULER_NO_TASK != nh->ltask){ GNUNET_SCHEDULER_cancel (nh->ltask); - if (NULL != nh->lsock) + nh->ltask = GNUNET_SCHEDULER_NO_TASK; + } + if (NULL != nh->lsock){ GNUNET_NETWORK_socket_close (nh->lsock); + nh->lsock = NULL; + } nh->status = GNUNET_NAT_ERROR_NAT_REGISTER_FAILED; nh->ttask = GNUNET_SCHEDULER_add_now (&do_timeout, nh); return NULL; -- cgit v1.2.3