+ if (GNUNET_TIME_UNIT_ZERO_ABS.abs_value_us == vc->next_validation.abs_value_us)
+ s_next = GNUNET_strdup ("never");
+ else
+ s_next = GNUNET_strdup (GNUNET_STRINGS_absolute_time_to_string (vc->next_validation));
+
+ FPRINTF (stdout,
+ _("Peer `%s' %s %s\n\t%s%s\n\t%s%s\n\t%s%s\n"),
+ GNUNET_i2s (&vc->addrcp->peer),
+ (GNUNET_OK == res) ? address : "<invalid address>",
+ (monitor_validation) ? GNUNET_TRANSPORT_vs2s (vc->state) : "",
+ "Valid until : ", s_valid,
+ "Last validation: ",s_last,
+ "Next validation: ", s_next);
+ GNUNET_free (s_valid);
+ GNUNET_free (s_last);
+ GNUNET_free (s_next);
+ vc->printed = GNUNET_YES;
+ return;
+ }
+ /* last call, we are done */
+ GNUNET_assert (address_resolutions > 0);
+ address_resolutions--;
+ if ( (GNUNET_SYSERR == res) &&
+ (GNUNET_NO == vc->printed))
+ {
+ if (numeric == GNUNET_NO)
+ {
+ /* Failed to resolve address, try numeric lookup
+ (note: this should be unnecessary, as
+ transport should fallback to numeric lookup
+ internally if DNS takes too long anyway) */
+ resolve_validation_address (vc->addrcp,
+ GNUNET_NO,
+ vc->last_validation,
+ vc->valid_until,
+ vc->next_validation,
+ vc->state);
+ }
+ else
+ {
+ FPRINTF (stdout,
+ _("Peer `%s' %s `%s' \n"),
+ GNUNET_i2s (&vc->addrcp->peer),
+ "<unable to resolve address>",
+ GNUNET_TRANSPORT_vs2s (vc->state));
+ }
+ }
+ GNUNET_free (vc->transport);
+ GNUNET_free (vc->addrcp);
+ GNUNET_CONTAINER_DLL_remove (vc_head, vc_tail, vc);
+ GNUNET_free (vc);
+ if ((0 == address_resolutions) && (iterate_validation))
+ {
+ if (NULL != end)
+ {
+ GNUNET_SCHEDULER_cancel (end);
+ end = NULL;
+ }
+ if (NULL != op_timeout)
+ {
+ GNUNET_SCHEDULER_cancel (op_timeout);
+ op_timeout = NULL;
+ }
+ ret = 0;
+ end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
+ }
+}
+
+
+/**
+ * Resolve address we got a validation state for to a string.
+ *
+ * @param address the address itself
+ * @param numeric #GNUNET_YES to disable DNS, #GNUNET_NO to try reverse lookup
+ * @param last_validation when was the address validated last
+ * @param valid_until until when is the address valid
+ * @param next_validation when will we try to revalidate the address next
+ * @param state where are we in the validation state machine
+ */
+static void
+resolve_validation_address (const struct GNUNET_HELLO_Address *address,
+ int numeric,
+ struct GNUNET_TIME_Absolute last_validation,
+ struct GNUNET_TIME_Absolute valid_until,
+ struct GNUNET_TIME_Absolute next_validation,
+ enum GNUNET_TRANSPORT_ValidationState state)
+{
+ struct ValidationResolutionContext *vc;
+
+ vc = GNUNET_new (struct ValidationResolutionContext);
+ GNUNET_assert(NULL != vc);
+ GNUNET_CONTAINER_DLL_insert(vc_head, vc_tail, vc);
+ address_resolutions++;
+
+ vc->transport = GNUNET_strdup(address->transport_name);
+ vc->addrcp = GNUNET_HELLO_address_copy (address);
+ vc->printed = GNUNET_NO;
+ vc->state = state;
+ vc->last_validation = last_validation;
+ vc->valid_until = valid_until;
+ vc->next_validation = next_validation;
+
+ /* Resolve address to string */
+ vc->asc = GNUNET_TRANSPORT_address_to_string (cfg,
+ address,
+ numeric,
+ RESOLUTION_TIMEOUT,
+ &process_validation_string, vc);
+}
+
+
+/**
+ * Resolve address we got a validation state for to a string.
+ *
+ * @param cls NULL
+ * @param address the address itself
+ * @param last_validation when was the address validated last
+ * @param valid_until until when is the address valid
+ * @param next_validation when will we try to revalidate the address next
+ * @param state where are we in the validation state machine
+ */
+static void
+process_validation_cb (void *cls,
+ const struct GNUNET_HELLO_Address *address,
+ struct GNUNET_TIME_Absolute last_validation,
+ struct GNUNET_TIME_Absolute valid_until,
+ struct GNUNET_TIME_Absolute next_validation,
+ enum GNUNET_TRANSPORT_ValidationState state)
+{
+ if (NULL == address)
+ {
+ if (monitor_validation)
+ {
+ FPRINTF (stdout,
+ "%s",
+ _("Monitor disconnected from transport service. Reconnecting.\n"));
+ return;
+ }
+ vic = NULL;
+ if (NULL != end)
+ GNUNET_SCHEDULER_cancel (end);
+ end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
+ return;
+ }
+ resolve_validation_address (address,
+ numeric,
+ last_validation,
+ valid_until,
+ next_validation,
+ state);
+}
+
+
+static void
+run_nat_test ()
+{
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Running test for plugin `%s' using bind port %u and advertised port %u \n",
+ head->name,
+ (uint16_t) head->bnd_port,
+ (uint16_t) head->adv_port);
+
+ head->tst = GNUNET_NAT_test_start (cfg,
+ (0 == strcasecmp (head->name, "udp"))
+ ? GNUNET_NO : GNUNET_YES,
+ (uint16_t) head->bnd_port,
+ (uint16_t) head->adv_port,
+ TIMEOUT,
+ &result_callback, head);