struct GNUNET_CORE_Handle *ch;
struct GNUNET_PeerIdentity id;
struct GNUNET_TRANSPORT_Handle *th;
+ struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
struct GNUNET_MessageHeader *hello;
int connect_status;
#if START_ARM
GNUNET_assert (ok == 6);
GNUNET_CORE_disconnect (p1.ch);
GNUNET_CORE_disconnect (p2.ch);
- GNUNET_TRANSPORT_get_hello_cancel (p1.th, &process_hello, &p1);
- GNUNET_TRANSPORT_get_hello_cancel (p2.th, &process_hello, &p2);
+ GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
+ GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
GNUNET_TRANSPORT_disconnect (p1.th);
GNUNET_TRANSPORT_disconnect (p2.th);
ok = 0;
}
if (p1.th != NULL)
{
- GNUNET_TRANSPORT_get_hello_cancel (p1.th, &process_hello, &p1);
+ GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
GNUNET_TRANSPORT_disconnect (p1.th);
p1.th = NULL;
}
if (p2.th != NULL)
{
- GNUNET_TRANSPORT_get_hello_cancel (p2.th, &process_hello, &p2);
+ GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
GNUNET_TRANSPORT_disconnect (p2.th);
p2.th = NULL;
}
GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL);
GNUNET_assert (p->th != NULL);
- GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
+ p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
}
struct GNUNET_CORE_Handle *ch;
struct GNUNET_PeerIdentity id;
struct GNUNET_TRANSPORT_Handle *th;
+ struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
struct GNUNET_MessageHeader *hello;
int connect_status;
#if START_ARM
#endif
GNUNET_assert (ok == 6);
GNUNET_assert (NULL == irc);
- GNUNET_TRANSPORT_get_hello_cancel (p1.th, &process_hello, &p1);
- GNUNET_TRANSPORT_get_hello_cancel (p2.th, &process_hello, &p2);
+ GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
+ GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
GNUNET_CORE_disconnect (p1.ch);
GNUNET_CORE_disconnect (p2.ch);
GNUNET_TRANSPORT_disconnect (p1.th);
GNUNET_SCHEDULER_cancel (ask_task);
ask_task = GNUNET_SCHEDULER_NO_TASK;
}
- GNUNET_TRANSPORT_get_hello_cancel (p1.th, &process_hello, &p1);
- GNUNET_TRANSPORT_get_hello_cancel (p2.th, &process_hello, &p2);
+ GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
+ GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
GNUNET_CORE_disconnect (p1.ch);
GNUNET_CORE_disconnect (p2.ch);
GNUNET_TRANSPORT_disconnect (p1.th);
GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL);
GNUNET_assert (p->th != NULL);
- GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
+ p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
}
struct GNUNET_PeerIdentity id;
struct GNUNET_TRANSPORT_Handle *th;
struct GNUNET_MessageHeader *hello;
+ struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
int connect_status;
#if START_ARM
struct GNUNET_OS_Process *arm_proc;
{
unsigned long long delta;
- GNUNET_TRANSPORT_get_hello_cancel (p1.th, &process_hello, &p1);
- GNUNET_TRANSPORT_get_hello_cancel (p2.th, &process_hello, &p2);
+ GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
+ GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
GNUNET_CORE_disconnect (p1.ch);
p1.ch = NULL;
GNUNET_CORE_disconnect (p2.ch);
}
if (p1.th != NULL)
{
- GNUNET_TRANSPORT_get_hello_cancel (p1.th, &process_hello, &p1);
+ GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
GNUNET_TRANSPORT_disconnect (p1.th);
p1.th = NULL;
}
if (p2.th != NULL)
{
- GNUNET_TRANSPORT_get_hello_cancel (p2.th, &process_hello, &p2);
+ GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
GNUNET_TRANSPORT_disconnect (p2.th);
p2.th = NULL;
}
GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname));
p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL);
GNUNET_assert (p->th != NULL);
- GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
+ p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
}
struct GNUNET_TRANSPORT_Handle *th;
struct GNUNET_MessageHeader *hello;
struct GNUNET_STATISTICS_Handle *stats;
+ struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
int connect_status;
#if START_ARM
struct GNUNET_OS_Process *arm_proc;
{
struct GNUNET_CORE_Handle *ch;
- GNUNET_TRANSPORT_get_hello_cancel (p2.th, &process_hello, &p2);
- GNUNET_TRANSPORT_get_hello_cancel (p1.th, &process_hello, &p1);
+ GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
+ GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
ch = p1.ch;
p1.ch = NULL;
GNUNET_CORE_disconnect (ch);
if (measure_task != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (measure_task);
- GNUNET_TRANSPORT_get_hello_cancel (p1.th, &process_hello, &p1);
- GNUNET_TRANSPORT_get_hello_cancel (p2.th, &process_hello, &p2);
+ GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
+ GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
GNUNET_CORE_disconnect (p1.ch);
p1.ch = NULL;
GNUNET_assert (p->stats != NULL);
p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL);
GNUNET_assert (p->th != NULL);
- GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
+ p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
}
*/
struct GNUNET_STATISTICS_Handle *stats;
+/**
+ * Handle to get our current HELLO.
+ */
+static struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
/**
* The configuration the DHT service is running with
int bucket_count;
struct PeerInfo *pos;
+ if (NULL != ghh)
+ {
+ GNUNET_TRANSPORT_get_hello_cancel (ghh);
+ ghh = NULL;
+ }
if (transport_handle != NULL)
{
GNUNET_free_non_null (my_hello);
- GNUNET_TRANSPORT_get_hello_cancel (transport_handle, &process_hello, NULL);
GNUNET_TRANSPORT_disconnect (transport_handle);
+ transport_handle = NULL;
}
if (coreAPI != NULL)
{
transport_handle =
GNUNET_TRANSPORT_connect (cfg, NULL, NULL, NULL, NULL, NULL);
if (transport_handle != NULL)
- GNUNET_TRANSPORT_get_hello (transport_handle, &process_hello, NULL);
+ ghh = GNUNET_TRANSPORT_get_hello (transport_handle, &process_hello, NULL);
else
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
"Failed to connect to transport service!\n");
struct GNUNET_CONFIGURATION_Handle *cfg;
struct GNUNET_TRANSPORT_Handle *th;
struct GNUNET_MessageHeader *hello;
+ struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
#if START_ARM
struct GNUNET_OS_Process *arm_proc;
#endif
{
struct PeerContext *p = cls;
- GNUNET_TRANSPORT_get_hello_cancel (p->th, &process_hello, p);
+ GNUNET_TRANSPORT_get_hello_cancel (p->ghh);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received HELLO, starting hostlist service.\n");
}
p->th =
GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, ¬ify_connect, NULL);
GNUNET_assert (p->th != NULL);
- GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
+ p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
}
struct GNUNET_CONFIGURATION_Handle *cfg;
struct GNUNET_TRANSPORT_Handle *th;
struct GNUNET_MessageHeader *hello;
+ struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
#if START_ARM
struct GNUNET_OS_Process *arm_proc;
#endif
{
struct PeerContext *p = cls;
- GNUNET_TRANSPORT_get_hello_cancel (p->th, &process_hello, p);
+ GNUNET_TRANSPORT_get_hello_cancel (p->ghh);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received HELLO, starting hostlist service.\n");
}
p->th =
GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, ¬ify_connect, NULL);
GNUNET_assert (p->th != NULL);
- GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
+ p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p);
}
*/
struct GNUNET_TRANSPORT_Handle *th;
+ /**
+ * Handle for getting HELLOs from transport
+ */
+ struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
+
/**
* HELLO message for this peer
*/
* @param cb function to call at the end
* @param cb_cls closure for cb
*/
-struct GNUNET_TESTING_ConnectContext *
+void /* struct GNUNET_TESTING_ConnectContext * */
GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1,
struct GNUNET_TESTING_Daemon *d2,
struct GNUNET_TIME_Relative timeout,
void *cb_cls);
+#if 0
/**
* Cancel an attempt to connect two daemons.
*
void
GNUNET_TESTING_daemons_connect_cancel (struct GNUNET_TESTING_ConnectContext
*cc);
+#endif
/**
hello);
+/**
+ * Handle to cancel a 'GNUNET_TRANSPORT_get_hello' operation.
+ */
+struct GNUNET_TRANSPORT_GetHelloHandle;
+
+
/**
* Obtain updates on changes to the HELLO message for this peer.
*
* @param handle connection to transport service
* @param rec function to call with the HELLO
* @param rec_cls closure for rec
+ * @return handle to cancel the operation, NULL on error
*/
-void
+struct GNUNET_TRANSPORT_GetHelloHandle *
GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle,
GNUNET_TRANSPORT_HelloUpdateCallback rec,
void *rec_cls);
/**
* Stop receiving updates about changes to our HELLO message.
*
- * @param handle connection to transport service
- * @param rec function previously registered to be called with the HELLOs
- * @param rec_cls closure for rec
+ * @param ghh handle returned from 'GNUNET_TRANSPORT_get_hello')
*/
void
-GNUNET_TRANSPORT_get_hello_cancel (struct GNUNET_TRANSPORT_Handle *handle,
- GNUNET_TRANSPORT_HelloUpdateCallback rec,
- void *rec_cls);
+GNUNET_TRANSPORT_get_hello_cancel (struct GNUNET_TRANSPORT_GetHelloHandle *ghh);
/**
GNUNET_free (handle);
}
-/* end of mesh_api.c */
\ No newline at end of file
+/* end of mesh_api.c */
nat_res = GNUNET_OS_check_helper_binary ("gnunet-nat-server");
if (GNUNET_NO == nat_res)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Cannot run NAT test: `%s' %s \n",
- "gnunet-nat-server",
- "SUID not set");
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Cannot run NAT test: `%s' %s \n",
+ "gnunet-nat-server", "SUID not set");
return 0;
}
- if (GNUNET_SYSERR == nat_res)
+ if (GNUNET_SYSERR == nat_res)
{
- GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Cannot run NAT test: `%s' %s \n",
- "gnunet-nat-server",
- "file not found");
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Cannot run NAT test: `%s' %s \n",
+ "gnunet-nat-server", "file not found");
return 0;
}
{
return;
}
- if (daemon->th != NULL)
+ if (daemon->ghh != NULL)
{
- GNUNET_TRANSPORT_get_hello_cancel (daemon->th, &process_hello, daemon);
+ GNUNET_TRANSPORT_get_hello_cancel (daemon->ghh);
}
#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
GNUNET_i2s (my_identity));
#endif
- GNUNET_TRANSPORT_get_hello (d->th, &process_hello, d);
+ d->ghh = GNUNET_TRANSPORT_get_hello (d->th, &process_hello, d);
/* wait some more */
if (d->task != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (d->task);
GNUNET_i2s (&d->id));
#endif
- GNUNET_TRANSPORT_get_hello (d->th, &process_hello, d);
+ d->ghh = GNUNET_TRANSPORT_get_hello (d->th, &process_hello, d);
GNUNET_SCHEDULER_add_now (¬ify_daemon_started, d);
/*cb = d->cb;
* d->cb = NULL;
("either `gnunet-arm' or `ssh' does not seem to terminate.\n"));
if (d->th != NULL)
{
- GNUNET_TRANSPORT_get_hello_cancel (d->th, &process_hello, d);
+ GNUNET_TRANSPORT_get_hello_cancel (d->ghh);
+ d->ghh = NULL;
GNUNET_TRANSPORT_disconnect (d->th);
d->th = NULL;
}
("shutdown (either `gnunet-arm' or `ssh') did not complete cleanly.\n"));
if (d->th != NULL)
{
- GNUNET_TRANSPORT_get_hello_cancel (d->th, &process_hello, d);
+ GNUNET_TRANSPORT_get_hello_cancel (d->ghh);
+ d->ghh = NULL;
GNUNET_TRANSPORT_disconnect (d->th);
d->th = NULL;
}
if (d->th != NULL)
{
- GNUNET_TRANSPORT_get_hello_cancel (d->th, &process_hello, d);
+ GNUNET_TRANSPORT_get_hello_cancel (d->ghh);
+ d->ghh = NULL;
GNUNET_TRANSPORT_disconnect (d->th);
d->th = NULL;
}
if (d->th != NULL)
{
- GNUNET_TRANSPORT_get_hello_cancel (d->th, &process_hello, d);
+ GNUNET_TRANSPORT_get_hello_cancel (d->ghh);
+ d->ghh = NULL;
GNUNET_TRANSPORT_disconnect (d->th);
d->th = NULL;
}
d->churn = GNUNET_YES;
if (d->th != NULL)
{
- GNUNET_TRANSPORT_get_hello_cancel (d->th, &process_hello, d);
+ GNUNET_TRANSPORT_get_hello_cancel (d->ghh);
+ d->ghh = NULL;
GNUNET_TRANSPORT_disconnect (d->th);
d->th = NULL;
}
ctx->d2->hello = NULL;
if (NULL != ctx->d2->th)
{
- GNUNET_TRANSPORT_get_hello_cancel (ctx->d2->th, &process_hello, ctx->d2);
+ GNUNET_TRANSPORT_get_hello_cancel (ctx->d2->ghh);
+ ctx->d2->ghh = NULL;
GNUNET_TRANSPORT_disconnect (ctx->d2->th);
}
ctx->d2->th =
GNUNET_TRANSPORT_connect (ctx->d2->cfg, &ctx->d2->id, NULL, NULL, NULL,
NULL);
GNUNET_assert (ctx->d2->th != NULL);
- GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2);
+ ctx->d2->ghh =
+ GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2);
}
if ((NULL == ctx->d2->hello) && (ctx->d2->th == NULL))
_("Failed to connect to transport service!\n"));
return;
}
- GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2);
+ ctx->d2->ghh =
+ GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2);
}
if (ctx->send_hello == GNUNET_YES)
_("Failed to connect to transport service!\n"));
return;
}
- GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2);
+ ctx->d2->ghh =
+ GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2);
}
if (ctx->send_hello == GNUNET_YES)
lib_LTLIBRARIES = \
libgnunettransport.la \
libgnunettransporttesting.la
-
+
libgnunettransporttesting_la_SOURCES = \
transport-testing.c
libgnunettransporttesting_la_LIBADD = \
$(top_builddir)/src/transport/libgnunettransport.la \
$(top_builddir)/src/hello/libgnunethello.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
- $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/util/libgnunetutil.la
test_transport_startonly_SOURCES = \
$(top_builddir)/src/transport/libgnunettransport.la \
$(top_builddir)/src/hello/libgnunethello.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
- $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/util/libgnunetutil.la \
$(top_builddir)/src/transport/libgnunettransporttesting.la
-lglpk \
$(top_builddir)/src/transport/libgnunettransport.la \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
- $(top_builddir)/src/testing/libgnunettesting.la \
$(top_builddir)/src/util/libgnunetutil.la
test_transport_ats_multiple_peers_SOURCES = \
if (n == NULL)
{
GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, "transmit_send_continuation",
- "Neighbour `%s' no longer exists\n", GNUNET_i2s (&mq->neighbour_id));
+ "Neighbour `%s' no longer exists\n",
+ GNUNET_i2s (&mq->neighbour_id));
return;
}
if (mq->client != NULL)
size_t addrlen;
/**
- * When passing the address in 'add_valid_peer_address', did we
+ * When passing the address in 'add_valid_peer_address', did we
* copy the address to the HELLO yet?
*/
int copied;
struct ValidationEntry *ve = cls;
if (GNUNET_YES == ve->copied)
- return 0; /* terminate */
+ return 0; /* terminate */
ve->copied = GNUNET_YES;
return GNUNET_HELLO_add_address (ve->transport_name, ve->valid_until,
ve->addr, ve->addrlen, buf, max);
GNUNET_SCHEDULER_cancel (tct);
tct = GNUNET_SCHEDULER_NO_TASK;
}
- GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, &p2);
- GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1);
+ GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
+ GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
if (is_asymmetric_send_constant == GNUNET_YES)
measure (MEASUREMENT_MIN_QUOTA, MEASUREMENT_MAX_QUOTA);
else if (is_asymmetric_recv_constant == GNUNET_YES)
GNUNET_assert (p1.th != NULL);
GNUNET_assert (p2.th != NULL);
- GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1);
- GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
+ p1.ghh = GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1);
+ p2.ghh = GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
tct = GNUNET_SCHEDULER_add_now (&try_connect, NULL);
}
}
else
{
- GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, &p2);
- GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1);
+ GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
+ GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
}
GNUNET_TRANSPORT_disconnect (p1.th);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from Transport \n");
- GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, &p2);
- GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1);
+ GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
+ GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
GNUNET_TRANSPORT_disconnect (p1.th);
p1.th = NULL;
GNUNET_assert (p1.th != NULL);
GNUNET_assert (p2.th != NULL);
- GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1);
- GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
+ p1.ghh = GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1);
+ p2.ghh = GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
tct = GNUNET_SCHEDULER_add_now (&try_connect, NULL);
}
GNUNET_SCHEDULER_TaskIdentifier tct;
GNUNET_TRANSPORT_TESTING_connect_cb cb;
void *cb_cls;
-
struct GNUNET_TRANSPORT_Handle *th_p1;
struct GNUNET_TRANSPORT_Handle *th_p2;
int p1_c;
if ((cc->p2_c == GNUNET_YES) && (cc->p2_c == GNUNET_YES))
{
/* clean up */
- GNUNET_TRANSPORT_get_hello_cancel (cc->th_p2, &exchange_hello_last, cc);
- GNUNET_TRANSPORT_get_hello_cancel (cc->th_p1, &exchange_hello, cc);
+ GNUNET_TRANSPORT_get_hello_cancel (cc->p1->ghh);
+ GNUNET_TRANSPORT_get_hello_cancel (cc->p2->ghh);
if (cc->tct != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (cc->tct);
GNUNET_assert (cc->th_p1 != NULL);
GNUNET_assert (cc->th_p2 != NULL);
- GNUNET_TRANSPORT_get_hello (cc->th_p1, &exchange_hello, cc);
- GNUNET_TRANSPORT_get_hello (cc->th_p2, &exchange_hello_last, cc);
+ p1->ghh = GNUNET_TRANSPORT_get_hello (cc->th_p1, &exchange_hello, cc);
+ p2->ghh = GNUNET_TRANSPORT_get_hello (cc->th_p2, &exchange_hello_last, cc);
cc->tct = GNUNET_SCHEDULER_add_now (&try_connect, cc);
return cc;
struct ConnectingContext *cc = ccr;
/* clean up */
- GNUNET_TRANSPORT_get_hello_cancel (cc->th_p2, &exchange_hello_last, cc);
- GNUNET_TRANSPORT_get_hello_cancel (cc->th_p1, &exchange_hello, cc);
+ GNUNET_TRANSPORT_get_hello_cancel (cc->p1->ghh);
+ GNUNET_TRANSPORT_get_hello_cancel (cc->p2->ghh);
if (cc->tct != GNUNET_SCHEDULER_NO_TASK)
GNUNET_SCHEDULER_cancel (cc->tct);
struct GNUNET_TRANSPORT_Handle *th;
+ struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
+
struct GNUNET_PeerIdentity id;
struct GNUNET_OS_Process *arm_proc;
/**
* Linked list of functions to call whenever our HELLO is updated.
*/
-struct HelloWaitList
+struct GNUNET_TRANSPORT_GetHelloHandle
{
/**
* This is a doubly linked list.
*/
- struct HelloWaitList *next;
+ struct GNUNET_TRANSPORT_GetHelloHandle *next;
/**
* This is a doubly linked list.
*/
- struct HelloWaitList *prev;
+ struct GNUNET_TRANSPORT_GetHelloHandle *prev;
+
+ /**
+ * Transport handle.
+ */
+ struct GNUNET_TRANSPORT_Handle *handle;
/**
* Callback to call once we got our HELLO.
/**
* Linked list of pending requests for our HELLO.
*/
- struct HelloWaitList *hwl_head;
+ struct GNUNET_TRANSPORT_GetHelloHandle *hwl_head;
/**
* Linked list of pending requests for our HELLO.
*/
- struct HelloWaitList *hwl_tail;
+ struct GNUNET_TRANSPORT_GetHelloHandle *hwl_tail;
/**
* My configuration.
const struct InboundMessage *im;
const struct GNUNET_MessageHeader *imm;
const struct SendOkMessage *okm;
- struct HelloWaitList *hwl;
- struct HelloWaitList *next_hwl;
+ struct GNUNET_TRANSPORT_GetHelloHandle *hwl;
+ struct GNUNET_TRANSPORT_GetHelloHandle *next_hwl;
struct Neighbour *n;
struct GNUNET_PeerIdentity me;
uint16_t size;
* (handshake with transport service pending/failed).
* cost estimate will be 0.
* @param rec_cls closure for rec
+ * @return handle to cancel the operation, NULL on error
*/
-void
+struct GNUNET_TRANSPORT_GetHelloHandle *
GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle,
GNUNET_TRANSPORT_HelloUpdateCallback rec,
void *rec_cls)
{
- struct HelloWaitList *hwl;
+ struct GNUNET_TRANSPORT_GetHelloHandle *hwl;
- hwl = GNUNET_malloc (sizeof (struct HelloWaitList));
+ if (handle->my_hello == NULL)
+ return NULL;
+ hwl = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_GetHelloHandle));
hwl->rec = rec;
hwl->rec_cls = rec_cls;
+ hwl->handle = handle;
GNUNET_CONTAINER_DLL_insert (handle->hwl_head, handle->hwl_tail, hwl);
- if (handle->my_hello == NULL)
- return;
rec (rec_cls, (const struct GNUNET_MessageHeader *) handle->my_hello);
+ return hwl;
}
/**
* Stop receiving updates about changes to our HELLO message.
*
- * @param handle connection to transport service
- * @param rec function previously registered to be called with the HELLOs
- * @param rec_cls closure for rec
+ * @param ghh handle to cancel
*/
void
-GNUNET_TRANSPORT_get_hello_cancel (struct GNUNET_TRANSPORT_Handle *handle,
- GNUNET_TRANSPORT_HelloUpdateCallback rec,
- void *rec_cls)
+GNUNET_TRANSPORT_get_hello_cancel (struct GNUNET_TRANSPORT_GetHelloHandle *ghh)
{
- struct HelloWaitList *pos;
+ struct GNUNET_TRANSPORT_Handle *handle = ghh->handle;
- pos = handle->hwl_head;
- while (pos != NULL)
- {
- if ((pos->rec == rec) && (pos->rec_cls == rec_cls))
- break;
- pos = pos->next;
- }
- GNUNET_break (pos != NULL);
- if (pos == NULL)
- return;
- GNUNET_CONTAINER_DLL_remove (handle->hwl_head, handle->hwl_tail, pos);
- GNUNET_free (pos);
+ GNUNET_CONTAINER_DLL_remove (handle->hwl_head, handle->hwl_tail, ghh);
+ GNUNET_free (ghh);
}