diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/transport/gnunet-service-transport.c | 1016 |
1 files changed, 417 insertions, 599 deletions
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index e1dfbae0f..45183afd9 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c | |||
@@ -158,7 +158,8 @@ struct TransportClient | |||
158 | */ | 158 | */ |
159 | enum ClientType type; | 159 | enum ClientType type; |
160 | 160 | ||
161 | union { | 161 | union |
162 | { | ||
162 | 163 | ||
163 | /** | 164 | /** |
164 | * Peer identity to monitor the addresses of. | 165 | * Peer identity to monitor the addresses of. |
@@ -170,7 +171,8 @@ struct TransportClient | |||
170 | /** | 171 | /** |
171 | * Additional details if @e type is CT_BLACKLIST. | 172 | * Additional details if @e type is CT_BLACKLIST. |
172 | */ | 173 | */ |
173 | struct { | 174 | struct |
175 | { | ||
174 | 176 | ||
175 | /** | 177 | /** |
176 | * Blacklist check that we're currently performing (or NULL | 178 | * Blacklist check that we're currently performing (or NULL |
@@ -191,11 +193,9 @@ struct TransportClient | |||
191 | } blacklist; | 193 | } blacklist; |
192 | 194 | ||
193 | } details; | 195 | } details; |
194 | |||
195 | }; | 196 | }; |
196 | 197 | ||
197 | 198 | ||
198 | |||
199 | /** | 199 | /** |
200 | * Context we use when performing a blacklist check. | 200 | * Context we use when performing a blacklist check. |
201 | */ | 201 | */ |
@@ -246,7 +246,6 @@ struct GST_BlacklistCheck | |||
246 | * Current task performing the check. | 246 | * Current task performing the check. |
247 | */ | 247 | */ |
248 | struct GNUNET_SCHEDULER_Task *task; | 248 | struct GNUNET_SCHEDULER_Task *task; |
249 | |||
250 | }; | 249 | }; |
251 | 250 | ||
252 | 251 | ||
@@ -268,7 +267,7 @@ struct AddressToStringContext | |||
268 | /** | 267 | /** |
269 | * Client that made the request. | 268 | * Client that made the request. |
270 | */ | 269 | */ |
271 | struct TransportClient* tc; | 270 | struct TransportClient *tc; |
272 | }; | 271 | }; |
273 | 272 | ||
274 | 273 | ||
@@ -439,24 +438,25 @@ unicast (struct TransportClient *tc, | |||
439 | { | 438 | { |
440 | struct GNUNET_MQ_Envelope *env; | 439 | struct GNUNET_MQ_Envelope *env; |
441 | 440 | ||
442 | if ( (GNUNET_MQ_get_length (tc->mq) >= MAX_PENDING) && | 441 | if ((GNUNET_MQ_get_length (tc->mq) >= MAX_PENDING) && |
443 | (GNUNET_YES == may_drop) ) | 442 | (GNUNET_YES == may_drop)) |
444 | { | 443 | { |
445 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 444 | GNUNET_log ( |
446 | "Dropping message of type %u and size %u, have %u/%u messages pending\n", | 445 | GNUNET_ERROR_TYPE_DEBUG, |
447 | ntohs (msg->type), | 446 | "Dropping message of type %u and size %u, have %u/%u messages pending\n", |
448 | ntohs (msg->size), | 447 | ntohs (msg->type), |
449 | GNUNET_MQ_get_length (tc->mq), | 448 | ntohs (msg->size), |
450 | MAX_PENDING); | 449 | GNUNET_MQ_get_length (tc->mq), |
450 | MAX_PENDING); | ||
451 | GNUNET_STATISTICS_update (GST_stats, | 451 | GNUNET_STATISTICS_update (GST_stats, |
452 | gettext_noop ("# messages dropped due to slow client"), | 452 | gettext_noop ( |
453 | "# messages dropped due to slow client"), | ||
453 | 1, | 454 | 1, |
454 | GNUNET_NO); | 455 | GNUNET_NO); |
455 | return; | 456 | return; |
456 | } | 457 | } |
457 | env = GNUNET_MQ_msg_copy (msg); | 458 | env = GNUNET_MQ_msg_copy (msg); |
458 | GNUNET_MQ_send (tc->mq, | 459 | GNUNET_MQ_send (tc->mq, env); |
459 | env); | ||
460 | } | 460 | } |
461 | 461 | ||
462 | 462 | ||
@@ -471,20 +471,16 @@ unicast (struct TransportClient *tc, | |||
471 | */ | 471 | */ |
472 | static void * | 472 | static void * |
473 | client_connect_cb (void *cls, | 473 | client_connect_cb (void *cls, |
474 | struct GNUNET_SERVICE_Client *client, | 474 | struct GNUNET_SERVICE_Client *client, |
475 | struct GNUNET_MQ_Handle *mq) | 475 | struct GNUNET_MQ_Handle *mq) |
476 | { | 476 | { |
477 | struct TransportClient *tc; | 477 | struct TransportClient *tc; |
478 | 478 | ||
479 | tc = GNUNET_new (struct TransportClient); | 479 | tc = GNUNET_new (struct TransportClient); |
480 | tc->client = client; | 480 | tc->client = client; |
481 | tc->mq = mq; | 481 | tc->mq = mq; |
482 | GNUNET_CONTAINER_DLL_insert (clients_head, | 482 | GNUNET_CONTAINER_DLL_insert (clients_head, clients_tail, tc); |
483 | clients_tail, | 483 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected\n", tc); |
484 | tc); | ||
485 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
486 | "Client %p connected\n", | ||
487 | tc); | ||
488 | return tc; | 484 | return tc; |
489 | } | 485 | } |
490 | 486 | ||
@@ -508,9 +504,7 @@ do_blacklist_check (void *cls); | |||
508 | * @return #GNUNET_OK (continue to iterate) | 504 | * @return #GNUNET_OK (continue to iterate) |
509 | */ | 505 | */ |
510 | static int | 506 | static int |
511 | mark_match_down (void *cls, | 507 | mark_match_down (void *cls, const struct GNUNET_PeerIdentity *peer, void *value) |
512 | const struct GNUNET_PeerIdentity *peer, | ||
513 | void *value) | ||
514 | { | 508 | { |
515 | struct TransportClient *tc = cls; | 509 | struct TransportClient *tc = cls; |
516 | struct SendTransmitContinuationContext *stcc = value; | 510 | struct SendTransmitContinuationContext *stcc = value; |
@@ -534,8 +528,8 @@ mark_match_down (void *cls, | |||
534 | */ | 528 | */ |
535 | static void | 529 | static void |
536 | client_disconnect_cb (void *cls, | 530 | client_disconnect_cb (void *cls, |
537 | struct GNUNET_SERVICE_Client *client, | 531 | struct GNUNET_SERVICE_Client *client, |
538 | void *app_ctx) | 532 | void *app_ctx) |
539 | { | 533 | { |
540 | struct TransportClient *tc = app_ctx; | 534 | struct TransportClient *tc = app_ctx; |
541 | struct GST_BlacklistCheck *bc; | 535 | struct GST_BlacklistCheck *bc; |
@@ -543,19 +537,14 @@ client_disconnect_cb (void *cls, | |||
543 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 537 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
544 | "Client %p disconnected, cleaning up.\n", | 538 | "Client %p disconnected, cleaning up.\n", |
545 | tc); | 539 | tc); |
546 | GNUNET_CONTAINER_multipeermap_iterate (active_stccs, | 540 | GNUNET_CONTAINER_multipeermap_iterate (active_stccs, &mark_match_down, tc); |
547 | &mark_match_down, | 541 | for (struct AddressToStringContext *cur = a2s_head; NULL != cur; |
548 | tc); | ||
549 | for (struct AddressToStringContext *cur = a2s_head; | ||
550 | NULL != cur; | ||
551 | cur = cur->next) | 542 | cur = cur->next) |
552 | { | 543 | { |
553 | if (cur->tc == tc) | 544 | if (cur->tc == tc) |
554 | cur->tc = NULL; | 545 | cur->tc = NULL; |
555 | } | 546 | } |
556 | GNUNET_CONTAINER_DLL_remove (clients_head, | 547 | GNUNET_CONTAINER_DLL_remove (clients_head, clients_tail, tc); |
557 | clients_tail, | ||
558 | tc); | ||
559 | switch (tc->type) | 548 | switch (tc->type) |
560 | { | 549 | { |
561 | case CT_NONE: | 550 | case CT_NONE: |
@@ -571,8 +560,7 @@ client_disconnect_cb (void *cls, | |||
571 | continue; | 560 | continue; |
572 | bc->bl_pos = tc->next; | 561 | bc->bl_pos = tc->next; |
573 | if (NULL == bc->task) | 562 | if (NULL == bc->task) |
574 | bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check, | 563 | bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check, bc); |
575 | bc); | ||
576 | } | 564 | } |
577 | break; | 565 | break; |
578 | case CT_CORE_NO_HANDLERS: | 566 | case CT_CORE_NO_HANDLERS: |
@@ -612,9 +600,7 @@ notify_client_about_neighbour (void *cls, | |||
612 | cim.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); | 600 | cim.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_CONNECT); |
613 | cim.id = *peer; | 601 | cim.id = *peer; |
614 | cim.quota_out = bandwidth_out; | 602 | cim.quota_out = bandwidth_out; |
615 | unicast (tc, | 603 | unicast (tc, &cim.header, GNUNET_NO); |
616 | &cim.header, | ||
617 | GNUNET_NO); | ||
618 | } | 604 | } |
619 | 605 | ||
620 | 606 | ||
@@ -627,22 +613,18 @@ notify_client_about_neighbour (void *cls, | |||
627 | * @param start the start message that was sent | 613 | * @param start the start message that was sent |
628 | */ | 614 | */ |
629 | static void | 615 | static void |
630 | handle_client_start (void *cls, | 616 | handle_client_start (void *cls, const struct StartMessage *start) |
631 | const struct StartMessage *start) | ||
632 | { | 617 | { |
633 | struct TransportClient *tc = cls; | 618 | struct TransportClient *tc = cls; |
634 | const struct GNUNET_MessageHeader *hello; | 619 | const struct GNUNET_MessageHeader *hello; |
635 | uint32_t options; | 620 | uint32_t options; |
636 | 621 | ||
637 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 622 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Client %p sent START\n", tc); |
638 | "Client %p sent START\n", | ||
639 | tc); | ||
640 | options = ntohl (start->options); | 623 | options = ntohl (start->options); |
641 | if ((0 != (1 & options)) && | 624 | if ((0 != (1 & options)) && |
642 | (0 != | 625 | (0 != memcmp (&start->self, |
643 | memcmp (&start->self, | 626 | &GST_my_identity, |
644 | &GST_my_identity, | 627 | sizeof (struct GNUNET_PeerIdentity)))) |
645 | sizeof (struct GNUNET_PeerIdentity)))) | ||
646 | { | 628 | { |
647 | /* client thinks this is a different peer, reject */ | 629 | /* client thinks this is a different peer, reject */ |
648 | GNUNET_break (0); | 630 | GNUNET_break (0); |
@@ -661,11 +643,8 @@ handle_client_start (void *cls, | |||
661 | tc->type = CT_CORE_NO_HANDLERS; | 643 | tc->type = CT_CORE_NO_HANDLERS; |
662 | hello = GST_hello_get (); | 644 | hello = GST_hello_get (); |
663 | if (NULL != hello) | 645 | if (NULL != hello) |
664 | unicast (tc, | 646 | unicast (tc, hello, GNUNET_NO); |
665 | hello, | 647 | GST_neighbours_iterate (¬ify_client_about_neighbour, tc); |
666 | GNUNET_NO); | ||
667 | GST_neighbours_iterate (¬ify_client_about_neighbour, | ||
668 | tc); | ||
669 | GNUNET_SERVICE_client_continue (tc->client); | 648 | GNUNET_SERVICE_client_continue (tc->client); |
670 | } | 649 | } |
671 | 650 | ||
@@ -677,8 +656,7 @@ handle_client_start (void *cls, | |||
677 | * @param message the HELLO message | 656 | * @param message the HELLO message |
678 | */ | 657 | */ |
679 | static int | 658 | static int |
680 | check_client_hello (void *cls, | 659 | check_client_hello (void *cls, const struct GNUNET_MessageHeader *message) |
681 | const struct GNUNET_MessageHeader *message) | ||
682 | { | 660 | { |
683 | return GNUNET_OK; /* FIXME: check here? */ | 661 | return GNUNET_OK; /* FIXME: check here? */ |
684 | } | 662 | } |
@@ -691,13 +669,11 @@ check_client_hello (void *cls, | |||
691 | * @param message the HELLO message | 669 | * @param message the HELLO message |
692 | */ | 670 | */ |
693 | static void | 671 | static void |
694 | handle_client_hello (void *cls, | 672 | handle_client_hello (void *cls, const struct GNUNET_MessageHeader *message) |
695 | const struct GNUNET_MessageHeader *message) | ||
696 | { | 673 | { |
697 | struct TransportClient *tc = cls; | 674 | struct TransportClient *tc = cls; |
698 | 675 | ||
699 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 676 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Received HELLO message\n"); |
700 | "Received HELLO message\n"); | ||
701 | GST_validation_handle_hello (message); | 677 | GST_validation_handle_hello (message); |
702 | GNUNET_SERVICE_client_continue (tc->client); | 678 | GNUNET_SERVICE_client_continue (tc->client); |
703 | } | 679 | } |
@@ -728,8 +704,7 @@ handle_send_transmit_continuation (void *cls, | |||
728 | if (delay.rel_value_us > GNUNET_CONSTANTS_LATENCY_WARN.rel_value_us) | 704 | if (delay.rel_value_us > GNUNET_CONSTANTS_LATENCY_WARN.rel_value_us) |
729 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 705 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
730 | "It took us %s to send %u/%u bytes to %s (%d, %s)\n", | 706 | "It took us %s to send %u/%u bytes to %s (%d, %s)\n", |
731 | GNUNET_STRINGS_relative_time_to_string (delay, | 707 | GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES), |
732 | GNUNET_YES), | ||
733 | (unsigned int) bytes_payload, | 708 | (unsigned int) bytes_payload, |
734 | (unsigned int) bytes_on_wire, | 709 | (unsigned int) bytes_on_wire, |
735 | GNUNET_i2s (&stcc->target), | 710 | GNUNET_i2s (&stcc->target), |
@@ -738,8 +713,7 @@ handle_send_transmit_continuation (void *cls, | |||
738 | else | 713 | else |
739 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 714 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
740 | "It took us %s to send %u/%u bytes to %s (%d, %s)\n", | 715 | "It took us %s to send %u/%u bytes to %s (%d, %s)\n", |
741 | GNUNET_STRINGS_relative_time_to_string (delay, | 716 | GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES), |
742 | GNUNET_YES), | ||
743 | (unsigned int) bytes_payload, | 717 | (unsigned int) bytes_payload, |
744 | (unsigned int) bytes_on_wire, | 718 | (unsigned int) bytes_on_wire, |
745 | GNUNET_i2s (&stcc->target), | 719 | GNUNET_i2s (&stcc->target), |
@@ -758,14 +732,11 @@ handle_send_transmit_continuation (void *cls, | |||
758 | send_ok_msg.bytes_physical = htonl (bytes_on_wire); | 732 | send_ok_msg.bytes_physical = htonl (bytes_on_wire); |
759 | send_ok_msg.success = htonl (success); | 733 | send_ok_msg.success = htonl (success); |
760 | send_ok_msg.peer = stcc->target; | 734 | send_ok_msg.peer = stcc->target; |
761 | unicast (stcc->tc, | 735 | unicast (stcc->tc, &send_ok_msg.header, GNUNET_NO); |
762 | &send_ok_msg.header, | 736 | } |
763 | GNUNET_NO); | 737 | GNUNET_assert ( |
764 | } | 738 | GNUNET_OK == |
765 | GNUNET_assert (GNUNET_OK == | 739 | GNUNET_CONTAINER_multipeermap_remove (active_stccs, &stcc->target, stcc)); |
766 | GNUNET_CONTAINER_multipeermap_remove (active_stccs, | ||
767 | &stcc->target, | ||
768 | stcc)); | ||
769 | GNUNET_free (stcc); | 740 | GNUNET_free (stcc); |
770 | } | 741 | } |
771 | 742 | ||
@@ -777,8 +748,7 @@ handle_send_transmit_continuation (void *cls, | |||
777 | * @param obm the send message that was sent | 748 | * @param obm the send message that was sent |
778 | */ | 749 | */ |
779 | static int | 750 | static int |
780 | check_client_send (void *cls, | 751 | check_client_send (void *cls, const struct OutboundMessage *obm) |
781 | const struct OutboundMessage *obm) | ||
782 | { | 752 | { |
783 | uint16_t size; | 753 | uint16_t size; |
784 | const struct GNUNET_MessageHeader *obmm; | 754 | const struct GNUNET_MessageHeader *obmm; |
@@ -806,8 +776,7 @@ check_client_send (void *cls, | |||
806 | * @param obm the send message that was sent | 776 | * @param obm the send message that was sent |
807 | */ | 777 | */ |
808 | static void | 778 | static void |
809 | handle_client_send (void *cls, | 779 | handle_client_send (void *cls, const struct OutboundMessage *obm) |
810 | const struct OutboundMessage *obm) | ||
811 | { | 780 | { |
812 | static unsigned long long uuid_gen; | 781 | static unsigned long long uuid_gen; |
813 | struct TransportClient *tc = cls; | 782 | struct TransportClient *tc = cls; |
@@ -821,20 +790,21 @@ handle_client_send (void *cls, | |||
821 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 790 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
822 | "Could not send message to peer `%s': not connected\n", | 791 | "Could not send message to peer `%s': not connected\n", |
823 | GNUNET_i2s (&obm->peer)); | 792 | GNUNET_i2s (&obm->peer)); |
824 | GNUNET_STATISTICS_update (GST_stats, | 793 | GNUNET_STATISTICS_update ( |
825 | gettext_noop | 794 | GST_stats, |
826 | ("# bytes payload dropped (other peer was not connected)"), | 795 | gettext_noop ("# bytes payload dropped (other peer was not connected)"), |
827 | ntohs (obmm->size), | 796 | ntohs (obmm->size), |
828 | GNUNET_NO); | 797 | GNUNET_NO); |
829 | GNUNET_SERVICE_client_continue (tc->client); | 798 | GNUNET_SERVICE_client_continue (tc->client); |
830 | return; | 799 | return; |
831 | } | 800 | } |
832 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 801 | GNUNET_log ( |
833 | "Received SEND request %llu for `%s' and first message of type %u and total size %u\n", | 802 | GNUNET_ERROR_TYPE_DEBUG, |
834 | uuid_gen, | 803 | "Received SEND request %llu for `%s' and first message of type %u and total size %u\n", |
835 | GNUNET_i2s (&obm->peer), | 804 | uuid_gen, |
836 | ntohs (obmm->type), | 805 | GNUNET_i2s (&obm->peer), |
837 | ntohs (obmm->size)); | 806 | ntohs (obmm->type), |
807 | ntohs (obmm->size)); | ||
838 | GNUNET_SERVICE_client_continue (tc->client); | 808 | GNUNET_SERVICE_client_continue (tc->client); |
839 | 809 | ||
840 | stcc = GNUNET_new (struct SendTransmitContinuationContext); | 810 | stcc = GNUNET_new (struct SendTransmitContinuationContext); |
@@ -842,10 +812,11 @@ handle_client_send (void *cls, | |||
842 | stcc->tc = tc; | 812 | stcc->tc = tc; |
843 | stcc->send_time = GNUNET_TIME_absolute_get (); | 813 | stcc->send_time = GNUNET_TIME_absolute_get (); |
844 | stcc->uuid = uuid_gen++; | 814 | stcc->uuid = uuid_gen++; |
845 | (void) GNUNET_CONTAINER_multipeermap_put (active_stccs, | 815 | (void) GNUNET_CONTAINER_multipeermap_put ( |
846 | &stcc->target, | 816 | active_stccs, |
847 | stcc, | 817 | &stcc->target, |
848 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 818 | stcc, |
819 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | ||
849 | GST_manipulation_send (&obm->peer, | 820 | GST_manipulation_send (&obm->peer, |
850 | obmm, | 821 | obmm, |
851 | ntohs (obmm->size), | 822 | ntohs (obmm->size), |
@@ -870,33 +841,27 @@ handle_client_send (void *cls, | |||
870 | * never #GNUNET_NO | 841 | * never #GNUNET_NO |
871 | */ | 842 | */ |
872 | static void | 843 | static void |
873 | transmit_address_to_client (void *cls, | 844 | transmit_address_to_client (void *cls, const char *buf, int res) |
874 | const char *buf, | ||
875 | int res) | ||
876 | { | 845 | { |
877 | struct AddressToStringContext *actx = cls; | 846 | struct AddressToStringContext *actx = cls; |
878 | struct GNUNET_MQ_Envelope *env; | 847 | struct GNUNET_MQ_Envelope *env; |
879 | struct AddressToStringResultMessage *atsm; | 848 | struct AddressToStringResultMessage *atsm; |
880 | size_t slen; | 849 | size_t slen; |
881 | 850 | ||
882 | GNUNET_assert ( (GNUNET_OK == res) || | 851 | GNUNET_assert ((GNUNET_OK == res) || (GNUNET_SYSERR == res)); |
883 | (GNUNET_SYSERR == res) ); | ||
884 | if (NULL == actx->tc) | 852 | if (NULL == actx->tc) |
885 | return; | 853 | return; |
886 | if (NULL == buf) | 854 | if (NULL == buf) |
887 | { | 855 | { |
888 | env = GNUNET_MQ_msg (atsm, | 856 | env = GNUNET_MQ_msg (atsm, |
889 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY); | 857 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY); |
890 | if (GNUNET_OK == res) | 858 | if (GNUNET_OK == res) |
891 | { | 859 | { |
892 | /* this was the last call, transmit */ | 860 | /* this was the last call, transmit */ |
893 | atsm->res = htonl (GNUNET_OK); | 861 | atsm->res = htonl (GNUNET_OK); |
894 | atsm->addr_len = htonl (0); | 862 | atsm->addr_len = htonl (0); |
895 | GNUNET_MQ_send (actx->tc->mq, | 863 | GNUNET_MQ_send (actx->tc->mq, env); |
896 | env); | 864 | GNUNET_CONTAINER_DLL_remove (a2s_head, a2s_tail, actx); |
897 | GNUNET_CONTAINER_DLL_remove (a2s_head, | ||
898 | a2s_tail, | ||
899 | actx); | ||
900 | GNUNET_free (actx); | 865 | GNUNET_free (actx); |
901 | return; | 866 | return; |
902 | } | 867 | } |
@@ -905,24 +870,21 @@ transmit_address_to_client (void *cls, | |||
905 | /* address conversion failed, but there will be more callbacks */ | 870 | /* address conversion failed, but there will be more callbacks */ |
906 | atsm->res = htonl (GNUNET_SYSERR); | 871 | atsm->res = htonl (GNUNET_SYSERR); |
907 | atsm->addr_len = htonl (0); | 872 | atsm->addr_len = htonl (0); |
908 | GNUNET_MQ_send (actx->tc->mq, | 873 | GNUNET_MQ_send (actx->tc->mq, env); |
909 | env); | ||
910 | return; | 874 | return; |
911 | } | 875 | } |
912 | } | 876 | } |
913 | GNUNET_assert (GNUNET_OK == res); | 877 | GNUNET_assert (GNUNET_OK == res); |
914 | /* succesful conversion, append*/ | 878 | /* succesful conversion, append*/ |
915 | slen = strlen (buf) + 1; | 879 | slen = strlen (buf) + 1; |
916 | env = GNUNET_MQ_msg_extra (atsm, | 880 | env = |
917 | slen, | 881 | GNUNET_MQ_msg_extra (atsm, |
918 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY); | 882 | slen, |
883 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY); | ||
919 | atsm->res = htonl (GNUNET_YES); | 884 | atsm->res = htonl (GNUNET_YES); |
920 | atsm->addr_len = htonl (slen); | 885 | atsm->addr_len = htonl (slen); |
921 | GNUNET_memcpy (&atsm[1], | 886 | GNUNET_memcpy (&atsm[1], buf, slen); |
922 | buf, | 887 | GNUNET_MQ_send (actx->tc->mq, env); |
923 | slen); | ||
924 | GNUNET_MQ_send (actx->tc->mq, | ||
925 | env); | ||
926 | } | 888 | } |
927 | 889 | ||
928 | 890 | ||
@@ -935,7 +897,7 @@ transmit_address_to_client (void *cls, | |||
935 | */ | 897 | */ |
936 | static int | 898 | static int |
937 | check_client_address_to_string (void *cls, | 899 | check_client_address_to_string (void *cls, |
938 | const struct AddressLookupMessage *alum) | 900 | const struct AddressLookupMessage *alum) |
939 | { | 901 | { |
940 | const char *plugin_name; | 902 | const char *plugin_name; |
941 | const char *address; | 903 | const char *address; |
@@ -951,7 +913,8 @@ check_client_address_to_string (void *cls, | |||
951 | } | 913 | } |
952 | address = (const char *) &alum[1]; | 914 | address = (const char *) &alum[1]; |
953 | plugin_name = (const char *) &address[address_len]; | 915 | plugin_name = (const char *) &address[address_len]; |
954 | if ('\0' != plugin_name[size - sizeof (struct AddressLookupMessage) - address_len - 1]) | 916 | if ('\0' != plugin_name[size - sizeof (struct AddressLookupMessage) - |
917 | address_len - 1]) | ||
955 | { | 918 | { |
956 | GNUNET_break (0); | 919 | GNUNET_break (0); |
957 | return GNUNET_SYSERR; | 920 | return GNUNET_SYSERR; |
@@ -968,7 +931,7 @@ check_client_address_to_string (void *cls, | |||
968 | */ | 931 | */ |
969 | static void | 932 | static void |
970 | handle_client_address_to_string (void *cls, | 933 | handle_client_address_to_string (void *cls, |
971 | const struct AddressLookupMessage *alum) | 934 | const struct AddressLookupMessage *alum) |
972 | { | 935 | { |
973 | struct TransportClient *tc = cls; | 936 | struct TransportClient *tc = cls; |
974 | struct GNUNET_TRANSPORT_PluginFunctions *papi; | 937 | struct GNUNET_TRANSPORT_PluginFunctions *papi; |
@@ -993,24 +956,20 @@ handle_client_address_to_string (void *cls, | |||
993 | "Failed to find plugin `%s'\n", | 956 | "Failed to find plugin `%s'\n", |
994 | plugin_name); | 957 | plugin_name); |
995 | env = GNUNET_MQ_msg (atsm, | 958 | env = GNUNET_MQ_msg (atsm, |
996 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY); | 959 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY); |
997 | atsm->res = htonl (GNUNET_SYSERR); | 960 | atsm->res = htonl (GNUNET_SYSERR); |
998 | atsm->addr_len = htonl (0); | 961 | atsm->addr_len = htonl (0); |
999 | GNUNET_MQ_send (tc->mq, | 962 | GNUNET_MQ_send (tc->mq, env); |
1000 | env); | ||
1001 | env = GNUNET_MQ_msg (atsm, | 963 | env = GNUNET_MQ_msg (atsm, |
1002 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY); | 964 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING_REPLY); |
1003 | atsm->res = htonl (GNUNET_OK); | 965 | atsm->res = htonl (GNUNET_OK); |
1004 | atsm->addr_len = htonl (0); | 966 | atsm->addr_len = htonl (0); |
1005 | GNUNET_MQ_send (tc->mq, | 967 | GNUNET_MQ_send (tc->mq, env); |
1006 | env); | ||
1007 | return; | 968 | return; |
1008 | } | 969 | } |
1009 | actx = GNUNET_new (struct AddressToStringContext); | 970 | actx = GNUNET_new (struct AddressToStringContext); |
1010 | actx->tc = tc; | 971 | actx->tc = tc; |
1011 | GNUNET_CONTAINER_DLL_insert (a2s_head, | 972 | GNUNET_CONTAINER_DLL_insert (a2s_head, a2s_tail, actx); |
1012 | a2s_tail, | ||
1013 | actx); | ||
1014 | GNUNET_SERVICE_client_disable_continue_warning (tc->client); | 973 | GNUNET_SERVICE_client_disable_continue_warning (tc->client); |
1015 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 974 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1016 | "Pretty-printing address of %u bytes using plugin `%s'\n", | 975 | "Pretty-printing address of %u bytes using plugin `%s'\n", |
@@ -1019,7 +978,7 @@ handle_client_address_to_string (void *cls, | |||
1019 | papi->address_pretty_printer (papi->cls, | 978 | papi->address_pretty_printer (papi->cls, |
1020 | plugin_name, | 979 | plugin_name, |
1021 | address, | 980 | address, |
1022 | address_len, | 981 | address_len, |
1023 | numeric, | 982 | numeric, |
1024 | rtimeout, | 983 | rtimeout, |
1025 | &transmit_address_to_client, | 984 | &transmit_address_to_client, |
@@ -1035,8 +994,9 @@ handle_client_address_to_string (void *cls, | |||
1035 | * @return composed message | 994 | * @return composed message |
1036 | */ | 995 | */ |
1037 | static struct PeerIterateResponseMessage * | 996 | static struct PeerIterateResponseMessage * |
1038 | compose_address_iterate_response_message (const struct GNUNET_PeerIdentity *peer, | 997 | compose_address_iterate_response_message ( |
1039 | const struct GNUNET_HELLO_Address *address) | 998 | const struct GNUNET_PeerIdentity *peer, |
999 | const struct GNUNET_HELLO_Address *address) | ||
1040 | { | 1000 | { |
1041 | struct PeerIterateResponseMessage *msg; | 1001 | struct PeerIterateResponseMessage *msg; |
1042 | size_t size; | 1002 | size_t size; |
@@ -1058,8 +1018,8 @@ compose_address_iterate_response_message (const struct GNUNET_PeerIdentity *peer | |||
1058 | size = (sizeof (struct PeerIterateResponseMessage) + alen + tlen); | 1018 | size = (sizeof (struct PeerIterateResponseMessage) + alen + tlen); |
1059 | msg = GNUNET_malloc (size); | 1019 | msg = GNUNET_malloc (size); |
1060 | msg->header.size = htons (size); | 1020 | msg->header.size = htons (size); |
1061 | msg->header.type | 1021 | msg->header.type = |
1062 | = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE); | 1022 | htons (GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE); |
1063 | msg->reserved = htonl (0); | 1023 | msg->reserved = htonl (0); |
1064 | msg->peer = *peer; | 1024 | msg->peer = *peer; |
1065 | msg->addrlen = htonl (alen); | 1025 | msg->addrlen = htonl (alen); |
@@ -1067,14 +1027,10 @@ compose_address_iterate_response_message (const struct GNUNET_PeerIdentity *peer | |||
1067 | 1027 | ||
1068 | if (NULL != address) | 1028 | if (NULL != address) |
1069 | { | 1029 | { |
1070 | msg->local_address_info = htonl((uint32_t) address->local_info); | 1030 | msg->local_address_info = htonl ((uint32_t) address->local_info); |
1071 | addr = (char *) &msg[1]; | 1031 | addr = (char *) &msg[1]; |
1072 | GNUNET_memcpy (addr, | 1032 | GNUNET_memcpy (addr, address->address, alen); |
1073 | address->address, | 1033 | GNUNET_memcpy (&addr[alen], address->transport_name, tlen); |
1074 | alen); | ||
1075 | GNUNET_memcpy (&addr[alen], | ||
1076 | address->transport_name, | ||
1077 | tlen); | ||
1078 | } | 1034 | } |
1079 | return msg; | 1035 | return msg; |
1080 | } | 1036 | } |
@@ -1127,24 +1083,19 @@ send_peer_information (void *cls, | |||
1127 | struct GNUNET_MQ_Envelope *env; | 1083 | struct GNUNET_MQ_Envelope *env; |
1128 | struct PeerIterateResponseMessage *msg; | 1084 | struct PeerIterateResponseMessage *msg; |
1129 | 1085 | ||
1130 | if ( (GNUNET_YES != pc->all) && | 1086 | if ((GNUNET_YES != pc->all) && (0 != memcmp (peer, &pc->id, sizeof (pc->id)))) |
1131 | (0 != memcmp (peer, | ||
1132 | &pc->id, | ||
1133 | sizeof (pc->id))) ) | ||
1134 | return; | 1087 | return; |
1135 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1088 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1136 | "Sending information about `%s' using address `%s' in state `%s'\n", | 1089 | "Sending information about `%s' using address `%s' in state `%s'\n", |
1137 | GNUNET_i2s(peer), | 1090 | GNUNET_i2s (peer), |
1138 | (NULL != address) ? GST_plugins_a2s (address) : "<none>", | 1091 | (NULL != address) ? GST_plugins_a2s (address) : "<none>", |
1139 | GNUNET_TRANSPORT_ps2s (state)); | 1092 | GNUNET_TRANSPORT_ps2s (state)); |
1140 | msg = compose_address_iterate_response_message (peer, | 1093 | msg = compose_address_iterate_response_message (peer, address); |
1141 | address); | ||
1142 | msg->state = htonl (state); | 1094 | msg->state = htonl (state); |
1143 | msg->state_timeout = GNUNET_TIME_absolute_hton(state_timeout); | 1095 | msg->state_timeout = GNUNET_TIME_absolute_hton (state_timeout); |
1144 | env = GNUNET_MQ_msg_copy (&msg->header); | 1096 | env = GNUNET_MQ_msg_copy (&msg->header); |
1145 | GNUNET_free (msg); | 1097 | GNUNET_free (msg); |
1146 | GNUNET_MQ_send (pc->tc->mq, | 1098 | GNUNET_MQ_send (pc->tc->mq, env); |
1147 | env); | ||
1148 | } | 1099 | } |
1149 | 1100 | ||
1150 | 1101 | ||
@@ -1156,8 +1107,7 @@ send_peer_information (void *cls, | |||
1156 | * @param msg the peer address information request | 1107 | * @param msg the peer address information request |
1157 | */ | 1108 | */ |
1158 | static void | 1109 | static void |
1159 | handle_client_monitor_peers (void *cls, | 1110 | handle_client_monitor_peers (void *cls, const struct PeerMonitorMessage *msg) |
1160 | const struct PeerMonitorMessage *msg) | ||
1161 | { | 1111 | { |
1162 | struct TransportClient *tc = cls; | 1112 | struct TransportClient *tc = cls; |
1163 | struct IterationContext pc; | 1113 | struct IterationContext pc; |
@@ -1173,9 +1123,7 @@ handle_client_monitor_peers (void *cls, | |||
1173 | 1123 | ||
1174 | /* Send initial list */ | 1124 | /* Send initial list */ |
1175 | pc.tc = tc; | 1125 | pc.tc = tc; |
1176 | if (0 == memcmp (&msg->peer, | 1126 | if (0 == memcmp (&msg->peer, &all_zeros, sizeof (struct GNUNET_PeerIdentity))) |
1177 | &all_zeros, | ||
1178 | sizeof (struct GNUNET_PeerIdentity))) | ||
1179 | { | 1127 | { |
1180 | /* iterate over all neighbours */ | 1128 | /* iterate over all neighbours */ |
1181 | pc.all = GNUNET_YES; | 1129 | pc.all = GNUNET_YES; |
@@ -1187,34 +1135,32 @@ handle_client_monitor_peers (void *cls, | |||
1187 | pc.all = GNUNET_NO; | 1135 | pc.all = GNUNET_NO; |
1188 | pc.id = msg->peer; | 1136 | pc.id = msg->peer; |
1189 | } | 1137 | } |
1190 | GST_neighbours_iterate (&send_peer_information, | 1138 | GST_neighbours_iterate (&send_peer_information, &pc); |
1191 | &pc); | ||
1192 | 1139 | ||
1193 | if (GNUNET_YES != ntohl (msg->one_shot)) | 1140 | if (GNUNET_YES != ntohl (msg->one_shot)) |
1194 | { | 1141 | { |
1195 | tc->details.monitor_peer = msg->peer; | 1142 | tc->details.monitor_peer = msg->peer; |
1196 | tc->type = CT_MONITOR; | 1143 | tc->type = CT_MONITOR; |
1197 | if (0 != memcmp (&msg->peer, | 1144 | if (0 != |
1198 | &all_zeros, | 1145 | memcmp (&msg->peer, &all_zeros, sizeof (struct GNUNET_PeerIdentity))) |
1199 | sizeof (struct GNUNET_PeerIdentity))) | ||
1200 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1146 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1201 | "Client %p started monitoring of the peer `%s'\n", | 1147 | "Client %p started monitoring of the peer `%s'\n", |
1202 | tc, | 1148 | tc, |
1203 | GNUNET_i2s (&msg->peer)); | 1149 | GNUNET_i2s (&msg->peer)); |
1204 | else | 1150 | else |
1205 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1151 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1206 | "Client %p started monitoring all peers\n", | 1152 | "Client %p started monitoring all peers\n", |
1207 | tc); | 1153 | tc); |
1208 | } | 1154 | } |
1209 | else | 1155 | else |
1210 | { | 1156 | { |
1211 | struct GNUNET_MessageHeader *msg; | 1157 | struct GNUNET_MessageHeader *msg; |
1212 | struct GNUNET_MQ_Envelope *env; | 1158 | struct GNUNET_MQ_Envelope *env; |
1213 | 1159 | ||
1214 | env = GNUNET_MQ_msg (msg, | 1160 | env = |
1215 | GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE_END); | 1161 | GNUNET_MQ_msg (msg, |
1216 | GNUNET_MQ_send (tc->mq, | 1162 | GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_RESPONSE_END); |
1217 | env); | 1163 | GNUNET_MQ_send (tc->mq, env); |
1218 | } | 1164 | } |
1219 | } | 1165 | } |
1220 | 1166 | ||
@@ -1233,8 +1179,8 @@ handle_client_monitor_peers (void *cls, | |||
1233 | */ | 1179 | */ |
1234 | static void | 1180 | static void |
1235 | plugin_session_info_cb (void *cls, | 1181 | plugin_session_info_cb (void *cls, |
1236 | struct GNUNET_ATS_Session *session, | 1182 | struct GNUNET_ATS_Session *session, |
1237 | const struct GNUNET_TRANSPORT_SessionInfo *info) | 1183 | const struct GNUNET_TRANSPORT_SessionInfo *info) |
1238 | { | 1184 | { |
1239 | struct GNUNET_MQ_Envelope *env; | 1185 | struct GNUNET_MQ_Envelope *env; |
1240 | struct TransportPluginMonitorMessage *msg; | 1186 | struct TransportPluginMonitorMessage *msg; |
@@ -1247,20 +1193,17 @@ plugin_session_info_cb (void *cls, | |||
1247 | 1193 | ||
1248 | if (0 == GNUNET_notification_context_get_size (plugin_nc)) | 1194 | if (0 == GNUNET_notification_context_get_size (plugin_nc)) |
1249 | { | 1195 | { |
1250 | GST_plugins_monitor_subscribe (NULL, | 1196 | GST_plugins_monitor_subscribe (NULL, NULL); |
1251 | NULL); | ||
1252 | return; | 1197 | return; |
1253 | } | 1198 | } |
1254 | if ( (NULL == info) && | 1199 | if ((NULL == info) && (NULL == session)) |
1255 | (NULL == session) ) | ||
1256 | { | 1200 | { |
1257 | /* end of initial iteration */ | 1201 | /* end of initial iteration */ |
1258 | if (NULL != sync_client) | 1202 | if (NULL != sync_client) |
1259 | { | 1203 | { |
1260 | env = GNUNET_MQ_msg (sync, | 1204 | env = |
1261 | GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_SYNC); | 1205 | GNUNET_MQ_msg (sync, GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_SYNC); |
1262 | GNUNET_MQ_send (sync_client->mq, | 1206 | GNUNET_MQ_send (sync_client->mq, env); |
1263 | env); | ||
1264 | sync_client = NULL; | 1207 | sync_client = NULL; |
1265 | } | 1208 | } |
1266 | return; | 1209 | return; |
@@ -1292,26 +1235,19 @@ plugin_session_info_cb (void *cls, | |||
1292 | msg->plugin_name_len = htons (slen); | 1235 | msg->plugin_name_len = htons (slen); |
1293 | msg->plugin_address_len = htons (alen); | 1236 | msg->plugin_address_len = htons (alen); |
1294 | name = (char *) &msg[1]; | 1237 | name = (char *) &msg[1]; |
1295 | GNUNET_memcpy (name, | 1238 | GNUNET_memcpy (name, info->address->transport_name, slen); |
1296 | info->address->transport_name, | ||
1297 | slen); | ||
1298 | addr = &name[slen]; | 1239 | addr = &name[slen]; |
1299 | GNUNET_memcpy (addr, | 1240 | GNUNET_memcpy (addr, info->address->address, alen); |
1300 | info->address->address, | ||
1301 | alen); | ||
1302 | if (NULL != sync_client) | 1241 | if (NULL != sync_client) |
1303 | { | 1242 | { |
1304 | struct GNUNET_MQ_Envelope *env; | 1243 | struct GNUNET_MQ_Envelope *env; |
1305 | 1244 | ||
1306 | env = GNUNET_MQ_msg_copy (&msg->header); | 1245 | env = GNUNET_MQ_msg_copy (&msg->header); |
1307 | GNUNET_MQ_send (sync_client->mq, | 1246 | GNUNET_MQ_send (sync_client->mq, env); |
1308 | env); | ||
1309 | } | 1247 | } |
1310 | else | 1248 | else |
1311 | { | 1249 | { |
1312 | GNUNET_notification_context_broadcast (plugin_nc, | 1250 | GNUNET_notification_context_broadcast (plugin_nc, &msg->header, GNUNET_NO); |
1313 | &msg->header, | ||
1314 | GNUNET_NO); | ||
1315 | } | 1251 | } |
1316 | GNUNET_free (msg); | 1252 | GNUNET_free (msg); |
1317 | } | 1253 | } |
@@ -1325,18 +1261,16 @@ plugin_session_info_cb (void *cls, | |||
1325 | */ | 1261 | */ |
1326 | static void | 1262 | static void |
1327 | handle_client_monitor_plugins (void *cls, | 1263 | handle_client_monitor_plugins (void *cls, |
1328 | const struct GNUNET_MessageHeader *message) | 1264 | const struct GNUNET_MessageHeader *message) |
1329 | { | 1265 | { |
1330 | struct TransportClient *tc = cls; | 1266 | struct TransportClient *tc = cls; |
1331 | 1267 | ||
1332 | GNUNET_SERVICE_client_mark_monitor (tc->client); | 1268 | GNUNET_SERVICE_client_mark_monitor (tc->client); |
1333 | GNUNET_SERVICE_client_disable_continue_warning (tc->client); | 1269 | GNUNET_SERVICE_client_disable_continue_warning (tc->client); |
1334 | GNUNET_notification_context_add (plugin_nc, | 1270 | GNUNET_notification_context_add (plugin_nc, tc->mq); |
1335 | tc->mq); | ||
1336 | GNUNET_assert (NULL == sync_client); | 1271 | GNUNET_assert (NULL == sync_client); |
1337 | sync_client = tc; | 1272 | sync_client = tc; |
1338 | GST_plugins_monitor_subscribe (&plugin_session_info_cb, | 1273 | GST_plugins_monitor_subscribe (&plugin_session_info_cb, NULL); |
1339 | NULL); | ||
1340 | } | 1274 | } |
1341 | 1275 | ||
1342 | 1276 | ||
@@ -1347,8 +1281,7 @@ handle_client_monitor_plugins (void *cls, | |||
1347 | * @param may_drop #GNUNET_YES if the message can be dropped / is payload | 1281 | * @param may_drop #GNUNET_YES if the message can be dropped / is payload |
1348 | */ | 1282 | */ |
1349 | void | 1283 | void |
1350 | GST_clients_broadcast (const struct GNUNET_MessageHeader *msg, | 1284 | GST_clients_broadcast (const struct GNUNET_MessageHeader *msg, int may_drop) |
1351 | int may_drop) | ||
1352 | { | 1285 | { |
1353 | int done; | 1286 | int done; |
1354 | 1287 | ||
@@ -1357,24 +1290,19 @@ GST_clients_broadcast (const struct GNUNET_MessageHeader *msg, | |||
1357 | (unsigned int) ntohs (msg->type), | 1290 | (unsigned int) ntohs (msg->type), |
1358 | (unsigned int) ntohs (msg->size)); | 1291 | (unsigned int) ntohs (msg->size)); |
1359 | done = GNUNET_NO; | 1292 | done = GNUNET_NO; |
1360 | for (struct TransportClient *tc = clients_head; | 1293 | for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next) |
1361 | NULL != tc; | ||
1362 | tc = tc->next) | ||
1363 | { | 1294 | { |
1364 | if (CT_NONE == tc->type) | 1295 | if (CT_NONE == tc->type) |
1365 | continue; /* client not yet ready */ | 1296 | continue; /* client not yet ready */ |
1366 | if ( (GNUNET_YES == may_drop) && | 1297 | if ((GNUNET_YES == may_drop) && (CT_CORE != tc->type)) |
1367 | (CT_CORE != tc->type) ) | ||
1368 | continue; /* skip, this client does not care about payload */ | 1298 | continue; /* skip, this client does not care about payload */ |
1369 | unicast (tc, | 1299 | unicast (tc, msg, may_drop); |
1370 | msg, | ||
1371 | may_drop); | ||
1372 | done = GNUNET_YES; | 1300 | done = GNUNET_YES; |
1373 | } | 1301 | } |
1374 | if (GNUNET_NO == done) | 1302 | if (GNUNET_NO == done) |
1375 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1303 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1376 | "Message of type %u not delivered, is CORE service up?\n", | 1304 | "Message of type %u not delivered, is CORE service up?\n", |
1377 | ntohs (msg->type)); | 1305 | ntohs (msg->type)); |
1378 | } | 1306 | } |
1379 | 1307 | ||
1380 | 1308 | ||
@@ -1387,34 +1315,31 @@ GST_clients_broadcast (const struct GNUNET_MessageHeader *msg, | |||
1387 | * @param state_timeout the time out for the state | 1315 | * @param state_timeout the time out for the state |
1388 | */ | 1316 | */ |
1389 | void | 1317 | void |
1390 | GST_clients_broadcast_peer_notification (const struct GNUNET_PeerIdentity *peer, | 1318 | GST_clients_broadcast_peer_notification ( |
1391 | const struct GNUNET_HELLO_Address *address, | 1319 | const struct GNUNET_PeerIdentity *peer, |
1392 | enum GNUNET_TRANSPORT_PeerState state, | 1320 | const struct GNUNET_HELLO_Address *address, |
1393 | struct GNUNET_TIME_Absolute state_timeout) | 1321 | enum GNUNET_TRANSPORT_PeerState state, |
1322 | struct GNUNET_TIME_Absolute state_timeout) | ||
1394 | { | 1323 | { |
1395 | struct GNUNET_MQ_Envelope *env; | 1324 | struct GNUNET_MQ_Envelope *env; |
1396 | struct PeerIterateResponseMessage *msg; | 1325 | struct PeerIterateResponseMessage *msg; |
1397 | 1326 | ||
1398 | msg = compose_address_iterate_response_message (peer, | 1327 | msg = compose_address_iterate_response_message (peer, address); |
1399 | address); | ||
1400 | msg->state = htonl (state); | 1328 | msg->state = htonl (state); |
1401 | msg->state_timeout = GNUNET_TIME_absolute_hton (state_timeout); | 1329 | msg->state_timeout = GNUNET_TIME_absolute_hton (state_timeout); |
1402 | for (struct TransportClient *tc = clients_head; | 1330 | for (struct TransportClient *tc = clients_head; NULL != tc; tc = tc->next) |
1403 | NULL != tc; | ||
1404 | tc = tc->next) | ||
1405 | { | 1331 | { |
1406 | if (CT_MONITOR != tc->type) | 1332 | if (CT_MONITOR != tc->type) |
1407 | continue; | 1333 | continue; |
1408 | if ((0 == memcmp (&tc->details.monitor_peer, | 1334 | if ((0 == memcmp (&tc->details.monitor_peer, |
1409 | &all_zeros, | 1335 | &all_zeros, |
1410 | sizeof (struct GNUNET_PeerIdentity))) || | 1336 | sizeof (struct GNUNET_PeerIdentity))) || |
1411 | (0 == memcmp (&tc->details.monitor_peer, | 1337 | (0 == memcmp (&tc->details.monitor_peer, |
1412 | peer, | 1338 | peer, |
1413 | sizeof (struct GNUNET_PeerIdentity)))) | 1339 | sizeof (struct GNUNET_PeerIdentity)))) |
1414 | { | 1340 | { |
1415 | env = GNUNET_MQ_msg_copy (&msg->header); | 1341 | env = GNUNET_MQ_msg_copy (&msg->header); |
1416 | GNUNET_MQ_send (tc->mq, | 1342 | GNUNET_MQ_send (tc->mq, env); |
1417 | env); | ||
1418 | } | 1343 | } |
1419 | } | 1344 | } |
1420 | GNUNET_free (msg); | 1345 | GNUNET_free (msg); |
@@ -1431,9 +1356,7 @@ GST_clients_broadcast_peer_notification (const struct GNUNET_PeerIdentity *peer, | |||
1431 | * @return #GNUNET_OK (continue to iterate) | 1356 | * @return #GNUNET_OK (continue to iterate) |
1432 | */ | 1357 | */ |
1433 | static int | 1358 | static int |
1434 | mark_peer_down (void *cls, | 1359 | mark_peer_down (void *cls, const struct GNUNET_PeerIdentity *peer, void *value) |
1435 | const struct GNUNET_PeerIdentity *peer, | ||
1436 | void *value) | ||
1437 | { | 1360 | { |
1438 | struct SendTransmitContinuationContext *stcc = value; | 1361 | struct SendTransmitContinuationContext *stcc = value; |
1439 | 1362 | ||
@@ -1457,13 +1380,11 @@ GST_clients_broadcast_disconnect (const struct GNUNET_PeerIdentity *peer) | |||
1457 | peer, | 1380 | peer, |
1458 | &mark_peer_down, | 1381 | &mark_peer_down, |
1459 | NULL); | 1382 | NULL); |
1460 | disconnect_msg.header.size = htons (sizeof(struct DisconnectInfoMessage)); | 1383 | disconnect_msg.header.size = htons (sizeof (struct DisconnectInfoMessage)); |
1461 | disconnect_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT); | 1384 | disconnect_msg.header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_DISCONNECT); |
1462 | disconnect_msg.reserved = htonl (0); | 1385 | disconnect_msg.reserved = htonl (0); |
1463 | disconnect_msg.peer = *peer; | 1386 | disconnect_msg.peer = *peer; |
1464 | GST_clients_broadcast (&disconnect_msg.header, | 1387 | GST_clients_broadcast (&disconnect_msg.header, GNUNET_NO); |
1465 | GNUNET_NO); | ||
1466 | |||
1467 | } | 1388 | } |
1468 | 1389 | ||
1469 | 1390 | ||
@@ -1481,28 +1402,25 @@ GST_clients_broadcast_disconnect (const struct GNUNET_PeerIdentity *peer) | |||
1481 | static void | 1402 | static void |
1482 | transmit_our_hello (void *cls, | 1403 | transmit_our_hello (void *cls, |
1483 | const struct GNUNET_PeerIdentity *peer, | 1404 | const struct GNUNET_PeerIdentity *peer, |
1484 | const struct GNUNET_HELLO_Address *address, | 1405 | const struct GNUNET_HELLO_Address *address, |
1485 | enum GNUNET_TRANSPORT_PeerState state, | 1406 | enum GNUNET_TRANSPORT_PeerState state, |
1486 | struct GNUNET_TIME_Absolute state_timeout, | 1407 | struct GNUNET_TIME_Absolute state_timeout, |
1487 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | 1408 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, |
1488 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) | 1409 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) |
1489 | { | 1410 | { |
1490 | const struct GNUNET_MessageHeader *hello = cls; | 1411 | const struct GNUNET_MessageHeader *hello = cls; |
1491 | 1412 | ||
1492 | if (0 == | 1413 | if (0 == memcmp (peer, &GST_my_identity, sizeof (struct GNUNET_PeerIdentity))) |
1493 | memcmp (peer, | ||
1494 | &GST_my_identity, | ||
1495 | sizeof (struct GNUNET_PeerIdentity))) | ||
1496 | return; /* not to ourselves */ | 1414 | return; /* not to ourselves */ |
1497 | if (GNUNET_NO == GST_neighbours_test_connected (peer)) | 1415 | if (GNUNET_NO == GST_neighbours_test_connected (peer)) |
1498 | return; | 1416 | return; |
1499 | 1417 | ||
1500 | GST_neighbours_send (peer, | 1418 | GST_neighbours_send (peer, |
1501 | hello, | 1419 | hello, |
1502 | ntohs (hello->size), | 1420 | ntohs (hello->size), |
1503 | hello_expiration, | 1421 | hello_expiration, |
1504 | NULL, | 1422 | NULL, |
1505 | NULL); | 1423 | NULL); |
1506 | } | 1424 | } |
1507 | 1425 | ||
1508 | 1426 | ||
@@ -1513,16 +1431,12 @@ transmit_our_hello (void *cls, | |||
1513 | * @param hello new HELLO | 1431 | * @param hello new HELLO |
1514 | */ | 1432 | */ |
1515 | static void | 1433 | static void |
1516 | process_hello_update (void *cls, | 1434 | process_hello_update (void *cls, const struct GNUNET_MessageHeader *hello) |
1517 | const struct GNUNET_MessageHeader *hello) | ||
1518 | { | 1435 | { |
1519 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1436 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Broadcasting HELLO to clients\n"); |
1520 | "Broadcasting HELLO to clients\n"); | ||
1521 | GST_clients_broadcast (hello, GNUNET_NO); | 1437 | GST_clients_broadcast (hello, GNUNET_NO); |
1522 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1438 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Broadcasting HELLO to neighbours\n"); |
1523 | "Broadcasting HELLO to neighbours\n"); | 1439 | GST_neighbours_iterate (&transmit_our_hello, (void *) hello); |
1524 | GST_neighbours_iterate (&transmit_our_hello, | ||
1525 | (void *) hello); | ||
1526 | } | 1440 | } |
1527 | 1441 | ||
1528 | 1442 | ||
@@ -1545,13 +1459,13 @@ process_payload (const struct GNUNET_HELLO_Address *address, | |||
1545 | int do_forward; | 1459 | int do_forward; |
1546 | struct InboundMessage *im; | 1460 | struct InboundMessage *im; |
1547 | size_t msg_size = ntohs (message->size); | 1461 | size_t msg_size = ntohs (message->size); |
1548 | size_t size = sizeof(struct InboundMessage) + msg_size; | 1462 | size_t size = sizeof (struct InboundMessage) + msg_size; |
1549 | char buf[size] GNUNET_ALIGN; | 1463 | char buf[size] GNUNET_ALIGN; |
1550 | 1464 | ||
1551 | do_forward = GNUNET_SYSERR; | 1465 | do_forward = GNUNET_SYSERR; |
1552 | ret = GST_neighbours_calculate_receive_delay (&address->peer, | 1466 | ret = GST_neighbours_calculate_receive_delay (&address->peer, |
1553 | msg_size, | 1467 | msg_size, |
1554 | &do_forward); | 1468 | &do_forward); |
1555 | if (! GST_neighbours_test_connected (&address->peer)) | 1469 | if (! GST_neighbours_test_connected (&address->peer)) |
1556 | { | 1470 | { |
1557 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1471 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1559,10 +1473,11 @@ process_payload (const struct GNUNET_HELLO_Address *address, | |||
1559 | (unsigned int) msg_size, | 1473 | (unsigned int) msg_size, |
1560 | ntohs (message->type), | 1474 | ntohs (message->type), |
1561 | GNUNET_i2s (&address->peer)); | 1475 | GNUNET_i2s (&address->peer)); |
1562 | GNUNET_STATISTICS_update (GST_stats, gettext_noop | 1476 | GNUNET_STATISTICS_update ( |
1563 | ("# bytes payload discarded due to not connected peer"), | 1477 | GST_stats, |
1564 | msg_size, | 1478 | gettext_noop ("# bytes payload discarded due to not connected peer"), |
1565 | GNUNET_NO); | 1479 | msg_size, |
1480 | GNUNET_NO); | ||
1566 | return ret; | 1481 | return ret; |
1567 | } | 1482 | } |
1568 | 1483 | ||
@@ -1572,11 +1487,8 @@ process_payload (const struct GNUNET_HELLO_Address *address, | |||
1572 | im->header.size = htons (size); | 1487 | im->header.size = htons (size); |
1573 | im->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RECV); | 1488 | im->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_RECV); |
1574 | im->peer = address->peer; | 1489 | im->peer = address->peer; |
1575 | GNUNET_memcpy (&im[1], | 1490 | GNUNET_memcpy (&im[1], message, ntohs (message->size)); |
1576 | message, | 1491 | GST_clients_broadcast (&im->header, GNUNET_YES); |
1577 | ntohs (message->size)); | ||
1578 | GST_clients_broadcast (&im->header, | ||
1579 | GNUNET_YES); | ||
1580 | return ret; | 1492 | return ret; |
1581 | } | 1493 | } |
1582 | 1494 | ||
@@ -1592,12 +1504,9 @@ kill_session_task (void *cls) | |||
1592 | struct GNUNET_ATS_SessionKiller *sk = cls; | 1504 | struct GNUNET_ATS_SessionKiller *sk = cls; |
1593 | 1505 | ||
1594 | sk->task = NULL; | 1506 | sk->task = NULL; |
1595 | GNUNET_CONTAINER_DLL_remove (sk_head, | 1507 | GNUNET_CONTAINER_DLL_remove (sk_head, sk_tail, sk); |
1596 | sk_tail, | 1508 | sk->plugin->disconnect_session (sk->plugin->cls, sk->session); |
1597 | sk); | 1509 | GNUNET_free (sk); |
1598 | sk->plugin->disconnect_session (sk->plugin->cls, | ||
1599 | sk->session); | ||
1600 | GNUNET_free(sk); | ||
1601 | } | 1510 | } |
1602 | 1511 | ||
1603 | 1512 | ||
@@ -1609,8 +1518,7 @@ kill_session_task (void *cls) | |||
1609 | * @param session session to termiante | 1518 | * @param session session to termiante |
1610 | */ | 1519 | */ |
1611 | static void | 1520 | static void |
1612 | kill_session (const char *plugin_name, | 1521 | kill_session (const char *plugin_name, struct GNUNET_ATS_Session *session) |
1613 | struct GNUNET_ATS_Session *session) | ||
1614 | { | 1522 | { |
1615 | struct GNUNET_TRANSPORT_PluginFunctions *plugin; | 1523 | struct GNUNET_TRANSPORT_PluginFunctions *plugin; |
1616 | struct GNUNET_ATS_SessionKiller *sk; | 1524 | struct GNUNET_ATS_SessionKiller *sk; |
@@ -1621,18 +1529,15 @@ kill_session (const char *plugin_name, | |||
1621 | plugin = GST_plugins_find (plugin_name); | 1529 | plugin = GST_plugins_find (plugin_name); |
1622 | if (NULL == plugin) | 1530 | if (NULL == plugin) |
1623 | { | 1531 | { |
1624 | GNUNET_break(0); | 1532 | GNUNET_break (0); |
1625 | return; | 1533 | return; |
1626 | } | 1534 | } |
1627 | /* need to issue disconnect asynchronously */ | 1535 | /* need to issue disconnect asynchronously */ |
1628 | sk = GNUNET_new (struct GNUNET_ATS_SessionKiller); | 1536 | sk = GNUNET_new (struct GNUNET_ATS_SessionKiller); |
1629 | sk->session = session; | 1537 | sk->session = session; |
1630 | sk->plugin = plugin; | 1538 | sk->plugin = plugin; |
1631 | sk->task = GNUNET_SCHEDULER_add_now (&kill_session_task, | 1539 | sk->task = GNUNET_SCHEDULER_add_now (&kill_session_task, sk); |
1632 | sk); | 1540 | GNUNET_CONTAINER_DLL_insert (sk_head, sk_tail, sk); |
1633 | GNUNET_CONTAINER_DLL_insert (sk_head, | ||
1634 | sk_tail, | ||
1635 | sk); | ||
1636 | } | 1541 | } |
1637 | 1542 | ||
1638 | 1543 | ||
@@ -1649,8 +1554,8 @@ kill_session (const char *plugin_name, | |||
1649 | static void | 1554 | static void |
1650 | connect_bl_check_cont (void *cls, | 1555 | connect_bl_check_cont (void *cls, |
1651 | const struct GNUNET_PeerIdentity *peer, | 1556 | const struct GNUNET_PeerIdentity *peer, |
1652 | const struct GNUNET_HELLO_Address *address, | 1557 | const struct GNUNET_HELLO_Address *address, |
1653 | struct GNUNET_ATS_Session *session, | 1558 | struct GNUNET_ATS_Session *session, |
1654 | int result) | 1559 | int result) |
1655 | { | 1560 | { |
1656 | struct GNUNET_MessageHeader *msg = cls; | 1561 | struct GNUNET_MessageHeader *msg = cls; |
@@ -1662,14 +1567,10 @@ connect_bl_check_cont (void *cls, | |||
1662 | "Received SYN message from peer `%s' at `%s'\n", | 1567 | "Received SYN message from peer `%s' at `%s'\n", |
1663 | GNUNET_i2s (peer), | 1568 | GNUNET_i2s (peer), |
1664 | GST_plugins_a2s (address)); | 1569 | GST_plugins_a2s (address)); |
1665 | if (GNUNET_OK != | 1570 | if (GNUNET_OK != GST_neighbours_handle_session_syn (msg, peer)) |
1666 | GST_neighbours_handle_session_syn (msg, | ||
1667 | peer)) | ||
1668 | { | 1571 | { |
1669 | GST_blacklist_abort_matching (address, | 1572 | GST_blacklist_abort_matching (address, session); |
1670 | session); | 1573 | kill_session (address->transport_name, session); |
1671 | kill_session (address->transport_name, | ||
1672 | session); | ||
1673 | } | 1574 | } |
1674 | GNUNET_free (msg); | 1575 | GNUNET_free (msg); |
1675 | return; | 1576 | return; |
@@ -1679,10 +1580,9 @@ connect_bl_check_cont (void *cls, | |||
1679 | return; /* check was aborted, session destroyed */ | 1580 | return; /* check was aborted, session destroyed */ |
1680 | /* Blacklist denies to speak to this peer */ | 1581 | /* Blacklist denies to speak to this peer */ |
1681 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1582 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1682 | "Discarding SYN message from `%s' due to denied blacklist check\n", | 1583 | "Discarding SYN message from `%s' due to denied blacklist check\n", |
1683 | GNUNET_i2s (peer)); | 1584 | GNUNET_i2s (peer)); |
1684 | kill_session (address->transport_name, | 1585 | kill_session (address->transport_name, session); |
1685 | session); | ||
1686 | } | 1586 | } |
1687 | 1587 | ||
1688 | 1588 | ||
@@ -1723,8 +1623,7 @@ GST_receive_callback (void *cls, | |||
1723 | gettext_noop ("# bytes total received"), | 1623 | gettext_noop ("# bytes total received"), |
1724 | ntohs (message->size), | 1624 | ntohs (message->size), |
1725 | GNUNET_NO); | 1625 | GNUNET_NO); |
1726 | GST_neighbours_notify_data_recv (address, | 1626 | GST_neighbours_notify_data_recv (address, message); |
1727 | message); | ||
1728 | switch (type) | 1627 | switch (type) |
1729 | { | 1628 | { |
1730 | case GNUNET_MESSAGE_TYPE_HELLO_LEGACY: | 1629 | case GNUNET_MESSAGE_TYPE_HELLO_LEGACY: |
@@ -1734,8 +1633,7 @@ GST_receive_callback (void *cls, | |||
1734 | if (GNUNET_OK != GST_validation_handle_hello (message)) | 1633 | if (GNUNET_OK != GST_validation_handle_hello (message)) |
1735 | { | 1634 | { |
1736 | GNUNET_break_op (0); | 1635 | GNUNET_break_op (0); |
1737 | GST_blacklist_abort_matching (address, | 1636 | GST_blacklist_abort_matching (address, session); |
1738 | session); | ||
1739 | } | 1637 | } |
1740 | return ret; | 1638 | return ret; |
1741 | case GNUNET_MESSAGE_TYPE_TRANSPORT_PING: | 1639 | case GNUNET_MESSAGE_TYPE_TRANSPORT_PING: |
@@ -1743,45 +1641,35 @@ GST_receive_callback (void *cls, | |||
1743 | "Processing PING from `%s'\n", | 1641 | "Processing PING from `%s'\n", |
1744 | GST_plugins_a2s (address)); | 1642 | GST_plugins_a2s (address)); |
1745 | if (GNUNET_OK != | 1643 | if (GNUNET_OK != |
1746 | GST_validation_handle_ping (&address->peer, | 1644 | GST_validation_handle_ping (&address->peer, message, address, session)) |
1747 | message, | ||
1748 | address, | ||
1749 | session)) | ||
1750 | { | 1645 | { |
1751 | GST_blacklist_abort_matching (address, | 1646 | GST_blacklist_abort_matching (address, session); |
1752 | session); | 1647 | kill_session (plugin_name, session); |
1753 | kill_session (plugin_name, | ||
1754 | session); | ||
1755 | } | 1648 | } |
1756 | break; | 1649 | break; |
1757 | case GNUNET_MESSAGE_TYPE_TRANSPORT_PONG: | 1650 | case GNUNET_MESSAGE_TYPE_TRANSPORT_PONG: |
1758 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1651 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1759 | "Processing PONG from `%s'\n", | 1652 | "Processing PONG from `%s'\n", |
1760 | GST_plugins_a2s (address)); | 1653 | GST_plugins_a2s (address)); |
1761 | if (GNUNET_OK != | 1654 | if (GNUNET_OK != GST_validation_handle_pong (&address->peer, message)) |
1762 | GST_validation_handle_pong (&address->peer, | ||
1763 | message)) | ||
1764 | { | 1655 | { |
1765 | GNUNET_break_op (0); | 1656 | GNUNET_break_op (0); |
1766 | GST_blacklist_abort_matching (address, | 1657 | GST_blacklist_abort_matching (address, session); |
1767 | session); | ||
1768 | kill_session (plugin_name, session); | 1658 | kill_session (plugin_name, session); |
1769 | } | 1659 | } |
1770 | break; | 1660 | break; |
1771 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN: | 1661 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN: |
1772 | /* Do blacklist check if communication with this peer is allowed */ | 1662 | /* Do blacklist check if communication with this peer is allowed */ |
1773 | (void) GST_blacklist_test_allowed (&address->peer, | 1663 | (void) GST_blacklist_test_allowed (&address->peer, |
1774 | NULL, | 1664 | NULL, |
1775 | &connect_bl_check_cont, | 1665 | &connect_bl_check_cont, |
1776 | GNUNET_copy_message (message), | 1666 | GNUNET_copy_message (message), |
1777 | address, | 1667 | address, |
1778 | session); | 1668 | session); |
1779 | break; | 1669 | break; |
1780 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN_ACK: | 1670 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_SYN_ACK: |
1781 | if (GNUNET_OK != | 1671 | if (GNUNET_OK != |
1782 | GST_neighbours_handle_session_syn_ack (message, | 1672 | GST_neighbours_handle_session_syn_ack (message, address, session)) |
1783 | address, | ||
1784 | session)) | ||
1785 | { | 1673 | { |
1786 | GST_blacklist_abort_matching (address, session); | 1674 | GST_blacklist_abort_matching (address, session); |
1787 | kill_session (plugin_name, session); | 1675 | kill_session (plugin_name, session); |
@@ -1789,30 +1677,24 @@ GST_receive_callback (void *cls, | |||
1789 | break; | 1677 | break; |
1790 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK: | 1678 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_ACK: |
1791 | if (GNUNET_OK != | 1679 | if (GNUNET_OK != |
1792 | GST_neighbours_handle_session_ack (message, | 1680 | GST_neighbours_handle_session_ack (message, address, session)) |
1793 | address, | ||
1794 | session)) | ||
1795 | { | 1681 | { |
1796 | GNUNET_break_op(0); | 1682 | GNUNET_break_op (0); |
1797 | GST_blacklist_abort_matching (address, session); | 1683 | GST_blacklist_abort_matching (address, session); |
1798 | kill_session (plugin_name, session); | 1684 | kill_session (plugin_name, session); |
1799 | } | 1685 | } |
1800 | break; | 1686 | break; |
1801 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT: | 1687 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_DISCONNECT: |
1802 | GST_neighbours_handle_disconnect_message (&address->peer, | 1688 | GST_neighbours_handle_disconnect_message (&address->peer, message); |
1803 | message); | ||
1804 | break; | 1689 | break; |
1805 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_QUOTA: | 1690 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_QUOTA: |
1806 | GST_neighbours_handle_quota_message (&address->peer, | 1691 | GST_neighbours_handle_quota_message (&address->peer, message); |
1807 | message); | ||
1808 | break; | 1692 | break; |
1809 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE: | 1693 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE: |
1810 | GST_neighbours_keepalive (&address->peer, | 1694 | GST_neighbours_keepalive (&address->peer, message); |
1811 | message); | ||
1812 | break; | 1695 | break; |
1813 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE_RESPONSE: | 1696 | case GNUNET_MESSAGE_TYPE_TRANSPORT_SESSION_KEEPALIVE_RESPONSE: |
1814 | GST_neighbours_keepalive_response (&address->peer, | 1697 | GST_neighbours_keepalive_response (&address->peer, message); |
1815 | message); | ||
1816 | break; | 1698 | break; |
1817 | default: | 1699 | default: |
1818 | /* should be payload */ | 1700 | /* should be payload */ |
@@ -1820,17 +1702,14 @@ GST_receive_callback (void *cls, | |||
1820 | gettext_noop ("# bytes payload received"), | 1702 | gettext_noop ("# bytes payload received"), |
1821 | ntohs (message->size), | 1703 | ntohs (message->size), |
1822 | GNUNET_NO); | 1704 | GNUNET_NO); |
1823 | ret = process_payload (address, | 1705 | ret = process_payload (address, session, message); |
1824 | session, | ||
1825 | message); | ||
1826 | break; | 1706 | break; |
1827 | } | 1707 | } |
1828 | end: | 1708 | end: |
1829 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1709 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1830 | "Allowing receive from peer %s to continue in %s\n", | 1710 | "Allowing receive from peer %s to continue in %s\n", |
1831 | GNUNET_i2s (&address->peer), | 1711 | GNUNET_i2s (&address->peer), |
1832 | GNUNET_STRINGS_relative_time_to_string (ret, | 1712 | GNUNET_STRINGS_relative_time_to_string (ret, GNUNET_YES)); |
1833 | GNUNET_YES)); | ||
1834 | return ret; | 1713 | return ret; |
1835 | } | 1714 | } |
1836 | 1715 | ||
@@ -1845,19 +1724,17 @@ GST_receive_callback (void *cls, | |||
1845 | * @param address the address to add or remove | 1724 | * @param address the address to add or remove |
1846 | */ | 1725 | */ |
1847 | static void | 1726 | static void |
1848 | plugin_env_address_change_notification (void *cls, | 1727 | plugin_env_address_change_notification ( |
1849 | int add_remove, | 1728 | void *cls, |
1850 | const struct GNUNET_HELLO_Address *address) | 1729 | int add_remove, |
1730 | const struct GNUNET_HELLO_Address *address) | ||
1851 | { | 1731 | { |
1852 | static int addresses = 0; | 1732 | static int addresses = 0; |
1853 | 1733 | ||
1854 | if (GNUNET_YES == add_remove) | 1734 | if (GNUNET_YES == add_remove) |
1855 | { | 1735 | { |
1856 | addresses ++; | 1736 | addresses++; |
1857 | GNUNET_STATISTICS_update (GST_stats, | 1737 | GNUNET_STATISTICS_update (GST_stats, "# transport addresses", 1, GNUNET_NO); |
1858 | "# transport addresses", | ||
1859 | 1, | ||
1860 | GNUNET_NO); | ||
1861 | } | 1738 | } |
1862 | else if (GNUNET_NO == add_remove) | 1739 | else if (GNUNET_NO == add_remove) |
1863 | { | 1740 | { |
@@ -1867,7 +1744,7 @@ plugin_env_address_change_notification (void *cls, | |||
1867 | } | 1744 | } |
1868 | else | 1745 | else |
1869 | { | 1746 | { |
1870 | addresses --; | 1747 | addresses--; |
1871 | GNUNET_STATISTICS_update (GST_stats, | 1748 | GNUNET_STATISTICS_update (GST_stats, |
1872 | "# transport addresses", | 1749 | "# transport addresses", |
1873 | -1, | 1750 | -1, |
@@ -1877,8 +1754,7 @@ plugin_env_address_change_notification (void *cls, | |||
1877 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1754 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1878 | "Transport now has %u addresses to communicate\n", | 1755 | "Transport now has %u addresses to communicate\n", |
1879 | addresses); | 1756 | addresses); |
1880 | GST_hello_modify_addresses (add_remove, | 1757 | GST_hello_modify_addresses (add_remove, address); |
1881 | address); | ||
1882 | } | 1758 | } |
1883 | 1759 | ||
1884 | 1760 | ||
@@ -1914,28 +1790,24 @@ plugin_env_session_end (void *cls, | |||
1914 | } | 1790 | } |
1915 | GNUNET_assert (strlen (address->transport_name) > 0); | 1791 | GNUNET_assert (strlen (address->transport_name) > 0); |
1916 | 1792 | ||
1917 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1793 | GNUNET_log ( |
1918 | "Notification from plugin about terminated session %p from peer `%s' address `%s'\n", | 1794 | GNUNET_ERROR_TYPE_DEBUG, |
1919 | session, | 1795 | "Notification from plugin about terminated session %p from peer `%s' address `%s'\n", |
1920 | GNUNET_i2s (&address->peer), | 1796 | session, |
1921 | GST_plugins_a2s (address)); | 1797 | GNUNET_i2s (&address->peer), |
1798 | GST_plugins_a2s (address)); | ||
1922 | 1799 | ||
1923 | GST_neighbours_session_terminated (&address->peer, | 1800 | GST_neighbours_session_terminated (&address->peer, session); |
1924 | session); | 1801 | GST_ats_del_session (address, session); |
1925 | GST_ats_del_session (address, | 1802 | GST_blacklist_abort_matching (address, session); |
1926 | session); | ||
1927 | GST_blacklist_abort_matching (address, | ||
1928 | session); | ||
1929 | 1803 | ||
1930 | for (sk = sk_head; NULL != sk; sk = sk->next) | 1804 | for (sk = sk_head; NULL != sk; sk = sk->next) |
1931 | { | 1805 | { |
1932 | if (sk->session == session) | 1806 | if (sk->session == session) |
1933 | { | 1807 | { |
1934 | GNUNET_CONTAINER_DLL_remove (sk_head, | 1808 | GNUNET_CONTAINER_DLL_remove (sk_head, sk_tail, sk); |
1935 | sk_tail, | ||
1936 | sk); | ||
1937 | GNUNET_SCHEDULER_cancel (sk->task); | 1809 | GNUNET_SCHEDULER_cancel (sk->task); |
1938 | GNUNET_free(sk); | 1810 | GNUNET_free (sk); |
1939 | break; | 1811 | break; |
1940 | } | 1812 | } |
1941 | } | 1813 | } |
@@ -1954,21 +1826,21 @@ plugin_env_session_end (void *cls, | |||
1954 | * @param result the result | 1826 | * @param result the result |
1955 | */ | 1827 | */ |
1956 | static void | 1828 | static void |
1957 | plugin_env_session_start_bl_check_cont (void *cls, | 1829 | plugin_env_session_start_bl_check_cont ( |
1958 | const struct GNUNET_PeerIdentity *peer, | 1830 | void *cls, |
1959 | const struct GNUNET_HELLO_Address *address, | 1831 | const struct GNUNET_PeerIdentity *peer, |
1960 | struct GNUNET_ATS_Session *session, | 1832 | const struct GNUNET_HELLO_Address *address, |
1961 | int result) | 1833 | struct GNUNET_ATS_Session *session, |
1834 | int result) | ||
1962 | { | 1835 | { |
1963 | if (GNUNET_OK != result) | 1836 | if (GNUNET_OK != result) |
1964 | { | 1837 | { |
1965 | kill_session (address->transport_name, | 1838 | kill_session (address->transport_name, session); |
1966 | session); | ||
1967 | return; | 1839 | return; |
1968 | } | 1840 | } |
1969 | if (GNUNET_YES != | 1841 | if (GNUNET_YES != |
1970 | GNUNET_HELLO_address_check_option (address, | 1842 | GNUNET_HELLO_address_check_option (address, |
1971 | GNUNET_HELLO_ADDRESS_INFO_INBOUND)) | 1843 | GNUNET_HELLO_ADDRESS_INFO_INBOUND)) |
1972 | { | 1844 | { |
1973 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1845 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1974 | "Informing verifier about inbound session's address `%s'\n", | 1846 | "Informing verifier about inbound session's address `%s'\n", |
@@ -1996,19 +1868,20 @@ plugin_env_session_start (void *cls, | |||
1996 | 1868 | ||
1997 | if (NULL == address) | 1869 | if (NULL == address) |
1998 | { | 1870 | { |
1999 | GNUNET_break(0); | 1871 | GNUNET_break (0); |
2000 | return; | 1872 | return; |
2001 | } | 1873 | } |
2002 | if (NULL == session) | 1874 | if (NULL == session) |
2003 | { | 1875 | { |
2004 | GNUNET_break(0); | 1876 | GNUNET_break (0); |
2005 | return; | 1877 | return; |
2006 | } | 1878 | } |
2007 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1879 | GNUNET_log ( |
2008 | "Notification from plugin `%s' about new session from peer `%s' address `%s'\n", | 1880 | GNUNET_ERROR_TYPE_INFO, |
2009 | address->transport_name, | 1881 | "Notification from plugin `%s' about new session from peer `%s' address `%s'\n", |
2010 | GNUNET_i2s (&address->peer), | 1882 | address->transport_name, |
2011 | GST_plugins_a2s (address)); | 1883 | GNUNET_i2s (&address->peer), |
1884 | GST_plugins_a2s (address)); | ||
2012 | if (GNUNET_YES == | 1885 | if (GNUNET_YES == |
2013 | GNUNET_HELLO_address_check_option (address, | 1886 | GNUNET_HELLO_address_check_option (address, |
2014 | GNUNET_HELLO_ADDRESS_INFO_INBOUND)) | 1887 | GNUNET_HELLO_ADDRESS_INFO_INBOUND)) |
@@ -2017,22 +1890,18 @@ plugin_env_session_start (void *cls, | |||
2017 | for example for UNIX, we have symmetric connections and thus we | 1890 | for example for UNIX, we have symmetric connections and thus we |
2018 | may not know the address yet; add if necessary! */ | 1891 | may not know the address yet; add if necessary! */ |
2019 | /* FIXME: maybe change API here so we just pass scope? */ | 1892 | /* FIXME: maybe change API here so we just pass scope? */ |
2020 | memset (&prop, | 1893 | memset (&prop, 0, sizeof (prop)); |
2021 | 0, | ||
2022 | sizeof (prop)); | ||
2023 | GNUNET_break (GNUNET_NT_UNSPECIFIED != scope); | 1894 | GNUNET_break (GNUNET_NT_UNSPECIFIED != scope); |
2024 | prop.scope = scope; | 1895 | prop.scope = scope; |
2025 | GST_ats_add_inbound_address (address, | 1896 | GST_ats_add_inbound_address (address, session, &prop); |
2026 | session, | ||
2027 | &prop); | ||
2028 | } | 1897 | } |
2029 | /* Do blacklist check if communication with this peer is allowed */ | 1898 | /* Do blacklist check if communication with this peer is allowed */ |
2030 | (void) GST_blacklist_test_allowed (&address->peer, | 1899 | (void) GST_blacklist_test_allowed (&address->peer, |
2031 | address->transport_name, | 1900 | address->transport_name, |
2032 | &plugin_env_session_start_bl_check_cont, | 1901 | &plugin_env_session_start_bl_check_cont, |
2033 | NULL, | 1902 | NULL, |
2034 | address, | 1903 | address, |
2035 | session); | 1904 | session); |
2036 | } | 1905 | } |
2037 | 1906 | ||
2038 | 1907 | ||
@@ -2127,15 +1996,15 @@ struct TestConnectionContext | |||
2127 | static void | 1996 | static void |
2128 | confirm_or_drop_neighbour (void *cls, | 1997 | confirm_or_drop_neighbour (void *cls, |
2129 | const struct GNUNET_PeerIdentity *peer, | 1998 | const struct GNUNET_PeerIdentity *peer, |
2130 | const struct GNUNET_HELLO_Address *address, | 1999 | const struct GNUNET_HELLO_Address *address, |
2131 | struct GNUNET_ATS_Session *session, | 2000 | struct GNUNET_ATS_Session *session, |
2132 | int allowed) | 2001 | int allowed) |
2133 | { | 2002 | { |
2134 | if (GNUNET_OK == allowed) | 2003 | if (GNUNET_OK == allowed) |
2135 | return; /* we're done */ | 2004 | return; /* we're done */ |
2136 | GNUNET_STATISTICS_update (GST_stats, | 2005 | GNUNET_STATISTICS_update (GST_stats, |
2137 | gettext_noop ("# disconnects due to blacklist"), | 2006 | gettext_noop ("# disconnects due to blacklist"), |
2138 | 1, | 2007 | 1, |
2139 | GNUNET_NO); | 2008 | GNUNET_NO); |
2140 | GST_neighbours_force_disconnect (peer); | 2009 | GST_neighbours_force_disconnect (peer); |
2141 | } | 2010 | } |
@@ -2156,19 +2025,17 @@ confirm_or_drop_neighbour (void *cls, | |||
2156 | static void | 2025 | static void |
2157 | test_connection_ok (void *cls, | 2026 | test_connection_ok (void *cls, |
2158 | const struct GNUNET_PeerIdentity *peer, | 2027 | const struct GNUNET_PeerIdentity *peer, |
2159 | const struct GNUNET_HELLO_Address *address, | 2028 | const struct GNUNET_HELLO_Address *address, |
2160 | enum GNUNET_TRANSPORT_PeerState state, | 2029 | enum GNUNET_TRANSPORT_PeerState state, |
2161 | struct GNUNET_TIME_Absolute state_timeout, | 2030 | struct GNUNET_TIME_Absolute state_timeout, |
2162 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, | 2031 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, |
2163 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) | 2032 | struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out) |
2164 | { | 2033 | { |
2165 | struct TestConnectionContext *tcc = cls; | 2034 | struct TestConnectionContext *tcc = cls; |
2166 | struct GST_BlacklistCheck *bc; | 2035 | struct GST_BlacklistCheck *bc; |
2167 | 2036 | ||
2168 | bc = GNUNET_new (struct GST_BlacklistCheck); | 2037 | bc = GNUNET_new (struct GST_BlacklistCheck); |
2169 | GNUNET_CONTAINER_DLL_insert (bc_head, | 2038 | GNUNET_CONTAINER_DLL_insert (bc_head, bc_tail, bc); |
2170 | bc_tail, | ||
2171 | bc); | ||
2172 | bc->peer = *peer; | 2039 | bc->peer = *peer; |
2173 | bc->address = GNUNET_HELLO_address_copy (address); | 2040 | bc->address = GNUNET_HELLO_address_copy (address); |
2174 | bc->cont = &confirm_or_drop_neighbour; | 2041 | bc->cont = &confirm_or_drop_neighbour; |
@@ -2178,8 +2045,7 @@ test_connection_ok (void *cls, | |||
2178 | { | 2045 | { |
2179 | /* all would wait for the same client, no need to | 2046 | /* all would wait for the same client, no need to |
2180 | * create more than just the first task right now */ | 2047 | * create more than just the first task right now */ |
2181 | bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check, | 2048 | bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check, bc); |
2182 | bc); | ||
2183 | tcc->first = GNUNET_NO; | 2049 | tcc->first = GNUNET_NO; |
2184 | } | 2050 | } |
2185 | } | 2051 | } |
@@ -2195,7 +2061,7 @@ test_connection_ok (void *cls, | |||
2195 | */ | 2061 | */ |
2196 | static void | 2062 | static void |
2197 | handle_client_blacklist_init (void *cls, | 2063 | handle_client_blacklist_init (void *cls, |
2198 | const struct GNUNET_MessageHeader *message) | 2064 | const struct GNUNET_MessageHeader *message) |
2199 | { | 2065 | { |
2200 | struct TransportClient *tc = cls; | 2066 | struct TransportClient *tc = cls; |
2201 | struct TestConnectionContext tcc; | 2067 | struct TestConnectionContext tcc; |
@@ -2209,14 +2075,11 @@ handle_client_blacklist_init (void *cls, | |||
2209 | GNUNET_SERVICE_client_mark_monitor (tc->client); | 2075 | GNUNET_SERVICE_client_mark_monitor (tc->client); |
2210 | tc->type = CT_BLACKLIST; | 2076 | tc->type = CT_BLACKLIST; |
2211 | tc->details.blacklist.call_receive_done = GNUNET_YES; | 2077 | tc->details.blacklist.call_receive_done = GNUNET_YES; |
2212 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2078 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "New blacklist client %p\n", tc); |
2213 | "New blacklist client %p\n", | ||
2214 | tc); | ||
2215 | /* confirm that all existing connections are OK! */ | 2079 | /* confirm that all existing connections are OK! */ |
2216 | tcc.tc = tc; | 2080 | tcc.tc = tc; |
2217 | tcc.first = GNUNET_YES; | 2081 | tcc.first = GNUNET_YES; |
2218 | GST_neighbours_iterate (&test_connection_ok, | 2082 | GST_neighbours_iterate (&test_connection_ok, &tcc); |
2219 | &tcc); | ||
2220 | } | 2083 | } |
2221 | 2084 | ||
2222 | 2085 | ||
@@ -2230,8 +2093,8 @@ handle_client_blacklist_init (void *cls, | |||
2230 | */ | 2093 | */ |
2231 | static int | 2094 | static int |
2232 | free_blacklist_entry (void *cls, | 2095 | free_blacklist_entry (void *cls, |
2233 | const struct GNUNET_PeerIdentity *key, | 2096 | const struct GNUNET_PeerIdentity *key, |
2234 | void *value) | 2097 | void *value) |
2235 | { | 2098 | { |
2236 | char *be = value; | 2099 | char *be = value; |
2237 | 2100 | ||
@@ -2247,8 +2110,7 @@ free_blacklist_entry (void *cls, | |||
2247 | * @param message containing information | 2110 | * @param message containing information |
2248 | */ | 2111 | */ |
2249 | static void | 2112 | static void |
2250 | handle_client_set_metric (void *cls, | 2113 | handle_client_set_metric (void *cls, const struct TrafficMetricMessage *tm) |
2251 | const struct TrafficMetricMessage *tm) | ||
2252 | { | 2114 | { |
2253 | struct TransportClient *tc = cls; | 2115 | struct TransportClient *tc = cls; |
2254 | 2116 | ||
@@ -2280,9 +2142,7 @@ shutdown_task (void *cls) | |||
2280 | GST_is = NULL; | 2142 | GST_is = NULL; |
2281 | while (NULL != (cur = a2s_head)) | 2143 | while (NULL != (cur = a2s_head)) |
2282 | { | 2144 | { |
2283 | GNUNET_CONTAINER_DLL_remove (a2s_head, | 2145 | GNUNET_CONTAINER_DLL_remove (a2s_head, a2s_tail, cur); |
2284 | a2s_tail, | ||
2285 | cur); | ||
2286 | GNUNET_free (cur); | 2146 | GNUNET_free (cur); |
2287 | } | 2147 | } |
2288 | if (NULL != plugin_nc) | 2148 | if (NULL != plugin_nc) |
@@ -2295,8 +2155,8 @@ shutdown_task (void *cls) | |||
2295 | if (NULL != blacklist) | 2155 | if (NULL != blacklist) |
2296 | { | 2156 | { |
2297 | GNUNET_CONTAINER_multipeermap_iterate (blacklist, | 2157 | GNUNET_CONTAINER_multipeermap_iterate (blacklist, |
2298 | &free_blacklist_entry, | 2158 | &free_blacklist_entry, |
2299 | NULL); | 2159 | NULL); |
2300 | GNUNET_CONTAINER_multipeermap_destroy (blacklist); | 2160 | GNUNET_CONTAINER_multipeermap_destroy (blacklist); |
2301 | blacklist = NULL; | 2161 | blacklist = NULL; |
2302 | } | 2162 | } |
@@ -2347,24 +2207,18 @@ do_blacklist_check (void *cls) | |||
2347 | "No other blacklist clients active, will allow neighbour `%s'\n", | 2207 | "No other blacklist clients active, will allow neighbour `%s'\n", |
2348 | GNUNET_i2s (&bc->peer)); | 2208 | GNUNET_i2s (&bc->peer)); |
2349 | 2209 | ||
2350 | bc->cont (bc->cont_cls, | 2210 | bc->cont (bc->cont_cls, &bc->peer, bc->address, bc->session, GNUNET_OK); |
2351 | &bc->peer, | ||
2352 | bc->address, | ||
2353 | bc->session, | ||
2354 | GNUNET_OK); | ||
2355 | GST_blacklist_test_cancel (bc); | 2211 | GST_blacklist_test_cancel (bc); |
2356 | return; | 2212 | return; |
2357 | } | 2213 | } |
2358 | if ( (NULL != tc->details.blacklist.bc) || | 2214 | if ((NULL != tc->details.blacklist.bc) || |
2359 | (GNUNET_NO != tc->details.blacklist.waiting_for_reply) ) | 2215 | (GNUNET_NO != tc->details.blacklist.waiting_for_reply)) |
2360 | return; /* someone else busy with this client */ | 2216 | return; /* someone else busy with this client */ |
2361 | tc->details.blacklist.bc = bc; | 2217 | tc->details.blacklist.bc = bc; |
2362 | env = GNUNET_MQ_msg (bm, | 2218 | env = GNUNET_MQ_msg (bm, GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY); |
2363 | GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_QUERY); | ||
2364 | bm->is_allowed = htonl (0); | 2219 | bm->is_allowed = htonl (0); |
2365 | bm->peer = bc->peer; | 2220 | bm->peer = bc->peer; |
2366 | GNUNET_MQ_send (tc->mq, | 2221 | GNUNET_MQ_send (tc->mq, env); |
2367 | env); | ||
2368 | if (GNUNET_YES == tc->details.blacklist.call_receive_done) | 2222 | if (GNUNET_YES == tc->details.blacklist.call_receive_done) |
2369 | { | 2223 | { |
2370 | tc->details.blacklist.call_receive_done = GNUNET_NO; | 2224 | tc->details.blacklist.call_receive_done = GNUNET_NO; |
@@ -2381,8 +2235,7 @@ do_blacklist_check (void *cls) | |||
2381 | * @param msg the blacklist-reply message that was sent | 2235 | * @param msg the blacklist-reply message that was sent |
2382 | */ | 2236 | */ |
2383 | static void | 2237 | static void |
2384 | handle_client_blacklist_reply (void *cls, | 2238 | handle_client_blacklist_reply (void *cls, const struct BlacklistMessage *msg) |
2385 | const struct BlacklistMessage *msg) | ||
2386 | { | 2239 | { |
2387 | struct TransportClient *tc = cls; | 2240 | struct TransportClient *tc = cls; |
2388 | struct GST_BlacklistCheck *bc; | 2241 | struct GST_BlacklistCheck *bc; |
@@ -2413,17 +2266,9 @@ handle_client_blacklist_reply (void *cls, | |||
2413 | /* For the duration of the continuation, make the ongoing | 2266 | /* For the duration of the continuation, make the ongoing |
2414 | check invisible (to avoid double-cancellation); then | 2267 | check invisible (to avoid double-cancellation); then |
2415 | add it back again so we can re-use GST_blacklist_test_cancel() */ | 2268 | add it back again so we can re-use GST_blacklist_test_cancel() */ |
2416 | GNUNET_CONTAINER_DLL_remove (bc_head, | 2269 | GNUNET_CONTAINER_DLL_remove (bc_head, bc_tail, bc); |
2417 | bc_tail, | 2270 | bc->cont (bc->cont_cls, &bc->peer, bc->address, bc->session, GNUNET_NO); |
2418 | bc); | 2271 | GNUNET_CONTAINER_DLL_insert (bc_head, bc_tail, bc); |
2419 | bc->cont (bc->cont_cls, | ||
2420 | &bc->peer, | ||
2421 | bc->address, | ||
2422 | bc->session, | ||
2423 | GNUNET_NO); | ||
2424 | GNUNET_CONTAINER_DLL_insert (bc_head, | ||
2425 | bc_tail, | ||
2426 | bc); | ||
2427 | GST_blacklist_test_cancel (bc); | 2272 | GST_blacklist_test_cancel (bc); |
2428 | tc->details.blacklist.call_receive_done = GNUNET_NO; | 2273 | tc->details.blacklist.call_receive_done = GNUNET_NO; |
2429 | GNUNET_SERVICE_client_continue (tc->client); | 2274 | GNUNET_SERVICE_client_continue (tc->client); |
@@ -2436,17 +2281,14 @@ handle_client_blacklist_reply (void *cls, | |||
2436 | tc->details.blacklist.call_receive_done = GNUNET_NO; | 2281 | tc->details.blacklist.call_receive_done = GNUNET_NO; |
2437 | GNUNET_SERVICE_client_continue (tc->client); | 2282 | GNUNET_SERVICE_client_continue (tc->client); |
2438 | bc->bl_pos = tc->next; | 2283 | bc->bl_pos = tc->next; |
2439 | bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check, | 2284 | bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check, bc); |
2440 | bc); | ||
2441 | } | 2285 | } |
2442 | } | 2286 | } |
2443 | /* check if any other blacklist checks are waiting for this blacklister */ | 2287 | /* check if any other blacklist checks are waiting for this blacklister */ |
2444 | for (bc = bc_head; bc != NULL; bc = bc->next) | 2288 | for (bc = bc_head; bc != NULL; bc = bc->next) |
2445 | if ( (bc->bl_pos == tc) && | 2289 | if ((bc->bl_pos == tc) && (NULL == bc->task)) |
2446 | (NULL == bc->task) ) | ||
2447 | { | 2290 | { |
2448 | bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check, | 2291 | bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check, bc); |
2449 | bc); | ||
2450 | break; | 2292 | break; |
2451 | } | 2293 | } |
2452 | } | 2294 | } |
@@ -2467,22 +2309,22 @@ GST_blacklist_add_peer (const struct GNUNET_PeerIdentity *peer, | |||
2467 | if (NULL != transport_name) | 2309 | if (NULL != transport_name) |
2468 | { | 2310 | { |
2469 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 2311 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
2470 | "Adding peer `%s' with plugin `%s' to blacklist\n", | 2312 | "Adding peer `%s' with plugin `%s' to blacklist\n", |
2471 | GNUNET_i2s (peer), | 2313 | GNUNET_i2s (peer), |
2472 | transport_name); | 2314 | transport_name); |
2473 | transport = GNUNET_strdup (transport_name); | 2315 | transport = GNUNET_strdup (transport_name); |
2474 | } | 2316 | } |
2475 | else | 2317 | else |
2476 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 2318 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
2477 | "Adding peer `%s' with all plugins to blacklist\n", | 2319 | "Adding peer `%s' with all plugins to blacklist\n", |
2478 | GNUNET_i2s (peer)); | 2320 | GNUNET_i2s (peer)); |
2479 | if (NULL == blacklist) | 2321 | if (NULL == blacklist) |
2480 | blacklist = | 2322 | blacklist = |
2481 | GNUNET_CONTAINER_multipeermap_create (TRANSPORT_BLACKLIST_HT_SIZE, | 2323 | GNUNET_CONTAINER_multipeermap_create (TRANSPORT_BLACKLIST_HT_SIZE, |
2482 | GNUNET_NO); | 2324 | GNUNET_NO); |
2483 | 2325 | ||
2484 | GNUNET_CONTAINER_multipeermap_put (blacklist, | 2326 | GNUNET_CONTAINER_multipeermap_put (blacklist, |
2485 | peer, | 2327 | peer, |
2486 | transport, | 2328 | transport, |
2487 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 2329 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
2488 | } | 2330 | } |
@@ -2496,7 +2338,7 @@ GST_blacklist_add_peer (const struct GNUNET_PeerIdentity *peer, | |||
2496 | */ | 2338 | */ |
2497 | void | 2339 | void |
2498 | GST_blacklist_abort_matching (const struct GNUNET_HELLO_Address *address, | 2340 | GST_blacklist_abort_matching (const struct GNUNET_HELLO_Address *address, |
2499 | struct GNUNET_ATS_Session *session) | 2341 | struct GNUNET_ATS_Session *session) |
2500 | { | 2342 | { |
2501 | struct GST_BlacklistCheck *bc; | 2343 | struct GST_BlacklistCheck *bc; |
2502 | struct GST_BlacklistCheck *n; | 2344 | struct GST_BlacklistCheck *n; |
@@ -2505,15 +2347,14 @@ GST_blacklist_abort_matching (const struct GNUNET_HELLO_Address *address, | |||
2505 | while (NULL != (bc = n)) | 2347 | while (NULL != (bc = n)) |
2506 | { | 2348 | { |
2507 | n = bc->next; | 2349 | n = bc->next; |
2508 | if ( (bc->session == session) && | 2350 | if ((bc->session == session) && |
2509 | (0 == GNUNET_HELLO_address_cmp (bc->address, | 2351 | (0 == GNUNET_HELLO_address_cmp (bc->address, address))) |
2510 | address)) ) | ||
2511 | { | 2352 | { |
2512 | bc->cont (bc->cont_cls, | 2353 | bc->cont (bc->cont_cls, |
2513 | &bc->peer, | 2354 | &bc->peer, |
2514 | bc->address, | 2355 | bc->address, |
2515 | bc->session, | 2356 | bc->session, |
2516 | GNUNET_SYSERR); | 2357 | GNUNET_SYSERR); |
2517 | GST_blacklist_test_cancel (bc); | 2358 | GST_blacklist_test_cancel (bc); |
2518 | } | 2359 | } |
2519 | } | 2360 | } |
@@ -2530,9 +2371,7 @@ GST_blacklist_abort_matching (const struct GNUNET_HELLO_Address *address, | |||
2530 | * @return #GNUNET_OK if the entry does not match, #GNUNET_NO if it matches | 2371 | * @return #GNUNET_OK if the entry does not match, #GNUNET_NO if it matches |
2531 | */ | 2372 | */ |
2532 | static int | 2373 | static int |
2533 | test_blacklisted (void *cls, | 2374 | test_blacklisted (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
2534 | const struct GNUNET_PeerIdentity *key, | ||
2535 | void *value) | ||
2536 | { | 2375 | { |
2537 | const char *transport_name = cls; | 2376 | const char *transport_name = cls; |
2538 | char *be = value; | 2377 | char *be = value; |
@@ -2547,21 +2386,19 @@ test_blacklisted (void *cls, | |||
2547 | */ | 2386 | */ |
2548 | 2387 | ||
2549 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2388 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2550 | "Comparing BL request for peer `%4s':`%s' with BL entry: `%s'\n", | 2389 | "Comparing BL request for peer `%4s':`%s' with BL entry: `%s'\n", |
2551 | GNUNET_i2s (key), | 2390 | GNUNET_i2s (key), |
2552 | (NULL == transport_name) ? "unspecified" : transport_name, | 2391 | (NULL == transport_name) ? "unspecified" : transport_name, |
2553 | (NULL == be) ? "all plugins" : be); | 2392 | (NULL == be) ? "all plugins" : be); |
2554 | /* all plugins for this peer were blacklisted: disallow */ | 2393 | /* all plugins for this peer were blacklisted: disallow */ |
2555 | if (NULL == value) | 2394 | if (NULL == value) |
2556 | return GNUNET_NO; | 2395 | return GNUNET_NO; |
2557 | 2396 | ||
2558 | /* blacklist check for specific transport */ | 2397 | /* blacklist check for specific transport */ |
2559 | if ( (NULL != transport_name) && | 2398 | if ((NULL != transport_name) && (NULL != value)) |
2560 | (NULL != value) ) | ||
2561 | { | 2399 | { |
2562 | if (0 == strcmp (transport_name, | 2400 | if (0 == strcmp (transport_name, be)) |
2563 | be)) | 2401 | return GNUNET_NO; /* plugin is blacklisted! */ |
2564 | return GNUNET_NO; /* plugin is blacklisted! */ | ||
2565 | } | 2402 | } |
2566 | return GNUNET_OK; | 2403 | return GNUNET_OK; |
2567 | } | 2404 | } |
@@ -2584,8 +2421,8 @@ GST_blacklist_test_allowed (const struct GNUNET_PeerIdentity *peer, | |||
2584 | const char *transport_name, | 2421 | const char *transport_name, |
2585 | GST_BlacklistTestContinuation cont, | 2422 | GST_BlacklistTestContinuation cont, |
2586 | void *cont_cls, | 2423 | void *cont_cls, |
2587 | const struct GNUNET_HELLO_Address *address, | 2424 | const struct GNUNET_HELLO_Address *address, |
2588 | struct GNUNET_ATS_Session *session) | 2425 | struct GNUNET_ATS_Session *session) |
2589 | { | 2426 | { |
2590 | struct GST_BlacklistCheck *bc; | 2427 | struct GST_BlacklistCheck *bc; |
2591 | struct TransportClient *tc; | 2428 | struct TransportClient *tc; |
@@ -2600,7 +2437,8 @@ GST_blacklist_test_allowed (const struct GNUNET_PeerIdentity *peer, | |||
2600 | * If iteration is aborted, we found a matching blacklist entry */ | 2437 | * If iteration is aborted, we found a matching blacklist entry */ |
2601 | if ((NULL != blacklist) && | 2438 | if ((NULL != blacklist) && |
2602 | (GNUNET_SYSERR == | 2439 | (GNUNET_SYSERR == |
2603 | GNUNET_CONTAINER_multipeermap_get_multiple (blacklist, peer, | 2440 | GNUNET_CONTAINER_multipeermap_get_multiple (blacklist, |
2441 | peer, | ||
2604 | &test_blacklisted, | 2442 | &test_blacklisted, |
2605 | (void *) transport_name))) | 2443 | (void *) transport_name))) |
2606 | { | 2444 | { |
@@ -2608,17 +2446,13 @@ GST_blacklist_test_allowed (const struct GNUNET_PeerIdentity *peer, | |||
2608 | GNUNET_STATISTICS_update (GST_stats, | 2446 | GNUNET_STATISTICS_update (GST_stats, |
2609 | gettext_noop ("# disconnects due to blacklist"), | 2447 | gettext_noop ("# disconnects due to blacklist"), |
2610 | 1, | 2448 | 1, |
2611 | GNUNET_NO); | 2449 | GNUNET_NO); |
2612 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 2450 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
2613 | _("Disallowing connection to peer `%s' on transport %s\n"), | 2451 | _ ("Disallowing connection to peer `%s' on transport %s\n"), |
2614 | GNUNET_i2s (peer), | 2452 | GNUNET_i2s (peer), |
2615 | (NULL != transport_name) ? transport_name : "unspecified"); | 2453 | (NULL != transport_name) ? transport_name : "unspecified"); |
2616 | if (NULL != cont) | 2454 | if (NULL != cont) |
2617 | cont (cont_cls, | 2455 | cont (cont_cls, peer, address, session, GNUNET_NO); |
2618 | peer, | ||
2619 | address, | ||
2620 | session, | ||
2621 | GNUNET_NO); | ||
2622 | return NULL; | 2456 | return NULL; |
2623 | } | 2457 | } |
2624 | 2458 | ||
@@ -2629,31 +2463,24 @@ GST_blacklist_test_allowed (const struct GNUNET_PeerIdentity *peer, | |||
2629 | { | 2463 | { |
2630 | /* no blacklist clients, approve instantly */ | 2464 | /* no blacklist clients, approve instantly */ |
2631 | if (NULL != cont) | 2465 | if (NULL != cont) |
2632 | cont (cont_cls, | 2466 | cont (cont_cls, peer, address, session, GNUNET_OK); |
2633 | peer, | ||
2634 | address, | ||
2635 | session, | ||
2636 | GNUNET_OK); | ||
2637 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2467 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2638 | "Allowing connection to peer `%s' %s\n", | 2468 | "Allowing connection to peer `%s' %s\n", |
2639 | GNUNET_i2s (peer), | 2469 | GNUNET_i2s (peer), |
2640 | (NULL != transport_name) ? transport_name : ""); | 2470 | (NULL != transport_name) ? transport_name : ""); |
2641 | return NULL; | 2471 | return NULL; |
2642 | } | 2472 | } |
2643 | 2473 | ||
2644 | /* need to query blacklist clients */ | 2474 | /* need to query blacklist clients */ |
2645 | bc = GNUNET_new (struct GST_BlacklistCheck); | 2475 | bc = GNUNET_new (struct GST_BlacklistCheck); |
2646 | GNUNET_CONTAINER_DLL_insert (bc_head, | 2476 | GNUNET_CONTAINER_DLL_insert (bc_head, bc_tail, bc); |
2647 | bc_tail, | ||
2648 | bc); | ||
2649 | bc->peer = *peer; | 2477 | bc->peer = *peer; |
2650 | bc->address = GNUNET_HELLO_address_copy (address); | 2478 | bc->address = GNUNET_HELLO_address_copy (address); |
2651 | bc->session = session; | 2479 | bc->session = session; |
2652 | bc->cont = cont; | 2480 | bc->cont = cont; |
2653 | bc->cont_cls = cont_cls; | 2481 | bc->cont_cls = cont_cls; |
2654 | bc->bl_pos = tc; | 2482 | bc->bl_pos = tc; |
2655 | bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check, | 2483 | bc->task = GNUNET_SCHEDULER_add_now (&do_blacklist_check, bc); |
2656 | bc); | ||
2657 | return bc; | 2484 | return bc; |
2658 | } | 2485 | } |
2659 | 2486 | ||
@@ -2666,13 +2493,11 @@ GST_blacklist_test_allowed (const struct GNUNET_PeerIdentity *peer, | |||
2666 | void | 2493 | void |
2667 | GST_blacklist_test_cancel (struct GST_BlacklistCheck *bc) | 2494 | GST_blacklist_test_cancel (struct GST_BlacklistCheck *bc) |
2668 | { | 2495 | { |
2669 | GNUNET_CONTAINER_DLL_remove (bc_head, | 2496 | GNUNET_CONTAINER_DLL_remove (bc_head, bc_tail, bc); |
2670 | bc_tail, | ||
2671 | bc); | ||
2672 | if (NULL != bc->bl_pos) | 2497 | if (NULL != bc->bl_pos) |
2673 | { | 2498 | { |
2674 | if ( (CT_BLACKLIST == bc->bl_pos->type) && | 2499 | if ((CT_BLACKLIST == bc->bl_pos->type) && |
2675 | (bc->bl_pos->details.blacklist.bc == bc) ) | 2500 | (bc->bl_pos->details.blacklist.bc == bc)) |
2676 | { | 2501 | { |
2677 | /* we're at the head of the queue, remove us! */ | 2502 | /* we're at the head of the queue, remove us! */ |
2678 | bc->bl_pos->details.blacklist.bc = NULL; | 2503 | bc->bl_pos->details.blacklist.bc = NULL; |
@@ -2699,8 +2524,8 @@ GST_blacklist_test_cancel (struct GST_BlacklistCheck *bc) | |||
2699 | static void | 2524 | static void |
2700 | blacklist_cfg_iter (void *cls, | 2525 | blacklist_cfg_iter (void *cls, |
2701 | const char *section, | 2526 | const char *section, |
2702 | const char *option, | 2527 | const char *option, |
2703 | const char *value) | 2528 | const char *value) |
2704 | { | 2529 | { |
2705 | unsigned int *res = cls; | 2530 | unsigned int *res = cls; |
2706 | struct GNUNET_PeerIdentity peer; | 2531 | struct GNUNET_PeerIdentity peer; |
@@ -2713,24 +2538,25 @@ blacklist_cfg_iter (void *cls, | |||
2713 | &peer.public_key)) | 2538 | &peer.public_key)) |
2714 | return; | 2539 | return; |
2715 | 2540 | ||
2716 | if ((NULL == value) || (0 == strcmp(value, ""))) | 2541 | if ((NULL == value) || (0 == strcmp (value, ""))) |
2717 | { | 2542 | { |
2718 | /* Blacklist whole peer */ | 2543 | /* Blacklist whole peer */ |
2719 | GST_blacklist_add_peer (&peer, NULL); | 2544 | GST_blacklist_add_peer (&peer, NULL); |
2720 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 2545 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
2721 | _("Adding blacklisting entry for peer `%s'\n"), | 2546 | _ ("Adding blacklisting entry for peer `%s'\n"), |
2722 | GNUNET_i2s (&peer)); | 2547 | GNUNET_i2s (&peer)); |
2723 | } | 2548 | } |
2724 | else | 2549 | else |
2725 | { | 2550 | { |
2726 | plugs = GNUNET_strdup (value); | 2551 | plugs = GNUNET_strdup (value); |
2727 | for (pos = strtok (plugs, " "); pos != NULL; pos = strtok (NULL, " ")) | 2552 | for (pos = strtok (plugs, " "); pos != NULL; pos = strtok (NULL, " ")) |
2728 | { | 2553 | { |
2729 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 2554 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
2730 | _("Adding blacklisting entry for peer `%s':`%s'\n"), | 2555 | _ ("Adding blacklisting entry for peer `%s':`%s'\n"), |
2731 | GNUNET_i2s (&peer), pos); | 2556 | GNUNET_i2s (&peer), |
2732 | GST_blacklist_add_peer (&peer, pos); | 2557 | pos); |
2733 | } | 2558 | GST_blacklist_add_peer (&peer, pos); |
2559 | } | ||
2734 | GNUNET_free (plugs); | 2560 | GNUNET_free (plugs); |
2735 | } | 2561 | } |
2736 | (*res)++; | 2562 | (*res)++; |
@@ -2745,15 +2571,15 @@ blacklist_cfg_iter (void *cls, | |||
2745 | */ | 2571 | */ |
2746 | static void | 2572 | static void |
2747 | read_blacklist_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg, | 2573 | read_blacklist_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg, |
2748 | const struct GNUNET_PeerIdentity *my_id) | 2574 | const struct GNUNET_PeerIdentity *my_id) |
2749 | { | 2575 | { |
2750 | char cfg_sect[512]; | 2576 | char cfg_sect[512]; |
2751 | unsigned int res = 0; | 2577 | unsigned int res = 0; |
2752 | 2578 | ||
2753 | GNUNET_snprintf (cfg_sect, | 2579 | GNUNET_snprintf (cfg_sect, |
2754 | sizeof (cfg_sect), | 2580 | sizeof (cfg_sect), |
2755 | "transport-blacklist-%s", | 2581 | "transport-blacklist-%s", |
2756 | GNUNET_i2s_full (my_id)); | 2582 | GNUNET_i2s_full (my_id)); |
2757 | GNUNET_CONFIGURATION_iterate_section_values (cfg, | 2583 | GNUNET_CONFIGURATION_iterate_section_values (cfg, |
2758 | cfg_sect, | 2584 | cfg_sect, |
2759 | &blacklist_cfg_iter, | 2585 | &blacklist_cfg_iter, |
@@ -2785,22 +2611,22 @@ run (void *cls, | |||
2785 | 2611 | ||
2786 | /* setup globals */ | 2612 | /* setup globals */ |
2787 | GST_cfg = c; | 2613 | GST_cfg = c; |
2788 | if (GNUNET_OK != | 2614 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (c, |
2789 | GNUNET_CONFIGURATION_get_value_filename (c, | 2615 | "PEER", |
2790 | "PEER", | 2616 | "PRIVATE_KEY", |
2791 | "PRIVATE_KEY", | 2617 | &keyfile)) |
2792 | &keyfile)) | 2618 | { |
2793 | { | 2619 | GNUNET_log ( |
2794 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | 2620 | GNUNET_ERROR_TYPE_ERROR, |
2795 | _("Transport service is lacking key configuration settings. Exiting.\n")); | 2621 | _ ( |
2622 | "Transport service is lacking key configuration settings. Exiting.\n")); | ||
2796 | GNUNET_SCHEDULER_shutdown (); | 2623 | GNUNET_SCHEDULER_shutdown (); |
2797 | return; | 2624 | return; |
2798 | } | 2625 | } |
2799 | if (GNUNET_OK != | 2626 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_time (c, |
2800 | GNUNET_CONFIGURATION_get_value_time (c, | 2627 | "transport", |
2801 | "transport", | 2628 | "HELLO_EXPIRATION", |
2802 | "HELLO_EXPIRATION", | 2629 | &hello_expiration)) |
2803 | &hello_expiration)) | ||
2804 | { | 2630 | { |
2805 | hello_expiration = GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION; | 2631 | hello_expiration = GNUNET_CONSTANTS_HELLO_ADDRESS_EXPIRATION; |
2806 | } | 2632 | } |
@@ -2815,16 +2641,15 @@ run (void *cls, | |||
2815 | &GST_my_identity.public_key); | 2641 | &GST_my_identity.public_key); |
2816 | GNUNET_assert (NULL != GST_my_private_key); | 2642 | GNUNET_assert (NULL != GST_my_private_key); |
2817 | 2643 | ||
2818 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, | 2644 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
2819 | "My identity is `%s'\n", | 2645 | "My identity is `%s'\n", |
2820 | GNUNET_i2s_full (&GST_my_identity)); | 2646 | GNUNET_i2s_full (&GST_my_identity)); |
2821 | 2647 | ||
2822 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, | 2648 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, NULL); |
2823 | NULL); | ||
2824 | if (NULL == GST_peerinfo) | 2649 | if (NULL == GST_peerinfo) |
2825 | { | 2650 | { |
2826 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2651 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
2827 | _("Could not access PEERINFO service. Exiting.\n")); | 2652 | _ ("Could not access PEERINFO service. Exiting.\n")); |
2828 | GNUNET_SCHEDULER_shutdown (); | 2653 | GNUNET_SCHEDULER_shutdown (); |
2829 | return; | 2654 | return; |
2830 | } | 2655 | } |
@@ -2834,23 +2659,22 @@ run (void *cls, | |||
2834 | { | 2659 | { |
2835 | struct rlimit r_file; | 2660 | struct rlimit r_file; |
2836 | 2661 | ||
2837 | if (0 == getrlimit (RLIMIT_NOFILE, | 2662 | if (0 == getrlimit (RLIMIT_NOFILE, &r_file)) |
2838 | &r_file)) | ||
2839 | { | 2663 | { |
2840 | max_fd_rlimit = r_file.rlim_cur; | 2664 | max_fd_rlimit = r_file.rlim_cur; |
2841 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2665 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2842 | "Maximum number of open files was: %u/%u\n", | 2666 | "Maximum number of open files was: %u/%u\n", |
2843 | (unsigned int) r_file.rlim_cur, | 2667 | (unsigned int) r_file.rlim_cur, |
2844 | (unsigned int) r_file.rlim_max); | 2668 | (unsigned int) r_file.rlim_max); |
2845 | } | 2669 | } |
2846 | max_fd_rlimit = (9 * max_fd_rlimit) / 10; /* Keep 10% for rest of transport */ | 2670 | max_fd_rlimit = |
2671 | (9 * max_fd_rlimit) / 10; /* Keep 10% for rest of transport */ | ||
2847 | } | 2672 | } |
2848 | #endif | 2673 | #endif |
2849 | if (GNUNET_OK != | 2674 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (GST_cfg, |
2850 | GNUNET_CONFIGURATION_get_value_number (GST_cfg, | 2675 | "transport", |
2851 | "transport", | 2676 | "MAX_FD", |
2852 | "MAX_FD", | 2677 | &max_fd_cfg)) |
2853 | &max_fd_cfg)) | ||
2854 | max_fd_cfg = max_fd_rlimit; | 2678 | max_fd_cfg = max_fd_rlimit; |
2855 | 2679 | ||
2856 | if (max_fd_cfg > max_fd_rlimit) | 2680 | if (max_fd_cfg > max_fd_rlimit) |
@@ -2866,31 +2690,25 @@ run (void *cls, | |||
2866 | (max_fd / 3), | 2690 | (max_fd / 3), |
2867 | (max_fd / 3) * 2); | 2691 | (max_fd / 3) * 2); |
2868 | 2692 | ||
2869 | friend_only = GNUNET_CONFIGURATION_get_value_yesno (GST_cfg, | 2693 | friend_only = |
2870 | "topology", | 2694 | GNUNET_CONFIGURATION_get_value_yesno (GST_cfg, "topology", "FRIENDS-ONLY"); |
2871 | "FRIENDS-ONLY"); | ||
2872 | if (GNUNET_SYSERR == friend_only) | 2695 | if (GNUNET_SYSERR == friend_only) |
2873 | friend_only = GNUNET_NO; /* According to topology defaults */ | 2696 | friend_only = GNUNET_NO; /* According to topology defaults */ |
2874 | /* start subsystems */ | 2697 | /* start subsystems */ |
2875 | read_blacklist_configuration (GST_cfg, | 2698 | read_blacklist_configuration (GST_cfg, &GST_my_identity); |
2876 | &GST_my_identity); | ||
2877 | GST_is = GNUNET_NT_scanner_init (); | 2699 | GST_is = GNUNET_NT_scanner_init (); |
2878 | GST_ats_connect = GNUNET_ATS_connectivity_init (GST_cfg); | 2700 | GST_ats_connect = GNUNET_ATS_connectivity_init (GST_cfg); |
2879 | GST_ats = GNUNET_ATS_scheduling_init (GST_cfg, | 2701 | GST_ats = |
2880 | &ats_request_address_change, | 2702 | GNUNET_ATS_scheduling_init (GST_cfg, &ats_request_address_change, NULL); |
2881 | NULL); | ||
2882 | GST_ats_init (); | 2703 | GST_ats_init (); |
2883 | GST_manipulation_init (); | 2704 | GST_manipulation_init (); |
2884 | GST_plugins_load (&GST_manipulation_recv, | 2705 | GST_plugins_load (&GST_manipulation_recv, |
2885 | &plugin_env_address_change_notification, | 2706 | &plugin_env_address_change_notification, |
2886 | &plugin_env_session_start, | 2707 | &plugin_env_session_start, |
2887 | &plugin_env_session_end); | 2708 | &plugin_env_session_end); |
2888 | GST_hello_start (friend_only, | 2709 | GST_hello_start (friend_only, &process_hello_update, NULL); |
2889 | &process_hello_update, | ||
2890 | NULL); | ||
2891 | GST_neighbours_start ((max_fd / 3) * 2); | 2710 | GST_neighbours_start ((max_fd / 3) * 2); |
2892 | active_stccs = GNUNET_CONTAINER_multipeermap_create (128, | 2711 | active_stccs = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_YES); |
2893 | GNUNET_YES); | ||
2894 | plugin_nc = GNUNET_notification_context_create (0); | 2712 | plugin_nc = GNUNET_notification_context_create (0); |
2895 | GST_validation_start ((max_fd / 3)); | 2713 | GST_validation_start ((max_fd / 3)); |
2896 | } | 2714 | } |
@@ -2899,50 +2717,50 @@ run (void *cls, | |||
2899 | /** | 2717 | /** |
2900 | * Define "main" method using service macro. | 2718 | * Define "main" method using service macro. |
2901 | */ | 2719 | */ |
2902 | GNUNET_SERVICE_MAIN | 2720 | GNUNET_SERVICE_MAIN ( |
2903 | ("transport", | 2721 | "transport", |
2904 | GNUNET_SERVICE_OPTION_NONE, | 2722 | GNUNET_SERVICE_OPTION_NONE, |
2905 | &run, | 2723 | &run, |
2906 | &client_connect_cb, | 2724 | &client_connect_cb, |
2907 | &client_disconnect_cb, | 2725 | &client_disconnect_cb, |
2908 | NULL, | 2726 | NULL, |
2909 | GNUNET_MQ_hd_fixed_size (client_start, | 2727 | GNUNET_MQ_hd_fixed_size (client_start, |
2910 | GNUNET_MESSAGE_TYPE_TRANSPORT_START, | 2728 | GNUNET_MESSAGE_TYPE_TRANSPORT_START, |
2911 | struct StartMessage, | 2729 | struct StartMessage, |
2912 | NULL), | 2730 | NULL), |
2913 | GNUNET_MQ_hd_var_size (client_hello, | 2731 | GNUNET_MQ_hd_var_size (client_hello, |
2914 | GNUNET_MESSAGE_TYPE_HELLO, | 2732 | GNUNET_MESSAGE_TYPE_HELLO, |
2915 | struct GNUNET_MessageHeader, | 2733 | struct GNUNET_MessageHeader, |
2916 | NULL), | 2734 | NULL), |
2917 | GNUNET_MQ_hd_var_size (client_send, | 2735 | GNUNET_MQ_hd_var_size (client_send, |
2918 | GNUNET_MESSAGE_TYPE_TRANSPORT_SEND, | 2736 | GNUNET_MESSAGE_TYPE_TRANSPORT_SEND, |
2919 | struct OutboundMessage, | 2737 | struct OutboundMessage, |
2920 | NULL), | 2738 | NULL), |
2921 | GNUNET_MQ_hd_var_size (client_address_to_string, | 2739 | GNUNET_MQ_hd_var_size (client_address_to_string, |
2922 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING, | 2740 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING, |
2923 | struct AddressLookupMessage, | 2741 | struct AddressLookupMessage, |
2924 | NULL), | 2742 | NULL), |
2925 | GNUNET_MQ_hd_fixed_size (client_monitor_peers, | 2743 | GNUNET_MQ_hd_fixed_size (client_monitor_peers, |
2926 | GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_REQUEST, | 2744 | GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PEER_REQUEST, |
2927 | struct PeerMonitorMessage, | 2745 | struct PeerMonitorMessage, |
2928 | NULL), | 2746 | NULL), |
2929 | GNUNET_MQ_hd_fixed_size (client_blacklist_init, | 2747 | GNUNET_MQ_hd_fixed_size (client_blacklist_init, |
2930 | GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_INIT, | 2748 | GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_INIT, |
2931 | struct GNUNET_MessageHeader, | 2749 | struct GNUNET_MessageHeader, |
2932 | NULL), | 2750 | NULL), |
2933 | GNUNET_MQ_hd_fixed_size (client_blacklist_reply, | 2751 | GNUNET_MQ_hd_fixed_size (client_blacklist_reply, |
2934 | GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_REPLY, | 2752 | GNUNET_MESSAGE_TYPE_TRANSPORT_BLACKLIST_REPLY, |
2935 | struct BlacklistMessage, | 2753 | struct BlacklistMessage, |
2936 | NULL), | 2754 | NULL), |
2937 | GNUNET_MQ_hd_fixed_size (client_set_metric, | 2755 | GNUNET_MQ_hd_fixed_size (client_set_metric, |
2938 | GNUNET_MESSAGE_TYPE_TRANSPORT_TRAFFIC_METRIC, | 2756 | GNUNET_MESSAGE_TYPE_TRANSPORT_TRAFFIC_METRIC, |
2939 | struct TrafficMetricMessage, | 2757 | struct TrafficMetricMessage, |
2940 | NULL), | 2758 | NULL), |
2941 | GNUNET_MQ_hd_fixed_size (client_monitor_plugins, | 2759 | GNUNET_MQ_hd_fixed_size (client_monitor_plugins, |
2942 | GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_START, | 2760 | GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_START, |
2943 | struct GNUNET_MessageHeader, | 2761 | struct GNUNET_MessageHeader, |
2944 | NULL), | 2762 | NULL), |
2945 | GNUNET_MQ_handler_end ()); | 2763 | GNUNET_MQ_handler_end ()); |
2946 | 2764 | ||
2947 | 2765 | ||
2948 | /* end of file gnunet-service-transport.c */ | 2766 | /* end of file gnunet-service-transport.c */ |