}
-/**
- * FIXME: document.
- */
-struct LookupHelloContext
-{
- GNUNET_TRANSPORT_AddressCallback iterator;
-
- void *iterator_cls;
-};
-
-
-/**
- * FIXME: document.
- */
-static int
-lookup_address_callback (void *cls,
- const char *tname,
- struct GNUNET_TIME_Absolute expiration,
- const void *addr, size_t addrlen)
-{
- struct LookupHelloContext *lhc = cls;
- lhc->iterator (lhc->iterator_cls, tname, addr, addrlen);
- return GNUNET_OK;
-}
-
-
-/**
- * FIXME: document.
- */
-static void
-lookup_hello_callback (void *cls,
- const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_HELLO_Message *h, uint32_t trust)
-{
- struct LookupHelloContext *lhc = cls;
-
- if (peer == NULL)
- {
- lhc->iterator (lhc->iterator_cls, NULL, NULL, 0);
- GNUNET_free (lhc);
- return;
- }
- if (h == NULL)
- return;
- GNUNET_HELLO_iterate_addresses (h,
- GNUNET_NO, &lookup_address_callback, lhc);
-}
-
-
-/**
- * Function that allows a transport to query the known
- * network addresses for a given peer.
- *
- * @param cls closure
- * @param timeout after how long should we time out?
- * @param target which peer are we looking for?
- * @param iter function to call for each known address
- * @param iter_cls closure for iter
- */
-static void
-plugin_env_lookup_address (void *cls,
- struct GNUNET_TIME_Relative timeout,
- const struct GNUNET_PeerIdentity *target,
- GNUNET_TRANSPORT_AddressCallback iter,
- void *iter_cls)
-{
- struct LookupHelloContext *lhc;
-
- lhc = GNUNET_malloc (sizeof (struct LookupHelloContext));
- lhc->iterator = iter;
- lhc->iterator_cls = iter_cls;
- GNUNET_PEERINFO_for_all (cfg,
- sched,
- target, 0, timeout, &lookup_hello_callback, &lhc);
-}
-
-
/**
* Notify all of our clients about a peer connecting.
*/
*/
struct ValidationList *e;
+ /**
+ * Context for peerinfo iteration.
+ * NULL after we are done processing peerinfo's information.
+ */
+ struct GNUNET_PEERINFO_IteratorContext *piter;
+
};
first_call = GNUNET_NO;
if (chvc->e == NULL)
{
+ chvc->piter = NULL;
first_call = GNUNET_YES;
chvc->e = GNUNET_malloc (sizeof (struct ValidationList));
GNUNET_assert (GNUNET_OK ==
memcpy (chvc->hello, hello, hsize);
/* finally, check if HELLO was previously validated
(continuation will then schedule actual validation) */
- GNUNET_PEERINFO_for_all (cfg,
- sched,
- &target,
- 0,
- HELLO_VERIFICATION_TIMEOUT,
- &check_hello_validated, chvc);
+ chvc->piter = GNUNET_PEERINFO_iterate (cfg,
+ sched,
+ &target,
+ 0,
+ HELLO_VERIFICATION_TIMEOUT,
+ &check_hello_validated, chvc);
return GNUNET_OK;
}
plug->env.my_identity = &my_identity;
plug->env.cls = plug;
plug->env.receive = &plugin_env_receive;
- plug->env.lookup = &plugin_env_lookup_address;
plug->env.notify_address = &plugin_env_notify_address;
plug->env.notify_validation = &plugin_env_notify_validation;
plug->env.default_quota_in = (GNUNET_CONSTANTS_DEFAULT_BPM_IN_OUT + 59999) / (60 * 1000);
size_t addrlen);
-/**
- * Function that allows a transport to query the known
- * network addresses for a given peer.
- *
- * @param cls closure
- * @param timeout after how long should we time out?
- * @param target which peer are we looking for?
- * @param iter function to call for each known address
- * @param iter_cls closure for iter
- */
-typedef void (*GNUNET_TRANSPORT_LookupAddress) (void *cls,
- struct GNUNET_TIME_Relative
- timeout,
- const struct
- GNUNET_PeerIdentity * target,
- GNUNET_TRANSPORT_AddressCallback
- iter, void *iter_cls);
-
-
/**
* The transport service will pass a pointer to a struct
* of this type as the first and only argument to the
*/
GNUNET_TRANSPORT_PluginReceiveCallback receive;
- /**
- * Address lookup function.
- */
- GNUNET_TRANSPORT_LookupAddress lookup;
-
/**
* Function that must be called by each plugin to notify the
* transport service about the addresses under which the transport
*/
struct GNUNET_TIME_Absolute last_quota_update;
+ /**
+ * Context for our iteration to find HELLOs for this peer. NULL
+ * after iteration has completed.
+ */
+ struct GNUNET_PEERINFO_IteratorContext *ic;
+
/**
* Address of the other peer if WE initiated the connection
* (and hence can be sure what it is), otherwise NULL.
else
prev->next = session->next;
/* clean up state */
+ if (session->ic != NULL)
+ {
+ GNUNET_PEERINFO_iterate_cancel (session->ic);
+ session->ic = NULL;
+ }
if (session->transmit_handle != NULL)
{
GNUNET_CONNECTION_notify_transmit_ready_cancel (session->transmit_handle);
if (peer == NULL)
{
+ session->ic = NULL;
/* last call, destroy session if we are still not
connected */
if (session->client != NULL)
session->expecting_welcome = GNUNET_YES;
session->pending_messages = pm;
session->service_context = service_context;
- GNUNET_PEERINFO_for_all (plugin->env->cfg,
- plugin->env->sched,
- target,
- 0, timeout, &session_try_connect, session);
+ session->ic = GNUNET_PEERINFO_iterate (plugin->env->cfg,
+ plugin->env->sched,
+ target,
+ 0, timeout, &session_try_connect, session);
return;
}
GNUNET_assert (session != NULL);