diff options
author | ng0 <ng0@n0.is> | 2019-09-06 22:46:29 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-09-06 22:46:29 +0000 |
commit | 6e599264ad13e8fc105493d74d7c11d46f8739ed (patch) | |
tree | 169bef1ecbade5a659831fb169f3ae6943af127f /src/transport/plugin_transport_udp.c | |
parent | 4f13bc15113021ebf71d5d81e99bc29f8a07fc9c (diff) | |
download | gnunet-6e599264ad13e8fc105493d74d7c11d46f8739ed.tar.gz gnunet-6e599264ad13e8fc105493d74d7c11d46f8739ed.zip |
first step to remove plibc
Diffstat (limited to 'src/transport/plugin_transport_udp.c')
-rw-r--r-- | src/transport/plugin_transport_udp.c | 1187 |
1 files changed, 456 insertions, 731 deletions
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c index b05192e06..1d34cdd1a 100644 --- a/src/transport/plugin_transport_udp.c +++ b/src/transport/plugin_transport_udp.c | |||
@@ -40,12 +40,13 @@ | |||
40 | #include "gnunet_transport_plugin.h" | 40 | #include "gnunet_transport_plugin.h" |
41 | #include "transport.h" | 41 | #include "transport.h" |
42 | 42 | ||
43 | #define LOG(kind,...) GNUNET_log_from (kind, "transport-udp", __VA_ARGS__) | 43 | #define LOG(kind, ...) GNUNET_log_from (kind, "transport-udp", __VA_ARGS__) |
44 | 44 | ||
45 | /** | 45 | /** |
46 | * After how much inactivity should a UDP session time out? | 46 | * After how much inactivity should a UDP session time out? |
47 | */ | 47 | */ |
48 | #define UDP_SESSION_TIME_OUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) | 48 | #define UDP_SESSION_TIME_OUT \ |
49 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60) | ||
49 | 50 | ||
50 | /** | 51 | /** |
51 | * Number of messages we can defragment in parallel. We only really | 52 | * Number of messages we can defragment in parallel. We only really |
@@ -86,7 +87,6 @@ struct UDPMessage | |||
86 | * What is the identity of the sender | 87 | * What is the identity of the sender |
87 | */ | 88 | */ |
88 | struct GNUNET_PeerIdentity sender; | 89 | struct GNUNET_PeerIdentity sender; |
89 | |||
90 | }; | 90 | }; |
91 | 91 | ||
92 | 92 | ||
@@ -144,7 +144,6 @@ struct PrettyPrinterContext | |||
144 | * Port to add after the IP address. | 144 | * Port to add after the IP address. |
145 | */ | 145 | */ |
146 | uint16_t port; | 146 | uint16_t port; |
147 | |||
148 | }; | 147 | }; |
149 | 148 | ||
150 | 149 | ||
@@ -248,7 +247,6 @@ struct GNUNET_ATS_Session | |||
248 | }; | 247 | }; |
249 | 248 | ||
250 | 249 | ||
251 | |||
252 | /** | 250 | /** |
253 | * Data structure to track defragmentation contexts based | 251 | * Data structure to track defragmentation contexts based |
254 | * on the source of the UDP traffic. | 252 | * on the source of the UDP traffic. |
@@ -374,7 +372,6 @@ struct UDP_FragmentationContext | |||
374 | * Bytes used to send all fragments on wire including UDP overhead | 372 | * Bytes used to send all fragments on wire including UDP overhead |
375 | */ | 373 | */ |
376 | size_t on_wire_size; | 374 | size_t on_wire_size; |
377 | |||
378 | }; | 375 | }; |
379 | 376 | ||
380 | 377 | ||
@@ -388,10 +385,9 @@ struct UDP_FragmentationContext | |||
388 | * #GNUNET_SYSERR if the target disconnected | 385 | * #GNUNET_SYSERR if the target disconnected |
389 | * or we had a timeout or other trouble sending | 386 | * or we had a timeout or other trouble sending |
390 | */ | 387 | */ |
391 | typedef void | 388 | typedef void (*QueueContinuation) (void *cls, |
392 | (*QueueContinuation) (void *cls, | 389 | struct UDP_MessageWrapper *udpw, |
393 | struct UDP_MessageWrapper *udpw, | 390 | int result); |
394 | int result); | ||
395 | 391 | ||
396 | 392 | ||
397 | /** | 393 | /** |
@@ -474,7 +470,6 @@ struct UDP_MessageWrapper | |||
474 | * Payload size of original message. | 470 | * Payload size of original message. |
475 | */ | 471 | */ |
476 | size_t payload_size; | 472 | size_t payload_size; |
477 | |||
478 | }; | 473 | }; |
479 | 474 | ||
480 | 475 | ||
@@ -501,7 +496,6 @@ struct UDP_ACK_Message | |||
501 | * What is the identity of the sender | 496 | * What is the identity of the sender |
502 | */ | 497 | */ |
503 | struct GNUNET_PeerIdentity sender; | 498 | struct GNUNET_PeerIdentity sender; |
504 | |||
505 | }; | 499 | }; |
506 | 500 | ||
507 | GNUNET_NETWORK_STRUCT_END | 501 | GNUNET_NETWORK_STRUCT_END |
@@ -529,9 +523,7 @@ notify_session_monitor (struct Plugin *plugin, | |||
529 | return; | 523 | return; |
530 | if (GNUNET_YES == session->in_destroy) | 524 | if (GNUNET_YES == session->in_destroy) |
531 | return; /* already destroyed, just RC>0 left-over actions */ | 525 | return; /* already destroyed, just RC>0 left-over actions */ |
532 | memset (&info, | 526 | memset (&info, 0, sizeof (info)); |
533 | 0, | ||
534 | sizeof (info)); | ||
535 | info.state = state; | 527 | info.state = state; |
536 | info.is_inbound = GNUNET_SYSERR; /* hard to say */ | 528 | info.is_inbound = GNUNET_SYSERR; /* hard to say */ |
537 | info.num_msg_pending = session->msgs_in_queue; | 529 | info.num_msg_pending = session->msgs_in_queue; |
@@ -541,9 +533,7 @@ notify_session_monitor (struct Plugin *plugin, | |||
541 | to receive from others) */ | 533 | to receive from others) */ |
542 | info.session_timeout = session->timeout; | 534 | info.session_timeout = session->timeout; |
543 | info.address = session->address; | 535 | info.address = session->address; |
544 | plugin->sic (plugin->sic_cls, | 536 | plugin->sic (plugin->sic_cls, session, &info); |
545 | session, | ||
546 | &info); | ||
547 | } | 537 | } |
548 | 538 | ||
549 | 539 | ||
@@ -563,12 +553,8 @@ send_session_info_iter (void *cls, | |||
563 | struct Plugin *plugin = cls; | 553 | struct Plugin *plugin = cls; |
564 | struct GNUNET_ATS_Session *session = value; | 554 | struct GNUNET_ATS_Session *session = value; |
565 | 555 | ||
566 | notify_session_monitor (plugin, | 556 | notify_session_monitor (plugin, session, GNUNET_TRANSPORT_SS_INIT); |
567 | session, | 557 | notify_session_monitor (plugin, session, GNUNET_TRANSPORT_SS_UP); |
568 | GNUNET_TRANSPORT_SS_INIT); | ||
569 | notify_session_monitor (plugin, | ||
570 | session, | ||
571 | GNUNET_TRANSPORT_SS_UP); | ||
572 | return GNUNET_OK; | 558 | return GNUNET_OK; |
573 | } | 559 | } |
574 | 560 | ||
@@ -600,9 +586,7 @@ udp_plugin_setup_monitor (void *cls, | |||
600 | &send_session_info_iter, | 586 | &send_session_info_iter, |
601 | plugin); | 587 | plugin); |
602 | /* signal end of first iteration */ | 588 | /* signal end of first iteration */ |
603 | sic (sic_cls, | 589 | sic (sic_cls, NULL, NULL); |
604 | NULL, | ||
605 | NULL); | ||
606 | } | 590 | } |
607 | } | 591 | } |
608 | 592 | ||
@@ -625,9 +609,7 @@ free_session (struct GNUNET_ATS_Session *s) | |||
625 | } | 609 | } |
626 | if (NULL != s->frag_ctx) | 610 | if (NULL != s->frag_ctx) |
627 | { | 611 | { |
628 | GNUNET_FRAGMENT_context_destroy (s->frag_ctx->frag, | 612 | GNUNET_FRAGMENT_context_destroy (s->frag_ctx->frag, NULL, NULL); |
629 | NULL, | ||
630 | NULL); | ||
631 | GNUNET_free (s->frag_ctx); | 613 | GNUNET_free (s->frag_ctx); |
632 | s->frag_ctx = NULL; | 614 | s->frag_ctx = NULL; |
633 | } | 615 | } |
@@ -663,8 +645,7 @@ udp_query_keepalive_factor (void *cls) | |||
663 | * @return the network type | 645 | * @return the network type |
664 | */ | 646 | */ |
665 | static enum GNUNET_NetworkType | 647 | static enum GNUNET_NetworkType |
666 | udp_plugin_get_network (void *cls, | 648 | udp_plugin_get_network (void *cls, struct GNUNET_ATS_Session *session) |
667 | struct GNUNET_ATS_Session *session) | ||
668 | { | 649 | { |
669 | return session->scope; | 650 | return session->scope; |
670 | } | 651 | } |
@@ -691,25 +672,25 @@ udp_plugin_get_network_for_address (void *cls, | |||
691 | size_t sbs; | 672 | size_t sbs; |
692 | 673 | ||
693 | addrlen = address->address_length; | 674 | addrlen = address->address_length; |
694 | if (addrlen == sizeof(struct IPv6UdpAddress)) | 675 | if (addrlen == sizeof (struct IPv6UdpAddress)) |
695 | { | 676 | { |
696 | GNUNET_assert (NULL != address->address); /* make static analysis happy */ | 677 | GNUNET_assert (NULL != address->address); /* make static analysis happy */ |
697 | u6 = address->address; | 678 | u6 = address->address; |
698 | memset (&a6, 0, sizeof(a6)); | 679 | memset (&a6, 0, sizeof (a6)); |
699 | #if HAVE_SOCKADDR_IN_SIN_LEN | 680 | #if HAVE_SOCKADDR_IN_SIN_LEN |
700 | a6.sin6_len = sizeof (a6); | 681 | a6.sin6_len = sizeof (a6); |
701 | #endif | 682 | #endif |
702 | a6.sin6_family = AF_INET6; | 683 | a6.sin6_family = AF_INET6; |
703 | a6.sin6_port = u6->u6_port; | 684 | a6.sin6_port = u6->u6_port; |
704 | GNUNET_memcpy (&a6.sin6_addr, &u6->ipv6_addr, sizeof(struct in6_addr)); | 685 | GNUNET_memcpy (&a6.sin6_addr, &u6->ipv6_addr, sizeof (struct in6_addr)); |
705 | sb = &a6; | 686 | sb = &a6; |
706 | sbs = sizeof(a6); | 687 | sbs = sizeof (a6); |
707 | } | 688 | } |
708 | else if (addrlen == sizeof(struct IPv4UdpAddress)) | 689 | else if (addrlen == sizeof (struct IPv4UdpAddress)) |
709 | { | 690 | { |
710 | GNUNET_assert (NULL != address->address); /* make static analysis happy */ | 691 | GNUNET_assert (NULL != address->address); /* make static analysis happy */ |
711 | u4 = address->address; | 692 | u4 = address->address; |
712 | memset (&a4, 0, sizeof(a4)); | 693 | memset (&a4, 0, sizeof (a4)); |
713 | #if HAVE_SOCKADDR_IN_SIN_LEN | 694 | #if HAVE_SOCKADDR_IN_SIN_LEN |
714 | a4.sin_len = sizeof (a4); | 695 | a4.sin_len = sizeof (a4); |
715 | #endif | 696 | #endif |
@@ -717,16 +698,14 @@ udp_plugin_get_network_for_address (void *cls, | |||
717 | a4.sin_port = u4->u4_port; | 698 | a4.sin_port = u4->u4_port; |
718 | a4.sin_addr.s_addr = u4->ipv4_addr; | 699 | a4.sin_addr.s_addr = u4->ipv4_addr; |
719 | sb = &a4; | 700 | sb = &a4; |
720 | sbs = sizeof(a4); | 701 | sbs = sizeof (a4); |
721 | } | 702 | } |
722 | else | 703 | else |
723 | { | 704 | { |
724 | GNUNET_break (0); | 705 | GNUNET_break (0); |
725 | return GNUNET_NT_UNSPECIFIED; | 706 | return GNUNET_NT_UNSPECIFIED; |
726 | } | 707 | } |
727 | return plugin->env->get_address_type (plugin->env->cls, | 708 | return plugin->env->get_address_type (plugin->env->cls, sb, sbs); |
728 | sb, | ||
729 | sbs); | ||
730 | } | 709 | } |
731 | 710 | ||
732 | 711 | ||
@@ -767,8 +746,7 @@ schedule_select_v4 (struct Plugin *plugin) | |||
767 | struct UDP_MessageWrapper *udpw; | 746 | struct UDP_MessageWrapper *udpw; |
768 | struct UDP_MessageWrapper *min_udpw; | 747 | struct UDP_MessageWrapper *min_udpw; |
769 | 748 | ||
770 | if ( (GNUNET_YES == plugin->enable_ipv4) && | 749 | if ((GNUNET_YES == plugin->enable_ipv4) && (NULL != plugin->sockv4)) |
771 | (NULL != plugin->sockv4) ) | ||
772 | { | 750 | { |
773 | /* Find a message ready to send: | 751 | /* Find a message ready to send: |
774 | * Flow delay from other peer is expired or not set (0) */ | 752 | * Flow delay from other peer is expired or not set (0) */ |
@@ -804,11 +782,11 @@ schedule_select_v4 (struct Plugin *plugin) | |||
804 | GNUNET_i2s (&min_udpw->session->target)); | 782 | GNUNET_i2s (&min_udpw->session->target)); |
805 | } | 783 | } |
806 | } | 784 | } |
807 | plugin->select_task_v4 | 785 | plugin->select_task_v4 = |
808 | = GNUNET_SCHEDULER_add_read_net (min_delay, | 786 | GNUNET_SCHEDULER_add_read_net (min_delay, |
809 | plugin->sockv4, | 787 | plugin->sockv4, |
810 | &udp_plugin_select_v4, | 788 | &udp_plugin_select_v4, |
811 | plugin); | 789 | plugin); |
812 | } | 790 | } |
813 | } | 791 | } |
814 | 792 | ||
@@ -826,8 +804,7 @@ schedule_select_v6 (struct Plugin *plugin) | |||
826 | struct UDP_MessageWrapper *udpw; | 804 | struct UDP_MessageWrapper *udpw; |
827 | struct UDP_MessageWrapper *min_udpw; | 805 | struct UDP_MessageWrapper *min_udpw; |
828 | 806 | ||
829 | if ( (GNUNET_YES == plugin->enable_ipv6) && | 807 | if ((GNUNET_YES == plugin->enable_ipv6) && (NULL != plugin->sockv6)) |
830 | (NULL != plugin->sockv6) ) | ||
831 | { | 808 | { |
832 | min_delay = GNUNET_TIME_UNIT_FOREVER_REL; | 809 | min_delay = GNUNET_TIME_UNIT_FOREVER_REL; |
833 | min_udpw = NULL; | 810 | min_udpw = NULL; |
@@ -861,11 +838,11 @@ schedule_select_v6 (struct Plugin *plugin) | |||
861 | GNUNET_i2s (&min_udpw->session->target)); | 838 | GNUNET_i2s (&min_udpw->session->target)); |
862 | } | 839 | } |
863 | } | 840 | } |
864 | plugin->select_task_v6 | 841 | plugin->select_task_v6 = |
865 | = GNUNET_SCHEDULER_add_read_net (min_delay, | 842 | GNUNET_SCHEDULER_add_read_net (min_delay, |
866 | plugin->sockv6, | 843 | plugin->sockv6, |
867 | &udp_plugin_select_v6, | 844 | &udp_plugin_select_v6, |
868 | plugin); | 845 | plugin); |
869 | } | 846 | } |
870 | } | 847 | } |
871 | 848 | ||
@@ -885,9 +862,7 @@ schedule_select_v6 (struct Plugin *plugin) | |||
885 | * @return string representing the same address | 862 | * @return string representing the same address |
886 | */ | 863 | */ |
887 | const char * | 864 | const char * |
888 | udp_address_to_string (void *cls, | 865 | udp_address_to_string (void *cls, const void *addr, size_t addrlen) |
889 | const void *addr, | ||
890 | size_t addrlen) | ||
891 | { | 866 | { |
892 | static char rbuf[INET6_ADDRSTRLEN + 10]; | 867 | static char rbuf[INET6_ADDRSTRLEN + 10]; |
893 | char buf[INET6_ADDRSTRLEN]; | 868 | char buf[INET6_ADDRSTRLEN]; |
@@ -906,7 +881,7 @@ udp_address_to_string (void *cls, | |||
906 | return NULL; | 881 | return NULL; |
907 | } | 882 | } |
908 | 883 | ||
909 | if (addrlen == sizeof(struct IPv6UdpAddress)) | 884 | if (addrlen == sizeof (struct IPv6UdpAddress)) |
910 | { | 885 | { |
911 | t6 = addr; | 886 | t6 = addr; |
912 | af = AF_INET6; | 887 | af = AF_INET6; |
@@ -915,7 +890,7 @@ udp_address_to_string (void *cls, | |||
915 | a6 = t6->ipv6_addr; | 890 | a6 = t6->ipv6_addr; |
916 | sb = &a6; | 891 | sb = &a6; |
917 | } | 892 | } |
918 | else if (addrlen == sizeof(struct IPv4UdpAddress)) | 893 | else if (addrlen == sizeof (struct IPv4UdpAddress)) |
919 | { | 894 | { |
920 | t4 = addr; | 895 | t4 = addr; |
921 | af = AF_INET; | 896 | af = AF_INET; |
@@ -929,15 +904,10 @@ udp_address_to_string (void *cls, | |||
929 | GNUNET_break_op (0); | 904 | GNUNET_break_op (0); |
930 | return NULL; | 905 | return NULL; |
931 | } | 906 | } |
932 | inet_ntop (af, | 907 | inet_ntop (af, sb, buf, INET6_ADDRSTRLEN); |
933 | sb, | ||
934 | buf, | ||
935 | INET6_ADDRSTRLEN); | ||
936 | GNUNET_snprintf (rbuf, | 908 | GNUNET_snprintf (rbuf, |
937 | sizeof(rbuf), | 909 | sizeof (rbuf), |
938 | (af == AF_INET6) | 910 | (af == AF_INET6) ? "%s.%u.[%s]:%u" : "%s.%u.%s:%u", |
939 | ? "%s.%u.[%s]:%u" | ||
940 | : "%s.%u.%s:%u", | ||
941 | PLUGIN_NAME, | 911 | PLUGIN_NAME, |
942 | options, | 912 | options, |
943 | buf, | 913 | buf, |
@@ -1012,44 +982,42 @@ udp_string_to_address (void *cls, | |||
1012 | address++; | 982 | address++; |
1013 | 983 | ||
1014 | if (GNUNET_OK != | 984 | if (GNUNET_OK != |
1015 | GNUNET_STRINGS_to_address_ip (address, | 985 | GNUNET_STRINGS_to_address_ip (address, strlen (address), &socket_address)) |
1016 | strlen (address), | ||
1017 | &socket_address)) | ||
1018 | { | 986 | { |
1019 | GNUNET_break (0); | 987 | GNUNET_break (0); |
1020 | GNUNET_free (plugin); | 988 | GNUNET_free (plugin); |
1021 | return GNUNET_SYSERR; | 989 | return GNUNET_SYSERR; |
1022 | } | 990 | } |
1023 | GNUNET_free(plugin); | 991 | GNUNET_free (plugin); |
1024 | 992 | ||
1025 | switch (socket_address.ss_family) | 993 | switch (socket_address.ss_family) |
1026 | { | 994 | { |
1027 | case AF_INET: | 995 | case AF_INET: { |
1028 | { | 996 | struct IPv4UdpAddress *u4; |
1029 | struct IPv4UdpAddress *u4; | 997 | const struct sockaddr_in *in4 = |
1030 | const struct sockaddr_in *in4 = (const struct sockaddr_in *) &socket_address; | 998 | (const struct sockaddr_in *) &socket_address; |
1031 | 999 | ||
1032 | u4 = GNUNET_new (struct IPv4UdpAddress); | 1000 | u4 = GNUNET_new (struct IPv4UdpAddress); |
1033 | u4->options = htonl (options); | 1001 | u4->options = htonl (options); |
1034 | u4->ipv4_addr = in4->sin_addr.s_addr; | 1002 | u4->ipv4_addr = in4->sin_addr.s_addr; |
1035 | u4->u4_port = in4->sin_port; | 1003 | u4->u4_port = in4->sin_port; |
1036 | *buf = u4; | 1004 | *buf = u4; |
1037 | *added = sizeof (struct IPv4UdpAddress); | 1005 | *added = sizeof (struct IPv4UdpAddress); |
1038 | return GNUNET_OK; | 1006 | return GNUNET_OK; |
1039 | } | 1007 | } |
1040 | case AF_INET6: | 1008 | case AF_INET6: { |
1041 | { | 1009 | struct IPv6UdpAddress *u6; |
1042 | struct IPv6UdpAddress *u6; | 1010 | const struct sockaddr_in6 *in6 = |
1043 | const struct sockaddr_in6 *in6 = (const struct sockaddr_in6 *) &socket_address; | 1011 | (const struct sockaddr_in6 *) &socket_address; |
1044 | 1012 | ||
1045 | u6 = GNUNET_new (struct IPv6UdpAddress); | 1013 | u6 = GNUNET_new (struct IPv6UdpAddress); |
1046 | u6->options = htonl (options); | 1014 | u6->options = htonl (options); |
1047 | u6->ipv6_addr = in6->sin6_addr; | 1015 | u6->ipv6_addr = in6->sin6_addr; |
1048 | u6->u6_port = in6->sin6_port; | 1016 | u6->u6_port = in6->sin6_port; |
1049 | *buf = u6; | 1017 | *buf = u6; |
1050 | *added = sizeof (struct IPv6UdpAddress); | 1018 | *added = sizeof (struct IPv6UdpAddress); |
1051 | return GNUNET_OK; | 1019 | return GNUNET_OK; |
1052 | } | 1020 | } |
1053 | default: | 1021 | default: |
1054 | GNUNET_break (0); | 1022 | GNUNET_break (0); |
1055 | return GNUNET_SYSERR; | 1023 | return GNUNET_SYSERR; |
@@ -1064,8 +1032,7 @@ udp_string_to_address (void *cls, | |||
1064 | * @param hostname result from DNS resolver | 1032 | * @param hostname result from DNS resolver |
1065 | */ | 1033 | */ |
1066 | static void | 1034 | static void |
1067 | append_port (void *cls, | 1035 | append_port (void *cls, const char *hostname) |
1068 | const char *hostname) | ||
1069 | { | 1036 | { |
1070 | struct PrettyPrinterContext *ppc = cls; | 1037 | struct PrettyPrinterContext *ppc = cls; |
1071 | struct Plugin *plugin = ppc->plugin; | 1038 | struct Plugin *plugin = ppc->plugin; |
@@ -1078,9 +1045,7 @@ append_port (void *cls, | |||
1078 | plugin->ppc_dll_tail, | 1045 | plugin->ppc_dll_tail, |
1079 | ppc); | 1046 | ppc); |
1080 | ppc->resolver_handle = NULL; | 1047 | ppc->resolver_handle = NULL; |
1081 | ppc->asc (ppc->asc_cls, | 1048 | ppc->asc (ppc->asc_cls, NULL, GNUNET_OK); |
1082 | NULL, | ||
1083 | GNUNET_OK); | ||
1084 | GNUNET_free (ppc); | 1049 | GNUNET_free (ppc); |
1085 | return; | 1050 | return; |
1086 | } | 1051 | } |
@@ -1098,9 +1063,7 @@ append_port (void *cls, | |||
1098 | ppc->options, | 1063 | ppc->options, |
1099 | hostname, | 1064 | hostname, |
1100 | ppc->port); | 1065 | ppc->port); |
1101 | ppc->asc (ppc->asc_cls, | 1066 | ppc->asc (ppc->asc_cls, ret, GNUNET_OK); |
1102 | ret, | ||
1103 | GNUNET_OK); | ||
1104 | GNUNET_free (ret); | 1067 | GNUNET_free (ret); |
1105 | } | 1068 | } |
1106 | 1069 | ||
@@ -1140,12 +1103,10 @@ udp_plugin_address_pretty_printer (void *cls, | |||
1140 | uint16_t port; | 1103 | uint16_t port; |
1141 | uint32_t options; | 1104 | uint32_t options; |
1142 | 1105 | ||
1143 | if (addrlen == sizeof(struct IPv6UdpAddress)) | 1106 | if (addrlen == sizeof (struct IPv6UdpAddress)) |
1144 | { | 1107 | { |
1145 | u6 = addr; | 1108 | u6 = addr; |
1146 | memset (&a6, | 1109 | memset (&a6, 0, sizeof (a6)); |
1147 | 0, | ||
1148 | sizeof (a6)); | ||
1149 | a6.sin6_family = AF_INET6; | 1110 | a6.sin6_family = AF_INET6; |
1150 | #if HAVE_SOCKADDR_IN_SIN_LEN | 1111 | #if HAVE_SOCKADDR_IN_SIN_LEN |
1151 | a6.sin6_len = sizeof (a6); | 1112 | a6.sin6_len = sizeof (a6); |
@@ -1160,9 +1121,7 @@ udp_plugin_address_pretty_printer (void *cls, | |||
1160 | else if (addrlen == sizeof (struct IPv4UdpAddress)) | 1121 | else if (addrlen == sizeof (struct IPv4UdpAddress)) |
1161 | { | 1122 | { |
1162 | u4 = addr; | 1123 | u4 = addr; |
1163 | memset (&a4, | 1124 | memset (&a4, 0, sizeof (a4)); |
1164 | 0, | ||
1165 | sizeof(a4)); | ||
1166 | a4.sin_family = AF_INET; | 1125 | a4.sin_family = AF_INET; |
1167 | #if HAVE_SOCKADDR_IN_SIN_LEN | 1126 | #if HAVE_SOCKADDR_IN_SIN_LEN |
1168 | a4.sin_len = sizeof (a4); | 1127 | a4.sin_len = sizeof (a4); |
@@ -1172,18 +1131,14 @@ udp_plugin_address_pretty_printer (void *cls, | |||
1172 | port = ntohs (u4->u4_port); | 1131 | port = ntohs (u4->u4_port); |
1173 | options = ntohl (u4->options); | 1132 | options = ntohl (u4->options); |
1174 | sb = (const struct sockaddr *) &a4; | 1133 | sb = (const struct sockaddr *) &a4; |
1175 | sbs = sizeof(a4); | 1134 | sbs = sizeof (a4); |
1176 | } | 1135 | } |
1177 | else | 1136 | else |
1178 | { | 1137 | { |
1179 | /* invalid address */ | 1138 | /* invalid address */ |
1180 | GNUNET_break_op (0); | 1139 | GNUNET_break_op (0); |
1181 | asc (asc_cls, | 1140 | asc (asc_cls, NULL, GNUNET_SYSERR); |
1182 | NULL, | 1141 | asc (asc_cls, NULL, GNUNET_OK); |
1183 | GNUNET_SYSERR); | ||
1184 | asc (asc_cls, | ||
1185 | NULL, | ||
1186 | GNUNET_OK); | ||
1187 | return; | 1142 | return; |
1188 | } | 1143 | } |
1189 | ppc = GNUNET_new (struct PrettyPrinterContext); | 1144 | ppc = GNUNET_new (struct PrettyPrinterContext); |
@@ -1196,16 +1151,13 @@ udp_plugin_address_pretty_printer (void *cls, | |||
1196 | ppc->ipv6 = GNUNET_YES; | 1151 | ppc->ipv6 = GNUNET_YES; |
1197 | else | 1152 | else |
1198 | ppc->ipv6 = GNUNET_NO; | 1153 | ppc->ipv6 = GNUNET_NO; |
1199 | GNUNET_CONTAINER_DLL_insert (plugin->ppc_dll_head, | 1154 | GNUNET_CONTAINER_DLL_insert (plugin->ppc_dll_head, plugin->ppc_dll_tail, ppc); |
1200 | plugin->ppc_dll_tail, | 1155 | ppc->resolver_handle = GNUNET_RESOLVER_hostname_get (sb, |
1201 | ppc); | 1156 | sbs, |
1202 | ppc->resolver_handle | 1157 | ! numeric, |
1203 | = GNUNET_RESOLVER_hostname_get (sb, | 1158 | timeout, |
1204 | sbs, | 1159 | &append_port, |
1205 | ! numeric, | 1160 | ppc); |
1206 | timeout, | ||
1207 | &append_port, | ||
1208 | ppc); | ||
1209 | } | 1161 | } |
1210 | 1162 | ||
1211 | 1163 | ||
@@ -1219,11 +1171,9 @@ udp_plugin_address_pretty_printer (void *cls, | |||
1219 | * @return #GNUNET_OK if port is either our open or advertised port | 1171 | * @return #GNUNET_OK if port is either our open or advertised port |
1220 | */ | 1172 | */ |
1221 | static int | 1173 | static int |
1222 | check_port (const struct Plugin *plugin, | 1174 | check_port (const struct Plugin *plugin, uint16_t in_port) |
1223 | uint16_t in_port) | ||
1224 | { | 1175 | { |
1225 | if ( (plugin->port == in_port) || | 1176 | if ((plugin->port == in_port) || (plugin->aport == in_port)) |
1226 | (plugin->aport == in_port) ) | ||
1227 | return GNUNET_OK; | 1177 | return GNUNET_OK; |
1228 | return GNUNET_SYSERR; | 1178 | return GNUNET_SYSERR; |
1229 | } | 1179 | } |
@@ -1245,21 +1195,18 @@ check_port (const struct Plugin *plugin, | |||
1245 | * and transport, #GNUNET_SYSERR if not | 1195 | * and transport, #GNUNET_SYSERR if not |
1246 | */ | 1196 | */ |
1247 | static int | 1197 | static int |
1248 | udp_plugin_check_address (void *cls, | 1198 | udp_plugin_check_address (void *cls, const void *addr, size_t addrlen) |
1249 | const void *addr, | ||
1250 | size_t addrlen) | ||
1251 | { | 1199 | { |
1252 | struct Plugin *plugin = cls; | 1200 | struct Plugin *plugin = cls; |
1253 | const struct IPv4UdpAddress *v4; | 1201 | const struct IPv4UdpAddress *v4; |
1254 | const struct IPv6UdpAddress *v6; | 1202 | const struct IPv6UdpAddress *v6; |
1255 | 1203 | ||
1256 | if (sizeof(struct IPv4UdpAddress) == addrlen) | 1204 | if (sizeof (struct IPv4UdpAddress) == addrlen) |
1257 | { | 1205 | { |
1258 | struct sockaddr_in s4; | 1206 | struct sockaddr_in s4; |
1259 | 1207 | ||
1260 | v4 = (const struct IPv4UdpAddress *) addr; | 1208 | v4 = (const struct IPv4UdpAddress *) addr; |
1261 | if (GNUNET_OK != check_port (plugin, | 1209 | if (GNUNET_OK != check_port (plugin, ntohs (v4->u4_port))) |
1262 | ntohs (v4->u4_port))) | ||
1263 | return GNUNET_SYSERR; | 1210 | return GNUNET_SYSERR; |
1264 | memset (&s4, 0, sizeof (s4)); | 1211 | memset (&s4, 0, sizeof (s4)); |
1265 | s4.sin_family = AF_INET; | 1212 | s4.sin_family = AF_INET; |
@@ -1270,12 +1217,10 @@ udp_plugin_check_address (void *cls, | |||
1270 | s4.sin_addr.s_addr = v4->ipv4_addr; | 1217 | s4.sin_addr.s_addr = v4->ipv4_addr; |
1271 | 1218 | ||
1272 | if (GNUNET_OK != | 1219 | if (GNUNET_OK != |
1273 | GNUNET_NAT_test_address (plugin->nat, | 1220 | GNUNET_NAT_test_address (plugin->nat, &s4, sizeof (struct sockaddr_in))) |
1274 | &s4, | ||
1275 | sizeof (struct sockaddr_in))) | ||
1276 | return GNUNET_SYSERR; | 1221 | return GNUNET_SYSERR; |
1277 | } | 1222 | } |
1278 | else if (sizeof(struct IPv6UdpAddress) == addrlen) | 1223 | else if (sizeof (struct IPv6UdpAddress) == addrlen) |
1279 | { | 1224 | { |
1280 | struct sockaddr_in6 s6; | 1225 | struct sockaddr_in6 s6; |
1281 | 1226 | ||
@@ -1290,10 +1235,9 @@ udp_plugin_check_address (void *cls, | |||
1290 | s6.sin6_port = v6->u6_port; | 1235 | s6.sin6_port = v6->u6_port; |
1291 | s6.sin6_addr = v6->ipv6_addr; | 1236 | s6.sin6_addr = v6->ipv6_addr; |
1292 | 1237 | ||
1293 | if (GNUNET_OK != | 1238 | if (GNUNET_OK != GNUNET_NAT_test_address (plugin->nat, |
1294 | GNUNET_NAT_test_address (plugin->nat, | 1239 | &s6, |
1295 | &s6, | 1240 | sizeof (struct sockaddr_in6))) |
1296 | sizeof(struct sockaddr_in6))) | ||
1297 | return GNUNET_SYSERR; | 1241 | return GNUNET_SYSERR; |
1298 | } | 1242 | } |
1299 | else | 1243 | else |
@@ -1319,9 +1263,9 @@ udp_plugin_check_address (void *cls, | |||
1319 | */ | 1263 | */ |
1320 | static void | 1264 | static void |
1321 | udp_nat_port_map_callback (void *cls, | 1265 | udp_nat_port_map_callback (void *cls, |
1322 | void **app_ctx, | 1266 | void **app_ctx, |
1323 | int add_remove, | 1267 | int add_remove, |
1324 | enum GNUNET_NAT_AddressClass ac, | 1268 | enum GNUNET_NAT_AddressClass ac, |
1325 | const struct sockaddr *addr, | 1269 | const struct sockaddr *addr, |
1326 | socklen_t addrlen) | 1270 | socklen_t addrlen) |
1327 | { | 1271 | { |
@@ -1334,50 +1278,42 @@ udp_nat_port_map_callback (void *cls, | |||
1334 | 1278 | ||
1335 | (void) app_ctx; | 1279 | (void) app_ctx; |
1336 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1280 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1337 | (GNUNET_YES == add_remove) | 1281 | (GNUNET_YES == add_remove) ? "NAT notification to add address `%s'\n" |
1338 | ? "NAT notification to add address `%s'\n" | 1282 | : "NAT notification to remove address `%s'\n", |
1339 | : "NAT notification to remove address `%s'\n", | 1283 | GNUNET_a2s (addr, addrlen)); |
1340 | GNUNET_a2s (addr, | ||
1341 | addrlen)); | ||
1342 | /* convert 'address' to our internal format */ | 1284 | /* convert 'address' to our internal format */ |
1343 | switch (addr->sa_family) | 1285 | switch (addr->sa_family) |
1344 | { | 1286 | { |
1345 | case AF_INET: | 1287 | case AF_INET: { |
1346 | { | 1288 | const struct sockaddr_in *i4; |
1347 | const struct sockaddr_in *i4; | 1289 | |
1348 | 1290 | GNUNET_assert (sizeof (struct sockaddr_in) == addrlen); | |
1349 | GNUNET_assert (sizeof(struct sockaddr_in) == addrlen); | 1291 | i4 = (const struct sockaddr_in *) addr; |
1350 | i4 = (const struct sockaddr_in *) addr; | 1292 | if (0 == ntohs (i4->sin_port)) |
1351 | if (0 == ntohs (i4->sin_port)) | 1293 | return; /* Port = 0 means unmapped, ignore these for UDP. */ |
1352 | return; /* Port = 0 means unmapped, ignore these for UDP. */ | 1294 | memset (&u4, 0, sizeof (u4)); |
1353 | memset (&u4, | 1295 | u4.options = htonl (plugin->myoptions); |
1354 | 0, | 1296 | u4.ipv4_addr = i4->sin_addr.s_addr; |
1355 | sizeof(u4)); | 1297 | u4.u4_port = i4->sin_port; |
1356 | u4.options = htonl (plugin->myoptions); | 1298 | arg = &u4; |
1357 | u4.ipv4_addr = i4->sin_addr.s_addr; | 1299 | args = sizeof (struct IPv4UdpAddress); |
1358 | u4.u4_port = i4->sin_port; | 1300 | break; |
1359 | arg = &u4; | 1301 | } |
1360 | args = sizeof (struct IPv4UdpAddress); | 1302 | case AF_INET6: { |
1361 | break; | 1303 | const struct sockaddr_in6 *i6; |
1362 | } | 1304 | |
1363 | case AF_INET6: | 1305 | GNUNET_assert (sizeof (struct sockaddr_in6) == addrlen); |
1364 | { | 1306 | i6 = (const struct sockaddr_in6 *) addr; |
1365 | const struct sockaddr_in6 *i6; | 1307 | if (0 == ntohs (i6->sin6_port)) |
1366 | 1308 | return; /* Port = 0 means unmapped, ignore these for UDP. */ | |
1367 | GNUNET_assert (sizeof(struct sockaddr_in6) == addrlen); | 1309 | memset (&u6, 0, sizeof (u6)); |
1368 | i6 = (const struct sockaddr_in6 *) addr; | 1310 | u6.options = htonl (plugin->myoptions); |
1369 | if (0 == ntohs (i6->sin6_port)) | 1311 | u6.ipv6_addr = i6->sin6_addr; |
1370 | return; /* Port = 0 means unmapped, ignore these for UDP. */ | 1312 | u6.u6_port = i6->sin6_port; |
1371 | memset (&u6, | 1313 | arg = &u6; |
1372 | 0, | 1314 | args = sizeof (struct IPv6UdpAddress); |
1373 | sizeof(u6)); | 1315 | break; |
1374 | u6.options = htonl (plugin->myoptions); | 1316 | } |
1375 | u6.ipv6_addr = i6->sin6_addr; | ||
1376 | u6.u6_port = i6->sin6_port; | ||
1377 | arg = &u6; | ||
1378 | args = sizeof (struct IPv6UdpAddress); | ||
1379 | break; | ||
1380 | } | ||
1381 | default: | 1317 | default: |
1382 | GNUNET_break (0); | 1318 | GNUNET_break (0); |
1383 | return; | 1319 | return; |
@@ -1389,9 +1325,7 @@ udp_nat_port_map_callback (void *cls, | |||
1389 | arg, | 1325 | arg, |
1390 | args, | 1326 | args, |
1391 | GNUNET_HELLO_ADDRESS_INFO_NONE); | 1327 | GNUNET_HELLO_ADDRESS_INFO_NONE); |
1392 | plugin->env->notify_address (plugin->env->cls, | 1328 | plugin->env->notify_address (plugin->env->cls, add_remove, address); |
1393 | add_remove, | ||
1394 | address); | ||
1395 | GNUNET_HELLO_address_free (address); | 1329 | GNUNET_HELLO_address_free (address); |
1396 | } | 1330 | } |
1397 | 1331 | ||
@@ -1425,15 +1359,12 @@ struct GNUNET_ATS_SessionCompareContext | |||
1425 | * @return #GNUNET_NO if we found the session, #GNUNET_OK if not | 1359 | * @return #GNUNET_NO if we found the session, #GNUNET_OK if not |
1426 | */ | 1360 | */ |
1427 | static int | 1361 | static int |
1428 | session_cmp_it (void *cls, | 1362 | session_cmp_it (void *cls, const struct GNUNET_PeerIdentity *key, void *value) |
1429 | const struct GNUNET_PeerIdentity *key, | ||
1430 | void *value) | ||
1431 | { | 1363 | { |
1432 | struct GNUNET_ATS_SessionCompareContext *cctx = cls; | 1364 | struct GNUNET_ATS_SessionCompareContext *cctx = cls; |
1433 | struct GNUNET_ATS_Session *s = value; | 1365 | struct GNUNET_ATS_Session *s = value; |
1434 | 1366 | ||
1435 | if (0 == GNUNET_HELLO_address_cmp (s->address, | 1367 | if (0 == GNUNET_HELLO_address_cmp (s->address, cctx->address)) |
1436 | cctx->address)) | ||
1437 | { | 1368 | { |
1438 | GNUNET_assert (GNUNET_NO == s->in_destroy); | 1369 | GNUNET_assert (GNUNET_NO == s->in_destroy); |
1439 | cctx->res = s; | 1370 | cctx->res = s; |
@@ -1466,7 +1397,7 @@ udp_plugin_lookup_session (void *cls, | |||
1466 | GNUNET_break (0); | 1397 | GNUNET_break (0); |
1467 | return NULL; | 1398 | return NULL; |
1468 | } | 1399 | } |
1469 | if (sizeof(struct IPv4UdpAddress) == address->address_length) | 1400 | if (sizeof (struct IPv4UdpAddress) == address->address_length) |
1470 | { | 1401 | { |
1471 | if (NULL == plugin->sockv4) | 1402 | if (NULL == plugin->sockv4) |
1472 | return NULL; | 1403 | return NULL; |
@@ -1477,7 +1408,7 @@ udp_plugin_lookup_session (void *cls, | |||
1477 | return NULL; | 1408 | return NULL; |
1478 | } | 1409 | } |
1479 | } | 1410 | } |
1480 | else if (sizeof(struct IPv6UdpAddress) == address->address_length) | 1411 | else if (sizeof (struct IPv6UdpAddress) == address->address_length) |
1481 | { | 1412 | { |
1482 | if (NULL == plugin->sockv6) | 1413 | if (NULL == plugin->sockv6) |
1483 | return NULL; | 1414 | return NULL; |
@@ -1509,9 +1440,7 @@ udp_plugin_lookup_session (void *cls, | |||
1509 | &cctx); | 1440 | &cctx); |
1510 | if (NULL == cctx.res) | 1441 | if (NULL == cctx.res) |
1511 | return NULL; | 1442 | return NULL; |
1512 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1443 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Found existing session %p\n", cctx.res); |
1513 | "Found existing session %p\n", | ||
1514 | cctx.res); | ||
1515 | return cctx.res; | 1444 | return cctx.res; |
1516 | } | 1445 | } |
1517 | 1446 | ||
@@ -1534,7 +1463,6 @@ reschedule_session_timeout (struct GNUNET_ATS_Session *s) | |||
1534 | } | 1463 | } |
1535 | 1464 | ||
1536 | 1465 | ||
1537 | |||
1538 | /** | 1466 | /** |
1539 | * Function that will be called whenever the transport service wants to | 1467 | * Function that will be called whenever the transport service wants to |
1540 | * notify the plugin that a session is still active and in use and | 1468 | * notify the plugin that a session is still active and in use and |
@@ -1575,8 +1503,7 @@ udp_plugin_update_session_timeout (void *cls, | |||
1575 | * @param udpw message wrapper to dequeue | 1503 | * @param udpw message wrapper to dequeue |
1576 | */ | 1504 | */ |
1577 | static void | 1505 | static void |
1578 | dequeue (struct Plugin *plugin, | 1506 | dequeue (struct Plugin *plugin, struct UDP_MessageWrapper *udpw) |
1579 | struct UDP_MessageWrapper *udpw) | ||
1580 | { | 1507 | { |
1581 | struct GNUNET_ATS_Session *session = udpw->session; | 1508 | struct GNUNET_ATS_Session *session = udpw->session; |
1582 | 1509 | ||
@@ -1588,7 +1515,7 @@ dequeue (struct Plugin *plugin, | |||
1588 | { | 1515 | { |
1589 | GNUNET_STATISTICS_update (plugin->env->stats, | 1516 | GNUNET_STATISTICS_update (plugin->env->stats, |
1590 | "# UDP, total bytes in send buffers", | 1517 | "# UDP, total bytes in send buffers", |
1591 | - (long long) udpw->msg_size, | 1518 | -(long long) udpw->msg_size, |
1592 | GNUNET_NO); | 1519 | GNUNET_NO); |
1593 | plugin->bytes_in_buffer -= udpw->msg_size; | 1520 | plugin->bytes_in_buffer -= udpw->msg_size; |
1594 | } | 1521 | } |
@@ -1596,13 +1523,14 @@ dequeue (struct Plugin *plugin, | |||
1596 | "# UDP, total messages in send buffers", | 1523 | "# UDP, total messages in send buffers", |
1597 | -1, | 1524 | -1, |
1598 | GNUNET_NO); | 1525 | GNUNET_NO); |
1599 | if (sizeof(struct IPv4UdpAddress) == udpw->session->address->address_length) | 1526 | if (sizeof (struct IPv4UdpAddress) == udpw->session->address->address_length) |
1600 | { | 1527 | { |
1601 | GNUNET_CONTAINER_DLL_remove (plugin->ipv4_queue_head, | 1528 | GNUNET_CONTAINER_DLL_remove (plugin->ipv4_queue_head, |
1602 | plugin->ipv4_queue_tail, | 1529 | plugin->ipv4_queue_tail, |
1603 | udpw); | 1530 | udpw); |
1604 | } | 1531 | } |
1605 | else if (sizeof(struct IPv6UdpAddress) == udpw->session->address->address_length) | 1532 | else if (sizeof (struct IPv6UdpAddress) == |
1533 | udpw->session->address->address_length) | ||
1606 | { | 1534 | { |
1607 | GNUNET_CONTAINER_DLL_remove (plugin->ipv6_queue_head, | 1535 | GNUNET_CONTAINER_DLL_remove (plugin->ipv6_queue_head, |
1608 | plugin->ipv6_queue_tail, | 1536 | plugin->ipv6_queue_tail, |
@@ -1627,8 +1555,7 @@ dequeue (struct Plugin *plugin, | |||
1627 | * @param udpw message wrapper to queue | 1555 | * @param udpw message wrapper to queue |
1628 | */ | 1556 | */ |
1629 | static void | 1557 | static void |
1630 | enqueue (struct Plugin *plugin, | 1558 | enqueue (struct Plugin *plugin, struct UDP_MessageWrapper *udpw) |
1631 | struct UDP_MessageWrapper *udpw) | ||
1632 | { | 1559 | { |
1633 | struct GNUNET_ATS_Session *session = udpw->session; | 1560 | struct GNUNET_ATS_Session *session = udpw->session; |
1634 | 1561 | ||
@@ -1656,11 +1583,12 @@ enqueue (struct Plugin *plugin, | |||
1656 | GNUNET_NO); | 1583 | GNUNET_NO); |
1657 | if (sizeof (struct IPv4UdpAddress) == udpw->session->address->address_length) | 1584 | if (sizeof (struct IPv4UdpAddress) == udpw->session->address->address_length) |
1658 | { | 1585 | { |
1659 | GNUNET_CONTAINER_DLL_insert(plugin->ipv4_queue_head, | 1586 | GNUNET_CONTAINER_DLL_insert (plugin->ipv4_queue_head, |
1660 | plugin->ipv4_queue_tail, | 1587 | plugin->ipv4_queue_tail, |
1661 | udpw); | 1588 | udpw); |
1662 | } | 1589 | } |
1663 | else if (sizeof (struct IPv6UdpAddress) == udpw->session->address->address_length) | 1590 | else if (sizeof (struct IPv6UdpAddress) == |
1591 | udpw->session->address->address_length) | ||
1664 | { | 1592 | { |
1665 | GNUNET_CONTAINER_DLL_insert (plugin->ipv6_queue_head, | 1593 | GNUNET_CONTAINER_DLL_insert (plugin->ipv6_queue_head, |
1666 | plugin->ipv6_queue_tail, | 1594 | plugin->ipv6_queue_tail, |
@@ -1693,8 +1621,7 @@ enqueue (struct Plugin *plugin, | |||
1693 | * #GNUNET_SYSERR if the transmission failed | 1621 | * #GNUNET_SYSERR if the transmission failed |
1694 | */ | 1622 | */ |
1695 | static void | 1623 | static void |
1696 | fragmented_message_done (struct UDP_FragmentationContext *frag_ctx, | 1624 | fragmented_message_done (struct UDP_FragmentationContext *frag_ctx, int result) |
1697 | int result) | ||
1698 | { | 1625 | { |
1699 | struct Plugin *plugin = frag_ctx->plugin; | 1626 | struct Plugin *plugin = frag_ctx->plugin; |
1700 | struct GNUNET_ATS_Session *s = frag_ctx->session; | 1627 | struct GNUNET_ATS_Session *s = frag_ctx->session; |
@@ -1717,16 +1644,14 @@ fragmented_message_done (struct UDP_FragmentationContext *frag_ctx, | |||
1717 | { | 1644 | { |
1718 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1645 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1719 | "Fragmented message acknowledged after %s (expected at %s)\n", | 1646 | "Fragmented message acknowledged after %s (expected at %s)\n", |
1720 | GNUNET_STRINGS_relative_time_to_string (delay, | 1647 | GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES), |
1721 | GNUNET_YES), | ||
1722 | GNUNET_STRINGS_absolute_time_to_string (frag_ctx->next_frag_time)); | 1648 | GNUNET_STRINGS_absolute_time_to_string (frag_ctx->next_frag_time)); |
1723 | } | 1649 | } |
1724 | else | 1650 | else |
1725 | { | 1651 | { |
1726 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1652 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1727 | "Fragmented message acknowledged after %s (expected at %s)\n", | 1653 | "Fragmented message acknowledged after %s (expected at %s)\n", |
1728 | GNUNET_STRINGS_relative_time_to_string (delay, | 1654 | GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES), |
1729 | GNUNET_YES), | ||
1730 | GNUNET_STRINGS_absolute_time_to_string (frag_ctx->next_frag_time)); | 1655 | GNUNET_STRINGS_absolute_time_to_string (frag_ctx->next_frag_time)); |
1731 | } | 1656 | } |
1732 | 1657 | ||
@@ -1751,10 +1676,11 @@ fragmented_message_done (struct UDP_FragmentationContext *frag_ctx, | |||
1751 | "# UDP, fragmented msgs, bytes payload, sent, success", | 1676 | "# UDP, fragmented msgs, bytes payload, sent, success", |
1752 | s->frag_ctx->payload_size, | 1677 | s->frag_ctx->payload_size, |
1753 | GNUNET_NO); | 1678 | GNUNET_NO); |
1754 | GNUNET_STATISTICS_update (plugin->env->stats, | 1679 | GNUNET_STATISTICS_update ( |
1755 | "# UDP, fragmented msgs, bytes overhead, sent, success", | 1680 | plugin->env->stats, |
1756 | overhead, | 1681 | "# UDP, fragmented msgs, bytes overhead, sent, success", |
1757 | GNUNET_NO); | 1682 | overhead, |
1683 | GNUNET_NO); | ||
1758 | GNUNET_STATISTICS_update (plugin->env->stats, | 1684 | GNUNET_STATISTICS_update (plugin->env->stats, |
1759 | "# UDP, total, bytes overhead, sent", | 1685 | "# UDP, total, bytes overhead, sent", |
1760 | overhead, | 1686 | overhead, |
@@ -1786,41 +1712,35 @@ fragmented_message_done (struct UDP_FragmentationContext *frag_ctx, | |||
1786 | 1712 | ||
1787 | /* Remove remaining fragments from queue, no need to transmit those | 1713 | /* Remove remaining fragments from queue, no need to transmit those |
1788 | any longer. */ | 1714 | any longer. */ |
1789 | if (s->address->address_length == sizeof(struct IPv6UdpAddress)) | 1715 | if (s->address->address_length == sizeof (struct IPv6UdpAddress)) |
1790 | { | 1716 | { |
1791 | udpw = plugin->ipv6_queue_head; | 1717 | udpw = plugin->ipv6_queue_head; |
1792 | while (NULL != udpw) | 1718 | while (NULL != udpw) |
1793 | { | 1719 | { |
1794 | tmp = udpw->next; | 1720 | tmp = udpw->next; |
1795 | if ( (udpw->frag_ctx != NULL) && | 1721 | if ((udpw->frag_ctx != NULL) && (udpw->frag_ctx == frag_ctx)) |
1796 | (udpw->frag_ctx == frag_ctx) ) | ||
1797 | { | 1722 | { |
1798 | dequeue (plugin, | 1723 | dequeue (plugin, udpw); |
1799 | udpw); | 1724 | GNUNET_free (udpw); |
1800 | GNUNET_free (udpw); | ||
1801 | } | 1725 | } |
1802 | udpw = tmp; | 1726 | udpw = tmp; |
1803 | } | 1727 | } |
1804 | } | 1728 | } |
1805 | if (s->address->address_length == sizeof(struct IPv4UdpAddress)) | 1729 | if (s->address->address_length == sizeof (struct IPv4UdpAddress)) |
1806 | { | 1730 | { |
1807 | udpw = plugin->ipv4_queue_head; | 1731 | udpw = plugin->ipv4_queue_head; |
1808 | while (NULL != udpw) | 1732 | while (NULL != udpw) |
1809 | { | 1733 | { |
1810 | tmp = udpw->next; | 1734 | tmp = udpw->next; |
1811 | if ( (NULL != udpw->frag_ctx) && | 1735 | if ((NULL != udpw->frag_ctx) && (udpw->frag_ctx == frag_ctx)) |
1812 | (udpw->frag_ctx == frag_ctx) ) | ||
1813 | { | 1736 | { |
1814 | dequeue (plugin, | 1737 | dequeue (plugin, udpw); |
1815 | udpw); | ||
1816 | GNUNET_free (udpw); | 1738 | GNUNET_free (udpw); |
1817 | } | 1739 | } |
1818 | udpw = tmp; | 1740 | udpw = tmp; |
1819 | } | 1741 | } |
1820 | } | 1742 | } |
1821 | notify_session_monitor (s->plugin, | 1743 | notify_session_monitor (s->plugin, s, GNUNET_TRANSPORT_SS_UPDATE); |
1822 | s, | ||
1823 | GNUNET_TRANSPORT_SS_UPDATE); | ||
1824 | GNUNET_FRAGMENT_context_destroy (frag_ctx->frag, | 1744 | GNUNET_FRAGMENT_context_destroy (frag_ctx->frag, |
1825 | &s->last_expected_msg_delay, | 1745 | &s->last_expected_msg_delay, |
1826 | &s->last_expected_ack_delay); | 1746 | &s->last_expected_ack_delay); |
@@ -1838,9 +1758,7 @@ fragmented_message_done (struct UDP_FragmentationContext *frag_ctx, | |||
1838 | * @param result #GNUNET_OK on success, #GNUNET_SYSERR on failure | 1758 | * @param result #GNUNET_OK on success, #GNUNET_SYSERR on failure |
1839 | */ | 1759 | */ |
1840 | static void | 1760 | static void |
1841 | qc_fragment_sent (void *cls, | 1761 | qc_fragment_sent (void *cls, struct UDP_MessageWrapper *udpw, int result) |
1842 | struct UDP_MessageWrapper *udpw, | ||
1843 | int result) | ||
1844 | { | 1762 | { |
1845 | struct Plugin *plugin = cls; | 1763 | struct Plugin *plugin = cls; |
1846 | 1764 | ||
@@ -1856,10 +1774,11 @@ qc_fragment_sent (void *cls, | |||
1856 | "# UDP, fragmented msgs, fragments, sent, success", | 1774 | "# UDP, fragmented msgs, fragments, sent, success", |
1857 | 1, | 1775 | 1, |
1858 | GNUNET_NO); | 1776 | GNUNET_NO); |
1859 | GNUNET_STATISTICS_update (plugin->env->stats, | 1777 | GNUNET_STATISTICS_update ( |
1860 | "# UDP, fragmented msgs, fragments bytes, sent, success", | 1778 | plugin->env->stats, |
1861 | udpw->msg_size, | 1779 | "# UDP, fragmented msgs, fragments bytes, sent, success", |
1862 | GNUNET_NO); | 1780 | udpw->msg_size, |
1781 | GNUNET_NO); | ||
1863 | } | 1782 | } |
1864 | else | 1783 | else |
1865 | { | 1784 | { |
@@ -1867,16 +1786,16 @@ qc_fragment_sent (void *cls, | |||
1867 | "Failed to transmit fragment of message with %u bytes to %s\n", | 1786 | "Failed to transmit fragment of message with %u bytes to %s\n", |
1868 | (unsigned int) udpw->payload_size, | 1787 | (unsigned int) udpw->payload_size, |
1869 | GNUNET_i2s (&udpw->session->target)); | 1788 | GNUNET_i2s (&udpw->session->target)); |
1870 | fragmented_message_done (udpw->frag_ctx, | 1789 | fragmented_message_done (udpw->frag_ctx, GNUNET_SYSERR); |
1871 | GNUNET_SYSERR); | ||
1872 | GNUNET_STATISTICS_update (plugin->env->stats, | 1790 | GNUNET_STATISTICS_update (plugin->env->stats, |
1873 | "# UDP, fragmented msgs, fragments, sent, failure", | 1791 | "# UDP, fragmented msgs, fragments, sent, failure", |
1874 | 1, | 1792 | 1, |
1875 | GNUNET_NO); | 1793 | GNUNET_NO); |
1876 | GNUNET_STATISTICS_update (plugin->env->stats, | 1794 | GNUNET_STATISTICS_update ( |
1877 | "# UDP, fragmented msgs, fragments bytes, sent, failure", | 1795 | plugin->env->stats, |
1878 | udpw->msg_size, | 1796 | "# UDP, fragmented msgs, fragments bytes, sent, failure", |
1879 | GNUNET_NO); | 1797 | udpw->msg_size, |
1798 | GNUNET_NO); | ||
1880 | } | 1799 | } |
1881 | } | 1800 | } |
1882 | 1801 | ||
@@ -1891,8 +1810,7 @@ qc_fragment_sent (void *cls, | |||
1891 | * @param msg the message that was created | 1810 | * @param msg the message that was created |
1892 | */ | 1811 | */ |
1893 | static void | 1812 | static void |
1894 | enqueue_fragment (void *cls, | 1813 | enqueue_fragment (void *cls, const struct GNUNET_MessageHeader *msg) |
1895 | const struct GNUNET_MessageHeader *msg) | ||
1896 | { | 1814 | { |
1897 | struct UDP_FragmentationContext *frag_ctx = cls; | 1815 | struct UDP_FragmentationContext *frag_ctx = cls; |
1898 | struct Plugin *plugin = frag_ctx->plugin; | 1816 | struct Plugin *plugin = frag_ctx->plugin; |
@@ -1900,9 +1818,7 @@ enqueue_fragment (void *cls, | |||
1900 | struct GNUNET_ATS_Session *session = frag_ctx->session; | 1818 | struct GNUNET_ATS_Session *session = frag_ctx->session; |
1901 | size_t msg_len = ntohs (msg->size); | 1819 | size_t msg_len = ntohs (msg->size); |
1902 | 1820 | ||
1903 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1821 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Enqueuing fragment with %u bytes\n", msg_len); |
1904 | "Enqueuing fragment with %u bytes\n", | ||
1905 | msg_len); | ||
1906 | udpw = GNUNET_malloc (sizeof (struct UDP_MessageWrapper) + msg_len); | 1822 | udpw = GNUNET_malloc (sizeof (struct UDP_MessageWrapper) + msg_len); |
1907 | udpw->session = session; | 1823 | udpw->session = session; |
1908 | udpw->msg_buf = (char *) &udpw[1]; | 1824 | udpw->msg_buf = (char *) &udpw[1]; |
@@ -1911,17 +1827,14 @@ enqueue_fragment (void *cls, | |||
1911 | udpw->timeout = frag_ctx->timeout; | 1827 | udpw->timeout = frag_ctx->timeout; |
1912 | udpw->start_time = frag_ctx->start_time; | 1828 | udpw->start_time = frag_ctx->start_time; |
1913 | udpw->transmission_time = frag_ctx->next_frag_time; | 1829 | udpw->transmission_time = frag_ctx->next_frag_time; |
1914 | frag_ctx->next_frag_time | 1830 | frag_ctx->next_frag_time = |
1915 | = GNUNET_TIME_absolute_add (frag_ctx->next_frag_time, | 1831 | GNUNET_TIME_absolute_add (frag_ctx->next_frag_time, |
1916 | frag_ctx->flow_delay_from_other_peer); | 1832 | frag_ctx->flow_delay_from_other_peer); |
1917 | udpw->frag_ctx = frag_ctx; | 1833 | udpw->frag_ctx = frag_ctx; |
1918 | udpw->qc = &qc_fragment_sent; | 1834 | udpw->qc = &qc_fragment_sent; |
1919 | udpw->qc_cls = plugin; | 1835 | udpw->qc_cls = plugin; |
1920 | GNUNET_memcpy (udpw->msg_buf, | 1836 | GNUNET_memcpy (udpw->msg_buf, msg, msg_len); |
1921 | msg, | 1837 | enqueue (plugin, udpw); |
1922 | msg_len); | ||
1923 | enqueue (plugin, | ||
1924 | udpw); | ||
1925 | if (session->address->address_length == sizeof (struct IPv4UdpAddress)) | 1838 | if (session->address->address_length == sizeof (struct IPv4UdpAddress)) |
1926 | schedule_select_v4 (plugin); | 1839 | schedule_select_v4 (plugin); |
1927 | else | 1840 | else |
@@ -1938,9 +1851,7 @@ enqueue_fragment (void *cls, | |||
1938 | * @param result #GNUNET_OK on success, #GNUNET_SYSERR on failure | 1851 | * @param result #GNUNET_OK on success, #GNUNET_SYSERR on failure |
1939 | */ | 1852 | */ |
1940 | static void | 1853 | static void |
1941 | qc_message_sent (void *cls, | 1854 | qc_message_sent (void *cls, struct UDP_MessageWrapper *udpw, int result) |
1942 | struct UDP_MessageWrapper *udpw, | ||
1943 | int result) | ||
1944 | { | 1855 | { |
1945 | struct Plugin *plugin = cls; | 1856 | struct Plugin *plugin = cls; |
1946 | size_t overhead; | 1857 | size_t overhead; |
@@ -1958,15 +1869,13 @@ qc_message_sent (void *cls, | |||
1958 | { | 1869 | { |
1959 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1870 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1960 | "Message sent via UDP with delay of %s\n", | 1871 | "Message sent via UDP with delay of %s\n", |
1961 | GNUNET_STRINGS_relative_time_to_string (delay, | 1872 | GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES)); |
1962 | GNUNET_YES)); | ||
1963 | } | 1873 | } |
1964 | else | 1874 | else |
1965 | { | 1875 | { |
1966 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 1876 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
1967 | "Message sent via UDP with delay of %s\n", | 1877 | "Message sent via UDP with delay of %s\n", |
1968 | GNUNET_STRINGS_relative_time_to_string (delay, | 1878 | GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES)); |
1969 | GNUNET_YES)); | ||
1970 | } | 1879 | } |
1971 | udpw->cont (udpw->cont_cls, | 1880 | udpw->cont (udpw->cont_cls, |
1972 | &udpw->session->target, | 1881 | &udpw->session->target, |
@@ -1980,14 +1889,16 @@ qc_message_sent (void *cls, | |||
1980 | "# UDP, unfragmented msgs, messages, sent, success", | 1889 | "# UDP, unfragmented msgs, messages, sent, success", |
1981 | 1, | 1890 | 1, |
1982 | GNUNET_NO); | 1891 | GNUNET_NO); |
1983 | GNUNET_STATISTICS_update (plugin->env->stats, | 1892 | GNUNET_STATISTICS_update ( |
1984 | "# UDP, unfragmented msgs, bytes payload, sent, success", | 1893 | plugin->env->stats, |
1985 | udpw->payload_size, | 1894 | "# UDP, unfragmented msgs, bytes payload, sent, success", |
1986 | GNUNET_NO); | 1895 | udpw->payload_size, |
1987 | GNUNET_STATISTICS_update (plugin->env->stats, | 1896 | GNUNET_NO); |
1988 | "# UDP, unfragmented msgs, bytes overhead, sent, success", | 1897 | GNUNET_STATISTICS_update ( |
1989 | overhead, | 1898 | plugin->env->stats, |
1990 | GNUNET_NO); | 1899 | "# UDP, unfragmented msgs, bytes overhead, sent, success", |
1900 | overhead, | ||
1901 | GNUNET_NO); | ||
1991 | GNUNET_STATISTICS_update (plugin->env->stats, | 1902 | GNUNET_STATISTICS_update (plugin->env->stats, |
1992 | "# UDP, total, bytes overhead, sent", | 1903 | "# UDP, total, bytes overhead, sent", |
1993 | overhead, | 1904 | overhead, |
@@ -2003,14 +1914,16 @@ qc_message_sent (void *cls, | |||
2003 | "# UDP, unfragmented msgs, messages, sent, failure", | 1914 | "# UDP, unfragmented msgs, messages, sent, failure", |
2004 | 1, | 1915 | 1, |
2005 | GNUNET_NO); | 1916 | GNUNET_NO); |
2006 | GNUNET_STATISTICS_update (plugin->env->stats, | 1917 | GNUNET_STATISTICS_update ( |
2007 | "# UDP, unfragmented msgs, bytes payload, sent, failure", | 1918 | plugin->env->stats, |
2008 | udpw->payload_size, | 1919 | "# UDP, unfragmented msgs, bytes payload, sent, failure", |
2009 | GNUNET_NO); | 1920 | udpw->payload_size, |
2010 | GNUNET_STATISTICS_update (plugin->env->stats, | 1921 | GNUNET_NO); |
2011 | "# UDP, unfragmented msgs, bytes overhead, sent, failure", | 1922 | GNUNET_STATISTICS_update ( |
2012 | overhead, | 1923 | plugin->env->stats, |
2013 | GNUNET_NO); | 1924 | "# UDP, unfragmented msgs, bytes overhead, sent, failure", |
1925 | overhead, | ||
1926 | GNUNET_NO); | ||
2014 | } | 1927 | } |
2015 | } | 1928 | } |
2016 | 1929 | ||
@@ -2053,18 +1966,18 @@ udp_plugin_send (void *cls, | |||
2053 | void *cont_cls) | 1966 | void *cont_cls) |
2054 | { | 1967 | { |
2055 | struct Plugin *plugin = cls; | 1968 | struct Plugin *plugin = cls; |
2056 | size_t udpmlen = msgbuf_size + sizeof(struct UDPMessage); | 1969 | size_t udpmlen = msgbuf_size + sizeof (struct UDPMessage); |
2057 | struct UDP_FragmentationContext *frag_ctx; | 1970 | struct UDP_FragmentationContext *frag_ctx; |
2058 | struct UDP_MessageWrapper *udpw; | 1971 | struct UDP_MessageWrapper *udpw; |
2059 | struct UDPMessage *udp; | 1972 | struct UDPMessage *udp; |
2060 | char mbuf[udpmlen] GNUNET_ALIGN; | 1973 | char mbuf[udpmlen] GNUNET_ALIGN; |
2061 | struct GNUNET_TIME_Relative latency; | 1974 | struct GNUNET_TIME_Relative latency; |
2062 | 1975 | ||
2063 | if ( (sizeof(struct IPv6UdpAddress) == s->address->address_length) && | 1976 | if ((sizeof (struct IPv6UdpAddress) == s->address->address_length) && |
2064 | (NULL == plugin->sockv6) ) | 1977 | (NULL == plugin->sockv6)) |
2065 | return GNUNET_SYSERR; | 1978 | return GNUNET_SYSERR; |
2066 | if ( (sizeof(struct IPv4UdpAddress) == s->address->address_length) && | 1979 | if ((sizeof (struct IPv4UdpAddress) == s->address->address_length) && |
2067 | (NULL == plugin->sockv4) ) | 1980 | (NULL == plugin->sockv4)) |
2068 | return GNUNET_SYSERR; | 1981 | return GNUNET_SYSERR; |
2069 | if (udpmlen >= GNUNET_MAX_MESSAGE_SIZE) | 1982 | if (udpmlen >= GNUNET_MAX_MESSAGE_SIZE) |
2070 | { | 1983 | { |
@@ -2112,22 +2025,19 @@ udp_plugin_send (void *cls, | |||
2112 | udpw->start_time = GNUNET_TIME_absolute_get (); | 2025 | udpw->start_time = GNUNET_TIME_absolute_get (); |
2113 | udpw->timeout = GNUNET_TIME_relative_to_absolute (to); | 2026 | udpw->timeout = GNUNET_TIME_relative_to_absolute (to); |
2114 | udpw->transmission_time = s->last_transmit_time; | 2027 | udpw->transmission_time = s->last_transmit_time; |
2115 | s->last_transmit_time | 2028 | s->last_transmit_time = |
2116 | = GNUNET_TIME_absolute_add (s->last_transmit_time, | 2029 | GNUNET_TIME_absolute_add (s->last_transmit_time, |
2117 | s->flow_delay_from_other_peer); | 2030 | s->flow_delay_from_other_peer); |
2118 | udpw->cont = cont; | 2031 | udpw->cont = cont; |
2119 | udpw->cont_cls = cont_cls; | 2032 | udpw->cont_cls = cont_cls; |
2120 | udpw->frag_ctx = NULL; | 2033 | udpw->frag_ctx = NULL; |
2121 | udpw->qc = &qc_message_sent; | 2034 | udpw->qc = &qc_message_sent; |
2122 | udpw->qc_cls = plugin; | 2035 | udpw->qc_cls = plugin; |
2123 | GNUNET_memcpy (udpw->msg_buf, | 2036 | GNUNET_memcpy (udpw->msg_buf, udp, sizeof (struct UDPMessage)); |
2124 | udp, | 2037 | GNUNET_memcpy (&udpw->msg_buf[sizeof (struct UDPMessage)], |
2125 | sizeof (struct UDPMessage)); | 2038 | msgbuf, |
2126 | GNUNET_memcpy (&udpw->msg_buf[sizeof(struct UDPMessage)], | 2039 | msgbuf_size); |
2127 | msgbuf, | 2040 | enqueue (plugin, udpw); |
2128 | msgbuf_size); | ||
2129 | enqueue (plugin, | ||
2130 | udpw); | ||
2131 | GNUNET_STATISTICS_update (plugin->env->stats, | 2041 | GNUNET_STATISTICS_update (plugin->env->stats, |
2132 | "# UDP, unfragmented messages queued total", | 2042 | "# UDP, unfragmented messages queued total", |
2133 | 1, | 2043 | 1, |
@@ -2146,9 +2056,7 @@ udp_plugin_send (void *cls, | |||
2146 | /* fragmented message */ | 2056 | /* fragmented message */ |
2147 | if (NULL != s->frag_ctx) | 2057 | if (NULL != s->frag_ctx) |
2148 | return GNUNET_SYSERR; | 2058 | return GNUNET_SYSERR; |
2149 | GNUNET_memcpy (&udp[1], | 2059 | GNUNET_memcpy (&udp[1], msgbuf, msgbuf_size); |
2150 | msgbuf, | ||
2151 | msgbuf_size); | ||
2152 | frag_ctx = GNUNET_new (struct UDP_FragmentationContext); | 2060 | frag_ctx = GNUNET_new (struct UDP_FragmentationContext); |
2153 | frag_ctx->plugin = plugin; | 2061 | frag_ctx->plugin = plugin; |
2154 | frag_ctx->session = s; | 2062 | frag_ctx->session = s; |
@@ -2156,12 +2064,12 @@ udp_plugin_send (void *cls, | |||
2156 | frag_ctx->cont_cls = cont_cls; | 2064 | frag_ctx->cont_cls = cont_cls; |
2157 | frag_ctx->start_time = GNUNET_TIME_absolute_get (); | 2065 | frag_ctx->start_time = GNUNET_TIME_absolute_get (); |
2158 | frag_ctx->next_frag_time = s->last_transmit_time; | 2066 | frag_ctx->next_frag_time = s->last_transmit_time; |
2159 | frag_ctx->flow_delay_from_other_peer | 2067 | frag_ctx->flow_delay_from_other_peer = |
2160 | = GNUNET_TIME_relative_divide (s->flow_delay_from_other_peer, | 2068 | GNUNET_TIME_relative_divide (s->flow_delay_from_other_peer, |
2161 | 1 + (msgbuf_size / | 2069 | 1 + (msgbuf_size / UDP_MTU)); |
2162 | UDP_MTU)); | ||
2163 | frag_ctx->timeout = GNUNET_TIME_relative_to_absolute (to); | 2070 | frag_ctx->timeout = GNUNET_TIME_relative_to_absolute (to); |
2164 | frag_ctx->payload_size = msgbuf_size; /* unfragmented message size without UDP overhead */ | 2071 | frag_ctx->payload_size = |
2072 | msgbuf_size; /* unfragmented message size without UDP overhead */ | ||
2165 | frag_ctx->on_wire_size = 0; /* bytes with UDP and fragmentation overhead */ | 2073 | frag_ctx->on_wire_size = 0; /* bytes with UDP and fragmentation overhead */ |
2166 | frag_ctx->frag = GNUNET_FRAGMENT_context_create (plugin->env->stats, | 2074 | frag_ctx->frag = GNUNET_FRAGMENT_context_create (plugin->env->stats, |
2167 | UDP_MTU, | 2075 | UDP_MTU, |
@@ -2177,15 +2085,13 @@ udp_plugin_send (void *cls, | |||
2177 | if (latency.rel_value_us > GNUNET_CONSTANTS_LATENCY_WARN.rel_value_us) | 2085 | if (latency.rel_value_us > GNUNET_CONSTANTS_LATENCY_WARN.rel_value_us) |
2178 | LOG (GNUNET_ERROR_TYPE_WARNING, | 2086 | LOG (GNUNET_ERROR_TYPE_WARNING, |
2179 | "Enqueued fragments will take %s for transmission to %s (queue size: %u)\n", | 2087 | "Enqueued fragments will take %s for transmission to %s (queue size: %u)\n", |
2180 | GNUNET_STRINGS_relative_time_to_string (latency, | 2088 | GNUNET_STRINGS_relative_time_to_string (latency, GNUNET_YES), |
2181 | GNUNET_YES), | ||
2182 | GNUNET_i2s (&s->target), | 2089 | GNUNET_i2s (&s->target), |
2183 | (unsigned int) s->msgs_in_queue); | 2090 | (unsigned int) s->msgs_in_queue); |
2184 | else | 2091 | else |
2185 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2092 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2186 | "Enqueued fragments will take %s for transmission to %s (queue size: %u)\n", | 2093 | "Enqueued fragments will take %s for transmission to %s (queue size: %u)\n", |
2187 | GNUNET_STRINGS_relative_time_to_string (latency, | 2094 | GNUNET_STRINGS_relative_time_to_string (latency, GNUNET_YES), |
2188 | GNUNET_YES), | ||
2189 | GNUNET_i2s (&s->target), | 2095 | GNUNET_i2s (&s->target), |
2190 | (unsigned int) s->msgs_in_queue); | 2096 | (unsigned int) s->msgs_in_queue); |
2191 | 2097 | ||
@@ -2202,9 +2108,7 @@ udp_plugin_send (void *cls, | |||
2202 | frag_ctx->payload_size, | 2108 | frag_ctx->payload_size, |
2203 | GNUNET_NO); | 2109 | GNUNET_NO); |
2204 | } | 2110 | } |
2205 | notify_session_monitor (s->plugin, | 2111 | notify_session_monitor (s->plugin, s, GNUNET_TRANSPORT_SS_UPDATE); |
2206 | s, | ||
2207 | GNUNET_TRANSPORT_SS_UPDATE); | ||
2208 | return udpmlen; | 2112 | return udpmlen; |
2209 | } | 2113 | } |
2210 | 2114 | ||
@@ -2236,7 +2140,6 @@ struct FindReceiveContext | |||
2236 | * Number of bytes in @e udp_addr. | 2140 | * Number of bytes in @e udp_addr. |
2237 | */ | 2141 | */ |
2238 | size_t udp_addr_len; | 2142 | size_t udp_addr_len; |
2239 | |||
2240 | }; | 2143 | }; |
2241 | 2144 | ||
2242 | 2145 | ||
@@ -2259,10 +2162,8 @@ find_receive_context (void *cls, | |||
2259 | struct FindReceiveContext *frc = cls; | 2162 | struct FindReceiveContext *frc = cls; |
2260 | struct DefragContext *e = element; | 2163 | struct DefragContext *e = element; |
2261 | 2164 | ||
2262 | if ( (frc->udp_addr_len == e->udp_addr_len) && | 2165 | if ((frc->udp_addr_len == e->udp_addr_len) && |
2263 | (0 == memcmp (frc->udp_addr, | 2166 | (0 == memcmp (frc->udp_addr, e->udp_addr, frc->udp_addr_len))) |
2264 | e->udp_addr, | ||
2265 | frc->udp_addr_len)) ) | ||
2266 | { | 2167 | { |
2267 | frc->rc = e; | 2168 | frc->rc = e; |
2268 | return GNUNET_NO; | 2169 | return GNUNET_NO; |
@@ -2280,8 +2181,7 @@ find_receive_context (void *cls, | |||
2280 | * @return #GNUNET_OK on success | 2181 | * @return #GNUNET_OK on success |
2281 | */ | 2182 | */ |
2282 | static int | 2183 | static int |
2283 | udp_disconnect_session (void *cls, | 2184 | udp_disconnect_session (void *cls, struct GNUNET_ATS_Session *s) |
2284 | struct GNUNET_ATS_Session *s) | ||
2285 | { | 2185 | { |
2286 | struct Plugin *plugin = cls; | 2186 | struct Plugin *plugin = cls; |
2287 | struct UDP_MessageWrapper *udpw; | 2187 | struct UDP_MessageWrapper *udpw; |
@@ -2304,13 +2204,11 @@ udp_disconnect_session (void *cls, | |||
2304 | if (NULL != s->frag_ctx) | 2204 | if (NULL != s->frag_ctx) |
2305 | { | 2205 | { |
2306 | /* Remove fragmented message due to disconnect */ | 2206 | /* Remove fragmented message due to disconnect */ |
2307 | fragmented_message_done (s->frag_ctx, | 2207 | fragmented_message_done (s->frag_ctx, GNUNET_SYSERR); |
2308 | GNUNET_SYSERR); | ||
2309 | } | 2208 | } |
2310 | GNUNET_assert (GNUNET_YES == | 2209 | GNUNET_assert ( |
2311 | GNUNET_CONTAINER_multipeermap_remove (plugin->sessions, | 2210 | GNUNET_YES == |
2312 | &s->target, | 2211 | GNUNET_CONTAINER_multipeermap_remove (plugin->sessions, &s->target, s)); |
2313 | s)); | ||
2314 | frc.rc = NULL; | 2212 | frc.rc = NULL; |
2315 | frc.udp_addr = s->address->address; | 2213 | frc.udp_addr = s->address->address; |
2316 | frc.udp_addr_len = s->address->address_length; | 2214 | frc.udp_addr_len = s->address->address_length; |
@@ -2336,11 +2234,8 @@ udp_disconnect_session (void *cls, | |||
2336 | next = udpw->next; | 2234 | next = udpw->next; |
2337 | if (udpw->session == s) | 2235 | if (udpw->session == s) |
2338 | { | 2236 | { |
2339 | dequeue (plugin, | 2237 | dequeue (plugin, udpw); |
2340 | udpw); | 2238 | udpw->qc (udpw->qc_cls, udpw, GNUNET_SYSERR); |
2341 | udpw->qc (udpw->qc_cls, | ||
2342 | udpw, | ||
2343 | GNUNET_SYSERR); | ||
2344 | GNUNET_free (udpw); | 2239 | GNUNET_free (udpw); |
2345 | } | 2240 | } |
2346 | } | 2241 | } |
@@ -2350,16 +2245,12 @@ udp_disconnect_session (void *cls, | |||
2350 | next = udpw->next; | 2245 | next = udpw->next; |
2351 | if (udpw->session == s) | 2246 | if (udpw->session == s) |
2352 | { | 2247 | { |
2353 | dequeue (plugin, | 2248 | dequeue (plugin, udpw); |
2354 | udpw); | 2249 | udpw->qc (udpw->qc_cls, udpw, GNUNET_SYSERR); |
2355 | udpw->qc (udpw->qc_cls, | ||
2356 | udpw, | ||
2357 | GNUNET_SYSERR); | ||
2358 | GNUNET_free (udpw); | 2250 | GNUNET_free (udpw); |
2359 | } | 2251 | } |
2360 | } | 2252 | } |
2361 | if ( (NULL != s->frag_ctx) && | 2253 | if ((NULL != s->frag_ctx) && (NULL != s->frag_ctx->cont)) |
2362 | (NULL != s->frag_ctx->cont) ) | ||
2363 | { | 2254 | { |
2364 | /* The 'frag_ctx' itself will be freed in #free_session() a bit | 2255 | /* The 'frag_ctx' itself will be freed in #free_session() a bit |
2365 | later, as it might be in use right now */ | 2256 | later, as it might be in use right now */ |
@@ -2372,12 +2263,8 @@ udp_disconnect_session (void *cls, | |||
2372 | s->frag_ctx->payload_size, | 2263 | s->frag_ctx->payload_size, |
2373 | s->frag_ctx->on_wire_size); | 2264 | s->frag_ctx->on_wire_size); |
2374 | } | 2265 | } |
2375 | notify_session_monitor (s->plugin, | 2266 | notify_session_monitor (s->plugin, s, GNUNET_TRANSPORT_SS_DONE); |
2376 | s, | 2267 | plugin->env->session_end (plugin->env->cls, s->address, s); |
2377 | GNUNET_TRANSPORT_SS_DONE); | ||
2378 | plugin->env->session_end (plugin->env->cls, | ||
2379 | s->address, | ||
2380 | s); | ||
2381 | GNUNET_STATISTICS_set (plugin->env->stats, | 2268 | GNUNET_STATISTICS_set (plugin->env->stats, |
2382 | "# UDP sessions active", | 2269 | "# UDP sessions active", |
2383 | GNUNET_CONTAINER_multipeermap_size (plugin->sessions), | 2270 | GNUNET_CONTAINER_multipeermap_size (plugin->sessions), |
@@ -2409,17 +2296,17 @@ read_process_ack (struct Plugin *plugin, | |||
2409 | struct GNUNET_TIME_Relative flow_delay; | 2296 | struct GNUNET_TIME_Relative flow_delay; |
2410 | 2297 | ||
2411 | /* check message format */ | 2298 | /* check message format */ |
2412 | if (ntohs (msg->size) | 2299 | if (ntohs (msg->size) < |
2413 | < sizeof(struct UDP_ACK_Message) + sizeof(struct GNUNET_MessageHeader)) | 2300 | sizeof (struct UDP_ACK_Message) + sizeof (struct GNUNET_MessageHeader)) |
2414 | { | 2301 | { |
2415 | GNUNET_break_op (0); | 2302 | GNUNET_break_op (0); |
2416 | return; | 2303 | return; |
2417 | } | 2304 | } |
2418 | udp_ack = (const struct UDP_ACK_Message *) msg; | 2305 | udp_ack = (const struct UDP_ACK_Message *) msg; |
2419 | ack = (const struct GNUNET_MessageHeader *) &udp_ack[1]; | 2306 | ack = (const struct GNUNET_MessageHeader *) &udp_ack[1]; |
2420 | if (ntohs (ack->size) != ntohs (msg->size) - sizeof(struct UDP_ACK_Message)) | 2307 | if (ntohs (ack->size) != ntohs (msg->size) - sizeof (struct UDP_ACK_Message)) |
2421 | { | 2308 | { |
2422 | GNUNET_break_op(0); | 2309 | GNUNET_break_op (0); |
2423 | return; | 2310 | return; |
2424 | } | 2311 | } |
2425 | 2312 | ||
@@ -2429,8 +2316,7 @@ read_process_ack (struct Plugin *plugin, | |||
2429 | udp_addr, | 2316 | udp_addr, |
2430 | udp_addr_len, | 2317 | udp_addr_len, |
2431 | GNUNET_HELLO_ADDRESS_INFO_NONE); | 2318 | GNUNET_HELLO_ADDRESS_INFO_NONE); |
2432 | s = udp_plugin_lookup_session (plugin, | 2319 | s = udp_plugin_lookup_session (plugin, address); |
2433 | address); | ||
2434 | if (NULL == s) | 2320 | if (NULL == s) |
2435 | { | 2321 | { |
2436 | LOG (GNUNET_ERROR_TYPE_WARNING, | 2322 | LOG (GNUNET_ERROR_TYPE_WARNING, |
@@ -2461,39 +2347,32 @@ read_process_ack (struct Plugin *plugin, | |||
2461 | LOG (GNUNET_ERROR_TYPE_INFO, | 2347 | LOG (GNUNET_ERROR_TYPE_INFO, |
2462 | "Asked to disconnect UDP session of %s\n", | 2348 | "Asked to disconnect UDP session of %s\n", |
2463 | GNUNET_i2s (&udp_ack->sender)); | 2349 | GNUNET_i2s (&udp_ack->sender)); |
2464 | udp_disconnect_session (plugin, | 2350 | udp_disconnect_session (plugin, s); |
2465 | s); | ||
2466 | return; | 2351 | return; |
2467 | } | 2352 | } |
2468 | flow_delay.rel_value_us = (uint64_t) ntohl (udp_ack->delay); | 2353 | flow_delay.rel_value_us = (uint64_t) ntohl (udp_ack->delay); |
2469 | if (flow_delay.rel_value_us > GNUNET_CONSTANTS_LATENCY_WARN.rel_value_us) | 2354 | if (flow_delay.rel_value_us > GNUNET_CONSTANTS_LATENCY_WARN.rel_value_us) |
2470 | LOG (GNUNET_ERROR_TYPE_WARNING, | 2355 | LOG (GNUNET_ERROR_TYPE_WARNING, |
2471 | "We received a sending delay of %s for %s\n", | 2356 | "We received a sending delay of %s for %s\n", |
2472 | GNUNET_STRINGS_relative_time_to_string (flow_delay, | 2357 | GNUNET_STRINGS_relative_time_to_string (flow_delay, GNUNET_YES), |
2473 | GNUNET_YES), | ||
2474 | GNUNET_i2s (&udp_ack->sender)); | 2358 | GNUNET_i2s (&udp_ack->sender)); |
2475 | else | 2359 | else |
2476 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2360 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2477 | "We received a sending delay of %s for %s\n", | 2361 | "We received a sending delay of %s for %s\n", |
2478 | GNUNET_STRINGS_relative_time_to_string (flow_delay, | 2362 | GNUNET_STRINGS_relative_time_to_string (flow_delay, GNUNET_YES), |
2479 | GNUNET_YES), | ||
2480 | GNUNET_i2s (&udp_ack->sender)); | 2363 | GNUNET_i2s (&udp_ack->sender)); |
2481 | /* Flow delay is for the reassembled packet, however, our delay | 2364 | /* Flow delay is for the reassembled packet, however, our delay |
2482 | is per packet, so we need to adjust: */ | 2365 | is per packet, so we need to adjust: */ |
2483 | s->flow_delay_from_other_peer = flow_delay; | 2366 | s->flow_delay_from_other_peer = flow_delay; |
2484 | 2367 | ||
2485 | /* Handle ACK */ | 2368 | /* Handle ACK */ |
2486 | if (GNUNET_OK != | 2369 | if (GNUNET_OK != GNUNET_FRAGMENT_process_ack (s->frag_ctx->frag, ack)) |
2487 | GNUNET_FRAGMENT_process_ack (s->frag_ctx->frag, | ||
2488 | ack)) | ||
2489 | { | 2370 | { |
2490 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2371 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2491 | "UDP processes %u-byte acknowledgement from `%s' at `%s'\n", | 2372 | "UDP processes %u-byte acknowledgement from `%s' at `%s'\n", |
2492 | (unsigned int) ntohs (msg->size), | 2373 | (unsigned int) ntohs (msg->size), |
2493 | GNUNET_i2s (&udp_ack->sender), | 2374 | GNUNET_i2s (&udp_ack->sender), |
2494 | udp_address_to_string (plugin, | 2375 | udp_address_to_string (plugin, udp_addr, udp_addr_len)); |
2495 | udp_addr, | ||
2496 | udp_addr_len)); | ||
2497 | /* Expect more ACKs to arrive */ | 2376 | /* Expect more ACKs to arrive */ |
2498 | return; | 2377 | return; |
2499 | } | 2378 | } |
@@ -2502,11 +2381,8 @@ read_process_ack (struct Plugin *plugin, | |||
2502 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2381 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2503 | "Message from %s at %s full ACK'ed\n", | 2382 | "Message from %s at %s full ACK'ed\n", |
2504 | GNUNET_i2s (&udp_ack->sender), | 2383 | GNUNET_i2s (&udp_ack->sender), |
2505 | udp_address_to_string (plugin, | 2384 | udp_address_to_string (plugin, udp_addr, udp_addr_len)); |
2506 | udp_addr, | 2385 | fragmented_message_done (s->frag_ctx, GNUNET_OK); |
2507 | udp_addr_len)); | ||
2508 | fragmented_message_done (s->frag_ctx, | ||
2509 | GNUNET_OK); | ||
2510 | } | 2386 | } |
2511 | 2387 | ||
2512 | 2388 | ||
@@ -2528,11 +2404,8 @@ process_inbound_tokenized_messages (void *cls, | |||
2528 | if (GNUNET_YES == session->in_destroy) | 2404 | if (GNUNET_YES == session->in_destroy) |
2529 | return GNUNET_OK; | 2405 | return GNUNET_OK; |
2530 | reschedule_session_timeout (session); | 2406 | reschedule_session_timeout (session); |
2531 | session->flow_delay_for_other_peer | 2407 | session->flow_delay_for_other_peer = |
2532 | = plugin->env->receive (plugin->env->cls, | 2408 | plugin->env->receive (plugin->env->cls, session->address, session, hdr); |
2533 | session->address, | ||
2534 | session, | ||
2535 | hdr); | ||
2536 | return GNUNET_OK; | 2409 | return GNUNET_OK; |
2537 | } | 2410 | } |
2538 | 2411 | ||
@@ -2552,8 +2425,7 @@ disconnect_and_free_it (void *cls, | |||
2552 | { | 2425 | { |
2553 | struct Plugin *plugin = cls; | 2426 | struct Plugin *plugin = cls; |
2554 | 2427 | ||
2555 | udp_disconnect_session (plugin, | 2428 | udp_disconnect_session (plugin, value); |
2556 | value); | ||
2557 | return GNUNET_OK; | 2429 | return GNUNET_OK; |
2558 | } | 2430 | } |
2559 | 2431 | ||
@@ -2567,8 +2439,7 @@ disconnect_and_free_it (void *cls, | |||
2567 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the operation failed | 2439 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if the operation failed |
2568 | */ | 2440 | */ |
2569 | static void | 2441 | static void |
2570 | udp_disconnect (void *cls, | 2442 | udp_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) |
2571 | const struct GNUNET_PeerIdentity *target) | ||
2572 | { | 2443 | { |
2573 | struct Plugin *plugin = cls; | 2444 | struct Plugin *plugin = cls; |
2574 | 2445 | ||
@@ -2600,12 +2471,8 @@ session_timeout (void *cls) | |||
2600 | { | 2471 | { |
2601 | /* not actually our turn yet, but let's at least update | 2472 | /* not actually our turn yet, but let's at least update |
2602 | the monitor, it may think we're about to die ... */ | 2473 | the monitor, it may think we're about to die ... */ |
2603 | notify_session_monitor (s->plugin, | 2474 | notify_session_monitor (s->plugin, s, GNUNET_TRANSPORT_SS_UPDATE); |
2604 | s, | 2475 | s->timeout_task = GNUNET_SCHEDULER_add_delayed (left, &session_timeout, s); |
2605 | GNUNET_TRANSPORT_SS_UPDATE); | ||
2606 | s->timeout_task = GNUNET_SCHEDULER_add_delayed (left, | ||
2607 | &session_timeout, | ||
2608 | s); | ||
2609 | return; | 2476 | return; |
2610 | } | 2477 | } |
2611 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2478 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -2614,8 +2481,7 @@ session_timeout (void *cls) | |||
2614 | GNUNET_STRINGS_relative_time_to_string (UDP_SESSION_TIME_OUT, | 2481 | GNUNET_STRINGS_relative_time_to_string (UDP_SESSION_TIME_OUT, |
2615 | GNUNET_YES)); | 2482 | GNUNET_YES)); |
2616 | /* call session destroy function */ | 2483 | /* call session destroy function */ |
2617 | udp_disconnect_session (plugin, | 2484 | udp_disconnect_session (plugin, s); |
2618 | s); | ||
2619 | } | 2485 | } |
2620 | 2486 | ||
2621 | 2487 | ||
@@ -2639,21 +2505,19 @@ udp_plugin_create_session (void *cls, | |||
2639 | struct GNUNET_ATS_Session *s; | 2505 | struct GNUNET_ATS_Session *s; |
2640 | 2506 | ||
2641 | s = GNUNET_new (struct GNUNET_ATS_Session); | 2507 | s = GNUNET_new (struct GNUNET_ATS_Session); |
2642 | s->mst = GNUNET_MST_create (&process_inbound_tokenized_messages, | 2508 | s->mst = GNUNET_MST_create (&process_inbound_tokenized_messages, s); |
2643 | s); | ||
2644 | s->plugin = plugin; | 2509 | s->plugin = plugin; |
2645 | s->address = GNUNET_HELLO_address_copy (address); | 2510 | s->address = GNUNET_HELLO_address_copy (address); |
2646 | s->target = address->peer; | 2511 | s->target = address->peer; |
2647 | s->last_transmit_time = GNUNET_TIME_absolute_get (); | 2512 | s->last_transmit_time = GNUNET_TIME_absolute_get (); |
2648 | s->last_expected_ack_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, | 2513 | s->last_expected_ack_delay = |
2649 | 250); | 2514 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250); |
2650 | s->last_expected_msg_delay = GNUNET_TIME_UNIT_MILLISECONDS; | 2515 | s->last_expected_msg_delay = GNUNET_TIME_UNIT_MILLISECONDS; |
2651 | s->flow_delay_from_other_peer = GNUNET_TIME_UNIT_ZERO; | 2516 | s->flow_delay_from_other_peer = GNUNET_TIME_UNIT_ZERO; |
2652 | s->flow_delay_for_other_peer = GNUNET_TIME_UNIT_ZERO; | 2517 | s->flow_delay_for_other_peer = GNUNET_TIME_UNIT_ZERO; |
2653 | s->timeout = GNUNET_TIME_relative_to_absolute (UDP_SESSION_TIME_OUT); | 2518 | s->timeout = GNUNET_TIME_relative_to_absolute (UDP_SESSION_TIME_OUT); |
2654 | s->timeout_task = GNUNET_SCHEDULER_add_delayed (UDP_SESSION_TIME_OUT, | 2519 | s->timeout_task = |
2655 | &session_timeout, | 2520 | GNUNET_SCHEDULER_add_delayed (UDP_SESSION_TIME_OUT, &session_timeout, s); |
2656 | s); | ||
2657 | s->scope = network_type; | 2521 | s->scope = network_type; |
2658 | 2522 | ||
2659 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2523 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -2663,18 +2527,16 @@ udp_plugin_create_session (void *cls, | |||
2663 | udp_address_to_string (plugin, | 2527 | udp_address_to_string (plugin, |
2664 | address->address, | 2528 | address->address, |
2665 | address->address_length)); | 2529 | address->address_length)); |
2666 | GNUNET_assert (GNUNET_OK == | 2530 | GNUNET_assert (GNUNET_OK == GNUNET_CONTAINER_multipeermap_put ( |
2667 | GNUNET_CONTAINER_multipeermap_put (plugin->sessions, | 2531 | plugin->sessions, |
2668 | &s->target, | 2532 | &s->target, |
2669 | s, | 2533 | s, |
2670 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); | 2534 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE)); |
2671 | GNUNET_STATISTICS_set (plugin->env->stats, | 2535 | GNUNET_STATISTICS_set (plugin->env->stats, |
2672 | "# UDP sessions active", | 2536 | "# UDP sessions active", |
2673 | GNUNET_CONTAINER_multipeermap_size (plugin->sessions), | 2537 | GNUNET_CONTAINER_multipeermap_size (plugin->sessions), |
2674 | GNUNET_NO); | 2538 | GNUNET_NO); |
2675 | notify_session_monitor (plugin, | 2539 | notify_session_monitor (plugin, s, GNUNET_TRANSPORT_SS_INIT); |
2676 | s, | ||
2677 | GNUNET_TRANSPORT_SS_INIT); | ||
2678 | return s; | 2540 | return s; |
2679 | } | 2541 | } |
2680 | 2542 | ||
@@ -2688,8 +2550,7 @@ udp_plugin_create_session (void *cls, | |||
2688 | * @return the session or NULL of max connections exceeded | 2550 | * @return the session or NULL of max connections exceeded |
2689 | */ | 2551 | */ |
2690 | static struct GNUNET_ATS_Session * | 2552 | static struct GNUNET_ATS_Session * |
2691 | udp_plugin_get_session (void *cls, | 2553 | udp_plugin_get_session (void *cls, const struct GNUNET_HELLO_Address *address) |
2692 | const struct GNUNET_HELLO_Address *address) | ||
2693 | { | 2554 | { |
2694 | struct Plugin *plugin = cls; | 2555 | struct Plugin *plugin = cls; |
2695 | struct GNUNET_ATS_Session *s; | 2556 | struct GNUNET_ATS_Session *s; |
@@ -2702,14 +2563,13 @@ udp_plugin_get_session (void *cls, | |||
2702 | GNUNET_break (0); | 2563 | GNUNET_break (0); |
2703 | return NULL; | 2564 | return NULL; |
2704 | } | 2565 | } |
2705 | if ( (address->address_length != sizeof(struct IPv4UdpAddress)) && | 2566 | if ((address->address_length != sizeof (struct IPv4UdpAddress)) && |
2706 | (address->address_length != sizeof(struct IPv6UdpAddress)) ) | 2567 | (address->address_length != sizeof (struct IPv6UdpAddress))) |
2707 | { | 2568 | { |
2708 | GNUNET_break_op (0); | 2569 | GNUNET_break_op (0); |
2709 | return NULL; | 2570 | return NULL; |
2710 | } | 2571 | } |
2711 | if (NULL != (s = udp_plugin_lookup_session (cls, | 2572 | if (NULL != (s = udp_plugin_lookup_session (cls, address))) |
2712 | address))) | ||
2713 | return s; | 2573 | return s; |
2714 | 2574 | ||
2715 | /* need to create new session */ | 2575 | /* need to create new session */ |
@@ -2746,9 +2606,7 @@ udp_plugin_get_session (void *cls, | |||
2746 | sizeof (v6)); | 2606 | sizeof (v6)); |
2747 | } | 2607 | } |
2748 | GNUNET_break (GNUNET_NT_UNSPECIFIED != network_type); | 2608 | GNUNET_break (GNUNET_NT_UNSPECIFIED != network_type); |
2749 | return udp_plugin_create_session (cls, | 2609 | return udp_plugin_create_session (cls, address, network_type); |
2750 | address, | ||
2751 | network_type); | ||
2752 | } | 2610 | } |
2753 | 2611 | ||
2754 | 2612 | ||
@@ -2774,13 +2632,13 @@ process_udp_message (struct Plugin *plugin, | |||
2774 | GNUNET_break (GNUNET_NT_UNSPECIFIED != network_type); | 2632 | GNUNET_break (GNUNET_NT_UNSPECIFIED != network_type); |
2775 | if (0 != ntohl (msg->reserved)) | 2633 | if (0 != ntohl (msg->reserved)) |
2776 | { | 2634 | { |
2777 | GNUNET_break_op(0); | 2635 | GNUNET_break_op (0); |
2778 | return; | 2636 | return; |
2779 | } | 2637 | } |
2780 | if (ntohs (msg->header.size) | 2638 | if (ntohs (msg->header.size) < |
2781 | < sizeof(struct GNUNET_MessageHeader) + sizeof(struct UDPMessage)) | 2639 | sizeof (struct GNUNET_MessageHeader) + sizeof (struct UDPMessage)) |
2782 | { | 2640 | { |
2783 | GNUNET_break_op(0); | 2641 | GNUNET_break_op (0); |
2784 | return; | 2642 | return; |
2785 | } | 2643 | } |
2786 | 2644 | ||
@@ -2789,32 +2647,22 @@ process_udp_message (struct Plugin *plugin, | |||
2789 | udp_addr, | 2647 | udp_addr, |
2790 | udp_addr_len, | 2648 | udp_addr_len, |
2791 | GNUNET_HELLO_ADDRESS_INFO_NONE); | 2649 | GNUNET_HELLO_ADDRESS_INFO_NONE); |
2792 | if (NULL == | 2650 | if (NULL == (s = udp_plugin_lookup_session (plugin, address))) |
2793 | (s = udp_plugin_lookup_session (plugin, | ||
2794 | address))) | ||
2795 | { | 2651 | { |
2796 | s = udp_plugin_create_session (plugin, | 2652 | s = udp_plugin_create_session (plugin, address, network_type); |
2797 | address, | 2653 | plugin->env->session_start (plugin->env->cls, address, s, s->scope); |
2798 | network_type); | 2654 | notify_session_monitor (plugin, s, GNUNET_TRANSPORT_SS_UP); |
2799 | plugin->env->session_start (plugin->env->cls, | ||
2800 | address, | ||
2801 | s, | ||
2802 | s->scope); | ||
2803 | notify_session_monitor (plugin, | ||
2804 | s, | ||
2805 | GNUNET_TRANSPORT_SS_UP); | ||
2806 | } | 2655 | } |
2807 | GNUNET_free (address); | 2656 | GNUNET_free (address); |
2808 | 2657 | ||
2809 | s->rc++; | 2658 | s->rc++; |
2810 | GNUNET_MST_from_buffer (s->mst, | 2659 | GNUNET_MST_from_buffer (s->mst, |
2811 | (const char *) &msg[1], | 2660 | (const char *) &msg[1], |
2812 | ntohs (msg->header.size) - sizeof(struct UDPMessage), | 2661 | ntohs (msg->header.size) - sizeof (struct UDPMessage), |
2813 | GNUNET_YES, | 2662 | GNUNET_YES, |
2814 | GNUNET_NO); | 2663 | GNUNET_NO); |
2815 | s->rc--; | 2664 | s->rc--; |
2816 | if ( (0 == s->rc) && | 2665 | if ((0 == s->rc) && (GNUNET_YES == s->in_destroy)) |
2817 | (GNUNET_YES == s->in_destroy) ) | ||
2818 | free_session (s); | 2666 | free_session (s); |
2819 | } | 2667 | } |
2820 | 2668 | ||
@@ -2826,8 +2674,7 @@ process_udp_message (struct Plugin *plugin, | |||
2826 | * @param msg the message | 2674 | * @param msg the message |
2827 | */ | 2675 | */ |
2828 | static void | 2676 | static void |
2829 | fragment_msg_proc (void *cls, | 2677 | fragment_msg_proc (void *cls, const struct GNUNET_MessageHeader *msg) |
2830 | const struct GNUNET_MessageHeader *msg) | ||
2831 | { | 2678 | { |
2832 | struct DefragContext *dc = cls; | 2679 | struct DefragContext *dc = cls; |
2833 | const struct UDPMessage *um; | 2680 | const struct UDPMessage *um; |
@@ -2837,7 +2684,7 @@ fragment_msg_proc (void *cls, | |||
2837 | GNUNET_break_op (0); | 2684 | GNUNET_break_op (0); |
2838 | return; | 2685 | return; |
2839 | } | 2686 | } |
2840 | if (ntohs (msg->size) < sizeof(struct UDPMessage)) | 2687 | if (ntohs (msg->size) < sizeof (struct UDPMessage)) |
2841 | { | 2688 | { |
2842 | GNUNET_break_op (0); | 2689 | GNUNET_break_op (0); |
2843 | return; | 2690 | return; |
@@ -2863,9 +2710,7 @@ fragment_msg_proc (void *cls, | |||
2863 | * #GNUNET_SYSERR if we failed to send the ACK | 2710 | * #GNUNET_SYSERR if we failed to send the ACK |
2864 | */ | 2711 | */ |
2865 | static void | 2712 | static void |
2866 | ack_message_sent (void *cls, | 2713 | ack_message_sent (void *cls, struct UDP_MessageWrapper *udpw, int result) |
2867 | struct UDP_MessageWrapper *udpw, | ||
2868 | int result) | ||
2869 | { | 2714 | { |
2870 | struct Plugin *plugin = cls; | 2715 | struct Plugin *plugin = cls; |
2871 | 2716 | ||
@@ -2894,13 +2739,11 @@ ack_message_sent (void *cls, | |||
2894 | * @param msg ack to transmit | 2739 | * @param msg ack to transmit |
2895 | */ | 2740 | */ |
2896 | static void | 2741 | static void |
2897 | ack_proc (void *cls, | 2742 | ack_proc (void *cls, uint32_t id, const struct GNUNET_MessageHeader *msg) |
2898 | uint32_t id, | ||
2899 | const struct GNUNET_MessageHeader *msg) | ||
2900 | { | 2743 | { |
2901 | struct DefragContext *rc = cls; | 2744 | struct DefragContext *rc = cls; |
2902 | struct Plugin *plugin = rc->plugin; | 2745 | struct Plugin *plugin = rc->plugin; |
2903 | size_t msize = sizeof(struct UDP_ACK_Message) + ntohs (msg->size); | 2746 | size_t msize = sizeof (struct UDP_ACK_Message) + ntohs (msg->size); |
2904 | struct UDP_ACK_Message *udp_ack; | 2747 | struct UDP_ACK_Message *udp_ack; |
2905 | uint32_t delay; | 2748 | uint32_t delay; |
2906 | struct UDP_MessageWrapper *udpw; | 2749 | struct UDP_MessageWrapper *udpw; |
@@ -2922,16 +2765,13 @@ ack_proc (void *cls, | |||
2922 | rc->udp_addr, | 2765 | rc->udp_addr, |
2923 | rc->udp_addr_len, | 2766 | rc->udp_addr_len, |
2924 | GNUNET_HELLO_ADDRESS_INFO_NONE); | 2767 | GNUNET_HELLO_ADDRESS_INFO_NONE); |
2925 | s = udp_plugin_lookup_session (plugin, | 2768 | s = udp_plugin_lookup_session (plugin, address); |
2926 | address); | ||
2927 | GNUNET_HELLO_address_free (address); | 2769 | GNUNET_HELLO_address_free (address); |
2928 | if (NULL == s) | 2770 | if (NULL == s) |
2929 | { | 2771 | { |
2930 | LOG (GNUNET_ERROR_TYPE_ERROR, | 2772 | LOG (GNUNET_ERROR_TYPE_ERROR, |
2931 | "Trying to transmit ACK to peer `%s' but no session found!\n", | 2773 | "Trying to transmit ACK to peer `%s' but no session found!\n", |
2932 | udp_address_to_string (plugin, | 2774 | udp_address_to_string (plugin, rc->udp_addr, rc->udp_addr_len)); |
2933 | rc->udp_addr, | ||
2934 | rc->udp_addr_len)); | ||
2935 | GNUNET_CONTAINER_heap_remove_node (rc->hnode); | 2775 | GNUNET_CONTAINER_heap_remove_node (rc->hnode); |
2936 | GNUNET_DEFRAGMENT_context_destroy (rc->defrag); | 2776 | GNUNET_DEFRAGMENT_context_destroy (rc->defrag); |
2937 | GNUNET_free (rc); | 2777 | GNUNET_free (rc); |
@@ -2950,9 +2790,7 @@ ack_proc (void *cls, | |||
2950 | delay = UINT32_MAX - 1; /* largest value we can communicate */ | 2790 | delay = UINT32_MAX - 1; /* largest value we can communicate */ |
2951 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2791 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
2952 | "Sending ACK to `%s' including delay of %s\n", | 2792 | "Sending ACK to `%s' including delay of %s\n", |
2953 | udp_address_to_string (plugin, | 2793 | udp_address_to_string (plugin, rc->udp_addr, rc->udp_addr_len), |
2954 | rc->udp_addr, | ||
2955 | rc->udp_addr_len), | ||
2956 | GNUNET_STRINGS_relative_time_to_string (s->flow_delay_for_other_peer, | 2794 | GNUNET_STRINGS_relative_time_to_string (s->flow_delay_for_other_peer, |
2957 | GNUNET_YES)); | 2795 | GNUNET_YES)); |
2958 | udpw = GNUNET_malloc (sizeof (struct UDP_MessageWrapper) + msize); | 2796 | udpw = GNUNET_malloc (sizeof (struct UDP_MessageWrapper) + msize); |
@@ -2969,14 +2807,9 @@ ack_proc (void *cls, | |||
2969 | udp_ack->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_ACK); | 2807 | udp_ack->header.type = htons (GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_ACK); |
2970 | udp_ack->delay = htonl (delay); | 2808 | udp_ack->delay = htonl (delay); |
2971 | udp_ack->sender = *plugin->env->my_identity; | 2809 | udp_ack->sender = *plugin->env->my_identity; |
2972 | GNUNET_memcpy (&udp_ack[1], | 2810 | GNUNET_memcpy (&udp_ack[1], msg, ntohs (msg->size)); |
2973 | msg, | 2811 | enqueue (plugin, udpw); |
2974 | ntohs (msg->size)); | 2812 | notify_session_monitor (plugin, s, GNUNET_TRANSPORT_SS_UPDATE); |
2975 | enqueue (plugin, | ||
2976 | udpw); | ||
2977 | notify_session_monitor (plugin, | ||
2978 | s, | ||
2979 | GNUNET_TRANSPORT_SS_UPDATE); | ||
2980 | if (s->address->address_length == sizeof (struct IPv4UdpAddress)) | 2813 | if (s->address->address_length == sizeof (struct IPv4UdpAddress)) |
2981 | schedule_select_v4 (plugin); | 2814 | schedule_select_v4 (plugin); |
2982 | else | 2815 | else |
@@ -3019,46 +2852,41 @@ read_process_fragment (struct Plugin *plugin, | |||
3019 | { | 2852 | { |
3020 | /* Create a new defragmentation context */ | 2853 | /* Create a new defragmentation context */ |
3021 | d_ctx = GNUNET_malloc (sizeof (struct DefragContext) + udp_addr_len); | 2854 | d_ctx = GNUNET_malloc (sizeof (struct DefragContext) + udp_addr_len); |
3022 | GNUNET_memcpy (&d_ctx[1], | 2855 | GNUNET_memcpy (&d_ctx[1], udp_addr, udp_addr_len); |
3023 | udp_addr, | ||
3024 | udp_addr_len); | ||
3025 | d_ctx->udp_addr = (const union UdpAddress *) &d_ctx[1]; | 2856 | d_ctx->udp_addr = (const union UdpAddress *) &d_ctx[1]; |
3026 | d_ctx->udp_addr_len = udp_addr_len; | 2857 | d_ctx->udp_addr_len = udp_addr_len; |
3027 | d_ctx->network_type = network_type; | 2858 | d_ctx->network_type = network_type; |
3028 | d_ctx->plugin = plugin; | 2859 | d_ctx->plugin = plugin; |
3029 | d_ctx->defrag = GNUNET_DEFRAGMENT_context_create (plugin->env->stats, | 2860 | d_ctx->defrag = |
3030 | UDP_MTU, | 2861 | GNUNET_DEFRAGMENT_context_create (plugin->env->stats, |
3031 | UDP_MAX_MESSAGES_IN_DEFRAG, | 2862 | UDP_MTU, |
3032 | d_ctx, | 2863 | UDP_MAX_MESSAGES_IN_DEFRAG, |
3033 | &fragment_msg_proc, | 2864 | d_ctx, |
3034 | &ack_proc); | 2865 | &fragment_msg_proc, |
2866 | &ack_proc); | ||
3035 | d_ctx->hnode = GNUNET_CONTAINER_heap_insert (plugin->defrag_ctxs, | 2867 | d_ctx->hnode = GNUNET_CONTAINER_heap_insert (plugin->defrag_ctxs, |
3036 | d_ctx, | 2868 | d_ctx, |
3037 | (GNUNET_CONTAINER_HeapCostType) now.abs_value_us); | 2869 | (GNUNET_CONTAINER_HeapCostType) |
2870 | now.abs_value_us); | ||
3038 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2871 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
3039 | "Created new defragmentation context for %u-byte fragment from `%s'\n", | 2872 | "Created new defragmentation context for %u-byte fragment from `%s'\n", |
3040 | (unsigned int) ntohs (msg->size), | 2873 | (unsigned int) ntohs (msg->size), |
3041 | udp_address_to_string (plugin, | 2874 | udp_address_to_string (plugin, udp_addr, udp_addr_len)); |
3042 | udp_addr, | ||
3043 | udp_addr_len)); | ||
3044 | } | 2875 | } |
3045 | else | 2876 | else |
3046 | { | 2877 | { |
3047 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2878 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
3048 | "Found existing defragmentation context for %u-byte fragment from `%s'\n", | 2879 | "Found existing defragmentation context for %u-byte fragment from `%s'\n", |
3049 | (unsigned int) ntohs (msg->size), | 2880 | (unsigned int) ntohs (msg->size), |
3050 | udp_address_to_string (plugin, | 2881 | udp_address_to_string (plugin, udp_addr, udp_addr_len)); |
3051 | udp_addr, | ||
3052 | udp_addr_len)); | ||
3053 | } | 2882 | } |
3054 | 2883 | ||
3055 | if (GNUNET_OK == | 2884 | if (GNUNET_OK == GNUNET_DEFRAGMENT_process_fragment (d_ctx->defrag, msg)) |
3056 | GNUNET_DEFRAGMENT_process_fragment (d_ctx->defrag, | ||
3057 | msg)) | ||
3058 | { | 2885 | { |
3059 | /* keep this 'rc' from expiring */ | 2886 | /* keep this 'rc' from expiring */ |
3060 | GNUNET_CONTAINER_heap_update_cost (d_ctx->hnode, | 2887 | GNUNET_CONTAINER_heap_update_cost (d_ctx->hnode, |
3061 | (GNUNET_CONTAINER_HeapCostType) now.abs_value_us); | 2888 | (GNUNET_CONTAINER_HeapCostType) |
2889 | now.abs_value_us); | ||
3062 | } | 2890 | } |
3063 | if (GNUNET_CONTAINER_heap_get_size (plugin->defrag_ctxs) > | 2891 | if (GNUNET_CONTAINER_heap_get_size (plugin->defrag_ctxs) > |
3064 | UDP_MAX_SENDER_ADDRESSES_WITH_DEFRAG) | 2892 | UDP_MAX_SENDER_ADDRESSES_WITH_DEFRAG) |
@@ -3083,8 +2911,7 @@ read_process_fragment (struct Plugin *plugin, | |||
3083 | * @param rsock socket to read from | 2911 | * @param rsock socket to read from |
3084 | */ | 2912 | */ |
3085 | static void | 2913 | static void |
3086 | udp_select_read (struct Plugin *plugin, | 2914 | udp_select_read (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *rsock) |
3087 | struct GNUNET_NETWORK_Handle *rsock) | ||
3088 | { | 2915 | { |
3089 | socklen_t fromlen; | 2916 | socklen_t fromlen; |
3090 | struct sockaddr_storage addr; | 2917 | struct sockaddr_storage addr; |
@@ -3101,9 +2928,7 @@ udp_select_read (struct Plugin *plugin, | |||
3101 | enum GNUNET_NetworkType network_type; | 2928 | enum GNUNET_NetworkType network_type; |
3102 | 2929 | ||
3103 | fromlen = sizeof (addr); | 2930 | fromlen = sizeof (addr); |
3104 | memset (&addr, | 2931 | memset (&addr, 0, sizeof (addr)); |
3105 | 0, | ||
3106 | sizeof(addr)); | ||
3107 | size = GNUNET_NETWORK_socket_recvfrom (rsock, | 2932 | size = GNUNET_NETWORK_socket_recvfrom (rsock, |
3108 | buf, | 2933 | buf, |
3109 | sizeof (buf), | 2934 | sizeof (buf), |
@@ -3121,15 +2946,14 @@ udp_select_read (struct Plugin *plugin, | |||
3121 | * error indicates a previous send operation resulted in an ICMP Port | 2946 | * error indicates a previous send operation resulted in an ICMP Port |
3122 | * Unreachable message. | 2947 | * Unreachable message. |
3123 | */ | 2948 | */ |
3124 | if ( (-1 == size) && | 2949 | if ((-1 == size) && (ECONNRESET == errno)) |
3125 | (ECONNRESET == errno) ) | ||
3126 | return; | 2950 | return; |
3127 | #endif | 2951 | #endif |
3128 | if (-1 == size) | 2952 | if (-1 == size) |
3129 | { | 2953 | { |
3130 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2954 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
3131 | "UDP failed to receive data: %s\n", | 2955 | "UDP failed to receive data: %s\n", |
3132 | STRERROR (errno)); | 2956 | strerror (errno)); |
3133 | /* Connection failure or something. Not a protocol violation. */ | 2957 | /* Connection failure or something. Not a protocol violation. */ |
3134 | return; | 2958 | return; |
3135 | } | 2959 | } |
@@ -3137,19 +2961,18 @@ udp_select_read (struct Plugin *plugin, | |||
3137 | /* Check if this is a STUN packet */ | 2961 | /* Check if this is a STUN packet */ |
3138 | if (GNUNET_NO != | 2962 | if (GNUNET_NO != |
3139 | GNUNET_NAT_stun_handle_packet (plugin->nat, | 2963 | GNUNET_NAT_stun_handle_packet (plugin->nat, |
3140 | (const struct sockaddr *) &addr, | 2964 | (const struct sockaddr *) &addr, |
3141 | fromlen, | 2965 | fromlen, |
3142 | buf, | 2966 | buf, |
3143 | size)) | 2967 | size)) |
3144 | return; /* was STUN, do not process further */ | 2968 | return; /* was STUN, do not process further */ |
3145 | 2969 | ||
3146 | if (size < sizeof(struct GNUNET_MessageHeader)) | 2970 | if (size < sizeof (struct GNUNET_MessageHeader)) |
3147 | { | 2971 | { |
3148 | LOG (GNUNET_ERROR_TYPE_WARNING, | 2972 | LOG (GNUNET_ERROR_TYPE_WARNING, |
3149 | "UDP got %u bytes from %s, which is not enough for a GNUnet message header\n", | 2973 | "UDP got %u bytes from %s, which is not enough for a GNUnet message header\n", |
3150 | (unsigned int ) size, | 2974 | (unsigned int) size, |
3151 | GNUNET_a2s (sa, | 2975 | GNUNET_a2s (sa, fromlen)); |
3152 | fromlen)); | ||
3153 | /* _MAY_ be a connection failure (got partial message) */ | 2976 | /* _MAY_ be a connection failure (got partial message) */ |
3154 | /* But it _MAY_ also be that the other side uses non-GNUnet protocol. */ | 2977 | /* But it _MAY_ also be that the other side uses non-GNUnet protocol. */ |
3155 | GNUNET_break_op (0); | 2978 | GNUNET_break_op (0); |
@@ -3160,16 +2983,14 @@ udp_select_read (struct Plugin *plugin, | |||
3160 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 2983 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
3161 | "UDP received %u-byte message from `%s' type %u\n", | 2984 | "UDP received %u-byte message from `%s' type %u\n", |
3162 | (unsigned int) size, | 2985 | (unsigned int) size, |
3163 | GNUNET_a2s (sa, | 2986 | GNUNET_a2s (sa, fromlen), |
3164 | fromlen), | ||
3165 | ntohs (msg->type)); | 2987 | ntohs (msg->type)); |
3166 | if (size != ntohs (msg->size)) | 2988 | if (size != ntohs (msg->size)) |
3167 | { | 2989 | { |
3168 | LOG (GNUNET_ERROR_TYPE_WARNING, | 2990 | LOG (GNUNET_ERROR_TYPE_WARNING, |
3169 | "UDP malformed message (size %u) header from %s\n", | 2991 | "UDP malformed message (size %u) header from %s\n", |
3170 | (unsigned int) size, | 2992 | (unsigned int) size, |
3171 | GNUNET_a2s (sa, | 2993 | GNUNET_a2s (sa, fromlen)); |
3172 | fromlen)); | ||
3173 | GNUNET_break_op (0); | 2994 | GNUNET_break_op (0); |
3174 | return; | 2995 | return; |
3175 | } | 2996 | } |
@@ -3177,9 +2998,7 @@ udp_select_read (struct Plugin *plugin, | |||
3177 | "# UDP, total bytes received", | 2998 | "# UDP, total bytes received", |
3178 | size, | 2999 | size, |
3179 | GNUNET_NO); | 3000 | GNUNET_NO); |
3180 | network_type = plugin->env->get_address_type (plugin->env->cls, | 3001 | network_type = plugin->env->get_address_type (plugin->env->cls, sa, fromlen); |
3181 | sa, | ||
3182 | fromlen); | ||
3183 | switch (sa->sa_family) | 3002 | switch (sa->sa_family) |
3184 | { | 3003 | { |
3185 | case AF_INET: | 3004 | case AF_INET: |
@@ -3215,9 +3034,9 @@ udp_select_read (struct Plugin *plugin, | |||
3215 | network_type); | 3034 | network_type); |
3216 | return; | 3035 | return; |
3217 | case GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_MESSAGE: | 3036 | case GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_MESSAGE: |
3218 | if (ntohs (msg->size) < sizeof(struct UDPMessage)) | 3037 | if (ntohs (msg->size) < sizeof (struct UDPMessage)) |
3219 | { | 3038 | { |
3220 | GNUNET_break_op(0); | 3039 | GNUNET_break_op (0); |
3221 | return; | 3040 | return; |
3222 | } | 3041 | } |
3223 | process_udp_message (plugin, | 3042 | process_udp_message (plugin, |
@@ -3227,20 +3046,13 @@ udp_select_read (struct Plugin *plugin, | |||
3227 | network_type); | 3046 | network_type); |
3228 | return; | 3047 | return; |
3229 | case GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_ACK: | 3048 | case GNUNET_MESSAGE_TYPE_TRANSPORT_UDP_ACK: |
3230 | read_process_ack (plugin, | 3049 | read_process_ack (plugin, msg, int_addr, int_addr_len); |
3231 | msg, | ||
3232 | int_addr, | ||
3233 | int_addr_len); | ||
3234 | return; | 3050 | return; |
3235 | case GNUNET_MESSAGE_TYPE_FRAGMENT: | 3051 | case GNUNET_MESSAGE_TYPE_FRAGMENT: |
3236 | read_process_fragment (plugin, | 3052 | read_process_fragment (plugin, msg, int_addr, int_addr_len, network_type); |
3237 | msg, | ||
3238 | int_addr, | ||
3239 | int_addr_len, | ||
3240 | network_type); | ||
3241 | return; | 3053 | return; |
3242 | default: | 3054 | default: |
3243 | GNUNET_break_op(0); | 3055 | GNUNET_break_op (0); |
3244 | return; | 3056 | return; |
3245 | } | 3057 | } |
3246 | } | 3058 | } |
@@ -3265,9 +3077,8 @@ remove_timeout_messages_and_select (struct Plugin *plugin, | |||
3265 | int removed; | 3077 | int removed; |
3266 | 3078 | ||
3267 | removed = GNUNET_NO; | 3079 | removed = GNUNET_NO; |
3268 | udpw = (sock == plugin->sockv4) | 3080 | udpw = (sock == plugin->sockv4) ? plugin->ipv4_queue_head |
3269 | ? plugin->ipv4_queue_head | 3081 | : plugin->ipv6_queue_head; |
3270 | : plugin->ipv6_queue_head; | ||
3271 | while (NULL != udpw) | 3082 | while (NULL != udpw) |
3272 | { | 3083 | { |
3273 | session = udpw->session; | 3084 | session = udpw->session; |
@@ -3277,11 +3088,8 @@ remove_timeout_messages_and_select (struct Plugin *plugin, | |||
3277 | { | 3088 | { |
3278 | /* Message timed out */ | 3089 | /* Message timed out */ |
3279 | removed = GNUNET_YES; | 3090 | removed = GNUNET_YES; |
3280 | dequeue (plugin, | 3091 | dequeue (plugin, udpw); |
3281 | udpw); | 3092 | udpw->qc (udpw->qc_cls, udpw, GNUNET_SYSERR); |
3282 | udpw->qc (udpw->qc_cls, | ||
3283 | udpw, | ||
3284 | GNUNET_SYSERR); | ||
3285 | GNUNET_free (udpw); | 3093 | GNUNET_free (udpw); |
3286 | 3094 | ||
3287 | if (sock == plugin->sockv4) | 3095 | if (sock == plugin->sockv4) |
@@ -3321,9 +3129,8 @@ remove_timeout_messages_and_select (struct Plugin *plugin, | |||
3321 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 3129 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
3322 | "Message for peer `%s' (%u bytes) is delayed for %s\n", | 3130 | "Message for peer `%s' (%u bytes) is delayed for %s\n", |
3323 | GNUNET_i2s (&udpw->session->target), | 3131 | GNUNET_i2s (&udpw->session->target), |
3324 | udpw->payload_size, | 3132 | udpw->payload_size, |
3325 | GNUNET_STRINGS_relative_time_to_string (remaining, | 3133 | GNUNET_STRINGS_relative_time_to_string (remaining, GNUNET_YES)); |
3326 | GNUNET_YES)); | ||
3327 | udpw = udpw->next; | 3134 | udpw = udpw->next; |
3328 | } | 3135 | } |
3329 | } | 3136 | } |
@@ -3353,13 +3160,9 @@ analyze_send_error (struct Plugin *plugin, | |||
3353 | { | 3160 | { |
3354 | enum GNUNET_NetworkType type; | 3161 | enum GNUNET_NetworkType type; |
3355 | 3162 | ||
3356 | type = plugin->env->get_address_type (plugin->env->cls, | 3163 | type = plugin->env->get_address_type (plugin->env->cls, sa, slen); |
3357 | sa, | 3164 | if (((GNUNET_NT_LAN == type) || (GNUNET_NT_WAN == type)) && |
3358 | slen); | 3165 | ((ENETUNREACH == errno) || (ENETDOWN == errno))) |
3359 | if ( ( (GNUNET_NT_LAN == type) || | ||
3360 | (GNUNET_NT_WAN == type) ) && | ||
3361 | ( (ENETUNREACH == errno) || | ||
3362 | (ENETDOWN == errno) ) ) | ||
3363 | { | 3166 | { |
3364 | if (slen == sizeof (struct sockaddr_in)) | 3167 | if (slen == sizeof (struct sockaddr_in)) |
3365 | { | 3168 | { |
@@ -3368,10 +3171,9 @@ analyze_send_error (struct Plugin *plugin, | |||
3368 | * This indicates we do not have connectivity | 3171 | * This indicates we do not have connectivity |
3369 | */ | 3172 | */ |
3370 | LOG (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, | 3173 | LOG (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, |
3371 | _("UDP could not transmit message to `%s': " | 3174 | _ ("UDP could not transmit message to `%s': " |
3372 | "Network seems down, please check your network configuration\n"), | 3175 | "Network seems down, please check your network configuration\n"), |
3373 | GNUNET_a2s (sa, | 3176 | GNUNET_a2s (sa, slen)); |
3374 | slen)); | ||
3375 | } | 3177 | } |
3376 | if (slen == sizeof (struct sockaddr_in6)) | 3178 | if (slen == sizeof (struct sockaddr_in6)) |
3377 | { | 3179 | { |
@@ -3382,7 +3184,8 @@ analyze_send_error (struct Plugin *plugin, | |||
3382 | * connectivity | 3184 | * connectivity |
3383 | */ | 3185 | */ |
3384 | LOG (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, | 3186 | LOG (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, |
3385 | _("UDP could not transmit IPv6 message! " | 3187 | _ ( |
3188 | "UDP could not transmit IPv6 message! " | ||
3386 | "Please check your network configuration and disable IPv6 if your " | 3189 | "Please check your network configuration and disable IPv6 if your " |
3387 | "connection does not have a global IPv6 address\n")); | 3190 | "connection does not have a global IPv6 address\n")); |
3388 | } | 3191 | } |
@@ -3391,9 +3194,8 @@ analyze_send_error (struct Plugin *plugin, | |||
3391 | { | 3194 | { |
3392 | LOG (GNUNET_ERROR_TYPE_WARNING, | 3195 | LOG (GNUNET_ERROR_TYPE_WARNING, |
3393 | "UDP could not transmit message to `%s': `%s'\n", | 3196 | "UDP could not transmit message to `%s': `%s'\n", |
3394 | GNUNET_a2s (sa, | 3197 | GNUNET_a2s (sa, slen), |
3395 | slen), | 3198 | strerror (error)); |
3396 | STRERROR (error)); | ||
3397 | } | 3199 | } |
3398 | } | 3200 | } |
3399 | 3201 | ||
@@ -3406,8 +3208,7 @@ analyze_send_error (struct Plugin *plugin, | |||
3406 | * @param sock which socket (v4/v6) to send on | 3208 | * @param sock which socket (v4/v6) to send on |
3407 | */ | 3209 | */ |
3408 | static void | 3210 | static void |
3409 | udp_select_send (struct Plugin *plugin, | 3211 | udp_select_send (struct Plugin *plugin, struct GNUNET_NETWORK_Handle *sock) |
3410 | struct GNUNET_NETWORK_Handle *sock) | ||
3411 | { | 3212 | { |
3412 | ssize_t sent; | 3213 | ssize_t sent; |
3413 | socklen_t slen; | 3214 | socklen_t slen; |
@@ -3419,15 +3220,13 @@ udp_select_send (struct Plugin *plugin, | |||
3419 | struct UDP_MessageWrapper *udpw; | 3220 | struct UDP_MessageWrapper *udpw; |
3420 | 3221 | ||
3421 | /* Find message(s) to send */ | 3222 | /* Find message(s) to send */ |
3422 | while (NULL != (udpw = remove_timeout_messages_and_select (plugin, | 3223 | while (NULL != (udpw = remove_timeout_messages_and_select (plugin, sock))) |
3423 | sock))) | ||
3424 | { | 3224 | { |
3425 | if (sizeof (struct IPv4UdpAddress) == udpw->session->address->address_length) | 3225 | if (sizeof (struct IPv4UdpAddress) == |
3226 | udpw->session->address->address_length) | ||
3426 | { | 3227 | { |
3427 | u4 = udpw->session->address->address; | 3228 | u4 = udpw->session->address->address; |
3428 | memset (&a4, | 3229 | memset (&a4, 0, sizeof (a4)); |
3429 | 0, | ||
3430 | sizeof(a4)); | ||
3431 | a4.sin_family = AF_INET; | 3230 | a4.sin_family = AF_INET; |
3432 | #if HAVE_SOCKADDR_IN_SIN_LEN | 3231 | #if HAVE_SOCKADDR_IN_SIN_LEN |
3433 | a4.sin_len = sizeof (a4); | 3232 | a4.sin_len = sizeof (a4); |
@@ -3437,12 +3236,11 @@ udp_select_send (struct Plugin *plugin, | |||
3437 | a = (const struct sockaddr *) &a4; | 3236 | a = (const struct sockaddr *) &a4; |
3438 | slen = sizeof (a4); | 3237 | slen = sizeof (a4); |
3439 | } | 3238 | } |
3440 | else if (sizeof (struct IPv6UdpAddress) == udpw->session->address->address_length) | 3239 | else if (sizeof (struct IPv6UdpAddress) == |
3240 | udpw->session->address->address_length) | ||
3441 | { | 3241 | { |
3442 | u6 = udpw->session->address->address; | 3242 | u6 = udpw->session->address->address; |
3443 | memset (&a6, | 3243 | memset (&a6, 0, sizeof (a6)); |
3444 | 0, | ||
3445 | sizeof(a6)); | ||
3446 | a6.sin6_family = AF_INET6; | 3244 | a6.sin6_family = AF_INET6; |
3447 | #if HAVE_SOCKADDR_IN_SIN_LEN | 3245 | #if HAVE_SOCKADDR_IN_SIN_LEN |
3448 | a6.sin6_len = sizeof (a6); | 3246 | a6.sin6_len = sizeof (a6); |
@@ -3455,11 +3253,8 @@ udp_select_send (struct Plugin *plugin, | |||
3455 | else | 3253 | else |
3456 | { | 3254 | { |
3457 | GNUNET_break (0); | 3255 | GNUNET_break (0); |
3458 | dequeue (plugin, | 3256 | dequeue (plugin, udpw); |
3459 | udpw); | 3257 | udpw->qc (udpw->qc_cls, udpw, GNUNET_SYSERR); |
3460 | udpw->qc (udpw->qc_cls, | ||
3461 | udpw, | ||
3462 | GNUNET_SYSERR); | ||
3463 | notify_session_monitor (plugin, | 3258 | notify_session_monitor (plugin, |
3464 | udpw->session, | 3259 | udpw->session, |
3465 | GNUNET_TRANSPORT_SS_UPDATE); | 3260 | GNUNET_TRANSPORT_SS_UPDATE); |
@@ -3471,21 +3266,15 @@ udp_select_send (struct Plugin *plugin, | |||
3471 | udpw->msg_size, | 3266 | udpw->msg_size, |
3472 | a, | 3267 | a, |
3473 | slen); | 3268 | slen); |
3474 | udpw->session->last_transmit_time | 3269 | udpw->session->last_transmit_time = |
3475 | = GNUNET_TIME_absolute_max (GNUNET_TIME_absolute_get (), | 3270 | GNUNET_TIME_absolute_max (GNUNET_TIME_absolute_get (), |
3476 | udpw->session->last_transmit_time); | 3271 | udpw->session->last_transmit_time); |
3477 | dequeue (plugin, | 3272 | dequeue (plugin, udpw); |
3478 | udpw); | ||
3479 | if (GNUNET_SYSERR == sent) | 3273 | if (GNUNET_SYSERR == sent) |
3480 | { | 3274 | { |
3481 | /* Failure */ | 3275 | /* Failure */ |
3482 | analyze_send_error (plugin, | 3276 | analyze_send_error (plugin, a, slen, errno); |
3483 | a, | 3277 | udpw->qc (udpw->qc_cls, udpw, GNUNET_SYSERR); |
3484 | slen, | ||
3485 | errno); | ||
3486 | udpw->qc (udpw->qc_cls, | ||
3487 | udpw, | ||
3488 | GNUNET_SYSERR); | ||
3489 | GNUNET_STATISTICS_update (plugin->env->stats, | 3278 | GNUNET_STATISTICS_update (plugin->env->stats, |
3490 | "# UDP, total, bytes, sent, failure", | 3279 | "# UDP, total, bytes, sent, failure", |
3491 | sent, | 3280 | sent, |
@@ -3502,10 +3291,9 @@ udp_select_send (struct Plugin *plugin, | |||
3502 | "UDP transmitted %u-byte message to `%s' `%s' (%d: %s)\n", | 3291 | "UDP transmitted %u-byte message to `%s' `%s' (%d: %s)\n", |
3503 | (unsigned int) (udpw->msg_size), | 3292 | (unsigned int) (udpw->msg_size), |
3504 | GNUNET_i2s (&udpw->session->target), | 3293 | GNUNET_i2s (&udpw->session->target), |
3505 | GNUNET_a2s (a, | 3294 | GNUNET_a2s (a, slen), |
3506 | slen), | 3295 | (int) sent, |
3507 | (int ) sent, | 3296 | (sent < 0) ? strerror (errno) : "ok"); |
3508 | (sent < 0) ? STRERROR (errno) : "ok"); | ||
3509 | GNUNET_STATISTICS_update (plugin->env->stats, | 3297 | GNUNET_STATISTICS_update (plugin->env->stats, |
3510 | "# UDP, total, bytes, sent, success", | 3298 | "# UDP, total, bytes, sent, success", |
3511 | sent, | 3299 | sent, |
@@ -3516,13 +3304,9 @@ udp_select_send (struct Plugin *plugin, | |||
3516 | GNUNET_NO); | 3304 | GNUNET_NO); |
3517 | if (NULL != udpw->frag_ctx) | 3305 | if (NULL != udpw->frag_ctx) |
3518 | udpw->frag_ctx->on_wire_size += udpw->msg_size; | 3306 | udpw->frag_ctx->on_wire_size += udpw->msg_size; |
3519 | udpw->qc (udpw->qc_cls, | 3307 | udpw->qc (udpw->qc_cls, udpw, GNUNET_OK); |
3520 | udpw, | ||
3521 | GNUNET_OK); | ||
3522 | } | 3308 | } |
3523 | notify_session_monitor (plugin, | 3309 | notify_session_monitor (plugin, udpw->session, GNUNET_TRANSPORT_SS_UPDATE); |
3524 | udpw->session, | ||
3525 | GNUNET_TRANSPORT_SS_UPDATE); | ||
3526 | GNUNET_free (udpw); | 3310 | GNUNET_free (udpw); |
3527 | } | 3311 | } |
3528 | } | 3312 | } |
@@ -3549,12 +3333,9 @@ udp_plugin_select_v4 (void *cls) | |||
3549 | return; | 3333 | return; |
3550 | tc = GNUNET_SCHEDULER_get_task_context (); | 3334 | tc = GNUNET_SCHEDULER_get_task_context (); |
3551 | if ((0 != (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) && | 3335 | if ((0 != (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) && |
3552 | (GNUNET_NETWORK_fdset_isset (tc->read_ready, | 3336 | (GNUNET_NETWORK_fdset_isset (tc->read_ready, plugin->sockv4))) |
3553 | plugin->sockv4))) | 3337 | udp_select_read (plugin, plugin->sockv4); |
3554 | udp_select_read (plugin, | 3338 | udp_select_send (plugin, plugin->sockv4); |
3555 | plugin->sockv4); | ||
3556 | udp_select_send (plugin, | ||
3557 | plugin->sockv4); | ||
3558 | schedule_select_v4 (plugin); | 3339 | schedule_select_v4 (plugin); |
3559 | } | 3340 | } |
3560 | 3341 | ||
@@ -3576,14 +3357,11 @@ udp_plugin_select_v6 (void *cls) | |||
3576 | if (NULL == plugin->sockv6) | 3357 | if (NULL == plugin->sockv6) |
3577 | return; | 3358 | return; |
3578 | tc = GNUNET_SCHEDULER_get_task_context (); | 3359 | tc = GNUNET_SCHEDULER_get_task_context (); |
3579 | if ( (0 != (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) && | 3360 | if ((0 != (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) && |
3580 | (GNUNET_NETWORK_fdset_isset (tc->read_ready, | 3361 | (GNUNET_NETWORK_fdset_isset (tc->read_ready, plugin->sockv6))) |
3581 | plugin->sockv6)) ) | 3362 | udp_select_read (plugin, plugin->sockv6); |
3582 | udp_select_read (plugin, | 3363 | |
3583 | plugin->sockv6); | 3364 | udp_select_send (plugin, plugin->sockv6); |
3584 | |||
3585 | udp_select_send (plugin, | ||
3586 | plugin->sockv6); | ||
3587 | schedule_select_v6 (plugin); | 3365 | schedule_select_v6 (plugin); |
3588 | } | 3366 | } |
3589 | 3367 | ||
@@ -3618,20 +3396,16 @@ setup_sockets (struct Plugin *plugin, | |||
3618 | eno = EINVAL; | 3396 | eno = EINVAL; |
3619 | if (GNUNET_YES == plugin->enable_ipv6) | 3397 | if (GNUNET_YES == plugin->enable_ipv6) |
3620 | { | 3398 | { |
3621 | plugin->sockv6 = GNUNET_NETWORK_socket_create (PF_INET6, | 3399 | plugin->sockv6 = GNUNET_NETWORK_socket_create (PF_INET6, SOCK_DGRAM, 0); |
3622 | SOCK_DGRAM, | ||
3623 | 0); | ||
3624 | if (NULL == plugin->sockv6) | 3400 | if (NULL == plugin->sockv6) |
3625 | { | 3401 | { |
3626 | LOG (GNUNET_ERROR_TYPE_INFO, | 3402 | LOG (GNUNET_ERROR_TYPE_INFO, |
3627 | _("Disabling IPv6 since it is not supported on this system!\n")); | 3403 | _ ("Disabling IPv6 since it is not supported on this system!\n")); |
3628 | plugin->enable_ipv6 = GNUNET_NO; | 3404 | plugin->enable_ipv6 = GNUNET_NO; |
3629 | } | 3405 | } |
3630 | else | 3406 | else |
3631 | { | 3407 | { |
3632 | memset (&server_addrv6, | 3408 | memset (&server_addrv6, 0, sizeof (struct sockaddr_in6)); |
3633 | 0, | ||
3634 | sizeof(struct sockaddr_in6)); | ||
3635 | #if HAVE_SOCKADDR_IN_SIN_LEN | 3409 | #if HAVE_SOCKADDR_IN_SIN_LEN |
3636 | server_addrv6.sin6_len = sizeof (struct sockaddr_in6); | 3410 | server_addrv6.sin6_len = sizeof (struct sockaddr_in6); |
3637 | #endif | 3411 | #endif |
@@ -3642,10 +3416,9 @@ setup_sockets (struct Plugin *plugin, | |||
3642 | server_addrv6.sin6_addr = in6addr_any; | 3416 | server_addrv6.sin6_addr = in6addr_any; |
3643 | 3417 | ||
3644 | if (0 == plugin->port) /* autodetect */ | 3418 | if (0 == plugin->port) /* autodetect */ |
3645 | server_addrv6.sin6_port | 3419 | server_addrv6.sin6_port = htons ( |
3646 | = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, | 3420 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + |
3647 | 33537) | 3421 | 32000); |
3648 | + 32000); | ||
3649 | else | 3422 | else |
3650 | server_addrv6.sin6_port = htons (plugin->port); | 3423 | server_addrv6.sin6_port = htons (plugin->port); |
3651 | addrlen = sizeof (struct sockaddr_in6); | 3424 | addrlen = sizeof (struct sockaddr_in6); |
@@ -3654,15 +3427,12 @@ setup_sockets (struct Plugin *plugin, | |||
3654 | tries = 0; | 3427 | tries = 0; |
3655 | while (tries < 10) | 3428 | while (tries < 10) |
3656 | { | 3429 | { |
3657 | LOG(GNUNET_ERROR_TYPE_DEBUG, | 3430 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
3658 | "Binding to IPv6 `%s'\n", | 3431 | "Binding to IPv6 `%s'\n", |
3659 | GNUNET_a2s (server_addr, | 3432 | GNUNET_a2s (server_addr, addrlen)); |
3660 | addrlen)); | ||
3661 | /* binding */ | 3433 | /* binding */ |
3662 | if (GNUNET_OK == | 3434 | if (GNUNET_OK == |
3663 | GNUNET_NETWORK_socket_bind (plugin->sockv6, | 3435 | GNUNET_NETWORK_socket_bind (plugin->sockv6, server_addr, addrlen)) |
3664 | server_addr, | ||
3665 | addrlen)) | ||
3666 | break; | 3436 | break; |
3667 | eno = errno; | 3437 | eno = errno; |
3668 | if (0 != plugin->port) | 3438 | if (0 != plugin->port) |
@@ -3671,10 +3441,9 @@ setup_sockets (struct Plugin *plugin, | |||
3671 | break; /* bind failed on specific port */ | 3441 | break; /* bind failed on specific port */ |
3672 | } | 3442 | } |
3673 | /* autodetect */ | 3443 | /* autodetect */ |
3674 | server_addrv6.sin6_port | 3444 | server_addrv6.sin6_port = htons ( |
3675 | = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, | 3445 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + |
3676 | 33537) | 3446 | 32000); |
3677 | + 32000); | ||
3678 | tries++; | 3447 | tries++; |
3679 | } | 3448 | } |
3680 | if (tries >= 10) | 3449 | if (tries >= 10) |
@@ -3691,8 +3460,7 @@ setup_sockets (struct Plugin *plugin, | |||
3691 | { | 3460 | { |
3692 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 3461 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
3693 | "IPv6 UDP socket created listinging at %s\n", | 3462 | "IPv6 UDP socket created listinging at %s\n", |
3694 | GNUNET_a2s (server_addr, | 3463 | GNUNET_a2s (server_addr, addrlen)); |
3695 | addrlen)); | ||
3696 | addrs[sockets_created] = server_addr; | 3464 | addrs[sockets_created] = server_addr; |
3697 | addrlens[sockets_created] = addrlen; | 3465 | addrlens[sockets_created] = addrlen; |
3698 | sockets_created++; | 3466 | sockets_created++; |
@@ -3700,32 +3468,26 @@ setup_sockets (struct Plugin *plugin, | |||
3700 | else | 3468 | else |
3701 | { | 3469 | { |
3702 | LOG (GNUNET_ERROR_TYPE_WARNING, | 3470 | LOG (GNUNET_ERROR_TYPE_WARNING, |
3703 | _("Failed to bind UDP socket to %s: %s\n"), | 3471 | _ ("Failed to bind UDP socket to %s: %s\n"), |
3704 | GNUNET_a2s (server_addr, | 3472 | GNUNET_a2s (server_addr, addrlen), |
3705 | addrlen), | 3473 | strerror (eno)); |
3706 | STRERROR (eno)); | ||
3707 | } | 3474 | } |
3708 | } | 3475 | } |
3709 | } | 3476 | } |
3710 | 3477 | ||
3711 | /* Create IPv4 socket */ | 3478 | /* Create IPv4 socket */ |
3712 | eno = EINVAL; | 3479 | eno = EINVAL; |
3713 | plugin->sockv4 = GNUNET_NETWORK_socket_create (PF_INET, | 3480 | plugin->sockv4 = GNUNET_NETWORK_socket_create (PF_INET, SOCK_DGRAM, 0); |
3714 | SOCK_DGRAM, | ||
3715 | 0); | ||
3716 | if (NULL == plugin->sockv4) | 3481 | if (NULL == plugin->sockv4) |
3717 | { | 3482 | { |
3718 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, | 3483 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "socket"); |
3719 | "socket"); | ||
3720 | LOG (GNUNET_ERROR_TYPE_INFO, | 3484 | LOG (GNUNET_ERROR_TYPE_INFO, |
3721 | _("Disabling IPv4 since it is not supported on this system!\n")); | 3485 | _ ("Disabling IPv4 since it is not supported on this system!\n")); |
3722 | plugin->enable_ipv4 = GNUNET_NO; | 3486 | plugin->enable_ipv4 = GNUNET_NO; |
3723 | } | 3487 | } |
3724 | else | 3488 | else |
3725 | { | 3489 | { |
3726 | memset (&server_addrv4, | 3490 | memset (&server_addrv4, 0, sizeof (struct sockaddr_in)); |
3727 | 0, | ||
3728 | sizeof(struct sockaddr_in)); | ||
3729 | #if HAVE_SOCKADDR_IN_SIN_LEN | 3491 | #if HAVE_SOCKADDR_IN_SIN_LEN |
3730 | server_addrv4.sin_len = sizeof (struct sockaddr_in); | 3492 | server_addrv4.sin_len = sizeof (struct sockaddr_in); |
3731 | #endif | 3493 | #endif |
@@ -3737,10 +3499,8 @@ setup_sockets (struct Plugin *plugin, | |||
3737 | 3499 | ||
3738 | if (0 == plugin->port) | 3500 | if (0 == plugin->port) |
3739 | /* autodetect */ | 3501 | /* autodetect */ |
3740 | server_addrv4.sin_port | 3502 | server_addrv4.sin_port = htons ( |
3741 | = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, | 3503 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); |
3742 | 33537) | ||
3743 | + 32000); | ||
3744 | else | 3504 | else |
3745 | server_addrv4.sin_port = htons (plugin->port); | 3505 | server_addrv4.sin_port = htons (plugin->port); |
3746 | 3506 | ||
@@ -3752,14 +3512,11 @@ setup_sockets (struct Plugin *plugin, | |||
3752 | { | 3512 | { |
3753 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 3513 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
3754 | "Binding to IPv4 `%s'\n", | 3514 | "Binding to IPv4 `%s'\n", |
3755 | GNUNET_a2s (server_addr, | 3515 | GNUNET_a2s (server_addr, addrlen)); |
3756 | addrlen)); | ||
3757 | 3516 | ||
3758 | /* binding */ | 3517 | /* binding */ |
3759 | if (GNUNET_OK == | 3518 | if (GNUNET_OK == |
3760 | GNUNET_NETWORK_socket_bind (plugin->sockv4, | 3519 | GNUNET_NETWORK_socket_bind (plugin->sockv4, server_addr, addrlen)) |
3761 | server_addr, | ||
3762 | addrlen)) | ||
3763 | break; | 3520 | break; |
3764 | eno = errno; | 3521 | eno = errno; |
3765 | if (0 != plugin->port) | 3522 | if (0 != plugin->port) |
@@ -3769,10 +3526,8 @@ setup_sockets (struct Plugin *plugin, | |||
3769 | } | 3526 | } |
3770 | 3527 | ||
3771 | /* autodetect */ | 3528 | /* autodetect */ |
3772 | server_addrv4.sin_port | 3529 | server_addrv4.sin_port = htons ( |
3773 | = htons (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, | 3530 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, 33537) + 32000); |
3774 | 33537) | ||
3775 | + 32000); | ||
3776 | tries++; | 3531 | tries++; |
3777 | } | 3532 | } |
3778 | if (tries >= 10) | 3533 | if (tries >= 10) |
@@ -3790,8 +3545,7 @@ setup_sockets (struct Plugin *plugin, | |||
3790 | { | 3545 | { |
3791 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 3546 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
3792 | "IPv4 socket created on port %s\n", | 3547 | "IPv4 socket created on port %s\n", |
3793 | GNUNET_a2s (server_addr, | 3548 | GNUNET_a2s (server_addr, addrlen)); |
3794 | addrlen)); | ||
3795 | addrs[sockets_created] = server_addr; | 3549 | addrs[sockets_created] = server_addr; |
3796 | addrlens[sockets_created] = addrlen; | 3550 | addrlens[sockets_created] = addrlen; |
3797 | sockets_created++; | 3551 | sockets_created++; |
@@ -3799,24 +3553,22 @@ setup_sockets (struct Plugin *plugin, | |||
3799 | else | 3553 | else |
3800 | { | 3554 | { |
3801 | LOG (GNUNET_ERROR_TYPE_ERROR, | 3555 | LOG (GNUNET_ERROR_TYPE_ERROR, |
3802 | _("Failed to bind UDP socket to %s: %s\n"), | 3556 | _ ("Failed to bind UDP socket to %s: %s\n"), |
3803 | GNUNET_a2s (server_addr, | 3557 | GNUNET_a2s (server_addr, addrlen), |
3804 | addrlen), | 3558 | strerror (eno)); |
3805 | STRERROR (eno)); | ||
3806 | } | 3559 | } |
3807 | } | 3560 | } |
3808 | 3561 | ||
3809 | if (0 == sockets_created) | 3562 | if (0 == sockets_created) |
3810 | { | 3563 | { |
3811 | LOG (GNUNET_ERROR_TYPE_WARNING, | 3564 | LOG (GNUNET_ERROR_TYPE_WARNING, _ ("Failed to open UDP sockets\n")); |
3812 | _("Failed to open UDP sockets\n")); | ||
3813 | return 0; /* No sockets created, return */ | 3565 | return 0; /* No sockets created, return */ |
3814 | } | 3566 | } |
3815 | schedule_select_v4 (plugin); | 3567 | schedule_select_v4 (plugin); |
3816 | schedule_select_v6 (plugin); | 3568 | schedule_select_v6 (plugin); |
3817 | plugin->nat = GNUNET_NAT_register (plugin->env->cfg, | 3569 | plugin->nat = GNUNET_NAT_register (plugin->env->cfg, |
3818 | "transport-udp", | 3570 | "transport-udp", |
3819 | IPPROTO_UDP, | 3571 | IPPROTO_UDP, |
3820 | sockets_created, | 3572 | sockets_created, |
3821 | addrs, | 3573 | addrs, |
3822 | addrlens, | 3574 | addrlens, |
@@ -3869,64 +3621,55 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
3869 | 3621 | ||
3870 | /* Get port number: port == 0 : autodetect a port, | 3622 | /* Get port number: port == 0 : autodetect a port, |
3871 | * > 0 : use this port, not given : 2086 default */ | 3623 | * > 0 : use this port, not given : 2086 default */ |
3872 | if (GNUNET_OK != | 3624 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (env->cfg, |
3873 | GNUNET_CONFIGURATION_get_value_number (env->cfg, | 3625 | "transport-udp", |
3874 | "transport-udp", | 3626 | "PORT", |
3875 | "PORT", | 3627 | &port)) |
3876 | &port)) | ||
3877 | port = 2086; | 3628 | port = 2086; |
3878 | if (port > 65535) | 3629 | if (port > 65535) |
3879 | { | 3630 | { |
3880 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, | 3631 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, |
3881 | "transport-udp", | 3632 | "transport-udp", |
3882 | "PORT", | 3633 | "PORT", |
3883 | _("must be in [0,65535]")); | 3634 | _ ("must be in [0,65535]")); |
3884 | return NULL; | 3635 | return NULL; |
3885 | } | 3636 | } |
3886 | if (GNUNET_OK != | 3637 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (env->cfg, |
3887 | GNUNET_CONFIGURATION_get_value_number (env->cfg, | 3638 | "transport-udp", |
3888 | "transport-udp", | 3639 | "ADVERTISED_PORT", |
3889 | "ADVERTISED_PORT", | 3640 | &aport)) |
3890 | &aport)) | ||
3891 | aport = port; | 3641 | aport = port; |
3892 | if (aport > 65535) | 3642 | if (aport > 65535) |
3893 | { | 3643 | { |
3894 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, | 3644 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, |
3895 | "transport-udp", | 3645 | "transport-udp", |
3896 | "ADVERTISED_PORT", | 3646 | "ADVERTISED_PORT", |
3897 | _("must be in [0,65535]")); | 3647 | _ ("must be in [0,65535]")); |
3898 | return NULL; | 3648 | return NULL; |
3899 | } | 3649 | } |
3900 | 3650 | ||
3901 | if (GNUNET_YES == | 3651 | if (GNUNET_YES == |
3902 | GNUNET_CONFIGURATION_get_value_yesno (env->cfg, | 3652 | GNUNET_CONFIGURATION_get_value_yesno (env->cfg, "nat", "DISABLEV6")) |
3903 | "nat", | ||
3904 | "DISABLEV6")) | ||
3905 | enable_v6 = GNUNET_NO; | 3653 | enable_v6 = GNUNET_NO; |
3906 | else | 3654 | else |
3907 | enable_v6 = GNUNET_YES; | 3655 | enable_v6 = GNUNET_YES; |
3908 | 3656 | ||
3909 | have_bind4 = GNUNET_NO; | 3657 | have_bind4 = GNUNET_NO; |
3910 | memset (&server_addrv4, | 3658 | memset (&server_addrv4, 0, sizeof (server_addrv4)); |
3911 | 0, | 3659 | if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (env->cfg, |
3912 | sizeof (server_addrv4)); | 3660 | "transport-udp", |
3913 | if (GNUNET_YES == | 3661 | "BINDTO", |
3914 | GNUNET_CONFIGURATION_get_value_string (env->cfg, | 3662 | &bind4_address)) |
3915 | "transport-udp", | ||
3916 | "BINDTO", | ||
3917 | &bind4_address)) | ||
3918 | { | 3663 | { |
3919 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 3664 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
3920 | "Binding UDP plugin to specific address: `%s'\n", | 3665 | "Binding UDP plugin to specific address: `%s'\n", |
3921 | bind4_address); | 3666 | bind4_address); |
3922 | if (1 != inet_pton (AF_INET, | 3667 | if (1 != inet_pton (AF_INET, bind4_address, &server_addrv4.sin_addr)) |
3923 | bind4_address, | ||
3924 | &server_addrv4.sin_addr)) | ||
3925 | { | 3668 | { |
3926 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, | 3669 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, |
3927 | "transport-udp", | 3670 | "transport-udp", |
3928 | "BINDTO", | 3671 | "BINDTO", |
3929 | _("must be valid IPv4 address")); | 3672 | _ ("must be valid IPv4 address")); |
3930 | GNUNET_free (bind4_address); | 3673 | GNUNET_free (bind4_address); |
3931 | return NULL; | 3674 | return NULL; |
3932 | } | 3675 | } |
@@ -3934,26 +3677,21 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
3934 | } | 3677 | } |
3935 | GNUNET_free_non_null (bind4_address); | 3678 | GNUNET_free_non_null (bind4_address); |
3936 | have_bind6 = GNUNET_NO; | 3679 | have_bind6 = GNUNET_NO; |
3937 | memset (&server_addrv6, | 3680 | memset (&server_addrv6, 0, sizeof (server_addrv6)); |
3938 | 0, | 3681 | if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (env->cfg, |
3939 | sizeof (server_addrv6)); | 3682 | "transport-udp", |
3940 | if (GNUNET_YES == | 3683 | "BINDTO6", |
3941 | GNUNET_CONFIGURATION_get_value_string (env->cfg, | 3684 | &bind6_address)) |
3942 | "transport-udp", | ||
3943 | "BINDTO6", | ||
3944 | &bind6_address)) | ||
3945 | { | 3685 | { |
3946 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 3686 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
3947 | "Binding udp plugin to specific address: `%s'\n", | 3687 | "Binding udp plugin to specific address: `%s'\n", |
3948 | bind6_address); | 3688 | bind6_address); |
3949 | if (1 != inet_pton (AF_INET6, | 3689 | if (1 != inet_pton (AF_INET6, bind6_address, &server_addrv6.sin6_addr)) |
3950 | bind6_address, | ||
3951 | &server_addrv6.sin6_addr)) | ||
3952 | { | 3690 | { |
3953 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, | 3691 | GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR, |
3954 | "transport-udp", | 3692 | "transport-udp", |
3955 | "BINDTO6", | 3693 | "BINDTO6", |
3956 | _("must be valid IPv6 address")); | 3694 | _ ("must be valid IPv6 address")); |
3957 | GNUNET_free (bind6_address); | 3695 | GNUNET_free (bind6_address); |
3958 | return NULL; | 3696 | return NULL; |
3959 | } | 3697 | } |
@@ -3967,9 +3705,10 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
3967 | if (enable_broadcasting == GNUNET_SYSERR) | 3705 | if (enable_broadcasting == GNUNET_SYSERR) |
3968 | enable_broadcasting = GNUNET_NO; | 3706 | enable_broadcasting = GNUNET_NO; |
3969 | 3707 | ||
3970 | enable_broadcasting_recv = GNUNET_CONFIGURATION_get_value_yesno (env->cfg, | 3708 | enable_broadcasting_recv = |
3971 | "transport-udp", | 3709 | GNUNET_CONFIGURATION_get_value_yesno (env->cfg, |
3972 | "BROADCAST_RECEIVE"); | 3710 | "transport-udp", |
3711 | "BROADCAST_RECEIVE"); | ||
3973 | if (enable_broadcasting_recv == GNUNET_SYSERR) | 3712 | if (enable_broadcasting_recv == GNUNET_SYSERR) |
3974 | enable_broadcasting_recv = GNUNET_YES; | 3713 | enable_broadcasting_recv = GNUNET_YES; |
3975 | 3714 | ||
@@ -3979,14 +3718,12 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
3979 | "BROADCAST_INTERVAL", | 3718 | "BROADCAST_INTERVAL", |
3980 | &interval)) | 3719 | &interval)) |
3981 | { | 3720 | { |
3982 | interval = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | 3721 | interval = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10); |
3983 | 10); | ||
3984 | } | 3722 | } |
3985 | if (GNUNET_OK != | 3723 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (env->cfg, |
3986 | GNUNET_CONFIGURATION_get_value_number (env->cfg, | 3724 | "transport-udp", |
3987 | "transport-udp", | 3725 | "MAX_BPS", |
3988 | "MAX_BPS", | 3726 | &udp_max_bps)) |
3989 | &udp_max_bps)) | ||
3990 | { | 3727 | { |
3991 | /* 50 MB/s == infinity for practical purposes */ | 3728 | /* 50 MB/s == infinity for practical purposes */ |
3992 | udp_max_bps = 1024 * 1024 * 50; | 3729 | udp_max_bps = 1024 * 1024 * 50; |
@@ -4001,23 +3738,21 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
4001 | p->enable_broadcasting = enable_broadcasting; | 3738 | p->enable_broadcasting = enable_broadcasting; |
4002 | p->enable_broadcasting_receiving = enable_broadcasting_recv; | 3739 | p->enable_broadcasting_receiving = enable_broadcasting_recv; |
4003 | p->env = env; | 3740 | p->env = env; |
4004 | p->sessions = GNUNET_CONTAINER_multipeermap_create (16, | 3741 | p->sessions = GNUNET_CONTAINER_multipeermap_create (16, GNUNET_NO); |
4005 | GNUNET_NO); | 3742 | p->defrag_ctxs = |
4006 | p->defrag_ctxs = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); | 3743 | GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); |
4007 | GNUNET_BANDWIDTH_tracker_init (&p->tracker, | 3744 | GNUNET_BANDWIDTH_tracker_init (&p->tracker, |
4008 | NULL, | 3745 | NULL, |
4009 | NULL, | 3746 | NULL, |
4010 | GNUNET_BANDWIDTH_value_init ((uint32_t) udp_max_bps), | 3747 | GNUNET_BANDWIDTH_value_init ( |
3748 | (uint32_t) udp_max_bps), | ||
4011 | 30); | 3749 | 30); |
4012 | res = setup_sockets (p, | 3750 | res = setup_sockets (p, |
4013 | (GNUNET_YES == have_bind6) ? &server_addrv6 : NULL, | 3751 | (GNUNET_YES == have_bind6) ? &server_addrv6 : NULL, |
4014 | (GNUNET_YES == have_bind4) ? &server_addrv4 : NULL); | 3752 | (GNUNET_YES == have_bind4) ? &server_addrv4 : NULL); |
4015 | if ( (0 == res) || | 3753 | if ((0 == res) || ((NULL == p->sockv4) && (NULL == p->sockv6))) |
4016 | ( (NULL == p->sockv4) && | ||
4017 | (NULL == p->sockv6) ) ) | ||
4018 | { | 3754 | { |
4019 | LOG (GNUNET_ERROR_TYPE_ERROR, | 3755 | LOG (GNUNET_ERROR_TYPE_ERROR, _ ("Failed to create UDP network sockets\n")); |
4020 | _("Failed to create UDP network sockets\n")); | ||
4021 | GNUNET_CONTAINER_multipeermap_destroy (p->sessions); | 3756 | GNUNET_CONTAINER_multipeermap_destroy (p->sessions); |
4022 | GNUNET_CONTAINER_heap_destroy (p->defrag_ctxs); | 3757 | GNUNET_CONTAINER_heap_destroy (p->defrag_ctxs); |
4023 | if (NULL != p->nat) | 3758 | if (NULL != p->nat) |
@@ -4027,9 +3762,7 @@ libgnunet_plugin_transport_udp_init (void *cls) | |||
4027 | } | 3762 | } |
4028 | 3763 | ||
4029 | /* Setup broadcasting and receiving beacons */ | 3764 | /* Setup broadcasting and receiving beacons */ |
4030 | setup_broadcast (p, | 3765 | setup_broadcast (p, &server_addrv6, &server_addrv4); |
4031 | &server_addrv6, | ||
4032 | &server_addrv4); | ||
4033 | 3766 | ||
4034 | api = GNUNET_new (struct GNUNET_TRANSPORT_PluginFunctions); | 3767 | api = GNUNET_new (struct GNUNET_TRANSPORT_PluginFunctions); |
4035 | api->cls = p; | 3768 | api->cls = p; |
@@ -4108,14 +3841,12 @@ libgnunet_plugin_transport_udp_done (void *cls) | |||
4108 | } | 3841 | } |
4109 | if (NULL != plugin->sockv4) | 3842 | if (NULL != plugin->sockv4) |
4110 | { | 3843 | { |
4111 | GNUNET_break (GNUNET_OK == | 3844 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (plugin->sockv4)); |
4112 | GNUNET_NETWORK_socket_close (plugin->sockv4)); | ||
4113 | plugin->sockv4 = NULL; | 3845 | plugin->sockv4 = NULL; |
4114 | } | 3846 | } |
4115 | if (NULL != plugin->sockv6) | 3847 | if (NULL != plugin->sockv6) |
4116 | { | 3848 | { |
4117 | GNUNET_break (GNUNET_OK == | 3849 | GNUNET_break (GNUNET_OK == GNUNET_NETWORK_socket_close (plugin->sockv6)); |
4118 | GNUNET_NETWORK_socket_close (plugin->sockv6)); | ||
4119 | plugin->sockv6 = NULL; | 3850 | plugin->sockv6 = NULL; |
4120 | } | 3851 | } |
4121 | if (NULL != plugin->nat) | 3852 | if (NULL != plugin->nat) |
@@ -4133,20 +3864,14 @@ libgnunet_plugin_transport_udp_done (void *cls) | |||
4133 | } | 3864 | } |
4134 | while (NULL != (udpw = plugin->ipv4_queue_head)) | 3865 | while (NULL != (udpw = plugin->ipv4_queue_head)) |
4135 | { | 3866 | { |
4136 | dequeue (plugin, | 3867 | dequeue (plugin, udpw); |
4137 | udpw); | 3868 | udpw->qc (udpw->qc_cls, udpw, GNUNET_SYSERR); |
4138 | udpw->qc (udpw->qc_cls, | ||
4139 | udpw, | ||
4140 | GNUNET_SYSERR); | ||
4141 | GNUNET_free (udpw); | 3869 | GNUNET_free (udpw); |
4142 | } | 3870 | } |
4143 | while (NULL != (udpw = plugin->ipv6_queue_head)) | 3871 | while (NULL != (udpw = plugin->ipv6_queue_head)) |
4144 | { | 3872 | { |
4145 | dequeue (plugin, | 3873 | dequeue (plugin, udpw); |
4146 | udpw); | 3874 | udpw->qc (udpw->qc_cls, udpw, GNUNET_SYSERR); |
4147 | udpw->qc (udpw->qc_cls, | ||
4148 | udpw, | ||
4149 | GNUNET_SYSERR); | ||
4150 | GNUNET_free (udpw); | 3875 | GNUNET_free (udpw); |
4151 | } | 3876 | } |
4152 | GNUNET_CONTAINER_multipeermap_iterate (plugin->sessions, | 3877 | GNUNET_CONTAINER_multipeermap_iterate (plugin->sessions, |