diff options
Diffstat (limited to 'src/nat/nat_test.c')
-rw-r--r-- | src/nat/nat_test.c | 289 |
1 files changed, 124 insertions, 165 deletions
diff --git a/src/nat/nat_test.c b/src/nat/nat_test.c index 8c9933cdb..30db00803 100644 --- a/src/nat/nat_test.c +++ b/src/nat/nat_test.c | |||
@@ -99,7 +99,7 @@ struct GNUNET_NAT_Test | |||
99 | * Function to call with success report | 99 | * Function to call with success report |
100 | */ | 100 | */ |
101 | GNUNET_NAT_TestCallback report; | 101 | GNUNET_NAT_TestCallback report; |
102 | 102 | ||
103 | /** | 103 | /** |
104 | * Closure for 'report'. | 104 | * Closure for 'report'. |
105 | */ | 105 | */ |
@@ -167,9 +167,7 @@ struct GNUNET_NAT_Test | |||
167 | * @param addrlen actual lenght of the address | 167 | * @param addrlen actual lenght of the address |
168 | */ | 168 | */ |
169 | static void | 169 | static void |
170 | reversal_cb (void *cls, | 170 | reversal_cb (void *cls, const struct sockaddr *addr, socklen_t addrlen) |
171 | const struct sockaddr *addr, | ||
172 | socklen_t addrlen) | ||
173 | { | 171 | { |
174 | struct GNUNET_NAT_Test *h = cls; | 172 | struct GNUNET_NAT_Test *h = cls; |
175 | const struct sockaddr_in *sa; | 173 | const struct sockaddr_in *sa; |
@@ -178,14 +176,14 @@ reversal_cb (void *cls, | |||
178 | return; | 176 | return; |
179 | sa = (const struct sockaddr_in *) addr; | 177 | sa = (const struct sockaddr_in *) addr; |
180 | if (h->data != sa->sin_port) | 178 | if (h->data != sa->sin_port) |
181 | { | 179 | { |
182 | #if DEBUG_NAT | 180 | #if DEBUG_NAT |
183 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 181 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
184 | "nat", | 182 | "nat", |
185 | "Received connection reversal request for wrong port\n"); | 183 | "Received connection reversal request for wrong port\n"); |
186 | #endif | 184 | #endif |
187 | return; /* wrong port */ | 185 | return; /* wrong port */ |
188 | } | 186 | } |
189 | /* report success */ | 187 | /* report success */ |
190 | h->report (h->report_cls, GNUNET_OK); | 188 | h->report (h->report_cls, GNUNET_OK); |
191 | } | 189 | } |
@@ -199,38 +197,31 @@ reversal_cb (void *cls, | |||
199 | * @param tc scheduler context | 197 | * @param tc scheduler context |
200 | */ | 198 | */ |
201 | static void | 199 | static void |
202 | do_udp_read (void *cls, | 200 | do_udp_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
203 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
204 | { | 201 | { |
205 | struct GNUNET_NAT_Test *tst = cls; | 202 | struct GNUNET_NAT_Test *tst = cls; |
206 | uint16_t data; | 203 | uint16_t data; |
207 | 204 | ||
208 | tst->ltask = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | 205 | tst->ltask = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
209 | tst->lsock, | 206 | tst->lsock, &do_udp_read, tst); |
210 | &do_udp_read, | 207 | if ((NULL != tc->write_ready) && |
211 | tst); | 208 | (GNUNET_NETWORK_fdset_isset (tc->read_ready, |
212 | if ( (NULL != tc->write_ready) && | 209 | tst->lsock)) && |
213 | (GNUNET_NETWORK_fdset_isset (tc->read_ready, | 210 | (sizeof (data) == |
214 | tst->lsock)) && | 211 | GNUNET_NETWORK_socket_recv (tst->lsock, &data, sizeof (data)))) |
215 | (sizeof (data) == | 212 | { |
216 | GNUNET_NETWORK_socket_recv (tst->lsock, | 213 | if (data == tst->data) |
217 | &data, | 214 | tst->report (tst->report_cls, GNUNET_OK); |
218 | sizeof (data))) ) | ||
219 | { | ||
220 | if (data == tst->data) | ||
221 | tst->report (tst->report_cls, GNUNET_OK); | ||
222 | #if DEBUG_NAT | 215 | #if DEBUG_NAT |
223 | else | 216 | else |
224 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 217 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
225 | "nat", | 218 | "nat", "Received data mismatches expected value\n"); |
226 | "Received data mismatches expected value\n"); | ||
227 | #endif | 219 | #endif |
228 | } | 220 | } |
229 | #if DEBUG_NAT | 221 | #if DEBUG_NAT |
230 | else | 222 | else |
231 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 223 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
232 | "nat", | 224 | "nat", "Failed to receive data from inbound connection\n"); |
233 | "Failed to receive data from inbound connection\n"); | ||
234 | #endif | 225 | #endif |
235 | } | 226 | } |
236 | 227 | ||
@@ -243,8 +234,7 @@ do_udp_read (void *cls, | |||
243 | * @param tc scheduler context | 234 | * @param tc scheduler context |
244 | */ | 235 | */ |
245 | static void | 236 | static void |
246 | do_read (void *cls, | 237 | do_read (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
247 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
248 | { | 238 | { |
249 | struct NatActivity *na = cls; | 239 | struct NatActivity *na = cls; |
250 | struct GNUNET_NAT_Test *tst; | 240 | struct GNUNET_NAT_Test *tst; |
@@ -252,31 +242,25 @@ do_read (void *cls, | |||
252 | 242 | ||
253 | na->rtask = GNUNET_SCHEDULER_NO_TASK; | 243 | na->rtask = GNUNET_SCHEDULER_NO_TASK; |
254 | tst = na->h; | 244 | tst = na->h; |
255 | GNUNET_CONTAINER_DLL_remove (tst->na_head, | 245 | GNUNET_CONTAINER_DLL_remove (tst->na_head, tst->na_tail, na); |
256 | tst->na_tail, | 246 | if ((NULL != tc->write_ready) && |
257 | na); | 247 | (GNUNET_NETWORK_fdset_isset (tc->read_ready, |
258 | if ( (NULL != tc->write_ready) && | 248 | na->sock)) && |
259 | (GNUNET_NETWORK_fdset_isset (tc->read_ready, | 249 | (sizeof (data) == |
260 | na->sock)) && | 250 | GNUNET_NETWORK_socket_recv (na->sock, &data, sizeof (data)))) |
261 | (sizeof (data) == | 251 | { |
262 | GNUNET_NETWORK_socket_recv (na->sock, | 252 | if (data == tst->data) |
263 | &data, | 253 | tst->report (tst->report_cls, GNUNET_OK); |
264 | sizeof (data))) ) | ||
265 | { | ||
266 | if (data == tst->data) | ||
267 | tst->report (tst->report_cls, GNUNET_OK); | ||
268 | #if DEBUG_NAT | 254 | #if DEBUG_NAT |
269 | else | 255 | else |
270 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 256 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
271 | "nat" | 257 | "nat" "Received data mismatches expected value\n"); |
272 | "Received data mismatches expected value\n"); | ||
273 | #endif | 258 | #endif |
274 | } | 259 | } |
275 | #if DEBUG_NAT | 260 | #if DEBUG_NAT |
276 | else | 261 | else |
277 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 262 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
278 | "nat", | 263 | "nat", "Failed to receive data from inbound connection\n"); |
279 | "Failed to receive data from inbound connection\n"); | ||
280 | #endif | 264 | #endif |
281 | GNUNET_NETWORK_socket_close (na->sock); | 265 | GNUNET_NETWORK_socket_close (na->sock); |
282 | GNUNET_free (na); | 266 | GNUNET_free (na); |
@@ -291,8 +275,7 @@ do_read (void *cls, | |||
291 | * @param tc scheduler context | 275 | * @param tc scheduler context |
292 | */ | 276 | */ |
293 | static void | 277 | static void |
294 | do_accept (void *cls, | 278 | do_accept (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
295 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
296 | { | 279 | { |
297 | struct GNUNET_NAT_Test *tst = cls; | 280 | struct GNUNET_NAT_Test *tst = cls; |
298 | struct GNUNET_NETWORK_Handle *s; | 281 | struct GNUNET_NETWORK_Handle *s; |
@@ -300,32 +283,25 @@ do_accept (void *cls, | |||
300 | 283 | ||
301 | tst->ltask = GNUNET_SCHEDULER_NO_TASK; | 284 | tst->ltask = GNUNET_SCHEDULER_NO_TASK; |
302 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 285 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
303 | return; | 286 | return; |
304 | tst->ltask = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | 287 | tst->ltask = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
305 | tst->lsock, | 288 | tst->lsock, &do_accept, tst); |
306 | &do_accept, | ||
307 | tst); | ||
308 | s = GNUNET_NETWORK_socket_accept (tst->lsock, NULL, NULL); | 289 | s = GNUNET_NETWORK_socket_accept (tst->lsock, NULL, NULL); |
309 | if (NULL == s) | 290 | if (NULL == s) |
310 | { | 291 | { |
311 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_INFO, "accept"); | 292 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_INFO, "accept"); |
312 | return; /* odd error */ | 293 | return; /* odd error */ |
313 | } | 294 | } |
314 | #if DEBUG_NAT | 295 | #if DEBUG_NAT |
315 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 296 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
316 | "nat", | 297 | "nat", "Got an inbound connection, waiting for data\n"); |
317 | "Got an inbound connection, waiting for data\n"); | ||
318 | #endif | 298 | #endif |
319 | wl = GNUNET_malloc (sizeof (struct NatActivity)); | 299 | wl = GNUNET_malloc (sizeof (struct NatActivity)); |
320 | wl->sock = s; | 300 | wl->sock = s; |
321 | wl->h = tst; | 301 | wl->h = tst; |
322 | wl->rtask = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | 302 | wl->rtask = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
323 | wl->sock, | 303 | wl->sock, &do_read, wl); |
324 | &do_read, | 304 | GNUNET_CONTAINER_DLL_insert (tst->na_head, tst->na_tail, wl); |
325 | wl); | ||
326 | GNUNET_CONTAINER_DLL_insert (tst->na_head, | ||
327 | tst->na_tail, | ||
328 | wl); | ||
329 | } | 305 | } |
330 | 306 | ||
331 | 307 | ||
@@ -338,11 +314,9 @@ do_accept (void *cls, | |||
338 | * @param addr either the previous or the new public IP address | 314 | * @param addr either the previous or the new public IP address |
339 | * @param addrlen actual lenght of the address | 315 | * @param addrlen actual lenght of the address |
340 | */ | 316 | */ |
341 | static void | 317 | static void |
342 | addr_cb (void *cls, | 318 | addr_cb (void *cls, |
343 | int add_remove, | 319 | int add_remove, const struct sockaddr *addr, socklen_t addrlen) |
344 | const struct sockaddr *addr, | ||
345 | socklen_t addrlen) | ||
346 | { | 320 | { |
347 | struct GNUNET_NAT_Test *h = cls; | 321 | struct GNUNET_NAT_Test *h = cls; |
348 | struct ClientActivity *ca; | 322 | struct ClientActivity *ca; |
@@ -353,40 +327,37 @@ addr_cb (void *cls, | |||
353 | if (GNUNET_YES != add_remove) | 327 | if (GNUNET_YES != add_remove) |
354 | return; | 328 | return; |
355 | if (addrlen != sizeof (struct sockaddr_in)) | 329 | if (addrlen != sizeof (struct sockaddr_in)) |
356 | return; /* ignore IPv6 here */ | 330 | return; /* ignore IPv6 here */ |
357 | #if DEBUG_NAT | 331 | #if DEBUG_NAT |
358 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 332 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, |
359 | "nat", | 333 | "nat", |
360 | "Asking gnunet-nat-server to connect to `%s'\n", | 334 | "Asking gnunet-nat-server to connect to `%s'\n", |
361 | GNUNET_a2s (addr, addrlen)); | 335 | GNUNET_a2s (addr, addrlen)); |
362 | #endif | 336 | #endif |
363 | sa = (const struct sockaddr_in*) addr; | 337 | sa = (const struct sockaddr_in *) addr; |
364 | msg.header.size = htons (sizeof(struct GNUNET_NAT_TestMessage)); | 338 | msg.header.size = htons (sizeof (struct GNUNET_NAT_TestMessage)); |
365 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_NAT_TEST); | 339 | msg.header.type = htons (GNUNET_MESSAGE_TYPE_NAT_TEST); |
366 | msg.dst_ipv4 = sa->sin_addr.s_addr; | 340 | msg.dst_ipv4 = sa->sin_addr.s_addr; |
367 | msg.dport = sa->sin_port; | 341 | msg.dport = sa->sin_port; |
368 | msg.data = h->data; | 342 | msg.data = h->data; |
369 | msg.is_tcp = htonl ((uint32_t) h->is_tcp); | 343 | msg.is_tcp = htonl ((uint32_t) h->is_tcp); |
370 | 344 | ||
371 | client = GNUNET_CLIENT_connect ("gnunet-nat-server", | 345 | client = GNUNET_CLIENT_connect ("gnunet-nat-server", h->cfg); |
372 | h->cfg); | ||
373 | if (NULL == client) | 346 | if (NULL == client) |
374 | { | 347 | { |
375 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 348 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
376 | _("Failed to connect to `gnunet-nat-server'\n")); | 349 | _("Failed to connect to `gnunet-nat-server'\n")); |
377 | return; | 350 | return; |
378 | } | 351 | } |
379 | ca = GNUNET_malloc (sizeof (struct ClientActivity)); | 352 | ca = GNUNET_malloc (sizeof (struct ClientActivity)); |
380 | ca->client = client; | 353 | ca->client = client; |
381 | GNUNET_CONTAINER_DLL_insert (h->ca_head, | 354 | GNUNET_CONTAINER_DLL_insert (h->ca_head, h->ca_tail, ca); |
382 | h->ca_tail, | ||
383 | ca); | ||
384 | GNUNET_break (GNUNET_OK == | 355 | GNUNET_break (GNUNET_OK == |
385 | GNUNET_CLIENT_transmit_and_get_response (client, | 356 | GNUNET_CLIENT_transmit_and_get_response (client, |
386 | &msg.header, | 357 | &msg.header, |
387 | GNUNET_TIME_UNIT_SECONDS, | 358 | GNUNET_TIME_UNIT_SECONDS, |
388 | GNUNET_YES, | 359 | GNUNET_YES, |
389 | NULL, NULL)); | 360 | NULL, NULL)); |
390 | } | 361 | } |
391 | 362 | ||
392 | 363 | ||
@@ -404,15 +375,14 @@ addr_cb (void *cls, | |||
404 | */ | 375 | */ |
405 | struct GNUNET_NAT_Test * | 376 | struct GNUNET_NAT_Test * |
406 | GNUNET_NAT_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | 377 | GNUNET_NAT_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, |
407 | int is_tcp, | 378 | int is_tcp, |
408 | uint16_t bnd_port, | 379 | uint16_t bnd_port, |
409 | uint16_t adv_port, | 380 | uint16_t adv_port, |
410 | GNUNET_NAT_TestCallback report, | 381 | GNUNET_NAT_TestCallback report, void *report_cls) |
411 | void *report_cls) | ||
412 | { | 382 | { |
413 | struct GNUNET_NAT_Test *ret; | 383 | struct GNUNET_NAT_Test *ret; |
414 | struct sockaddr_in sa; | 384 | struct sockaddr_in sa; |
415 | const struct sockaddr *addrs[] = { (const struct sockaddr*) &sa }; | 385 | const struct sockaddr *addrs[] = { (const struct sockaddr *) &sa }; |
416 | const socklen_t addrlens[] = { sizeof (sa) }; | 386 | const socklen_t addrlens[] = { sizeof (sa) }; |
417 | 387 | ||
418 | memset (&sa, 0, sizeof (sa)); | 388 | memset (&sa, 0, sizeof (sa)); |
@@ -421,7 +391,7 @@ GNUNET_NAT_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
421 | #if HAVE_SOCKADDR_IN_SIN_LEN | 391 | #if HAVE_SOCKADDR_IN_SIN_LEN |
422 | sa.sin_len = sizeof (sa); | 392 | sa.sin_len = sizeof (sa); |
423 | #endif | 393 | #endif |
424 | 394 | ||
425 | ret = GNUNET_malloc (sizeof (struct GNUNET_NAT_Test)); | 395 | ret = GNUNET_malloc (sizeof (struct GNUNET_NAT_Test)); |
426 | ret->cfg = cfg; | 396 | ret->cfg = cfg; |
427 | ret->is_tcp = is_tcp; | 397 | ret->is_tcp = is_tcp; |
@@ -430,54 +400,47 @@ GNUNET_NAT_test_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
430 | ret->report = report; | 400 | ret->report = report; |
431 | ret->report_cls = report_cls; | 401 | ret->report_cls = report_cls; |
432 | if (bnd_port == 0) | 402 | if (bnd_port == 0) |
433 | { | 403 | { |
434 | ret->nat = GNUNET_NAT_register (cfg, is_tcp, | 404 | ret->nat = GNUNET_NAT_register (cfg, is_tcp, |
435 | 0, | 405 | 0, |
436 | 0, NULL, NULL, | 406 | 0, NULL, NULL, &addr_cb, &reversal_cb, ret); |
437 | &addr_cb, &reversal_cb, ret); | 407 | } |
438 | } | ||
439 | else | 408 | else |
409 | { | ||
410 | ret->lsock = GNUNET_NETWORK_socket_create (AF_INET, | ||
411 | (is_tcp == GNUNET_YES) | ||
412 | ? SOCK_STREAM : SOCK_DGRAM, 0); | ||
413 | if ((ret->lsock == NULL) || | ||
414 | (GNUNET_OK != GNUNET_NETWORK_socket_bind (ret->lsock, | ||
415 | (const struct sockaddr *) &sa, | ||
416 | sizeof (sa)))) | ||
417 | { | ||
418 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
419 | _ | ||
420 | ("Failed to create listen socket bound to `%s' for NAT test: %s\n"), | ||
421 | GNUNET_a2s ((const struct sockaddr *) &sa, sizeof (sa)), | ||
422 | STRERROR (errno)); | ||
423 | if (NULL != ret->lsock) | ||
424 | GNUNET_NETWORK_socket_close (ret->lsock); | ||
425 | GNUNET_free (ret); | ||
426 | return NULL; | ||
427 | } | ||
428 | if (GNUNET_YES == is_tcp) | ||
429 | { | ||
430 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_listen (ret->lsock, 5)); | ||
431 | ret->ltask = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | ||
432 | ret->lsock, &do_accept, ret); | ||
433 | } | ||
434 | else | ||
440 | { | 435 | { |
441 | ret->lsock = GNUNET_NETWORK_socket_create (AF_INET, | 436 | ret->ltask = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
442 | (is_tcp==GNUNET_YES) | 437 | ret->lsock, |
443 | ? SOCK_STREAM | 438 | &do_udp_read, ret); |
444 | : SOCK_DGRAM, 0); | ||
445 | if ( (ret->lsock == NULL) || | ||
446 | (GNUNET_OK != GNUNET_NETWORK_socket_bind (ret->lsock, | ||
447 | (const struct sockaddr*) &sa, | ||
448 | sizeof (sa))) ) | ||
449 | { | ||
450 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
451 | _("Failed to create listen socket bound to `%s' for NAT test: %s\n"), | ||
452 | GNUNET_a2s ((const struct sockaddr*)&sa, | ||
453 | sizeof(sa)), | ||
454 | STRERROR (errno)); | ||
455 | if (NULL != ret->lsock) | ||
456 | GNUNET_NETWORK_socket_close (ret->lsock); | ||
457 | GNUNET_free (ret); | ||
458 | return NULL; | ||
459 | } | ||
460 | if (GNUNET_YES == is_tcp) | ||
461 | { | ||
462 | GNUNET_break (GNUNET_OK == | ||
463 | GNUNET_NETWORK_socket_listen (ret->lsock, 5)); | ||
464 | ret->ltask = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | ||
465 | ret->lsock, | ||
466 | &do_accept, | ||
467 | ret); | ||
468 | } | ||
469 | else | ||
470 | { | ||
471 | ret->ltask = GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | ||
472 | ret->lsock, | ||
473 | &do_udp_read, | ||
474 | ret); | ||
475 | } | ||
476 | ret->nat = GNUNET_NAT_register (cfg, is_tcp, | ||
477 | adv_port, | ||
478 | 1, addrs, addrlens, | ||
479 | &addr_cb, NULL, ret); | ||
480 | } | 439 | } |
440 | ret->nat = GNUNET_NAT_register (cfg, is_tcp, | ||
441 | adv_port, | ||
442 | 1, addrs, addrlens, &addr_cb, NULL, ret); | ||
443 | } | ||
481 | return ret; | 444 | return ret; |
482 | } | 445 | } |
483 | 446 | ||
@@ -494,22 +457,18 @@ GNUNET_NAT_test_stop (struct GNUNET_NAT_Test *tst) | |||
494 | struct ClientActivity *cpos; | 457 | struct ClientActivity *cpos; |
495 | 458 | ||
496 | while (NULL != (cpos = tst->ca_head)) | 459 | while (NULL != (cpos = tst->ca_head)) |
497 | { | 460 | { |
498 | GNUNET_CONTAINER_DLL_remove (tst->ca_head, | 461 | GNUNET_CONTAINER_DLL_remove (tst->ca_head, tst->ca_tail, cpos); |
499 | tst->ca_tail, | 462 | GNUNET_CLIENT_disconnect (cpos->client, GNUNET_NO); |
500 | cpos); | 463 | GNUNET_free (cpos); |
501 | GNUNET_CLIENT_disconnect (cpos->client, GNUNET_NO); | 464 | } |
502 | GNUNET_free (cpos); | ||
503 | } | ||
504 | while (NULL != (pos = tst->na_head)) | 465 | while (NULL != (pos = tst->na_head)) |
505 | { | 466 | { |
506 | GNUNET_CONTAINER_DLL_remove (tst->na_head, | 467 | GNUNET_CONTAINER_DLL_remove (tst->na_head, tst->na_tail, pos); |
507 | tst->na_tail, | 468 | GNUNET_SCHEDULER_cancel (pos->rtask); |
508 | pos); | 469 | GNUNET_NETWORK_socket_close (pos->sock); |
509 | GNUNET_SCHEDULER_cancel (pos->rtask); | 470 | GNUNET_free (pos); |
510 | GNUNET_NETWORK_socket_close (pos->sock); | 471 | } |
511 | GNUNET_free (pos); | ||
512 | } | ||
513 | if (GNUNET_SCHEDULER_NO_TASK != tst->ltask) | 472 | if (GNUNET_SCHEDULER_NO_TASK != tst->ltask) |
514 | GNUNET_SCHEDULER_cancel (tst->ltask); | 473 | GNUNET_SCHEDULER_cancel (tst->ltask); |
515 | if (NULL != tst->lsock) | 474 | if (NULL != tst->lsock) |