diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2014-03-28 13:06:44 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2014-03-28 13:06:44 +0000 |
commit | 0946e217c746adf49291643eca33f009af10e104 (patch) | |
tree | c827c6285bedf0f52e43f0ed34d8fd55f62bc26c /src/transport/gnunet-service-transport.c | |
parent | e806c9794b23600f3b50ec0aefb9e300a4b98810 (diff) | |
download | gnunet-0946e217c746adf49291643eca33f009af10e104.tar.gz gnunet-0946e217c746adf49291643eca33f009af10e104.zip |
re-add address on connect
Diffstat (limited to 'src/transport/gnunet-service-transport.c')
-rw-r--r-- | src/transport/gnunet-service-transport.c | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index 906ed2970..66514b8e5 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -358,6 +358,36 @@ connect_bl_check_cont (void *cls, | |||
358 | } | 358 | } |
359 | 359 | ||
360 | /** | 360 | /** |
361 | * Black list check result for try_connect call | ||
362 | * If connection to the peer is allowed request adddress and | ||
363 | * | ||
364 | * @param cls blc_ctx bl context | ||
365 | * @param peer the peer | ||
366 | * @param result the result | ||
367 | */ | ||
368 | static void | ||
369 | connect_transport_bl_check_cont (void *cls, | ||
370 | const struct GNUNET_PeerIdentity *peer, int result) | ||
371 | { | ||
372 | struct BlacklistCheckContext *blctx = cls; | ||
373 | |||
374 | GNUNET_CONTAINER_DLL_remove (bc_head, bc_tail, blctx); | ||
375 | blctx->blc = NULL; | ||
376 | |||
377 | if (GNUNET_OK == result) | ||
378 | { | ||
379 | /* Blacklist allows to speak to this transport */ | ||
380 | GST_ats_add_address(blctx->address, blctx->session, blctx->ats, blctx->ats_count); | ||
381 | } | ||
382 | |||
383 | if (NULL != blctx->address) | ||
384 | GNUNET_HELLO_address_free (blctx->address); | ||
385 | GNUNET_free (blctx->msg); | ||
386 | GNUNET_free (blctx); | ||
387 | } | ||
388 | |||
389 | |||
390 | /** | ||
361 | * Function called by the transport for each received message. | 391 | * Function called by the transport for each received message. |
362 | * | 392 | * |
363 | * @param cls closure, const char* with the name of the plugin we received the message from | 393 | * @param cls closure, const char* with the name of the plugin we received the message from |
@@ -440,6 +470,18 @@ GST_receive_callback (void *cls, | |||
440 | { | 470 | { |
441 | blctx->blc = blc; | 471 | blctx->blc = blc; |
442 | } | 472 | } |
473 | |||
474 | blctx = GNUNET_new (struct BlacklistCheckContext); | ||
475 | blctx->address = GNUNET_HELLO_address_copy (address); | ||
476 | blctx->session = session; | ||
477 | blctx->msg = GNUNET_malloc (ntohs(message->size)); | ||
478 | memcpy (blctx->msg, message, ntohs(message->size)); | ||
479 | GNUNET_CONTAINER_DLL_insert (bc_head, bc_tail, blctx); | ||
480 | if (NULL != (blc = GST_blacklist_test_allowed (&address->peer, | ||
481 | address->transport_name, &connect_transport_bl_check_cont, blctx))) | ||
482 | { | ||
483 | blctx->blc = blc; | ||
484 | } | ||
443 | break; | 485 | break; |
444 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT_ACK: | 486 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_CONNECT_ACK: |
445 | if (GNUNET_OK != GST_neighbours_handle_connect_ack (message, | 487 | if (GNUNET_OK != GST_neighbours_handle_connect_ack (message, |
@@ -650,10 +692,10 @@ GST_ats_add_address (const struct GNUNET_HELLO_Address *address, | |||
650 | ats2[0].value = htonl (net); | 692 | ats2[0].value = htonl (net); |
651 | memcpy (&ats2[1], ats, sizeof(struct GNUNET_ATS_Information) * ats_count); | 693 | memcpy (&ats2[1], ats, sizeof(struct GNUNET_ATS_Information) * ats_count); |
652 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 694 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
653 | "Notifying ATS about peer `%s''s new address `%s' session %p in network %s %u\n", | 695 | "Notifying ATS about peer `%s''s new address `%s' session %p in network %s\n", |
654 | GNUNET_i2s (&address->peer), | 696 | GNUNET_i2s (&address->peer), |
655 | (0 == address->address_length) ? "<inbound>" : GST_plugins_a2s (address), | 697 | (0 == address->address_length) ? "<inbound>" : GST_plugins_a2s (address), |
656 | session, GNUNET_ATS_print_network_type (net), net); | 698 | session, GNUNET_ATS_print_network_type (net)); |
657 | GNUNET_ATS_address_add (GST_ats, address, session, ats2, ats_count + 1); | 699 | GNUNET_ATS_address_add (GST_ats, address, session, ats2, ats_count + 1); |
658 | } | 700 | } |
659 | 701 | ||