From 99eb14783e48a602085e0d5197bc01ab68633638 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Tue, 14 Jul 2015 21:56:33 +0000 Subject: [PATCH] committing version used to produce 3846:9432 --- src/cadet/gnunet-service-cadet_connection.c | 201 ++++++++++++-------- src/cadet/gnunet-service-cadet_connection.h | 6 + src/cadet/gnunet-service-cadet_dht.h | 7 +- src/cadet/gnunet-service-cadet_peer.c | 85 +++++++-- src/cadet/gnunet-service-cadet_peer.h | 12 +- src/cadet/gnunet-service-cadet_tunnel.h | 41 +++- 6 files changed, 251 insertions(+), 101 deletions(-) diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c index 75f5bb7fe..7970b3c86 100644 --- a/src/cadet/gnunet-service-cadet_connection.c +++ b/src/cadet/gnunet-service-cadet_connection.c @@ -501,6 +501,7 @@ send_ack (struct CadetConnection *c, unsigned int buffer, int fwd, int force) 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", @@ -523,6 +524,7 @@ send_ack (struct CadetConnection *c, unsigned int buffer, int fwd, int force) 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; } @@ -536,6 +538,7 @@ send_ack (struct CadetConnection *c, unsigned int buffer, int fwd, int force) 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; } @@ -551,6 +554,7 @@ send_ack (struct CadetConnection *c, unsigned int buffer, int fwd, int force) else { LOG (GNUNET_ERROR_TYPE_DEBUG, " same ACK already in queue\n"); + GCC_check_connections (); return; } } @@ -567,6 +571,7 @@ send_ack (struct CadetConnection *c, unsigned int buffer, int fwd, int force) !fwd, GNUNET_YES, &ack_sent, prev_fc); GNUNET_assert (NULL != prev_fc->ack_msg); + GCC_check_connections (); } @@ -598,6 +603,7 @@ conn_message_sent (void *cls, double usecsperbyte; int forced; + GCC_check_connections (); LOG (GNUNET_ERROR_TYPE_DEBUG, "connection message_sent\n"); GCC_debug (c, GNUNET_ERROR_TYPE_DEBUG); @@ -633,6 +639,7 @@ conn_message_sent (void *cls, 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); @@ -643,6 +650,7 @@ conn_message_sent (void *cls, 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 */ @@ -729,6 +737,7 @@ conn_message_sent (void *cls, p->avg /= p->size; } p->idx = (p->idx + 1) % AVG_MSGS; + GCC_check_connections (); return GNUNET_NO; } @@ -806,6 +815,7 @@ check_neighbours (const struct CadetConnection *c) GCP_check_connection (get_prev_hop (c), c); } + /** * Helper for #check_connections(). Calls #check_neighbours(). * @@ -827,11 +837,13 @@ check_connection (void *cls, /** - * 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); @@ -933,6 +945,7 @@ send_connection_ack (struct CadetConnection *connection, int fwd) { 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)); @@ -945,6 +958,7 @@ send_connection_ack (struct CadetConnection *connection, int fwd) GCT_change_cstate (t, CADET_TUNNEL_WAITING); if (CADET_CONNECTION_READY != connection->state) connection_change_state (connection, CADET_CONNECTION_SENT); + GCC_check_connections (); } @@ -964,13 +978,16 @@ send_broken (struct CadetConnection *c, { 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 (); } @@ -992,6 +1009,7 @@ send_broken_unknown (const struct GNUNET_CADET_Hash *connection_id, 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))); @@ -1009,6 +1027,7 @@ send_broken_unknown (const struct GNUNET_CADET_Hash *connection_id, 0, 2, sizeof (struct GNUNET_CADET_ConnectionBroken), NULL, GNUNET_SYSERR, /* connection, fwd */ NULL, NULL); /* continuation */ + GCC_check_connections (); } @@ -1024,7 +1043,9 @@ send_connection_keepalive (struct CadetConnection *c, int fwd) 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; @@ -1043,6 +1064,7 @@ send_connection_keepalive (struct CadetConnection *c, int fwd) GNUNET_assert (NULL == GCT_send_prebuilt_message (&msg, c->t, c, GNUNET_NO, NULL, NULL)); + GCC_check_connections (); } @@ -1055,7 +1077,8 @@ send_connection_keepalive (struct CadetConnection *c, int fwd) 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 @@ -1113,7 +1136,6 @@ connection_maintain (struct CadetConnection *c, int fwd) } - /** * Keep the connection alive. * @@ -1125,7 +1147,9 @@ connection_maintain (struct CadetConnection *c, int fwd) 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) @@ -1137,7 +1161,7 @@ connection_keepalive (struct CadetConnection *c, int fwd, int shutdown) return; connection_maintain (c, fwd); - + GCC_check_connections (); /* Next execution will be scheduled by message_sent or _maintain*/ } @@ -1152,9 +1176,11 @@ static void 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 (); } @@ -1168,9 +1194,11 @@ static void 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 (); } @@ -1190,6 +1218,7 @@ schedule_next_keepalive (struct CadetConnection *c, int fwd) struct GNUNET_SCHEDULER_Task * *task_id; GNUNET_SCHEDULER_TaskCallback keepalive_task; + GCC_check_connections (); if (GNUNET_NO == GCC_is_origin (c, fwd)) return; @@ -1229,9 +1258,12 @@ schedule_next_keepalive (struct CadetConnection *c, int fwd) } /* 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 (); } @@ -1250,7 +1282,9 @@ connection_unlock_queue (struct CadetConnection *c, int fwd) { 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)) @@ -1261,6 +1295,7 @@ connection_unlock_queue (struct CadetConnection *c, int fwd) peer = get_hop (c, fwd); GCP_queue_unlock (peer, c); + GCC_check_connections (); } @@ -1279,7 +1314,9 @@ connection_cancel_queues (struct CadetConnection *c, int fwd) 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) { @@ -1296,6 +1333,7 @@ connection_cancel_queues (struct CadetConnection *c, int fwd) } peer = get_hop (c, fwd); GCP_queue_cancel (peer, c); + GCC_check_connections (); } @@ -1307,7 +1345,8 @@ connection_cancel_queues (struct CadetConnection *c, int fwd) * @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); /** @@ -1338,11 +1377,12 @@ poll_sent (void *cls, 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. @@ -1359,6 +1399,7 @@ connection_poll (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) int fwd; fc->poll_task = NULL; + GCC_check_connections (); if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) { return; @@ -1377,6 +1418,7 @@ connection_poll (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 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 (); } @@ -1396,6 +1438,7 @@ resend_messages_and_destroy (struct CadetConnection *c, int fwd) unsigned int pending; int destroyed; + GCC_check_connections (); c->state = CADET_CONNECTION_DESTROYED; c->destroy = GNUNET_YES; @@ -1423,6 +1466,7 @@ resend_messages_and_destroy (struct CadetConnection *c, int fwd) } GCC_destroy (c); } + GCC_check_connections (); } @@ -1440,6 +1484,7 @@ connection_timeout (struct CadetConnection *c, int fwd) { struct CadetFlowControl *reverse_fc; + GCC_check_connections (); reverse_fc = fwd ? &c->bck_fc : &c->fwd_fc; LOG (GNUNET_ERROR_TYPE_INFO, @@ -1463,10 +1508,12 @@ connection_timeout (struct CadetConnection *c, int fwd) 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 (); } @@ -1486,8 +1533,9 @@ connection_fwd_timeout (void *cls, 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 (); } @@ -1507,8 +1555,9 @@ connection_bck_timeout (void *cls, 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 (); } @@ -1530,7 +1579,6 @@ static void 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); @@ -1658,7 +1706,6 @@ add_to_peer (struct CadetConnection *c, } - /** * Iterator to compare each connection's path with the path of a new connection. * @@ -1689,6 +1736,7 @@ check_path (void *cls, struct CadetConnection *c) } } + /** * Finds out if this path is already being used by and existing connection. * @@ -1700,9 +1748,8 @@ check_path (void *cls, struct CadetConnection *c) * 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) @@ -1810,7 +1857,7 @@ GCC_handle_create (void *cls, const struct GNUNET_PeerIdentity *peer, 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)) @@ -1879,14 +1926,14 @@ GCC_handle_create (void *cls, const struct GNUNET_PeerIdentity *peer, /* 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); @@ -1924,7 +1971,7 @@ GCC_handle_create (void *cls, const struct GNUNET_PeerIdentity *peer, path_destroy (path); GCC_destroy (c); send_broken_unknown (cid, &my_full_id, NULL, peer); - check_connections (); + GCC_check_connections (); return GNUNET_OK; } @@ -1946,7 +1993,7 @@ GCC_handle_create (void *cls, const struct GNUNET_PeerIdentity *peer, NULL, NULL)); } path_destroy (path); - check_connections (); + GCC_check_connections (); return GNUNET_OK; } @@ -1972,7 +2019,7 @@ GCC_handle_confirm (void *cls, 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); @@ -1983,7 +2030,7 @@ GCC_handle_confirm (void *cls, 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; } @@ -1991,7 +2038,7 @@ GCC_handle_confirm (void *cls, { LOG (GNUNET_ERROR_TYPE_DEBUG, " connection being destroyed\n"); - check_connections (); + GCC_check_connections (); return GNUNET_OK; } @@ -2051,7 +2098,7 @@ GCC_handle_confirm (void *cls, /* 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; } @@ -2072,7 +2119,7 @@ GCC_handle_confirm (void *cls, /* 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; } @@ -2080,7 +2127,7 @@ GCC_handle_confirm (void *cls, GNUNET_assert (NULL == GCC_send_prebuilt_message (message, 0, 0, c, fwd, GNUNET_YES, NULL, NULL)); - check_connections (); + GCC_check_connections (); return GNUNET_OK; } @@ -2105,7 +2152,7 @@ GCC_handle_broken (void* cls, 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", @@ -2116,7 +2163,7 @@ GCC_handle_broken (void* cls, if (NULL == c) { LOG (GNUNET_ERROR_TYPE_DEBUG, " duplicate CONNECTION_BROKEN\n"); - check_connections (); + GCC_check_connections (); return GNUNET_OK; } @@ -2156,7 +2203,7 @@ GCC_handle_broken (void* cls, GNUNET_YES, NULL, NULL)); connection_cancel_queues (c, !fwd); } - check_connections (); + GCC_check_connections (); return GNUNET_OK; } @@ -2179,7 +2226,7 @@ GCC_handle_destroy (void *cls, 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); @@ -2193,7 +2240,7 @@ GCC_handle_destroy (void *cls, 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); @@ -2209,7 +2256,7 @@ GCC_handle_destroy (void *cls, { LOG (GNUNET_ERROR_TYPE_DEBUG, " directly destroying connection!\n"); GCC_destroy (c); - check_connections (); + GCC_check_connections (); return GNUNET_OK; } c->destroy = GNUNET_YES; @@ -2219,7 +2266,7 @@ GCC_handle_destroy (void *cls, GCT_remove_connection (c->t, c); c->t = NULL; } - check_connections (); + GCC_check_connections (); return GNUNET_OK; } @@ -2368,7 +2415,7 @@ handle_cadet_encrypted (const struct GNUNET_PeerIdentity *peer, 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); @@ -2394,7 +2441,7 @@ handle_cadet_encrypted (const struct GNUNET_PeerIdentity *peer, /* If something went wrong, discard message. */ if (GNUNET_SYSERR == fwd) { - check_connections (); + GCC_check_connections (); return GNUNET_OK; } @@ -2410,7 +2457,7 @@ handle_cadet_encrypted (const struct GNUNET_PeerIdentity *peer, } GCT_handle_encrypted (c->t, message); GCC_send_ack (c, fwd, GNUNET_NO); - check_connections (); + GCC_check_connections (); return GNUNET_OK; } @@ -2425,7 +2472,7 @@ handle_cadet_encrypted (const struct GNUNET_PeerIdentity *peer, 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; } } @@ -2433,7 +2480,7 @@ handle_cadet_encrypted (const struct GNUNET_PeerIdentity *peer, 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; } @@ -2455,7 +2502,7 @@ handle_cadet_kx (const struct GNUNET_PeerIdentity *peer, size_t expected_size; int fwd; - check_connections (); + GCC_check_connections (); cid = &msg->cid; log_message (&msg->header, peer, cid); @@ -2479,7 +2526,7 @@ handle_cadet_kx (const struct GNUNET_PeerIdentity *peer, return GNUNET_OK; } GCT_handle_kx (c->t, &msg[1].header); - check_connections (); + GCC_check_connections (); return GNUNET_OK; } @@ -2488,7 +2535,7 @@ handle_cadet_kx (const struct GNUNET_PeerIdentity *peer, 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; } @@ -2507,7 +2554,7 @@ GCC_handle_kx (void *cls, 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); } @@ -2525,7 +2572,7 @@ int 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); } @@ -2550,7 +2597,7 @@ GCC_handle_ack (void *cls, const struct GNUNET_PeerIdentity *peer, 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); @@ -2559,7 +2606,7 @@ GCC_handle_ack (void *cls, const struct GNUNET_PeerIdentity *peer, 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; } @@ -2598,7 +2645,7 @@ GCC_handle_ack (void *cls, const struct GNUNET_PeerIdentity *peer, } connection_unlock_queue (c, fwd); - check_connections (); + GCC_check_connections (); return GNUNET_OK; } @@ -2624,7 +2671,7 @@ GCC_handle_poll (void *cls, 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); @@ -2635,7 +2682,7 @@ GCC_handle_poll (void *cls, 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; } @@ -2666,7 +2713,7 @@ GCC_handle_poll (void *cls, 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; } @@ -2685,7 +2732,7 @@ GCC_send_ack (struct CadetConnection *c, int fwd, int force) { 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)); @@ -2698,7 +2745,7 @@ GCC_send_ack (struct CadetConnection *c, int fwd, int force) if (GNUNET_NO != c->destroy) { LOG (GNUNET_ERROR_TYPE_DEBUG, " being destroyed, why bother...\n"); - check_connections (); + GCC_check_connections (); return; } @@ -2716,7 +2763,7 @@ GCC_send_ack (struct CadetConnection *c, int fwd, int force) LOG (GNUNET_ERROR_TYPE_DEBUG, " buffer available: %u\n", buffer); if (0 == buffer && GNUNET_NO == force) { - check_connections (); + GCC_check_connections (); return; } @@ -2732,7 +2779,7 @@ GCC_send_ack (struct CadetConnection *c, int fwd, int force) LOG (GNUNET_ERROR_TYPE_DEBUG, " sending on connection\n"); send_ack (c, buffer, fwd, force); } - check_connections (); + GCC_check_connections (); } @@ -2807,7 +2854,7 @@ shutdown_iterator (void *cls, void GCC_shutdown (void) { - check_connections (); + GCC_check_connections (); GNUNET_CONTAINER_multihashmap_iterate (connections, &shutdown_iterator, NULL); @@ -2835,7 +2882,7 @@ GCC_new (const struct GNUNET_CADET_Hash *cid, struct CadetConnection *c; struct CadetPeerPath *p; - check_connections (); + GCC_check_connections (); p = path_duplicate (path); c = GNUNET_new (struct CadetConnection); c->id = *cid; @@ -2871,7 +2918,7 @@ GCC_new (const struct GNUNET_CADET_Hash *cid, return NULL; } LOG (GNUNET_ERROR_TYPE_INFO, "New connection %s\n", GCC_2s (c)); - check_connections (); + GCC_check_connections (); return c; } @@ -2879,7 +2926,7 @@ GCC_new (const struct GNUNET_CADET_Hash *cid, void GCC_destroy (struct CadetConnection *c) { - check_connections (); + GCC_check_connections (); if (NULL == c) { GNUNET_break (0); @@ -2953,7 +3000,7 @@ GCC_destroy (struct CadetConnection *c) -1, GNUNET_NO); GNUNET_free (c); - check_connections (); + GCC_check_connections (); } @@ -3145,7 +3192,7 @@ GCC_notify_broken (struct CadetConnection *c, 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), @@ -3162,7 +3209,7 @@ GCC_notify_broken (struct CadetConnection *c, { /* Local shutdown, no one to notify about this. */ GCC_destroy (c); - check_connections (); + GCC_check_connections (); return; } if (GNUNET_NO == c->destroy) @@ -3178,7 +3225,7 @@ GCC_notify_broken (struct CadetConnection *c, * Cancel all queues, if no message is left, connection will be destroyed. */ connection_cancel_queues (c, ! fwd); - check_connections (); + GCC_check_connections (); } @@ -3296,7 +3343,7 @@ GCC_send_prebuilt_message (const struct GNUNET_MessageHeader *message, uint16_t type; int droppable; - check_connections (); + GCC_check_connections (); size = ntohs (message->size); data = GNUNET_malloc (size); memcpy (data, message, size); @@ -3418,12 +3465,12 @@ GCC_send_prebuilt_message (const struct GNUNET_MessageHeader *message, 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; } @@ -3444,7 +3491,7 @@ GCC_cancel (struct CadetConnectionQueue *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 (); } @@ -3460,7 +3507,7 @@ GCC_send_create (struct CadetConnection *connection) 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); @@ -3481,7 +3528,7 @@ GCC_send_create (struct CadetConnection *connection) 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 (); } @@ -3501,7 +3548,7 @@ GCC_send_destroy (struct CadetConnection *c) 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; @@ -3519,7 +3566,7 @@ GCC_send_destroy (struct CadetConnection *c) NULL, NULL)); c->destroy = GNUNET_YES; c->state = CADET_CONNECTION_DESTROYED; - check_connections (); + GCC_check_connections (); } diff --git a/src/cadet/gnunet-service-cadet_connection.h b/src/cadet/gnunet-service-cadet_connection.h index a6d0a7096..784d9cf59 100644 --- a/src/cadet/gnunet-service-cadet_connection.h +++ b/src/cadet/gnunet-service-cadet_connection.h @@ -92,6 +92,12 @@ struct CadetConnectionQueue; #include "gnunet-service-cadet_peer.h" +/** + * Check invariants for all connections using #check_neighbours(). + */ +void +GCC_check_connections (); + /** * Callback called when a queued message is sent. diff --git a/src/cadet/gnunet-service-cadet_dht.h b/src/cadet/gnunet-service-cadet_dht.h index da8be0cb5..39e37dca7 100644 --- a/src/cadet/gnunet-service-cadet_dht.h +++ b/src/cadet/gnunet-service-cadet_dht.h @@ -50,8 +50,9 @@ struct GCD_search_handle; * @param path An unchecked, unoptimized path to the target node. * After callback will no longer be valid! */ -typedef void (*GCD_search_callback) (void *cls, - const struct CadetPeerPath *path); +typedef void +(*GCD_search_callback) (void *cls, + const struct CadetPeerPath *path); /******************************************************************************/ /******************************** API ***********************************/ @@ -89,4 +90,4 @@ GCD_search_stop (struct GCD_search_handle *h); /* ifndef GNUNET_CADET_SERVICE_LOCAL_H */ #endif -/* end of gnunet-cadet-service_LOCAL.h */ \ No newline at end of file +/* end of gnunet-cadet-service_LOCAL.h */ diff --git a/src/cadet/gnunet-service-cadet_peer.c b/src/cadet/gnunet-service-cadet_peer.c index 488c74b38..ef816bcb5 100644 --- a/src/cadet/gnunet-service-cadet_peer.c +++ b/src/cadet/gnunet-service-cadet_peer.c @@ -409,6 +409,7 @@ core_connect (void *cls, struct CadetPeerPath *path; char own_id[16]; + GCC_check_connections (); GNUNET_snprintf (own_id, sizeof (own_id), "%s", @@ -444,6 +445,7 @@ core_connect (void *cls, if ( (NULL != GCP_get_tunnel (mp)) && (0 > GNUNET_CRYPTO_cmp_peer_identity (&my_full_id, peer)) ) GCP_connect (mp); + GCC_check_connections (); } @@ -461,6 +463,7 @@ core_disconnect (void *cls, 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) @@ -493,6 +496,7 @@ core_disconnect (void *cls, -1, GNUNET_NO); path_destroy (direct_path); + GCC_check_connections (); } @@ -789,8 +793,9 @@ shutdown_peer (void *cls, 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; } @@ -806,11 +811,11 @@ delayed_search (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 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 (); } @@ -1017,6 +1022,7 @@ search_handler (void *cls, const struct CadetPeerPath *path) struct CadetPeer *peer = cls; unsigned int connection_count; + GCC_check_connections (); GCP_add_path_to_all (path, GNUNET_NO); /* Count connections */ @@ -1024,13 +1030,17 @@ search_handler (void *cls, const struct CadetPeerPath *path) /* 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 (); } @@ -1147,6 +1157,7 @@ queue_send (void *cls, size_t size, void *buf) 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", @@ -1175,6 +1186,7 @@ queue_send (void *cls, size_t size, void *buf) peer->core_transmit = NULL; peer->tmt_time.abs_value_us = 0; } + GCC_check_connections (); return 0; } @@ -1274,7 +1286,7 @@ queue_send (void *cls, size_t size, void *buf) LOG (GNUNET_ERROR_TYPE_DEBUG, " return %d\n", total_size); queue_debug (peer, GNUNET_ERROR_TYPE_DEBUG); - + GCC_check_connections (); return total_size; } @@ -1300,12 +1312,15 @@ queue_send (void *cls, size_t size, void *buf) * #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) @@ -1365,6 +1380,7 @@ GCP_queue_destroy (struct CadetPeerQueue *queue, int clear_cls, } GNUNET_free (queue); + GCC_check_connections (); return connection_destroyed; } @@ -1396,6 +1412,7 @@ GCP_queue_add (struct CadetPeer *peer, void *cls, uint16_t type, 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 @@ -1481,6 +1498,7 @@ GCP_queue_add (struct CadetPeer *peer, void *cls, uint16_t type, } queue_debug (peer, GNUNET_ERROR_TYPE_DEBUG); + GCC_check_connections (); return q; } @@ -1500,6 +1518,7 @@ GCP_queue_cancel (struct CadetPeer *peer, struct CadetConnection *c) struct CadetPeerQueue *prev; int connection_destroyed; + GCC_check_connections (); connection_destroyed = GNUNET_NO; for (q = peer->queue_head; NULL != q; q = next) { @@ -1537,6 +1556,7 @@ GCP_queue_cancel (struct CadetPeer *peer, struct CadetConnection *c) peer->core_transmit = NULL; peer->tmt_time.abs_value_us = 0; } + GCC_check_connections (); } @@ -1592,6 +1612,7 @@ GCP_connection_pop (struct CadetPeer *peer, 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) @@ -1636,10 +1657,11 @@ GCP_connection_pop (struct CadetPeer *peer, 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. * @@ -1656,6 +1678,7 @@ GCP_queue_unlock (struct CadetPeer *peer, struct CadetConnection *c) struct CadetPeerQueue *q; size_t size; + GCC_check_connections (); if (NULL != peer->core_transmit) { LOG (GNUNET_ERROR_TYPE_DEBUG, " already unlocked!\n"); @@ -1679,6 +1702,7 @@ GCP_queue_unlock (struct CadetPeer *peer, struct CadetConnection *c) &queue_send, peer); peer->tmt_time = GNUNET_TIME_absolute_get (); + GCC_check_connections (); } @@ -1865,6 +1889,7 @@ GCP_connect (struct CadetPeer *peer) 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. */ @@ -1924,13 +1949,16 @@ GCP_connect (struct CadetPeer *peer) 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 (); } @@ -1971,9 +1999,11 @@ GCP_is_neighbor (const struct CadetPeer *peer) void GCP_add_tunnel (struct CadetPeer *peer) { + GCC_check_connections (); if (NULL != peer->tunnel) return; peer->tunnel = GCT_new (peer); + GCC_check_connections (); } @@ -2025,14 +2055,17 @@ GCP_add_connection (struct CadetPeer *peer, * 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 @@ -2106,6 +2139,7 @@ finish: { GCP_connect (peer); } + GCC_check_connections (); return path; } @@ -2148,6 +2182,7 @@ GCP_add_path_to_all (const struct CadetPeerPath *p, int confirmed) 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++) { @@ -2159,6 +2194,7 @@ GCP_add_path_to_all (const struct CadetPeerPath *p, int confirmed) copy->length = i + 1; GCP_add_path (aux, copy, p->length < 3 ? GNUNET_NO : confirmed); } + GCC_check_connections (); } @@ -2174,6 +2210,7 @@ GCP_remove_path (struct CadetPeer *peer, struct CadetPeerPath *path) struct CadetPeerPath *iter; struct CadetPeerPath *next; + GCC_check_connections (); GNUNET_assert (myid == path->peers[0]); GNUNET_assert (peer->id == path->peers[path->length - 1]); @@ -2194,6 +2231,7 @@ GCP_remove_path (struct CadetPeer *peer, struct CadetPeerPath *path) } } path_destroy (path); + GCC_check_connections (); } @@ -2259,7 +2297,8 @@ GCP_start_search (struct CadetPeer *peer) 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; @@ -2283,6 +2322,7 @@ GCP_start_search (struct CadetPeer *peer) { GCT_change_cstate (t, CADET_TUNNEL_SEARCHING); } + GCC_check_connections (); } @@ -2295,6 +2335,7 @@ GCP_start_search (struct CadetPeer *peer) void GCP_stop_search (struct CadetPeer *peer) { + GCC_check_connections (); if (NULL != peer->search_h) { GCD_search_stop (peer->search_h); @@ -2305,6 +2346,7 @@ GCP_stop_search (struct CadetPeer *peer) GNUNET_SCHEDULER_cancel (peer->search_delayed); peer->search_delayed = NULL; } + GCC_check_connections (); } @@ -2381,7 +2423,8 @@ GCP_set_hello (struct CadetPeer *peer, const struct GNUNET_HELLO_Message *hello) 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; @@ -2400,6 +2443,7 @@ GCP_set_hello (struct CadetPeer *peer, const struct GNUNET_HELLO_Message *hello) peer->hello, GNUNET_HELLO_size (hello)); GNUNET_free (old); } + GCC_check_connections (); } @@ -2445,13 +2489,17 @@ GCP_try_connect (struct CadetPeer *peer) 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 (); } @@ -2474,6 +2522,7 @@ GCP_notify_broken_link (struct CadetPeer *peer, GNUNET_PEER_Id p1; GNUNET_PEER_Id p2; + GCC_check_connections (); p1 = GNUNET_PEER_search (peer1); p2 = GNUNET_PEER_search (peer2); @@ -2502,6 +2551,7 @@ GCP_notify_broken_link (struct CadetPeer *peer, } } } + GCC_check_connections (); } @@ -2535,9 +2585,11 @@ void GCP_iterate_all (GNUNET_CONTAINER_PeerMapIterator iter, void *cls) { + GCC_check_connections (); GNUNET_CONTAINER_multipeermap_iterate (peers, iter, cls); + GCC_check_connections (); } @@ -2555,3 +2607,6 @@ GCP_2s (const struct CadetPeer *peer) return "(NULL)"; return GNUNET_i2s (GNUNET_PEER_resolve2 (peer->id)); } + + +/* end of gnunet-service-cadet_peer.c */ diff --git a/src/cadet/gnunet-service-cadet_peer.h b/src/cadet/gnunet-service-cadet_peer.h index cd1873824..87e828b66 100644 --- a/src/cadet/gnunet-service-cadet_peer.h +++ b/src/cadet/gnunet-service-cadet_peer.h @@ -52,6 +52,7 @@ struct CadetPeerQueue; #include "gnunet-service-cadet_connection.h" + /** * Callback called when a queued message is sent. * @@ -63,13 +64,14 @@ struct CadetPeerQueue; * @param fwd Was this a FWD going message? * @param size Size of the message. * @param wait Time spent waiting for core (only the time for THIS message) - * * @return #GNUNET_YES if connection was destroyed, #GNUNET_NO otherwise. */ -typedef int (*GCP_sent) (void *cls, - struct CadetConnection *c, int sent, - uint16_t type, uint32_t pid, int fwd, size_t size, - struct GNUNET_TIME_Relative wait); +typedef int +(*GCP_sent) (void *cls, + struct CadetConnection *c, int sent, + uint16_t type, uint32_t pid, int fwd, size_t size, + struct GNUNET_TIME_Relative wait); + /******************************************************************************/ /******************************** API ***********************************/ diff --git a/src/cadet/gnunet-service-cadet_tunnel.h b/src/cadet/gnunet-service-cadet_tunnel.h index b2c6f05bc..a2504436b 100644 --- a/src/cadet/gnunet-service-cadet_tunnel.h +++ b/src/cadet/gnunet-service-cadet_tunnel.h @@ -156,12 +156,14 @@ void 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. * @@ -170,6 +172,7 @@ GCT_shutdown (void); struct CadetTunnel * GCT_new (struct CadetPeer *destination); + /** * Tunnel is empty: destroy it. * @@ -180,6 +183,7 @@ GCT_new (struct CadetPeer *destination); void GCT_destroy_empty (struct CadetTunnel *t); + /** * Destroy tunnel if empty (no more channels). * @@ -188,6 +192,7 @@ GCT_destroy_empty (struct CadetTunnel *t); void GCT_destroy_if_empty (struct CadetTunnel *t); + /** * Destroy the tunnel. * @@ -222,6 +227,7 @@ GCT_change_cstate (struct CadetTunnel* t, enum CadetTunnelCState cstate); void GCT_change_estate (struct CadetTunnel* t, enum CadetTunnelEState state); + /** * Add a connection to a tunnel. * @@ -231,6 +237,7 @@ GCT_change_estate (struct CadetTunnel* t, enum CadetTunnelEState state); void GCT_add_connection (struct CadetTunnel *t, struct CadetConnection *c); + /** * Remove a connection from a tunnel. * @@ -240,6 +247,7 @@ GCT_add_connection (struct CadetTunnel *t, struct CadetConnection *c); void GCT_remove_connection (struct CadetTunnel *t, struct CadetConnection *c); + /** * Add a channel to a tunnel. * @@ -249,6 +257,7 @@ GCT_remove_connection (struct CadetTunnel *t, struct CadetConnection *c); void GCT_add_channel (struct CadetTunnel *t, struct CadetChannel *ch); + /** * Remove a channel from a tunnel. * @@ -258,6 +267,7 @@ GCT_add_channel (struct CadetTunnel *t, struct CadetChannel *ch); void GCT_remove_channel (struct CadetTunnel *t, struct CadetChannel *ch); + /** * Search for a channel by global ID. * @@ -269,6 +279,7 @@ GCT_remove_channel (struct CadetTunnel *t, struct CadetChannel *ch); 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. @@ -291,6 +302,7 @@ void 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). @@ -304,6 +316,7 @@ GCT_handle_kx (struct CadetTunnel *t, struct CadetConnection * GCT_use_path (struct CadetTunnel *t, struct CadetPeerPath *p); + /** * Count all created connections of a tunnel. Not necessarily ready connections! * @@ -314,6 +327,7 @@ GCT_use_path (struct CadetTunnel *t, struct CadetPeerPath *p); unsigned int GCT_count_any_connections (struct CadetTunnel *t); + /** * Count established (ready) connections of a tunnel. * @@ -324,6 +338,7 @@ GCT_count_any_connections (struct CadetTunnel *t); unsigned int GCT_count_connections (struct CadetTunnel *t); + /** * Count channels of a tunnel. * @@ -334,6 +349,7 @@ GCT_count_connections (struct CadetTunnel *t); unsigned int GCT_count_channels (struct CadetTunnel *t); + /** * Get the connectivity state of a tunnel. * @@ -344,6 +360,7 @@ GCT_count_channels (struct CadetTunnel *t); enum CadetTunnelCState GCT_get_cstate (struct CadetTunnel *t); + /** * Get the encryption state of a tunnel. * @@ -354,6 +371,7 @@ GCT_get_cstate (struct CadetTunnel *t); enum CadetTunnelEState GCT_get_estate (struct CadetTunnel *t); + /** * Get the maximum buffer space for a tunnel towards a local client. * @@ -364,6 +382,7 @@ GCT_get_estate (struct CadetTunnel *t); unsigned int GCT_get_channels_buffer (struct CadetTunnel *t); + /** * Get the total buffer space for a tunnel for P2P traffic. * @@ -374,6 +393,7 @@ GCT_get_channels_buffer (struct CadetTunnel *t); unsigned int GCT_get_connections_buffer (struct CadetTunnel *t); + /** * Get the tunnel's destination. * @@ -384,6 +404,7 @@ GCT_get_connections_buffer (struct CadetTunnel *t); const struct GNUNET_PeerIdentity * GCT_get_destination (struct CadetTunnel *t); + /** * Get the tunnel's next free Channel ID. * @@ -394,6 +415,7 @@ GCT_get_destination (struct CadetTunnel *t); CADET_ChannelNumber GCT_get_next_chid (struct CadetTunnel *t); + /** * Send ACK on one or more channels due to buffer in connections. * @@ -402,6 +424,7 @@ GCT_get_next_chid (struct CadetTunnel *t); void GCT_unchoke_channels (struct CadetTunnel *t); + /** * Send ACK on one or more connections due to buffer space to the client. * @@ -412,6 +435,7 @@ GCT_unchoke_channels (struct CadetTunnel *t); void GCT_send_connection_acks (struct CadetTunnel *t); + /** * Cancel a previously sent message while it's in the queue. * @@ -424,6 +448,7 @@ GCT_send_connection_acks (struct CadetTunnel *t); void GCT_cancel (struct CadetTunnelQueue *q); + /** * Sends an already built message on a tunnel, encrypting it and * choosing the best connection. @@ -442,6 +467,7 @@ GCT_send_prebuilt_message (const struct GNUNET_MessageHeader *message, struct CadetTunnel *t, struct CadetConnection *c, int force, GCT_sent cont, void *cont_cls); + /** * Send an Axolotl KX message. * @@ -451,6 +477,7 @@ GCT_send_prebuilt_message (const struct GNUNET_MessageHeader *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. @@ -462,6 +489,7 @@ void GCT_resend_message (const struct GNUNET_MessageHeader *message, struct CadetTunnel *t); + /** * Is the tunnel directed towards the local peer? * @@ -472,6 +500,7 @@ GCT_resend_message (const struct GNUNET_MessageHeader *message, int GCT_is_loopback (const struct CadetTunnel *t); + /** * Is the tunnel using this path already? * @@ -483,6 +512,7 @@ GCT_is_loopback (const struct CadetTunnel *t); 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. * @@ -495,6 +525,7 @@ unsigned int GCT_get_path_cost (const struct CadetTunnel *t, const struct CadetPeerPath *path); + /** * Get the static string for the peer this tunnel is directed. * @@ -505,6 +536,7 @@ GCT_get_path_cost (const struct CadetTunnel *t, const char * GCT_2s (const struct CadetTunnel *t); + /** * Log all possible info about the tunnel state. * @@ -514,6 +546,7 @@ GCT_2s (const struct CadetTunnel *t); void GCT_debug (const struct CadetTunnel *t, enum GNUNET_ErrorType level); + /** * Iterate all tunnels. * @@ -523,6 +556,7 @@ GCT_debug (const struct CadetTunnel *t, enum GNUNET_ErrorType level); void GCT_iterate_all (GNUNET_CONTAINER_PeerMapIterator iter, void *cls); + /** * Count all tunnels. * @@ -531,6 +565,7 @@ GCT_iterate_all (GNUNET_CONTAINER_PeerMapIterator iter, void *cls); unsigned int GCT_count_all (void); + /** * Iterate all connections of a tunnel. * @@ -541,6 +576,7 @@ GCT_count_all (void); void GCT_iterate_connections (struct CadetTunnel *t, GCT_conn_iter iter, void *cls); + /** * Iterate all channels of a tunnel. * @@ -549,7 +585,10 @@ GCT_iterate_connections (struct CadetTunnel *t, GCT_conn_iter iter, void *cls); * @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 */ { -- 2.25.1