aboutsummaryrefslogtreecommitdiff
path: root/src/cadet
diff options
context:
space:
mode:
authorBart Polot <bart@net.in.tum.de>2015-10-06 12:03:14 +0000
committerBart Polot <bart@net.in.tum.de>2015-10-06 12:03:14 +0000
commit79f53fe65e00a29889b290fca9c9390101ea537e (patch)
treee169fc09e181acc9d73cc51f224bbbc3898564cf /src/cadet
parentc3c8597a4ce377b7825e4a526b7de1daeba2105d (diff)
downloadgnunet-79f53fe65e00a29889b290fca9c9390101ea537e.tar.gz
gnunet-79f53fe65e00a29889b290fca9c9390101ea537e.zip
- Revamp traffic logging, small bugfixes, complete doxygen
Diffstat (limited to 'src/cadet')
-rw-r--r--src/cadet/cadet_common.c14
-rw-r--r--src/cadet/gnunet-service-cadet_channel.c120
-rw-r--r--src/cadet/gnunet-service-cadet_connection.c66
-rw-r--r--src/cadet/gnunet-service-cadet_peer.c10
-rw-r--r--src/cadet/gnunet-service-cadet_peer.h22
-rw-r--r--src/cadet/gnunet-service-cadet_tunnel.c30
6 files changed, 187 insertions, 75 deletions
diff --git a/src/cadet/cadet_common.c b/src/cadet/cadet_common.c
index 360fbcee6..b985f02ed 100644
--- a/src/cadet/cadet_common.c
+++ b/src/cadet/cadet_common.c
@@ -47,7 +47,7 @@ GC_f2s (int fwd)
47 else 47 else
48 { 48 {
49 /* Not an error, can happen with CONNECTION_BROKEN messages. */ 49 /* Not an error, can happen with CONNECTION_BROKEN messages. */
50 return ""; 50 return "\???";
51 } 51 }
52} 52}
53 53
@@ -146,7 +146,7 @@ GC_m2s (uint16_t m)
146 * Used to mark the "payload" of a non-payload message. 146 * Used to mark the "payload" of a non-payload message.
147 */ 147 */
148 case 0: 148 case 0:
149 s = "retrnsmit"; 149 s = "retransmit";
150 break; 150 break;
151 151
152 /** 152 /**
@@ -380,8 +380,16 @@ GC_m2s (uint16_t m)
380 s = "INFO_DUMP"; 380 s = "INFO_DUMP";
381 break; 381 break;
382 382
383 /**
384 * Used to mark the "payload" of a non-payload message.
385 */
386 case UINT16_MAX:
387 s = " N/A";
388 break;
389
390
383 default: 391 default:
384 SPRINTF (buf[idx], "%u (UNKNOWN)", m); 392 SPRINTF (buf[idx], "{UNK: %5u}", m);
385 return buf[idx]; 393 return buf[idx];
386 } 394 }
387 SPRINTF (buf[idx], "{%10s}", s); 395 SPRINTF (buf[idx], "{%10s}", s);
diff --git a/src/cadet/gnunet-service-cadet_channel.c b/src/cadet/gnunet-service-cadet_channel.c
index 367a34e5d..d7fe82d20 100644
--- a/src/cadet/gnunet-service-cadet_channel.c
+++ b/src/cadet/gnunet-service-cadet_channel.c
@@ -1041,7 +1041,7 @@ channel_rel_free_sent (struct CadetChannelReliability *rel,
1041 1041
1042 bitfield = msg->futures; 1042 bitfield = msg->futures;
1043 mid = ntohl (msg->mid); 1043 mid = ntohl (msg->mid);
1044 LOG (GNUNET_ERROR_TYPE_DEBUG, "free_sent_reliable %u %llX\n", mid, bitfield); 1044 LOG (GNUNET_ERROR_TYPE_DEBUG, "free_sent_reliable %u %lX\n", mid, bitfield);
1045 LOG (GNUNET_ERROR_TYPE_DEBUG, " rel %p, head %p\n", rel, rel->head_sent); 1045 LOG (GNUNET_ERROR_TYPE_DEBUG, " rel %p, head %p\n", rel, rel->head_sent);
1046 for (i = 0, r = 0, copy = rel->head_sent; 1046 for (i = 0, r = 0, copy = rel->head_sent;
1047 i < 64 && NULL != copy && 0 != bitfield; 1047 i < 64 && NULL != copy && 0 != bitfield;
@@ -1561,11 +1561,9 @@ GCCH_send_data_ack (struct CadetChannel *ch, int fwd)
1561 mask = 0x1LL << delta; 1561 mask = 0x1LL << delta;
1562 msg.futures |= mask; 1562 msg.futures |= mask;
1563 LOG (GNUNET_ERROR_TYPE_DEBUG, 1563 LOG (GNUNET_ERROR_TYPE_DEBUG,
1564 " setting bit for %u (delta %u) (%llX) -> %llX\n", 1564 " setting bit for %u (delta %u) (%lX) -> %lX\n",
1565 copy->mid, delta, mask, msg.futures); 1565 copy->mid, delta, mask, msg.futures);
1566 } 1566 }
1567 LOG (GNUNET_ERROR_TYPE_INFO, "===> DATA_ACK for %u + %llX\n",
1568 ack, msg.futures);
1569 1567
1570 GCCH_send_prebuilt_message (&msg.header, ch, !fwd, NULL); 1568 GCCH_send_prebuilt_message (&msg.header, ch, !fwd, NULL);
1571 LOG (GNUNET_ERROR_TYPE_DEBUG, "send_data_ack END\n"); 1569 LOG (GNUNET_ERROR_TYPE_DEBUG, "send_data_ack END\n");
@@ -1859,7 +1857,7 @@ GCCH_handle_local_create (struct CadetClient *c,
1859 CADET_ChannelNumber chid; 1857 CADET_ChannelNumber chid;
1860 1858
1861 LOG (GNUNET_ERROR_TYPE_DEBUG, " towards %s:%u\n", 1859 LOG (GNUNET_ERROR_TYPE_DEBUG, " towards %s:%u\n",
1862 GNUNET_i2s (&msg->peer), ntohl (msg->port)); 1860 GNUNET_i2s (&msg->peer), ntohl (msg->port));
1863 chid = ntohl (msg->channel_id); 1861 chid = ntohl (msg->channel_id);
1864 1862
1865 /* Sanity check for duplicate channel IDs */ 1863 /* Sanity check for duplicate channel IDs */
@@ -1924,7 +1922,10 @@ GCCH_handle_data (struct CadetChannel *ch,
1924{ 1922{
1925 struct CadetChannelReliability *rel; 1923 struct CadetChannelReliability *rel;
1926 struct CadetClient *c; 1924 struct CadetClient *c;
1925 struct GNUNET_MessageHeader *payload_msg;
1927 uint32_t mid; 1926 uint32_t mid;
1927 uint16_t payload_type;
1928 uint16_t payload_size;
1928 1929
1929 /* If this is a remote (non-loopback) channel, find 'fwd'. */ 1930 /* If this is a remote (non-loopback) channel, find 'fwd'. */
1930 if (GNUNET_SYSERR == fwd) 1931 if (GNUNET_SYSERR == fwd)
@@ -1965,18 +1966,22 @@ GCCH_handle_data (struct CadetChannel *ch,
1965 channel_confirm (ch, GNUNET_NO); 1966 channel_confirm (ch, GNUNET_NO);
1966 } 1967 }
1967 1968
1968 GNUNET_STATISTICS_update (stats, "# data received", 1, GNUNET_NO); 1969 payload_msg = (struct GNUNET_MessageHeader *) &msg[1];
1970 payload_type = ntohs (payload_msg->type);
1971 payload_size = ntohs (payload_msg->size);
1972
1973 GNUNET_STATISTICS_update (stats, "# messages received", 1, GNUNET_NO);
1974 GNUNET_STATISTICS_update (stats, "# bytes received", payload_size, GNUNET_NO);
1969 1975
1970 mid = ntohl (msg->mid); 1976 mid = ntohl (msg->mid);
1971 LOG (GNUNET_ERROR_TYPE_INFO, "<=== DATA %u %s on channel %s\n", 1977 LOG (GNUNET_ERROR_TYPE_INFO, "<== %s (%s %4u) on chan %s (%p) %s [%5u]\n",
1972 mid, GC_f2s (fwd), GCCH_2s (ch)); 1978 GC_m2s (GNUNET_MESSAGE_TYPE_CADET_DATA), GC_m2s (payload_type), mid,
1979 GCCH_2s (ch), ch, GC_f2s (fwd), ntohs (msg->header.size));
1973 1980
1974 if (GNUNET_NO == ch->reliable || 1981 if (GNUNET_NO == ch->reliable ||
1975 ( !GC_is_pid_bigger (rel->mid_recv, mid) && 1982 ( !GC_is_pid_bigger (rel->mid_recv, mid) &&
1976 GC_is_pid_bigger (rel->mid_recv + 64, mid) ) ) 1983 GC_is_pid_bigger (rel->mid_recv + 64, mid) ) )
1977 { 1984 {
1978 LOG (GNUNET_ERROR_TYPE_DEBUG, "RECV MID %u (%u)\n",
1979 mid, ntohs (msg->header.size));
1980 if (GNUNET_YES == ch->reliable) 1985 if (GNUNET_YES == ch->reliable)
1981 { 1986 {
1982 /* Is this the exact next expected messasge? */ 1987 /* Is this the exact next expected messasge? */
@@ -2063,8 +2068,10 @@ GCCH_handle_data_ack (struct CadetChannel *ch,
2063 } 2068 }
2064 2069
2065 ack = ntohl (msg->mid); 2070 ack = ntohl (msg->mid);
2066 LOG (GNUNET_ERROR_TYPE_INFO, "<=== %s ACK %u + %llX\n", 2071 LOG (GNUNET_ERROR_TYPE_INFO,
2067 GC_f2s (fwd), ack, msg->futures); 2072 "<== %s (0x%010lX %4u) on chan %s (%p) %s [%5u]\n",
2073 GC_m2s (GNUNET_MESSAGE_TYPE_CADET_DATA_ACK), msg->futures, ack,
2074 GCCH_2s (ch), ch, GC_f2s (fwd), ntohs (msg->header.size));
2068 2075
2069 if (GNUNET_YES == fwd) 2076 if (GNUNET_YES == fwd)
2070 rel = ch->root_rel; 2077 rel = ch->root_rel;
@@ -2151,8 +2158,10 @@ GCCH_handle_create (struct CadetTunnel *t,
2151 struct CadetChannel *ch; 2158 struct CadetChannel *ch;
2152 struct CadetClient *c; 2159 struct CadetClient *c;
2153 int new_channel; 2160 int new_channel;
2161 uint32_t port;
2154 2162
2155 chid = ntohl (msg->chid); 2163 chid = ntohl (msg->chid);
2164
2156 ch = GCT_get_channel (t, chid); 2165 ch = GCT_get_channel (t, chid);
2157 if (NULL == ch) 2166 if (NULL == ch)
2158 { 2167 {
@@ -2166,11 +2175,17 @@ GCCH_handle_create (struct CadetTunnel *t,
2166 { 2175 {
2167 new_channel = GNUNET_NO; 2176 new_channel = GNUNET_NO;
2168 } 2177 }
2178 port = ntohl (msg->port);
2179
2180 LOG (GNUNET_ERROR_TYPE_INFO,
2181 "<== %s ( 0x%08X %4u) on chan %s (%p) %s [%5u]\n",
2182 GC_m2s (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE), chid, port,
2183 GCCH_2s (ch), ch, GC_f2s (GNUNET_YES), ntohs (msg->header.size));
2169 2184
2170 if (GNUNET_YES == new_channel || GCT_is_loopback (t)) 2185 if (GNUNET_YES == new_channel || GCT_is_loopback (t))
2171 { 2186 {
2172 /* Find a destination client */ 2187 /* Find a destination client */
2173 ch->port = ntohl (msg->port); 2188 ch->port = port;
2174 LOG (GNUNET_ERROR_TYPE_DEBUG, " port %u\n", ch->port); 2189 LOG (GNUNET_ERROR_TYPE_DEBUG, " port %u\n", ch->port);
2175 c = GML_client_get_by_port (ch->port); 2190 c = GML_client_get_by_port (ch->port);
2176 if (NULL == c) 2191 if (NULL == c)
@@ -2235,6 +2250,11 @@ GCCH_handle_create (struct CadetTunnel *t,
2235void 2250void
2236GCCH_handle_nack (struct CadetChannel *ch) 2251GCCH_handle_nack (struct CadetChannel *ch)
2237{ 2252{
2253 LOG (GNUNET_ERROR_TYPE_INFO,
2254 "<== %s ( 0x%08X %4u) on chan %s (%p) %s [%5u]\n",
2255 GC_m2s (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_NACK), ch->gid, 0,
2256 GCCH_2s (ch), ch, "---", 0);
2257
2238 send_client_nack (ch); 2258 send_client_nack (ch);
2239 GCCH_destroy (ch); 2259 GCCH_destroy (ch);
2240} 2260}
@@ -2255,6 +2275,11 @@ GCCH_handle_ack (struct CadetChannel *ch,
2255 const struct GNUNET_CADET_ChannelManage *msg, 2275 const struct GNUNET_CADET_ChannelManage *msg,
2256 int fwd) 2276 int fwd)
2257{ 2277{
2278 LOG (GNUNET_ERROR_TYPE_INFO,
2279 "<== %s ( 0x%08X %4u) on chan %s (%p) %s [%5u]\n",
2280 GC_m2s (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_ACK), ch->gid, 0,
2281 GCCH_2s (ch), ch, GC_f2s (fwd), ntohs (msg->header.size));
2282
2258 /* If this is a remote (non-loopback) channel, find 'fwd'. */ 2283 /* If this is a remote (non-loopback) channel, find 'fwd'. */
2259 if (GNUNET_SYSERR == fwd) 2284 if (GNUNET_SYSERR == fwd)
2260 { 2285 {
@@ -2288,6 +2313,11 @@ GCCH_handle_destroy (struct CadetChannel *ch,
2288{ 2313{
2289 struct CadetChannelReliability *rel; 2314 struct CadetChannelReliability *rel;
2290 2315
2316 LOG (GNUNET_ERROR_TYPE_INFO,
2317 "<== %s ( 0x%08X %4u) on chan %s (%p) %s [%5u]\n",
2318 GC_m2s (GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY), ch->gid, 0,
2319 GCCH_2s (ch), ch, GC_f2s (fwd), ntohs (msg->header.size));
2320
2291 /* If this is a remote (non-loopback) channel, find 'fwd'. */ 2321 /* If this is a remote (non-loopback) channel, find 'fwd'. */
2292 if (GNUNET_SYSERR == fwd) 2322 if (GNUNET_SYSERR == fwd)
2293 { 2323 {
@@ -2342,11 +2372,64 @@ GCCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
2342 void *existing_copy) 2372 void *existing_copy)
2343{ 2373{
2344 struct CadetChannelQueue *chq; 2374 struct CadetChannelQueue *chq;
2375 uint32_t data_id;
2345 uint16_t type; 2376 uint16_t type;
2377 uint16_t size;
2378 char info[32];
2346 2379
2347 type = ntohs (message->type); 2380 type = ntohs (message->type);
2348 LOG (GNUNET_ERROR_TYPE_INFO, "===> %s %s on channel %s\n", 2381 size = ntohs (message->size);
2349 GC_m2s (type), GC_f2s (fwd), GCCH_2s (ch)); 2382
2383 switch (type)
2384 {
2385 case GNUNET_MESSAGE_TYPE_CADET_DATA:
2386 {
2387 struct GNUNET_CADET_Data *data_msg;
2388 struct GNUNET_MessageHeader *payload_msg;
2389 uint16_t payload_type;
2390
2391 data_msg = (struct GNUNET_CADET_Data *) message;
2392 data_id = ntohl (data_msg->mid);
2393 payload_msg = (struct GNUNET_MessageHeader *) &data_msg[1];
2394 payload_type = ntohs (payload_msg->type);
2395 strncpy (info, GC_m2s (payload_type), 31);
2396 info[31] = '\0';
2397 break;
2398 }
2399 case GNUNET_MESSAGE_TYPE_CADET_DATA_ACK:
2400 {
2401 struct GNUNET_CADET_DataACK *ack_msg;
2402 ack_msg = (struct GNUNET_CADET_DataACK *) message;
2403 data_id = ntohl (ack_msg->mid);
2404 SPRINTF (info, "0x%010lX", ack_msg->futures);
2405 break;
2406 }
2407 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_CREATE:
2408 {
2409 struct GNUNET_CADET_ChannelCreate *cc_msg;
2410 cc_msg = (struct GNUNET_CADET_ChannelCreate *) message;
2411 data_id = ntohl (cc_msg->port);
2412 SPRINTF (info, " 0x%08X", ntohl (cc_msg->chid));
2413 break;
2414 }
2415 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_ACK:
2416 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_NACK:
2417 case GNUNET_MESSAGE_TYPE_CADET_CHANNEL_DESTROY:
2418 {
2419 struct GNUNET_CADET_ChannelManage *m_msg;
2420 m_msg = (struct GNUNET_CADET_ChannelManage *) message;
2421 data_id = 0;
2422 SPRINTF (info, " 0x%08X", ntohl (m_msg->chid));
2423 break;
2424 }
2425 default:
2426 data_id = 0;
2427 info[0] = '\0';
2428 }
2429 LOG (GNUNET_ERROR_TYPE_INFO,
2430 "==> %s (%12s %4u) on chan %s (%p) %s [%5u]\n",
2431 GC_m2s (type), info, data_id,
2432 GCCH_2s (ch), ch, GC_f2s (fwd), size);
2350 2433
2351 if (GCT_is_loopback (ch->t)) 2434 if (GCT_is_loopback (ch->t))
2352 { 2435 {
@@ -2356,12 +2439,7 @@ GCCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
2356 2439
2357 switch (type) 2440 switch (type)
2358 { 2441 {
2359 struct GNUNET_CADET_Data *payload;
2360 case GNUNET_MESSAGE_TYPE_CADET_DATA: 2442 case GNUNET_MESSAGE_TYPE_CADET_DATA:
2361
2362 payload = (struct GNUNET_CADET_Data *) message;
2363 LOG (GNUNET_ERROR_TYPE_INFO, "===> %s %u\n",
2364 GC_m2s (type), ntohl (payload->mid));
2365 if (GNUNET_YES == ch->reliable) 2443 if (GNUNET_YES == ch->reliable)
2366 { 2444 {
2367 chq = GNUNET_new (struct CadetChannelQueue); 2445 chq = GNUNET_new (struct CadetChannelQueue);
@@ -2450,7 +2528,7 @@ GCCH_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
2450 2528
2451 default: 2529 default:
2452 GNUNET_break (0); 2530 GNUNET_break (0);
2453 LOG (GNUNET_ERROR_TYPE_DEBUG, "type %s unknown!\n", GC_m2s (type)); 2531 LOG (GNUNET_ERROR_TYPE_WARNING, "type %s unknown!\n", GC_m2s (type));
2454 fire_and_forget (message, ch, GNUNET_YES); 2532 fire_and_forget (message, ch, GNUNET_YES);
2455 } 2533 }
2456} 2534}
diff --git a/src/cadet/gnunet-service-cadet_connection.c b/src/cadet/gnunet-service-cadet_connection.c
index 2ba39236a..8b7ff9d8b 100644
--- a/src/cadet/gnunet-service-cadet_connection.c
+++ b/src/cadet/gnunet-service-cadet_connection.c
@@ -589,8 +589,8 @@ send_ack (struct CadetConnection *c, unsigned int buffer, int fwd, int force)
589 msg.ack = htonl (ack); 589 msg.ack = htonl (ack);
590 msg.cid = c->id; 590 msg.cid = c->id;
591 591
592 prev_fc->ack_msg = GCC_send_prebuilt_message (&msg.header, 0, ack, c, 592 prev_fc->ack_msg = GCC_send_prebuilt_message (&msg.header, UINT16_MAX, ack,
593 !fwd, GNUNET_YES, 593 c, !fwd, GNUNET_YES,
594 &ack_sent, prev_fc); 594 &ack_sent, prev_fc);
595 GNUNET_assert (NULL != prev_fc->ack_msg); 595 GNUNET_assert (NULL != prev_fc->ack_msg);
596 GCC_check_connections (); 596 GCC_check_connections ();
@@ -966,15 +966,16 @@ static void
966send_connection_ack (struct CadetConnection *connection, int fwd) 966send_connection_ack (struct CadetConnection *connection, int fwd)
967{ 967{
968 struct CadetTunnel *t; 968 struct CadetTunnel *t;
969 size_t size = sizeof (struct GNUNET_CADET_ConnectionACK);
969 970
970 GCC_check_connections (); 971 GCC_check_connections ();
971 t = connection->t; 972 t = connection->t;
972 LOG (GNUNET_ERROR_TYPE_INFO, "--> {%14s ACK} on conn %s\n", 973 LOG (GNUNET_ERROR_TYPE_INFO,
973 GC_f2s (!fwd), GCC_2s (connection)); 974 "==> { C %s ACK} %19s on conn %s (%p) %s [%5u]\n",
975 GC_f2s (!fwd), "", GCC_2s (connection), connection, GC_f2s (fwd), size);
974 GCP_queue_add (get_hop (connection, fwd), NULL, 976 GCP_queue_add (get_hop (connection, fwd), NULL,
975 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK, 0, 0, 977 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK, UINT16_MAX, 0,
976 sizeof (struct GNUNET_CADET_ConnectionACK), 978 size, connection, fwd, &conn_message_sent, NULL);
977 connection, fwd, &conn_message_sent, NULL);
978 connection->pending_messages++; 979 connection->pending_messages++;
979 if (CADET_TUNNEL_NEW == GCT_get_cstate (t)) 980 if (CADET_TUNNEL_NEW == GCT_get_cstate (t))
980 GCT_change_cstate (t, CADET_TUNNEL_WAITING); 981 GCT_change_cstate (t, CADET_TUNNEL_WAITING);
@@ -1007,7 +1008,7 @@ send_broken (struct CadetConnection *c,
1007 msg.peer1 = *id1; 1008 msg.peer1 = *id1;
1008 msg.peer2 = *id2; 1009 msg.peer2 = *id2;
1009 GNUNET_assert (NULL == 1010 GNUNET_assert (NULL ==
1010 GCC_send_prebuilt_message (&msg.header, 0, 0, c, fwd, 1011 GCC_send_prebuilt_message (&msg.header, UINT16_MAX, 0, c, fwd,
1011 GNUNET_YES, NULL, NULL)); 1012 GNUNET_YES, NULL, NULL));
1012 GCC_check_connections (); 1013 GCC_check_connections ();
1013} 1014}
@@ -1047,7 +1048,7 @@ send_broken_unknown (const struct GNUNET_CADET_Hash *connection_id,
1047 neighbor = GCP_get (peer_id, GNUNET_NO); /* We MUST know neighbor. */ 1048 neighbor = GCP_get (peer_id, GNUNET_NO); /* We MUST know neighbor. */
1048 GNUNET_assert (NULL != neighbor); 1049 GNUNET_assert (NULL != neighbor);
1049 GCP_queue_add (neighbor, msg, GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN, 1050 GCP_queue_add (neighbor, msg, GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN,
1050 0, 2, sizeof (struct GNUNET_CADET_ConnectionBroken), 1051 UINT16_MAX, 2, sizeof (struct GNUNET_CADET_ConnectionBroken),
1051 NULL, GNUNET_SYSERR, /* connection, fwd */ 1052 NULL, GNUNET_SYSERR, /* connection, fwd */
1052 NULL, NULL); /* continuation */ 1053 NULL, NULL); /* continuation */
1053 GCC_check_connections (); 1054 GCC_check_connections ();
@@ -1445,7 +1446,7 @@ connection_poll (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1445 msg.pid = htonl (fc->last_pid_sent); 1446 msg.pid = htonl (fc->last_pid_sent);
1446 LOG (GNUNET_ERROR_TYPE_DEBUG, " last pid sent: %u\n", fc->last_pid_sent); 1447 LOG (GNUNET_ERROR_TYPE_DEBUG, " last pid sent: %u\n", fc->last_pid_sent);
1447 fc->poll_msg = 1448 fc->poll_msg =
1448 GCC_send_prebuilt_message (&msg.header, 0, fc->last_pid_sent, c, 1449 GCC_send_prebuilt_message (&msg.header, UINT16_MAX, fc->last_pid_sent, c,
1449 fc == &c->fwd_fc, GNUNET_YES, &poll_sent, fc); 1450 fc == &c->fwd_fc, GNUNET_YES, &poll_sent, fc);
1450 GNUNET_assert (NULL != fc->poll_msg); 1451 GNUNET_assert (NULL != fc->poll_msg);
1451 GCC_check_connections (); 1452 GCC_check_connections ();
@@ -1912,12 +1913,24 @@ log_message (const struct GNUNET_MessageHeader *message,
1912 const struct GNUNET_CADET_Hash *hash) 1913 const struct GNUNET_CADET_Hash *hash)
1913{ 1914{
1914 uint16_t size; 1915 uint16_t size;
1916 uint16_t type;
1917 char *arrow;
1915 1918
1916 size = ntohs (message->size); 1919 size = ntohs (message->size);
1917 LOG (GNUNET_ERROR_TYPE_INFO, "\n"); 1920 type = ntohs (message->type);
1918 LOG (GNUNET_ERROR_TYPE_INFO, "\n"); 1921 switch (type)
1919 LOG (GNUNET_ERROR_TYPE_INFO, "<-- %s on conn %s from %s, %6u bytes\n", 1922 {
1920 GC_m2s (ntohs (message->type)), GNUNET_h2s (GC_h2hc (hash)), 1923 case GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE:
1924 case GNUNET_MESSAGE_TYPE_CADET_CONNECTION_ACK:
1925 case GNUNET_MESSAGE_TYPE_CADET_CONNECTION_BROKEN:
1926 case GNUNET_MESSAGE_TYPE_CADET_CONNECTION_DESTROY:
1927 arrow = "==";
1928 break;
1929 default:
1930 arrow = "--";
1931 }
1932 LOG (GNUNET_ERROR_TYPE_INFO, "<%s %s on conn %s from %s, %6u bytes\n",
1933 arrow, GC_m2s (type), GNUNET_h2s (GC_h2hc (hash)),
1921 GNUNET_i2s (peer), (unsigned int) size); 1934 GNUNET_i2s (peer), (unsigned int) size);
1922} 1935}
1923 1936
@@ -2338,8 +2351,7 @@ GCC_handle_destroy (void *cls,
2338 } 2351 }
2339 else if (0 == c->pending_messages) 2352 else if (0 == c->pending_messages)
2340 { 2353 {
2341 LOG (GNUNET_ERROR_TYPE_DEBUG, 2354 LOG (GNUNET_ERROR_TYPE_DEBUG, " directly destroying connection!\n");
2342 " directly destroying connection!\n");
2343 GCC_destroy (c); 2355 GCC_destroy (c);
2344 GCC_check_connections (); 2356 GCC_check_connections ();
2345 return GNUNET_OK; 2357 return GNUNET_OK;
@@ -3456,7 +3468,7 @@ GCC_send_prebuilt_message (const struct GNUNET_MessageHeader *message,
3456 memcpy (data, message, size); 3468 memcpy (data, message, size);
3457 type = ntohs (message->type); 3469 type = ntohs (message->type);
3458 LOG (GNUNET_ERROR_TYPE_INFO, 3470 LOG (GNUNET_ERROR_TYPE_INFO,
3459 "--> %s (%s %4u) on conn %s (%p) %s (%u bytes)\n", 3471 "--> %s (%s %4u) on conn %s (%p) %s [%5u]\n",
3460 GC_m2s (type), GC_m2s (payload_type), payload_id, GCC_2s (c), c, 3472 GC_m2s (type), GC_m2s (payload_type), payload_id, GCC_2s (c), c,
3461 GC_f2s(fwd), size); 3473 GC_f2s(fwd), size);
3462 3474
@@ -3620,16 +3632,16 @@ GCC_send_create (struct CadetConnection *connection)
3620 size = sizeof (struct GNUNET_CADET_ConnectionCreate); 3632 size = sizeof (struct GNUNET_CADET_ConnectionCreate);
3621 size += connection->path->length * sizeof (struct GNUNET_PeerIdentity); 3633 size += connection->path->length * sizeof (struct GNUNET_PeerIdentity);
3622 3634
3623 LOG (GNUNET_ERROR_TYPE_INFO, "--> %s on conn %s (%u bytes)\n", 3635 LOG (GNUNET_ERROR_TYPE_INFO, "==> %s %19s on conn %s (%p) FWD [%5u]\n",
3624 GC_m2s (GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE), 3636 GC_m2s (GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE), "",
3625 GCC_2s (connection), size); 3637 GCC_2s (connection), connection, size);
3626 LOG (GNUNET_ERROR_TYPE_DEBUG, " C_P+ %p %u (create)\n", 3638 LOG (GNUNET_ERROR_TYPE_DEBUG, " C_P+ %p %u (create)\n",
3627 connection, connection->pending_messages); 3639 connection, connection->pending_messages);
3628 connection->pending_messages++; 3640 connection->pending_messages++;
3629 3641
3630 connection->maintenance_q = 3642 connection->maintenance_q =
3631 GCP_queue_add (get_next_hop (connection), NULL, 3643 GCP_queue_add (get_next_hop (connection), NULL,
3632 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE, 0, 0, 3644 GNUNET_MESSAGE_TYPE_CADET_CONNECTION_CREATE, UINT16_MAX, 0,
3633 size, connection, GNUNET_YES, &conn_message_sent, NULL); 3645 size, connection, GNUNET_YES, &conn_message_sent, NULL);
3634 3646
3635 state = GCT_get_cstate (connection->t); 3647 state = GCT_get_cstate (connection->t);
@@ -3666,13 +3678,13 @@ GCC_send_destroy (struct CadetConnection *c)
3666 GCC_2s (c)); 3678 GCC_2s (c));
3667 3679
3668 if (GNUNET_NO == GCC_is_terminal (c, GNUNET_YES)) 3680 if (GNUNET_NO == GCC_is_terminal (c, GNUNET_YES))
3669 GNUNET_assert (NULL == GCC_send_prebuilt_message (&msg.header, 0, 0, c, 3681 GNUNET_assert (NULL == GCC_send_prebuilt_message (&msg.header, UINT16_MAX,
3670 GNUNET_YES, GNUNET_YES, 3682 0, c, GNUNET_YES,
3671 NULL, NULL)); 3683 GNUNET_YES, NULL, NULL));
3672 if (GNUNET_NO == GCC_is_terminal (c, GNUNET_NO)) 3684 if (GNUNET_NO == GCC_is_terminal (c, GNUNET_NO))
3673 GNUNET_assert (NULL == GCC_send_prebuilt_message (&msg.header, 0, 0, c, 3685 GNUNET_assert (NULL == GCC_send_prebuilt_message (&msg.header, UINT16_MAX,
3674 GNUNET_NO, GNUNET_YES, 3686 0, c, GNUNET_NO,
3675 NULL, NULL)); 3687 GNUNET_YES, NULL, NULL));
3676 c->destroy = GNUNET_YES; 3688 c->destroy = GNUNET_YES;
3677 c->state = CADET_CONNECTION_DESTROYED; 3689 c->state = CADET_CONNECTION_DESTROYED;
3678 GCC_check_connections (); 3690 GCC_check_connections ();
diff --git a/src/cadet/gnunet-service-cadet_peer.c b/src/cadet/gnunet-service-cadet_peer.c
index 891d32e39..f3161383a 100644
--- a/src/cadet/gnunet-service-cadet_peer.c
+++ b/src/cadet/gnunet-service-cadet_peer.c
@@ -1219,7 +1219,7 @@ queue_send (void *cls, size_t size, void *buf)
1219 wait_s = GNUNET_STRINGS_relative_time_to_string (core_wait_time, GNUNET_YES); 1219 wait_s = GNUNET_STRINGS_relative_time_to_string (core_wait_time, GNUNET_YES);
1220 if (core_wait_time.rel_value_us >= 1000000) 1220 if (core_wait_time.rel_value_us >= 1000000)
1221 { 1221 {
1222 LOG (GNUNET_ERROR_TYPE_ERROR, 1222 LOG (GNUNET_ERROR_TYPE_WARNING,
1223 " %s: core wait time %s (> 1 second) for %u bytes\n", 1223 " %s: core wait time %s (> 1 second) for %u bytes\n",
1224 GCP_2s (peer), wait_s, queue->size); 1224 GCP_2s (peer), wait_s, queue->size);
1225 } 1225 }
@@ -1248,7 +1248,7 @@ queue_send (void *cls, size_t size, void *buf)
1248 else 1248 else
1249 { 1249 {
1250 LOG (GNUNET_ERROR_TYPE_INFO, 1250 LOG (GNUNET_ERROR_TYPE_INFO,
1251 ">>> %s (%s %4u) on conn %s (%p) %s (%u bytes), after %s\n", 1251 ">>> %s (%s %4u) on conn %s (%p) %s [%5u], after %s\n",
1252 GC_m2s (queue->type), GC_m2s (queue->payload_type), 1252 GC_m2s (queue->type), GC_m2s (queue->payload_type),
1253 queue->payload_id, GCC_2s (c), c, 1253 queue->payload_id, GCC_2s (c), c,
1254 GC_f2s (queue->fwd), msg_size, wait_s); 1254 GC_f2s (queue->fwd), msg_size, wait_s);
@@ -1401,7 +1401,11 @@ GCP_queue_destroy (struct CadetPeerQueue *queue,
1401 * @param peer Peer towards which to queue the message. 1401 * @param peer Peer towards which to queue the message.
1402 * @param cls Closure (@c type dependant). It will be used by queue_send to 1402 * @param cls Closure (@c type dependant). It will be used by queue_send to
1403 * build the message to be sent if not already prebuilt. 1403 * build the message to be sent if not already prebuilt.
1404 * @param type Type of the message, 0 for a raw message. 1404 * @param type Type of the message.
1405 * @param payload_type Type of the message's payload
1406 * 0 if the message is a retransmission (unknown payload).
1407 * UINT16_MAX if the message does not have payload.
1408 * @param payload_id ID of the payload (MID, ACK #, etc)
1405 * @param size Size of the message. 1409 * @param size Size of the message.
1406 * @param c Connection this message belongs to (can be NULL). 1410 * @param c Connection this message belongs to (can be NULL).
1407 * @param fwd Is this a message going root->dest? (FWD ACK are NOT FWD!) 1411 * @param fwd Is this a message going root->dest? (FWD ACK are NOT FWD!)
diff --git a/src/cadet/gnunet-service-cadet_peer.h b/src/cadet/gnunet-service-cadet_peer.h
index 65704f9c4..c053820ff 100644
--- a/src/cadet/gnunet-service-cadet_peer.h
+++ b/src/cadet/gnunet-service-cadet_peer.h
@@ -170,9 +170,13 @@ GCP_queue_destroy (struct CadetPeerQueue *queue, int clear_cls,
170 * @param peer Peer towards which to queue the message. 170 * @param peer Peer towards which to queue the message.
171 * @param cls Closure (@c type dependant). It will be used by queue_send to 171 * @param cls Closure (@c type dependant). It will be used by queue_send to
172 * build the message to be sent if not already prebuilt. 172 * build the message to be sent if not already prebuilt.
173 * @param type Type of the message, 0 for a raw message. 173 * @param type Type of the message.
174 * @param payload_type Type of the message's payload
175 * 0 if the message is a retransmission (unknown payload).
176 * UINT16_MAX if the message does not have payload.
177 * @param payload_id ID of the payload (MID, ACK #, etc)
174 * @param size Size of the message. 178 * @param size Size of the message.
175 * @param c Connection this message belongs to (cannot be NULL). 179 * @param c Connection this message belongs to (can be NULL).
176 * @param fwd Is this a message going root->dest? (FWD ACK are NOT FWD!) 180 * @param fwd Is this a message going root->dest? (FWD ACK are NOT FWD!)
177 * @param cont Continuation to be called once CORE has taken the message. 181 * @param cont Continuation to be called once CORE has taken the message.
178 * @param cont_cls Closure for @c cont. 182 * @param cont_cls Closure for @c cont.
@@ -181,10 +185,16 @@ GCP_queue_destroy (struct CadetPeerQueue *queue, int clear_cls,
181 * message has been sent and therefore the handle is no longer valid. 185 * message has been sent and therefore the handle is no longer valid.
182 */ 186 */
183struct CadetPeerQueue * 187struct CadetPeerQueue *
184GCP_queue_add (struct CadetPeer *peer, void *cls, uint16_t type, 188GCP_queue_add (struct CadetPeer *peer,
185 uint16_t payload_type, uint32_t payload_id, 189 void *cls,
186 size_t size, struct CadetConnection *c, int fwd, 190 uint16_t type,
187 GCP_sent cont, void *cont_cls); 191 uint16_t payload_type,
192 uint32_t payload_id,
193 size_t size,
194 struct CadetConnection *c,
195 int fwd,
196 GCP_sent cont,
197 void *cont_cls);
188 198
189/** 199/**
190 * Cancel all queued messages to a peer that belong to a certain connection. 200 * Cancel all queued messages to a peer that belong to a certain connection.
diff --git a/src/cadet/gnunet-service-cadet_tunnel.c b/src/cadet/gnunet-service-cadet_tunnel.c
index 987d307f0..a944f9e5f 100644
--- a/src/cadet/gnunet-service-cadet_tunnel.c
+++ b/src/cadet/gnunet-service-cadet_tunnel.c
@@ -2276,7 +2276,7 @@ send_kx (struct CadetTunnel *t,
2276static void 2276static void
2277send_ephemeral (struct CadetTunnel *t) 2277send_ephemeral (struct CadetTunnel *t)
2278{ 2278{
2279 LOG (GNUNET_ERROR_TYPE_INFO, "===> EPHM for %s\n", GCT_2s (t)); 2279 LOG (GNUNET_ERROR_TYPE_INFO, "==> EPHM for %s\n", GCT_2s (t));
2280 if (NULL != t->ephm_h) 2280 if (NULL != t->ephm_h)
2281 { 2281 {
2282 LOG (GNUNET_ERROR_TYPE_INFO, " already queued\n"); 2282 LOG (GNUNET_ERROR_TYPE_INFO, " already queued\n");
@@ -2305,7 +2305,7 @@ send_pong (struct CadetTunnel *t, uint32_t challenge)
2305{ 2305{
2306 struct GNUNET_CADET_KX_Pong msg; 2306 struct GNUNET_CADET_KX_Pong msg;
2307 2307
2308 LOG (GNUNET_ERROR_TYPE_INFO, "===> PONG for %s\n", GCT_2s (t)); 2308 LOG (GNUNET_ERROR_TYPE_INFO, "==> PONG for %s\n", GCT_2s (t));
2309 if (NULL != t->pong_h) 2309 if (NULL != t->pong_h)
2310 { 2310 {
2311 LOG (GNUNET_ERROR_TYPE_INFO, " already queued\n"); 2311 LOG (GNUNET_ERROR_TYPE_INFO, " already queued\n");
@@ -2560,7 +2560,7 @@ handle_data (struct CadetTunnel *t,
2560 } 2560 }
2561 type = ntohs (msg[1].header.type); 2561 type = ntohs (msg[1].header.type);
2562 LOG (GNUNET_ERROR_TYPE_DEBUG, " payload of type %s\n", GC_m2s (type)); 2562 LOG (GNUNET_ERROR_TYPE_DEBUG, " payload of type %s\n", GC_m2s (type));
2563 sprintf (buf, "# received payload of type %hu", type); 2563 SPRINTF (buf, "# received payload of type %hu", type);
2564 GNUNET_STATISTICS_update (stats, buf, 1, GNUNET_NO); 2564 GNUNET_STATISTICS_update (stats, buf, 1, GNUNET_NO);
2565 2565
2566 2566
@@ -2570,8 +2570,7 @@ handle_data (struct CadetTunnel *t,
2570 { 2570 {
2571 GNUNET_STATISTICS_update (stats, "# data on unknown channel", 2571 GNUNET_STATISTICS_update (stats, "# data on unknown channel",
2572 1, GNUNET_NO); 2572 1, GNUNET_NO);
2573 LOG (GNUNET_ERROR_TYPE_DEBUG, "WARNING channel 0x%X unknown\n", 2573 LOG (GNUNET_ERROR_TYPE_DEBUG, "channel 0x%X unknown\n", ntohl (msg->chid));
2574 ntohl (msg->chid));
2575 send_channel_destroy (t, ntohl (msg->chid)); 2574 send_channel_destroy (t, ntohl (msg->chid));
2576 return; 2575 return;
2577 } 2576 }
@@ -2624,8 +2623,8 @@ handle_data_ack (struct CadetTunnel *t,
2624/** 2623/**
2625 * Handle channel create. 2624 * Handle channel create.
2626 * 2625 *
2627 * @param t Tunnel on which the data came. 2626 * @param t Tunnel on which the message came.
2628 * @param msg Data message. 2627 * @param msg ChannelCreate message.
2629 */ 2628 */
2630static void 2629static void
2631handle_ch_create (struct CadetTunnel *t, 2630handle_ch_create (struct CadetTunnel *t,
@@ -2638,7 +2637,7 @@ handle_ch_create (struct CadetTunnel *t,
2638 size = ntohs (msg->header.size); 2637 size = ntohs (msg->header.size);
2639 if (size != sizeof (struct GNUNET_CADET_ChannelCreate)) 2638 if (size != sizeof (struct GNUNET_CADET_ChannelCreate))
2640 { 2639 {
2641 GNUNET_break (0); 2640 GNUNET_break_op (0);
2642 return; 2641 return;
2643 } 2642 }
2644 2643
@@ -2814,7 +2813,7 @@ static void
2814handle_ephemeral (struct CadetTunnel *t, 2813handle_ephemeral (struct CadetTunnel *t,
2815 const struct GNUNET_CADET_KX_Ephemeral *msg) 2814 const struct GNUNET_CADET_KX_Ephemeral *msg)
2816{ 2815{
2817 LOG (GNUNET_ERROR_TYPE_INFO, "<=== EPHM for %s\n", GCT_2s (t)); 2816 LOG (GNUNET_ERROR_TYPE_INFO, "<== EPHM for %s\n", GCT_2s (t));
2818 2817
2819 /* Some old versions are still around, don't log as error. */ 2818 /* Some old versions are still around, don't log as error. */
2820 if (GNUNET_OK != check_ephemeral (t, msg)) 2819 if (GNUNET_OK != check_ephemeral (t, msg))
@@ -2900,7 +2899,7 @@ handle_pong (struct CadetTunnel *t,
2900{ 2899{
2901 uint32_t challenge; 2900 uint32_t challenge;
2902 2901
2903 LOG (GNUNET_ERROR_TYPE_INFO, "<=== PONG for %s\n", GCT_2s (t)); 2902 LOG (GNUNET_ERROR_TYPE_INFO, "<== PONG for %s\n", GCT_2s (t));
2904 if (NULL == t->rekey_task) 2903 if (NULL == t->rekey_task)
2905 { 2904 {
2906 GNUNET_STATISTICS_update (stats, "# duplicate PONG messages", 1, GNUNET_NO); 2905 GNUNET_STATISTICS_update (stats, "# duplicate PONG messages", 1, GNUNET_NO);
@@ -2952,7 +2951,7 @@ handle_kx_ax (struct CadetTunnel *t, const struct GNUNET_CADET_AX_KX *msg)
2952 const struct GNUNET_PeerIdentity *pid; 2951 const struct GNUNET_PeerIdentity *pid;
2953 int am_I_alice; 2952 int am_I_alice;
2954 2953
2955 LOG (GNUNET_ERROR_TYPE_INFO, "<=== AX_KX on %s\n", GCT_2s (t)); 2954 LOG (GNUNET_ERROR_TYPE_INFO, "<== { AX_KX} on %s\n", GCT_2s (t));
2956 2955
2957 if (NULL == t->ax) 2956 if (NULL == t->ax)
2958 { 2957 {
@@ -3099,8 +3098,8 @@ handle_decrypted (struct CadetTunnel *t,
3099 char buf[256]; 3098 char buf[256];
3100 3099
3101 type = ntohs (msgh->type); 3100 type = ntohs (msgh->type);
3102 LOG (GNUNET_ERROR_TYPE_INFO, "<=== %s on %s\n", GC_m2s (type), GCT_2s (t)); 3101 LOG (GNUNET_ERROR_TYPE_DEBUG, "<-- %s on %s\n", GC_m2s (type), GCT_2s (t));
3103 sprintf (buf, "# received encrypted of type %hu (%s)", type, GC_m2s (type)); 3102 SPRINTF (buf, "# received encrypted of type %hu (%s)", type, GC_m2s (type));
3104 GNUNET_STATISTICS_update (stats, buf, 1, GNUNET_NO); 3103 GNUNET_STATISTICS_update (stats, buf, 1, GNUNET_NO);
3105 3104
3106 switch (type) 3105 switch (type)
@@ -4374,7 +4373,7 @@ GCT_send_ax_kx (struct CadetTunnel *t, int force_reply)
4374 struct GNUNET_CADET_AX_KX msg; 4373 struct GNUNET_CADET_AX_KX msg;
4375 enum GNUNET_CADET_AX_KX_Flags flags; 4374 enum GNUNET_CADET_AX_KX_Flags flags;
4376 4375
4377 LOG (GNUNET_ERROR_TYPE_INFO, "===> AX_KX for %s\n", GCT_2s (t)); 4376 LOG (GNUNET_ERROR_TYPE_INFO, "==> { AX_KX} on %s\n", GCT_2s (t));
4378 if (NULL != t->ephm_h) 4377 if (NULL != t->ephm_h)
4379 { 4378 {
4380 LOG (GNUNET_ERROR_TYPE_INFO, " already queued\n"); 4379 LOG (GNUNET_ERROR_TYPE_INFO, " already queued\n");
@@ -4418,7 +4417,8 @@ GCT_resend_message (const struct GNUNET_MessageHeader *message,
4418 return; 4417 return;
4419 } 4418 }
4420 fwd = GCC_is_origin (c, GNUNET_YES); 4419 fwd = GCC_is_origin (c, GNUNET_YES);
4421 GNUNET_break (NULL == GCC_send_prebuilt_message (message, 0, 0, c, fwd, 4420 GNUNET_break (NULL == GCC_send_prebuilt_message (message, UINT16_MAX, 0,
4421 c, fwd,
4422 GNUNET_YES, NULL, NULL)); 4422 GNUNET_YES, NULL, NULL));
4423} 4423}
4424 4424