}
+/**
+ * Convert state to human-readable string.
+ *
+ * @param state the state value
+ * @return corresponding string
+ */
static const char *
-print_state (int state)
+print_state (enum State state)
{
-
switch (state)
{
case S_NOT_CONNECTED:
static void
disconnect_neighbour (struct NeighbourMapEntry *n)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Disconnecting from peer %s in state %s\n",
+ GNUNET_i2s (&n->id),
+ print_state (n->state));
/* depending on state, notify neighbour and/or upper layers of this peer
about disconnect */
switch (n->state)
}
if (bytes_in_send_queue < mq->message_buf_size)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Bytes_in_send_queue `%u', Message_size %u, result: %s, payload %u, on wire %u\n",
- bytes_in_send_queue, mq->message_buf_size,
- (GNUNET_OK == success) ? "OK" : "FAIL",
- size_payload, physical);
- GNUNET_break (0);
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Bytes_in_send_queue `%u', Message_size %u, result: %s, payload %u, on wire %u\n",
+ bytes_in_send_queue, mq->message_buf_size,
+ (GNUNET_OK == success) ? "OK" : "FAIL",
+ size_payload, physical);
+ GNUNET_break (0);
}
1, GNUNET_NO);
GNUNET_CONTAINER_DLL_remove (n->messages_head, n->messages_tail, mq);
n->is_active = mq;
- transmit_send_continuation (mq, &n->id, GNUNET_SYSERR, mq->message_buf_size, 0); /* timeout */
+ transmit_send_continuation (mq, &n->id,
+ GNUNET_SYSERR,
+ mq->message_buf_size, 0); /* timeout */
}
if (NULL == mq)
return; /* no more messages */
while (0 == nonce)
nonce = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX);
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Sending keep alive response to peer `%s' with nonce %u\n",
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Sending keep alive to peer `%s' with nonce %u\n",
GNUNET_i2s (&n->id), nonce);
m.header.size = htons (sizeof (struct SessionKeepAliveMessage));
return;
}
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received keep alive request from peer `%s' with nonce %u\n",
GNUNET_i2s (&n->id), ntohl (msg_in->nonce));
}
else
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received keep alive response from peer `%s' for session %p\n",
GNUNET_i2s (&n->id), n->primary_address.session);
/* Update session timeout here */
if (NULL != (papi = GST_plugins_find (n->primary_address.address->transport_name)))
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Updating session for peer `%s' for session %p\n",
GNUNET_i2s (&n->id), n->primary_address.session);
papi->update_session_timeout (papi->cls, &n->id, n->primary_address.session);
GNUNET_break (0);
}
+ n->primary_address.keep_alive_nonce = 0;
n->expect_latency_response = GNUNET_NO;
n->latency = GNUNET_TIME_absolute_get_duration (n->last_keep_alive_time);
n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
*
* @param sender sender of the message
* @param size size of the message
- * @param do_forward set to GNUNET_YES if the message should be forwarded to clients
- * GNUNET_NO if the neighbour is not connected or violates the quota,
- * GNUNET_SYSERR if the connection is not fully up yet
+ * @param do_forward set to #GNUNET_YES if the message should be forwarded to clients
+ * #GNUNET_NO if the neighbour is not connected or violates the quota,
+ * #GNUNET_SYSERR if the connection is not fully up yet
* @return how long to wait before reading more from this sender
*/
struct GNUNET_TIME_Relative
GNUNET_i2s (peer),
(GNUNET_OK == result) ? "allowed" : "FORBIDDEN");
if (GNUNET_OK == result)
- GST_ats_add_address (bcc->na.address, bcc->na.session);
+ GST_ats_add_address (bcc->na.address, bcc->na.session, NULL, 0);
else
{
/* Blacklist disagreed on connecting to a peer with this address
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "ATS tells us to switch to address '%s' session %p for "
+ "ATS tells us to switch to address '%s/%s' session %p for "
"peer `%s' in state %s/%d (quota in/out %u %u )\n",
(address->address_length != 0) ? GST_plugins_a2s (address): "<inbound>",
+ address->transport_name,
session,
GNUNET_i2s (peer),
print_state (n->state),
address and check blacklist again */
set_address (&n->primary_address,
address, session, bandwidth_in, bandwidth_out, GNUNET_NO);
+ n->state = S_CONNECT_RECV_BLACKLIST;
n->timeout = GNUNET_TIME_relative_to_absolute (BLACKLIST_RESPONSE_TIMEOUT);
check_blacklist (&n->id,
n->connect_ack_timestamp,
n->primary_address.bandwidth_in,
n->primary_address.bandwidth_out);
/* Tell ATS that the outbound session we created to send CONNECT was successful */
- GST_ats_add_address (n->primary_address.address, n->primary_address.session);
+ GST_ats_add_address (n->primary_address.address,
+ n->primary_address.session,
+ NULL, 0);
set_address (&n->primary_address,
n->primary_address.address,
n->primary_address.session,
n->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT);
GNUNET_break (GNUNET_NO == n->alternative_address.ats_active);
- GST_ats_add_address (n->alternative_address.address, n->alternative_address.session);
+ GST_ats_add_address (n->alternative_address.address,
+ n->alternative_address.session,
+ NULL, 0);
set_address (&n->primary_address,
n->alternative_address.address,
n->alternative_address.session,
n->primary_address.bandwidth_in,
n->primary_address.bandwidth_out);
- GST_ats_add_address (n->primary_address.address, n->primary_address.session);
+ GST_ats_add_address (n->primary_address.address,
+ n->primary_address.session,
+ NULL, 0);
set_address (&n->primary_address,
n->primary_address.address,
n->primary_address.session,
GNUNET_BANDWIDTH_tracker_update_quota (&n->in_tracker, quota);
if (0 != ntohl (quota.value__))
return;
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting peer `%4s' due to `%s'\n",
- GNUNET_i2s (&n->id), "SET_QUOTA");
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Disconnecting peer `%4s' due to SET_QUOTA\n",
+ GNUNET_i2s (&n->id));
if (GNUNET_YES == test_connected (n))
GNUNET_STATISTICS_update (GST_stats,
gettext_noop ("# disconnects due to quota of 0"),
* @param msg the disconnect message
*/
void
-GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity
- *peer,
- const struct GNUNET_MessageHeader
- *msg)
+GST_neighbours_handle_disconnect_message (const struct GNUNET_PeerIdentity *peer,
+ const struct GNUNET_MessageHeader *msg)
{
struct NeighbourMapEntry *n;
const struct SessionDisconnectMessage *sdm;
gettext_noop
("# other peer asked to disconnect from us"), 1,
GNUNET_NO);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Disconnecting by request from peer %s\n",
+ GNUNET_i2s (peer));
disconnect_neighbour (n);
}
gettext_noop
("# disconnected from peer upon explicit request"), 1,
GNUNET_NO);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Forced disconnect from peer %s\n",
+ GNUNET_i2s (target));
disconnect_neighbour (n);
}