diff options
Diffstat (limited to 'src/transport/plugin_transport_udp.c')
-rw-r--r-- | src/transport/plugin_transport_udp.c | 477 |
1 files changed, 263 insertions, 214 deletions
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index cf6e01306..667af25be 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -120,12 +120,12 @@ struct UDP_Beacon_Message | |||
120 | /** | 120 | /** |
121 | * Message header. | 121 | * Message header. |
122 | */ | 122 | */ |
123 | struct GNUNET_MessageHeader header; | 123 | struct GNUNET_MessageHeader header; |
124 | 124 | ||
125 | /** | 125 | /** |
126 | * What is the identity of the sender | 126 | * What is the identity of the sender |
127 | */ | 127 | */ |
128 | struct GNUNET_PeerIdentity sender; | 128 | struct GNUNET_PeerIdentity sender; |
129 | }; | 129 | }; |
130 | 130 | ||
131 | 131 | ||
@@ -396,8 +396,8 @@ struct Plugin | |||
396 | 396 | ||
397 | struct PeerSessionIteratorContext | 397 | struct PeerSessionIteratorContext |
398 | { | 398 | { |
399 | struct Session * result; | 399 | struct Session *result; |
400 | const void * addr; | 400 | const void *addr; |
401 | size_t addrlen; | 401 | size_t addrlen; |
402 | }; | 402 | }; |
403 | 403 | ||
@@ -417,13 +417,12 @@ find_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *peer) | |||
417 | } | 417 | } |
418 | 418 | ||
419 | 419 | ||
420 | static int | 420 | static int |
421 | inbound_session_iterator (void *cls, | 421 | inbound_session_iterator (void *cls, const GNUNET_HashCode * key, void *value) |
422 | const GNUNET_HashCode * key, | ||
423 | void *value) | ||
424 | { | 422 | { |
425 | struct PeerSessionIteratorContext *psc = cls; | 423 | struct PeerSessionIteratorContext *psc = cls; |
426 | struct Session *s = value; | 424 | struct Session *s = value; |
425 | |||
427 | if (s->addrlen == psc->addrlen) | 426 | if (s->addrlen == psc->addrlen) |
428 | { | 427 | { |
429 | if (0 == memcmp (&s[1], psc->addr, s->addrlen)) | 428 | if (0 == memcmp (&s[1], psc->addr, s->addrlen)) |
@@ -444,26 +443,29 @@ inbound_session_iterator (void *cls, | |||
444 | */ | 443 | */ |
445 | static struct Session * | 444 | static struct Session * |
446 | find_inbound_session (struct Plugin *plugin, | 445 | find_inbound_session (struct Plugin *plugin, |
447 | const struct GNUNET_PeerIdentity *peer, | 446 | const struct GNUNET_PeerIdentity *peer, const void *addr, |
448 | const void * addr, size_t addrlen) | 447 | size_t addrlen) |
449 | { | 448 | { |
450 | struct PeerSessionIteratorContext psc; | 449 | struct PeerSessionIteratorContext psc; |
450 | |||
451 | psc.result = NULL; | 451 | psc.result = NULL; |
452 | psc.addrlen = addrlen; | 452 | psc.addrlen = addrlen; |
453 | psc.addr = addr; | 453 | psc.addr = addr; |
454 | 454 | ||
455 | GNUNET_CONTAINER_multihashmap_get_multiple(plugin->inbound_sessions, &peer->hashPubKey, &inbound_session_iterator, &psc); | 455 | GNUNET_CONTAINER_multihashmap_get_multiple (plugin->inbound_sessions, |
456 | &peer->hashPubKey, | ||
457 | &inbound_session_iterator, &psc); | ||
456 | return psc.result; | 458 | return psc.result; |
457 | } | 459 | } |
458 | 460 | ||
459 | 461 | ||
460 | static int | 462 | static int |
461 | inbound_session_by_addr_iterator (void *cls, | 463 | inbound_session_by_addr_iterator (void *cls, const GNUNET_HashCode * key, |
462 | const GNUNET_HashCode * key, | 464 | void *value) |
463 | void *value) | ||
464 | { | 465 | { |
465 | struct PeerSessionIteratorContext *psc = cls; | 466 | struct PeerSessionIteratorContext *psc = cls; |
466 | struct Session *s = value; | 467 | struct Session *s = value; |
468 | |||
467 | if (s->addrlen == psc->addrlen) | 469 | if (s->addrlen == psc->addrlen) |
468 | { | 470 | { |
469 | if (0 == memcmp (&s[1], psc->addr, s->addrlen)) | 471 | if (0 == memcmp (&s[1], psc->addr, s->addrlen)) |
@@ -484,14 +486,18 @@ inbound_session_by_addr_iterator (void *cls, | |||
484 | * @return NULL if we have no session | 486 | * @return NULL if we have no session |
485 | */ | 487 | */ |
486 | static struct Session * | 488 | static struct Session * |
487 | find_inbound_session_by_addr (struct Plugin *plugin, const void * addr, size_t addrlen) | 489 | find_inbound_session_by_addr (struct Plugin *plugin, const void *addr, |
490 | size_t addrlen) | ||
488 | { | 491 | { |
489 | struct PeerSessionIteratorContext psc; | 492 | struct PeerSessionIteratorContext psc; |
493 | |||
490 | psc.result = NULL; | 494 | psc.result = NULL; |
491 | psc.addrlen = addrlen; | 495 | psc.addrlen = addrlen; |
492 | psc.addr = addr; | 496 | psc.addr = addr; |
493 | 497 | ||
494 | GNUNET_CONTAINER_multihashmap_iterate (plugin->inbound_sessions, &inbound_session_by_addr_iterator, &psc); | 498 | GNUNET_CONTAINER_multihashmap_iterate (plugin->inbound_sessions, |
499 | &inbound_session_by_addr_iterator, | ||
500 | &psc); | ||
495 | return psc.result; | 501 | return psc.result; |
496 | } | 502 | } |
497 | 503 | ||
@@ -531,7 +537,7 @@ destroy_inbound_session (void *cls, const GNUNET_HashCode * key, void *value) | |||
531 | struct Session *s = value; | 537 | struct Session *s = value; |
532 | 538 | ||
533 | if (s->invalidation_task != GNUNET_SCHEDULER_NO_TASK) | 539 | if (s->invalidation_task != GNUNET_SCHEDULER_NO_TASK) |
534 | GNUNET_SCHEDULER_cancel(s->invalidation_task); | 540 | GNUNET_SCHEDULER_cancel (s->invalidation_task); |
535 | if (GNUNET_SCHEDULER_NO_TASK != s->delayed_cont_task) | 541 | if (GNUNET_SCHEDULER_NO_TASK != s->delayed_cont_task) |
536 | GNUNET_SCHEDULER_cancel (s->delayed_cont_task); | 542 | GNUNET_SCHEDULER_cancel (s->delayed_cont_task); |
537 | GNUNET_free (s); | 543 | GNUNET_free (s); |
@@ -560,11 +566,10 @@ udp_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) | |||
560 | session)); | 566 | session)); |
561 | 567 | ||
562 | GNUNET_CONTAINER_multihashmap_get_multiple (plugin->inbound_sessions, | 568 | GNUNET_CONTAINER_multihashmap_get_multiple (plugin->inbound_sessions, |
563 | &target->hashPubKey, | 569 | &target->hashPubKey, |
564 | &destroy_inbound_session, NULL); | 570 | &destroy_inbound_session, NULL); |
565 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sendto"); | 571 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sendto"); |
566 | LOG (GNUNET_ERROR_TYPE_ERROR, | 572 | LOG (GNUNET_ERROR_TYPE_ERROR, "UDP DISCONNECT\n"); |
567 | "UDP DISCONNECT\n"); | ||
568 | 573 | ||
569 | plugin->last_expected_delay = GNUNET_FRAGMENT_context_destroy (session->frag); | 574 | plugin->last_expected_delay = GNUNET_FRAGMENT_context_destroy (session->frag); |
570 | if (GNUNET_SCHEDULER_NO_TASK != session->delayed_cont_task) | 575 | if (GNUNET_SCHEDULER_NO_TASK != session->delayed_cont_task) |
@@ -614,15 +619,15 @@ udp_send (struct Plugin *plugin, const struct sockaddr *sa, | |||
614 | { | 619 | { |
615 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sendto"); | 620 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "sendto"); |
616 | LOG (GNUNET_ERROR_TYPE_ERROR, | 621 | LOG (GNUNET_ERROR_TYPE_ERROR, |
617 | "UDP transmited %u-byte message to %s (%d: %s)\n", | 622 | "UDP transmited %u-byte message to %s (%d: %s)\n", |
618 | (unsigned int) ntohs (msg->size), GNUNET_a2s (sa, slen), | 623 | (unsigned int) ntohs (msg->size), GNUNET_a2s (sa, slen), (int) sent, |
619 | (int) sent, (sent < 0) ? STRERROR (errno) : "ok"); | 624 | (sent < 0) ? STRERROR (errno) : "ok"); |
620 | 625 | ||
621 | } | 626 | } |
622 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 627 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
623 | "UDP transmited %u-byte message to %s (%d: %s)\n", | 628 | "UDP transmited %u-byte message to %s (%d: %s)\n", |
624 | (unsigned int) ntohs (msg->size), GNUNET_a2s (sa, slen), | 629 | (unsigned int) ntohs (msg->size), GNUNET_a2s (sa, slen), (int) sent, |
625 | (int) sent, (sent < 0) ? STRERROR (errno) : "ok"); | 630 | (sent < 0) ? STRERROR (errno) : "ok"); |
626 | return sent; | 631 | return sent; |
627 | } | 632 | } |
628 | 633 | ||
@@ -648,10 +653,10 @@ send_fragment (void *cls, const struct GNUNET_MessageHeader *msg) | |||
648 | 653 | ||
649 | static struct Session * | 654 | static struct Session * |
650 | create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | 655 | create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, |
651 | const void *addr, size_t addrlen, | 656 | const void *addr, size_t addrlen, |
652 | GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) | 657 | GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) |
653 | { | 658 | { |
654 | struct Session * peer_session; | 659 | struct Session *peer_session; |
655 | const struct IPv4UdpAddress *t4; | 660 | const struct IPv4UdpAddress *t4; |
656 | const struct IPv6UdpAddress *t6; | 661 | const struct IPv6UdpAddress *t6; |
657 | struct sockaddr_in *v4; | 662 | struct sockaddr_in *v4; |
@@ -667,8 +672,7 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | |||
667 | } | 672 | } |
668 | t4 = addr; | 673 | t4 = addr; |
669 | peer_session = | 674 | peer_session = |
670 | GNUNET_malloc (sizeof (struct Session) + | 675 | GNUNET_malloc (sizeof (struct Session) + sizeof (struct sockaddr_in)); |
671 | sizeof (struct sockaddr_in)); | ||
672 | len = sizeof (struct sockaddr_in); | 676 | len = sizeof (struct sockaddr_in); |
673 | v4 = (struct sockaddr_in *) &peer_session[1]; | 677 | v4 = (struct sockaddr_in *) &peer_session[1]; |
674 | v4->sin_family = AF_INET; | 678 | v4->sin_family = AF_INET; |
@@ -685,8 +689,7 @@ create_session (struct Plugin *plugin, const struct GNUNET_PeerIdentity *target, | |||
685 | } | 689 | } |
686 | t6 = addr; | 690 | t6 = addr; |
687 | peer_session = | 691 | peer_session = |
688 | GNUNET_malloc (sizeof (struct Session) + | 692 | GNUNET_malloc (sizeof (struct Session) + sizeof (struct sockaddr_in6)); |
689 | sizeof (struct sockaddr_in6)); | ||
690 | len = sizeof (struct sockaddr_in6); | 693 | len = sizeof (struct sockaddr_in6); |
691 | v6 = (struct sockaddr_in6 *) &peer_session[1]; | 694 | v6 = (struct sockaddr_in6 *) &peer_session[1]; |
692 | v6->sin6_family = AF_INET6; | 695 | v6->sin6_family = AF_INET6; |
@@ -719,8 +722,7 @@ udp_address_to_string (void *cls, const void *addr, size_t addrlen); | |||
719 | 722 | ||
720 | 723 | ||
721 | static void | 724 | static void |
722 | udp_call_continuation (void *cls, | 725 | udp_call_continuation (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
723 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
724 | { | 726 | { |
725 | struct Session *s = cls; | 727 | struct Session *s = cls; |
726 | GNUNET_TRANSPORT_TransmitContinuation cont = s->cont; | 728 | GNUNET_TRANSPORT_TransmitContinuation cont = s->cont; |
@@ -779,10 +781,10 @@ udp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
779 | } | 781 | } |
780 | 782 | ||
781 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 783 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
782 | "UDP transmits %u-byte message to `%s' using address `%s' session 0x%X mode %i\n", | 784 | "UDP transmits %u-byte message to `%s' using address `%s' session 0x%X mode %i\n", |
783 | msgbuf_size, GNUNET_i2s (target), | 785 | msgbuf_size, GNUNET_i2s (target), udp_address_to_string (NULL, addr, |
784 | udp_address_to_string (NULL, addr, addrlen), | 786 | addrlen), |
785 | session, force_address); | 787 | session, force_address); |
786 | 788 | ||
787 | if ((force_address == GNUNET_SYSERR) && (session == NULL)) | 789 | if ((force_address == GNUNET_SYSERR) && (session == NULL)) |
788 | return GNUNET_SYSERR; | 790 | return GNUNET_SYSERR; |
@@ -792,10 +794,11 @@ udp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
792 | if ((session != NULL) && (addr != NULL) && (addrlen != 0)) | 794 | if ((session != NULL) && (addr != NULL) && (addrlen != 0)) |
793 | { | 795 | { |
794 | s = session; | 796 | s = session; |
795 | GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_contains_value ( | 797 | GNUNET_assert (GNUNET_YES == |
796 | plugin->inbound_sessions, &target->hashPubKey, s)); | 798 | GNUNET_CONTAINER_multihashmap_contains_value |
799 | (plugin->inbound_sessions, &target->hashPubKey, s)); | ||
797 | 800 | ||
798 | if (0 != memcmp (&s->target, target, sizeof (struct GNUNET_PeerIdentity))) | 801 | if (0 != memcmp (&s->target, target, sizeof (struct GNUNET_PeerIdentity))) |
799 | return GNUNET_SYSERR; | 802 | return GNUNET_SYSERR; |
800 | switch (addrlen) | 803 | switch (addrlen) |
801 | { | 804 | { |
@@ -810,10 +813,13 @@ udp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
810 | if (s->addrlen != (sizeof (struct sockaddr_in))) | 813 | if (s->addrlen != (sizeof (struct sockaddr_in))) |
811 | return GNUNET_SYSERR; | 814 | return GNUNET_SYSERR; |
812 | struct sockaddr_in *a4 = (struct sockaddr_in *) s->sock_addr; | 815 | struct sockaddr_in *a4 = (struct sockaddr_in *) s->sock_addr; |
816 | |||
813 | GNUNET_assert (a4->sin_port == t4->u4_port); | 817 | GNUNET_assert (a4->sin_port == t4->u4_port); |
814 | GNUNET_assert (0 == memcmp(&a4->sin_addr, &t4->ipv4_addr, sizeof (struct in_addr))); | 818 | GNUNET_assert (0 == |
815 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 819 | memcmp (&a4->sin_addr, &t4->ipv4_addr, |
816 | "Session 0x%X successfully checked!\n", session); | 820 | sizeof (struct in_addr))); |
821 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Session 0x%X successfully checked!\n", | ||
822 | session); | ||
817 | break; | 823 | break; |
818 | case sizeof (struct IPv6UdpAddress): | 824 | case sizeof (struct IPv6UdpAddress): |
819 | if (NULL == plugin->sockv6) | 825 | if (NULL == plugin->sockv6) |
@@ -825,10 +831,13 @@ udp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
825 | t6 = addr; | 831 | t6 = addr; |
826 | GNUNET_assert (s->addrlen == sizeof (struct sockaddr_in6)); | 832 | GNUNET_assert (s->addrlen == sizeof (struct sockaddr_in6)); |
827 | struct sockaddr_in6 *a6 = (struct sockaddr_in6 *) s->sock_addr; | 833 | struct sockaddr_in6 *a6 = (struct sockaddr_in6 *) s->sock_addr; |
834 | |||
828 | GNUNET_assert (a6->sin6_port == t6->u6_port); | 835 | GNUNET_assert (a6->sin6_port == t6->u6_port); |
829 | GNUNET_assert (0 == memcmp(&a6->sin6_addr, &t6->ipv6_addr, sizeof (struct in6_addr))); | 836 | GNUNET_assert (0 == |
830 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 837 | memcmp (&a6->sin6_addr, &t6->ipv6_addr, |
831 | "Session 0x%X successfully checked!\n", session); | 838 | sizeof (struct in6_addr))); |
839 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Session 0x%X successfully checked!\n", | ||
840 | session); | ||
832 | break; | 841 | break; |
833 | default: | 842 | default: |
834 | /* Must have a valid address to send to */ | 843 | /* Must have a valid address to send to */ |
@@ -854,7 +863,7 @@ udp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
854 | udp->sender = *plugin->env->my_identity; | 863 | udp->sender = *plugin->env->my_identity; |
855 | memcpy (&udp[1], msgbuf, msgbuf_size); | 864 | memcpy (&udp[1], msgbuf, msgbuf_size); |
856 | 865 | ||
857 | if (s != NULL) | 866 | if (s != NULL) |
858 | delta = GNUNET_TIME_absolute_get_remaining (s->flow_delay_from_other_peer); | 867 | delta = GNUNET_TIME_absolute_get_remaining (s->flow_delay_from_other_peer); |
859 | else | 868 | else |
860 | delta = GNUNET_TIME_UNIT_ZERO; | 869 | delta = GNUNET_TIME_UNIT_ZERO; |
@@ -863,17 +872,15 @@ udp_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, | |||
863 | mlen = udp_send (plugin, peer_session->sock_addr, &udp->header); | 872 | mlen = udp_send (plugin, peer_session->sock_addr, &udp->header); |
864 | if (cont != NULL) | 873 | if (cont != NULL) |
865 | { | 874 | { |
866 | if ( (delta.rel_value > 0) && | 875 | if ((delta.rel_value > 0) && (mlen > 0)) |
867 | (mlen > 0) ) | ||
868 | { | 876 | { |
869 | s->cont = cont; | 877 | s->cont = cont; |
870 | s->cont_cls = cont_cls; | 878 | s->cont_cls = cont_cls; |
871 | s->delayed_cont_task = GNUNET_SCHEDULER_add_delayed (delta, | 879 | s->delayed_cont_task = |
872 | &udp_call_continuation, | 880 | GNUNET_SCHEDULER_add_delayed (delta, &udp_call_continuation, s); |
873 | s); | ||
874 | } | 881 | } |
875 | else | 882 | else |
876 | cont (cont_cls, target, (mlen > 0) ? GNUNET_OK : GNUNET_SYSERR); | 883 | cont (cont_cls, target, (mlen > 0) ? GNUNET_OK : GNUNET_SYSERR); |
877 | } | 884 | } |
878 | GNUNET_free_non_null (peer_session); | 885 | GNUNET_free_non_null (peer_session); |
879 | } | 886 | } |
@@ -915,7 +922,7 @@ struct SourceInformation | |||
915 | */ | 922 | */ |
916 | size_t args; | 923 | size_t args; |
917 | 924 | ||
918 | struct Session * session; | 925 | struct Session *session; |
919 | }; | 926 | }; |
920 | 927 | ||
921 | 928 | ||
@@ -940,23 +947,29 @@ process_inbound_tokenized_messages (void *cls, void *client, | |||
940 | distance.type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); | 947 | distance.type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); |
941 | distance.value = htonl (1); | 948 | distance.value = htonl (1); |
942 | 949 | ||
943 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 950 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Giving Session %X %s to transport\n", |
944 | "Giving Session %X %s to transport\n", si->session, GNUNET_i2s(&si->session->target)); | 951 | si->session, GNUNET_i2s (&si->session->target)); |
945 | delay = plugin->env->receive (plugin->env->cls, &si->sender, hdr, &distance, 1, si->session, | 952 | delay = |
946 | si->arg, si->args); | 953 | plugin->env->receive (plugin->env->cls, &si->sender, hdr, &distance, 1, |
954 | si->session, si->arg, si->args); | ||
947 | si->session->flow_delay_for_other_peer = delay; | 955 | si->session->flow_delay_for_other_peer = delay; |
948 | } | 956 | } |
949 | 957 | ||
950 | static void | 958 | static void |
951 | invalidation_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 959 | invalidation_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
952 | { | 960 | { |
953 | struct Session * s = cls; | 961 | struct Session *s = cls; |
954 | s->invalidation_task = GNUNET_SCHEDULER_NO_TASK; | ||
955 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
956 | "Session %X (`%s') is now invalid\n", s, GNUNET_a2s (s->sock_addr,s->addrlen)); | ||
957 | 962 | ||
958 | s->plugin->env->session_end(s->plugin->env->cls, &s->target, s); | 963 | s->invalidation_task = GNUNET_SCHEDULER_NO_TASK; |
959 | GNUNET_assert (GNUNET_YES == GNUNET_CONTAINER_multihashmap_remove(s->plugin->inbound_sessions, &s->target.hashPubKey, s)); | 964 | LOG (GNUNET_ERROR_TYPE_ERROR, "Session %X (`%s') is now invalid\n", s, |
965 | GNUNET_a2s (s->sock_addr, s->addrlen)); | ||
966 | |||
967 | s->plugin->env->session_end (s->plugin->env->cls, &s->target, s); | ||
968 | GNUNET_assert (GNUNET_YES == | ||
969 | GNUNET_CONTAINER_multihashmap_remove (s-> | ||
970 | plugin->inbound_sessions, | ||
971 | &s->target.hashPubKey, | ||
972 | s)); | ||
960 | GNUNET_free (s); | 973 | GNUNET_free (s); |
961 | } | 974 | } |
962 | 975 | ||
@@ -1015,54 +1028,54 @@ process_udp_message (struct Plugin *plugin, const struct UDPMessage *msg, | |||
1015 | } | 1028 | } |
1016 | #if DEBUG_UDP | 1029 | #if DEBUG_UDP |
1017 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1030 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1018 | "Received message with %u bytes from peer `%s' at `%s'\n", | 1031 | "Received message with %u bytes from peer `%s' at `%s'\n", |
1019 | (unsigned int) ntohs (msg->header.size), | 1032 | (unsigned int) ntohs (msg->header.size), GNUNET_i2s (&msg->sender), |
1020 | GNUNET_i2s (&msg->sender), GNUNET_a2s (sender_addr, | 1033 | GNUNET_a2s (sender_addr, sender_addr_len)); |
1021 | sender_addr_len)); | ||
1022 | #endif | 1034 | #endif |
1023 | 1035 | ||
1024 | /* create a session for inbound connections */ | 1036 | /* create a session for inbound connections */ |
1025 | const struct UDPMessage * udp_msg = (const struct UDPMessage *) msg; | 1037 | const struct UDPMessage *udp_msg = (const struct UDPMessage *) msg; |
1038 | |||
1026 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1039 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1027 | "Lookup inbound UDP sessions for peer `%s' address `%s'\n", | 1040 | "Lookup inbound UDP sessions for peer `%s' address `%s'\n", |
1028 | GNUNET_i2s (&udp_msg->sender), | 1041 | GNUNET_i2s (&udp_msg->sender), udp_address_to_string (NULL, arg, args)); |
1029 | udp_address_to_string(NULL, arg, args)); | ||
1030 | 1042 | ||
1031 | struct Session * s = NULL; | 1043 | struct Session *s = NULL; |
1032 | s = find_inbound_session (plugin, &udp_msg->sender, sender_addr, sender_addr_len); | 1044 | |
1045 | s = find_inbound_session (plugin, &udp_msg->sender, sender_addr, | ||
1046 | sender_addr_len); | ||
1033 | 1047 | ||
1034 | if (s != NULL) | 1048 | if (s != NULL) |
1035 | { | 1049 | { |
1036 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1050 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1037 | "Found existing inbound UDP sessions 0x%X for peer `%s' address `%s'\n", | 1051 | "Found existing inbound UDP sessions 0x%X for peer `%s' address `%s'\n", |
1038 | s, | 1052 | s, GNUNET_i2s (&s->target), udp_address_to_string (NULL, arg, args)); |
1039 | GNUNET_i2s (&s->target), | ||
1040 | udp_address_to_string(NULL, arg, args)); | ||
1041 | } | 1053 | } |
1042 | else | 1054 | else |
1043 | { | 1055 | { |
1044 | s = create_session (plugin, &udp_msg->sender, arg, args, NULL, NULL); | 1056 | s = create_session (plugin, &udp_msg->sender, arg, args, NULL, NULL); |
1045 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1057 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1046 | "Creating inbound UDP sessions 0x%X for peer `%s' address `%s'\n", | 1058 | "Creating inbound UDP sessions 0x%X for peer `%s' address `%s'\n", s, |
1047 | s, | 1059 | GNUNET_i2s (&s->target), udp_address_to_string (NULL, arg, args)); |
1048 | GNUNET_i2s (&s->target), | 1060 | |
1049 | udp_address_to_string(NULL, arg, args)); | 1061 | GNUNET_assert (GNUNET_OK == |
1050 | 1062 | GNUNET_CONTAINER_multihashmap_put (plugin->inbound_sessions, | |
1051 | GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multihashmap_put (plugin->inbound_sessions, | 1063 | &s->target.hashPubKey, s, |
1052 | &s->target.hashPubKey, | 1064 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); |
1053 | s, | ||
1054 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); | ||
1055 | } | 1065 | } |
1056 | s->valid_until = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); | 1066 | s->valid_until = |
1067 | GNUNET_TIME_relative_to_absolute | ||
1068 | (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT); | ||
1057 | if (s->invalidation_task != GNUNET_SCHEDULER_NO_TASK) | 1069 | if (s->invalidation_task != GNUNET_SCHEDULER_NO_TASK) |
1058 | { | 1070 | { |
1059 | GNUNET_SCHEDULER_cancel(s->invalidation_task); | 1071 | GNUNET_SCHEDULER_cancel (s->invalidation_task); |
1060 | s->invalidation_task = GNUNET_SCHEDULER_NO_TASK; | 1072 | s->invalidation_task = GNUNET_SCHEDULER_NO_TASK; |
1061 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1073 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Rescheduling %X' `%s'\n", s, |
1062 | "Rescheduling %X' `%s'\n", | 1074 | udp_address_to_string (NULL, arg, args)); |
1063 | s, udp_address_to_string(NULL, arg, args)); | ||
1064 | } | 1075 | } |
1065 | s->invalidation_task = GNUNET_SCHEDULER_add_delayed(GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, &invalidation_task, s); | 1076 | s->invalidation_task = |
1077 | GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT, | ||
1078 | &invalidation_task, s); | ||
1066 | /* iterate over all embedded messages */ | 1079 | /* iterate over all embedded messages */ |
1067 | si.sender = msg->sender; | 1080 | si.sender = msg->sender; |
1068 | si.arg = arg; | 1081 | si.arg = arg; |
@@ -1118,6 +1131,7 @@ ack_proc (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg) | |||
1118 | uint32_t delay = 0; | 1131 | uint32_t delay = 0; |
1119 | 1132 | ||
1120 | struct Session *s; | 1133 | struct Session *s; |
1134 | |||
1121 | s = find_inbound_session_by_addr (rc->plugin, rc->src_addr, rc->addr_len); | 1135 | s = find_inbound_session_by_addr (rc->plugin, rc->src_addr, rc->addr_len); |
1122 | if (s != NULL) | 1136 | if (s != NULL) |
1123 | { | 1137 | { |
@@ -1129,12 +1143,13 @@ ack_proc (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg) | |||
1129 | 1143 | ||
1130 | 1144 | ||
1131 | #if DEBUG_UDP | 1145 | #if DEBUG_UDP |
1132 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Sending ACK to `%s' including delay of %u ms\n", | 1146 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1133 | GNUNET_a2s (rc->src_addr, | 1147 | "Sending ACK to `%s' including delay of %u ms\n", |
1134 | (rc->src_addr->sa_family == | 1148 | GNUNET_a2s (rc->src_addr, |
1135 | AF_INET) ? sizeof (struct sockaddr_in) : | 1149 | (rc->src_addr->sa_family == |
1136 | sizeof (struct sockaddr_in6)), | 1150 | AF_INET) ? sizeof (struct sockaddr_in) : sizeof (struct |
1137 | delay); | 1151 | sockaddr_in6)), |
1152 | delay); | ||
1138 | #endif | 1153 | #endif |
1139 | udp_ack = (struct UDP_ACK_Message *) buf; | 1154 | udp_ack = (struct UDP_ACK_Message *) buf; |
1140 | udp_ack->header.size = htons ((uint16_t) msize); | 1155 | udp_ack->header.size = htons ((uint16_t) msize); |
@@ -1166,7 +1181,7 @@ struct FindReceiveContext | |||
1166 | */ | 1181 | */ |
1167 | socklen_t addr_len; | 1182 | socklen_t addr_len; |
1168 | 1183 | ||
1169 | struct Session * session; | 1184 | struct Session *session; |
1170 | }; | 1185 | }; |
1171 | 1186 | ||
1172 | 1187 | ||
@@ -1217,7 +1232,7 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) | |||
1217 | struct ReceiveContext *rc; | 1232 | struct ReceiveContext *rc; |
1218 | struct GNUNET_TIME_Absolute now; | 1233 | struct GNUNET_TIME_Absolute now; |
1219 | struct FindReceiveContext frc; | 1234 | struct FindReceiveContext frc; |
1220 | struct Session * s = NULL; | 1235 | struct Session *s = NULL; |
1221 | struct GNUNET_TIME_Relative flow_delay; | 1236 | struct GNUNET_TIME_Relative flow_delay; |
1222 | 1237 | ||
1223 | fromlen = sizeof (addr); | 1238 | fromlen = sizeof (addr); |
@@ -1233,8 +1248,8 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) | |||
1233 | msg = (const struct GNUNET_MessageHeader *) buf; | 1248 | msg = (const struct GNUNET_MessageHeader *) buf; |
1234 | 1249 | ||
1235 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1250 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1236 | "UDP received %u-byte message from `%s' type %i\n", (unsigned int) ret, | 1251 | "UDP received %u-byte message from `%s' type %i\n", (unsigned int) ret, |
1237 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen), ntohs(msg->type)); | 1252 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen), ntohs (msg->type)); |
1238 | 1253 | ||
1239 | if (ret != ntohs (msg->size)) | 1254 | if (ret != ntohs (msg->size)) |
1240 | { | 1255 | { |
@@ -1261,27 +1276,29 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) | |||
1261 | return; | 1276 | return; |
1262 | } | 1277 | } |
1263 | udp_ack = (const struct UDP_ACK_Message *) msg; | 1278 | udp_ack = (const struct UDP_ACK_Message *) msg; |
1264 | s = find_inbound_session(plugin, &udp_ack->sender, addr, fromlen); | 1279 | s = find_inbound_session (plugin, &udp_ack->sender, addr, fromlen); |
1265 | if (s != NULL) | 1280 | if (s != NULL) |
1266 | { | 1281 | { |
1267 | flow_delay.rel_value = (uint64_t) ntohl(udp_ack->delay); | 1282 | flow_delay.rel_value = (uint64_t) ntohl (udp_ack->delay); |
1268 | 1283 | ||
1269 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1284 | LOG (GNUNET_ERROR_TYPE_DEBUG, "We received a sending delay of %llu\n", |
1270 | "We received a sending delay of %llu\n", flow_delay.rel_value); | 1285 | flow_delay.rel_value); |
1271 | 1286 | ||
1272 | s->flow_delay_from_other_peer = GNUNET_TIME_relative_to_absolute (flow_delay); | 1287 | s->flow_delay_from_other_peer = |
1288 | GNUNET_TIME_relative_to_absolute (flow_delay); | ||
1273 | } | 1289 | } |
1274 | ack = (const struct GNUNET_MessageHeader *) &udp_ack[1]; | 1290 | ack = (const struct GNUNET_MessageHeader *) &udp_ack[1]; |
1275 | if (ntohs (ack->size) != ntohs (msg->size) - sizeof (struct UDP_ACK_Message)) | 1291 | if (ntohs (ack->size) != |
1292 | ntohs (msg->size) - sizeof (struct UDP_ACK_Message)) | ||
1276 | { | 1293 | { |
1277 | GNUNET_break_op (0); | 1294 | GNUNET_break_op (0); |
1278 | return; | 1295 | return; |
1279 | } | 1296 | } |
1280 | #if DEBUG_UDP | 1297 | #if DEBUG_UDP |
1281 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1298 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1282 | "UDP processes %u-byte acknowledgement from `%s' at `%s'\n", | 1299 | "UDP processes %u-byte acknowledgement from `%s' at `%s'\n", |
1283 | (unsigned int) ntohs (msg->size), GNUNET_i2s (&udp_ack->sender), | 1300 | (unsigned int) ntohs (msg->size), GNUNET_i2s (&udp_ack->sender), |
1284 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); | 1301 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); |
1285 | #endif | 1302 | #endif |
1286 | 1303 | ||
1287 | peer_session = find_session (plugin, &udp_ack->sender); | 1304 | peer_session = find_session (plugin, &udp_ack->sender); |
@@ -1289,7 +1306,7 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) | |||
1289 | { | 1306 | { |
1290 | #if DEBUG_UDP | 1307 | #if DEBUG_UDP |
1291 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1308 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1292 | "Session for ACK not found, dropping ACK!\n"); | 1309 | "Session for ACK not found, dropping ACK!\n"); |
1293 | #endif | 1310 | #endif |
1294 | return; | 1311 | return; |
1295 | } | 1312 | } |
@@ -1332,10 +1349,9 @@ udp_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) | |||
1332 | now.abs_value); | 1349 | now.abs_value); |
1333 | } | 1350 | } |
1334 | #if DEBUG_UDP | 1351 | #if DEBUG_UDP |
1335 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1352 | LOG (GNUNET_ERROR_TYPE_DEBUG, "UDP processes %u-byte fragment from `%s'\n", |
1336 | "UDP processes %u-byte fragment from `%s'\n", | 1353 | (unsigned int) ntohs (msg->size), |
1337 | (unsigned int) ntohs (msg->size), | 1354 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); |
1338 | GNUNET_a2s ((const struct sockaddr *) addr, fromlen)); | ||
1339 | #endif | 1355 | #endif |
1340 | 1356 | ||
1341 | if (GNUNET_OK == GNUNET_DEFRAGMENT_process_fragment (rc->defrag, msg)) | 1357 | if (GNUNET_OK == GNUNET_DEFRAGMENT_process_fragment (rc->defrag, msg)) |
@@ -1395,40 +1411,43 @@ udp_plugin_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1395 | 1411 | ||
1396 | struct MstContext | 1412 | struct MstContext |
1397 | { | 1413 | { |
1398 | struct Plugin * plugin; | 1414 | struct Plugin *plugin; |
1399 | 1415 | ||
1400 | struct IPv4UdpAddress addr; | 1416 | struct IPv4UdpAddress addr; |
1401 | }; | 1417 | }; |
1402 | 1418 | ||
1403 | void udp_broadcast_mst_cb (void *cls, void *client, | 1419 | void |
1404 | const struct | 1420 | udp_broadcast_mst_cb (void *cls, void *client, |
1405 | GNUNET_MessageHeader * | 1421 | const struct GNUNET_MessageHeader *message) |
1406 | message) | ||
1407 | { | 1422 | { |
1408 | struct Plugin * plugin = cls; | 1423 | struct Plugin *plugin = cls; |
1409 | struct MstContext * mc = client; | 1424 | struct MstContext *mc = client; |
1410 | const struct GNUNET_MessageHeader* hello; | 1425 | const struct GNUNET_MessageHeader *hello; |
1411 | struct UDP_Beacon_Message * msg; | 1426 | struct UDP_Beacon_Message *msg; |
1427 | |||
1412 | msg = (struct UDP_Beacon_Message *) message; | 1428 | msg = (struct UDP_Beacon_Message *) message; |
1413 | 1429 | ||
1414 | if (GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON != ntohs(msg->header.type)) | 1430 | if (GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON != |
1431 | ntohs (msg->header.type)) | ||
1415 | return; | 1432 | return; |
1416 | 1433 | ||
1417 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1434 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1418 | "Received beacon with %u bytes from peer `%s' via address `%s'\n", | 1435 | "Received beacon with %u bytes from peer `%s' via address `%s'\n", |
1419 | ntohs(msg->header.size), | 1436 | ntohs (msg->header.size), GNUNET_i2s (&msg->sender), |
1420 | GNUNET_i2s (&msg->sender), | 1437 | udp_address_to_string (NULL, &mc->addr, sizeof (mc->addr))); |
1421 | udp_address_to_string(NULL, &mc->addr, sizeof (mc->addr))); | ||
1422 | 1438 | ||
1423 | struct GNUNET_ATS_Information ats; | 1439 | struct GNUNET_ATS_Information ats; |
1440 | |||
1424 | ats.type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); | 1441 | ats.type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); |
1425 | ats.value = htonl (1); | 1442 | ats.value = htonl (1); |
1426 | 1443 | ||
1427 | hello = (struct GNUNET_MessageHeader *) &msg[1]; | 1444 | hello = (struct GNUNET_MessageHeader *) &msg[1]; |
1428 | plugin->env->receive (plugin->env->cls, &msg->sender, hello, &ats, 1, NULL, (const char *) &mc->addr, sizeof (mc->addr)); | 1445 | plugin->env->receive (plugin->env->cls, &msg->sender, hello, &ats, 1, NULL, |
1446 | (const char *) &mc->addr, sizeof (mc->addr)); | ||
1429 | 1447 | ||
1430 | GNUNET_STATISTICS_update(plugin->env->stats, | 1448 | GNUNET_STATISTICS_update (plugin->env->stats, |
1431 | _("# HELLO beacons received via udp"), 1, GNUNET_NO); | 1449 | _("# HELLO beacons received via udp"), 1, |
1450 | GNUNET_NO); | ||
1432 | GNUNET_free (mc); | 1451 | GNUNET_free (mc); |
1433 | } | 1452 | } |
1434 | 1453 | ||
@@ -1445,54 +1464,61 @@ udp_broadcast_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) | |||
1445 | char addr[32]; | 1464 | char addr[32]; |
1446 | char buf[65536]; | 1465 | char buf[65536]; |
1447 | ssize_t ret; | 1466 | ssize_t ret; |
1448 | struct MstContext * mc; | 1467 | struct MstContext *mc; |
1449 | 1468 | ||
1450 | 1469 | ||
1451 | fromlen = sizeof (addr); | 1470 | fromlen = sizeof (addr); |
1452 | memset (&addr, 0, sizeof (addr)); | 1471 | memset (&addr, 0, sizeof (addr)); |
1453 | ret = GNUNET_NETWORK_socket_recvfrom (rsock, buf, sizeof (buf), (struct sockaddr *) &addr, &fromlen); | 1472 | ret = |
1473 | GNUNET_NETWORK_socket_recvfrom (rsock, buf, sizeof (buf), | ||
1474 | (struct sockaddr *) &addr, &fromlen); | ||
1454 | if (ret < sizeof (struct GNUNET_MessageHeader)) | 1475 | if (ret < sizeof (struct GNUNET_MessageHeader)) |
1455 | { | 1476 | { |
1456 | /* malformed beacon, just throw it away */ | 1477 | /* malformed beacon, just throw it away */ |
1457 | return; | 1478 | return; |
1458 | } | 1479 | } |
1459 | 1480 | ||
1460 | mc = GNUNET_malloc(sizeof (struct MstContext)); | 1481 | mc = GNUNET_malloc (sizeof (struct MstContext)); |
1482 | |||
1483 | struct sockaddr_in *av4 = (struct sockaddr_in *) &addr; | ||
1461 | 1484 | ||
1462 | struct sockaddr_in * av4 = (struct sockaddr_in *) &addr; | ||
1463 | mc->addr.ipv4_addr = av4->sin_addr.s_addr; | 1485 | mc->addr.ipv4_addr = av4->sin_addr.s_addr; |
1464 | mc->addr.u4_port = av4->sin_port; | 1486 | mc->addr.u4_port = av4->sin_port; |
1465 | 1487 | ||
1466 | if (GNUNET_OK != GNUNET_SERVER_mst_receive(plugin->broadcast_mst, mc, buf, ret, GNUNET_NO, GNUNET_NO)) | 1488 | if (GNUNET_OK != |
1489 | GNUNET_SERVER_mst_receive (plugin->broadcast_mst, mc, buf, ret, GNUNET_NO, | ||
1490 | GNUNET_NO)) | ||
1467 | GNUNET_free (mc); | 1491 | GNUNET_free (mc); |
1468 | } | 1492 | } |
1469 | 1493 | ||
1470 | 1494 | ||
1471 | static void | 1495 | static void |
1472 | udp_broadcast_send (void *cls, | 1496 | udp_broadcast_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
1473 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
1474 | { | 1497 | { |
1475 | struct Plugin * plugin = cls; | 1498 | struct Plugin *plugin = cls; |
1476 | int sent; | 1499 | int sent; |
1477 | uint16_t msg_size; | 1500 | uint16_t msg_size; |
1478 | uint16_t hello_size; | 1501 | uint16_t hello_size; |
1479 | char buf[65536]; | 1502 | char buf[65536]; |
1503 | |||
1480 | // /ssize_t ret; | 1504 | // /ssize_t ret; |
1481 | const struct GNUNET_MessageHeader *hello; | 1505 | const struct GNUNET_MessageHeader *hello; |
1482 | struct UDP_Beacon_Message * msg; | 1506 | struct UDP_Beacon_Message *msg; |
1483 | 1507 | ||
1484 | plugin->send_broadcast_task = GNUNET_SCHEDULER_NO_TASK; | 1508 | plugin->send_broadcast_task = GNUNET_SCHEDULER_NO_TASK; |
1485 | 1509 | ||
1486 | struct sockaddr_in baddr; | 1510 | struct sockaddr_in baddr; |
1511 | |||
1487 | baddr.sin_family = AF_INET; | 1512 | baddr.sin_family = AF_INET; |
1488 | baddr.sin_port = htons (plugin->broadcast_port); | 1513 | baddr.sin_port = htons (plugin->broadcast_port); |
1489 | baddr.sin_addr.s_addr=htonl(-1); /* send message to 255.255.255.255 */ | 1514 | baddr.sin_addr.s_addr = htonl (-1); /* send message to 255.255.255.255 */ |
1490 | 1515 | ||
1491 | hello = plugin->env->get_our_hello (); | 1516 | hello = plugin->env->get_our_hello (); |
1492 | hello_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello); | 1517 | hello_size = GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) hello); |
1493 | msg_size = hello_size + sizeof (struct UDP_Beacon_Message); | 1518 | msg_size = hello_size + sizeof (struct UDP_Beacon_Message); |
1494 | 1519 | ||
1495 | if (hello_size < (sizeof (struct GNUNET_MessageHeader)) ||(msg_size > (UDP_MTU))) | 1520 | if (hello_size < (sizeof (struct GNUNET_MessageHeader)) || |
1521 | (msg_size > (UDP_MTU))) | ||
1496 | return; | 1522 | return; |
1497 | 1523 | ||
1498 | msg = (struct UDP_Beacon_Message *) buf; | 1524 | msg = (struct UDP_Beacon_Message *) buf; |
@@ -1501,13 +1527,17 @@ udp_broadcast_send (void *cls, | |||
1501 | msg->header.type = ntohs (GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON); | 1527 | msg->header.type = ntohs (GNUNET_MESSAGE_TYPE_TRANSPORT_BROADCAST_BEACON); |
1502 | memcpy (&msg[1], hello, hello_size); | 1528 | memcpy (&msg[1], hello, hello_size); |
1503 | 1529 | ||
1504 | sent = GNUNET_NETWORK_socket_sendto (plugin->sockv4_broadcast, msg, msg_size, | 1530 | sent = |
1505 | (const struct sockaddr *) &baddr, sizeof (struct sockaddr_in)); | 1531 | GNUNET_NETWORK_socket_sendto (plugin->sockv4_broadcast, msg, msg_size, |
1532 | (const struct sockaddr *) &baddr, | ||
1533 | sizeof (struct sockaddr_in)); | ||
1506 | 1534 | ||
1507 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1535 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Sent HELLO beacon broadcast with %i bytes\n", |
1508 | "Sent HELLO beacon broadcast with %i bytes\n", sent); | 1536 | sent); |
1509 | 1537 | ||
1510 | plugin->send_broadcast_task = GNUNET_SCHEDULER_add_delayed(plugin->broadcast_interval, &udp_broadcast_send, plugin); | 1538 | plugin->send_broadcast_task = |
1539 | GNUNET_SCHEDULER_add_delayed (plugin->broadcast_interval, | ||
1540 | &udp_broadcast_send, plugin); | ||
1511 | 1541 | ||
1512 | } | 1542 | } |
1513 | 1543 | ||
@@ -1520,7 +1550,8 @@ udp_broadcast_send (void *cls, | |||
1520 | * @param tc the scheduling context (for rescheduling this function again) | 1550 | * @param tc the scheduling context (for rescheduling this function again) |
1521 | */ | 1551 | */ |
1522 | static void | 1552 | static void |
1523 | udp_plugin_broadcast_select (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 1553 | udp_plugin_broadcast_select (void *cls, |
1554 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
1524 | { | 1555 | { |
1525 | struct Plugin *plugin = cls; | 1556 | struct Plugin *plugin = cls; |
1526 | 1557 | ||
@@ -1535,8 +1566,9 @@ udp_plugin_broadcast_select (void *cls, const struct GNUNET_SCHEDULER_TaskContex | |||
1535 | plugin->select_broadcast_task = | 1566 | plugin->select_broadcast_task = |
1536 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, | 1567 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
1537 | GNUNET_SCHEDULER_NO_TASK, | 1568 | GNUNET_SCHEDULER_NO_TASK, |
1538 | GNUNET_TIME_UNIT_FOREVER_REL, plugin->broadcast_rs, | 1569 | GNUNET_TIME_UNIT_FOREVER_REL, |
1539 | NULL, &udp_plugin_broadcast_select, plugin); | 1570 | plugin->broadcast_rs, NULL, |
1571 | &udp_plugin_broadcast_select, plugin); | ||
1540 | } | 1572 | } |
1541 | 1573 | ||
1542 | 1574 | ||
@@ -1664,7 +1696,7 @@ udp_address_to_string (void *cls, const void *addr, size_t addrlen) | |||
1664 | } | 1696 | } |
1665 | inet_ntop (af, sb, buf, INET6_ADDRSTRLEN); | 1697 | inet_ntop (af, sb, buf, INET6_ADDRSTRLEN); |
1666 | GNUNET_snprintf (rbuf, sizeof (rbuf), (af == AF_INET6) ? "[%s]:%u" : "%s:%u", | 1698 | GNUNET_snprintf (rbuf, sizeof (rbuf), (af == AF_INET6) ? "[%s]:%u" : "%s:%u", |
1667 | buf, port); | 1699 | buf, port); |
1668 | return rbuf; | 1700 | return rbuf; |
1669 | } | 1701 | } |
1670 | 1702 | ||
@@ -1868,16 +1900,20 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
1868 | &port)) | 1900 | &port)) |
1869 | port = 2086; | 1901 | port = 2086; |
1870 | 1902 | ||
1871 | broadcast = GNUNET_CONFIGURATION_get_value_yesno (env->cfg, "transport-udp", "BROADCAST"); | 1903 | broadcast = |
1872 | if (broadcast == GNUNET_SYSERR) | 1904 | GNUNET_CONFIGURATION_get_value_yesno (env->cfg, "transport-udp", |
1873 | broadcast = GNUNET_NO; | 1905 | "BROADCAST"); |
1906 | if (broadcast == GNUNET_SYSERR) | ||
1907 | broadcast = GNUNET_NO; | ||
1874 | 1908 | ||
1875 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_time (env->cfg, "transport-udp", "BROADCAST_INTERVAL", &interval)) | 1909 | if (GNUNET_SYSERR == |
1876 | interval = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10); | 1910 | GNUNET_CONFIGURATION_get_value_time (env->cfg, "transport-udp", |
1911 | "BROADCAST_INTERVAL", &interval)) | ||
1912 | interval = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10); | ||
1877 | 1913 | ||
1878 | if (GNUNET_OK != | 1914 | if (GNUNET_OK != |
1879 | GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-udp", "BROADCAST_PORT", | 1915 | GNUNET_CONFIGURATION_get_value_number (env->cfg, "transport-udp", |
1880 | &bport)) | 1916 | "BROADCAST_PORT", &bport)) |
1881 | bport = 20086; | 1917 | bport = 20086; |
1882 | 1918 | ||
1883 | if (GNUNET_OK != | 1919 | if (GNUNET_OK != |
@@ -1891,8 +1927,8 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
1891 | if (port > 65535) | 1927 | if (port > 65535) |
1892 | { | 1928 | { |
1893 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1929 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1894 | _("Given `%s' option is out of range: %llu > %u\n"), "PORT", | 1930 | _("Given `%s' option is out of range: %llu > %u\n"), "PORT", port, |
1895 | port, 65535); | 1931 | 65535); |
1896 | return NULL; | 1932 | return NULL; |
1897 | } | 1933 | } |
1898 | memset (&serverAddrv6, 0, sizeof (serverAddrv6)); | 1934 | memset (&serverAddrv6, 0, sizeof (serverAddrv6)); |
@@ -1923,8 +1959,8 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
1923 | "BINDTO", &plugin->bind4_address)) | 1959 | "BINDTO", &plugin->bind4_address)) |
1924 | { | 1960 | { |
1925 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1961 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1926 | "Binding udp plugin to specific address: `%s'\n", | 1962 | "Binding udp plugin to specific address: `%s'\n", |
1927 | plugin->bind4_address); | 1963 | plugin->bind4_address); |
1928 | if (1 != inet_pton (AF_INET, plugin->bind4_address, &serverAddrv4.sin_addr)) | 1964 | if (1 != inet_pton (AF_INET, plugin->bind4_address, &serverAddrv4.sin_addr)) |
1929 | { | 1965 | { |
1930 | GNUNET_free (plugin->bind4_address); | 1966 | GNUNET_free (plugin->bind4_address); |
@@ -1939,13 +1975,13 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
1939 | "BINDTO6", &plugin->bind6_address)) | 1975 | "BINDTO6", &plugin->bind6_address)) |
1940 | { | 1976 | { |
1941 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1977 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1942 | "Binding udp plugin to specific address: `%s'\n", | 1978 | "Binding udp plugin to specific address: `%s'\n", |
1943 | plugin->bind6_address); | 1979 | plugin->bind6_address); |
1944 | if (1 != | 1980 | if (1 != |
1945 | inet_pton (AF_INET6, plugin->bind6_address, &serverAddrv6.sin6_addr)) | 1981 | inet_pton (AF_INET6, plugin->bind6_address, &serverAddrv6.sin6_addr)) |
1946 | { | 1982 | { |
1947 | LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid IPv6 address: `%s'\n"), | 1983 | LOG (GNUNET_ERROR_TYPE_ERROR, _("Invalid IPv6 address: `%s'\n"), |
1948 | plugin->bind6_address); | 1984 | plugin->bind6_address); |
1949 | GNUNET_free_non_null (plugin->bind4_address); | 1985 | GNUNET_free_non_null (plugin->bind4_address); |
1950 | GNUNET_free (plugin->bind6_address); | 1986 | GNUNET_free (plugin->bind6_address); |
1951 | GNUNET_free (plugin); | 1987 | GNUNET_free (plugin); |
@@ -1984,7 +2020,7 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
1984 | serverAddr = (struct sockaddr *) &serverAddrv6; | 2020 | serverAddr = (struct sockaddr *) &serverAddrv6; |
1985 | #if DEBUG_UDP | 2021 | #if DEBUG_UDP |
1986 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Binding to IPv6 port %d\n", | 2022 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Binding to IPv6 port %d\n", |
1987 | ntohs (serverAddrv6.sin6_port)); | 2023 | ntohs (serverAddrv6.sin6_port)); |
1988 | #endif | 2024 | #endif |
1989 | tries = 0; | 2025 | tries = 0; |
1990 | while (GNUNET_NETWORK_socket_bind (plugin->sockv6, serverAddr, addrlen) != | 2026 | while (GNUNET_NETWORK_socket_bind (plugin->sockv6, serverAddr, addrlen) != |
@@ -1993,8 +2029,8 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
1993 | serverAddrv6.sin6_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* Find a good, non-root port */ | 2029 | serverAddrv6.sin6_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* Find a good, non-root port */ |
1994 | #if DEBUG_UDP | 2030 | #if DEBUG_UDP |
1995 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2031 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1996 | "IPv6 Binding failed, trying new port %d\n", | 2032 | "IPv6 Binding failed, trying new port %d\n", |
1997 | ntohs (serverAddrv6.sin6_port)); | 2033 | ntohs (serverAddrv6.sin6_port)); |
1998 | #endif | 2034 | #endif |
1999 | tries++; | 2035 | tries++; |
2000 | if (tries > 10) | 2036 | if (tries > 10) |
@@ -2032,7 +2068,7 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
2032 | serverAddr = (struct sockaddr *) &serverAddrv4; | 2068 | serverAddr = (struct sockaddr *) &serverAddrv4; |
2033 | #if DEBUG_UDP | 2069 | #if DEBUG_UDP |
2034 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Binding to IPv4 port %d\n", | 2070 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Binding to IPv4 port %d\n", |
2035 | ntohs (serverAddrv4.sin_port)); | 2071 | ntohs (serverAddrv4.sin_port)); |
2036 | #endif | 2072 | #endif |
2037 | tries = 0; | 2073 | tries = 0; |
2038 | while (GNUNET_NETWORK_socket_bind (plugin->sockv4, serverAddr, addrlen) != | 2074 | while (GNUNET_NETWORK_socket_bind (plugin->sockv4, serverAddr, addrlen) != |
@@ -2040,9 +2076,8 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
2040 | { | 2076 | { |
2041 | serverAddrv4.sin_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* Find a good, non-root port */ | 2077 | serverAddrv4.sin_port = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); /* Find a good, non-root port */ |
2042 | #if DEBUG_UDP | 2078 | #if DEBUG_UDP |
2043 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2079 | LOG (GNUNET_ERROR_TYPE_DEBUG, "IPv4 Binding failed, trying new port %d\n", |
2044 | "IPv4 Binding failed, trying new port %d\n", | 2080 | ntohs (serverAddrv4.sin_port)); |
2045 | ntohs (serverAddrv4.sin_port)); | ||
2046 | #endif | 2081 | #endif |
2047 | tries++; | 2082 | tries++; |
2048 | if (tries > 10) | 2083 | if (tries > 10) |
@@ -2077,47 +2112,56 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
2077 | /* create broadcast socket */ | 2112 | /* create broadcast socket */ |
2078 | if (broadcast) | 2113 | if (broadcast) |
2079 | { | 2114 | { |
2080 | plugin->sockv4_broadcast = GNUNET_NETWORK_socket_create (PF_INET, SOCK_DGRAM, 0); | 2115 | plugin->sockv4_broadcast = |
2116 | GNUNET_NETWORK_socket_create (PF_INET, SOCK_DGRAM, 0); | ||
2081 | if (NULL == plugin->sockv4_broadcast) | 2117 | if (NULL == plugin->sockv4_broadcast) |
2082 | { | 2118 | { |
2083 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "socket"); | 2119 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "socket"); |
2084 | } | 2120 | } |
2085 | else | 2121 | else |
2086 | { | 2122 | { |
2087 | #if HAVE_SOCKADDR_IN_SIN_LEN | 2123 | #if HAVE_SOCKADDR_IN_SIN_LEN |
2088 | serverAddrv4.sin_len = sizeof (serverAddrv4); | 2124 | serverAddrv4.sin_len = sizeof (serverAddrv4); |
2089 | #endif | 2125 | #endif |
2090 | serverAddrv4.sin_family = AF_INET; | 2126 | serverAddrv4.sin_family = AF_INET; |
2091 | serverAddrv4.sin_addr.s_addr = INADDR_ANY; | 2127 | serverAddrv4.sin_addr.s_addr = INADDR_ANY; |
2092 | serverAddrv4.sin_port = htons (plugin->broadcast_port); | 2128 | serverAddrv4.sin_port = htons (plugin->broadcast_port); |
2093 | addrlen = sizeof (serverAddrv4); | 2129 | addrlen = sizeof (serverAddrv4); |
2094 | serverAddr = (struct sockaddr *) &serverAddrv4; | 2130 | serverAddr = (struct sockaddr *) &serverAddrv4; |
2095 | #if DEBUG_UDP | 2131 | #if DEBUG_UDP |
2096 | #endif | 2132 | #endif |
2097 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Binding Broadcast to IPv4 port %d\n", | 2133 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Binding Broadcast to IPv4 port %d\n", |
2098 | ntohs (serverAddrv4.sin_port)); | 2134 | ntohs (serverAddrv4.sin_port)); |
2099 | 2135 | ||
2100 | if (GNUNET_NETWORK_socket_bind (plugin->sockv4_broadcast, serverAddr, addrlen) != GNUNET_OK) | 2136 | if (GNUNET_NETWORK_socket_bind |
2137 | (plugin->sockv4_broadcast, serverAddr, addrlen) != GNUNET_OK) | ||
2101 | { | 2138 | { |
2102 | LOG (GNUNET_ERROR_TYPE_WARNING, _("Failed to create IPv4 broadcast socket on port %d\n"), | 2139 | LOG (GNUNET_ERROR_TYPE_WARNING, |
2103 | ntohs (serverAddrv4.sin_port)); | 2140 | _("Failed to create IPv4 broadcast socket on port %d\n"), |
2104 | GNUNET_NETWORK_socket_close (plugin->sockv4_broadcast); | 2141 | ntohs (serverAddrv4.sin_port)); |
2105 | plugin->sockv4_broadcast = NULL; | 2142 | GNUNET_NETWORK_socket_close (plugin->sockv4_broadcast); |
2143 | plugin->sockv4_broadcast = NULL; | ||
2106 | } | 2144 | } |
2107 | if (plugin->sockv4_broadcast != NULL) | 2145 | if (plugin->sockv4_broadcast != NULL) |
2108 | { | 2146 | { |
2109 | int yes = 1; | 2147 | int yes = 1; |
2110 | if (GNUNET_NETWORK_socket_setsockopt (plugin->sockv4_broadcast, SOL_SOCKET, SO_BROADCAST, &yes, sizeof(int)) != GNUNET_OK) | 2148 | |
2149 | if (GNUNET_NETWORK_socket_setsockopt | ||
2150 | (plugin->sockv4_broadcast, SOL_SOCKET, SO_BROADCAST, &yes, | ||
2151 | sizeof (int)) != GNUNET_OK) | ||
2111 | { | 2152 | { |
2112 | LOG (GNUNET_ERROR_TYPE_WARNING, _("Failed to set IPv4 broadcast option for broadcast socket on port %d\n"), | 2153 | LOG (GNUNET_ERROR_TYPE_WARNING, |
2113 | ntohs (serverAddrv4.sin_port)); | 2154 | _ |
2114 | GNUNET_NETWORK_socket_close(plugin->sockv4_broadcast); | 2155 | ("Failed to set IPv4 broadcast option for broadcast socket on port %d\n"), |
2156 | ntohs (serverAddrv4.sin_port)); | ||
2157 | GNUNET_NETWORK_socket_close (plugin->sockv4_broadcast); | ||
2115 | plugin->sockv4_broadcast = NULL; | 2158 | plugin->sockv4_broadcast = NULL; |
2116 | } | 2159 | } |
2117 | else | 2160 | else |
2118 | { | 2161 | { |
2119 | plugin->broadcast_rs = GNUNET_NETWORK_fdset_create (); | 2162 | plugin->broadcast_rs = GNUNET_NETWORK_fdset_create (); |
2120 | GNUNET_NETWORK_fdset_set (plugin->broadcast_rs, plugin->sockv4_broadcast); | 2163 | GNUNET_NETWORK_fdset_set (plugin->broadcast_rs, |
2164 | plugin->sockv4_broadcast); | ||
2121 | } | 2165 | } |
2122 | } | 2166 | } |
2123 | } | 2167 | } |
@@ -2125,16 +2169,20 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
2125 | if (plugin->sockv4_broadcast != NULL) | 2169 | if (plugin->sockv4_broadcast != NULL) |
2126 | { | 2170 | { |
2127 | plugin->broadcast = GNUNET_YES; | 2171 | plugin->broadcast = GNUNET_YES; |
2128 | plugin->broadcast_mst = GNUNET_SERVER_mst_create (udp_broadcast_mst_cb, plugin); | 2172 | plugin->broadcast_mst = |
2129 | GNUNET_STATISTICS_update(plugin->env->stats, | 2173 | GNUNET_SERVER_mst_create (udp_broadcast_mst_cb, plugin); |
2130 | _("# HELLO beacons received via udp"), 1, GNUNET_NO); | 2174 | GNUNET_STATISTICS_update (plugin->env->stats, |
2175 | _("# HELLO beacons received via udp"), 1, | ||
2176 | GNUNET_NO); | ||
2131 | plugin->select_broadcast_task = | 2177 | plugin->select_broadcast_task = |
2132 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, | 2178 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
2133 | GNUNET_SCHEDULER_NO_TASK, | 2179 | GNUNET_SCHEDULER_NO_TASK, |
2134 | GNUNET_TIME_UNIT_FOREVER_REL, plugin->broadcast_rs, | 2180 | GNUNET_TIME_UNIT_FOREVER_REL, |
2135 | NULL, &udp_plugin_broadcast_select, plugin); | 2181 | plugin->broadcast_rs, NULL, |
2136 | 2182 | &udp_plugin_broadcast_select, plugin); | |
2137 | plugin->send_broadcast_task = GNUNET_SCHEDULER_add_now (&udp_broadcast_send, plugin); | 2183 | |
2184 | plugin->send_broadcast_task = | ||
2185 | GNUNET_SCHEDULER_add_now (&udp_broadcast_send, plugin); | ||
2138 | } | 2186 | } |
2139 | else | 2187 | else |
2140 | plugin->broadcast = GNUNET_NO; | 2188 | plugin->broadcast = GNUNET_NO; |
@@ -2167,8 +2215,8 @@ libgnunet_plugin_transport_udp_done (void *cls) | |||
2167 | NULL); | 2215 | NULL); |
2168 | GNUNET_CONTAINER_multihashmap_destroy (plugin->sessions); | 2216 | GNUNET_CONTAINER_multihashmap_destroy (plugin->sessions); |
2169 | plugin->sessions = NULL; | 2217 | plugin->sessions = NULL; |
2170 | GNUNET_CONTAINER_multihashmap_iterate (plugin->inbound_sessions, &destroy_inbound_session, | 2218 | GNUNET_CONTAINER_multihashmap_iterate (plugin->inbound_sessions, |
2171 | NULL); | 2219 | &destroy_inbound_session, NULL); |
2172 | GNUNET_CONTAINER_multihashmap_destroy (plugin->inbound_sessions); | 2220 | GNUNET_CONTAINER_multihashmap_destroy (plugin->inbound_sessions); |
2173 | plugin->inbound_sessions = NULL; | 2221 | plugin->inbound_sessions = NULL; |
2174 | while (NULL != (rc = GNUNET_CONTAINER_heap_remove_root (plugin->defrags))) | 2222 | while (NULL != (rc = GNUNET_CONTAINER_heap_remove_root (plugin->defrags))) |
@@ -2201,16 +2249,17 @@ libgnunet_plugin_transport_udp_done (void *cls) | |||
2201 | GNUNET_SCHEDULER_cancel (plugin->select_broadcast_task); | 2249 | GNUNET_SCHEDULER_cancel (plugin->select_broadcast_task); |
2202 | plugin->select_broadcast_task = GNUNET_SCHEDULER_NO_TASK; | 2250 | plugin->select_broadcast_task = GNUNET_SCHEDULER_NO_TASK; |
2203 | } | 2251 | } |
2204 | if (plugin->send_broadcast_task != GNUNET_SCHEDULER_NO_TASK) | 2252 | if (plugin->send_broadcast_task != GNUNET_SCHEDULER_NO_TASK) |
2205 | { | 2253 | { |
2206 | GNUNET_SCHEDULER_cancel (plugin->send_broadcast_task ); | 2254 | GNUNET_SCHEDULER_cancel (plugin->send_broadcast_task); |
2207 | plugin->send_broadcast_task = GNUNET_SCHEDULER_NO_TASK; | 2255 | plugin->send_broadcast_task = GNUNET_SCHEDULER_NO_TASK; |
2208 | } | 2256 | } |
2209 | if (plugin->broadcast_mst != NULL) | 2257 | if (plugin->broadcast_mst != NULL) |
2210 | GNUNET_SERVER_mst_destroy(plugin->broadcast_mst); | 2258 | GNUNET_SERVER_mst_destroy (plugin->broadcast_mst); |
2211 | if (plugin->sockv4_broadcast != NULL) | 2259 | if (plugin->sockv4_broadcast != NULL) |
2212 | { | 2260 | { |
2213 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (plugin->sockv4_broadcast)); | 2261 | GNUNET_break (GNUNET_OK == |
2262 | GNUNET_NETWORK_socket_close (plugin->sockv4_broadcast)); | ||
2214 | plugin->sockv4_broadcast = NULL; | 2263 | plugin->sockv4_broadcast = NULL; |
2215 | } | 2264 | } |
2216 | GNUNET_NETWORK_fdset_destroy (plugin->broadcast_rs); | 2265 | GNUNET_NETWORK_fdset_destroy (plugin->broadcast_rs); |