+
+/**
+ * Function called with responses from the service.
+ *
+ * @param cls our 'struct GNUNET_TRANSPORT_PeerAddressLookupContext*'
+ * @param msg NULL on timeout or error, otherwise presumably a
+ * message with the human-readable address
+ */
+static void
+peer_address_response_processor (void *cls,
+ const struct GNUNET_MessageHeader *msg);
+
+
+/**
+ * Send our subscription request to the service.
+ *
+ * @param pal_ctx our context
+ */
+static void
+send_request (struct GNUNET_TRANSPORT_PeerIterateContext *pal_ctx)
+{
+ struct AddressIterateMessage msg;
+
+ msg.header.size = htons (sizeof (struct AddressIterateMessage));
+ msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_ITERATE);
+ msg.one_shot = htonl (pal_ctx->one_shot);
+ msg.timeout = GNUNET_TIME_absolute_hton (pal_ctx->timeout);
+ msg.peer = pal_ctx->peer;
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CLIENT_transmit_and_get_response (pal_ctx->client,
+ &msg.header,
+ GNUNET_TIME_absolute_get_remaining (pal_ctx->timeout),
+ GNUNET_YES,
+ &peer_address_response_processor,
+ pal_ctx));
+}
+
+/**
+ * Task run to re-establish the connection.
+ *
+ * @param cls our 'struct GNUNET_TRANSPORT_PeerAddressLookupContext*'
+ * @param tc scheduler context, unused
+ */
+static void
+do_connect (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ struct GNUNET_TRANSPORT_PeerIterateContext *pal_ctx = cls;
+
+ pal_ctx->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
+ pal_ctx->client = GNUNET_CLIENT_connect ("transport", pal_ctx->cfg);
+ GNUNET_assert (NULL != pal_ctx->client);
+ send_request (pal_ctx);
+}
+
+
+/**
+ * Cut the existing connection and reconnect.
+ *
+ * @param pal_ctx our context
+ */
+static void
+reconnect (struct GNUNET_TRANSPORT_PeerIterateContext *pal_ctx)
+{
+ GNUNET_assert (GNUNET_NO == pal_ctx->one_shot);
+ GNUNET_CLIENT_disconnect (pal_ctx->client);
+ pal_ctx->client = NULL;
+ pal_ctx->backoff = GNUNET_TIME_relative_max (GNUNET_TIME_UNIT_MILLISECONDS,
+ GNUNET_TIME_relative_min (GNUNET_TIME_relative_multiply (pal_ctx->backoff, 2),
+ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30)));
+ pal_ctx->reconnect_task = GNUNET_SCHEDULER_add_delayed (pal_ctx->backoff,
+ &do_connect,
+ pal_ctx);
+}
+
+