diff options
-rw-r--r-- | src/nat/nat.c | 19 | ||||
-rw-r--r-- | src/nat/nat_auto.c | 9 | ||||
-rw-r--r-- | src/nat/nat_mini.c | 4 | ||||
-rw-r--r-- | src/nat/nat_test.c | 17 | ||||
-rw-r--r-- | src/nat/test_nat_mini.c | 2 | ||||
-rw-r--r-- | src/nat/test_nat_test.c | 2 | ||||
-rw-r--r-- | src/transport/gnunet-transport.c | 2 |
7 files changed, 41 insertions, 14 deletions
diff --git a/src/nat/nat.c b/src/nat/nat.c index 670ae6a27..61ca5eab7 100644 --- a/src/nat/nat.c +++ b/src/nat/nat.c | |||
@@ -1018,7 +1018,7 @@ upnp_add (void *cls, | |||
1018 | int add_remove, | 1018 | int add_remove, |
1019 | const struct sockaddr *addr, | 1019 | const struct sockaddr *addr, |
1020 | socklen_t addrlen, | 1020 | socklen_t addrlen, |
1021 | enum GNUNET_NAT_FailureCode ret) | 1021 | enum GNUNET_NAT_StatusCode ret) |
1022 | { | 1022 | { |
1023 | struct GNUNET_NAT_Handle *h = cls; | 1023 | struct GNUNET_NAT_Handle *h = cls; |
1024 | struct LocalAddressList *pos; | 1024 | struct LocalAddressList *pos; |
@@ -1561,4 +1561,21 @@ GNUNET_NAT_test_address (struct GNUNET_NAT_Handle *h, | |||
1561 | } | 1561 | } |
1562 | 1562 | ||
1563 | 1563 | ||
1564 | /** | ||
1565 | * Converts enum GNUNET_NAT_StatusCode to a string | ||
1566 | * | ||
1567 | * @param err error code to resolve to a string | ||
1568 | * @return point to a static string containing the error code | ||
1569 | */ | ||
1570 | const char * | ||
1571 | GNUNET_NAT_status2string (enum GNUNET_NAT_StatusCode err){ | ||
1572 | switch (err){ | ||
1573 | case GNUNET_NAT_ERROR_SUCCESS: | ||
1574 | return _("Operation Successful"); | ||
1575 | |||
1576 | default: | ||
1577 | return "unknown status code"; | ||
1578 | } | ||
1579 | } | ||
1580 | |||
1564 | /* end of nat.c */ | 1581 | /* end of nat.c */ |
diff --git a/src/nat/nat_auto.c b/src/nat/nat_auto.c index 5b40857af..8fc85d7a7 100644 --- a/src/nat/nat_auto.c +++ b/src/nat/nat_auto.c | |||
@@ -144,7 +144,7 @@ struct GNUNET_NAT_AutoHandle | |||
144 | /** | 144 | /** |
145 | * Error code for better debugging and user feedback | 145 | * Error code for better debugging and user feedback |
146 | */ | 146 | */ |
147 | enum GNUNET_NAT_FailureCode ret; | 147 | enum GNUNET_NAT_StatusCode ret; |
148 | }; | 148 | }; |
149 | 149 | ||
150 | 150 | ||
@@ -167,10 +167,11 @@ next_phase (struct GNUNET_NAT_AutoHandle *ah); | |||
167 | */ | 167 | */ |
168 | static void | 168 | static void |
169 | result_callback (void *cls, | 169 | result_callback (void *cls, |
170 | enum GNUNET_NAT_FailureCode ret) | 170 | enum GNUNET_NAT_StatusCode ret) |
171 | { | 171 | { |
172 | struct GNUNET_NAT_AutoHandle *ah = cls; | 172 | struct GNUNET_NAT_AutoHandle *ah = cls; |
173 | GNUNET_NAT_test_stop (ah->tst); | 173 | if (GNUNET_NAT_ERROR_SUCCESS == ret) |
174 | GNUNET_NAT_test_stop (ah->tst); | ||
174 | ah->tst = NULL; | 175 | ah->tst = NULL; |
175 | ah->ret = ret; | 176 | ah->ret = ret; |
176 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 177 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
@@ -231,7 +232,7 @@ test_online (struct GNUNET_NAT_AutoHandle *ah) | |||
231 | static void | 232 | static void |
232 | set_external_ipv4 (void *cls, | 233 | set_external_ipv4 (void *cls, |
233 | const struct in_addr *addr, | 234 | const struct in_addr *addr, |
234 | enum GNUNET_NAT_FailureCode ret) | 235 | enum GNUNET_NAT_StatusCode ret) |
235 | { | 236 | { |
236 | struct GNUNET_NAT_AutoHandle *ah = cls; | 237 | struct GNUNET_NAT_AutoHandle *ah = cls; |
237 | char buf[INET_ADDRSTRLEN]; | 238 | char buf[INET_ADDRSTRLEN]; |
diff --git a/src/nat/nat_mini.c b/src/nat/nat_mini.c index ae15b5c13..1e8ab7ecc 100644 --- a/src/nat/nat_mini.c +++ b/src/nat/nat_mini.c | |||
@@ -101,7 +101,7 @@ struct GNUNET_NAT_ExternalHandle | |||
101 | /** | 101 | /** |
102 | * Error code for better debugging and user feedback | 102 | * Error code for better debugging and user feedback |
103 | */ | 103 | */ |
104 | enum GNUNET_NAT_FailureCode ret; | 104 | enum GNUNET_NAT_StatusCode ret; |
105 | }; | 105 | }; |
106 | 106 | ||
107 | 107 | ||
@@ -223,7 +223,7 @@ GNUNET_NAT_mini_get_external_ipv4 (struct GNUNET_TIME_Relative timeout, | |||
223 | if (NULL == eh->eip) | 223 | if (NULL == eh->eip) |
224 | { | 224 | { |
225 | GNUNET_DISK_pipe_close (eh->opipe); | 225 | GNUNET_DISK_pipe_close (eh->opipe); |
226 | eh->ret = GNUNET_NAT_ERROR_EXTERNAL_IP_UTILITY_NOT_EXECUTEABLE; | 226 | eh->ret = GNUNET_NAT_ERROR_EXTERNAL_IP_UTILITY_FAILED; |
227 | eh->task = GNUNET_SCHEDULER_add_now (&signal_external_ip_error, | 227 | eh->task = GNUNET_SCHEDULER_add_now (&signal_external_ip_error, |
228 | eh); | 228 | eh); |
229 | return eh; | 229 | return eh; |
diff --git a/src/nat/nat_test.c b/src/nat/nat_test.c index 2836730ca..860c51b26 100644 --- a/src/nat/nat_test.c +++ b/src/nat/nat_test.c | |||
@@ -163,6 +163,10 @@ struct GNUNET_NAT_Test | |||
163 | */ | 163 | */ |
164 | uint16_t adv_port; | 164 | uint16_t adv_port; |
165 | 165 | ||
166 | /** | ||
167 | * Status code to be reported to the timeout/status call | ||
168 | */ | ||
169 | enum GNUNET_NAT_StatusCode status; | ||
166 | }; | 170 | }; |
167 | 171 | ||
168 | 172 | ||
@@ -371,6 +375,8 @@ addr_cb (void *cls, | |||
371 | * Timeout task for a nat test. | 375 | * Timeout task for a nat test. |
372 | * Calls the report-callback with a timeout return value | 376 | * Calls the report-callback with a timeout return value |
373 | * | 377 | * |
378 | * Destroys the nat handle after the callback has been processed. | ||
379 | * | ||
374 | * @param cls handle to the timed out NAT test | 380 | * @param cls handle to the timed out NAT test |
375 | * @param tc not used | 381 | * @param tc not used |
376 | */ | 382 | */ |
@@ -381,7 +387,7 @@ do_timeout (void *cls, | |||
381 | struct GNUNET_NAT_Test *nh = (struct GNUNET_NAT_Test *) cls; | 387 | struct GNUNET_NAT_Test *nh = (struct GNUNET_NAT_Test *) cls; |
382 | 388 | ||
383 | nh->ttask = GNUNET_SCHEDULER_NO_TASK; | 389 | nh->ttask = GNUNET_SCHEDULER_NO_TASK; |
384 | nh->report (nh->report_cls, GNUNET_NAT_ERROR_TIMEOUT); | 390 | nh->report (nh->report_cls, (GNUNET_NAT_ERROR_SUCCESS == nh->status)? GNUNET_NAT_ERROR_TIMEOUT: nh->status ); |
385 | 391 | ||
386 | GNUNET_NAT_test_stop(nh); | 392 | GNUNET_NAT_test_stop(nh); |
387 | } | 393 | } |
@@ -400,7 +406,7 @@ do_timeout (void *cls, | |||
400 | * @param timeout delay after which the test should be aborted | 406 | * @param timeout delay after which the test should be aborted |
401 | * @param report function to call with the result of the test | 407 | * @param report function to call with the result of the test |
402 | * @param report_cls closure for @a report | 408 | * @param report_cls closure for @a report |
403 | * @return handle to cancel NAT test | 409 | * @return handle to cancel NAT test or NULL. The error is indicated through the report callback |
404 | */ | 410 | */ |
405 | struct GNUNET_NAT_Test * | 411 | struct GNUNET_NAT_Test * |
406 | GNUNET_NAT_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | 412 | GNUNET_NAT_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, |
@@ -431,6 +437,7 @@ GNUNET_NAT_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
431 | nh->report = report; | 437 | nh->report = report; |
432 | nh->report_cls = report_cls; | 438 | nh->report_cls = report_cls; |
433 | nh->ttask = GNUNET_SCHEDULER_NO_TASK; | 439 | nh->ttask = GNUNET_SCHEDULER_NO_TASK; |
440 | nh->status = GNUNET_NAT_ERROR_SUCCESS; | ||
434 | if (0 == bnd_port) | 441 | if (0 == bnd_port) |
435 | { | 442 | { |
436 | nh->nat = | 443 | nh->nat = |
@@ -455,7 +462,8 @@ GNUNET_NAT_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
455 | STRERROR (errno)); | 462 | STRERROR (errno)); |
456 | if (NULL != nh->lsock) | 463 | if (NULL != nh->lsock) |
457 | GNUNET_NETWORK_socket_close (nh->lsock); | 464 | GNUNET_NETWORK_socket_close (nh->lsock); |
458 | GNUNET_free (nh); | 465 | nh->status = GNUNET_NAT_ERROR_INTERNAL_NETWORK_ERROR; |
466 | nh->ttask = GNUNET_SCHEDULER_add_now (&do_timeout, nh); | ||
459 | return NULL; | 467 | return NULL; |
460 | } | 468 | } |
461 | if (GNUNET_YES == is_tcp) | 469 | if (GNUNET_YES == is_tcp) |
@@ -485,7 +493,8 @@ GNUNET_NAT_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
485 | GNUNET_SCHEDULER_cancel (nh->ltask); | 493 | GNUNET_SCHEDULER_cancel (nh->ltask); |
486 | if (NULL != nh->lsock) | 494 | if (NULL != nh->lsock) |
487 | GNUNET_NETWORK_socket_close (nh->lsock); | 495 | GNUNET_NETWORK_socket_close (nh->lsock); |
488 | GNUNET_free (nh); | 496 | nh->status = GNUNET_NAT_ERROR_NAT_REGISTER_FAILED; |
497 | nh->ttask = GNUNET_SCHEDULER_add_now (&do_timeout, nh); | ||
489 | return NULL; | 498 | return NULL; |
490 | } | 499 | } |
491 | } | 500 | } |
diff --git a/src/nat/test_nat_mini.c b/src/nat/test_nat_mini.c index e9dab8351..da6e09d76 100644 --- a/src/nat/test_nat_mini.c +++ b/src/nat/test_nat_mini.c | |||
@@ -45,7 +45,7 @@ static void | |||
45 | addr_callback (void *cls, int add_remove, | 45 | addr_callback (void *cls, int add_remove, |
46 | const struct sockaddr *addr, | 46 | const struct sockaddr *addr, |
47 | socklen_t addrlen, | 47 | socklen_t addrlen, |
48 | enum GNUNET_NAT_FailureCode ret) | 48 | enum GNUNET_NAT_StatusCode ret) |
49 | { | 49 | { |
50 | if (GNUNET_NAT_ERROR_SUCCESS == ret) | 50 | if (GNUNET_NAT_ERROR_SUCCESS == ret) |
51 | { | 51 | { |
diff --git a/src/nat/test_nat_test.c b/src/nat/test_nat_test.c index 4095e840c..e86f2ed11 100644 --- a/src/nat/test_nat_test.c +++ b/src/nat/test_nat_test.c | |||
@@ -41,7 +41,7 @@ static struct GNUNET_NAT_Test *tst; | |||
41 | 41 | ||
42 | static void | 42 | static void |
43 | report_result (void *cls, | 43 | report_result (void *cls, |
44 | enum GNUNET_NAT_FailureCode aret) | 44 | enum GNUNET_NAT_StatusCode aret) |
45 | { | 45 | { |
46 | if (GNUNET_NAT_ERROR_TIMEOUT == aret) | 46 | if (GNUNET_NAT_ERROR_TIMEOUT == aret) |
47 | fprintf (stderr, | 47 | fprintf (stderr, |
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c index 8cd606f81..2f6604bdf 100644 --- a/src/transport/gnunet-transport.c +++ b/src/transport/gnunet-transport.c | |||
@@ -545,7 +545,7 @@ display_test_result (struct TestContext *tc, enum TestResult result) | |||
545 | * @param emsg error message, NULL on success | 545 | * @param emsg error message, NULL on success |
546 | */ | 546 | */ |
547 | static void | 547 | static void |
548 | result_callback (void *cls, enum GNUNET_NAT_FailureCode result) | 548 | result_callback (void *cls, enum GNUNET_NAT_StatusCode result) |
549 | { | 549 | { |
550 | struct TestContext *tc = cls; | 550 | struct TestContext *tc = cls; |
551 | display_test_result (tc, result); | 551 | display_test_result (tc, result); |