aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
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)
69lib_LTLIBRARIES = \ 69lib_LTLIBRARIES = \
70 libgnunettransport.la \ 70 libgnunettransport.la \
71 libgnunettransporttesting.la 71 libgnunettransporttesting.la
72 72
73libgnunettransporttesting_la_SOURCES = \ 73libgnunettransporttesting_la_SOURCES = \
74 transport-testing.c 74 transport-testing.c
75libgnunettransporttesting_la_LIBADD = \ 75libgnunettransporttesting_la_LIBADD = \
@@ -355,7 +355,6 @@ test_transport_api_disconnect_LDADD = \
355 $(top_builddir)/src/transport/libgnunettransport.la \ 355 $(top_builddir)/src/transport/libgnunettransport.la \
356 $(top_builddir)/src/hello/libgnunethello.la \ 356 $(top_builddir)/src/hello/libgnunethello.la \
357 $(top_builddir)/src/statistics/libgnunetstatistics.la \ 357 $(top_builddir)/src/statistics/libgnunetstatistics.la \
358 $(top_builddir)/src/testing/libgnunettesting.la \
359 $(top_builddir)/src/util/libgnunetutil.la 358 $(top_builddir)/src/util/libgnunetutil.la
360 359
361test_transport_startonly_SOURCES = \ 360test_transport_startonly_SOURCES = \
@@ -364,7 +363,6 @@ test_transport_startonly_LDADD = \
364 $(top_builddir)/src/transport/libgnunettransport.la \ 363 $(top_builddir)/src/transport/libgnunettransport.la \
365 $(top_builddir)/src/hello/libgnunethello.la \ 364 $(top_builddir)/src/hello/libgnunethello.la \
366 $(top_builddir)/src/statistics/libgnunetstatistics.la \ 365 $(top_builddir)/src/statistics/libgnunetstatistics.la \
367 $(top_builddir)/src/testing/libgnunettesting.la \
368 $(top_builddir)/src/util/libgnunetutil.la \ 366 $(top_builddir)/src/util/libgnunetutil.la \
369 $(top_builddir)/src/transport/libgnunettransporttesting.la 367 $(top_builddir)/src/transport/libgnunettransporttesting.la
370 368
@@ -374,7 +372,6 @@ test_transport_ats_LDADD = -lm \
374 -lglpk \ 372 -lglpk \
375 $(top_builddir)/src/transport/libgnunettransport.la \ 373 $(top_builddir)/src/transport/libgnunettransport.la \
376 $(top_builddir)/src/statistics/libgnunetstatistics.la \ 374 $(top_builddir)/src/statistics/libgnunetstatistics.la \
377 $(top_builddir)/src/testing/libgnunettesting.la \
378 $(top_builddir)/src/util/libgnunetutil.la 375 $(top_builddir)/src/util/libgnunetutil.la
379 376
380test_transport_ats_multiple_peers_SOURCES = \ 377test_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,
1616 if (n == NULL) 1616 if (n == NULL)
1617 { 1617 {
1618 GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, "transmit_send_continuation", 1618 GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, "transmit_send_continuation",
1619 "Neighbour `%s' no longer exists\n", GNUNET_i2s (&mq->neighbour_id)); 1619 "Neighbour `%s' no longer exists\n",
1620 GNUNET_i2s (&mq->neighbour_id));
1620 return; 1621 return;
1621 } 1622 }
1622 if (mq->client != NULL) 1623 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
218 size_t addrlen; 218 size_t addrlen;
219 219
220 /** 220 /**
221 * When passing the address in 'add_valid_peer_address', did we 221 * When passing the address in 'add_valid_peer_address', did we
222 * copy the address to the HELLO yet? 222 * copy the address to the HELLO yet?
223 */ 223 */
224 int copied; 224 int copied;
@@ -880,7 +880,7 @@ add_valid_peer_address (void *cls, size_t max, void *buf)
880 struct ValidationEntry *ve = cls; 880 struct ValidationEntry *ve = cls;
881 881
882 if (GNUNET_YES == ve->copied) 882 if (GNUNET_YES == ve->copied)
883 return 0; /* terminate */ 883 return 0; /* terminate */
884 ve->copied = GNUNET_YES; 884 ve->copied = GNUNET_YES;
885 return GNUNET_HELLO_add_address (ve->transport_name, ve->valid_until, 885 return GNUNET_HELLO_add_address (ve->transport_name, ve->valid_until,
886 ve->addr, ve->addrlen, buf, max); 886 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,
601 GNUNET_SCHEDULER_cancel (tct); 601 GNUNET_SCHEDULER_cancel (tct);
602 tct = GNUNET_SCHEDULER_NO_TASK; 602 tct = GNUNET_SCHEDULER_NO_TASK;
603 } 603 }
604 GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, &p2); 604 GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
605 GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1); 605 GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
606 if (is_asymmetric_send_constant == GNUNET_YES) 606 if (is_asymmetric_send_constant == GNUNET_YES)
607 measure (MEASUREMENT_MIN_QUOTA, MEASUREMENT_MAX_QUOTA); 607 measure (MEASUREMENT_MIN_QUOTA, MEASUREMENT_MAX_QUOTA);
608 else if (is_asymmetric_recv_constant == GNUNET_YES) 608 else if (is_asymmetric_recv_constant == GNUNET_YES)
@@ -776,8 +776,8 @@ run (void *cls, char *const *args, const char *cfgfile,
776 776
777 GNUNET_assert (p1.th != NULL); 777 GNUNET_assert (p1.th != NULL);
778 GNUNET_assert (p2.th != NULL); 778 GNUNET_assert (p2.th != NULL);
779 GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1); 779 p1.ghh = GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1);
780 GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2); 780 p2.ghh = GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
781 tct = GNUNET_SCHEDULER_add_now (&try_connect, NULL); 781 tct = GNUNET_SCHEDULER_add_now (&try_connect, NULL);
782} 782}
783 783
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 ()
170 } 170 }
171 else 171 else
172 { 172 {
173 GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, &p2); 173 GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
174 GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1); 174 GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
175 } 175 }
176 176
177 GNUNET_TRANSPORT_disconnect (p1.th); 177 GNUNET_TRANSPORT_disconnect (p1.th);
@@ -314,8 +314,8 @@ peers_disconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
314 314
315 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from Transport \n"); 315 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from Transport \n");
316 316
317 GNUNET_TRANSPORT_get_hello_cancel (p2.th, &exchange_hello_last, &p2); 317 GNUNET_TRANSPORT_get_hello_cancel (p2.ghh);
318 GNUNET_TRANSPORT_get_hello_cancel (p1.th, &exchange_hello, &p1); 318 GNUNET_TRANSPORT_get_hello_cancel (p1.ghh);
319 319
320 GNUNET_TRANSPORT_disconnect (p1.th); 320 GNUNET_TRANSPORT_disconnect (p1.th);
321 p1.th = NULL; 321 p1.th = NULL;
@@ -358,8 +358,8 @@ peers_connect ()
358 GNUNET_assert (p1.th != NULL); 358 GNUNET_assert (p1.th != NULL);
359 GNUNET_assert (p2.th != NULL); 359 GNUNET_assert (p2.th != NULL);
360 360
361 GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1); 361 p1.ghh = GNUNET_TRANSPORT_get_hello (p1.th, &exchange_hello, &p1);
362 GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2); 362 p2.ghh = GNUNET_TRANSPORT_get_hello (p2.th, &exchange_hello_last, &p2);
363 tct = GNUNET_SCHEDULER_add_now (&try_connect, NULL); 363 tct = GNUNET_SCHEDULER_add_now (&try_connect, NULL);
364} 364}
365 365
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
34 GNUNET_SCHEDULER_TaskIdentifier tct; 34 GNUNET_SCHEDULER_TaskIdentifier tct;
35 GNUNET_TRANSPORT_TESTING_connect_cb cb; 35 GNUNET_TRANSPORT_TESTING_connect_cb cb;
36 void *cb_cls; 36 void *cb_cls;
37
38 struct GNUNET_TRANSPORT_Handle *th_p1; 37 struct GNUNET_TRANSPORT_Handle *th_p1;
39 struct GNUNET_TRANSPORT_Handle *th_p2; 38 struct GNUNET_TRANSPORT_Handle *th_p2;
40 int p1_c; 39 int p1_c;
@@ -73,8 +72,8 @@ notify_connect_internal (void *cls, const struct GNUNET_PeerIdentity *peer,
73 if ((cc->p2_c == GNUNET_YES) && (cc->p2_c == GNUNET_YES)) 72 if ((cc->p2_c == GNUNET_YES) && (cc->p2_c == GNUNET_YES))
74 { 73 {
75 /* clean up */ 74 /* clean up */
76 GNUNET_TRANSPORT_get_hello_cancel (cc->th_p2, &exchange_hello_last, cc); 75 GNUNET_TRANSPORT_get_hello_cancel (cc->p1->ghh);
77 GNUNET_TRANSPORT_get_hello_cancel (cc->th_p1, &exchange_hello, cc); 76 GNUNET_TRANSPORT_get_hello_cancel (cc->p2->ghh);
78 77
79 if (cc->tct != GNUNET_SCHEDULER_NO_TASK) 78 if (cc->tct != GNUNET_SCHEDULER_NO_TASK)
80 GNUNET_SCHEDULER_cancel (cc->tct); 79 GNUNET_SCHEDULER_cancel (cc->tct);
@@ -315,8 +314,8 @@ GNUNET_TRANSPORT_TESTING_connect_peers (struct PeerContext *p1,
315 GNUNET_assert (cc->th_p1 != NULL); 314 GNUNET_assert (cc->th_p1 != NULL);
316 GNUNET_assert (cc->th_p2 != NULL); 315 GNUNET_assert (cc->th_p2 != NULL);
317 316
318 GNUNET_TRANSPORT_get_hello (cc->th_p1, &exchange_hello, cc); 317 p1->ghh = GNUNET_TRANSPORT_get_hello (cc->th_p1, &exchange_hello, cc);
319 GNUNET_TRANSPORT_get_hello (cc->th_p2, &exchange_hello_last, cc); 318 p2->ghh = GNUNET_TRANSPORT_get_hello (cc->th_p2, &exchange_hello_last, cc);
320 319
321 cc->tct = GNUNET_SCHEDULER_add_now (&try_connect, cc); 320 cc->tct = GNUNET_SCHEDULER_add_now (&try_connect, cc);
322 return cc; 321 return cc;
@@ -333,8 +332,8 @@ void GNUNET_TRANSPORT_TESTING_connect_peers_cancel
333 struct ConnectingContext *cc = ccr; 332 struct ConnectingContext *cc = ccr;
334 333
335 /* clean up */ 334 /* clean up */
336 GNUNET_TRANSPORT_get_hello_cancel (cc->th_p2, &exchange_hello_last, cc); 335 GNUNET_TRANSPORT_get_hello_cancel (cc->p1->ghh);
337 GNUNET_TRANSPORT_get_hello_cancel (cc->th_p1, &exchange_hello, cc); 336 GNUNET_TRANSPORT_get_hello_cancel (cc->p2->ghh);
338 337
339 if (cc->tct != GNUNET_SCHEDULER_NO_TASK) 338 if (cc->tct != GNUNET_SCHEDULER_NO_TASK)
340 GNUNET_SCHEDULER_cancel (cc->tct); 339 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
44 44
45 struct GNUNET_TRANSPORT_Handle *th; 45 struct GNUNET_TRANSPORT_Handle *th;
46 46
47 struct GNUNET_TRANSPORT_GetHelloHandle *ghh;
48
47 struct GNUNET_PeerIdentity id; 49 struct GNUNET_PeerIdentity id;
48 50
49 struct GNUNET_OS_Process *arm_proc; 51 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
150/** 150/**
151 * Linked list of functions to call whenever our HELLO is updated. 151 * Linked list of functions to call whenever our HELLO is updated.
152 */ 152 */
153struct HelloWaitList 153struct GNUNET_TRANSPORT_GetHelloHandle
154{ 154{
155 155
156 /** 156 /**
157 * This is a doubly linked list. 157 * This is a doubly linked list.
158 */ 158 */
159 struct HelloWaitList *next; 159 struct GNUNET_TRANSPORT_GetHelloHandle *next;
160 160
161 /** 161 /**
162 * This is a doubly linked list. 162 * This is a doubly linked list.
163 */ 163 */
164 struct HelloWaitList *prev; 164 struct GNUNET_TRANSPORT_GetHelloHandle *prev;
165
166 /**
167 * Transport handle.
168 */
169 struct GNUNET_TRANSPORT_Handle *handle;
165 170
166 /** 171 /**
167 * Callback to call once we got our HELLO. 172 * Callback to call once we got our HELLO.
@@ -232,12 +237,12 @@ struct GNUNET_TRANSPORT_Handle
232 /** 237 /**
233 * Linked list of pending requests for our HELLO. 238 * Linked list of pending requests for our HELLO.
234 */ 239 */
235 struct HelloWaitList *hwl_head; 240 struct GNUNET_TRANSPORT_GetHelloHandle *hwl_head;
236 241
237 /** 242 /**
238 * Linked list of pending requests for our HELLO. 243 * Linked list of pending requests for our HELLO.
239 */ 244 */
240 struct HelloWaitList *hwl_tail; 245 struct GNUNET_TRANSPORT_GetHelloHandle *hwl_tail;
241 246
242 /** 247 /**
243 * My configuration. 248 * My configuration.
@@ -397,8 +402,8 @@ demultiplexer (void *cls, const struct GNUNET_MessageHeader *msg)
397 const struct InboundMessage *im; 402 const struct InboundMessage *im;
398 const struct GNUNET_MessageHeader *imm; 403 const struct GNUNET_MessageHeader *imm;
399 const struct SendOkMessage *okm; 404 const struct SendOkMessage *okm;
400 struct HelloWaitList *hwl; 405 struct GNUNET_TRANSPORT_GetHelloHandle *hwl;
401 struct HelloWaitList *next_hwl; 406 struct GNUNET_TRANSPORT_GetHelloHandle *next_hwl;
402 struct Neighbour *n; 407 struct Neighbour *n;
403 struct GNUNET_PeerIdentity me; 408 struct GNUNET_PeerIdentity me;
404 uint16_t size; 409 uint16_t size;
@@ -1189,50 +1194,39 @@ GNUNET_TRANSPORT_offer_hello (struct GNUNET_TRANSPORT_Handle *handle,
1189 * (handshake with transport service pending/failed). 1194 * (handshake with transport service pending/failed).
1190 * cost estimate will be 0. 1195 * cost estimate will be 0.
1191 * @param rec_cls closure for rec 1196 * @param rec_cls closure for rec
1197 * @return handle to cancel the operation, NULL on error
1192 */ 1198 */
1193void 1199struct GNUNET_TRANSPORT_GetHelloHandle *
1194GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle, 1200GNUNET_TRANSPORT_get_hello (struct GNUNET_TRANSPORT_Handle *handle,
1195 GNUNET_TRANSPORT_HelloUpdateCallback rec, 1201 GNUNET_TRANSPORT_HelloUpdateCallback rec,
1196 void *rec_cls) 1202 void *rec_cls)
1197{ 1203{
1198 struct HelloWaitList *hwl; 1204 struct GNUNET_TRANSPORT_GetHelloHandle *hwl;
1199 1205
1200 hwl = GNUNET_malloc (sizeof (struct HelloWaitList)); 1206 if (handle->my_hello == NULL)
1207 return NULL;
1208 hwl = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_GetHelloHandle));
1201 hwl->rec = rec; 1209 hwl->rec = rec;
1202 hwl->rec_cls = rec_cls; 1210 hwl->rec_cls = rec_cls;
1211 hwl->handle = handle;
1203 GNUNET_CONTAINER_DLL_insert (handle->hwl_head, handle->hwl_tail, hwl); 1212 GNUNET_CONTAINER_DLL_insert (handle->hwl_head, handle->hwl_tail, hwl);
1204 if (handle->my_hello == NULL)
1205 return;
1206 rec (rec_cls, (const struct GNUNET_MessageHeader *) handle->my_hello); 1213 rec (rec_cls, (const struct GNUNET_MessageHeader *) handle->my_hello);
1214 return hwl;
1207} 1215}
1208 1216
1209 1217
1210/** 1218/**
1211 * Stop receiving updates about changes to our HELLO message. 1219 * Stop receiving updates about changes to our HELLO message.
1212 * 1220 *
1213 * @param handle connection to transport service 1221 * @param ghh handle to cancel
1214 * @param rec function previously registered to be called with the HELLOs
1215 * @param rec_cls closure for rec
1216 */ 1222 */
1217void 1223void
1218GNUNET_TRANSPORT_get_hello_cancel (struct GNUNET_TRANSPORT_Handle *handle, 1224GNUNET_TRANSPORT_get_hello_cancel (struct GNUNET_TRANSPORT_GetHelloHandle *ghh)
1219 GNUNET_TRANSPORT_HelloUpdateCallback rec,
1220 void *rec_cls)
1221{ 1225{
1222 struct HelloWaitList *pos; 1226 struct GNUNET_TRANSPORT_Handle *handle = ghh->handle;
1223 1227
1224 pos = handle->hwl_head; 1228 GNUNET_CONTAINER_DLL_remove (handle->hwl_head, handle->hwl_tail, ghh);
1225 while (pos != NULL) 1229 GNUNET_free (ghh);
1226 {
1227 if ((pos->rec == rec) && (pos->rec_cls == rec_cls))
1228 break;
1229 pos = pos->next;
1230 }
1231 GNUNET_break (pos != NULL);
1232 if (pos == NULL)
1233 return;
1234 GNUNET_CONTAINER_DLL_remove (handle->hwl_head, handle->hwl_tail, pos);
1235 GNUNET_free (pos);
1236} 1230}
1237 1231
1238 1232