Urgent items (before announcing ng.gnunet.org):
* CORE:
+ - update core API to reflect changes to transport API
+ (need to pass distance to clients!)
- test currently fails spectacularly
- request disconnect not implemented (needs better transport API)
* topology
- (forced) disconnect does not work (also CORE API issue)
- needs testing (not sure the current testcase does much...)
+* testing:
+ - timeout_hello_task is not used but should be (so we can fail
+ properly)
+ - check that 'GNUNET_TRANSPORT_get_hello' is associated with
+ a TIMEOUT task wherever else appropriate (other testcases
+ in particular!)
* hostlist
- test fails (looks like it works, but that's because of a bad
connectivity notification; somehow core is unable to send
* Function called by the transport for each received message.
*
* @param cls closure
- * @param latency estimated latency for communicating with the
- * given peer
* @param peer (claimed) identity of the other peer
* @param message the message
+ * @param latency estimated latency for communicating with the
+ * given peer (round-trip)
+ * @param distance in overlay hops, as given by transport plugin
*/
static void
handle_transport_receive (void *cls,
- struct GNUNET_TIME_Relative latency,
const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_MessageHeader *message)
+ const struct GNUNET_MessageHeader *message,
+ struct GNUNET_TIME_Relative latency,
+ unsigned int distance)
{
struct Neighbour *n;
struct GNUNET_TIME_Absolute now;
* @param cls closure
* @param peer the peer that connected
* @param latency current latency of the connection
+ * @param distance in overlay hops, as given by transport plugin
*/
static void
handle_transport_notify_connect (void *cls,
const struct GNUNET_PeerIdentity *peer,
- struct GNUNET_TIME_Relative latency)
+ struct GNUNET_TIME_Relative latency,
+ unsigned int distance)
{
struct Neighbour *n;
struct GNUNET_TIME_Absolute now;
static void
process_hello (void *cls,
- struct GNUNET_TIME_Relative latency,
- const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
struct PeerContext *p = cls;
- GNUNET_assert (peer != NULL);
+ GNUNET_TRANSPORT_get_hello_cancel (p->th, &process_hello, p);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received (my) `%s' from transport service of `%4s'\n",
- "HELLO", GNUNET_i2s (peer));
+ "Received (my) `%s' from transport service\n",
+ "HELLO");
GNUNET_assert (message != NULL);
p->hello = GNUNET_malloc (ntohs (message->size));
memcpy (p->hello, message, ntohs (message->size));
GNUNET_ARM_start_services (p->cfg, sched, "core", NULL);
p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, p, NULL, NULL, NULL);
GNUNET_assert (p->th != NULL);
- GNUNET_TRANSPORT_get_hello (p->th, TIMEOUT, &process_hello, p);
+ GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
}
* @param cls closure
* @param peer the peer that connected
* @param latency current latency of the connection
+ * @param distance in overlay hops, as given by transport plugin
*/
static void
notify_connect (void *cls,
const struct GNUNET_PeerIdentity * peer,
- struct GNUNET_TIME_Relative latency)
+ struct GNUNET_TIME_Relative latency,
+ unsigned int distance)
{
if (peer == NULL)
return;
static void
process_hello (void *cls,
- struct GNUNET_TIME_Relative latency,
- const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
struct PeerContext *p = cls;
- if (message == NULL)
- return;
+ GNUNET_TRANSPORT_get_hello_cancel (p->th, &process_hello, p);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received HELLO, starting hostlist service.\n");
GNUNET_ARM_start_services (p->cfg, sched, "hostlist", NULL);
p->th = GNUNET_TRANSPORT_connect (sched, p->cfg, p, NULL,
¬ify_connect, NULL);
GNUNET_assert (p->th != NULL);
- GNUNET_TRANSPORT_get_hello (p->th, TIMEOUT, &process_hello, p);
+ GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
}
}
+#if 0
+static void
+timeout_hello_task (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ GNUNET_TRANSPORT_get_hello_cancel (ctx->d1th,
+ &process_hello,
+ ctx);
+ GNUNET_TRANSPORT_disconnect (ctx->d1th);
+ GNUNET_TRANSPORT_disconnect (ctx->d2th);
+ if (NULL != ctx->cb)
+ ctx->cb (ctx->cb_cls,
+ _("Failed to receive `HELLO' from peer\n"));
+ GNUNET_free (ctx);
+}
+#endif
+
+
/**
* Receive the HELLO from one peer, give it to the other
* and ask them to connect.
*
* @param cls "struct ConnectContext"
- * @param latency how fast is the connection
- * @param peer ID of peer giving us the HELLO
* @param message HELLO message of peer
*/
static void
process_hello (void *cls,
- struct GNUNET_TIME_Relative latency,
- const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
struct ConnectContext *ctx = cls;
- if (peer == NULL)
- {
- /* signal error */
- GNUNET_TRANSPORT_disconnect (ctx->d1th);
- GNUNET_TRANSPORT_disconnect (ctx->d2th);
- if (NULL != ctx->cb)
- ctx->cb (ctx->cb_cls,
- _("Failed to receive `HELLO' from peer\n"));
- GNUNET_free (ctx);
- return;
- }
+ /* first of all, stop the notification stuff */
+ GNUNET_TRANSPORT_get_hello_cancel (ctx->d1th,
+ &process_hello,
+ ctx);
#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received `%s' from transport service of `%4s'\n",
if (NULL != cb)
cb (cb_cls, _("Failed to connect to transport service!\n"));
return;
- }
+ }
+ /* FIXME: need to handle timeout: start timeout task
+ as well here! (use 'timeout_hello_task') */
GNUNET_TRANSPORT_get_hello (ctx->d1th,
- timeout,
&process_hello,
ctx);
}