/**
* What type of client is this?
- */
+ */
enum ClientType type;
union {
-
+
/**
* Peer identity to monitor the addresses of.
* Zero to monitor all neighbours. Valid if
* if we're performing one that has been cancelled).
*/
struct GST_BlacklistCheck *bc;
-
+
/**
* Set to #GNUNET_YES if we're currently waiting for a reply.
*/
int waiting_for_reply;
-
+
/**
* #GNUNET_YES if we have to call receive_done for this client
*/
int call_receive_done;
-
+
} blacklist;
-
+
} details;
-
+
};
*/
struct SendTransmitContinuationContext
{
-
+
/**
* Client that made the request.
*/
bc);
}
break;
- }
+ }
GNUNET_free (tc);
}
const struct OutboundMessage *obm)
{
static unsigned long long uuid_gen;
- struct TransportClient *tc = cls;
+ struct TransportClient *tc = cls;
const struct GNUNET_MessageHeader *obmm;
struct SendTransmitContinuationContext *stcc;
return GNUNET_SYSERR;
}
return GNUNET_OK;
-}
+}
/**
handle_client_address_to_string (void *cls,
const struct AddressLookupMessage *alum)
{
- struct TransportClient *tc = cls;
+ struct TransportClient *tc = cls;
struct GNUNET_TRANSPORT_PluginFunctions *papi;
const char *plugin_name;
const char *address;
const struct GNUNET_MessageHeader *message)
{
struct TransportClient *tc = cls;
-
+
GNUNET_SERVICE_client_mark_monitor (tc->client);
GNUNET_SERVICE_client_disable_continue_warning (tc->client);
GNUNET_notification_context_add (plugin_nc,
goto end;
type = ntohs (message->type);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Received message with type %u from peer `%s'\n",
+ "Received message with type %u from peer `%s' at %s\n",
type,
- GNUNET_i2s (&address->peer));
+ GNUNET_i2s (&address->peer),
+ GST_plugins_a2s (address));
GNUNET_STATISTICS_update (GST_stats,
gettext_noop ("# bytes total received"),
const struct TrafficMetricMessage *tm)
{
struct TransportClient *tc = cls;
-
+
GST_manipulation_set_metric (tm);
GNUNET_SERVICE_client_continue (tc->client);
}
bc = tc->details.blacklist.bc;
tc->details.blacklist.bc = NULL;
tc->details.blacklist.waiting_for_reply = GNUNET_NO;
- tc->details.blacklist.call_receive_done = GNUNET_YES;
+ tc->details.blacklist.call_receive_done = GNUNET_YES;
if (NULL != bc)
{
/* only run this if the blacklist check has not been
#if HAVE_GETRLIMIT
{
struct rlimit r_file;
-
+
if (0 == getrlimit (RLIMIT_NOFILE,
&r_file))
{
GNUNET_MESSAGE_TYPE_TRANSPORT_SEND,
struct OutboundMessage,
NULL),
- GNUNET_MQ_hd_var_size (client_address_to_string,
+ GNUNET_MQ_hd_var_size (client_address_to_string,
GNUNET_MESSAGE_TYPE_TRANSPORT_ADDRESS_TO_STRING,
struct AddressLookupMessage,
NULL),
GNUNET_MESSAGE_TYPE_TRANSPORT_TRAFFIC_METRIC,
struct TrafficMetricMessage,
NULL),
- GNUNET_MQ_hd_fixed_size (client_monitor_plugins,
+ GNUNET_MQ_hd_fixed_size (client_monitor_plugins,
GNUNET_MESSAGE_TYPE_TRANSPORT_MONITOR_PLUGIN_START,
struct GNUNET_MessageHeader,
NULL),
GNUNET_assert (NULL == client);
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Creating new session for peer `%4s' at address %s\n",
+ "Creating new session for peer `%s' at address %s\n",
GNUNET_i2s (&address->peer),
tcp_plugin_address_to_string (plugin,
address->address,
if (NULL == buf)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Timeout trying to transmit to peer `%4s', discarding message queue.\n",
+ "Timeout trying to transmit to peer `%s', discarding message queue.\n",
GNUNET_i2s (&session->target));
/* timeout; cancel all messages that have already expired */
hd = NULL;
GNUNET_assert (pos->message_size <= session->bytes_in_queue);
session->bytes_in_queue -= pos->message_size;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Failed to transmit %u byte message to `%4s'.\n",
+ "Failed to transmit %u byte message to `%s'.\n",
pos->message_size,
GNUNET_i2s (&session->target));
ret += pos->message_size;
pm->transmit_cont = cont;
pm->transmit_cont_cls = cont_cls;
- LOG(GNUNET_ERROR_TYPE_DEBUG,
- "Asked to transmit %u bytes to `%s', added message to list.\n",
- msgbuf_size,
- GNUNET_i2s (&session->target));
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Asked to transmit %u bytes to `%s', added message to list.\n",
+ msgbuf_size,
+ GNUNET_i2s (&session->target));
if (GNUNET_YES ==
GNUNET_CONTAINER_multipeermap_contains_value (plugin->sessionmap,
address->address_length));
return session;
}
+ /* This is a bit of a hack, limiting TCP to never allow more than
+ one TCP connection to any given peer at the same time.
+ Without this, peers sometimes disagree about which of the TCP
+ connections they should use, causing one side to believe that
+ they transmit successfully, while the other receives nothing. */
+ return NULL; /* Refuse to have more than one TCP connection per
+ peer pair at the same time. */
}
if (addrlen == sizeof(struct IPv6TcpAddress))
&address->peer)))
{
struct sockaddr_in local_sa;
-
+
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Found valid IPv4 NAT address (creating session)!\n");
session = create_session (plugin,
if (NULL == sa)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Failed to create connection to `%4s' at `%s'\n",
+ "Failed to create connection to `%s' at `%s'\n",
GNUNET_i2s (&address->peer),
GNUNET_a2s (sb, sbs));
return NULL;
}
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Asked to transmit to `%4s', creating fresh session using address `%s'.\n",
+ "Asked to transmit to `%s', creating fresh session using address `%s'.\n",
GNUNET_i2s (&address->peer),
GNUNET_a2s (sb, sbs));
struct Plugin *plugin = cls;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Disconnecting peer `%4s'\n",
+ "Disconnecting peer `%s'\n",
GNUNET_i2s (target));
GNUNET_CONTAINER_multipeermap_get_multiple (plugin->sessionmap,
target,
if (addrlen == sizeof(struct IPv4TcpAddress))
{
struct sockaddr_in s4;
-
+
v4 = (const struct IPv4TcpAddress *) addr;
if (0 != memcmp (&v4->options,
&plugin->myoptions,
#endif
s4.sin_port = v4->t4_port;
s4.sin_addr.s_addr = v4->ipv4_addr;
-
+
if (GNUNET_OK !=
GNUNET_NAT_test_address (plugin->nat,
&s4,
else
{
struct sockaddr_in6 s6;
-
+
v6 = (const struct IPv6TcpAddress *) addr;
if (IN6_IS_ADDR_LINKLOCAL (&v6->ipv6_addr))
{
&alen))
{
LOG (GNUNET_ERROR_TYPE_INFO,
- "Received WELCOME message from my own identity `%4s' on address `%s'\n",
+ "Received WELCOME message from my own identity `%s' on address `%s'\n",
GNUNET_i2s (&wm->clientIdentity),
GNUNET_a2s (vaddr, alen));
- GNUNET_free(vaddr);
+ GNUNET_free (vaddr);
}
return;
}
- LOG(GNUNET_ERROR_TYPE_DEBUG,
- "Received WELCOME message from `%4s' %p\n",
- GNUNET_i2s (&wm->clientIdentity),
- client);
+ if (GNUNET_OK ==
+ GNUNET_SERVER_client_get_address (client,
+ &vaddr,
+ &alen))
+ {
+ LOG(GNUNET_ERROR_TYPE_DEBUG,
+ "Received WELCOME message from `%s' on address `%s'\n",
+ GNUNET_i2s (&wm->clientIdentity),
+ GNUNET_a2s (vaddr, alen));
+ GNUNET_free (vaddr);
+ }
GNUNET_STATISTICS_update (plugin->env->stats,
gettext_noop ("# TCP WELCOME messages received"),
1,
GNUNET_NO);
- session = lookup_session_by_client (plugin, client);
+ session = lookup_session_by_client (plugin,
+ client);
if (NULL != session)
{
if (GNUNET_OK ==
- GNUNET_SERVER_client_get_address (client, &vaddr, &alen))
+ GNUNET_SERVER_client_get_address (client,
+ &vaddr,
+ &alen))
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Found existing session %p for peer `%s'\n",
}
}
- if (session->expecting_welcome != GNUNET_YES)
+ if (GNUNET_YES != session->expecting_welcome)
{
- GNUNET_break_op(0);
+ GNUNET_break_op (0);
GNUNET_SERVER_receive_done (client,
GNUNET_SYSERR);
- GNUNET_break(0);
return;
}
session->last_activity = GNUNET_TIME_absolute_get ();
void *vaddr;
size_t alen;
- GNUNET_SERVER_client_get_address (client, &vaddr, &alen);
+ GNUNET_SERVER_client_get_address (client,
+ &vaddr,
+ &alen);
LOG (GNUNET_ERROR_TYPE_ERROR,
"Received unexpected %u bytes of type %u from `%s'\n",
(unsigned int) ntohs (message->size),
}
session->last_activity = GNUNET_TIME_absolute_get ();
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Passing %u bytes of type %u from `%4s' to transport service.\n",
- (unsigned int) ntohs (message->size),
- (unsigned int) ntohs (message->type),
- GNUNET_i2s (&session->target));
+ {
+ void *vaddr;
+ size_t alen;
+
+ GNUNET_SERVER_client_get_address (client,
+ &vaddr,
+ &alen);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Passing %u bytes of type %u from `%s' at %s to transport service.\n",
+ (unsigned int) ntohs (message->size),
+ (unsigned int) ntohs (message->type),
+ GNUNET_i2s (&session->target),
+ GNUNET_a2s (vaddr, alen));
+ GNUNET_free_non_null (vaddr);
+ }
GNUNET_STATISTICS_update (plugin->env->stats,
gettext_noop ("# bytes received via TCP"),
if (NULL == session)
return; /* unknown, nothing to do */
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Destroying session of `%4s' with %s due to network-level disconnect.\n",
+ "Destroying session of `%s' with %s due to network-level disconnect.\n",
GNUNET_i2s (&session->target),
tcp_plugin_address_to_string (session->plugin,
session->address->address,