diff options
Diffstat (limited to 'src/transport/gnunet-service-transport_clients.c')
-rw-r--r-- | src/transport/gnunet-service-transport_clients.c | 79 |
1 files changed, 35 insertions, 44 deletions
diff --git a/src/transport/gnunet-service-transport_clients.c b/src/transport/gnunet-service-transport_clients.c index 8e0b3fe68..cea1dc14e 100644 --- a/src/transport/gnunet-service-transport_clients.c +++ b/src/transport/gnunet-service-transport_clients.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2010-2014 Christian Grothoff (and other contributing authors) | 3 | Copyright (C) 2010-2015 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -613,38 +613,57 @@ clients_handle_start (void *cls, | |||
613 | const struct GNUNET_MessageHeader *message) | 613 | const struct GNUNET_MessageHeader *message) |
614 | { | 614 | { |
615 | const struct StartMessage *start; | 615 | const struct StartMessage *start; |
616 | const struct GNUNET_MessageHeader *hello; | ||
616 | struct TransportClient *tc; | 617 | struct TransportClient *tc; |
617 | uint32_t options; | 618 | uint32_t options; |
618 | 619 | ||
619 | tc = lookup_client (client); | 620 | tc = lookup_client (client); |
620 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
621 | "Client %p sent START\n", tc); | ||
622 | if (NULL != tc) | 621 | if (NULL != tc) |
623 | { | 622 | { |
624 | /* got 'start' twice from the same client, not allowed */ | 623 | /* got 'start' twice from the same client, not allowed */ |
625 | GNUNET_break (0); | 624 | GNUNET_break (0); |
626 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 625 | GNUNET_SERVER_receive_done (client, |
626 | GNUNET_SYSERR); | ||
627 | return; | 627 | return; |
628 | } | 628 | } |
629 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
630 | "Client %p sent START\n", | ||
631 | client); | ||
629 | start = (const struct StartMessage *) message; | 632 | start = (const struct StartMessage *) message; |
630 | options = ntohl (start->options); | 633 | options = ntohl (start->options); |
631 | if ((0 != (1 & options)) && | 634 | if ((0 != (1 & options)) && |
632 | (0 != | 635 | (0 != |
633 | memcmp (&start->self, &GST_my_identity, | 636 | memcmp (&start->self, |
637 | &GST_my_identity, | ||
634 | sizeof (struct GNUNET_PeerIdentity)))) | 638 | sizeof (struct GNUNET_PeerIdentity)))) |
635 | { | 639 | { |
636 | /* client thinks this is a different peer, reject */ | 640 | /* client thinks this is a different peer, reject */ |
637 | GNUNET_break (0); | 641 | GNUNET_break (0); |
638 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 642 | GNUNET_SERVER_receive_done (client, |
643 | GNUNET_SYSERR); | ||
639 | return; | 644 | return; |
640 | } | 645 | } |
641 | tc = setup_client (client); | 646 | tc = setup_client (client); |
642 | tc->send_payload = (0 != (2 & options)); | 647 | tc->send_payload = (0 != (2 & options)); |
643 | unicast (tc, | 648 | hello = GST_hello_get (); |
644 | GST_hello_get (), | 649 | if (NULL == hello) |
645 | GNUNET_NO); | 650 | { |
646 | GST_neighbours_iterate (¬ify_client_about_neighbour, tc); | 651 | /* We are during startup and should have no neighbours, hence |
647 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 652 | iteration with NULL must work. The HELLO will be sent to |
653 | all clients once it has been created, so this should happen | ||
654 | next anyway, and certainly before we get neighbours. */ | ||
655 | GST_neighbours_iterate (NULL, NULL); | ||
656 | } | ||
657 | else | ||
658 | { | ||
659 | unicast (tc, | ||
660 | hello, | ||
661 | GNUNET_NO); | ||
662 | GST_neighbours_iterate (¬ify_client_about_neighbour, | ||
663 | tc); | ||
664 | } | ||
665 | GNUNET_SERVER_receive_done (client, | ||
666 | GNUNET_OK); | ||
648 | } | 667 | } |
649 | 668 | ||
650 | 669 | ||
@@ -791,35 +810,6 @@ clients_handle_send (void *cls, | |||
791 | 810 | ||
792 | 811 | ||
793 | /** | 812 | /** |
794 | * Try to initiate a connection to the given peer if the blacklist | ||
795 | * allowed it. | ||
796 | * | ||
797 | * @param cls closure (unused, NULL) | ||
798 | * @param peer identity of peer that was tested | ||
799 | * @param result #GNUNET_OK if the connection is allowed, | ||
800 | * #GNUNET_NO if not | ||
801 | */ | ||
802 | static void | ||
803 | try_connect_if_allowed (void *cls, | ||
804 | const struct GNUNET_PeerIdentity *peer, | ||
805 | int result) | ||
806 | { | ||
807 | if (GNUNET_OK != result) | ||
808 | { | ||
809 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
810 | _("Blacklist refuses connection attempt to peer `%s'\n"), | ||
811 | GNUNET_i2s (peer)); | ||
812 | return; /* not allowed */ | ||
813 | } | ||
814 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
815 | "Blacklist allows connection attempt to peer `%s'\n", | ||
816 | GNUNET_i2s (peer)); | ||
817 | |||
818 | GST_neighbours_try_connect (peer); | ||
819 | } | ||
820 | |||
821 | |||
822 | /** | ||
823 | * Handle request connect message | 813 | * Handle request connect message |
824 | * | 814 | * |
825 | * @param cls closure (always NULL) | 815 | * @param cls closure (always NULL) |
@@ -850,10 +840,7 @@ clients_handle_request_connect (void *cls, | |||
850 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 840 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
851 | "Received a request connect message for peer `%s'\n", | 841 | "Received a request connect message for peer `%s'\n", |
852 | GNUNET_i2s (&trcm->peer)); | 842 | GNUNET_i2s (&trcm->peer)); |
853 | (void) GST_blacklist_test_allowed (&trcm->peer, | 843 | GST_neighbours_try_connect (&trcm->peer); |
854 | NULL, | ||
855 | &try_connect_if_allowed, | ||
856 | NULL); | ||
857 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 844 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
858 | } | 845 | } |
859 | 846 | ||
@@ -1590,6 +1577,10 @@ GST_clients_broadcast (const struct GNUNET_MessageHeader *msg, | |||
1590 | { | 1577 | { |
1591 | struct TransportClient *tc; | 1578 | struct TransportClient *tc; |
1592 | 1579 | ||
1580 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1581 | "Asked to broadcast message of type %u with %u bytes\n", | ||
1582 | (unsigned int) ntohs (msg->type), | ||
1583 | (unsigned int) ntohs (msg->size)); | ||
1593 | for (tc = clients_head; NULL != tc; tc = tc->next) | 1584 | for (tc = clients_head; NULL != tc; tc = tc->next) |
1594 | { | 1585 | { |
1595 | if ( (GNUNET_YES == may_drop) && | 1586 | if ( (GNUNET_YES == may_drop) && |