aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-07-14 21:56:33 +0000
committerChristian Grothoff <christian@grothoff.org>2015-07-14 21:56:33 +0000
commit99eb14783e48a602085e0d5197bc01ab68633638 (patch)
treeb065d72c009602a4fb447ca0ff95d04f25ea3c1a /src
parentb199b782b393d0fc04b5978edd69e36d6ae7ea64 (diff)
downloadgnunet-99eb14783e48a602085e0d5197bc01ab68633638.tar.gz
gnunet-99eb14783e48a602085e0d5197bc01ab68633638.zip
committing version used to produce 3846:9432
Diffstat (limited to 'src')
-rw-r--r--src/cadet/gnunet-service-cadet_connection.c201
-rw-r--r--src/cadet/gnunet-service-cadet_connection.h6
-rw-r--r--src/cadet/gnunet-service-cadet_dht.h7
-rw-r--r--src/cadet/gnunet-service-cadet_peer.c85
-rw-r--r--src/cadet/gnunet-service-cadet_peer.h12
-rw-r--r--src/cadet/gnunet-service-cadet_tunnel.h41
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)
501 int delta; 501 int delta;
502 502
503 /* If origin, there is no connection to send ACKs. Wrong function! */ 503 /* If origin, there is no connection to send ACKs. Wrong function! */
504 GCC_check_connections ();
504 if (GCC_is_origin (c, fwd)) 505 if (GCC_is_origin (c, fwd))
505 { 506 {
506 LOG (GNUNET_ERROR_TYPE_DEBUG, "connection %s is origin in %s\n", 507 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)
523 LOG (GNUNET_ERROR_TYPE_DEBUG, 524 LOG (GNUNET_ERROR_TYPE_DEBUG,
524 " last pid recv: %u, last ack sent: %u\n", 525 " last pid recv: %u, last ack sent: %u\n",
525 prev_fc->last_pid_recv, prev_fc->last_ack_sent); 526 prev_fc->last_pid_recv, prev_fc->last_ack_sent);
527 GCC_check_connections ();
526 return; 528 return;
527 } 529 }
528 530
@@ -536,6 +538,7 @@ send_ack (struct CadetConnection *c, unsigned int buffer, int fwd, int force)
536 if (ack == prev_fc->last_ack_sent && GNUNET_NO == force) 538 if (ack == prev_fc->last_ack_sent && GNUNET_NO == force)
537 { 539 {
538 LOG (GNUNET_ERROR_TYPE_DEBUG, "Not sending FWD ACK, not needed\n"); 540 LOG (GNUNET_ERROR_TYPE_DEBUG, "Not sending FWD ACK, not needed\n");
541 GCC_check_connections ();
539 return; 542 return;
540 } 543 }
541 544
@@ -551,6 +554,7 @@ send_ack (struct CadetConnection *c, unsigned int buffer, int fwd, int force)
551 else 554 else
552 { 555 {
553 LOG (GNUNET_ERROR_TYPE_DEBUG, " same ACK already in queue\n"); 556 LOG (GNUNET_ERROR_TYPE_DEBUG, " same ACK already in queue\n");
557 GCC_check_connections ();
554 return; 558 return;
555 } 559 }
556 } 560 }
@@ -567,6 +571,7 @@ send_ack (struct CadetConnection *c, unsigned int buffer, int fwd, int force)
567 !fwd, GNUNET_YES, 571 !fwd, GNUNET_YES,
568 &ack_sent, prev_fc); 572 &ack_sent, prev_fc);
569 GNUNET_assert (NULL != prev_fc->ack_msg); 573 GNUNET_assert (NULL != prev_fc->ack_msg);
574 GCC_check_connections ();
570} 575}
571 576
572 577
@@ -598,6 +603,7 @@ conn_message_sent (void *cls,
598 double usecsperbyte; 603 double usecsperbyte;
599 int forced; 604 int forced;
600 605
606 GCC_check_connections ();
601 LOG (GNUNET_ERROR_TYPE_DEBUG, "connection message_sent\n"); 607 LOG (GNUNET_ERROR_TYPE_DEBUG, "connection message_sent\n");
602 608
603 GCC_debug (c, GNUNET_ERROR_TYPE_DEBUG); 609 GCC_debug (c, GNUNET_ERROR_TYPE_DEBUG);
@@ -633,6 +639,7 @@ conn_message_sent (void *cls,
633 LOG (GNUNET_ERROR_TYPE_ERROR, "Message %s sent on NULL connection!\n", 639 LOG (GNUNET_ERROR_TYPE_ERROR, "Message %s sent on NULL connection!\n",
634 GC_m2s (type)); 640 GC_m2s (type));
635 } 641 }
642 GCC_check_connections ();
636 return GNUNET_NO; 643 return GNUNET_NO;
637 } 644 }
638 LOG (GNUNET_ERROR_TYPE_DEBUG, " C_P- %p %u\n", c, c->pending_messages); 645 LOG (GNUNET_ERROR_TYPE_DEBUG, " C_P- %p %u\n", c, c->pending_messages);
@@ -643,6 +650,7 @@ conn_message_sent (void *cls,
643 LOG (GNUNET_ERROR_TYPE_DEBUG, 650 LOG (GNUNET_ERROR_TYPE_DEBUG,
644 "! destroying connection!\n"); 651 "! destroying connection!\n");
645 GCC_destroy (c); 652 GCC_destroy (c);
653 GCC_check_connections ();
646 return GNUNET_YES; 654 return GNUNET_YES;
647 } 655 }
648 /* Send ACK if needed, after accounting for sent ID in fc->queue_n */ 656 /* Send ACK if needed, after accounting for sent ID in fc->queue_n */
@@ -729,6 +737,7 @@ conn_message_sent (void *cls,
729 p->avg /= p->size; 737 p->avg /= p->size;
730 } 738 }
731 p->idx = (p->idx + 1) % AVG_MSGS; 739 p->idx = (p->idx + 1) % AVG_MSGS;
740 GCC_check_connections ();
732 return GNUNET_NO; 741 return GNUNET_NO;
733} 742}
734 743
@@ -806,6 +815,7 @@ check_neighbours (const struct CadetConnection *c)
806 GCP_check_connection (get_prev_hop (c), c); 815 GCP_check_connection (get_prev_hop (c), c);
807} 816}
808 817
818
809/** 819/**
810 * Helper for #check_connections(). Calls #check_neighbours(). 820 * Helper for #check_connections(). Calls #check_neighbours().
811 * 821 *
@@ -827,11 +837,13 @@ check_connection (void *cls,
827 837
828 838
829/** 839/**
830 * Check all connections using #check_neighbours(). 840 * Check invariants for all connections using #check_neighbours().
831 */ 841 */
832static void 842void
833check_connections () 843GCC_check_connections ()
834{ 844{
845 if (NULL == connections)
846 return;
835 GNUNET_CONTAINER_multihashmap_iterate (connections, 847 GNUNET_CONTAINER_multihashmap_iterate (connections,
836 &check_connection, 848 &check_connection,
837 NULL); 849 NULL);
@@ -933,6 +945,7 @@ send_connection_ack (struct CadetConnection *connection, int fwd)
933{ 945{
934 struct CadetTunnel *t; 946 struct CadetTunnel *t;
935 947
948 GCC_check_connections ();
936 t = connection->t; 949 t = connection->t;
937 LOG (GNUNET_ERROR_TYPE_INFO, "---> {%14s ACK} on connection %s\n", 950 LOG (GNUNET_ERROR_TYPE_INFO, "---> {%14s ACK} on connection %s\n",
938 GC_f2s (!fwd), GCC_2s (connection)); 951 GC_f2s (!fwd), GCC_2s (connection));
@@ -945,6 +958,7 @@ send_connection_ack (struct CadetConnection *connection, int fwd)
945 GCT_change_cstate (t, CADET_TUNNEL_WAITING); 958 GCT_change_cstate (t, CADET_TUNNEL_WAITING);
946 if (CADET_CONNECTION_READY != connection->state) 959 if (CADET_CONNECTION_READY != connection->state)
947 connection_change_state (connection, CADET_CONNECTION_SENT); 960 connection_change_state (connection, CADET_CONNECTION_SENT);
961 GCC_check_connections ();
948} 962}
949 963
950 964
@@ -964,13 +978,16 @@ send_broken (struct CadetConnection *c,
964{ 978{
965 struct GNUNET_CADET_ConnectionBroken msg; 979 struct GNUNET_CADET_ConnectionBroken msg;
966 980
981 GCC_check_connections ();
967 msg.header.size = htons (sizeof (struct GNUNET_CADET_ConnectionBroken)); 982 msg.header.size = htons (sizeof (struct GNUNET_CADET_ConnectionBroken));
968 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN); 983 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN);
969 msg.cid = c->id; 984 msg.cid = c->id;
970 msg.peer1 = *id1; 985 msg.peer1 = *id1;
971 msg.peer2 = *id2; 986 msg.peer2 = *id2;
972 GNUNET_assert (NULL == GCC_send_prebuilt_message (&msg.header, 0, 0, c, fwd, 987 GNUNET_assert (NULL ==
973 GNUNET_YES, NULL, NULL)); 988 GCC_send_prebuilt_message (&msg.header, 0, 0, c, fwd,
989 GNUNET_YES, NULL, NULL));
990 GCC_check_connections ();
974} 991}
975 992
976 993
@@ -992,6 +1009,7 @@ send_broken_unknown (const struct GNUNET_CADET_Hash *connection_id,
992 struct GNUNET_CADET_ConnectionBroken *msg; 1009 struct GNUNET_CADET_ConnectionBroken *msg;
993 struct CadetPeer *neighbor; 1010 struct CadetPeer *neighbor;
994 1011
1012 GCC_check_connections ();
995 LOG (GNUNET_ERROR_TYPE_INFO, "---> BROKEN on unknown connection %s\n", 1013 LOG (GNUNET_ERROR_TYPE_INFO, "---> BROKEN on unknown connection %s\n",
996 GNUNET_h2s (GC_h2hc (connection_id))); 1014 GNUNET_h2s (GC_h2hc (connection_id)));
997 1015
@@ -1009,6 +1027,7 @@ send_broken_unknown (const struct GNUNET_CADET_Hash *connection_id,
1009 0, 2, sizeof (struct GNUNET_CADET_ConnectionBroken), 1027 0, 2, sizeof (struct GNUNET_CADET_ConnectionBroken),
1010 NULL, GNUNET_SYSERR, /* connection, fwd */ 1028 NULL, GNUNET_SYSERR, /* connection, fwd */
1011 NULL, NULL); /* continuation */ 1029 NULL, NULL); /* continuation */
1030 GCC_check_connections ();
1012} 1031}
1013 1032
1014 1033
@@ -1024,7 +1043,9 @@ send_connection_keepalive (struct CadetConnection *c, int fwd)
1024 struct GNUNET_MessageHeader msg; 1043 struct GNUNET_MessageHeader msg;
1025 struct CadetFlowControl *fc; 1044 struct CadetFlowControl *fc;
1026 1045
1027 LOG (GNUNET_ERROR_TYPE_INFO, "keepalive %s for connection %s\n", 1046 GCC_check_connections ();
1047 LOG (GNUNET_ERROR_TYPE_INFO,
1048 "keepalive %s for connection %s\n",
1028 GC_f2s (fwd), GCC_2s (c)); 1049 GC_f2s (fwd), GCC_2s (c));
1029 1050
1030 fc = fwd ? &c->fwd_fc : &c->bck_fc; 1051 fc = fwd ? &c->fwd_fc : &c->bck_fc;
@@ -1043,6 +1064,7 @@ send_connection_keepalive (struct CadetConnection *c, int fwd)
1043 GNUNET_assert (NULL == 1064 GNUNET_assert (NULL ==
1044 GCT_send_prebuilt_message (&msg, c->t, c, 1065 GCT_send_prebuilt_message (&msg, c->t, c,
1045 GNUNET_NO, NULL, NULL)); 1066 GNUNET_NO, NULL, NULL));
1067 GCC_check_connections ();
1046} 1068}
1047 1069
1048 1070
@@ -1055,7 +1077,8 @@ send_connection_keepalive (struct CadetConnection *c, int fwd)
1055static void 1077static void
1056connection_recreate (struct CadetConnection *c, int fwd) 1078connection_recreate (struct CadetConnection *c, int fwd)
1057{ 1079{
1058 LOG (GNUNET_ERROR_TYPE_DEBUG, "sending connection recreate\n"); 1080 LOG (GNUNET_ERROR_TYPE_DEBUG,
1081 "sending connection recreate\n");
1059 if (fwd) 1082 if (fwd)
1060 GCC_send_create (c); 1083 GCC_send_create (c);
1061 else 1084 else
@@ -1113,7 +1136,6 @@ connection_maintain (struct CadetConnection *c, int fwd)
1113} 1136}
1114 1137
1115 1138
1116
1117/** 1139/**
1118 * Keep the connection alive. 1140 * Keep the connection alive.
1119 * 1141 *
@@ -1125,7 +1147,9 @@ connection_maintain (struct CadetConnection *c, int fwd)
1125static void 1147static void
1126connection_keepalive (struct CadetConnection *c, int fwd, int shutdown) 1148connection_keepalive (struct CadetConnection *c, int fwd, int shutdown)
1127{ 1149{
1128 LOG (GNUNET_ERROR_TYPE_DEBUG, "%s keepalive for %s\n", 1150 GCC_check_connections ();
1151 LOG (GNUNET_ERROR_TYPE_DEBUG,
1152 "%s keepalive for %s\n",
1129 GC_f2s (fwd), GCC_2s (c)); 1153 GC_f2s (fwd), GCC_2s (c));
1130 1154
1131 if (fwd) 1155 if (fwd)
@@ -1137,7 +1161,7 @@ connection_keepalive (struct CadetConnection *c, int fwd, int shutdown)
1137 return; 1161 return;
1138 1162
1139 connection_maintain (c, fwd); 1163 connection_maintain (c, fwd);
1140 1164 GCC_check_connections ();
1141 /* Next execution will be scheduled by message_sent or _maintain*/ 1165 /* Next execution will be scheduled by message_sent or _maintain*/
1142} 1166}
1143 1167
@@ -1152,9 +1176,11 @@ static void
1152connection_fwd_keepalive (void *cls, 1176connection_fwd_keepalive (void *cls,
1153 const struct GNUNET_SCHEDULER_TaskContext *tc) 1177 const struct GNUNET_SCHEDULER_TaskContext *tc)
1154{ 1178{
1179 GCC_check_connections ();
1155 connection_keepalive ((struct CadetConnection *) cls, 1180 connection_keepalive ((struct CadetConnection *) cls,
1156 GNUNET_YES, 1181 GNUNET_YES,
1157 tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN); 1182 tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN);
1183 GCC_check_connections ();
1158} 1184}
1159 1185
1160 1186
@@ -1168,9 +1194,11 @@ static void
1168connection_bck_keepalive (void *cls, 1194connection_bck_keepalive (void *cls,
1169 const struct GNUNET_SCHEDULER_TaskContext *tc) 1195 const struct GNUNET_SCHEDULER_TaskContext *tc)
1170{ 1196{
1197 GCC_check_connections ();
1171 connection_keepalive ((struct CadetConnection *) cls, 1198 connection_keepalive ((struct CadetConnection *) cls,
1172 GNUNET_NO, 1199 GNUNET_NO,
1173 tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN); 1200 tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN);
1201 GCC_check_connections ();
1174} 1202}
1175 1203
1176 1204
@@ -1190,6 +1218,7 @@ schedule_next_keepalive (struct CadetConnection *c, int fwd)
1190 struct GNUNET_SCHEDULER_Task * *task_id; 1218 struct GNUNET_SCHEDULER_Task * *task_id;
1191 GNUNET_SCHEDULER_TaskCallback keepalive_task; 1219 GNUNET_SCHEDULER_TaskCallback keepalive_task;
1192 1220
1221 GCC_check_connections ();
1193 if (GNUNET_NO == GCC_is_origin (c, fwd)) 1222 if (GNUNET_NO == GCC_is_origin (c, fwd))
1194 return; 1223 return;
1195 1224
@@ -1229,9 +1258,12 @@ schedule_next_keepalive (struct CadetConnection *c, int fwd)
1229 } 1258 }
1230 1259
1231 /* Schedule the task */ 1260 /* Schedule the task */
1232 *task_id = GNUNET_SCHEDULER_add_delayed (delay, keepalive_task, c); 1261 *task_id = GNUNET_SCHEDULER_add_delayed (delay,
1262 keepalive_task,
1263 c);
1233 LOG (GNUNET_ERROR_TYPE_DEBUG, "next keepalive in %s\n", 1264 LOG (GNUNET_ERROR_TYPE_DEBUG, "next keepalive in %s\n",
1234 GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES)); 1265 GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES));
1266 GCC_check_connections ();
1235} 1267}
1236 1268
1237 1269
@@ -1250,7 +1282,9 @@ connection_unlock_queue (struct CadetConnection *c, int fwd)
1250{ 1282{
1251 struct CadetPeer *peer; 1283 struct CadetPeer *peer;
1252 1284
1253 LOG (GNUNET_ERROR_TYPE_DEBUG, "connection_unlock_queue %s on %s\n", 1285 GCC_check_connections ();
1286 LOG (GNUNET_ERROR_TYPE_DEBUG,
1287 "connection_unlock_queue %s on %s\n",
1254 GC_f2s (fwd), GCC_2s (c)); 1288 GC_f2s (fwd), GCC_2s (c));
1255 1289
1256 if (GCC_is_terminal (c, fwd)) 1290 if (GCC_is_terminal (c, fwd))
@@ -1261,6 +1295,7 @@ connection_unlock_queue (struct CadetConnection *c, int fwd)
1261 1295
1262 peer = get_hop (c, fwd); 1296 peer = get_hop (c, fwd);
1263 GCP_queue_unlock (peer, c); 1297 GCP_queue_unlock (peer, c);
1298 GCC_check_connections ();
1264} 1299}
1265 1300
1266 1301
@@ -1279,7 +1314,9 @@ connection_cancel_queues (struct CadetConnection *c, int fwd)
1279 struct CadetFlowControl *fc; 1314 struct CadetFlowControl *fc;
1280 struct CadetPeer *peer; 1315 struct CadetPeer *peer;
1281 1316
1282 LOG (GNUNET_ERROR_TYPE_DEBUG, "Cancel %s queues for connection %s\n", 1317 GCC_check_connections ();
1318 LOG (GNUNET_ERROR_TYPE_DEBUG,
1319 "Cancel %s queues for connection %s\n",
1283 GC_f2s (fwd), GCC_2s (c)); 1320 GC_f2s (fwd), GCC_2s (c));
1284 if (NULL == c) 1321 if (NULL == c)
1285 { 1322 {
@@ -1296,6 +1333,7 @@ connection_cancel_queues (struct CadetConnection *c, int fwd)
1296 } 1333 }
1297 peer = get_hop (c, fwd); 1334 peer = get_hop (c, fwd);
1298 GCP_queue_cancel (peer, c); 1335 GCP_queue_cancel (peer, c);
1336 GCC_check_connections ();
1299} 1337}
1300 1338
1301 1339
@@ -1307,7 +1345,8 @@ connection_cancel_queues (struct CadetConnection *c, int fwd)
1307 * @param tc TaskContext. 1345 * @param tc TaskContext.
1308 */ 1346 */
1309static void 1347static void
1310connection_poll (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); 1348connection_poll (void *cls,
1349 const struct GNUNET_SCHEDULER_TaskContext *tc);
1311 1350
1312 1351
1313/** 1352/**
@@ -1338,11 +1377,12 @@ poll_sent (void *cls,
1338 fc->poll_msg = NULL; 1377 fc->poll_msg = NULL;
1339 fc->poll_time = GNUNET_TIME_STD_BACKOFF (fc->poll_time); 1378 fc->poll_time = GNUNET_TIME_STD_BACKOFF (fc->poll_time);
1340 fc->poll_task = GNUNET_SCHEDULER_add_delayed (fc->poll_time, 1379 fc->poll_task = GNUNET_SCHEDULER_add_delayed (fc->poll_time,
1341 &connection_poll, fc); 1380 &connection_poll,
1381 fc);
1342 LOG (GNUNET_ERROR_TYPE_DEBUG, " task %u\n", fc->poll_task); 1382 LOG (GNUNET_ERROR_TYPE_DEBUG, " task %u\n", fc->poll_task);
1343
1344} 1383}
1345 1384
1385
1346/** 1386/**
1347 * Function called if a connection has been stalled for a while, 1387 * Function called if a connection has been stalled for a while,
1348 * possibly due to a missed ACK. Poll the neighbor about its ACK status. 1388 * 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)
1359 int fwd; 1399 int fwd;
1360 1400
1361 fc->poll_task = NULL; 1401 fc->poll_task = NULL;
1402 GCC_check_connections ();
1362 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 1403 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
1363 { 1404 {
1364 return; 1405 return;
@@ -1377,6 +1418,7 @@ connection_poll (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1377 GCC_send_prebuilt_message (&msg.header, 0, fc->last_pid_sent, c, 1418 GCC_send_prebuilt_message (&msg.header, 0, fc->last_pid_sent, c,
1378 fc == &c->fwd_fc, GNUNET_YES, &poll_sent, fc); 1419 fc == &c->fwd_fc, GNUNET_YES, &poll_sent, fc);
1379 GNUNET_assert (NULL != fc->poll_msg); 1420 GNUNET_assert (NULL != fc->poll_msg);
1421 GCC_check_connections ();
1380} 1422}
1381 1423
1382 1424
@@ -1396,6 +1438,7 @@ resend_messages_and_destroy (struct CadetConnection *c, int fwd)
1396 unsigned int pending; 1438 unsigned int pending;
1397 int destroyed; 1439 int destroyed;
1398 1440
1441 GCC_check_connections ();
1399 c->state = CADET_CONNECTION_DESTROYED; 1442 c->state = CADET_CONNECTION_DESTROYED;
1400 c->destroy = GNUNET_YES; 1443 c->destroy = GNUNET_YES;
1401 1444
@@ -1423,6 +1466,7 @@ resend_messages_and_destroy (struct CadetConnection *c, int fwd)
1423 } 1466 }
1424 GCC_destroy (c); 1467 GCC_destroy (c);
1425 } 1468 }
1469 GCC_check_connections ();
1426} 1470}
1427 1471
1428 1472
@@ -1440,6 +1484,7 @@ connection_timeout (struct CadetConnection *c, int fwd)
1440{ 1484{
1441 struct CadetFlowControl *reverse_fc; 1485 struct CadetFlowControl *reverse_fc;
1442 1486
1487 GCC_check_connections ();
1443 reverse_fc = fwd ? &c->bck_fc : &c->fwd_fc; 1488 reverse_fc = fwd ? &c->bck_fc : &c->fwd_fc;
1444 1489
1445 LOG (GNUNET_ERROR_TYPE_INFO, 1490 LOG (GNUNET_ERROR_TYPE_INFO,
@@ -1463,10 +1508,12 @@ connection_timeout (struct CadetConnection *c, int fwd)
1463 send_broken_unknown (&c->id, &my_full_id, NULL, next_hop); 1508 send_broken_unknown (&c->id, &my_full_id, NULL, next_hop);
1464 if (0 < reverse_fc->queue_n) 1509 if (0 < reverse_fc->queue_n)
1465 resend_messages_and_destroy (c, !fwd); 1510 resend_messages_and_destroy (c, !fwd);
1511 GCC_check_connections ();
1466 return; 1512 return;
1467 } 1513 }
1468 1514
1469 GCC_destroy (c); 1515 GCC_destroy (c);
1516 GCC_check_connections ();
1470} 1517}
1471 1518
1472 1519
@@ -1486,8 +1533,9 @@ connection_fwd_timeout (void *cls,
1486 c->fwd_maintenance_task = NULL; 1533 c->fwd_maintenance_task = NULL;
1487 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 1534 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
1488 return; 1535 return;
1489 1536 GCC_check_connections ();
1490 connection_timeout (c, GNUNET_YES); 1537 connection_timeout (c, GNUNET_YES);
1538 GCC_check_connections ();
1491} 1539}
1492 1540
1493 1541
@@ -1507,8 +1555,9 @@ connection_bck_timeout (void *cls,
1507 c->bck_maintenance_task = NULL; 1555 c->bck_maintenance_task = NULL;
1508 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 1556 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
1509 return; 1557 return;
1510 1558 GCC_check_connections ();
1511 connection_timeout (c, GNUNET_NO); 1559 connection_timeout (c, GNUNET_NO);
1560 GCC_check_connections ();
1512} 1561}
1513 1562
1514 1563
@@ -1530,7 +1579,6 @@ static void
1530connection_reset_timeout (struct CadetConnection *c, int fwd) 1579connection_reset_timeout (struct CadetConnection *c, int fwd)
1531{ 1580{
1532 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connection %s reset timeout\n", GC_f2s (fwd)); 1581 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connection %s reset timeout\n", GC_f2s (fwd));
1533
1534 if (GCC_is_origin (c, fwd)) /* Startpoint */ 1582 if (GCC_is_origin (c, fwd)) /* Startpoint */
1535 { 1583 {
1536 schedule_next_keepalive (c, fwd); 1584 schedule_next_keepalive (c, fwd);
@@ -1658,7 +1706,6 @@ add_to_peer (struct CadetConnection *c,
1658} 1706}
1659 1707
1660 1708
1661
1662/** 1709/**
1663 * Iterator to compare each connection's path with the path of a new connection. 1710 * Iterator to compare each connection's path with the path of a new connection.
1664 * 1711 *
@@ -1689,6 +1736,7 @@ check_path (void *cls, struct CadetConnection *c)
1689 } 1736 }
1690} 1737}
1691 1738
1739
1692/** 1740/**
1693 * Finds out if this path is already being used by and existing connection. 1741 * Finds out if this path is already being used by and existing connection.
1694 * 1742 *
@@ -1700,9 +1748,8 @@ check_path (void *cls, struct CadetConnection *c)
1700 * the peer will eventually reject our attempt). 1748 * the peer will eventually reject our attempt).
1701 * 1749 *
1702 * @param path Path to check. 1750 * @param path Path to check.
1703 * 1751 * @return #GNUNET_YES if the tunnel has a connection with the same path,
1704 * @return GNUNET_YES if the tunnel has a connection with the same path, 1752 * #GNUNET_NO otherwise.
1705 * GNUNET_NO otherwise.
1706 */ 1753 */
1707static int 1754static int
1708does_connection_exist (struct CadetConnection *conn) 1755does_connection_exist (struct CadetConnection *conn)
@@ -1810,7 +1857,7 @@ GCC_handle_create (void *cls, const struct GNUNET_PeerIdentity *peer,
1810 unsigned int own_pos; 1857 unsigned int own_pos;
1811 uint16_t size; 1858 uint16_t size;
1812 1859
1813 check_connections (); 1860 GCC_check_connections ();
1814 /* Check size */ 1861 /* Check size */
1815 size = ntohs (message->size); 1862 size = ntohs (message->size);
1816 if (size < sizeof (struct GNUNET_CADET_ConnectionCreate)) 1863 if (size < sizeof (struct GNUNET_CADET_ConnectionCreate))
@@ -1879,14 +1926,14 @@ GCC_handle_create (void *cls, const struct GNUNET_PeerIdentity *peer,
1879 /* If we are destination, why did the creation fail? */ 1926 /* If we are destination, why did the creation fail? */
1880 GNUNET_break (0); 1927 GNUNET_break (0);
1881 path_destroy (path); 1928 path_destroy (path);
1882 check_connections (); 1929 GCC_check_connections ();
1883 return GNUNET_OK; 1930 return GNUNET_OK;
1884 } 1931 }
1885 send_broken_unknown (cid, &my_full_id, 1932 send_broken_unknown (cid, &my_full_id,
1886 GNUNET_PEER_resolve2 (path->peers[own_pos + 1]), 1933 GNUNET_PEER_resolve2 (path->peers[own_pos + 1]),
1887 peer); 1934 peer);
1888 path_destroy (path); 1935 path_destroy (path);
1889 check_connections (); 1936 GCC_check_connections ();
1890 return GNUNET_OK; 1937 return GNUNET_OK;
1891 } 1938 }
1892 GCP_add_path_to_all (path, GNUNET_NO); 1939 GCP_add_path_to_all (path, GNUNET_NO);
@@ -1924,7 +1971,7 @@ GCC_handle_create (void *cls, const struct GNUNET_PeerIdentity *peer,
1924 path_destroy (path); 1971 path_destroy (path);
1925 GCC_destroy (c); 1972 GCC_destroy (c);
1926 send_broken_unknown (cid, &my_full_id, NULL, peer); 1973 send_broken_unknown (cid, &my_full_id, NULL, peer);
1927 check_connections (); 1974 GCC_check_connections ();
1928 return GNUNET_OK; 1975 return GNUNET_OK;
1929 } 1976 }
1930 1977
@@ -1946,7 +1993,7 @@ GCC_handle_create (void *cls, const struct GNUNET_PeerIdentity *peer,
1946 NULL, NULL)); 1993 NULL, NULL));
1947 } 1994 }
1948 path_destroy (path); 1995 path_destroy (path);
1949 check_connections (); 1996 GCC_check_connections ();
1950 return GNUNET_OK; 1997 return GNUNET_OK;
1951} 1998}
1952 1999
@@ -1972,7 +2019,7 @@ GCC_handle_confirm (void *cls,
1972 enum CadetConnectionState oldstate; 2019 enum CadetConnectionState oldstate;
1973 int fwd; 2020 int fwd;
1974 2021
1975 check_connections (); 2022 GCC_check_connections ();
1976 msg = (struct GNUNET_CADET_ConnectionACK *) message; 2023 msg = (struct GNUNET_CADET_ConnectionACK *) message;
1977 log_message (message, peer, &msg->cid); 2024 log_message (message, peer, &msg->cid);
1978 c = connection_get (&msg->cid); 2025 c = connection_get (&msg->cid);
@@ -1983,7 +2030,7 @@ GCC_handle_confirm (void *cls,
1983 LOG (GNUNET_ERROR_TYPE_DEBUG, 2030 LOG (GNUNET_ERROR_TYPE_DEBUG,
1984 " don't know the connection!\n"); 2031 " don't know the connection!\n");
1985 send_broken_unknown (&msg->cid, &my_full_id, NULL, peer); 2032 send_broken_unknown (&msg->cid, &my_full_id, NULL, peer);
1986 check_connections (); 2033 GCC_check_connections ();
1987 return GNUNET_OK; 2034 return GNUNET_OK;
1988 } 2035 }
1989 2036
@@ -1991,7 +2038,7 @@ GCC_handle_confirm (void *cls,
1991 { 2038 {
1992 LOG (GNUNET_ERROR_TYPE_DEBUG, 2039 LOG (GNUNET_ERROR_TYPE_DEBUG,
1993 " connection being destroyed\n"); 2040 " connection being destroyed\n");
1994 check_connections (); 2041 GCC_check_connections ();
1995 return GNUNET_OK; 2042 return GNUNET_OK;
1996 } 2043 }
1997 2044
@@ -2051,7 +2098,7 @@ GCC_handle_confirm (void *cls,
2051 /* Change tunnel state, trigger KX */ 2098 /* Change tunnel state, trigger KX */
2052 if (CADET_TUNNEL_WAITING == GCT_get_cstate (c->t)) 2099 if (CADET_TUNNEL_WAITING == GCT_get_cstate (c->t))
2053 GCT_change_cstate (c->t, CADET_TUNNEL_READY); 2100 GCT_change_cstate (c->t, CADET_TUNNEL_READY);
2054 check_connections (); 2101 GCC_check_connections ();
2055 return GNUNET_OK; 2102 return GNUNET_OK;
2056 } 2103 }
2057 2104
@@ -2072,7 +2119,7 @@ GCC_handle_confirm (void *cls,
2072 /* Change tunnel state */ 2119 /* Change tunnel state */
2073 if (CADET_TUNNEL_WAITING == GCT_get_cstate (c->t)) 2120 if (CADET_TUNNEL_WAITING == GCT_get_cstate (c->t))
2074 GCT_change_cstate (c->t, CADET_TUNNEL_READY); 2121 GCT_change_cstate (c->t, CADET_TUNNEL_READY);
2075 check_connections (); 2122 GCC_check_connections ();
2076 return GNUNET_OK; 2123 return GNUNET_OK;
2077 } 2124 }
2078 2125
@@ -2080,7 +2127,7 @@ GCC_handle_confirm (void *cls,
2080 GNUNET_assert (NULL == 2127 GNUNET_assert (NULL ==
2081 GCC_send_prebuilt_message (message, 0, 0, c, fwd, 2128 GCC_send_prebuilt_message (message, 0, 0, c, fwd,
2082 GNUNET_YES, NULL, NULL)); 2129 GNUNET_YES, NULL, NULL));
2083 check_connections (); 2130 GCC_check_connections ();
2084 return GNUNET_OK; 2131 return GNUNET_OK;
2085} 2132}
2086 2133
@@ -2105,7 +2152,7 @@ GCC_handle_broken (void* cls,
2105 int pending; 2152 int pending;
2106 int fwd; 2153 int fwd;
2107 2154
2108 check_connections (); 2155 GCC_check_connections ();
2109 msg = (struct GNUNET_CADET_ConnectionBroken *) message; 2156 msg = (struct GNUNET_CADET_ConnectionBroken *) message;
2110 log_message (message, id, &msg->cid); 2157 log_message (message, id, &msg->cid);
2111 LOG (GNUNET_ERROR_TYPE_DEBUG, " regarding %s\n", 2158 LOG (GNUNET_ERROR_TYPE_DEBUG, " regarding %s\n",
@@ -2116,7 +2163,7 @@ GCC_handle_broken (void* cls,
2116 if (NULL == c) 2163 if (NULL == c)
2117 { 2164 {
2118 LOG (GNUNET_ERROR_TYPE_DEBUG, " duplicate CONNECTION_BROKEN\n"); 2165 LOG (GNUNET_ERROR_TYPE_DEBUG, " duplicate CONNECTION_BROKEN\n");
2119 check_connections (); 2166 GCC_check_connections ();
2120 return GNUNET_OK; 2167 return GNUNET_OK;
2121 } 2168 }
2122 2169
@@ -2156,7 +2203,7 @@ GCC_handle_broken (void* cls,
2156 GNUNET_YES, NULL, NULL)); 2203 GNUNET_YES, NULL, NULL));
2157 connection_cancel_queues (c, !fwd); 2204 connection_cancel_queues (c, !fwd);
2158 } 2205 }
2159 check_connections (); 2206 GCC_check_connections ();
2160 return GNUNET_OK; 2207 return GNUNET_OK;
2161} 2208}
2162 2209
@@ -2179,7 +2226,7 @@ GCC_handle_destroy (void *cls,
2179 struct CadetConnection *c; 2226 struct CadetConnection *c;
2180 int fwd; 2227 int fwd;
2181 2228
2182 check_connections (); 2229 GCC_check_connections ();
2183 msg = (const struct GNUNET_CADET_ConnectionDestroy *) message; 2230 msg = (const struct GNUNET_CADET_ConnectionDestroy *) message;
2184 log_message (message, peer, &msg->cid); 2231 log_message (message, peer, &msg->cid);
2185 c = connection_get (&msg->cid); 2232 c = connection_get (&msg->cid);
@@ -2193,7 +2240,7 @@ GCC_handle_destroy (void *cls,
2193 1, GNUNET_NO); 2240 1, GNUNET_NO);
2194 LOG (GNUNET_ERROR_TYPE_DEBUG, 2241 LOG (GNUNET_ERROR_TYPE_DEBUG,
2195 " connection unknown: already destroyed?\n"); 2242 " connection unknown: already destroyed?\n");
2196 check_connections (); 2243 GCC_check_connections ();
2197 return GNUNET_OK; 2244 return GNUNET_OK;
2198 } 2245 }
2199 fwd = is_fwd (c, peer); 2246 fwd = is_fwd (c, peer);
@@ -2209,7 +2256,7 @@ GCC_handle_destroy (void *cls,
2209 { 2256 {
2210 LOG (GNUNET_ERROR_TYPE_DEBUG, " directly destroying connection!\n"); 2257 LOG (GNUNET_ERROR_TYPE_DEBUG, " directly destroying connection!\n");
2211 GCC_destroy (c); 2258 GCC_destroy (c);
2212 check_connections (); 2259 GCC_check_connections ();
2213 return GNUNET_OK; 2260 return GNUNET_OK;
2214 } 2261 }
2215 c->destroy = GNUNET_YES; 2262 c->destroy = GNUNET_YES;
@@ -2219,7 +2266,7 @@ GCC_handle_destroy (void *cls,
2219 GCT_remove_connection (c->t, c); 2266 GCT_remove_connection (c->t, c);
2220 c->t = NULL; 2267 c->t = NULL;
2221 } 2268 }
2222 check_connections (); 2269 GCC_check_connections ();
2223 2270
2224 return GNUNET_OK; 2271 return GNUNET_OK;
2225} 2272}
@@ -2368,7 +2415,7 @@ handle_cadet_encrypted (const struct GNUNET_PeerIdentity *peer,
2368 uint32_t ttl; 2415 uint32_t ttl;
2369 int fwd; 2416 int fwd;
2370 2417
2371 check_connections (); 2418 GCC_check_connections ();
2372 if (GNUNET_MESSAGE_TYPE_CADET_AX == ntohs (message->type)) 2419 if (GNUNET_MESSAGE_TYPE_CADET_AX == ntohs (message->type))
2373 { 2420 {
2374 overhead = sizeof (struct GNUNET_CADET_AX); 2421 overhead = sizeof (struct GNUNET_CADET_AX);
@@ -2394,7 +2441,7 @@ handle_cadet_encrypted (const struct GNUNET_PeerIdentity *peer,
2394 /* If something went wrong, discard message. */ 2441 /* If something went wrong, discard message. */
2395 if (GNUNET_SYSERR == fwd) 2442 if (GNUNET_SYSERR == fwd)
2396 { 2443 {
2397 check_connections (); 2444 GCC_check_connections ();
2398 return GNUNET_OK; 2445 return GNUNET_OK;
2399 } 2446 }
2400 2447
@@ -2410,7 +2457,7 @@ handle_cadet_encrypted (const struct GNUNET_PeerIdentity *peer,
2410 } 2457 }
2411 GCT_handle_encrypted (c->t, message); 2458 GCT_handle_encrypted (c->t, message);
2412 GCC_send_ack (c, fwd, GNUNET_NO); 2459 GCC_send_ack (c, fwd, GNUNET_NO);
2413 check_connections (); 2460 GCC_check_connections ();
2414 return GNUNET_OK; 2461 return GNUNET_OK;
2415 } 2462 }
2416 2463
@@ -2425,7 +2472,7 @@ handle_cadet_encrypted (const struct GNUNET_PeerIdentity *peer,
2425 GNUNET_STATISTICS_update (stats, "# TTL drops", 1, GNUNET_NO); 2472 GNUNET_STATISTICS_update (stats, "# TTL drops", 1, GNUNET_NO);
2426 LOG (GNUNET_ERROR_TYPE_WARNING, " TTL is 0, DROPPING!\n"); 2473 LOG (GNUNET_ERROR_TYPE_WARNING, " TTL is 0, DROPPING!\n");
2427 GCC_send_ack (c, fwd, GNUNET_NO); 2474 GCC_send_ack (c, fwd, GNUNET_NO);
2428 check_connections (); 2475 GCC_check_connections ();
2429 return GNUNET_OK; 2476 return GNUNET_OK;
2430 } 2477 }
2431 } 2478 }
@@ -2433,7 +2480,7 @@ handle_cadet_encrypted (const struct GNUNET_PeerIdentity *peer,
2433 GNUNET_STATISTICS_update (stats, "# messages forwarded", 1, GNUNET_NO); 2480 GNUNET_STATISTICS_update (stats, "# messages forwarded", 1, GNUNET_NO);
2434 GNUNET_assert (NULL == GCC_send_prebuilt_message (message, 0, 0, c, fwd, 2481 GNUNET_assert (NULL == GCC_send_prebuilt_message (message, 0, 0, c, fwd,
2435 GNUNET_NO, NULL, NULL)); 2482 GNUNET_NO, NULL, NULL));
2436 check_connections (); 2483 GCC_check_connections ();
2437 return GNUNET_OK; 2484 return GNUNET_OK;
2438} 2485}
2439 2486
@@ -2455,7 +2502,7 @@ handle_cadet_kx (const struct GNUNET_PeerIdentity *peer,
2455 size_t expected_size; 2502 size_t expected_size;
2456 int fwd; 2503 int fwd;
2457 2504
2458 check_connections (); 2505 GCC_check_connections ();
2459 cid = &msg->cid; 2506 cid = &msg->cid;
2460 log_message (&msg->header, peer, cid); 2507 log_message (&msg->header, peer, cid);
2461 2508
@@ -2479,7 +2526,7 @@ handle_cadet_kx (const struct GNUNET_PeerIdentity *peer,
2479 return GNUNET_OK; 2526 return GNUNET_OK;
2480 } 2527 }
2481 GCT_handle_kx (c->t, &msg[1].header); 2528 GCT_handle_kx (c->t, &msg[1].header);
2482 check_connections (); 2529 GCC_check_connections ();
2483 return GNUNET_OK; 2530 return GNUNET_OK;
2484 } 2531 }
2485 2532
@@ -2488,7 +2535,7 @@ handle_cadet_kx (const struct GNUNET_PeerIdentity *peer,
2488 GNUNET_STATISTICS_update (stats, "# messages forwarded", 1, GNUNET_NO); 2535 GNUNET_STATISTICS_update (stats, "# messages forwarded", 1, GNUNET_NO);
2489 GNUNET_assert (NULL == GCC_send_prebuilt_message (&msg->header, 0, 0, c, fwd, 2536 GNUNET_assert (NULL == GCC_send_prebuilt_message (&msg->header, 0, 0, c, fwd,
2490 GNUNET_NO, NULL, NULL)); 2537 GNUNET_NO, NULL, NULL));
2491 check_connections (); 2538 GCC_check_connections ();
2492 return GNUNET_OK; 2539 return GNUNET_OK;
2493} 2540}
2494 2541
@@ -2507,7 +2554,7 @@ GCC_handle_kx (void *cls,
2507 const struct GNUNET_PeerIdentity *peer, 2554 const struct GNUNET_PeerIdentity *peer,
2508 const struct GNUNET_MessageHeader *message) 2555 const struct GNUNET_MessageHeader *message)
2509{ 2556{
2510 check_connections (); 2557 GCC_check_connections ();
2511 return handle_cadet_kx (peer, (struct GNUNET_CADET_KX *) message); 2558 return handle_cadet_kx (peer, (struct GNUNET_CADET_KX *) message);
2512} 2559}
2513 2560
@@ -2525,7 +2572,7 @@ int
2525GCC_handle_encrypted (void *cls, const struct GNUNET_PeerIdentity *peer, 2572GCC_handle_encrypted (void *cls, const struct GNUNET_PeerIdentity *peer,
2526 const struct GNUNET_MessageHeader *message) 2573 const struct GNUNET_MessageHeader *message)
2527{ 2574{
2528 check_connections (); 2575 GCC_check_connections ();
2529 return handle_cadet_encrypted (peer, message); 2576 return handle_cadet_encrypted (peer, message);
2530} 2577}
2531 2578
@@ -2550,7 +2597,7 @@ GCC_handle_ack (void *cls, const struct GNUNET_PeerIdentity *peer,
2550 uint32_t ack; 2597 uint32_t ack;
2551 int fwd; 2598 int fwd;
2552 2599
2553 check_connections (); 2600 GCC_check_connections ();
2554 msg = (struct GNUNET_CADET_ACK *) message; 2601 msg = (struct GNUNET_CADET_ACK *) message;
2555 log_message (message, peer, &msg->cid); 2602 log_message (message, peer, &msg->cid);
2556 c = connection_get (&msg->cid); 2603 c = connection_get (&msg->cid);
@@ -2559,7 +2606,7 @@ GCC_handle_ack (void *cls, const struct GNUNET_PeerIdentity *peer,
2559 GNUNET_STATISTICS_update (stats, "# ack on unknown connection", 1, 2606 GNUNET_STATISTICS_update (stats, "# ack on unknown connection", 1,
2560 GNUNET_NO); 2607 GNUNET_NO);
2561 send_broken_unknown (&msg->cid, &my_full_id, NULL, peer); 2608 send_broken_unknown (&msg->cid, &my_full_id, NULL, peer);
2562 check_connections (); 2609 GCC_check_connections ();
2563 return GNUNET_OK; 2610 return GNUNET_OK;
2564 } 2611 }
2565 2612
@@ -2598,7 +2645,7 @@ GCC_handle_ack (void *cls, const struct GNUNET_PeerIdentity *peer,
2598 } 2645 }
2599 2646
2600 connection_unlock_queue (c, fwd); 2647 connection_unlock_queue (c, fwd);
2601 check_connections (); 2648 GCC_check_connections ();
2602 return GNUNET_OK; 2649 return GNUNET_OK;
2603} 2650}
2604 2651
@@ -2624,7 +2671,7 @@ GCC_handle_poll (void *cls,
2624 uint32_t pid; 2671 uint32_t pid;
2625 int fwd; 2672 int fwd;
2626 2673
2627 check_connections (); 2674 GCC_check_connections ();
2628 msg = (struct GNUNET_CADET_Poll *) message; 2675 msg = (struct GNUNET_CADET_Poll *) message;
2629 log_message (message, peer, &msg->cid); 2676 log_message (message, peer, &msg->cid);
2630 c = connection_get (&msg->cid); 2677 c = connection_get (&msg->cid);
@@ -2635,7 +2682,7 @@ GCC_handle_poll (void *cls,
2635 LOG (GNUNET_ERROR_TYPE_DEBUG, "POLL message on unknown connection %s!\n", 2682 LOG (GNUNET_ERROR_TYPE_DEBUG, "POLL message on unknown connection %s!\n",
2636 GNUNET_h2s (GC_h2hc (&msg->cid))); 2683 GNUNET_h2s (GC_h2hc (&msg->cid)));
2637 send_broken_unknown (&msg->cid, &my_full_id, NULL, peer); 2684 send_broken_unknown (&msg->cid, &my_full_id, NULL, peer);
2638 check_connections (); 2685 GCC_check_connections ();
2639 return GNUNET_OK; 2686 return GNUNET_OK;
2640 } 2687 }
2641 2688
@@ -2666,7 +2713,7 @@ GCC_handle_poll (void *cls,
2666 fc->last_pid_recv = pid; 2713 fc->last_pid_recv = pid;
2667 fwd = fc == &c->bck_fc; 2714 fwd = fc == &c->bck_fc;
2668 GCC_send_ack (c, fwd, GNUNET_YES); 2715 GCC_send_ack (c, fwd, GNUNET_YES);
2669 check_connections (); 2716 GCC_check_connections ();
2670 2717
2671 return GNUNET_OK; 2718 return GNUNET_OK;
2672} 2719}
@@ -2685,7 +2732,7 @@ GCC_send_ack (struct CadetConnection *c, int fwd, int force)
2685{ 2732{
2686 unsigned int buffer; 2733 unsigned int buffer;
2687 2734
2688 check_connections (); 2735 GCC_check_connections ();
2689 LOG (GNUNET_ERROR_TYPE_DEBUG, "GCC send %s ACK on %s\n", 2736 LOG (GNUNET_ERROR_TYPE_DEBUG, "GCC send %s ACK on %s\n",
2690 GC_f2s (fwd), GCC_2s (c)); 2737 GC_f2s (fwd), GCC_2s (c));
2691 2738
@@ -2698,7 +2745,7 @@ GCC_send_ack (struct CadetConnection *c, int fwd, int force)
2698 if (GNUNET_NO != c->destroy) 2745 if (GNUNET_NO != c->destroy)
2699 { 2746 {
2700 LOG (GNUNET_ERROR_TYPE_DEBUG, " being destroyed, why bother...\n"); 2747 LOG (GNUNET_ERROR_TYPE_DEBUG, " being destroyed, why bother...\n");
2701 check_connections (); 2748 GCC_check_connections ();
2702 return; 2749 return;
2703 } 2750 }
2704 2751
@@ -2716,7 +2763,7 @@ GCC_send_ack (struct CadetConnection *c, int fwd, int force)
2716 LOG (GNUNET_ERROR_TYPE_DEBUG, " buffer available: %u\n", buffer); 2763 LOG (GNUNET_ERROR_TYPE_DEBUG, " buffer available: %u\n", buffer);
2717 if (0 == buffer && GNUNET_NO == force) 2764 if (0 == buffer && GNUNET_NO == force)
2718 { 2765 {
2719 check_connections (); 2766 GCC_check_connections ();
2720 return; 2767 return;
2721 } 2768 }
2722 2769
@@ -2732,7 +2779,7 @@ GCC_send_ack (struct CadetConnection *c, int fwd, int force)
2732 LOG (GNUNET_ERROR_TYPE_DEBUG, " sending on connection\n"); 2779 LOG (GNUNET_ERROR_TYPE_DEBUG, " sending on connection\n");
2733 send_ack (c, buffer, fwd, force); 2780 send_ack (c, buffer, fwd, force);
2734 } 2781 }
2735 check_connections (); 2782 GCC_check_connections ();
2736} 2783}
2737 2784
2738 2785
@@ -2807,7 +2854,7 @@ shutdown_iterator (void *cls,
2807void 2854void
2808GCC_shutdown (void) 2855GCC_shutdown (void)
2809{ 2856{
2810 check_connections (); 2857 GCC_check_connections ();
2811 GNUNET_CONTAINER_multihashmap_iterate (connections, 2858 GNUNET_CONTAINER_multihashmap_iterate (connections,
2812 &shutdown_iterator, 2859 &shutdown_iterator,
2813 NULL); 2860 NULL);
@@ -2835,7 +2882,7 @@ GCC_new (const struct GNUNET_CADET_Hash *cid,
2835 struct CadetConnection *c; 2882 struct CadetConnection *c;
2836 struct CadetPeerPath *p; 2883 struct CadetPeerPath *p;
2837 2884
2838 check_connections (); 2885 GCC_check_connections ();
2839 p = path_duplicate (path); 2886 p = path_duplicate (path);
2840 c = GNUNET_new (struct CadetConnection); 2887 c = GNUNET_new (struct CadetConnection);
2841 c->id = *cid; 2888 c->id = *cid;
@@ -2871,7 +2918,7 @@ GCC_new (const struct GNUNET_CADET_Hash *cid,
2871 return NULL; 2918 return NULL;
2872 } 2919 }
2873 LOG (GNUNET_ERROR_TYPE_INFO, "New connection %s\n", GCC_2s (c)); 2920 LOG (GNUNET_ERROR_TYPE_INFO, "New connection %s\n", GCC_2s (c));
2874 check_connections (); 2921 GCC_check_connections ();
2875 return c; 2922 return c;
2876} 2923}
2877 2924
@@ -2879,7 +2926,7 @@ GCC_new (const struct GNUNET_CADET_Hash *cid,
2879void 2926void
2880GCC_destroy (struct CadetConnection *c) 2927GCC_destroy (struct CadetConnection *c)
2881{ 2928{
2882 check_connections (); 2929 GCC_check_connections ();
2883 if (NULL == c) 2930 if (NULL == c)
2884 { 2931 {
2885 GNUNET_break (0); 2932 GNUNET_break (0);
@@ -2953,7 +3000,7 @@ GCC_destroy (struct CadetConnection *c)
2953 -1, 3000 -1,
2954 GNUNET_NO); 3001 GNUNET_NO);
2955 GNUNET_free (c); 3002 GNUNET_free (c);
2956 check_connections (); 3003 GCC_check_connections ();
2957} 3004}
2958 3005
2959 3006
@@ -3145,7 +3192,7 @@ GCC_notify_broken (struct CadetConnection *c,
3145 struct CadetPeer *hop; 3192 struct CadetPeer *hop;
3146 int fwd; 3193 int fwd;
3147 3194
3148 check_connections (); 3195 GCC_check_connections ();
3149 LOG (GNUNET_ERROR_TYPE_DEBUG, 3196 LOG (GNUNET_ERROR_TYPE_DEBUG,
3150 "Notify broken on %s due to %s disconnect\n", 3197 "Notify broken on %s due to %s disconnect\n",
3151 GCC_2s (c), 3198 GCC_2s (c),
@@ -3162,7 +3209,7 @@ GCC_notify_broken (struct CadetConnection *c,
3162 { 3209 {
3163 /* Local shutdown, no one to notify about this. */ 3210 /* Local shutdown, no one to notify about this. */
3164 GCC_destroy (c); 3211 GCC_destroy (c);
3165 check_connections (); 3212 GCC_check_connections ();
3166 return; 3213 return;
3167 } 3214 }
3168 if (GNUNET_NO == c->destroy) 3215 if (GNUNET_NO == c->destroy)
@@ -3178,7 +3225,7 @@ GCC_notify_broken (struct CadetConnection *c,
3178 * Cancel all queues, if no message is left, connection will be destroyed. 3225 * Cancel all queues, if no message is left, connection will be destroyed.
3179 */ 3226 */
3180 connection_cancel_queues (c, ! fwd); 3227 connection_cancel_queues (c, ! fwd);
3181 check_connections (); 3228 GCC_check_connections ();
3182} 3229}
3183 3230
3184 3231
@@ -3296,7 +3343,7 @@ GCC_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
3296 uint16_t type; 3343 uint16_t type;
3297 int droppable; 3344 int droppable;
3298 3345
3299 check_connections (); 3346 GCC_check_connections ();
3300 size = ntohs (message->size); 3347 size = ntohs (message->size);
3301 data = GNUNET_malloc (size); 3348 data = GNUNET_malloc (size);
3302 memcpy (data, message, size); 3349 memcpy (data, message, size);
@@ -3418,12 +3465,12 @@ GCC_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
3418 LOG (GNUNET_ERROR_TYPE_DEBUG, "dropping msg on %s, NULL q\n", GCC_2s (c)); 3465 LOG (GNUNET_ERROR_TYPE_DEBUG, "dropping msg on %s, NULL q\n", GCC_2s (c));
3419 GNUNET_free (data); 3466 GNUNET_free (data);
3420 GNUNET_free (q); 3467 GNUNET_free (q);
3421 check_connections (); 3468 GCC_check_connections ();
3422 return NULL; 3469 return NULL;
3423 } 3470 }
3424 q->cont = cont; 3471 q->cont = cont;
3425 q->cont_cls = cont_cls; 3472 q->cont_cls = cont_cls;
3426 check_connections (); 3473 GCC_check_connections ();
3427 return (NULL == cont) ? NULL : q; 3474 return (NULL == cont) ? NULL : q;
3428} 3475}
3429 3476
@@ -3444,7 +3491,7 @@ GCC_cancel (struct CadetConnectionQueue *q)
3444 3491
3445 /* queue destroy calls message_sent, which calls q->cont and frees q */ 3492 /* queue destroy calls message_sent, which calls q->cont and frees q */
3446 GCP_queue_destroy (q->q, GNUNET_YES, GNUNET_NO, 0); 3493 GCP_queue_destroy (q->q, GNUNET_YES, GNUNET_NO, 0);
3447 check_connections (); 3494 GCC_check_connections ();
3448} 3495}
3449 3496
3450 3497
@@ -3460,7 +3507,7 @@ GCC_send_create (struct CadetConnection *connection)
3460 enum CadetTunnelCState state; 3507 enum CadetTunnelCState state;
3461 size_t size; 3508 size_t size;
3462 3509
3463 check_connections (); 3510 GCC_check_connections ();
3464 size = sizeof (struct GNUNET_CADET_ConnectionCreate); 3511 size = sizeof (struct GNUNET_CADET_ConnectionCreate);
3465 size += connection->path->length * sizeof (struct GNUNET_PeerIdentity); 3512 size += connection->path->length * sizeof (struct GNUNET_PeerIdentity);
3466 3513
@@ -3481,7 +3528,7 @@ GCC_send_create (struct CadetConnection *connection)
3481 GCT_change_cstate (connection->t, CADET_TUNNEL_WAITING); 3528 GCT_change_cstate (connection->t, CADET_TUNNEL_WAITING);
3482 if (CADET_CONNECTION_NEW == connection->state) 3529 if (CADET_CONNECTION_NEW == connection->state)
3483 connection_change_state (connection, CADET_CONNECTION_SENT); 3530 connection_change_state (connection, CADET_CONNECTION_SENT);
3484 check_connections (); 3531 GCC_check_connections ();
3485} 3532}
3486 3533
3487 3534
@@ -3501,7 +3548,7 @@ GCC_send_destroy (struct CadetConnection *c)
3501 3548
3502 if (GNUNET_YES == c->destroy) 3549 if (GNUNET_YES == c->destroy)
3503 return; 3550 return;
3504 check_connections (); 3551 GCC_check_connections ();
3505 msg.header.size = htons (sizeof (msg)); 3552 msg.header.size = htons (sizeof (msg));
3506 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY); 3553 msg.header.type = htons (GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY);
3507 msg.cid = c->id; 3554 msg.cid = c->id;
@@ -3519,7 +3566,7 @@ GCC_send_destroy (struct CadetConnection *c)
3519 NULL, NULL)); 3566 NULL, NULL));
3520 c->destroy = GNUNET_YES; 3567 c->destroy = GNUNET_YES;
3521 c->state = CADET_CONNECTION_DESTROYED; 3568 c->state = CADET_CONNECTION_DESTROYED;
3522 check_connections (); 3569 GCC_check_connections ();
3523} 3570}
3524 3571
3525 3572
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;
92#include "gnunet-service-cadet_peer.h" 92#include "gnunet-service-cadet_peer.h"
93 93
94 94
95/**
96 * Check invariants for all connections using #check_neighbours().
97 */
98void
99GCC_check_connections ();
100
95 101
96/** 102/**
97 * Callback called when a queued message is sent. 103 * 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;
50 * @param path An unchecked, unoptimized path to the target node. 50 * @param path An unchecked, unoptimized path to the target node.
51 * After callback will no longer be valid! 51 * After callback will no longer be valid!
52 */ 52 */
53typedef void (*GCD_search_callback) (void *cls, 53typedef void
54 const struct CadetPeerPath *path); 54(*GCD_search_callback) (void *cls,
55 const struct CadetPeerPath *path);
55 56
56/******************************************************************************/ 57/******************************************************************************/
57/******************************** API ***********************************/ 58/******************************** API ***********************************/
@@ -89,4 +90,4 @@ GCD_search_stop (struct GCD_search_handle *h);
89 90
90/* ifndef GNUNET_CADET_SERVICE_LOCAL_H */ 91/* ifndef GNUNET_CADET_SERVICE_LOCAL_H */
91#endif 92#endif
92/* end of gnunet-cadet-service_LOCAL.h */ \ No newline at end of file 93/* 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,
409 struct CadetPeerPath *path; 409 struct CadetPeerPath *path;
410 char own_id[16]; 410 char own_id[16];
411 411
412 GCC_check_connections ();
412 GNUNET_snprintf (own_id, 413 GNUNET_snprintf (own_id,
413 sizeof (own_id), 414 sizeof (own_id),
414 "%s", 415 "%s",
@@ -444,6 +445,7 @@ core_connect (void *cls,
444 if ( (NULL != GCP_get_tunnel (mp)) && 445 if ( (NULL != GCP_get_tunnel (mp)) &&
445 (0 > GNUNET_CRYPTO_cmp_peer_identity (&my_full_id, peer)) ) 446 (0 > GNUNET_CRYPTO_cmp_peer_identity (&my_full_id, peer)) )
446 GCP_connect (mp); 447 GCP_connect (mp);
448 GCC_check_connections ();
447} 449}
448 450
449 451
@@ -461,6 +463,7 @@ core_disconnect (void *cls,
461 struct CadetPeerPath *direct_path; 463 struct CadetPeerPath *direct_path;
462 char own_id[16]; 464 char own_id[16];
463 465
466 GCC_check_connections ();
464 strncpy (own_id, GNUNET_i2s (&my_full_id), 15); 467 strncpy (own_id, GNUNET_i2s (&my_full_id), 15);
465 p = GNUNET_CONTAINER_multipeermap_get (peers, peer); 468 p = GNUNET_CONTAINER_multipeermap_get (peers, peer);
466 if (NULL == p) 469 if (NULL == p)
@@ -493,6 +496,7 @@ core_disconnect (void *cls,
493 -1, 496 -1,
494 GNUNET_NO); 497 GNUNET_NO);
495 path_destroy (direct_path); 498 path_destroy (direct_path);
499 GCC_check_connections ();
496} 500}
497 501
498 502
@@ -789,8 +793,9 @@ shutdown_peer (void *cls,
789static int 793static int
790is_searching (const struct CadetPeer *peer) 794is_searching (const struct CadetPeer *peer)
791{ 795{
792 return (NULL == peer->search_h && NULL == peer->search_delayed) ? 796 return ( (NULL == peer->search_h) &&
793 GNUNET_NO : GNUNET_YES; 797 (NULL == peer->search_delayed) ) ?
798 GNUNET_NO : GNUNET_YES;
794} 799}
795 800
796 801
@@ -806,11 +811,11 @@ delayed_search (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
806 struct CadetPeer *peer = cls; 811 struct CadetPeer *peer = cls;
807 812
808 peer->search_delayed = NULL; 813 peer->search_delayed = NULL;
809
810 if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) 814 if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason))
811 return; 815 return;
812 816 GCC_check_connections ();
813 GCP_start_search (peer); 817 GCP_start_search (peer);
818 GCC_check_connections ();
814} 819}
815 820
816 821
@@ -1017,6 +1022,7 @@ search_handler (void *cls, const struct CadetPeerPath *path)
1017 struct CadetPeer *peer = cls; 1022 struct CadetPeer *peer = cls;
1018 unsigned int connection_count; 1023 unsigned int connection_count;
1019 1024
1025 GCC_check_connections ();
1020 GCP_add_path_to_all (path, GNUNET_NO); 1026 GCP_add_path_to_all (path, GNUNET_NO);
1021 1027
1022 /* Count connections */ 1028 /* Count connections */
@@ -1024,13 +1030,17 @@ search_handler (void *cls, const struct CadetPeerPath *path)
1024 1030
1025 /* If we already have our minimum (or more) connections, it's enough */ 1031 /* If we already have our minimum (or more) connections, it's enough */
1026 if (CONNECTIONS_PER_TUNNEL <= connection_count) 1032 if (CONNECTIONS_PER_TUNNEL <= connection_count)
1033 {
1034 GCC_check_connections ();
1027 return; 1035 return;
1036 }
1028 1037
1029 if (CADET_TUNNEL_SEARCHING == GCT_get_cstate (peer->tunnel)) 1038 if (CADET_TUNNEL_SEARCHING == GCT_get_cstate (peer->tunnel))
1030 { 1039 {
1031 LOG (GNUNET_ERROR_TYPE_DEBUG, " ... connect!\n"); 1040 LOG (GNUNET_ERROR_TYPE_DEBUG, " ... connect!\n");
1032 GCP_connect (peer); 1041 GCP_connect (peer);
1033 } 1042 }
1043 GCC_check_connections ();
1034} 1044}
1035 1045
1036 1046
@@ -1147,6 +1157,7 @@ queue_send (void *cls, size_t size, void *buf)
1147 char *dst; 1157 char *dst;
1148 uint32_t pid; 1158 uint32_t pid;
1149 1159
1160 GCC_check_connections ();
1150 LOG (GNUNET_ERROR_TYPE_DEBUG, "\n"); 1161 LOG (GNUNET_ERROR_TYPE_DEBUG, "\n");
1151 LOG (GNUNET_ERROR_TYPE_DEBUG, "\n"); 1162 LOG (GNUNET_ERROR_TYPE_DEBUG, "\n");
1152 LOG (GNUNET_ERROR_TYPE_DEBUG, "Queue send towards %s (max %u)\n", 1163 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)
1175 peer->core_transmit = NULL; 1186 peer->core_transmit = NULL;
1176 peer->tmt_time.abs_value_us = 0; 1187 peer->tmt_time.abs_value_us = 0;
1177 } 1188 }
1189 GCC_check_connections ();
1178 return 0; 1190 return 0;
1179 } 1191 }
1180 1192
@@ -1274,7 +1286,7 @@ queue_send (void *cls, size_t size, void *buf)
1274 1286
1275 LOG (GNUNET_ERROR_TYPE_DEBUG, " return %d\n", total_size); 1287 LOG (GNUNET_ERROR_TYPE_DEBUG, " return %d\n", total_size);
1276 queue_debug (peer, GNUNET_ERROR_TYPE_DEBUG); 1288 queue_debug (peer, GNUNET_ERROR_TYPE_DEBUG);
1277 1289 GCC_check_connections ();
1278 return total_size; 1290 return total_size;
1279} 1291}
1280 1292
@@ -1300,12 +1312,15 @@ queue_send (void *cls, size_t size, void *buf)
1300 * #GNUNET_NO otherwise. 1312 * #GNUNET_NO otherwise.
1301 */ 1313 */
1302int 1314int
1303GCP_queue_destroy (struct CadetPeerQueue *queue, int clear_cls, 1315GCP_queue_destroy (struct CadetPeerQueue *queue,
1304 int sent, uint32_t pid) 1316 int clear_cls,
1317 int sent,
1318 uint32_t pid)
1305{ 1319{
1306 struct CadetPeer *peer; 1320 struct CadetPeer *peer;
1307 int connection_destroyed; 1321 int connection_destroyed;
1308 1322
1323 GCC_check_connections ();
1309 peer = queue->peer; 1324 peer = queue->peer;
1310 LOG (GNUNET_ERROR_TYPE_DEBUG, "queue destroy %s\n", GC_m2s (queue->type)); 1325 LOG (GNUNET_ERROR_TYPE_DEBUG, "queue destroy %s\n", GC_m2s (queue->type));
1311 if (GNUNET_YES == clear_cls) 1326 if (GNUNET_YES == clear_cls)
@@ -1365,6 +1380,7 @@ GCP_queue_destroy (struct CadetPeerQueue *queue, int clear_cls,
1365 } 1380 }
1366 1381
1367 GNUNET_free (queue); 1382 GNUNET_free (queue);
1383 GCC_check_connections ();
1368 return connection_destroyed; 1384 return connection_destroyed;
1369} 1385}
1370 1386
@@ -1396,6 +1412,7 @@ GCP_queue_add (struct CadetPeer *peer, void *cls, uint16_t type,
1396 int priority; 1412 int priority;
1397 int call_core; 1413 int call_core;
1398 1414
1415 GCC_check_connections ();
1399 if (NULL == c && GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN != type) 1416 if (NULL == c && GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN != type)
1400 error_level = GNUNET_ERROR_TYPE_ERROR; 1417 error_level = GNUNET_ERROR_TYPE_ERROR;
1401 else 1418 else
@@ -1481,6 +1498,7 @@ GCP_queue_add (struct CadetPeer *peer, void *cls, uint16_t type,
1481 1498
1482 } 1499 }
1483 queue_debug (peer, GNUNET_ERROR_TYPE_DEBUG); 1500 queue_debug (peer, GNUNET_ERROR_TYPE_DEBUG);
1501 GCC_check_connections ();
1484 return q; 1502 return q;
1485} 1503}
1486 1504
@@ -1500,6 +1518,7 @@ GCP_queue_cancel (struct CadetPeer *peer, struct CadetConnection *c)
1500 struct CadetPeerQueue *prev; 1518 struct CadetPeerQueue *prev;
1501 int connection_destroyed; 1519 int connection_destroyed;
1502 1520
1521 GCC_check_connections ();
1503 connection_destroyed = GNUNET_NO; 1522 connection_destroyed = GNUNET_NO;
1504 for (q = peer->queue_head; NULL != q; q = next) 1523 for (q = peer->queue_head; NULL != q; q = next)
1505 { 1524 {
@@ -1537,6 +1556,7 @@ GCP_queue_cancel (struct CadetPeer *peer, struct CadetConnection *c)
1537 peer->core_transmit = NULL; 1556 peer->core_transmit = NULL;
1538 peer->tmt_time.abs_value_us = 0; 1557 peer->tmt_time.abs_value_us = 0;
1539 } 1558 }
1559 GCC_check_connections ();
1540} 1560}
1541 1561
1542 1562
@@ -1592,6 +1612,7 @@ GCP_connection_pop (struct CadetPeer *peer,
1592 struct GNUNET_MessageHeader *msg; 1612 struct GNUNET_MessageHeader *msg;
1593 int dest; 1613 int dest;
1594 1614
1615 GCC_check_connections ();
1595 GNUNET_assert (NULL != destroyed); 1616 GNUNET_assert (NULL != destroyed);
1596 LOG (GNUNET_ERROR_TYPE_DEBUG, "connection_pop on connection %p\n", c); 1617 LOG (GNUNET_ERROR_TYPE_DEBUG, "connection_pop on connection %p\n", c);
1597 for (q = peer->queue_head; NULL != q; q = next) 1618 for (q = peer->queue_head; NULL != q; q = next)
@@ -1636,10 +1657,11 @@ GCP_connection_pop (struct CadetPeer *peer,
1636 LOG (GNUNET_ERROR_TYPE_DEBUG, "Unknown message %s\n", GC_m2s (q->type)); 1657 LOG (GNUNET_ERROR_TYPE_DEBUG, "Unknown message %s\n", GC_m2s (q->type));
1637 } 1658 }
1638 } 1659 }
1639 1660 GCC_check_connections ();
1640 return NULL; 1661 return NULL;
1641} 1662}
1642 1663
1664
1643/** 1665/**
1644 * Unlock a possibly locked queue for a connection. 1666 * Unlock a possibly locked queue for a connection.
1645 * 1667 *
@@ -1656,6 +1678,7 @@ GCP_queue_unlock (struct CadetPeer *peer, struct CadetConnection *c)
1656 struct CadetPeerQueue *q; 1678 struct CadetPeerQueue *q;
1657 size_t size; 1679 size_t size;
1658 1680
1681 GCC_check_connections ();
1659 if (NULL != peer->core_transmit) 1682 if (NULL != peer->core_transmit)
1660 { 1683 {
1661 LOG (GNUNET_ERROR_TYPE_DEBUG, " already unlocked!\n"); 1684 LOG (GNUNET_ERROR_TYPE_DEBUG, " already unlocked!\n");
@@ -1679,6 +1702,7 @@ GCP_queue_unlock (struct CadetPeer *peer, struct CadetConnection *c)
1679 &queue_send, 1702 &queue_send,
1680 peer); 1703 peer);
1681 peer->tmt_time = GNUNET_TIME_absolute_get (); 1704 peer->tmt_time = GNUNET_TIME_absolute_get ();
1705 GCC_check_connections ();
1682} 1706}
1683 1707
1684 1708
@@ -1865,6 +1889,7 @@ GCP_connect (struct CadetPeer *peer)
1865 struct CadetConnection *c; 1889 struct CadetConnection *c;
1866 int rerun_search; 1890 int rerun_search;
1867 1891
1892 GCC_check_connections ();
1868 LOG (GNUNET_ERROR_TYPE_DEBUG, "peer_connect towards %s\n", GCP_2s (peer)); 1893 LOG (GNUNET_ERROR_TYPE_DEBUG, "peer_connect towards %s\n", GCP_2s (peer));
1869 1894
1870 /* If we have a current hello, try to connect using it. */ 1895 /* If we have a current hello, try to connect using it. */
@@ -1924,13 +1949,16 @@ GCP_connect (struct CadetPeer *peer)
1924 1949
1925 GCP_stop_search (peer); 1950 GCP_stop_search (peer);
1926 delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 100); 1951 delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 100);
1927 peer->search_delayed = GNUNET_SCHEDULER_add_delayed (delay, &delayed_search, 1952 peer->search_delayed = GNUNET_SCHEDULER_add_delayed (delay,
1953 &delayed_search,
1928 peer); 1954 peer);
1955 GCC_check_connections ();
1929 return; 1956 return;
1930 } 1957 }
1931 1958
1932 if (GNUNET_NO == is_searching (peer)) 1959 if (GNUNET_NO == is_searching (peer))
1933 GCP_start_search (peer); 1960 GCP_start_search (peer);
1961 GCC_check_connections ();
1934} 1962}
1935 1963
1936 1964
@@ -1971,9 +1999,11 @@ GCP_is_neighbor (const struct CadetPeer *peer)
1971void 1999void
1972GCP_add_tunnel (struct CadetPeer *peer) 2000GCP_add_tunnel (struct CadetPeer *peer)
1973{ 2001{
2002 GCC_check_connections ();
1974 if (NULL != peer->tunnel) 2003 if (NULL != peer->tunnel)
1975 return; 2004 return;
1976 peer->tunnel = GCT_new (peer); 2005 peer->tunnel = GCT_new (peer);
2006 GCC_check_connections ();
1977} 2007}
1978 2008
1979 2009
@@ -2025,14 +2055,17 @@ GCP_add_connection (struct CadetPeer *peer,
2025 * NULL on error. 2055 * NULL on error.
2026 */ 2056 */
2027struct CadetPeerPath * 2057struct CadetPeerPath *
2028GCP_add_path (struct CadetPeer *peer, struct CadetPeerPath *path, 2058GCP_add_path (struct CadetPeer *peer,
2059 struct CadetPeerPath *path,
2029 int trusted) 2060 int trusted)
2030{ 2061{
2031 struct CadetPeerPath *aux; 2062 struct CadetPeerPath *aux;
2032 unsigned int l; 2063 unsigned int l;
2033 unsigned int l2; 2064 unsigned int l2;
2034 2065
2035 LOG (GNUNET_ERROR_TYPE_DEBUG, "adding path [%u] to peer %s\n", 2066 GCC_check_connections ();
2067 LOG (GNUNET_ERROR_TYPE_DEBUG,
2068 "adding path [%u] to peer %s\n",
2036 path->length, GCP_2s (peer)); 2069 path->length, GCP_2s (peer));
2037 2070
2038 if (NULL == peer || NULL == path 2071 if (NULL == peer || NULL == path
@@ -2106,6 +2139,7 @@ finish:
2106 { 2139 {
2107 GCP_connect (peer); 2140 GCP_connect (peer);
2108 } 2141 }
2142 GCC_check_connections ();
2109 return path; 2143 return path;
2110} 2144}
2111 2145
@@ -2148,6 +2182,7 @@ GCP_add_path_to_all (const struct CadetPeerPath *p, int confirmed)
2148 unsigned int i; 2182 unsigned int i;
2149 2183
2150 /* TODO: invert and add */ 2184 /* TODO: invert and add */
2185 GCC_check_connections ();
2151 for (i = 0; i < p->length && p->peers[i] != myid; i++) /* skip'em */ ; 2186 for (i = 0; i < p->length && p->peers[i] != myid; i++) /* skip'em */ ;
2152 for (i++; i < p->length; i++) 2187 for (i++; i < p->length; i++)
2153 { 2188 {
@@ -2159,6 +2194,7 @@ GCP_add_path_to_all (const struct CadetPeerPath *p, int confirmed)
2159 copy->length = i + 1; 2194 copy->length = i + 1;
2160 GCP_add_path (aux, copy, p->length < 3 ? GNUNET_NO : confirmed); 2195 GCP_add_path (aux, copy, p->length < 3 ? GNUNET_NO : confirmed);
2161 } 2196 }
2197 GCC_check_connections ();
2162} 2198}
2163 2199
2164 2200
@@ -2174,6 +2210,7 @@ GCP_remove_path (struct CadetPeer *peer, struct CadetPeerPath *path)
2174 struct CadetPeerPath *iter; 2210 struct CadetPeerPath *iter;
2175 struct CadetPeerPath *next; 2211 struct CadetPeerPath *next;
2176 2212
2213 GCC_check_connections ();
2177 GNUNET_assert (myid == path->peers[0]); 2214 GNUNET_assert (myid == path->peers[0]);
2178 GNUNET_assert (peer->id == path->peers[path->length - 1]); 2215 GNUNET_assert (peer->id == path->peers[path->length - 1]);
2179 2216
@@ -2194,6 +2231,7 @@ GCP_remove_path (struct CadetPeer *peer, struct CadetPeerPath *path)
2194 } 2231 }
2195 } 2232 }
2196 path_destroy (path); 2233 path_destroy (path);
2234 GCC_check_connections ();
2197} 2235}
2198 2236
2199 2237
@@ -2259,7 +2297,8 @@ GCP_start_search (struct CadetPeer *peer)
2259 const struct GNUNET_PeerIdentity *id; 2297 const struct GNUNET_PeerIdentity *id;
2260 struct CadetTunnel *t = peer->tunnel; 2298 struct CadetTunnel *t = peer->tunnel;
2261 2299
2262 if (NULL != peer->search_h) 2300 GCC_check_connections ();
2301 if (NULL != peer->search_h)
2263 { 2302 {
2264 GNUNET_break (0); 2303 GNUNET_break (0);
2265 return; 2304 return;
@@ -2283,6 +2322,7 @@ GCP_start_search (struct CadetPeer *peer)
2283 { 2322 {
2284 GCT_change_cstate (t, CADET_TUNNEL_SEARCHING); 2323 GCT_change_cstate (t, CADET_TUNNEL_SEARCHING);
2285 } 2324 }
2325 GCC_check_connections ();
2286} 2326}
2287 2327
2288 2328
@@ -2295,6 +2335,7 @@ GCP_start_search (struct CadetPeer *peer)
2295void 2335void
2296GCP_stop_search (struct CadetPeer *peer) 2336GCP_stop_search (struct CadetPeer *peer)
2297{ 2337{
2338 GCC_check_connections ();
2298 if (NULL != peer->search_h) 2339 if (NULL != peer->search_h)
2299 { 2340 {
2300 GCD_search_stop (peer->search_h); 2341 GCD_search_stop (peer->search_h);
@@ -2305,6 +2346,7 @@ GCP_stop_search (struct CadetPeer *peer)
2305 GNUNET_SCHEDULER_cancel (peer->search_delayed); 2346 GNUNET_SCHEDULER_cancel (peer->search_delayed);
2306 peer->search_delayed = NULL; 2347 peer->search_delayed = NULL;
2307 } 2348 }
2349 GCC_check_connections ();
2308} 2350}
2309 2351
2310 2352
@@ -2381,7 +2423,8 @@ GCP_set_hello (struct CadetPeer *peer, const struct GNUNET_HELLO_Message *hello)
2381 struct GNUNET_HELLO_Message *old; 2423 struct GNUNET_HELLO_Message *old;
2382 size_t size; 2424 size_t size;
2383 2425
2384 LOG (GNUNET_ERROR_TYPE_DEBUG, "set hello for %s\n", GCP_2s (peer)); 2426 GCC_check_connections ();
2427 LOG (GNUNET_ERROR_TYPE_DEBUG, "set hello for %s\n", GCP_2s (peer));
2385 if (NULL == hello) 2428 if (NULL == hello)
2386 return; 2429 return;
2387 2430
@@ -2400,6 +2443,7 @@ GCP_set_hello (struct CadetPeer *peer, const struct GNUNET_HELLO_Message *hello)
2400 peer->hello, GNUNET_HELLO_size (hello)); 2443 peer->hello, GNUNET_HELLO_size (hello));
2401 GNUNET_free (old); 2444 GNUNET_free (old);
2402 } 2445 }
2446 GCC_check_connections ();
2403} 2447}
2404 2448
2405 2449
@@ -2445,13 +2489,17 @@ GCP_try_connect (struct CadetPeer *peer)
2445 2489
2446 if (NULL == transport_handle) 2490 if (NULL == transport_handle)
2447 return; 2491 return;
2448 2492 GCC_check_connections ();
2449 hello = GCP_get_hello (peer); 2493 hello = GCP_get_hello (peer);
2450 if (NULL == hello) 2494 if (NULL == hello)
2451 return; 2495 return;
2452 2496
2453 mh = GNUNET_HELLO_get_header (hello); 2497 mh = GNUNET_HELLO_get_header (hello);
2454 GNUNET_TRANSPORT_offer_hello (transport_handle, mh, try_connect, peer); 2498 GNUNET_TRANSPORT_offer_hello (transport_handle,
2499 mh,
2500 &try_connect,
2501 peer);
2502 GCC_check_connections ();
2455} 2503}
2456 2504
2457 2505
@@ -2474,6 +2522,7 @@ GCP_notify_broken_link (struct CadetPeer *peer,
2474 GNUNET_PEER_Id p1; 2522 GNUNET_PEER_Id p1;
2475 GNUNET_PEER_Id p2; 2523 GNUNET_PEER_Id p2;
2476 2524
2525 GCC_check_connections ();
2477 p1 = GNUNET_PEER_search (peer1); 2526 p1 = GNUNET_PEER_search (peer1);
2478 p2 = GNUNET_PEER_search (peer2); 2527 p2 = GNUNET_PEER_search (peer2);
2479 2528
@@ -2502,6 +2551,7 @@ GCP_notify_broken_link (struct CadetPeer *peer,
2502 } 2551 }
2503 } 2552 }
2504 } 2553 }
2554 GCC_check_connections ();
2505} 2555}
2506 2556
2507 2557
@@ -2535,9 +2585,11 @@ void
2535GCP_iterate_all (GNUNET_CONTAINER_PeerMapIterator iter, 2585GCP_iterate_all (GNUNET_CONTAINER_PeerMapIterator iter,
2536 void *cls) 2586 void *cls)
2537{ 2587{
2588 GCC_check_connections ();
2538 GNUNET_CONTAINER_multipeermap_iterate (peers, 2589 GNUNET_CONTAINER_multipeermap_iterate (peers,
2539 iter, 2590 iter,
2540 cls); 2591 cls);
2592 GCC_check_connections ();
2541} 2593}
2542 2594
2543 2595
@@ -2555,3 +2607,6 @@ GCP_2s (const struct CadetPeer *peer)
2555 return "(NULL)"; 2607 return "(NULL)";
2556 return GNUNET_i2s (GNUNET_PEER_resolve2 (peer->id)); 2608 return GNUNET_i2s (GNUNET_PEER_resolve2 (peer->id));
2557} 2609}
2610
2611
2612/* 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;
52 52
53#include "gnunet-service-cadet_connection.h" 53#include "gnunet-service-cadet_connection.h"
54 54
55
55/** 56/**
56 * Callback called when a queued message is sent. 57 * Callback called when a queued message is sent.
57 * 58 *
@@ -63,13 +64,14 @@ struct CadetPeerQueue;
63 * @param fwd Was this a FWD going message? 64 * @param fwd Was this a FWD going message?
64 * @param size Size of the message. 65 * @param size Size of the message.
65 * @param wait Time spent waiting for core (only the time for THIS message) 66 * @param wait Time spent waiting for core (only the time for THIS message)
66 *
67 * @return #GNUNET_YES if connection was destroyed, #GNUNET_NO otherwise. 67 * @return #GNUNET_YES if connection was destroyed, #GNUNET_NO otherwise.
68 */ 68 */
69typedef int (*GCP_sent) (void *cls, 69typedef int
70 struct CadetConnection *c, int sent, 70(*GCP_sent) (void *cls,
71 uint16_t type, uint32_t pid, int fwd, size_t size, 71 struct CadetConnection *c, int sent,
72 struct GNUNET_TIME_Relative wait); 72 uint16_t type, uint32_t pid, int fwd, size_t size,
73 struct GNUNET_TIME_Relative wait);
74
73 75
74/******************************************************************************/ 76/******************************************************************************/
75/******************************** API ***********************************/ 77/******************************** 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
156GCT_init (const struct GNUNET_CONFIGURATION_Handle *c, 156GCT_init (const struct GNUNET_CONFIGURATION_Handle *c,
157 const struct GNUNET_CRYPTO_EddsaPrivateKey *key); 157 const struct GNUNET_CRYPTO_EddsaPrivateKey *key);
158 158
159
159/** 160/**
160 * Shut down the tunnel subsystem. 161 * Shut down the tunnel subsystem.
161 */ 162 */
162void 163void
163GCT_shutdown (void); 164GCT_shutdown (void);
164 165
166
165/** 167/**
166 * Create a tunnel. 168 * Create a tunnel.
167 * 169 *
@@ -170,6 +172,7 @@ GCT_shutdown (void);
170struct CadetTunnel * 172struct CadetTunnel *
171GCT_new (struct CadetPeer *destination); 173GCT_new (struct CadetPeer *destination);
172 174
175
173/** 176/**
174 * Tunnel is empty: destroy it. 177 * Tunnel is empty: destroy it.
175 * 178 *
@@ -180,6 +183,7 @@ GCT_new (struct CadetPeer *destination);
180void 183void
181GCT_destroy_empty (struct CadetTunnel *t); 184GCT_destroy_empty (struct CadetTunnel *t);
182 185
186
183/** 187/**
184 * Destroy tunnel if empty (no more channels). 188 * Destroy tunnel if empty (no more channels).
185 * 189 *
@@ -188,6 +192,7 @@ GCT_destroy_empty (struct CadetTunnel *t);
188void 192void
189GCT_destroy_if_empty (struct CadetTunnel *t); 193GCT_destroy_if_empty (struct CadetTunnel *t);
190 194
195
191/** 196/**
192 * Destroy the tunnel. 197 * Destroy the tunnel.
193 * 198 *
@@ -222,6 +227,7 @@ GCT_change_cstate (struct CadetTunnel* t, enum CadetTunnelCState cstate);
222void 227void
223GCT_change_estate (struct CadetTunnel* t, enum CadetTunnelEState state); 228GCT_change_estate (struct CadetTunnel* t, enum CadetTunnelEState state);
224 229
230
225/** 231/**
226 * Add a connection to a tunnel. 232 * Add a connection to a tunnel.
227 * 233 *
@@ -231,6 +237,7 @@ GCT_change_estate (struct CadetTunnel* t, enum CadetTunnelEState state);
231void 237void
232GCT_add_connection (struct CadetTunnel *t, struct CadetConnection *c); 238GCT_add_connection (struct CadetTunnel *t, struct CadetConnection *c);
233 239
240
234/** 241/**
235 * Remove a connection from a tunnel. 242 * Remove a connection from a tunnel.
236 * 243 *
@@ -240,6 +247,7 @@ GCT_add_connection (struct CadetTunnel *t, struct CadetConnection *c);
240void 247void
241GCT_remove_connection (struct CadetTunnel *t, struct CadetConnection *c); 248GCT_remove_connection (struct CadetTunnel *t, struct CadetConnection *c);
242 249
250
243/** 251/**
244 * Add a channel to a tunnel. 252 * Add a channel to a tunnel.
245 * 253 *
@@ -249,6 +257,7 @@ GCT_remove_connection (struct CadetTunnel *t, struct CadetConnection *c);
249void 257void
250GCT_add_channel (struct CadetTunnel *t, struct CadetChannel *ch); 258GCT_add_channel (struct CadetTunnel *t, struct CadetChannel *ch);
251 259
260
252/** 261/**
253 * Remove a channel from a tunnel. 262 * Remove a channel from a tunnel.
254 * 263 *
@@ -258,6 +267,7 @@ GCT_add_channel (struct CadetTunnel *t, struct CadetChannel *ch);
258void 267void
259GCT_remove_channel (struct CadetTunnel *t, struct CadetChannel *ch); 268GCT_remove_channel (struct CadetTunnel *t, struct CadetChannel *ch);
260 269
270
261/** 271/**
262 * Search for a channel by global ID. 272 * Search for a channel by global ID.
263 * 273 *
@@ -269,6 +279,7 @@ GCT_remove_channel (struct CadetTunnel *t, struct CadetChannel *ch);
269struct CadetChannel * 279struct CadetChannel *
270GCT_get_channel (struct CadetTunnel *t, CADET_ChannelNumber chid); 280GCT_get_channel (struct CadetTunnel *t, CADET_ChannelNumber chid);
271 281
282
272/** 283/**
273 * Decrypt and demultiplex by message type. Call appropriate handler 284 * Decrypt and demultiplex by message type. Call appropriate handler
274 * for a message towards a channel of a local tunnel. 285 * for a message towards a channel of a local tunnel.
@@ -291,6 +302,7 @@ void
291GCT_handle_kx (struct CadetTunnel *t, 302GCT_handle_kx (struct CadetTunnel *t,
292 const struct GNUNET_MessageHeader *message); 303 const struct GNUNET_MessageHeader *message);
293 304
305
294/** 306/**
295 * @brief Use the given path for the tunnel. 307 * @brief Use the given path for the tunnel.
296 * Update the next and prev hops (and RCs). 308 * Update the next and prev hops (and RCs).
@@ -304,6 +316,7 @@ GCT_handle_kx (struct CadetTunnel *t,
304struct CadetConnection * 316struct CadetConnection *
305GCT_use_path (struct CadetTunnel *t, struct CadetPeerPath *p); 317GCT_use_path (struct CadetTunnel *t, struct CadetPeerPath *p);
306 318
319
307/** 320/**
308 * Count all created connections of a tunnel. Not necessarily ready connections! 321 * Count all created connections of a tunnel. Not necessarily ready connections!
309 * 322 *
@@ -314,6 +327,7 @@ GCT_use_path (struct CadetTunnel *t, struct CadetPeerPath *p);
314unsigned int 327unsigned int
315GCT_count_any_connections (struct CadetTunnel *t); 328GCT_count_any_connections (struct CadetTunnel *t);
316 329
330
317/** 331/**
318 * Count established (ready) connections of a tunnel. 332 * Count established (ready) connections of a tunnel.
319 * 333 *
@@ -324,6 +338,7 @@ GCT_count_any_connections (struct CadetTunnel *t);
324unsigned int 338unsigned int
325GCT_count_connections (struct CadetTunnel *t); 339GCT_count_connections (struct CadetTunnel *t);
326 340
341
327/** 342/**
328 * Count channels of a tunnel. 343 * Count channels of a tunnel.
329 * 344 *
@@ -334,6 +349,7 @@ GCT_count_connections (struct CadetTunnel *t);
334unsigned int 349unsigned int
335GCT_count_channels (struct CadetTunnel *t); 350GCT_count_channels (struct CadetTunnel *t);
336 351
352
337/** 353/**
338 * Get the connectivity state of a tunnel. 354 * Get the connectivity state of a tunnel.
339 * 355 *
@@ -344,6 +360,7 @@ GCT_count_channels (struct CadetTunnel *t);
344enum CadetTunnelCState 360enum CadetTunnelCState
345GCT_get_cstate (struct CadetTunnel *t); 361GCT_get_cstate (struct CadetTunnel *t);
346 362
363
347/** 364/**
348 * Get the encryption state of a tunnel. 365 * Get the encryption state of a tunnel.
349 * 366 *
@@ -354,6 +371,7 @@ GCT_get_cstate (struct CadetTunnel *t);
354enum CadetTunnelEState 371enum CadetTunnelEState
355GCT_get_estate (struct CadetTunnel *t); 372GCT_get_estate (struct CadetTunnel *t);
356 373
374
357/** 375/**
358 * Get the maximum buffer space for a tunnel towards a local client. 376 * Get the maximum buffer space for a tunnel towards a local client.
359 * 377 *
@@ -364,6 +382,7 @@ GCT_get_estate (struct CadetTunnel *t);
364unsigned int 382unsigned int
365GCT_get_channels_buffer (struct CadetTunnel *t); 383GCT_get_channels_buffer (struct CadetTunnel *t);
366 384
385
367/** 386/**
368 * Get the total buffer space for a tunnel for P2P traffic. 387 * Get the total buffer space for a tunnel for P2P traffic.
369 * 388 *
@@ -374,6 +393,7 @@ GCT_get_channels_buffer (struct CadetTunnel *t);
374unsigned int 393unsigned int
375GCT_get_connections_buffer (struct CadetTunnel *t); 394GCT_get_connections_buffer (struct CadetTunnel *t);
376 395
396
377/** 397/**
378 * Get the tunnel's destination. 398 * Get the tunnel's destination.
379 * 399 *
@@ -384,6 +404,7 @@ GCT_get_connections_buffer (struct CadetTunnel *t);
384const struct GNUNET_PeerIdentity * 404const struct GNUNET_PeerIdentity *
385GCT_get_destination (struct CadetTunnel *t); 405GCT_get_destination (struct CadetTunnel *t);
386 406
407
387/** 408/**
388 * Get the tunnel's next free Channel ID. 409 * Get the tunnel's next free Channel ID.
389 * 410 *
@@ -394,6 +415,7 @@ GCT_get_destination (struct CadetTunnel *t);
394CADET_ChannelNumber 415CADET_ChannelNumber
395GCT_get_next_chid (struct CadetTunnel *t); 416GCT_get_next_chid (struct CadetTunnel *t);
396 417
418
397/** 419/**
398 * Send ACK on one or more channels due to buffer in connections. 420 * Send ACK on one or more channels due to buffer in connections.
399 * 421 *
@@ -402,6 +424,7 @@ GCT_get_next_chid (struct CadetTunnel *t);
402void 424void
403GCT_unchoke_channels (struct CadetTunnel *t); 425GCT_unchoke_channels (struct CadetTunnel *t);
404 426
427
405/** 428/**
406 * Send ACK on one or more connections due to buffer space to the client. 429 * Send ACK on one or more connections due to buffer space to the client.
407 * 430 *
@@ -412,6 +435,7 @@ GCT_unchoke_channels (struct CadetTunnel *t);
412void 435void
413GCT_send_connection_acks (struct CadetTunnel *t); 436GCT_send_connection_acks (struct CadetTunnel *t);
414 437
438
415/** 439/**
416 * Cancel a previously sent message while it's in the queue. 440 * Cancel a previously sent message while it's in the queue.
417 * 441 *
@@ -424,6 +448,7 @@ GCT_send_connection_acks (struct CadetTunnel *t);
424void 448void
425GCT_cancel (struct CadetTunnelQueue *q); 449GCT_cancel (struct CadetTunnelQueue *q);
426 450
451
427/** 452/**
428 * Sends an already built message on a tunnel, encrypting it and 453 * Sends an already built message on a tunnel, encrypting it and
429 * choosing the best connection. 454 * choosing the best connection.
@@ -442,6 +467,7 @@ GCT_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
442 struct CadetTunnel *t, struct CadetConnection *c, 467 struct CadetTunnel *t, struct CadetConnection *c,
443 int force, GCT_sent cont, void *cont_cls); 468 int force, GCT_sent cont, void *cont_cls);
444 469
470
445/** 471/**
446 * Send an Axolotl KX message. 472 * Send an Axolotl KX message.
447 * 473 *
@@ -451,6 +477,7 @@ GCT_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
451void 477void
452GCT_send_ax_kx (struct CadetTunnel *t, int force_reply); 478GCT_send_ax_kx (struct CadetTunnel *t, int force_reply);
453 479
480
454/** 481/**
455 * Sends an already built and encrypted message on a tunnel, choosing the best 482 * Sends an already built and encrypted message on a tunnel, choosing the best
456 * connection. Useful for re-queueing messages queued on a destroyed connection. 483 * connection. Useful for re-queueing messages queued on a destroyed connection.
@@ -462,6 +489,7 @@ void
462GCT_resend_message (const struct GNUNET_MessageHeader *message, 489GCT_resend_message (const struct GNUNET_MessageHeader *message,
463 struct CadetTunnel *t); 490 struct CadetTunnel *t);
464 491
492
465/** 493/**
466 * Is the tunnel directed towards the local peer? 494 * Is the tunnel directed towards the local peer?
467 * 495 *
@@ -472,6 +500,7 @@ GCT_resend_message (const struct GNUNET_MessageHeader *message,
472int 500int
473GCT_is_loopback (const struct CadetTunnel *t); 501GCT_is_loopback (const struct CadetTunnel *t);
474 502
503
475/** 504/**
476 * Is the tunnel using this path already? 505 * Is the tunnel using this path already?
477 * 506 *
@@ -483,6 +512,7 @@ GCT_is_loopback (const struct CadetTunnel *t);
483int 512int
484GCT_is_path_used (const struct CadetTunnel *t, const struct CadetPeerPath *p); 513GCT_is_path_used (const struct CadetTunnel *t, const struct CadetPeerPath *p);
485 514
515
486/** 516/**
487 * Get a cost of a path for a tunnel considering existing connections. 517 * Get a cost of a path for a tunnel considering existing connections.
488 * 518 *
@@ -495,6 +525,7 @@ unsigned int
495GCT_get_path_cost (const struct CadetTunnel *t, 525GCT_get_path_cost (const struct CadetTunnel *t,
496 const struct CadetPeerPath *path); 526 const struct CadetPeerPath *path);
497 527
528
498/** 529/**
499 * Get the static string for the peer this tunnel is directed. 530 * Get the static string for the peer this tunnel is directed.
500 * 531 *
@@ -505,6 +536,7 @@ GCT_get_path_cost (const struct CadetTunnel *t,
505const char * 536const char *
506GCT_2s (const struct CadetTunnel *t); 537GCT_2s (const struct CadetTunnel *t);
507 538
539
508/** 540/**
509 * Log all possible info about the tunnel state. 541 * Log all possible info about the tunnel state.
510 * 542 *
@@ -514,6 +546,7 @@ GCT_2s (const struct CadetTunnel *t);
514void 546void
515GCT_debug (const struct CadetTunnel *t, enum GNUNET_ErrorType level); 547GCT_debug (const struct CadetTunnel *t, enum GNUNET_ErrorType level);
516 548
549
517/** 550/**
518 * Iterate all tunnels. 551 * Iterate all tunnels.
519 * 552 *
@@ -523,6 +556,7 @@ GCT_debug (const struct CadetTunnel *t, enum GNUNET_ErrorType level);
523void 556void
524GCT_iterate_all (GNUNET_CONTAINER_PeerMapIterator iter, void *cls); 557GCT_iterate_all (GNUNET_CONTAINER_PeerMapIterator iter, void *cls);
525 558
559
526/** 560/**
527 * Count all tunnels. 561 * Count all tunnels.
528 * 562 *
@@ -531,6 +565,7 @@ GCT_iterate_all (GNUNET_CONTAINER_PeerMapIterator iter, void *cls);
531unsigned int 565unsigned int
532GCT_count_all (void); 566GCT_count_all (void);
533 567
568
534/** 569/**
535 * Iterate all connections of a tunnel. 570 * Iterate all connections of a tunnel.
536 * 571 *
@@ -541,6 +576,7 @@ GCT_count_all (void);
541void 576void
542GCT_iterate_connections (struct CadetTunnel *t, GCT_conn_iter iter, void *cls); 577GCT_iterate_connections (struct CadetTunnel *t, GCT_conn_iter iter, void *cls);
543 578
579
544/** 580/**
545 * Iterate all channels of a tunnel. 581 * Iterate all channels of a tunnel.
546 * 582 *
@@ -549,7 +585,10 @@ GCT_iterate_connections (struct CadetTunnel *t, GCT_conn_iter iter, void *cls);
549 * @param cls Closure for @c iter. 585 * @param cls Closure for @c iter.
550 */ 586 */
551void 587void
552GCT_iterate_channels (struct CadetTunnel *t, GCT_chan_iter iter, void *cls); 588GCT_iterate_channels (struct CadetTunnel *t,
589 GCT_chan_iter iter,
590 void *cls);
591
553 592
554#if 0 /* keep Emacsens' auto-indent happy */ 593#if 0 /* keep Emacsens' auto-indent happy */
555{ 594{