summaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-09-02 11:21:00 +0000
committerChristian Grothoff <christian@grothoff.org>2011-09-02 11:21:00 +0000
commit147d72a99e4ed0558c98fe7c9c41062ede51a68a (patch)
treef712c8aa222e53dc3e299972f3144ad92b15b180 /src/transport
parent8439fe12f24ab3ae5a1821face2b79d443fa044e (diff)
cleanup API for get_hello and get_hello_cancel
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/Makefile.am5
-rw-r--r--src/transport/gnunet-service-transport.c3
-rw-r--r--src/transport/gnunet-service-transport_validation.c4
-rw-r--r--src/transport/test_quota_compliance.c8
-rw-r--r--src/transport/test_transport_api_disconnect.c12
-rw-r--r--src/transport/transport-testing.c13
-rw-r--r--src/transport/transport-testing.h2
-rw-r--r--src/transport/transport_api.c56
8 files changed, 48 insertions, 55 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am
index bfe717958..c9bc8c440 100644
--- a/src/transport/Makefile.am
+++ b/src/transport/Makefile.am
@@ -69,7 +69,7 @@ noinst_PROGRAMS = $(WLAN_BIN_DUMMY)
lib_LTLIBRARIES = \
libgnunettransport.la \
libgnunettransporttesting.la
-
+
libgnunettransporttesting_la_SOURCES = \
transport-testing.c
libgnunettransporttesting_la_LIBADD = \
@@ -355,7 +355,6 @@ test_transport_api_disconnect_LDADD = \
$(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 = \
@@ -364,7 +363,6 @@ test_transport_startonly_LDADD = \
$(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
@@ -374,7 +372,6 @@ test_transport_ats_LDADD = -lm \
-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 = \
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index 5bf3c4c77..74ff1749c 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -1616,7 +1616,8 @@ transmit_send_continuation (void *cls, const struct GNUNET_PeerIdentity *target,
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)
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c
index a79803afc..654bf52b8 100644
--- a/src/transport/gnunet-service-transport_validation.c
+++ b/src/transport/gnunet-service-transport_validation.c
@@ -218,7 +218,7 @@ struct ValidationEntry
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;
@@ -880,7 +880,7 @@ add_valid_peer_address (void *cls, size_t max, void *buf)
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);
diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c
index 71332bf36..63bd7da02 100644
--- a/src/transport/test_quota_compliance.c
+++ b/src/transport/test_quota_compliance.c
@@ -601,8 +601,8 @@ notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer,
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)
@@ -776,8 +776,8 @@ run (void *cls, char *const *args, const char *cfgfile,
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);
}
diff --git a/src/transport/test_transport_api_disconnect.c b/src/transport/test_transport_api_disconnect.c
index 540d3b729..a96a1a152 100644
--- a/src/transport/test_transport_api_disconnect.c
+++ b/src/transport/test_transport_api_disconnect.c
@@ -170,8 +170,8 @@ end_badly ()
}
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);
@@ -314,8 +314,8 @@ peers_disconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
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;
@@ -358,8 +358,8 @@ peers_connect ()
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);
}
diff --git a/src/transport/transport-testing.c b/src/transport/transport-testing.c
index 02bab07f4..e604c5961 100644
--- a/src/transport/transport-testing.c
+++ b/src/transport/transport-testing.c
@@ -34,7 +34,6 @@ struct ConnectingContext
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;
@@ -73,8 +72,8 @@ notify_connect_internal (void *cls, const struct GNUNET_PeerIdentity *peer,
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);
@@ -315,8 +314,8 @@ GNUNET_TRANSPORT_TESTING_connect_peers (struct PeerContext *p1,
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;
@@ -333,8 +332,8 @@ void GNUNET_TRANSPORT_TESTING_connect_peers_cancel
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);
diff --git a/src/transport/transport-testing.h b/src/transport/transport-testing.h
index 852f060e4..80eae3630 100644
--- a/src/transport/transport-testing.h
+++ b/src/transport/transport-testing.h
@@ -44,6 +44,8 @@ struct PeerContext
struct GNUNET_TRANSPORT_Handle *th;
+ struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
+
struct GNUNET_PeerIdentity id;
struct GNUNET_OS_Process *arm_proc;
diff --git a/src/transport/transport_api.c b/src/transport/transport_api.c
index a6d2fa0ba..bbfe1e63d 100644
--- a/src/transport/transport_api.c
+++ b/src/transport/transport_api.c
@@ -150,18 +150,23 @@ struct Neighbour
/**
* 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.
@@ -232,12 +237,12 @@ struct GNUNET_TRANSPORT_Handle
/**
* 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.
@@ -397,8 +402,8 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
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;
@@ -1189,50 +1194,39 @@ GNUNET_TRANSPORT_offer_hello (struct GNUNET_TRANSPORT_Handle *handle,
* (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);
}