diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
commit | 5746309cb4be2073d550ad7a6885e918631dbc38 (patch) | |
tree | 89455bc4aadf977816b38df13f990372cd81d71a /src/transport/plugin_transport_http.c | |
parent | 6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff) | |
download | gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip |
indentation
Diffstat (limited to 'src/transport/plugin_transport_http.c')
-rw-r--r-- | src/transport/plugin_transport_http.c | 476 |
1 files changed, 204 insertions, 272 deletions
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index 0c856e4ab..a6b24e73e 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c | |||
@@ -547,8 +547,7 @@ struct PrettyPrinterContext | |||
547 | * @param addrlen length of the address | 547 | * @param addrlen length of the address |
548 | * @return string representing the same address | 548 | * @return string representing the same address |
549 | */ | 549 | */ |
550 | static const char *http_plugin_address_to_string (void *cls, | 550 | static const char *http_plugin_address_to_string (void *cls, const void *addr, |
551 | const void *addr, | ||
552 | size_t addrlen); | 551 | size_t addrlen); |
553 | 552 | ||
554 | 553 | ||
@@ -618,8 +617,7 @@ create_url (struct Plugin *plugin, const void *addr, size_t addrlen, size_t id) | |||
618 | char *addr_str = (char *) http_plugin_address_to_string (NULL, addr, addrlen); | 617 | char *addr_str = (char *) http_plugin_address_to_string (NULL, addr, addrlen); |
619 | 618 | ||
620 | GNUNET_assert ((addr != NULL) && (addrlen != 0)); | 619 | GNUNET_assert ((addr != NULL) && (addrlen != 0)); |
621 | GNUNET_asprintf (&url, | 620 | GNUNET_asprintf (&url, "%s://%s/%s;%u", PROTOCOL_PREFIX, addr_str, |
622 | "%s://%s/%s;%u", PROTOCOL_PREFIX, addr_str, | ||
623 | (char *) (&plugin->my_ascii_hash_ident), id); | 621 | (char *) (&plugin->my_ascii_hash_ident), id); |
624 | return url; | 622 | return url; |
625 | } | 623 | } |
@@ -634,8 +632,8 @@ create_url (struct Plugin *plugin, const void *addr, size_t addrlen, size_t id) | |||
634 | static int | 632 | static int |
635 | remove_http_message (struct Session *ps, struct HTTP_Message *msg) | 633 | remove_http_message (struct Session *ps, struct HTTP_Message *msg) |
636 | { | 634 | { |
637 | GNUNET_CONTAINER_DLL_remove (ps->pending_msgs_head, | 635 | GNUNET_CONTAINER_DLL_remove (ps->pending_msgs_head, ps->pending_msgs_tail, |
638 | ps->pending_msgs_tail, msg); | 636 | msg); |
639 | GNUNET_free (msg); | 637 | GNUNET_free (msg); |
640 | return GNUNET_OK; | 638 | return GNUNET_OK; |
641 | } | 639 | } |
@@ -648,8 +646,8 @@ remove_http_message (struct Session *ps, struct HTTP_Message *msg) | |||
648 | * @return GNUNET_YES on success | 646 | * @return GNUNET_YES on success |
649 | */ | 647 | */ |
650 | static int | 648 | static int |
651 | remove_peer_context_Iterator (void *cls, | 649 | remove_peer_context_Iterator (void *cls, const GNUNET_HashCode * key, |
652 | const GNUNET_HashCode * key, void *value) | 650 | void *value) |
653 | { | 651 | { |
654 | struct Plugin *plugin = cls; | 652 | struct Plugin *plugin = cls; |
655 | struct HTTP_PeerContext *pc = value; | 653 | struct HTTP_PeerContext *pc = value; |
@@ -659,8 +657,8 @@ remove_peer_context_Iterator (void *cls, | |||
659 | struct HTTP_Message *msg_tmp = NULL; | 657 | struct HTTP_Message *msg_tmp = NULL; |
660 | 658 | ||
661 | #if DEBUG_HTTP | 659 | #if DEBUG_HTTP |
662 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 660 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Freeing context for peer `%s'\n", |
663 | "Freeing context for peer `%s'\n", GNUNET_i2s (&pc->identity)); | 661 | GNUNET_i2s (&pc->identity)); |
664 | #endif | 662 | #endif |
665 | GNUNET_assert (GNUNET_YES == | 663 | GNUNET_assert (GNUNET_YES == |
666 | GNUNET_CONTAINER_multihashmap_remove (plugin->peers, | 664 | GNUNET_CONTAINER_multihashmap_remove (plugin->peers, |
@@ -695,8 +693,8 @@ remove_peer_context_Iterator (void *cls, | |||
695 | } | 693 | } |
696 | GNUNET_free (pc); | 694 | GNUNET_free (pc); |
697 | GNUNET_STATISTICS_update (plugin->env->stats, | 695 | GNUNET_STATISTICS_update (plugin->env->stats, |
698 | gettext_noop ("# HTTP peers active"), | 696 | gettext_noop ("# HTTP peers active"), -1, |
699 | -1, GNUNET_NO); | 697 | GNUNET_NO); |
700 | return GNUNET_YES; | 698 | return GNUNET_YES; |
701 | } | 699 | } |
702 | 700 | ||
@@ -710,18 +708,17 @@ remove_peer_context_Iterator (void *cls, | |||
710 | * @return GNUNET_SYSERR if msg not found, GNUNET_OK on success | 708 | * @return GNUNET_SYSERR if msg not found, GNUNET_OK on success |
711 | */ | 709 | */ |
712 | static int | 710 | static int |
713 | remove_session (struct HTTP_PeerContext *pc, | 711 | remove_session (struct HTTP_PeerContext *pc, struct Session *ps, |
714 | struct Session *ps, int call_msg_cont, int call_msg_cont_result) | 712 | int call_msg_cont, int call_msg_cont_result) |
715 | { | 713 | { |
716 | struct HTTP_Message *msg; | 714 | struct HTTP_Message *msg; |
717 | struct Plugin *plugin = ps->peercontext->plugin; | 715 | struct Plugin *plugin = ps->peercontext->plugin; |
718 | 716 | ||
719 | #if DEBUG_CONNECTIONS | 717 | #if DEBUG_CONNECTIONS |
720 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 718 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
721 | "Connection %X: removing %s session %X with id %u\n", | 719 | "Connection %X: removing %s session %X with id %u\n", ps, |
722 | ps, | 720 | (ps->direction == INBOUND) ? "inbound" : "outbound", ps, |
723 | (ps->direction == INBOUND) | 721 | ps->session_id); |
724 | ? "inbound" : "outbound", ps, ps->session_id); | ||
725 | #endif | 722 | #endif |
726 | plugin->env->session_end (plugin, &pc->identity, ps); | 723 | plugin->env->session_end (plugin, &pc->identity, ps); |
727 | GNUNET_free_non_null (ps->addr); | 724 | GNUNET_free_non_null (ps->addr); |
@@ -746,11 +743,11 @@ remove_session (struct HTTP_PeerContext *pc, | |||
746 | { | 743 | { |
747 | if ((call_msg_cont == GNUNET_YES) && (msg->transmit_cont != NULL)) | 744 | if ((call_msg_cont == GNUNET_YES) && (msg->transmit_cont != NULL)) |
748 | { | 745 | { |
749 | msg->transmit_cont (msg->transmit_cont_cls, | 746 | msg->transmit_cont (msg->transmit_cont_cls, &pc->identity, |
750 | &pc->identity, call_msg_cont_result); | 747 | call_msg_cont_result); |
751 | } | 748 | } |
752 | GNUNET_CONTAINER_DLL_remove (ps->pending_msgs_head, | 749 | GNUNET_CONTAINER_DLL_remove (ps->pending_msgs_head, ps->pending_msgs_head, |
753 | ps->pending_msgs_head, msg); | 750 | msg); |
754 | GNUNET_free (msg); | 751 | GNUNET_free (msg); |
755 | msg = ps->pending_msgs_head; | 752 | msg = ps->pending_msgs_head; |
756 | } | 753 | } |
@@ -795,8 +792,8 @@ check_localaddress (const struct sockaddr *addr, socklen_t addrlen) | |||
795 | else | 792 | else |
796 | local = GNUNET_YES; | 793 | local = GNUNET_YES; |
797 | #if DEBUG_HTTP | 794 | #if DEBUG_HTTP |
798 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 795 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking IPv4 address `%s': %s\n", |
799 | "Checking IPv4 address `%s': %s\n", GNUNET_a2s (addr, addrlen), | 796 | GNUNET_a2s (addr, addrlen), |
800 | (local == GNUNET_YES) ? "local" : "global"); | 797 | (local == GNUNET_YES) ? "local" : "global"); |
801 | #endif | 798 | #endif |
802 | break; | 799 | break; |
@@ -809,8 +806,8 @@ check_localaddress (const struct sockaddr *addr, socklen_t addrlen) | |||
809 | else | 806 | else |
810 | local = GNUNET_NO; | 807 | local = GNUNET_NO; |
811 | #if DEBUG_HTTP | 808 | #if DEBUG_HTTP |
812 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 809 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Checking IPv6 address `%s' : %s\n", |
813 | "Checking IPv6 address `%s' : %s\n", GNUNET_a2s (addr, addrlen), | 810 | GNUNET_a2s (addr, addrlen), |
814 | (local == GNUNET_YES) ? "local" : "global"); | 811 | (local == GNUNET_YES) ? "local" : "global"); |
815 | #endif | 812 | #endif |
816 | break; | 813 | break; |
@@ -832,9 +829,7 @@ check_localaddress (const struct sockaddr *addr, socklen_t addrlen) | |||
832 | * @return GNUNET_OK to continue iterating | 829 | * @return GNUNET_OK to continue iterating |
833 | */ | 830 | */ |
834 | static int | 831 | static int |
835 | process_interfaces (void *cls, | 832 | process_interfaces (void *cls, const char *name, int isDefault, |
836 | const char *name, | ||
837 | int isDefault, | ||
838 | const struct sockaddr *addr, socklen_t addrlen) | 833 | const struct sockaddr *addr, socklen_t addrlen) |
839 | { | 834 | { |
840 | struct Plugin *plugin = cls; | 835 | struct Plugin *plugin = cls; |
@@ -847,8 +842,7 @@ process_interfaces (void *cls, | |||
847 | if (GNUNET_YES == check_localaddress (addr, addrlen)) | 842 | if (GNUNET_YES == check_localaddress (addr, addrlen)) |
848 | { | 843 | { |
849 | #if DEBUG_HTTP | 844 | #if DEBUG_HTTP |
850 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, | 845 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, PROTOCOL_PREFIX, |
851 | PROTOCOL_PREFIX, | ||
852 | "Not notifying transport of address `%s' (local address)\n", | 846 | "Not notifying transport of address `%s' (local address)\n", |
853 | GNUNET_a2s (addr, addrlen)); | 847 | GNUNET_a2s (addr, addrlen)); |
854 | #endif | 848 | #endif |
@@ -859,8 +853,8 @@ process_interfaces (void *cls, | |||
859 | 853 | ||
860 | GNUNET_assert (cls != NULL); | 854 | GNUNET_assert (cls != NULL); |
861 | af = addr->sa_family; | 855 | af = addr->sa_family; |
862 | if ((af == AF_INET) && | 856 | if ((af == AF_INET) && (plugin->use_ipv4 == GNUNET_YES) && |
863 | (plugin->use_ipv4 == GNUNET_YES) && (plugin->bind6_address == NULL)) | 857 | (plugin->bind6_address == NULL)) |
864 | { | 858 | { |
865 | 859 | ||
866 | struct in_addr bnd_cmp = ((struct sockaddr_in *) addr)->sin_addr; | 860 | struct in_addr bnd_cmp = ((struct sockaddr_in *) addr)->sin_addr; |
@@ -879,9 +873,8 @@ process_interfaces (void *cls, | |||
879 | { | 873 | { |
880 | GNUNET_CONTAINER_DLL_insert (plugin->ipv4_addr_head, | 874 | GNUNET_CONTAINER_DLL_insert (plugin->ipv4_addr_head, |
881 | plugin->ipv4_addr_tail, t4); | 875 | plugin->ipv4_addr_tail, t4); |
882 | plugin->env->notify_address (plugin->env->cls, | 876 | plugin->env->notify_address (plugin->env->cls, GNUNET_YES, t4, |
883 | GNUNET_YES, | 877 | sizeof (struct IPv4HttpAddress)); |
884 | t4, sizeof (struct IPv4HttpAddress)); | ||
885 | return GNUNET_OK; | 878 | return GNUNET_OK; |
886 | } | 879 | } |
887 | GNUNET_free (t4); | 880 | GNUNET_free (t4); |
@@ -891,14 +884,13 @@ process_interfaces (void *cls, | |||
891 | { | 884 | { |
892 | GNUNET_CONTAINER_DLL_insert (plugin->ipv4_addr_head, | 885 | GNUNET_CONTAINER_DLL_insert (plugin->ipv4_addr_head, |
893 | plugin->ipv4_addr_tail, t4); | 886 | plugin->ipv4_addr_tail, t4); |
894 | plugin->env->notify_address (plugin->env->cls, | 887 | plugin->env->notify_address (plugin->env->cls, GNUNET_YES, t4, |
895 | GNUNET_YES, | 888 | sizeof (struct IPv4HttpAddress)); |
896 | t4, sizeof (struct IPv4HttpAddress)); | ||
897 | return GNUNET_OK; | 889 | return GNUNET_OK; |
898 | } | 890 | } |
899 | } | 891 | } |
900 | if ((af == AF_INET6) && | 892 | if ((af == AF_INET6) && (plugin->use_ipv6 == GNUNET_YES) && |
901 | (plugin->use_ipv6 == GNUNET_YES) && (plugin->bind4_address == NULL)) | 893 | (plugin->bind4_address == NULL)) |
902 | { | 894 | { |
903 | 895 | ||
904 | struct in6_addr bnd_cmp6 = ((struct sockaddr_in6 *) addr)->sin6_addr; | 896 | struct in6_addr bnd_cmp6 = ((struct sockaddr_in6 *) addr)->sin6_addr; |
@@ -908,16 +900,15 @@ process_interfaces (void *cls, | |||
908 | 900 | ||
909 | if (plugin->bind6_address != NULL) | 901 | if (plugin->bind6_address != NULL) |
910 | { | 902 | { |
911 | if (0 == memcmp (&plugin->bind6_address->sin6_addr, | 903 | if (0 == |
912 | &bnd_cmp6, sizeof (struct in6_addr))) | 904 | memcmp (&plugin->bind6_address->sin6_addr, &bnd_cmp6, |
905 | sizeof (struct in6_addr))) | ||
913 | { | 906 | { |
914 | memcpy (&t6->ipv6_addr, | 907 | memcpy (&t6->ipv6_addr, &((struct sockaddr_in6 *) addr)->sin6_addr, |
915 | &((struct sockaddr_in6 *) addr)->sin6_addr, | ||
916 | sizeof (struct in6_addr)); | 908 | sizeof (struct in6_addr)); |
917 | t6->port = htons (plugin->port_inbound); | 909 | t6->port = htons (plugin->port_inbound); |
918 | plugin->env->notify_address (plugin->env->cls, | 910 | plugin->env->notify_address (plugin->env->cls, GNUNET_YES, t6, |
919 | GNUNET_YES, | 911 | sizeof (struct IPv6HttpAddress)); |
920 | t6, sizeof (struct IPv6HttpAddress)); | ||
921 | GNUNET_CONTAINER_DLL_insert (plugin->ipv6_addr_head, | 912 | GNUNET_CONTAINER_DLL_insert (plugin->ipv6_addr_head, |
922 | plugin->ipv6_addr_tail, t6); | 913 | plugin->ipv6_addr_tail, t6); |
923 | return GNUNET_OK; | 914 | return GNUNET_OK; |
@@ -925,16 +916,14 @@ process_interfaces (void *cls, | |||
925 | GNUNET_free (t6); | 916 | GNUNET_free (t6); |
926 | return GNUNET_OK; | 917 | return GNUNET_OK; |
927 | } | 918 | } |
928 | memcpy (&t6->ipv6_addr, | 919 | memcpy (&t6->ipv6_addr, &((struct sockaddr_in6 *) addr)->sin6_addr, |
929 | &((struct sockaddr_in6 *) addr)->sin6_addr, | ||
930 | sizeof (struct in6_addr)); | 920 | sizeof (struct in6_addr)); |
931 | t6->port = htons (plugin->port_inbound); | 921 | t6->port = htons (plugin->port_inbound); |
932 | GNUNET_CONTAINER_DLL_insert (plugin->ipv6_addr_head, plugin->ipv6_addr_tail, | 922 | GNUNET_CONTAINER_DLL_insert (plugin->ipv6_addr_head, plugin->ipv6_addr_tail, |
933 | t6); | 923 | t6); |
934 | 924 | ||
935 | plugin->env->notify_address (plugin->env->cls, | 925 | plugin->env->notify_address (plugin->env->cls, GNUNET_YES, t6, |
936 | GNUNET_YES, | 926 | sizeof (struct IPv6HttpAddress)); |
937 | t6, sizeof (struct IPv6HttpAddress)); | ||
938 | } | 927 | } |
939 | return GNUNET_OK; | 928 | return GNUNET_OK; |
940 | } | 929 | } |
@@ -958,8 +947,8 @@ mhd_logger (void *arg, const char *fmt, va_list ap) | |||
958 | 947 | ||
959 | 948 | ||
960 | static void | 949 | static void |
961 | mhd_termination_cb (void *cls, | 950 | mhd_termination_cb (void *cls, struct MHD_Connection *connection, |
962 | struct MHD_Connection *connection, void **httpSessionCache) | 951 | void **httpSessionCache) |
963 | { | 952 | { |
964 | struct Session *ps = *httpSessionCache; | 953 | struct Session *ps = *httpSessionCache; |
965 | 954 | ||
@@ -1013,8 +1002,8 @@ mhd_termination_cb (void *cls, | |||
1013 | * @param message the message to be forwarded to transport service | 1002 | * @param message the message to be forwarded to transport service |
1014 | */ | 1003 | */ |
1015 | static void | 1004 | static void |
1016 | mhd_write_mst_cb (void *cls, | 1005 | mhd_write_mst_cb (void *cls, void *client, |
1017 | void *client, const struct GNUNET_MessageHeader *message) | 1006 | const struct GNUNET_MessageHeader *message) |
1018 | { | 1007 | { |
1019 | struct Session *ps = cls; | 1008 | struct Session *ps = cls; |
1020 | struct HTTP_PeerContext *pc; | 1009 | struct HTTP_PeerContext *pc; |
@@ -1026,9 +1015,7 @@ mhd_write_mst_cb (void *cls, | |||
1026 | #if DEBUG_HTTP | 1015 | #if DEBUG_HTTP |
1027 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1016 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1028 | "Connection %X: Forwarding message to transport service, type %u and size %u from `%s' (`%s')\n", | 1017 | "Connection %X: Forwarding message to transport service, type %u and size %u from `%s' (`%s')\n", |
1029 | ps, | 1018 | ps, ntohs (message->type), ntohs (message->size), |
1030 | ntohs (message->type), | ||
1031 | ntohs (message->size), | ||
1032 | GNUNET_i2s (&(ps->peercontext)->identity), | 1019 | GNUNET_i2s (&(ps->peercontext)->identity), |
1033 | http_plugin_address_to_string (NULL, ps->addr, ps->addrlen)); | 1020 | http_plugin_address_to_string (NULL, ps->addr, ps->addrlen)); |
1034 | #endif | 1021 | #endif |
@@ -1038,12 +1025,11 @@ mhd_write_mst_cb (void *cls, | |||
1038 | distance[0].value = htonl (1); | 1025 | distance[0].value = htonl (1); |
1039 | distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); | 1026 | distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); |
1040 | distance[1].value = htonl (0); | 1027 | distance[1].value = htonl (0); |
1041 | delay = pc->plugin->env->receive (ps->peercontext->plugin->env->cls, | 1028 | delay = |
1042 | &pc->identity, | 1029 | pc->plugin->env->receive (ps->peercontext->plugin->env->cls, |
1043 | message, | 1030 | &pc->identity, message, |
1044 | (const struct | 1031 | (const struct GNUNET_TRANSPORT_ATS_Information |
1045 | GNUNET_TRANSPORT_ATS_Information *) | 1032 | *) &distance, 2, ps, NULL, 0); |
1046 | &distance, 2, ps, NULL, 0); | ||
1047 | pc->delay = delay; | 1033 | pc->delay = delay; |
1048 | if (pc->reset_task != GNUNET_SCHEDULER_NO_TASK) | 1034 | if (pc->reset_task != GNUNET_SCHEDULER_NO_TASK) |
1049 | GNUNET_SCHEDULER_cancel (pc->reset_task); | 1035 | GNUNET_SCHEDULER_cancel (pc->reset_task); |
@@ -1142,8 +1128,8 @@ mhd_send_callback (void *cls, uint64_t pos, char *buf, size_t max) | |||
1142 | } | 1128 | } |
1143 | } | 1129 | } |
1144 | #if DEBUG_CONNECTIONS | 1130 | #if DEBUG_CONNECTIONS |
1145 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1131 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection %X: MHD has sent %u bytes\n", |
1146 | "Connection %X: MHD has sent %u bytes\n", ps, bytes_read); | 1132 | ps, bytes_read); |
1147 | #endif | 1133 | #endif |
1148 | return bytes_read; | 1134 | return bytes_read; |
1149 | } | 1135 | } |
@@ -1157,13 +1143,10 @@ mhd_send_callback (void *cls, uint64_t pos, char *buf, size_t max) | |||
1157 | * already exists and create a new one if not. | 1143 | * already exists and create a new one if not. |
1158 | */ | 1144 | */ |
1159 | static int | 1145 | static int |
1160 | mhd_access_cb (void *cls, | 1146 | mhd_access_cb (void *cls, struct MHD_Connection *mhd_connection, |
1161 | struct MHD_Connection *mhd_connection, | 1147 | const char *url, const char *method, const char *version, |
1162 | const char *url, | 1148 | const char *upload_data, size_t * upload_data_size, |
1163 | const char *method, | 1149 | void **httpSessionCache) |
1164 | const char *version, | ||
1165 | const char *upload_data, | ||
1166 | size_t * upload_data_size, void **httpSessionCache) | ||
1167 | { | 1150 | { |
1168 | struct Plugin *plugin = cls; | 1151 | struct Plugin *plugin = cls; |
1169 | struct MHD_Response *response; | 1152 | struct MHD_Response *response; |
@@ -1205,9 +1188,9 @@ mhd_access_cb (void *cls, | |||
1205 | GNUNET_free (peer); | 1188 | GNUNET_free (peer); |
1206 | if (GNUNET_SYSERR == res) | 1189 | if (GNUNET_SYSERR == res) |
1207 | { | 1190 | { |
1208 | response = MHD_create_response_from_data (strlen (HTTP_ERROR_RESPONSE), | 1191 | response = |
1209 | HTTP_ERROR_RESPONSE, | 1192 | MHD_create_response_from_data (strlen (HTTP_ERROR_RESPONSE), |
1210 | MHD_NO, MHD_NO); | 1193 | HTTP_ERROR_RESPONSE, MHD_NO, MHD_NO); |
1211 | res = MHD_queue_response (mhd_connection, MHD_HTTP_NOT_FOUND, response); | 1194 | res = MHD_queue_response (mhd_connection, MHD_HTTP_NOT_FOUND, response); |
1212 | MHD_destroy_response (response); | 1195 | MHD_destroy_response (response); |
1213 | #if DEBUG_CONNECTIONS | 1196 | #if DEBUG_CONNECTIONS |
@@ -1240,12 +1223,11 @@ mhd_access_cb (void *cls, | |||
1240 | pc->last_session = NULL; | 1223 | pc->last_session = NULL; |
1241 | memcpy (&pc->identity, &pi_in, sizeof (struct GNUNET_PeerIdentity)); | 1224 | memcpy (&pc->identity, &pi_in, sizeof (struct GNUNET_PeerIdentity)); |
1242 | GNUNET_CONTAINER_multihashmap_put (plugin->peers, | 1225 | GNUNET_CONTAINER_multihashmap_put (plugin->peers, |
1243 | &pc->identity.hashPubKey, | 1226 | &pc->identity.hashPubKey, pc, |
1244 | pc, | ||
1245 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 1227 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
1246 | GNUNET_STATISTICS_update (plugin->env->stats, | 1228 | GNUNET_STATISTICS_update (plugin->env->stats, |
1247 | gettext_noop ("# HTTP peers active"), | 1229 | gettext_noop ("# HTTP peers active"), 1, |
1248 | 1, GNUNET_NO); | 1230 | GNUNET_NO); |
1249 | } | 1231 | } |
1250 | 1232 | ||
1251 | conn_info = | 1233 | conn_info = |
@@ -1329,9 +1311,7 @@ mhd_access_cb (void *cls, | |||
1329 | #if DEBUG_HTTP | 1311 | #if DEBUG_HTTP |
1330 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1312 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1331 | "Connection %X: HTTP Daemon has new an incoming `%s' request from peer `%s' (`%s')\n", | 1313 | "Connection %X: HTTP Daemon has new an incoming `%s' request from peer `%s' (`%s')\n", |
1332 | ps, | 1314 | ps, method, GNUNET_i2s (&pc->identity), |
1333 | method, | ||
1334 | GNUNET_i2s (&pc->identity), | ||
1335 | http_plugin_address_to_string (NULL, ps->addr, ps->addrlen)); | 1315 | http_plugin_address_to_string (NULL, ps->addr, ps->addrlen)); |
1336 | #endif | 1316 | #endif |
1337 | } | 1317 | } |
@@ -1365,9 +1345,9 @@ mhd_access_cb (void *cls, | |||
1365 | /* Transmission of all data complete */ | 1345 | /* Transmission of all data complete */ |
1366 | if ((*upload_data_size == 0) && (ps->recv_active == GNUNET_YES)) | 1346 | if ((*upload_data_size == 0) && (ps->recv_active == GNUNET_YES)) |
1367 | { | 1347 | { |
1368 | response = MHD_create_response_from_data (strlen (HTTP_PUT_RESPONSE), | 1348 | response = |
1369 | HTTP_PUT_RESPONSE, | 1349 | MHD_create_response_from_data (strlen (HTTP_PUT_RESPONSE), |
1370 | MHD_NO, MHD_NO); | 1350 | HTTP_PUT_RESPONSE, MHD_NO, MHD_NO); |
1371 | res = MHD_queue_response (mhd_connection, MHD_HTTP_OK, response); | 1351 | res = MHD_queue_response (mhd_connection, MHD_HTTP_OK, response); |
1372 | #if DEBUG_CONNECTIONS | 1352 | #if DEBUG_CONNECTIONS |
1373 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1353 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1385,12 +1365,12 @@ mhd_access_cb (void *cls, | |||
1385 | { | 1365 | { |
1386 | #if DEBUG_HTTP | 1366 | #if DEBUG_HTTP |
1387 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1367 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1388 | "Connection %X: PUT with %u bytes forwarded to MST\n", | 1368 | "Connection %X: PUT with %u bytes forwarded to MST\n", ps, |
1389 | ps, *upload_data_size); | 1369 | *upload_data_size); |
1390 | #endif | 1370 | #endif |
1391 | res = GNUNET_SERVER_mst_receive (ps->msgtok, ps, | 1371 | res = |
1392 | upload_data, *upload_data_size, | 1372 | GNUNET_SERVER_mst_receive (ps->msgtok, ps, upload_data, |
1393 | GNUNET_NO, GNUNET_NO); | 1373 | *upload_data_size, GNUNET_NO, GNUNET_NO); |
1394 | (*upload_data_size) = 0; | 1374 | (*upload_data_size) = 0; |
1395 | } | 1375 | } |
1396 | else | 1376 | else |
@@ -1485,11 +1465,10 @@ http_server_daemon_prepare (struct Plugin *plugin, | |||
1485 | plugin->http_server_daemon_v4 = GNUNET_SCHEDULER_NO_TASK; | 1465 | plugin->http_server_daemon_v4 = GNUNET_SCHEDULER_NO_TASK; |
1486 | } | 1466 | } |
1487 | 1467 | ||
1488 | ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, | 1468 | ret = |
1489 | GNUNET_SCHEDULER_NO_TASK, | 1469 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
1490 | tv, | 1470 | GNUNET_SCHEDULER_NO_TASK, tv, wrs, wws, |
1491 | wrs, | 1471 | &http_server_daemon_v4_run, plugin); |
1492 | wws, &http_server_daemon_v4_run, plugin); | ||
1493 | } | 1472 | } |
1494 | if (daemon_handle == plugin->http_server_daemon_v6) | 1473 | if (daemon_handle == plugin->http_server_daemon_v6) |
1495 | { | 1474 | { |
@@ -1499,11 +1478,10 @@ http_server_daemon_prepare (struct Plugin *plugin, | |||
1499 | plugin->http_server_task_v6 = GNUNET_SCHEDULER_NO_TASK; | 1478 | plugin->http_server_task_v6 = GNUNET_SCHEDULER_NO_TASK; |
1500 | } | 1479 | } |
1501 | 1480 | ||
1502 | ret = GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, | 1481 | ret = |
1503 | GNUNET_SCHEDULER_NO_TASK, | 1482 | GNUNET_SCHEDULER_add_select (GNUNET_SCHEDULER_PRIORITY_DEFAULT, |
1504 | tv, | 1483 | GNUNET_SCHEDULER_NO_TASK, tv, wrs, wws, |
1505 | wrs, | 1484 | &http_server_daemon_v6_run, plugin); |
1506 | wws, &http_server_daemon_v6_run, plugin); | ||
1507 | } | 1485 | } |
1508 | GNUNET_NETWORK_fdset_destroy (wrs); | 1486 | GNUNET_NETWORK_fdset_destroy (wrs); |
1509 | GNUNET_NETWORK_fdset_destroy (wws); | 1487 | GNUNET_NETWORK_fdset_destroy (wws); |
@@ -1643,8 +1621,8 @@ curl_get_header_cb (void *ptr, size_t size, size_t nmemb, void *stream) | |||
1643 | if (tmp[len - 2] == 13) | 1621 | if (tmp[len - 2] == 13) |
1644 | tmp[len - 2] = '\0'; | 1622 | tmp[len - 2] = '\0'; |
1645 | } | 1623 | } |
1646 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1624 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection %X: Header: %s\n", ps, |
1647 | "Connection %X: Header: %s\n", ps, tmp); | 1625 | tmp); |
1648 | } | 1626 | } |
1649 | GNUNET_free_non_null (tmp); | 1627 | GNUNET_free_non_null (tmp); |
1650 | #endif | 1628 | #endif |
@@ -1791,8 +1769,8 @@ curl_send_cb (void *stream, size_t size, size_t nmemb, void *ptr) | |||
1791 | 1769 | ||
1792 | 1770 | ||
1793 | static void | 1771 | static void |
1794 | curl_receive_mst_cb (void *cls, | 1772 | curl_receive_mst_cb (void *cls, void *client, |
1795 | void *client, const struct GNUNET_MessageHeader *message) | 1773 | const struct GNUNET_MessageHeader *message) |
1796 | { | 1774 | { |
1797 | struct Session *ps = cls; | 1775 | struct Session *ps = cls; |
1798 | struct GNUNET_TIME_Relative delay; | 1776 | struct GNUNET_TIME_Relative delay; |
@@ -1805,11 +1783,12 @@ curl_receive_mst_cb (void *cls, | |||
1805 | #if DEBUG_HTTP | 1783 | #if DEBUG_HTTP |
1806 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1784 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1807 | "Connection %X: Forwarding message to transport service, type %u and size %u from `%s' (`%s')\n", | 1785 | "Connection %X: Forwarding message to transport service, type %u and size %u from `%s' (`%s')\n", |
1808 | ps, | 1786 | ps, ntohs (message->type), ntohs (message->size), |
1809 | ntohs (message->type), | 1787 | GNUNET_i2s (&(pc->identity)), http_plugin_address_to_string (NULL, |
1810 | ntohs (message->size), | 1788 | ps-> |
1811 | GNUNET_i2s (&(pc->identity)), | 1789 | addr, |
1812 | http_plugin_address_to_string (NULL, ps->addr, ps->addrlen)); | 1790 | ps-> |
1791 | addrlen)); | ||
1813 | #endif | 1792 | #endif |
1814 | struct GNUNET_TRANSPORT_ATS_Information distance[2]; | 1793 | struct GNUNET_TRANSPORT_ATS_Information distance[2]; |
1815 | 1794 | ||
@@ -1818,12 +1797,10 @@ curl_receive_mst_cb (void *cls, | |||
1818 | distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); | 1797 | distance[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); |
1819 | distance[1].value = htonl (0); | 1798 | distance[1].value = htonl (0); |
1820 | 1799 | ||
1821 | delay = pc->plugin->env->receive (pc->plugin->env->cls, | 1800 | delay = |
1822 | &pc->identity, | 1801 | pc->plugin->env->receive (pc->plugin->env->cls, &pc->identity, message, |
1823 | message, | 1802 | (const struct GNUNET_TRANSPORT_ATS_Information |
1824 | (const struct | 1803 | *) &distance, 2, ps, ps->addr, ps->addrlen); |
1825 | GNUNET_TRANSPORT_ATS_Information *) | ||
1826 | &distance, 2, ps, ps->addr, ps->addrlen); | ||
1827 | pc->delay = delay; | 1804 | pc->delay = delay; |
1828 | if (pc->reset_task != GNUNET_SCHEDULER_NO_TASK) | 1805 | if (pc->reset_task != GNUNET_SCHEDULER_NO_TASK) |
1829 | GNUNET_SCHEDULER_cancel (pc->reset_task); | 1806 | GNUNET_SCHEDULER_cancel (pc->reset_task); |
@@ -1865,11 +1842,11 @@ curl_receive_cb (void *stream, size_t size, size_t nmemb, void *ptr) | |||
1865 | return 0; | 1842 | return 0; |
1866 | } | 1843 | } |
1867 | #if DEBUG_CONNECTIONS | 1844 | #if DEBUG_CONNECTIONS |
1868 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1845 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connection %X: %u bytes received\n", ps, |
1869 | "Connection %X: %u bytes received\n", ps, size * nmemb); | 1846 | size * nmemb); |
1870 | #endif | 1847 | #endif |
1871 | GNUNET_SERVER_mst_receive (ps->msgtok, ps, | 1848 | GNUNET_SERVER_mst_receive (ps->msgtok, ps, stream, size * nmemb, GNUNET_NO, |
1872 | stream, size * nmemb, GNUNET_NO, GNUNET_NO); | 1849 | GNUNET_NO); |
1873 | return (size * nmemb); | 1850 | return (size * nmemb); |
1874 | } | 1851 | } |
1875 | 1852 | ||
@@ -1958,8 +1935,7 @@ curl_handle_finished (struct Plugin *plugin) | |||
1958 | #if DEBUG_CONNECTIONS | 1935 | #if DEBUG_CONNECTIONS |
1959 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1936 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1960 | "Connection %X: HTTP PUT connection to peer `%s' (`%s') was closed with HTTP code %u\n", | 1937 | "Connection %X: HTTP PUT connection to peer `%s' (`%s') was closed with HTTP code %u\n", |
1961 | ps, | 1938 | ps, GNUNET_i2s (&pc->identity), |
1962 | GNUNET_i2s (&pc->identity), | ||
1963 | http_plugin_address_to_string (NULL, ps->addr, | 1939 | http_plugin_address_to_string (NULL, ps->addr, |
1964 | ps->addrlen), http_result); | 1940 | ps->addrlen), http_result); |
1965 | #endif | 1941 | #endif |
@@ -1995,8 +1971,7 @@ curl_handle_finished (struct Plugin *plugin) | |||
1995 | #if DEBUG_CONNECTIONS | 1971 | #if DEBUG_CONNECTIONS |
1996 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1972 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1997 | "Connection %X: HTTP GET connection to peer `%s' (`%s') was closed with HTTP code %u\n", | 1973 | "Connection %X: HTTP GET connection to peer `%s' (`%s') was closed with HTTP code %u\n", |
1998 | ps, | 1974 | ps, GNUNET_i2s (&pc->identity), |
1999 | GNUNET_i2s (&pc->identity), | ||
2000 | http_plugin_address_to_string (NULL, ps->addr, | 1975 | http_plugin_address_to_string (NULL, ps->addr, |
2001 | ps->addrlen), http_result); | 1976 | ps->addrlen), http_result); |
2002 | #endif | 1977 | #endif |
@@ -2081,8 +2056,7 @@ curl_schedule (struct Plugin *plugin) | |||
2081 | mret = curl_multi_fdset (plugin->multi_handle, &rs, &ws, &es, &max); | 2056 | mret = curl_multi_fdset (plugin->multi_handle, &rs, &ws, &es, &max); |
2082 | if (mret != CURLM_OK) | 2057 | if (mret != CURLM_OK) |
2083 | { | 2058 | { |
2084 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2059 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"), |
2085 | _("%s failed at %s:%d: `%s'\n"), | ||
2086 | "curl_multi_fdset", __FILE__, __LINE__, | 2060 | "curl_multi_fdset", __FILE__, __LINE__, |
2087 | curl_multi_strerror (mret)); | 2061 | curl_multi_strerror (mret)); |
2088 | return GNUNET_SYSERR; | 2062 | return GNUNET_SYSERR; |
@@ -2090,8 +2064,7 @@ curl_schedule (struct Plugin *plugin) | |||
2090 | mret = curl_multi_timeout (plugin->multi_handle, &to); | 2064 | mret = curl_multi_timeout (plugin->multi_handle, &to); |
2091 | if (mret != CURLM_OK) | 2065 | if (mret != CURLM_OK) |
2092 | { | 2066 | { |
2093 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2067 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("%s failed at %s:%d: `%s'\n"), |
2094 | _("%s failed at %s:%d: `%s'\n"), | ||
2095 | "curl_multi_timeout", __FILE__, __LINE__, | 2068 | "curl_multi_timeout", __FILE__, __LINE__, |
2096 | curl_multi_strerror (mret)); | 2069 | curl_multi_strerror (mret)); |
2097 | return GNUNET_SYSERR; | 2070 | return GNUNET_SYSERR; |
@@ -2129,8 +2102,8 @@ curl_schedule (struct Plugin *plugin) | |||
2129 | * @return 0 | 2102 | * @return 0 |
2130 | */ | 2103 | */ |
2131 | static int | 2104 | static int |
2132 | curl_logger (CURL * curl, | 2105 | curl_logger (CURL * curl, curl_infotype type, char *data, size_t size, |
2133 | curl_infotype type, char *data, size_t size, void *cls) | 2106 | void *cls) |
2134 | { | 2107 | { |
2135 | if (type == CURLINFO_TEXT) | 2108 | if (type == CURLINFO_TEXT) |
2136 | { | 2109 | { |
@@ -2217,8 +2190,7 @@ send_check_connections (struct Plugin *plugin, struct Session *ps) | |||
2217 | if (mret != CURLM_OK) | 2190 | if (mret != CURLM_OK) |
2218 | { | 2191 | { |
2219 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2192 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
2220 | _("Connection: %X: %s failed at %s:%d: `%s'\n"), | 2193 | _("Connection: %X: %s failed at %s:%d: `%s'\n"), ps, |
2221 | ps, | ||
2222 | "curl_multi_add_handle", __FILE__, __LINE__, | 2194 | "curl_multi_add_handle", __FILE__, __LINE__, |
2223 | curl_multi_strerror (mret)); | 2195 | curl_multi_strerror (mret)); |
2224 | return GNUNET_SYSERR; | 2196 | return GNUNET_SYSERR; |
@@ -2330,8 +2302,7 @@ send_check_connections (struct Plugin *plugin, struct Session *ps) | |||
2330 | if (mret != CURLM_OK) | 2302 | if (mret != CURLM_OK) |
2331 | { | 2303 | { |
2332 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 2304 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
2333 | _("Connection: %X: %s failed at %s:%d: `%s'\n"), | 2305 | _("Connection: %X: %s failed at %s:%d: `%s'\n"), ps, |
2334 | ps, | ||
2335 | "curl_multi_add_handle", __FILE__, __LINE__, | 2306 | "curl_multi_add_handle", __FILE__, __LINE__, |
2336 | curl_multi_strerror (mret)); | 2307 | curl_multi_strerror (mret)); |
2337 | return GNUNET_SYSERR; | 2308 | return GNUNET_SYSERR; |
@@ -2371,9 +2342,8 @@ send_check_connections (struct Plugin *plugin, struct Session *ps) | |||
2371 | * | 2342 | * |
2372 | */ | 2343 | */ |
2373 | static struct Session * | 2344 | static struct Session * |
2374 | send_select_session (struct HTTP_PeerContext *pc, | 2345 | send_select_session (struct HTTP_PeerContext *pc, const void *addr, |
2375 | const void *addr, size_t addrlen, | 2346 | size_t addrlen, int force_address, struct Session *session) |
2376 | int force_address, struct Session *session) | ||
2377 | { | 2347 | { |
2378 | struct Session *tmp = NULL; | 2348 | struct Session *tmp = NULL; |
2379 | int addr_given = GNUNET_NO; | 2349 | int addr_given = GNUNET_NO; |
@@ -2534,16 +2504,10 @@ send_select_session (struct HTTP_PeerContext *pc, | |||
2534 | * and does NOT mean that the message was not transmitted (DV) | 2504 | * and does NOT mean that the message was not transmitted (DV) |
2535 | */ | 2505 | */ |
2536 | static ssize_t | 2506 | static ssize_t |
2537 | http_plugin_send (void *cls, | 2507 | http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, |
2538 | const struct GNUNET_PeerIdentity *target, | 2508 | const char *msgbuf, size_t msgbuf_size, unsigned int priority, |
2539 | const char *msgbuf, | 2509 | struct GNUNET_TIME_Relative to, struct Session *session, |
2540 | size_t msgbuf_size, | 2510 | const void *addr, size_t addrlen, int force_address, |
2541 | unsigned int priority, | ||
2542 | struct GNUNET_TIME_Relative to, | ||
2543 | struct Session *session, | ||
2544 | const void *addr, | ||
2545 | size_t addrlen, | ||
2546 | int force_address, | ||
2547 | GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) | 2511 | GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) |
2548 | { | 2512 | { |
2549 | struct Plugin *plugin = cls; | 2513 | struct Plugin *plugin = cls; |
@@ -2566,9 +2530,7 @@ http_plugin_send (void *cls, | |||
2566 | GNUNET_assert (0); | 2530 | GNUNET_assert (0); |
2567 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2531 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2568 | "Transport tells me to send %u bytes to `%s' using %s (%s) and session: %X\n", | 2532 | "Transport tells me to send %u bytes to `%s' using %s (%s) and session: %X\n", |
2569 | msgbuf_size, | 2533 | msgbuf_size, GNUNET_i2s (target), force, |
2570 | GNUNET_i2s (target), | ||
2571 | force, | ||
2572 | http_plugin_address_to_string (NULL, addr, addrlen), session); | 2534 | http_plugin_address_to_string (NULL, addr, addrlen), session); |
2573 | GNUNET_free (force); | 2535 | GNUNET_free (force); |
2574 | #endif | 2536 | #endif |
@@ -2582,13 +2544,12 @@ http_plugin_send (void *cls, | |||
2582 | pc->session_id_counter = 1; | 2544 | pc->session_id_counter = 1; |
2583 | pc->last_session = NULL; | 2545 | pc->last_session = NULL; |
2584 | memcpy (&pc->identity, target, sizeof (struct GNUNET_PeerIdentity)); | 2546 | memcpy (&pc->identity, target, sizeof (struct GNUNET_PeerIdentity)); |
2585 | GNUNET_CONTAINER_multihashmap_put (plugin->peers, | 2547 | GNUNET_CONTAINER_multihashmap_put (plugin->peers, &pc->identity.hashPubKey, |
2586 | &pc->identity.hashPubKey, | ||
2587 | pc, | 2548 | pc, |
2588 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 2549 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
2589 | GNUNET_STATISTICS_update (plugin->env->stats, | 2550 | GNUNET_STATISTICS_update (plugin->env->stats, |
2590 | gettext_noop ("# HTTP peers active"), | 2551 | gettext_noop ("# HTTP peers active"), 1, |
2591 | 1, GNUNET_NO); | 2552 | GNUNET_NO); |
2592 | } | 2553 | } |
2593 | ps = send_select_session (pc, addr, addrlen, force_address, session); | 2554 | ps = send_select_session (pc, addr, addrlen, force_address, session); |
2594 | /* session not existing, but address forced -> creating new session */ | 2555 | /* session not existing, but address forced -> creating new session */ |
@@ -2659,8 +2620,8 @@ http_plugin_send (void *cls, | |||
2659 | msg->transmit_cont = cont; | 2620 | msg->transmit_cont = cont; |
2660 | msg->transmit_cont_cls = cont_cls; | 2621 | msg->transmit_cont_cls = cont_cls; |
2661 | memcpy (msg->buf, msgbuf, msgbuf_size); | 2622 | memcpy (msg->buf, msgbuf, msgbuf_size); |
2662 | GNUNET_CONTAINER_DLL_insert (ps->pending_msgs_head, | 2623 | GNUNET_CONTAINER_DLL_insert (ps->pending_msgs_head, ps->pending_msgs_tail, |
2663 | ps->pending_msgs_tail, msg); | 2624 | msg); |
2664 | ps->queue_length_cur += msgbuf_size; | 2625 | ps->queue_length_cur += msgbuf_size; |
2665 | if (send_check_connections (plugin, ps) == GNUNET_SYSERR) | 2626 | if (send_check_connections (plugin, ps) == GNUNET_SYSERR) |
2666 | return GNUNET_SYSERR; | 2627 | return GNUNET_SYSERR; |
@@ -2767,14 +2728,12 @@ append_port (void *cls, const char *hostname) | |||
2767 | * @param asc_cls closure for asc | 2728 | * @param asc_cls closure for asc |
2768 | */ | 2729 | */ |
2769 | static void | 2730 | static void |
2770 | http_plugin_address_pretty_printer (void *cls, | 2731 | http_plugin_address_pretty_printer (void *cls, const char *type, |
2771 | const char *type, | 2732 | const void *addr, size_t addrlen, |
2772 | const void *addr, | ||
2773 | size_t addrlen, | ||
2774 | int numeric, | 2733 | int numeric, |
2775 | struct GNUNET_TIME_Relative timeout, | 2734 | struct GNUNET_TIME_Relative timeout, |
2776 | GNUNET_TRANSPORT_AddressStringCallback | 2735 | GNUNET_TRANSPORT_AddressStringCallback asc, |
2777 | asc, void *asc_cls) | 2736 | void *asc_cls) |
2778 | { | 2737 | { |
2779 | struct PrettyPrinterContext *ppc; | 2738 | struct PrettyPrinterContext *ppc; |
2780 | const void *sb; | 2739 | const void *sb; |
@@ -2963,16 +2922,15 @@ http_plugin_address_to_string (void *cls, const void *addr, size_t addrlen) | |||
2963 | * @param addrlen number of bytes in addr | 2922 | * @param addrlen number of bytes in addr |
2964 | */ | 2923 | */ |
2965 | static void | 2924 | static void |
2966 | try_connection_reversal (void *cls, | 2925 | try_connection_reversal (void *cls, const struct sockaddr *addr, |
2967 | const struct sockaddr *addr, socklen_t addrlen) | 2926 | socklen_t addrlen) |
2968 | { | 2927 | { |
2969 | 2928 | ||
2970 | } | 2929 | } |
2971 | 2930 | ||
2972 | static void | 2931 | static void |
2973 | tcp_nat_cb_add_addr (void *cls, | 2932 | tcp_nat_cb_add_addr (void *cls, int add_remove, const struct sockaddr *addr, |
2974 | int add_remove, | 2933 | socklen_t addrlen) |
2975 | const struct sockaddr *addr, socklen_t addrlen) | ||
2976 | { | 2934 | { |
2977 | struct Plugin *plugin = cls; | 2935 | struct Plugin *plugin = cls; |
2978 | struct IPv4HttpAddress *t4 = NULL; | 2936 | struct IPv4HttpAddress *t4 = NULL; |
@@ -3000,8 +2958,7 @@ tcp_nat_cb_add_addr (void *cls, | |||
3000 | { | 2958 | { |
3001 | w_t4 = GNUNET_malloc (sizeof (struct IPv4HttpAddressWrapper)); | 2959 | w_t4 = GNUNET_malloc (sizeof (struct IPv4HttpAddressWrapper)); |
3002 | t4 = GNUNET_malloc (sizeof (struct IPv4HttpAddress)); | 2960 | t4 = GNUNET_malloc (sizeof (struct IPv4HttpAddress)); |
3003 | memcpy (&t4->ipv4_addr, | 2961 | memcpy (&t4->ipv4_addr, &((struct sockaddr_in *) addr)->sin_addr, |
3004 | &((struct sockaddr_in *) addr)->sin_addr, | ||
3005 | sizeof (struct in_addr)); | 2962 | sizeof (struct in_addr)); |
3006 | t4->port = htons (plugin->port_inbound); | 2963 | t4->port = htons (plugin->port_inbound); |
3007 | 2964 | ||
@@ -3010,9 +2967,8 @@ tcp_nat_cb_add_addr (void *cls, | |||
3010 | GNUNET_CONTAINER_DLL_insert (plugin->ipv4_addr_head, | 2967 | GNUNET_CONTAINER_DLL_insert (plugin->ipv4_addr_head, |
3011 | plugin->ipv4_addr_tail, w_t4); | 2968 | plugin->ipv4_addr_tail, w_t4); |
3012 | } | 2969 | } |
3013 | plugin->env->notify_address (plugin->env->cls, | 2970 | plugin->env->notify_address (plugin->env->cls, add_remove, w_t4->addr, |
3014 | add_remove, | 2971 | sizeof (struct IPv4HttpAddress)); |
3015 | w_t4->addr, sizeof (struct IPv4HttpAddress)); | ||
3016 | 2972 | ||
3017 | break; | 2973 | break; |
3018 | case AF_INET6: | 2974 | case AF_INET6: |
@@ -3032,8 +2988,7 @@ tcp_nat_cb_add_addr (void *cls, | |||
3032 | w_t6 = GNUNET_malloc (sizeof (struct IPv6HttpAddressWrapper)); | 2988 | w_t6 = GNUNET_malloc (sizeof (struct IPv6HttpAddressWrapper)); |
3033 | t6 = GNUNET_malloc (sizeof (struct IPv6HttpAddress)); | 2989 | t6 = GNUNET_malloc (sizeof (struct IPv6HttpAddress)); |
3034 | 2990 | ||
3035 | memcpy (&t6->ipv6_addr, | 2991 | memcpy (&t6->ipv6_addr, &((struct sockaddr_in6 *) addr)->sin6_addr, |
3036 | &((struct sockaddr_in6 *) addr)->sin6_addr, | ||
3037 | sizeof (struct in6_addr)); | 2992 | sizeof (struct in6_addr)); |
3038 | t6->port = htons (plugin->port_inbound); | 2993 | t6->port = htons (plugin->port_inbound); |
3039 | 2994 | ||
@@ -3042,9 +2997,8 @@ tcp_nat_cb_add_addr (void *cls, | |||
3042 | GNUNET_CONTAINER_DLL_insert (plugin->ipv6_addr_head, | 2997 | GNUNET_CONTAINER_DLL_insert (plugin->ipv6_addr_head, |
3043 | plugin->ipv6_addr_tail, w_t6); | 2998 | plugin->ipv6_addr_tail, w_t6); |
3044 | } | 2999 | } |
3045 | plugin->env->notify_address (plugin->env->cls, | 3000 | plugin->env->notify_address (plugin->env->cls, add_remove, w_t6->addr, |
3046 | add_remove, | 3001 | sizeof (struct IPv6HttpAddress)); |
3047 | w_t6->addr, sizeof (struct IPv6HttpAddress)); | ||
3048 | break; | 3002 | break; |
3049 | default: | 3003 | default: |
3050 | return; | 3004 | return; |
@@ -3053,9 +3007,8 @@ tcp_nat_cb_add_addr (void *cls, | |||
3053 | } | 3007 | } |
3054 | 3008 | ||
3055 | static void | 3009 | static void |
3056 | tcp_nat_cb_remove_addr (void *cls, | 3010 | tcp_nat_cb_remove_addr (void *cls, int add_remove, const struct sockaddr *addr, |
3057 | int add_remove, | 3011 | socklen_t addrlen) |
3058 | const struct sockaddr *addr, socklen_t addrlen) | ||
3059 | { | 3012 | { |
3060 | struct Plugin *plugin = cls; | 3013 | struct Plugin *plugin = cls; |
3061 | struct IPv4HttpAddressWrapper *w_t4 = NULL; | 3014 | struct IPv4HttpAddressWrapper *w_t4 = NULL; |
@@ -3079,12 +3032,11 @@ tcp_nat_cb_remove_addr (void *cls, | |||
3079 | } | 3032 | } |
3080 | if (w_t4 == NULL) | 3033 | if (w_t4 == NULL) |
3081 | return; | 3034 | return; |
3082 | plugin->env->notify_address (plugin->env->cls, | 3035 | plugin->env->notify_address (plugin->env->cls, add_remove, w_t4->addr, |
3083 | add_remove, | 3036 | sizeof (struct IPv4HttpAddress)); |
3084 | w_t4->addr, sizeof (struct IPv4HttpAddress)); | ||
3085 | 3037 | ||
3086 | GNUNET_CONTAINER_DLL_remove (plugin->ipv4_addr_head, | 3038 | GNUNET_CONTAINER_DLL_remove (plugin->ipv4_addr_head, plugin->ipv4_addr_tail, |
3087 | plugin->ipv4_addr_tail, w_t4); | 3039 | w_t4); |
3088 | GNUNET_free (w_t4->addr); | 3040 | GNUNET_free (w_t4->addr); |
3089 | GNUNET_free (w_t4); | 3041 | GNUNET_free (w_t4); |
3090 | break; | 3042 | break; |
@@ -3102,12 +3054,11 @@ tcp_nat_cb_remove_addr (void *cls, | |||
3102 | } | 3054 | } |
3103 | if (w_t6 == NULL) | 3055 | if (w_t6 == NULL) |
3104 | return; | 3056 | return; |
3105 | plugin->env->notify_address (plugin->env->cls, | 3057 | plugin->env->notify_address (plugin->env->cls, add_remove, w_t6->addr, |
3106 | add_remove, | 3058 | sizeof (struct IPv6HttpAddress)); |
3107 | w_t6->addr, sizeof (struct IPv6HttpAddress)); | ||
3108 | 3059 | ||
3109 | GNUNET_CONTAINER_DLL_remove (plugin->ipv6_addr_head, | 3060 | GNUNET_CONTAINER_DLL_remove (plugin->ipv6_addr_head, plugin->ipv6_addr_tail, |
3110 | plugin->ipv6_addr_tail, w_t6); | 3061 | w_t6); |
3111 | GNUNET_free (w_t6->addr); | 3062 | GNUNET_free (w_t6->addr); |
3112 | GNUNET_free (w_t6); | 3063 | GNUNET_free (w_t6); |
3113 | break; | 3064 | break; |
@@ -3127,14 +3078,12 @@ tcp_nat_cb_remove_addr (void *cls, | |||
3127 | * @param addrlen actual lenght of the address | 3078 | * @param addrlen actual lenght of the address |
3128 | */ | 3079 | */ |
3129 | static void | 3080 | static void |
3130 | tcp_nat_port_map_callback (void *cls, | 3081 | tcp_nat_port_map_callback (void *cls, int add_remove, |
3131 | int add_remove, | ||
3132 | const struct sockaddr *addr, socklen_t addrlen) | 3082 | const struct sockaddr *addr, socklen_t addrlen) |
3133 | { | 3083 | { |
3134 | GNUNET_assert (cls != NULL); | 3084 | GNUNET_assert (cls != NULL); |
3135 | #if DEBUG_HTTP | 3085 | #if DEBUG_HTTP |
3136 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 3086 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "NPMC called to %s address `%s'\n", |
3137 | "NPMC called to %s address `%s'\n", | ||
3138 | (add_remove == GNUNET_YES) ? "remove" : "add", | 3087 | (add_remove == GNUNET_YES) ? "remove" : "add", |
3139 | GNUNET_a2s (addr, addrlen)); | 3088 | GNUNET_a2s (addr, addrlen)); |
3140 | #endif | 3089 | #endif |
@@ -3242,8 +3191,8 @@ LIBGNUNET_PLUGIN_TRANSPORT_DONE (void *cls) | |||
3242 | GNUNET_free (plugin); | 3191 | GNUNET_free (plugin); |
3243 | GNUNET_free (api); | 3192 | GNUNET_free (api); |
3244 | #if DEBUG_HTTP | 3193 | #if DEBUG_HTTP |
3245 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3194 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Unload %s plugin complete...\n", |
3246 | "Unload %s plugin complete...\n", PROTOCOL_PREFIX); | 3195 | PROTOCOL_PREFIX); |
3247 | #endif | 3196 | #endif |
3248 | return NULL; | 3197 | return NULL; |
3249 | } | 3198 | } |
@@ -3304,8 +3253,8 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) | |||
3304 | 3253 | ||
3305 | GNUNET_assert (cls != NULL); | 3254 | GNUNET_assert (cls != NULL); |
3306 | #if DEBUG_HTTP | 3255 | #if DEBUG_HTTP |
3307 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3256 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting %s plugin...\n", |
3308 | "Starting %s plugin...\n", PROTOCOL_PREFIX); | 3257 | PROTOCOL_PREFIX); |
3309 | #endif | 3258 | #endif |
3310 | GNUNET_asprintf (&component_name, "transport-%s", PROTOCOL_PREFIX); | 3259 | GNUNET_asprintf (&component_name, "transport-%s", PROTOCOL_PREFIX); |
3311 | 3260 | ||
@@ -3333,8 +3282,7 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) | |||
3333 | 3282 | ||
3334 | 3283 | ||
3335 | if (GNUNET_OK != | 3284 | if (GNUNET_OK != |
3336 | GNUNET_CONFIGURATION_get_value_number (env->cfg, | 3285 | GNUNET_CONFIGURATION_get_value_number (env->cfg, component_name, |
3337 | component_name, | ||
3338 | "MAX_CONNECTIONS", &tneigh)) | 3286 | "MAX_CONNECTIONS", &tneigh)) |
3339 | tneigh = 128; | 3287 | tneigh = 128; |
3340 | plugin->max_connect_per_transport = tneigh; | 3288 | plugin->max_connect_per_transport = tneigh; |
@@ -3343,34 +3291,32 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) | |||
3343 | /* Use IPv6? */ | 3291 | /* Use IPv6? */ |
3344 | if (GNUNET_CONFIGURATION_have_value (env->cfg, component_name, "USE_IPv6")) | 3292 | if (GNUNET_CONFIGURATION_have_value (env->cfg, component_name, "USE_IPv6")) |
3345 | { | 3293 | { |
3346 | plugin->use_ipv6 = GNUNET_CONFIGURATION_get_value_yesno (env->cfg, | 3294 | plugin->use_ipv6 = |
3347 | component_name, | 3295 | GNUNET_CONFIGURATION_get_value_yesno (env->cfg, component_name, |
3348 | "USE_IPv6"); | 3296 | "USE_IPv6"); |
3349 | } | 3297 | } |
3350 | /* Use IPv4? */ | 3298 | /* Use IPv4? */ |
3351 | if (GNUNET_CONFIGURATION_have_value (env->cfg, component_name, "USE_IPv4")) | 3299 | if (GNUNET_CONFIGURATION_have_value (env->cfg, component_name, "USE_IPv4")) |
3352 | { | 3300 | { |
3353 | plugin->use_ipv4 = GNUNET_CONFIGURATION_get_value_yesno (env->cfg, | 3301 | plugin->use_ipv4 = |
3354 | component_name, | 3302 | GNUNET_CONFIGURATION_get_value_yesno (env->cfg, component_name, |
3355 | "USE_IPv4"); | 3303 | "USE_IPv4"); |
3356 | } | 3304 | } |
3357 | /* use local addresses? */ | 3305 | /* use local addresses? */ |
3358 | 3306 | ||
3359 | if (GNUNET_CONFIGURATION_have_value (env->cfg, | 3307 | if (GNUNET_CONFIGURATION_have_value |
3360 | component_name, "USE_LOCALADDR")) | 3308 | (env->cfg, component_name, "USE_LOCALADDR")) |
3361 | { | 3309 | { |
3362 | plugin->use_localaddresses = GNUNET_CONFIGURATION_get_value_yesno (env->cfg, | 3310 | plugin->use_localaddresses = |
3363 | component_name, | 3311 | GNUNET_CONFIGURATION_get_value_yesno (env->cfg, component_name, |
3364 | "USE_LOCALADDR"); | 3312 | "USE_LOCALADDR"); |
3365 | } | 3313 | } |
3366 | /* Reading port number from config file */ | 3314 | /* Reading port number from config file */ |
3367 | if ((GNUNET_OK != | 3315 | if ((GNUNET_OK != |
3368 | GNUNET_CONFIGURATION_get_value_number (env->cfg, | 3316 | GNUNET_CONFIGURATION_get_value_number (env->cfg, component_name, "PORT", |
3369 | component_name, | 3317 | &port)) || (port > 65535)) |
3370 | "PORT", &port)) || (port > 65535)) | ||
3371 | { | 3318 | { |
3372 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, | 3319 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, component_name, |
3373 | component_name, | ||
3374 | _ | 3320 | _ |
3375 | ("Require valid port number for transport plugin `%s' in configuration!\n"), | 3321 | ("Require valid port number for transport plugin `%s' in configuration!\n"), |
3376 | PROTOCOL_PREFIX); | 3322 | PROTOCOL_PREFIX); |
@@ -3387,7 +3333,8 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) | |||
3387 | GNUNET_CONFIGURATION_get_value_string (env->cfg, | 3333 | GNUNET_CONFIGURATION_get_value_string (env->cfg, |
3388 | component_name, | 3334 | component_name, |
3389 | "BINDTO4", | 3335 | "BINDTO4", |
3390 | &plugin->bind_hostname)); | 3336 | &plugin-> |
3337 | bind_hostname)); | ||
3391 | plugin->bind4_address = GNUNET_malloc (sizeof (struct sockaddr_in)); | 3338 | plugin->bind4_address = GNUNET_malloc (sizeof (struct sockaddr_in)); |
3392 | plugin->bind4_address->sin_family = AF_INET; | 3339 | plugin->bind4_address->sin_family = AF_INET; |
3393 | plugin->bind4_address->sin_port = htons (port); | 3340 | plugin->bind4_address->sin_port = htons (port); |
@@ -3398,8 +3345,7 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) | |||
3398 | (AF_INET, plugin->bind_hostname, | 3345 | (AF_INET, plugin->bind_hostname, |
3399 | &plugin->bind4_address->sin_addr) <= 0) | 3346 | &plugin->bind4_address->sin_addr) <= 0) |
3400 | { | 3347 | { |
3401 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, | 3348 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, component_name, |
3402 | component_name, | ||
3403 | _ | 3349 | _ |
3404 | ("Misconfigured address to bind to in configuration!\n")); | 3350 | ("Misconfigured address to bind to in configuration!\n")); |
3405 | GNUNET_free (plugin->bind4_address); | 3351 | GNUNET_free (plugin->bind4_address); |
@@ -3414,10 +3360,10 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) | |||
3414 | if ((plugin->use_ipv6 == GNUNET_YES) && | 3360 | if ((plugin->use_ipv6 == GNUNET_YES) && |
3415 | (GNUNET_CONFIGURATION_have_value (env->cfg, component_name, "BINDTO6"))) | 3361 | (GNUNET_CONFIGURATION_have_value (env->cfg, component_name, "BINDTO6"))) |
3416 | { | 3362 | { |
3417 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (env->cfg, | 3363 | if (GNUNET_OK == |
3418 | component_name, | 3364 | GNUNET_CONFIGURATION_get_value_string (env->cfg, component_name, |
3419 | "BINDTO6", | 3365 | "BINDTO6", |
3420 | &plugin->bind_hostname)) | 3366 | &plugin->bind_hostname)) |
3421 | { | 3367 | { |
3422 | plugin->bind6_address = GNUNET_malloc (sizeof (struct sockaddr_in6)); | 3368 | plugin->bind6_address = GNUNET_malloc (sizeof (struct sockaddr_in6)); |
3423 | plugin->bind6_address->sin6_family = AF_INET6; | 3369 | plugin->bind6_address->sin6_family = AF_INET6; |
@@ -3428,8 +3374,7 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) | |||
3428 | (AF_INET6, plugin->bind_hostname, | 3374 | (AF_INET6, plugin->bind_hostname, |
3429 | &plugin->bind6_address->sin6_addr) <= 0) | 3375 | &plugin->bind6_address->sin6_addr) <= 0) |
3430 | { | 3376 | { |
3431 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, | 3377 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, component_name, |
3432 | component_name, | ||
3433 | _ | 3378 | _ |
3434 | ("Misconfigured address to bind to in configuration!\n")); | 3379 | ("Misconfigured address to bind to in configuration!\n")); |
3435 | GNUNET_free (plugin->bind6_address); | 3380 | GNUNET_free (plugin->bind6_address); |
@@ -3445,22 +3390,17 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) | |||
3445 | /* Reading HTTPS crypto related configuration */ | 3390 | /* Reading HTTPS crypto related configuration */ |
3446 | /* Get crypto init string from config */ | 3391 | /* Get crypto init string from config */ |
3447 | if ((GNUNET_OK != | 3392 | if ((GNUNET_OK != |
3448 | GNUNET_CONFIGURATION_get_value_string (env->cfg, | 3393 | GNUNET_CONFIGURATION_get_value_string (env->cfg, "transport-https", |
3449 | "transport-https", | ||
3450 | "CRYPTO_INIT", | 3394 | "CRYPTO_INIT", |
3451 | &plugin->crypto_init)) || | 3395 | &plugin->crypto_init)) || |
3452 | (GNUNET_OK != | 3396 | (GNUNET_OK != |
3453 | GNUNET_CONFIGURATION_get_value_filename (env->cfg, | 3397 | GNUNET_CONFIGURATION_get_value_filename (env->cfg, "transport-https", |
3454 | "transport-https", | 3398 | "KEY_FILE", &key_file)) || |
3455 | "KEY_FILE", | ||
3456 | &key_file)) || | ||
3457 | (GNUNET_OK != | 3399 | (GNUNET_OK != |
3458 | GNUNET_CONFIGURATION_get_value_filename (env->cfg, | 3400 | GNUNET_CONFIGURATION_get_value_filename (env->cfg, "transport-https", |
3459 | "transport-https", | ||
3460 | "CERT_FILE", &cert_file))) | 3401 | "CERT_FILE", &cert_file))) |
3461 | { | 3402 | { |
3462 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, | 3403 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "https", |
3463 | "https", | ||
3464 | _ | 3404 | _ |
3465 | ("Required configuration options missing in section `%s'\n"), | 3405 | ("Required configuration options missing in section `%s'\n"), |
3466 | "transport-https"); | 3406 | "transport-https"); |
@@ -3472,8 +3412,8 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) | |||
3472 | } | 3412 | } |
3473 | 3413 | ||
3474 | /* read key & certificates from file */ | 3414 | /* read key & certificates from file */ |
3475 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3415 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Loading TLS certificate `%s' `%s'\n", |
3476 | "Loading TLS certificate `%s' `%s'\n", key_file, cert_file); | 3416 | key_file, cert_file); |
3477 | 3417 | ||
3478 | plugin->key = load_certificate (key_file); | 3418 | plugin->key = load_certificate (key_file); |
3479 | plugin->cert = load_certificate (cert_file); | 3419 | plugin->cert = load_certificate (cert_file); |
@@ -3491,14 +3431,14 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) | |||
3491 | "No usable TLS certificate found, creating certificate\n"); | 3431 | "No usable TLS certificate found, creating certificate\n"); |
3492 | #endif | 3432 | #endif |
3493 | errno = 0; | 3433 | errno = 0; |
3494 | certcreation = GNUNET_OS_start_process (NULL, NULL, | 3434 | certcreation = |
3495 | "gnunet-transport-certificate-creation", | 3435 | GNUNET_OS_start_process (NULL, NULL, |
3496 | "gnunet-transport-certificate-creation", | 3436 | "gnunet-transport-certificate-creation", |
3497 | key_file, cert_file, NULL); | 3437 | "gnunet-transport-certificate-creation", |
3438 | key_file, cert_file, NULL); | ||
3498 | if (certcreation == NULL) | 3439 | if (certcreation == NULL) |
3499 | { | 3440 | { |
3500 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, | 3441 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "https", |
3501 | "https", | ||
3502 | _ | 3442 | _ |
3503 | ("Could not create a new TLS certificate, program `gnunet-transport-certificate-creation' could not be started!\n")); | 3443 | ("Could not create a new TLS certificate, program `gnunet-transport-certificate-creation' could not be started!\n")); |
3504 | GNUNET_free (key_file); | 3444 | GNUNET_free (key_file); |
@@ -3514,8 +3454,7 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) | |||
3514 | } | 3454 | } |
3515 | if ((plugin->key == NULL) || (plugin->cert == NULL)) | 3455 | if ((plugin->key == NULL) || (plugin->cert == NULL)) |
3516 | { | 3456 | { |
3517 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, | 3457 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, "https", |
3518 | "https", | ||
3519 | _ | 3458 | _ |
3520 | ("No usable TLS certificate found and creating one failed!\n"), | 3459 | ("No usable TLS certificate found and creating one failed!\n"), |
3521 | "transport-https"); | 3460 | "transport-https"); |
@@ -3549,15 +3488,14 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) | |||
3549 | #if BUILD_HTTPS | 3488 | #if BUILD_HTTPS |
3550 | MHD_USE_SSL | | 3489 | MHD_USE_SSL | |
3551 | #endif | 3490 | #endif |
3552 | MHD_USE_IPv6, | 3491 | MHD_USE_IPv6, port, |
3553 | port, | ||
3554 | &mhd_accept_cb, plugin, | 3492 | &mhd_accept_cb, plugin, |
3555 | &mhd_access_cb, plugin, | 3493 | &mhd_access_cb, plugin, |
3556 | MHD_OPTION_SOCK_ADDR, | 3494 | MHD_OPTION_SOCK_ADDR, |
3557 | tmp, | 3495 | tmp, |
3558 | MHD_OPTION_CONNECTION_LIMIT, | 3496 | MHD_OPTION_CONNECTION_LIMIT, |
3559 | (unsigned int) | 3497 | (unsigned int) plugin-> |
3560 | plugin->max_connect_per_transport, | 3498 | max_connect_per_transport, |
3561 | #if BUILD_HTTPS | 3499 | #if BUILD_HTTPS |
3562 | MHD_OPTION_HTTPS_PRIORITIES, | 3500 | MHD_OPTION_HTTPS_PRIORITIES, |
3563 | plugin->crypto_init, | 3501 | plugin->crypto_init, |
@@ -3589,16 +3527,15 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) | |||
3589 | #if BUILD_HTTPS | 3527 | #if BUILD_HTTPS |
3590 | MHD_USE_SSL | | 3528 | MHD_USE_SSL | |
3591 | #endif | 3529 | #endif |
3592 | MHD_NO_FLAG, | 3530 | MHD_NO_FLAG, port, |
3593 | port, | ||
3594 | &mhd_accept_cb, plugin, | 3531 | &mhd_accept_cb, plugin, |
3595 | &mhd_access_cb, plugin, | 3532 | &mhd_access_cb, plugin, |
3596 | MHD_OPTION_SOCK_ADDR, | 3533 | MHD_OPTION_SOCK_ADDR, |
3597 | (struct sockaddr_in *) | 3534 | (struct sockaddr_in *) |
3598 | plugin->bind4_address, | 3535 | plugin->bind4_address, |
3599 | MHD_OPTION_CONNECTION_LIMIT, | 3536 | MHD_OPTION_CONNECTION_LIMIT, |
3600 | (unsigned int) | 3537 | (unsigned int) plugin-> |
3601 | plugin->max_connect_per_transport, | 3538 | max_connect_per_transport, |
3602 | #if BUILD_HTTPS | 3539 | #if BUILD_HTTPS |
3603 | MHD_OPTION_HTTPS_PRIORITIES, | 3540 | MHD_OPTION_HTTPS_PRIORITIES, |
3604 | plugin->crypto_init, | 3541 | plugin->crypto_init, |
@@ -3685,8 +3622,7 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) | |||
3685 | 3622 | ||
3686 | if (NULL == plugin->multi_handle) | 3623 | if (NULL == plugin->multi_handle) |
3687 | { | 3624 | { |
3688 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, | 3625 | GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, component_name, |
3689 | component_name, | ||
3690 | _ | 3626 | _ |
3691 | ("Could not initialize curl multi handle, failed to start %s plugin!\n"), | 3627 | ("Could not initialize curl multi handle, failed to start %s plugin!\n"), |
3692 | PROTOCOL_PREFIX); | 3628 | PROTOCOL_PREFIX); |
@@ -3695,19 +3631,17 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) | |||
3695 | return NULL; | 3631 | return NULL; |
3696 | } | 3632 | } |
3697 | 3633 | ||
3698 | ret = GNUNET_SERVICE_get_server_addresses (component_name, | 3634 | ret = |
3699 | env->cfg, &addrs, &addrlens); | 3635 | GNUNET_SERVICE_get_server_addresses (component_name, env->cfg, &addrs, |
3636 | &addrlens); | ||
3700 | 3637 | ||
3701 | if (ret != GNUNET_SYSERR) | 3638 | if (ret != GNUNET_SYSERR) |
3702 | { | 3639 | { |
3703 | plugin->nat = GNUNET_NAT_register (env->cfg, | 3640 | plugin->nat = |
3704 | GNUNET_YES, | 3641 | GNUNET_NAT_register (env->cfg, GNUNET_YES, port, (unsigned int) ret, |
3705 | port, | 3642 | (const struct sockaddr **) addrs, addrlens, |
3706 | (unsigned int) ret, | 3643 | &tcp_nat_port_map_callback, |
3707 | (const struct sockaddr **) addrs, | 3644 | &try_connection_reversal, plugin); |
3708 | addrlens, | ||
3709 | &tcp_nat_port_map_callback, | ||
3710 | &try_connection_reversal, plugin); | ||
3711 | while (ret > 0) | 3645 | while (ret > 0) |
3712 | { | 3646 | { |
3713 | ret--; | 3647 | ret--; |
@@ -3719,11 +3653,9 @@ LIBGNUNET_PLUGIN_TRANSPORT_INIT (void *cls) | |||
3719 | } | 3653 | } |
3720 | else | 3654 | else |
3721 | { | 3655 | { |
3722 | plugin->nat = GNUNET_NAT_register (env->cfg, | 3656 | plugin->nat = |
3723 | GNUNET_YES, | 3657 | GNUNET_NAT_register (env->cfg, GNUNET_YES, 0, 0, NULL, NULL, NULL, |
3724 | 0, | 3658 | &try_connection_reversal, plugin); |
3725 | 0, NULL, NULL, | ||
3726 | NULL, &try_connection_reversal, plugin); | ||
3727 | } | 3659 | } |
3728 | 3660 | ||
3729 | plugin->peers = GNUNET_CONTAINER_multihashmap_create (10); | 3661 | plugin->peers = GNUNET_CONTAINER_multihashmap_create (10); |