aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/scalarproduct/test_scalarproduct.conf3
-rw-r--r--src/transport/gnunet-service-transport.c41
-rw-r--r--src/transport/plugin_transport_tcp.c92
3 files changed, 81 insertions, 55 deletions
diff --git a/src/scalarproduct/test_scalarproduct.conf b/src/scalarproduct/test_scalarproduct.conf
index 3ab47cfeb..73dbadbce 100644
--- a/src/scalarproduct/test_scalarproduct.conf
+++ b/src/scalarproduct/test_scalarproduct.conf
@@ -21,6 +21,3 @@ WAN_QUOTA_OUT = unlimited
21 21
22[peerinfo] 22[peerinfo]
23USE_INCLUDED_HELLOS = NO 23USE_INCLUDED_HELLOS = NO
24
25[nat]
26RETURN_LOCAL_ADDRESSES = YES
diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c
index e7b221344..ec4d82164 100644
--- a/src/transport/gnunet-service-transport.c
+++ b/src/transport/gnunet-service-transport.c
@@ -150,11 +150,11 @@ struct TransportClient
150 150
151 /** 151 /**
152 * What type of client is this? 152 * What type of client is this?
153 */ 153 */
154 enum ClientType type; 154 enum ClientType type;
155 155
156 union { 156 union {
157 157
158 /** 158 /**
159 * Peer identity to monitor the addresses of. 159 * Peer identity to monitor the addresses of.
160 * Zero to monitor all neighbours. Valid if 160 * Zero to monitor all neighbours. Valid if
@@ -172,21 +172,21 @@ struct TransportClient
172 * if we're performing one that has been cancelled). 172 * if we're performing one that has been cancelled).
173 */ 173 */
174 struct GST_BlacklistCheck *bc; 174 struct GST_BlacklistCheck *bc;
175 175
176 /** 176 /**
177 * Set to #GNUNET_YES if we're currently waiting for a reply. 177 * Set to #GNUNET_YES if we're currently waiting for a reply.
178 */ 178 */
179 int waiting_for_reply; 179 int waiting_for_reply;
180 180
181 /** 181 /**
182 * #GNUNET_YES if we have to call receive_done for this client 182 * #GNUNET_YES if we have to call receive_done for this client
183 */ 183 */
184 int call_receive_done; 184 int call_receive_done;
185 185
186 } blacklist; 186 } blacklist;
187 187
188 } details; 188 } details;
189 189
190}; 190};
191 191
192 192
@@ -272,7 +272,7 @@ struct AddressToStringContext
272 */ 272 */
273struct SendTransmitContinuationContext 273struct SendTransmitContinuationContext
274{ 274{
275 275
276 /** 276 /**
277 * Client that made the request. 277 * Client that made the request.
278 */ 278 */
@@ -563,7 +563,7 @@ client_disconnect_cb (void *cls,
563 bc); 563 bc);
564 } 564 }
565 break; 565 break;
566 } 566 }
567 GNUNET_free (tc); 567 GNUNET_free (tc);
568} 568}
569 569
@@ -793,7 +793,7 @@ handle_client_send (void *cls,
793 const struct OutboundMessage *obm) 793 const struct OutboundMessage *obm)
794{ 794{
795 static unsigned long long uuid_gen; 795 static unsigned long long uuid_gen;
796 struct TransportClient *tc = cls; 796 struct TransportClient *tc = cls;
797 const struct GNUNET_MessageHeader *obmm; 797 const struct GNUNET_MessageHeader *obmm;
798 struct SendTransmitContinuationContext *stcc; 798 struct SendTransmitContinuationContext *stcc;
799 799
@@ -937,7 +937,7 @@ check_client_address_to_string (void *cls,
937 return GNUNET_SYSERR; 937 return GNUNET_SYSERR;
938 } 938 }
939 return GNUNET_OK; 939 return GNUNET_OK;
940} 940}
941 941
942 942
943/** 943/**
@@ -950,7 +950,7 @@ static void
950handle_client_address_to_string (void *cls, 950handle_client_address_to_string (void *cls,
951 const struct AddressLookupMessage *alum) 951 const struct AddressLookupMessage *alum)
952{ 952{
953 struct TransportClient *tc = cls; 953 struct TransportClient *tc = cls;
954 struct GNUNET_TRANSPORT_PluginFunctions *papi; 954 struct GNUNET_TRANSPORT_PluginFunctions *papi;
955 const char *plugin_name; 955 const char *plugin_name;
956 const char *address; 956 const char *address;
@@ -1308,7 +1308,7 @@ handle_client_monitor_plugins (void *cls,
1308 const struct GNUNET_MessageHeader *message) 1308 const struct GNUNET_MessageHeader *message)
1309{ 1309{
1310 struct TransportClient *tc = cls; 1310 struct TransportClient *tc = cls;
1311 1311
1312 GNUNET_SERVICE_client_mark_monitor (tc->client); 1312 GNUNET_SERVICE_client_mark_monitor (tc->client);
1313 GNUNET_SERVICE_client_disable_continue_warning (tc->client); 1313 GNUNET_SERVICE_client_disable_continue_warning (tc->client);
1314 GNUNET_notification_context_add (plugin_nc, 1314 GNUNET_notification_context_add (plugin_nc,
@@ -1690,9 +1690,10 @@ GST_receive_callback (void *cls,
1690 goto end; 1690 goto end;
1691 type = ntohs (message->type); 1691 type = ntohs (message->type);
1692 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1692 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1693 "Received message with type %u from peer `%s'\n", 1693 "Received message with type %u from peer `%s' at %s\n",
1694 type, 1694 type,
1695 GNUNET_i2s (&address->peer)); 1695 GNUNET_i2s (&address->peer),
1696 GST_plugins_a2s (address));
1696 1697
1697 GNUNET_STATISTICS_update (GST_stats, 1698 GNUNET_STATISTICS_update (GST_stats,
1698 gettext_noop ("# bytes total received"), 1699 gettext_noop ("# bytes total received"),
@@ -2226,7 +2227,7 @@ handle_client_set_metric (void *cls,
2226 const struct TrafficMetricMessage *tm) 2227 const struct TrafficMetricMessage *tm)
2227{ 2228{
2228 struct TransportClient *tc = cls; 2229 struct TransportClient *tc = cls;
2229 2230
2230 GST_manipulation_set_metric (tm); 2231 GST_manipulation_set_metric (tm);
2231 GNUNET_SERVICE_client_continue (tc->client); 2232 GNUNET_SERVICE_client_continue (tc->client);
2232} 2233}
@@ -2375,7 +2376,7 @@ handle_client_blacklist_reply (void *cls,
2375 bc = tc->details.blacklist.bc; 2376 bc = tc->details.blacklist.bc;
2376 tc->details.blacklist.bc = NULL; 2377 tc->details.blacklist.bc = NULL;
2377 tc->details.blacklist.waiting_for_reply = GNUNET_NO; 2378 tc->details.blacklist.waiting_for_reply = GNUNET_NO;
2378 tc->details.blacklist.call_receive_done = GNUNET_YES; 2379 tc->details.blacklist.call_receive_done = GNUNET_YES;
2379 if (NULL != bc) 2380 if (NULL != bc)
2380 { 2381 {
2381 /* only run this if the blacklist check has not been 2382 /* only run this if the blacklist check has not been
@@ -2808,7 +2809,7 @@ run (void *cls,
2808#if HAVE_GETRLIMIT 2809#if HAVE_GETRLIMIT
2809 { 2810 {
2810 struct rlimit r_file; 2811 struct rlimit r_file;
2811 2812
2812 if (0 == getrlimit (RLIMIT_NOFILE, 2813 if (0 == getrlimit (RLIMIT_NOFILE,
2813 &r_file)) 2814 &r_file))
2814 { 2815 {
@@ -2893,7 +2894,7 @@ GNUNET_SERVICE_MAIN
2893 GNUNET_MESSAGE_TYPE_TRANSPORT_SEND, 2894 GNUNET_MESSAGE_TYPE_TRANSPORT_SEND,
2894 struct OutboundMessage, 2895 struct OutboundMessage,
2895 NULL), 2896 NULL),
2896 GNUNET_MQ_hd_var_size (client_address_to_string, 2897 GNUNET_MQ_hd_var_size (client_address_to_string,
2897 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING, 2898 GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING,
2898 struct AddressLookupMessage, 2899 struct AddressLookupMessage,
2899 NULL), 2900 NULL),
@@ -2913,7 +2914,7 @@ GNUNET_SERVICE_MAIN
2913 GNUNET_MESSAGE_TYPE_TRANSPORT_TRAFFIC_METRIC, 2914 GNUNET_MESSAGE_TYPE_TRANSPORT_TRAFFIC_METRIC,
2914 struct TrafficMetricMessage, 2915 struct TrafficMetricMessage,
2915 NULL), 2916 NULL),
2916 GNUNET_MQ_hd_fixed_size (client_monitor_plugins, 2917 GNUNET_MQ_hd_fixed_size (client_monitor_plugins,
2917 GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_START, 2918 GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_START,
2918 struct GNUNET_MessageHeader, 2919 struct GNUNET_MessageHeader,
2919 NULL), 2920 NULL),
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c
index eca62a8ca..4ed5b38f7 100644
--- a/src/transport/plugin_transport_tcp.c
+++ b/src/transport/plugin_transport_tcp.c
@@ -1418,7 +1418,7 @@ create_session (struct Plugin *plugin,
1418 GNUNET_assert (NULL == client); 1418 GNUNET_assert (NULL == client);
1419 1419
1420 LOG (GNUNET_ERROR_TYPE_DEBUG, 1420 LOG (GNUNET_ERROR_TYPE_DEBUG,
1421 "Creating new session for peer `%4s' at address %s\n", 1421 "Creating new session for peer `%s' at address %s\n",
1422 GNUNET_i2s (&address->peer), 1422 GNUNET_i2s (&address->peer),
1423 tcp_plugin_address_to_string (plugin, 1423 tcp_plugin_address_to_string (plugin,
1424 address->address, 1424 address->address,
@@ -1522,7 +1522,7 @@ do_transmit (void *cls,
1522 if (NULL == buf) 1522 if (NULL == buf)
1523 { 1523 {
1524 LOG (GNUNET_ERROR_TYPE_DEBUG, 1524 LOG (GNUNET_ERROR_TYPE_DEBUG,
1525 "Timeout trying to transmit to peer `%4s', discarding message queue.\n", 1525 "Timeout trying to transmit to peer `%s', discarding message queue.\n",
1526 GNUNET_i2s (&session->target)); 1526 GNUNET_i2s (&session->target));
1527 /* timeout; cancel all messages that have already expired */ 1527 /* timeout; cancel all messages that have already expired */
1528 hd = NULL; 1528 hd = NULL;
@@ -1540,7 +1540,7 @@ do_transmit (void *cls,
1540 GNUNET_assert (pos->message_size <= session->bytes_in_queue); 1540 GNUNET_assert (pos->message_size <= session->bytes_in_queue);
1541 session->bytes_in_queue -= pos->message_size; 1541 session->bytes_in_queue -= pos->message_size;
1542 LOG (GNUNET_ERROR_TYPE_DEBUG, 1542 LOG (GNUNET_ERROR_TYPE_DEBUG,
1543 "Failed to transmit %u byte message to `%4s'.\n", 1543 "Failed to transmit %u byte message to `%s'.\n",
1544 pos->message_size, 1544 pos->message_size,
1545 GNUNET_i2s (&session->target)); 1545 GNUNET_i2s (&session->target));
1546 ret += pos->message_size; 1546 ret += pos->message_size;
@@ -1729,10 +1729,10 @@ tcp_plugin_send (void *cls,
1729 pm->transmit_cont = cont; 1729 pm->transmit_cont = cont;
1730 pm->transmit_cont_cls = cont_cls; 1730 pm->transmit_cont_cls = cont_cls;
1731 1731
1732 LOG(GNUNET_ERROR_TYPE_DEBUG, 1732 LOG (GNUNET_ERROR_TYPE_DEBUG,
1733 "Asked to transmit %u bytes to `%s', added message to list.\n", 1733 "Asked to transmit %u bytes to `%s', added message to list.\n",
1734 msgbuf_size, 1734 msgbuf_size,
1735 GNUNET_i2s (&session->target)); 1735 GNUNET_i2s (&session->target));
1736 1736
1737 if (GNUNET_YES == 1737 if (GNUNET_YES ==
1738 GNUNET_CONTAINER_multipeermap_contains_value (plugin->sessionmap, 1738 GNUNET_CONTAINER_multipeermap_contains_value (plugin->sessionmap,
@@ -1997,6 +1997,13 @@ tcp_plugin_get_session (void *cls,
1997 address->address_length)); 1997 address->address_length));
1998 return session; 1998 return session;
1999 } 1999 }
2000 /* This is a bit of a hack, limiting TCP to never allow more than
2001 one TCP connection to any given peer at the same time.
2002 Without this, peers sometimes disagree about which of the TCP
2003 connections they should use, causing one side to believe that
2004 they transmit successfully, while the other receives nothing. */
2005 return NULL; /* Refuse to have more than one TCP connection per
2006 peer pair at the same time. */
2000 } 2007 }
2001 2008
2002 if (addrlen == sizeof(struct IPv6TcpAddress)) 2009 if (addrlen == sizeof(struct IPv6TcpAddress))
@@ -2078,7 +2085,7 @@ tcp_plugin_get_session (void *cls,
2078 &address->peer))) 2085 &address->peer)))
2079 { 2086 {
2080 struct sockaddr_in local_sa; 2087 struct sockaddr_in local_sa;
2081 2088
2082 LOG (GNUNET_ERROR_TYPE_DEBUG, 2089 LOG (GNUNET_ERROR_TYPE_DEBUG,
2083 "Found valid IPv4 NAT address (creating session)!\n"); 2090 "Found valid IPv4 NAT address (creating session)!\n");
2084 session = create_session (plugin, 2091 session = create_session (plugin,
@@ -2168,13 +2175,13 @@ tcp_plugin_get_session (void *cls,
2168 if (NULL == sa) 2175 if (NULL == sa)
2169 { 2176 {
2170 LOG (GNUNET_ERROR_TYPE_DEBUG, 2177 LOG (GNUNET_ERROR_TYPE_DEBUG,
2171 "Failed to create connection to `%4s' at `%s'\n", 2178 "Failed to create connection to `%s' at `%s'\n",
2172 GNUNET_i2s (&address->peer), 2179 GNUNET_i2s (&address->peer),
2173 GNUNET_a2s (sb, sbs)); 2180 GNUNET_a2s (sb, sbs));
2174 return NULL; 2181 return NULL;
2175 } 2182 }
2176 LOG (GNUNET_ERROR_TYPE_DEBUG, 2183 LOG (GNUNET_ERROR_TYPE_DEBUG,
2177 "Asked to transmit to `%4s', creating fresh session using address `%s'.\n", 2184 "Asked to transmit to `%s', creating fresh session using address `%s'.\n",
2178 GNUNET_i2s (&address->peer), 2185 GNUNET_i2s (&address->peer),
2179 GNUNET_a2s (sb, sbs)); 2186 GNUNET_a2s (sb, sbs));
2180 2187
@@ -2246,7 +2253,7 @@ tcp_plugin_disconnect (void *cls,
2246 struct Plugin *plugin = cls; 2253 struct Plugin *plugin = cls;
2247 2254
2248 LOG (GNUNET_ERROR_TYPE_DEBUG, 2255 LOG (GNUNET_ERROR_TYPE_DEBUG,
2249 "Disconnecting peer `%4s'\n", 2256 "Disconnecting peer `%s'\n",
2250 GNUNET_i2s (target)); 2257 GNUNET_i2s (target));
2251 GNUNET_CONTAINER_multipeermap_get_multiple (plugin->sessionmap, 2258 GNUNET_CONTAINER_multipeermap_get_multiple (plugin->sessionmap,
2252 target, 2259 target,
@@ -2446,7 +2453,7 @@ tcp_plugin_check_address (void *cls,
2446 if (addrlen == sizeof(struct IPv4TcpAddress)) 2453 if (addrlen == sizeof(struct IPv4TcpAddress))
2447 { 2454 {
2448 struct sockaddr_in s4; 2455 struct sockaddr_in s4;
2449 2456
2450 v4 = (const struct IPv4TcpAddress *) addr; 2457 v4 = (const struct IPv4TcpAddress *) addr;
2451 if (0 != memcmp (&v4->options, 2458 if (0 != memcmp (&v4->options,
2452 &plugin->myoptions, 2459 &plugin->myoptions,
@@ -2462,7 +2469,7 @@ tcp_plugin_check_address (void *cls,
2462#endif 2469#endif
2463 s4.sin_port = v4->t4_port; 2470 s4.sin_port = v4->t4_port;
2464 s4.sin_addr.s_addr = v4->ipv4_addr; 2471 s4.sin_addr.s_addr = v4->ipv4_addr;
2465 2472
2466 if (GNUNET_OK != 2473 if (GNUNET_OK !=
2467 GNUNET_NAT_test_address (plugin->nat, 2474 GNUNET_NAT_test_address (plugin->nat,
2468 &s4, 2475 &s4,
@@ -2472,7 +2479,7 @@ tcp_plugin_check_address (void *cls,
2472 else 2479 else
2473 { 2480 {
2474 struct sockaddr_in6 s6; 2481 struct sockaddr_in6 s6;
2475 2482
2476 v6 = (const struct IPv6TcpAddress *) addr; 2483 v6 = (const struct IPv6TcpAddress *) addr;
2477 if (IN6_IS_ADDR_LINKLOCAL (&v6->ipv6_addr)) 2484 if (IN6_IS_ADDR_LINKLOCAL (&v6->ipv6_addr))
2478 { 2485 {
@@ -2686,27 +2693,37 @@ handle_tcp_welcome (void *cls,
2686 &alen)) 2693 &alen))
2687 { 2694 {
2688 LOG (GNUNET_ERROR_TYPE_INFO, 2695 LOG (GNUNET_ERROR_TYPE_INFO,
2689 "Received WELCOME message from my own identity `%4s' on address `%s'\n", 2696 "Received WELCOME message from my own identity `%s' on address `%s'\n",
2690 GNUNET_i2s (&wm->clientIdentity), 2697 GNUNET_i2s (&wm->clientIdentity),
2691 GNUNET_a2s (vaddr, alen)); 2698 GNUNET_a2s (vaddr, alen));
2692 GNUNET_free(vaddr); 2699 GNUNET_free (vaddr);
2693 } 2700 }
2694 return; 2701 return;
2695 } 2702 }
2696 2703
2697 LOG(GNUNET_ERROR_TYPE_DEBUG, 2704 if (GNUNET_OK ==
2698 "Received WELCOME message from `%4s' %p\n", 2705 GNUNET_SERVER_client_get_address (client,
2699 GNUNET_i2s (&wm->clientIdentity), 2706 &vaddr,
2700 client); 2707 &alen))
2708 {
2709 LOG(GNUNET_ERROR_TYPE_DEBUG,
2710 "Received WELCOME message from `%s' on address `%s'\n",
2711 GNUNET_i2s (&wm->clientIdentity),
2712 GNUNET_a2s (vaddr, alen));
2713 GNUNET_free (vaddr);
2714 }
2701 GNUNET_STATISTICS_update (plugin->env->stats, 2715 GNUNET_STATISTICS_update (plugin->env->stats,
2702 gettext_noop ("# TCP WELCOME messages received"), 2716 gettext_noop ("# TCP WELCOME messages received"),
2703 1, 2717 1,
2704 GNUNET_NO); 2718 GNUNET_NO);
2705 session = lookup_session_by_client (plugin, client); 2719 session = lookup_session_by_client (plugin,
2720 client);
2706 if (NULL != session) 2721 if (NULL != session)
2707 { 2722 {
2708 if (GNUNET_OK == 2723 if (GNUNET_OK ==
2709 GNUNET_SERVER_client_get_address (client, &vaddr, &alen)) 2724 GNUNET_SERVER_client_get_address (client,
2725 &vaddr,
2726 &alen))
2710 { 2727 {
2711 LOG (GNUNET_ERROR_TYPE_DEBUG, 2728 LOG (GNUNET_ERROR_TYPE_DEBUG,
2712 "Found existing session %p for peer `%s'\n", 2729 "Found existing session %p for peer `%s'\n",
@@ -2795,12 +2812,11 @@ handle_tcp_welcome (void *cls,
2795 } 2812 }
2796 } 2813 }
2797 2814
2798 if (session->expecting_welcome != GNUNET_YES) 2815 if (GNUNET_YES != session->expecting_welcome)
2799 { 2816 {
2800 GNUNET_break_op(0); 2817 GNUNET_break_op (0);
2801 GNUNET_SERVER_receive_done (client, 2818 GNUNET_SERVER_receive_done (client,
2802 GNUNET_SYSERR); 2819 GNUNET_SYSERR);
2803 GNUNET_break(0);
2804 return; 2820 return;
2805 } 2821 }
2806 session->last_activity = GNUNET_TIME_absolute_get (); 2822 session->last_activity = GNUNET_TIME_absolute_get ();
@@ -2869,7 +2885,9 @@ handle_tcp_data (void *cls,
2869 void *vaddr; 2885 void *vaddr;
2870 size_t alen; 2886 size_t alen;
2871 2887
2872 GNUNET_SERVER_client_get_address (client, &vaddr, &alen); 2888 GNUNET_SERVER_client_get_address (client,
2889 &vaddr,
2890 &alen);
2873 LOG (GNUNET_ERROR_TYPE_ERROR, 2891 LOG (GNUNET_ERROR_TYPE_ERROR,
2874 "Received unexpected %u bytes of type %u from `%s'\n", 2892 "Received unexpected %u bytes of type %u from `%s'\n",
2875 (unsigned int) ntohs (message->size), 2893 (unsigned int) ntohs (message->size),
@@ -2883,11 +2901,21 @@ handle_tcp_data (void *cls,
2883 } 2901 }
2884 2902
2885 session->last_activity = GNUNET_TIME_absolute_get (); 2903 session->last_activity = GNUNET_TIME_absolute_get ();
2886 LOG (GNUNET_ERROR_TYPE_DEBUG, 2904 {
2887 "Passing %u bytes of type %u from `%4s' to transport service.\n", 2905 void *vaddr;
2888 (unsigned int) ntohs (message->size), 2906 size_t alen;
2889 (unsigned int) ntohs (message->type), 2907
2890 GNUNET_i2s (&session->target)); 2908 GNUNET_SERVER_client_get_address (client,
2909 &vaddr,
2910 &alen);
2911 LOG (GNUNET_ERROR_TYPE_DEBUG,
2912 "Passing %u bytes of type %u from `%s' at %s to transport service.\n",
2913 (unsigned int) ntohs (message->size),
2914 (unsigned int) ntohs (message->type),
2915 GNUNET_i2s (&session->target),
2916 GNUNET_a2s (vaddr, alen));
2917 GNUNET_free_non_null (vaddr);
2918 }
2891 2919
2892 GNUNET_STATISTICS_update (plugin->env->stats, 2920 GNUNET_STATISTICS_update (plugin->env->stats,
2893 gettext_noop ("# bytes received via TCP"), 2921 gettext_noop ("# bytes received via TCP"),
@@ -2984,7 +3012,7 @@ disconnect_notify (void *cls,
2984 if (NULL == session) 3012 if (NULL == session)
2985 return; /* unknown, nothing to do */ 3013 return; /* unknown, nothing to do */
2986 LOG (GNUNET_ERROR_TYPE_DEBUG, 3014 LOG (GNUNET_ERROR_TYPE_DEBUG,
2987 "Destroying session of `%4s' with %s due to network-level disconnect.\n", 3015 "Destroying session of `%s' with %s due to network-level disconnect.\n",
2988 GNUNET_i2s (&session->target), 3016 GNUNET_i2s (&session->target),
2989 tcp_plugin_address_to_string (session->plugin, 3017 tcp_plugin_address_to_string (session->plugin,
2990 session->address->address, 3018 session->address->address,