int delta;
/* If origin, there is no connection to send ACKs. Wrong function! */
+ GCC_check_connections ();
if (GCC_is_origin (c, fwd))
{
LOG (GNUNET_ERROR_TYPE_DEBUG, "connection %s is origin in %s\n",
LOG (GNUNET_ERROR_TYPE_DEBUG,
" last pid recv: %u, last ack sent: %u\n",
prev_fc->last_pid_recv, prev_fc->last_ack_sent);
+ GCC_check_connections ();
return;
}
if (ack == prev_fc->last_ack_sent && GNUNET_NO == force)
{
LOG (GNUNET_ERROR_TYPE_DEBUG, "Not sending FWD ACK, not needed\n");
+ GCC_check_connections ();
return;
}
else
{
LOG (GNUNET_ERROR_TYPE_DEBUG, " same ACK already in queue\n");
+ GCC_check_connections ();
return;
}
}
!fwd, GNUNET_YES,
&ack_sent, prev_fc);
GNUNET_assert (NULL != prev_fc->ack_msg);
+ GCC_check_connections ();
}
double usecsperbyte;
int forced;
+ GCC_check_connections ();
LOG (GNUNET_ERROR_TYPE_DEBUG, "connection message_sent\n");
GCC_debug (c, GNUNET_ERROR_TYPE_DEBUG);
LOG (GNUNET_ERROR_TYPE_ERROR, "Message %s sent on NULL connection!\n",
GC_m2s (type));
}
+ GCC_check_connections ();
return GNUNET_NO;
}
LOG (GNUNET_ERROR_TYPE_DEBUG, " C_P- %p %u\n", c, c->pending_messages);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"! destroying connection!\n");
GCC_destroy (c);
+ GCC_check_connections ();
return GNUNET_YES;
}
/* Send ACK if needed, after accounting for sent ID in fc->queue_n */
p->avg /= p->size;
}
p->idx = (p->idx + 1) % AVG_MSGS;
+ GCC_check_connections ();
return GNUNET_NO;
}
GCP_check_connection (get_prev_hop (c), c);
}
+
/**
* Helper for #check_connections(). Calls #check_neighbours().
*
/**
- * Check all connections using #check_neighbours().
+ * Check invariants for all connections using #check_neighbours().
*/
-static void
-check_connections ()
+void
+GCC_check_connections ()
{
+ if (NULL == connections)
+ return;
GNUNET_CONTAINER_multihashmap_iterate (connections,
&check_connection,
NULL);
{
struct CadetTunnel *t;
+ GCC_check_connections ();
t = connection->t;
LOG (GNUNET_ERROR_TYPE_INFO, "---> {%14s ACK} on connection %s\n",
GC_f2s (!fwd), GCC_2s (connection));
GCT_change_cstate (t, CADET_TUNNEL_WAITING);
if (CADET_CONNECTION_READY != connection->state)
connection_change_state (connection, CADET_CONNECTION_SENT);
+ GCC_check_connections ();
}
{
struct GNUNET_CADET_ConnectionBroken msg;
+ GCC_check_connections ();
msg.header.size = htons (sizeof (struct GNUNET_CADET_ConnectionBroken));
msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN);
msg.cid = c->id;
msg.peer1 = *id1;
msg.peer2 = *id2;
- GNUNET_assert (NULL == GCC_send_prebuilt_message (&msg.header, 0, 0, c, fwd,
- GNUNET_YES, NULL, NULL));
+ GNUNET_assert (NULL ==
+ GCC_send_prebuilt_message (&msg.header, 0, 0, c, fwd,
+ GNUNET_YES, NULL, NULL));
+ GCC_check_connections ();
}
struct GNUNET_CADET_ConnectionBroken *msg;
struct CadetPeer *neighbor;
+ GCC_check_connections ();
LOG (GNUNET_ERROR_TYPE_INFO, "---> BROKEN on unknown connection %s\n",
GNUNET_h2s (GC_h2hc (connection_id)));
0, 2, sizeof (struct GNUNET_CADET_ConnectionBroken),
NULL, GNUNET_SYSERR, /* connection, fwd */
NULL, NULL); /* continuation */
+ GCC_check_connections ();
}
struct GNUNET_MessageHeader msg;
struct CadetFlowControl *fc;
- LOG (GNUNET_ERROR_TYPE_INFO, "keepalive %s for connection %s\n",
+ GCC_check_connections ();
+ LOG (GNUNET_ERROR_TYPE_INFO,
+ "keepalive %s for connection %s\n",
GC_f2s (fwd), GCC_2s (c));
fc = fwd ? &c->fwd_fc : &c->bck_fc;
GNUNET_assert (NULL ==
GCT_send_prebuilt_message (&msg, c->t, c,
GNUNET_NO, NULL, NULL));
+ GCC_check_connections ();
}
static void
connection_recreate (struct CadetConnection *c, int fwd)
{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "sending connection recreate\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "sending connection recreate\n");
if (fwd)
GCC_send_create (c);
else
}
-
/**
* Keep the connection alive.
*
static void
connection_keepalive (struct CadetConnection *c, int fwd, int shutdown)
{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "%s keepalive for %s\n",
+ GCC_check_connections ();
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "%s keepalive for %s\n",
GC_f2s (fwd), GCC_2s (c));
if (fwd)
return;
connection_maintain (c, fwd);
-
+ GCC_check_connections ();
/* Next execution will be scheduled by message_sent or _maintain*/
}
connection_fwd_keepalive (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
+ GCC_check_connections ();
connection_keepalive ((struct CadetConnection *) cls,
GNUNET_YES,
tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN);
+ GCC_check_connections ();
}
connection_bck_keepalive (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
+ GCC_check_connections ();
connection_keepalive ((struct CadetConnection *) cls,
GNUNET_NO,
tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN);
+ GCC_check_connections ();
}
struct GNUNET_SCHEDULER_Task * *task_id;
GNUNET_SCHEDULER_TaskCallback keepalive_task;
+ GCC_check_connections ();
if (GNUNET_NO == GCC_is_origin (c, fwd))
return;
}
/* Schedule the task */
- *task_id = GNUNET_SCHEDULER_add_delayed (delay, keepalive_task, c);
+ *task_id = GNUNET_SCHEDULER_add_delayed (delay,
+ keepalive_task,
+ c);
LOG (GNUNET_ERROR_TYPE_DEBUG, "next keepalive in %s\n",
GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES));
+ GCC_check_connections ();
}
{
struct CadetPeer *peer;
- LOG (GNUNET_ERROR_TYPE_DEBUG, "connection_unlock_queue %s on %s\n",
+ GCC_check_connections ();
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "connection_unlock_queue %s on %s\n",
GC_f2s (fwd), GCC_2s (c));
if (GCC_is_terminal (c, fwd))
peer = get_hop (c, fwd);
GCP_queue_unlock (peer, c);
+ GCC_check_connections ();
}
struct CadetFlowControl *fc;
struct CadetPeer *peer;
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Cancel %s queues for connection %s\n",
+ GCC_check_connections ();
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Cancel %s queues for connection %s\n",
GC_f2s (fwd), GCC_2s (c));
if (NULL == c)
{
}
peer = get_hop (c, fwd);
GCP_queue_cancel (peer, c);
+ GCC_check_connections ();
}
* @param tc TaskContext.
*/
static void
-connection_poll (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
+connection_poll (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc);
/**
fc->poll_msg = NULL;
fc->poll_time = GNUNET_TIME_STD_BACKOFF (fc->poll_time);
fc->poll_task = GNUNET_SCHEDULER_add_delayed (fc->poll_time,
- &connection_poll, fc);
+ &connection_poll,
+ fc);
LOG (GNUNET_ERROR_TYPE_DEBUG, " task %u\n", fc->poll_task);
-
}
+
/**
* Function called if a connection has been stalled for a while,
* possibly due to a missed ACK. Poll the neighbor about its ACK status.
int fwd;
fc->poll_task = NULL;
+ GCC_check_connections ();
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
{
return;
GCC_send_prebuilt_message (&msg.header, 0, fc->last_pid_sent, c,
fc == &c->fwd_fc, GNUNET_YES, &poll_sent, fc);
GNUNET_assert (NULL != fc->poll_msg);
+ GCC_check_connections ();
}
unsigned int pending;
int destroyed;
+ GCC_check_connections ();
c->state = CADET_CONNECTION_DESTROYED;
c->destroy = GNUNET_YES;
}
GCC_destroy (c);
}
+ GCC_check_connections ();
}
{
struct CadetFlowControl *reverse_fc;
+ GCC_check_connections ();
reverse_fc = fwd ? &c->bck_fc : &c->fwd_fc;
LOG (GNUNET_ERROR_TYPE_INFO,
send_broken_unknown (&c->id, &my_full_id, NULL, next_hop);
if (0 < reverse_fc->queue_n)
resend_messages_and_destroy (c, !fwd);
+ GCC_check_connections ();
return;
}
GCC_destroy (c);
+ GCC_check_connections ();
}
c->fwd_maintenance_task = NULL;
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
return;
-
+ GCC_check_connections ();
connection_timeout (c, GNUNET_YES);
+ GCC_check_connections ();
}
c->bck_maintenance_task = NULL;
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
return;
-
+ GCC_check_connections ();
connection_timeout (c, GNUNET_NO);
+ GCC_check_connections ();
}
connection_reset_timeout (struct CadetConnection *c, int fwd)
{
LOG (GNUNET_ERROR_TYPE_DEBUG, "Connection %s reset timeout\n", GC_f2s (fwd));
-
if (GCC_is_origin (c, fwd)) /* Startpoint */
{
schedule_next_keepalive (c, fwd);
}
-
/**
* Iterator to compare each connection's path with the path of a new connection.
*
}
}
+
/**
* Finds out if this path is already being used by and existing connection.
*
* the peer will eventually reject our attempt).
*
* @param path Path to check.
- *
- * @return GNUNET_YES if the tunnel has a connection with the same path,
- * GNUNET_NO otherwise.
+ * @return #GNUNET_YES if the tunnel has a connection with the same path,
+ * #GNUNET_NO otherwise.
*/
static int
does_connection_exist (struct CadetConnection *conn)
unsigned int own_pos;
uint16_t size;
- check_connections ();
+ GCC_check_connections ();
/* Check size */
size = ntohs (message->size);
if (size < sizeof (struct GNUNET_CADET_ConnectionCreate))
/* If we are destination, why did the creation fail? */
GNUNET_break (0);
path_destroy (path);
- check_connections ();
+ GCC_check_connections ();
return GNUNET_OK;
}
send_broken_unknown (cid, &my_full_id,
GNUNET_PEER_resolve2 (path->peers[own_pos + 1]),
peer);
path_destroy (path);
- check_connections ();
+ GCC_check_connections ();
return GNUNET_OK;
}
GCP_add_path_to_all (path, GNUNET_NO);
path_destroy (path);
GCC_destroy (c);
send_broken_unknown (cid, &my_full_id, NULL, peer);
- check_connections ();
+ GCC_check_connections ();
return GNUNET_OK;
}
NULL, NULL));
}
path_destroy (path);
- check_connections ();
+ GCC_check_connections ();
return GNUNET_OK;
}
enum CadetConnectionState oldstate;
int fwd;
- check_connections ();
+ GCC_check_connections ();
msg = (struct GNUNET_CADET_ConnectionACK *) message;
log_message (message, peer, &msg->cid);
c = connection_get (&msg->cid);
LOG (GNUNET_ERROR_TYPE_DEBUG,
" don't know the connection!\n");
send_broken_unknown (&msg->cid, &my_full_id, NULL, peer);
- check_connections ();
+ GCC_check_connections ();
return GNUNET_OK;
}
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
" connection being destroyed\n");
- check_connections ();
+ GCC_check_connections ();
return GNUNET_OK;
}
/* Change tunnel state, trigger KX */
if (CADET_TUNNEL_WAITING == GCT_get_cstate (c->t))
GCT_change_cstate (c->t, CADET_TUNNEL_READY);
- check_connections ();
+ GCC_check_connections ();
return GNUNET_OK;
}
/* Change tunnel state */
if (CADET_TUNNEL_WAITING == GCT_get_cstate (c->t))
GCT_change_cstate (c->t, CADET_TUNNEL_READY);
- check_connections ();
+ GCC_check_connections ();
return GNUNET_OK;
}
GNUNET_assert (NULL ==
GCC_send_prebuilt_message (message, 0, 0, c, fwd,
GNUNET_YES, NULL, NULL));
- check_connections ();
+ GCC_check_connections ();
return GNUNET_OK;
}
int pending;
int fwd;
- check_connections ();
+ GCC_check_connections ();
msg = (struct GNUNET_CADET_ConnectionBroken *) message;
log_message (message, id, &msg->cid);
LOG (GNUNET_ERROR_TYPE_DEBUG, " regarding %s\n",
if (NULL == c)
{
LOG (GNUNET_ERROR_TYPE_DEBUG, " duplicate CONNECTION_BROKEN\n");
- check_connections ();
+ GCC_check_connections ();
return GNUNET_OK;
}
GNUNET_YES, NULL, NULL));
connection_cancel_queues (c, !fwd);
}
- check_connections ();
+ GCC_check_connections ();
return GNUNET_OK;
}
struct CadetConnection *c;
int fwd;
- check_connections ();
+ GCC_check_connections ();
msg = (const struct GNUNET_CADET_ConnectionDestroy *) message;
log_message (message, peer, &msg->cid);
c = connection_get (&msg->cid);
1, GNUNET_NO);
LOG (GNUNET_ERROR_TYPE_DEBUG,
" connection unknown: already destroyed?\n");
- check_connections ();
+ GCC_check_connections ();
return GNUNET_OK;
}
fwd = is_fwd (c, peer);
{
LOG (GNUNET_ERROR_TYPE_DEBUG, " directly destroying connection!\n");
GCC_destroy (c);
- check_connections ();
+ GCC_check_connections ();
return GNUNET_OK;
}
c->destroy = GNUNET_YES;
GCT_remove_connection (c->t, c);
c->t = NULL;
}
- check_connections ();
+ GCC_check_connections ();
return GNUNET_OK;
}
uint32_t ttl;
int fwd;
- check_connections ();
+ GCC_check_connections ();
if (GNUNET_MESSAGE_TYPE_CADET_AX == ntohs (message->type))
{
overhead = sizeof (struct GNUNET_CADET_AX);
/* If something went wrong, discard message. */
if (GNUNET_SYSERR == fwd)
{
- check_connections ();
+ GCC_check_connections ();
return GNUNET_OK;
}
}
GCT_handle_encrypted (c->t, message);
GCC_send_ack (c, fwd, GNUNET_NO);
- check_connections ();
+ GCC_check_connections ();
return GNUNET_OK;
}
GNUNET_STATISTICS_update (stats, "# TTL drops", 1, GNUNET_NO);
LOG (GNUNET_ERROR_TYPE_WARNING, " TTL is 0, DROPPING!\n");
GCC_send_ack (c, fwd, GNUNET_NO);
- check_connections ();
+ GCC_check_connections ();
return GNUNET_OK;
}
}
GNUNET_STATISTICS_update (stats, "# messages forwarded", 1, GNUNET_NO);
GNUNET_assert (NULL == GCC_send_prebuilt_message (message, 0, 0, c, fwd,
GNUNET_NO, NULL, NULL));
- check_connections ();
+ GCC_check_connections ();
return GNUNET_OK;
}
size_t expected_size;
int fwd;
- check_connections ();
+ GCC_check_connections ();
cid = &msg->cid;
log_message (&msg->header, peer, cid);
return GNUNET_OK;
}
GCT_handle_kx (c->t, &msg[1].header);
- check_connections ();
+ GCC_check_connections ();
return GNUNET_OK;
}
GNUNET_STATISTICS_update (stats, "# messages forwarded", 1, GNUNET_NO);
GNUNET_assert (NULL == GCC_send_prebuilt_message (&msg->header, 0, 0, c, fwd,
GNUNET_NO, NULL, NULL));
- check_connections ();
+ GCC_check_connections ();
return GNUNET_OK;
}
const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
- check_connections ();
+ GCC_check_connections ();
return handle_cadet_kx (peer, (struct GNUNET_CADET_KX *) message);
}
GCC_handle_encrypted (void *cls, const struct GNUNET_PeerIdentity *peer,
const struct GNUNET_MessageHeader *message)
{
- check_connections ();
+ GCC_check_connections ();
return handle_cadet_encrypted (peer, message);
}
uint32_t ack;
int fwd;
- check_connections ();
+ GCC_check_connections ();
msg = (struct GNUNET_CADET_ACK *) message;
log_message (message, peer, &msg->cid);
c = connection_get (&msg->cid);
GNUNET_STATISTICS_update (stats, "# ack on unknown connection", 1,
GNUNET_NO);
send_broken_unknown (&msg->cid, &my_full_id, NULL, peer);
- check_connections ();
+ GCC_check_connections ();
return GNUNET_OK;
}
}
connection_unlock_queue (c, fwd);
- check_connections ();
+ GCC_check_connections ();
return GNUNET_OK;
}
uint32_t pid;
int fwd;
- check_connections ();
+ GCC_check_connections ();
msg = (struct GNUNET_CADET_Poll *) message;
log_message (message, peer, &msg->cid);
c = connection_get (&msg->cid);
LOG (GNUNET_ERROR_TYPE_DEBUG, "POLL message on unknown connection %s!\n",
GNUNET_h2s (GC_h2hc (&msg->cid)));
send_broken_unknown (&msg->cid, &my_full_id, NULL, peer);
- check_connections ();
+ GCC_check_connections ();
return GNUNET_OK;
}
fc->last_pid_recv = pid;
fwd = fc == &c->bck_fc;
GCC_send_ack (c, fwd, GNUNET_YES);
- check_connections ();
+ GCC_check_connections ();
return GNUNET_OK;
}
{
unsigned int buffer;
- check_connections ();
+ GCC_check_connections ();
LOG (GNUNET_ERROR_TYPE_DEBUG, "GCC send %s ACK on %s\n",
GC_f2s (fwd), GCC_2s (c));
if (GNUNET_NO != c->destroy)
{
LOG (GNUNET_ERROR_TYPE_DEBUG, " being destroyed, why bother...\n");
- check_connections ();
+ GCC_check_connections ();
return;
}
LOG (GNUNET_ERROR_TYPE_DEBUG, " buffer available: %u\n", buffer);
if (0 == buffer && GNUNET_NO == force)
{
- check_connections ();
+ GCC_check_connections ();
return;
}
LOG (GNUNET_ERROR_TYPE_DEBUG, " sending on connection\n");
send_ack (c, buffer, fwd, force);
}
- check_connections ();
+ GCC_check_connections ();
}
void
GCC_shutdown (void)
{
- check_connections ();
+ GCC_check_connections ();
GNUNET_CONTAINER_multihashmap_iterate (connections,
&shutdown_iterator,
NULL);
struct CadetConnection *c;
struct CadetPeerPath *p;
- check_connections ();
+ GCC_check_connections ();
p = path_duplicate (path);
c = GNUNET_new (struct CadetConnection);
c->id = *cid;
return NULL;
}
LOG (GNUNET_ERROR_TYPE_INFO, "New connection %s\n", GCC_2s (c));
- check_connections ();
+ GCC_check_connections ();
return c;
}
void
GCC_destroy (struct CadetConnection *c)
{
- check_connections ();
+ GCC_check_connections ();
if (NULL == c)
{
GNUNET_break (0);
-1,
GNUNET_NO);
GNUNET_free (c);
- check_connections ();
+ GCC_check_connections ();
}
struct CadetPeer *hop;
int fwd;
- check_connections ();
+ GCC_check_connections ();
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Notify broken on %s due to %s disconnect\n",
GCC_2s (c),
{
/* Local shutdown, no one to notify about this. */
GCC_destroy (c);
- check_connections ();
+ GCC_check_connections ();
return;
}
if (GNUNET_NO == c->destroy)
* Cancel all queues, if no message is left, connection will be destroyed.
*/
connection_cancel_queues (c, ! fwd);
- check_connections ();
+ GCC_check_connections ();
}
uint16_t type;
int droppable;
- check_connections ();
+ GCC_check_connections ();
size = ntohs (message->size);
data = GNUNET_malloc (size);
memcpy (data, message, size);
LOG (GNUNET_ERROR_TYPE_DEBUG, "dropping msg on %s, NULL q\n", GCC_2s (c));
GNUNET_free (data);
GNUNET_free (q);
- check_connections ();
+ GCC_check_connections ();
return NULL;
}
q->cont = cont;
q->cont_cls = cont_cls;
- check_connections ();
+ GCC_check_connections ();
return (NULL == cont) ? NULL : q;
}
/* queue destroy calls message_sent, which calls q->cont and frees q */
GCP_queue_destroy (q->q, GNUNET_YES, GNUNET_NO, 0);
- check_connections ();
+ GCC_check_connections ();
}
enum CadetTunnelCState state;
size_t size;
- check_connections ();
+ GCC_check_connections ();
size = sizeof (struct GNUNET_CADET_ConnectionCreate);
size += connection->path->length * sizeof (struct GNUNET_PeerIdentity);
GCT_change_cstate (connection->t, CADET_TUNNEL_WAITING);
if (CADET_CONNECTION_NEW == connection->state)
connection_change_state (connection, CADET_CONNECTION_SENT);
- check_connections ();
+ GCC_check_connections ();
}
if (GNUNET_YES == c->destroy)
return;
- check_connections ();
+ GCC_check_connections ();
msg.header.size = htons (sizeof (msg));
msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY);
msg.cid = c->id;
NULL, NULL));
c->destroy = GNUNET_YES;
c->state = CADET_CONNECTION_DESTROYED;
- check_connections ();
+ GCC_check_connections ();
}
struct CadetPeerPath *path;
char own_id[16];
+ GCC_check_connections ();
GNUNET_snprintf (own_id,
sizeof (own_id),
"%s",
if ( (NULL != GCP_get_tunnel (mp)) &&
(0 > GNUNET_CRYPTO_cmp_peer_identity (&my_full_id, peer)) )
GCP_connect (mp);
+ GCC_check_connections ();
}
struct CadetPeerPath *direct_path;
char own_id[16];
+ GCC_check_connections ();
strncpy (own_id, GNUNET_i2s (&my_full_id), 15);
p = GNUNET_CONTAINER_multipeermap_get (peers, peer);
if (NULL == p)
-1,
GNUNET_NO);
path_destroy (direct_path);
+ GCC_check_connections ();
}
static int
is_searching (const struct CadetPeer *peer)
{
- return (NULL == peer->search_h && NULL == peer->search_delayed) ?
- GNUNET_NO : GNUNET_YES;
+ return ( (NULL == peer->search_h) &&
+ (NULL == peer->search_delayed) ) ?
+ GNUNET_NO : GNUNET_YES;
}
struct CadetPeer *peer = cls;
peer->search_delayed = NULL;
-
if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason))
return;
-
+ GCC_check_connections ();
GCP_start_search (peer);
+ GCC_check_connections ();
}
struct CadetPeer *peer = cls;
unsigned int connection_count;
+ GCC_check_connections ();
GCP_add_path_to_all (path, GNUNET_NO);
/* Count connections */
/* If we already have our minimum (or more) connections, it's enough */
if (CONNECTIONS_PER_TUNNEL <= connection_count)
+ {
+ GCC_check_connections ();
return;
+ }
if (CADET_TUNNEL_SEARCHING == GCT_get_cstate (peer->tunnel))
{
LOG (GNUNET_ERROR_TYPE_DEBUG, " ... connect!\n");
GCP_connect (peer);
}
+ GCC_check_connections ();
}
char *dst;
uint32_t pid;
+ GCC_check_connections ();
LOG (GNUNET_ERROR_TYPE_DEBUG, "\n");
LOG (GNUNET_ERROR_TYPE_DEBUG, "\n");
LOG (GNUNET_ERROR_TYPE_DEBUG, "Queue send towards %s (max %u)\n",
peer->core_transmit = NULL;
peer->tmt_time.abs_value_us = 0;
}
+ GCC_check_connections ();
return 0;
}
LOG (GNUNET_ERROR_TYPE_DEBUG, " return %d\n", total_size);
queue_debug (peer, GNUNET_ERROR_TYPE_DEBUG);
-
+ GCC_check_connections ();
return total_size;
}
* #GNUNET_NO otherwise.
*/
int
-GCP_queue_destroy (struct CadetPeerQueue *queue, int clear_cls,
- int sent, uint32_t pid)
+GCP_queue_destroy (struct CadetPeerQueue *queue,
+ int clear_cls,
+ int sent,
+ uint32_t pid)
{
struct CadetPeer *peer;
int connection_destroyed;
+ GCC_check_connections ();
peer = queue->peer;
LOG (GNUNET_ERROR_TYPE_DEBUG, "queue destroy %s\n", GC_m2s (queue->type));
if (GNUNET_YES == clear_cls)
}
GNUNET_free (queue);
+ GCC_check_connections ();
return connection_destroyed;
}
int priority;
int call_core;
+ GCC_check_connections ();
if (NULL == c && GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN != type)
error_level = GNUNET_ERROR_TYPE_ERROR;
else
}
queue_debug (peer, GNUNET_ERROR_TYPE_DEBUG);
+ GCC_check_connections ();
return q;
}
struct CadetPeerQueue *prev;
int connection_destroyed;
+ GCC_check_connections ();
connection_destroyed = GNUNET_NO;
for (q = peer->queue_head; NULL != q; q = next)
{
peer->core_transmit = NULL;
peer->tmt_time.abs_value_us = 0;
}
+ GCC_check_connections ();
}
struct GNUNET_MessageHeader *msg;
int dest;
+ GCC_check_connections ();
GNUNET_assert (NULL != destroyed);
LOG (GNUNET_ERROR_TYPE_DEBUG, "connection_pop on connection %p\n", c);
for (q = peer->queue_head; NULL != q; q = next)
LOG (GNUNET_ERROR_TYPE_DEBUG, "Unknown message %s\n", GC_m2s (q->type));
}
}
-
+ GCC_check_connections ();
return NULL;
}
+
/**
* Unlock a possibly locked queue for a connection.
*
struct CadetPeerQueue *q;
size_t size;
+ GCC_check_connections ();
if (NULL != peer->core_transmit)
{
LOG (GNUNET_ERROR_TYPE_DEBUG, " already unlocked!\n");
&queue_send,
peer);
peer->tmt_time = GNUNET_TIME_absolute_get ();
+ GCC_check_connections ();
}
struct CadetConnection *c;
int rerun_search;
+ GCC_check_connections ();
LOG (GNUNET_ERROR_TYPE_DEBUG, "peer_connect towards %s\n", GCP_2s (peer));
/* If we have a current hello, try to connect using it. */
GCP_stop_search (peer);
delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 100);
- peer->search_delayed = GNUNET_SCHEDULER_add_delayed (delay, &delayed_search,
+ peer->search_delayed = GNUNET_SCHEDULER_add_delayed (delay,
+ &delayed_search,
peer);
+ GCC_check_connections ();
return;
}
if (GNUNET_NO == is_searching (peer))
GCP_start_search (peer);
+ GCC_check_connections ();
}
void
GCP_add_tunnel (struct CadetPeer *peer)
{
+ GCC_check_connections ();
if (NULL != peer->tunnel)
return;
peer->tunnel = GCT_new (peer);
+ GCC_check_connections ();
}
* NULL on error.
*/
struct CadetPeerPath *
-GCP_add_path (struct CadetPeer *peer, struct CadetPeerPath *path,
+GCP_add_path (struct CadetPeer *peer,
+ struct CadetPeerPath *path,
int trusted)
{
struct CadetPeerPath *aux;
unsigned int l;
unsigned int l2;
- LOG (GNUNET_ERROR_TYPE_DEBUG, "adding path [%u] to peer %s\n",
+ GCC_check_connections ();
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "adding path [%u] to peer %s\n",
path->length, GCP_2s (peer));
if (NULL == peer || NULL == path
{
GCP_connect (peer);
}
+ GCC_check_connections ();
return path;
}
unsigned int i;
/* TODO: invert and add */
+ GCC_check_connections ();
for (i = 0; i < p->length && p->peers[i] != myid; i++) /* skip'em */ ;
for (i++; i < p->length; i++)
{
copy->length = i + 1;
GCP_add_path (aux, copy, p->length < 3 ? GNUNET_NO : confirmed);
}
+ GCC_check_connections ();
}
struct CadetPeerPath *iter;
struct CadetPeerPath *next;
+ GCC_check_connections ();
GNUNET_assert (myid == path->peers[0]);
GNUNET_assert (peer->id == path->peers[path->length - 1]);
}
}
path_destroy (path);
+ GCC_check_connections ();
}
const struct GNUNET_PeerIdentity *id;
struct CadetTunnel *t = peer->tunnel;
- if (NULL != peer->search_h)
+ GCC_check_connections ();
+ if (NULL != peer->search_h)
{
GNUNET_break (0);
return;
{
GCT_change_cstate (t, CADET_TUNNEL_SEARCHING);
}
+ GCC_check_connections ();
}
void
GCP_stop_search (struct CadetPeer *peer)
{
+ GCC_check_connections ();
if (NULL != peer->search_h)
{
GCD_search_stop (peer->search_h);
GNUNET_SCHEDULER_cancel (peer->search_delayed);
peer->search_delayed = NULL;
}
+ GCC_check_connections ();
}
struct GNUNET_HELLO_Message *old;
size_t size;
- LOG (GNUNET_ERROR_TYPE_DEBUG, "set hello for %s\n", GCP_2s (peer));
+ GCC_check_connections ();
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "set hello for %s\n", GCP_2s (peer));
if (NULL == hello)
return;
peer->hello, GNUNET_HELLO_size (hello));
GNUNET_free (old);
}
+ GCC_check_connections ();
}
if (NULL == transport_handle)
return;
-
+ GCC_check_connections ();
hello = GCP_get_hello (peer);
if (NULL == hello)
return;
mh = GNUNET_HELLO_get_header (hello);
- GNUNET_TRANSPORT_offer_hello (transport_handle, mh, try_connect, peer);
+ GNUNET_TRANSPORT_offer_hello (transport_handle,
+ mh,
+ &try_connect,
+ peer);
+ GCC_check_connections ();
}
GNUNET_PEER_Id p1;
GNUNET_PEER_Id p2;
+ GCC_check_connections ();
p1 = GNUNET_PEER_search (peer1);
p2 = GNUNET_PEER_search (peer2);
}
}
}
+ GCC_check_connections ();
}
GCP_iterate_all (GNUNET_CONTAINER_PeerMapIterator iter,
void *cls)
{
+ GCC_check_connections ();
GNUNET_CONTAINER_multipeermap_iterate (peers,
iter,
cls);
+ GCC_check_connections ();
}
return "(NULL)";
return GNUNET_i2s (GNUNET_PEER_resolve2 (peer->id));
}
+
+
+/* end of gnunet-service-cadet_peer.c */
GCT_init (const struct GNUNET_CONFIGURATION_Handle *c,
const struct GNUNET_CRYPTO_EddsaPrivateKey *key);
+
/**
* Shut down the tunnel subsystem.
*/
void
GCT_shutdown (void);
+
/**
* Create a tunnel.
*
struct CadetTunnel *
GCT_new (struct CadetPeer *destination);
+
/**
* Tunnel is empty: destroy it.
*
void
GCT_destroy_empty (struct CadetTunnel *t);
+
/**
* Destroy tunnel if empty (no more channels).
*
void
GCT_destroy_if_empty (struct CadetTunnel *t);
+
/**
* Destroy the tunnel.
*
void
GCT_change_estate (struct CadetTunnel* t, enum CadetTunnelEState state);
+
/**
* Add a connection to a tunnel.
*
void
GCT_add_connection (struct CadetTunnel *t, struct CadetConnection *c);
+
/**
* Remove a connection from a tunnel.
*
void
GCT_remove_connection (struct CadetTunnel *t, struct CadetConnection *c);
+
/**
* Add a channel to a tunnel.
*
void
GCT_add_channel (struct CadetTunnel *t, struct CadetChannel *ch);
+
/**
* Remove a channel from a tunnel.
*
void
GCT_remove_channel (struct CadetTunnel *t, struct CadetChannel *ch);
+
/**
* Search for a channel by global ID.
*
struct CadetChannel *
GCT_get_channel (struct CadetTunnel *t, CADET_ChannelNumber chid);
+
/**
* Decrypt and demultiplex by message type. Call appropriate handler
* for a message towards a channel of a local tunnel.
GCT_handle_kx (struct CadetTunnel *t,
const struct GNUNET_MessageHeader *message);
+
/**
* @brief Use the given path for the tunnel.
* Update the next and prev hops (and RCs).
struct CadetConnection *
GCT_use_path (struct CadetTunnel *t, struct CadetPeerPath *p);
+
/**
* Count all created connections of a tunnel. Not necessarily ready connections!
*
unsigned int
GCT_count_any_connections (struct CadetTunnel *t);
+
/**
* Count established (ready) connections of a tunnel.
*
unsigned int
GCT_count_connections (struct CadetTunnel *t);
+
/**
* Count channels of a tunnel.
*
unsigned int
GCT_count_channels (struct CadetTunnel *t);
+
/**
* Get the connectivity state of a tunnel.
*
enum CadetTunnelCState
GCT_get_cstate (struct CadetTunnel *t);
+
/**
* Get the encryption state of a tunnel.
*
enum CadetTunnelEState
GCT_get_estate (struct CadetTunnel *t);
+
/**
* Get the maximum buffer space for a tunnel towards a local client.
*
unsigned int
GCT_get_channels_buffer (struct CadetTunnel *t);
+
/**
* Get the total buffer space for a tunnel for P2P traffic.
*
unsigned int
GCT_get_connections_buffer (struct CadetTunnel *t);
+
/**
* Get the tunnel's destination.
*
const struct GNUNET_PeerIdentity *
GCT_get_destination (struct CadetTunnel *t);
+
/**
* Get the tunnel's next free Channel ID.
*
CADET_ChannelNumber
GCT_get_next_chid (struct CadetTunnel *t);
+
/**
* Send ACK on one or more channels due to buffer in connections.
*
void
GCT_unchoke_channels (struct CadetTunnel *t);
+
/**
* Send ACK on one or more connections due to buffer space to the client.
*
void
GCT_send_connection_acks (struct CadetTunnel *t);
+
/**
* Cancel a previously sent message while it's in the queue.
*
void
GCT_cancel (struct CadetTunnelQueue *q);
+
/**
* Sends an already built message on a tunnel, encrypting it and
* choosing the best connection.
struct CadetTunnel *t, struct CadetConnection *c,
int force, GCT_sent cont, void *cont_cls);
+
/**
* Send an Axolotl KX message.
*
void
GCT_send_ax_kx (struct CadetTunnel *t, int force_reply);
+
/**
* Sends an already built and encrypted message on a tunnel, choosing the best
* connection. Useful for re-queueing messages queued on a destroyed connection.
GCT_resend_message (const struct GNUNET_MessageHeader *message,
struct CadetTunnel *t);
+
/**
* Is the tunnel directed towards the local peer?
*
int
GCT_is_loopback (const struct CadetTunnel *t);
+
/**
* Is the tunnel using this path already?
*
int
GCT_is_path_used (const struct CadetTunnel *t, const struct CadetPeerPath *p);
+
/**
* Get a cost of a path for a tunnel considering existing connections.
*
GCT_get_path_cost (const struct CadetTunnel *t,
const struct CadetPeerPath *path);
+
/**
* Get the static string for the peer this tunnel is directed.
*
const char *
GCT_2s (const struct CadetTunnel *t);
+
/**
* Log all possible info about the tunnel state.
*
void
GCT_debug (const struct CadetTunnel *t, enum GNUNET_ErrorType level);
+
/**
* Iterate all tunnels.
*
void
GCT_iterate_all (GNUNET_CONTAINER_PeerMapIterator iter, void *cls);
+
/**
* Count all tunnels.
*
unsigned int
GCT_count_all (void);
+
/**
* Iterate all connections of a tunnel.
*
void
GCT_iterate_connections (struct CadetTunnel *t, GCT_conn_iter iter, void *cls);
+
/**
* Iterate all channels of a tunnel.
*
* @param cls Closure for @c iter.
*/
void
-GCT_iterate_channels (struct CadetTunnel *t, GCT_chan_iter iter, void *cls);
+GCT_iterate_channels (struct CadetTunnel *t,
+ GCT_chan_iter iter,
+ void *cls);
+
#if 0 /* keep Emacsens' auto-indent happy */
{