aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-03-25 14:33:18 +0000
committerChristian Grothoff <christian@grothoff.org>2010-03-25 14:33:18 +0000
commitcafe3f8c7f404647d322e6c195f727a6e5a17224 (patch)
treed2c7e72ef8afc9070495d45a234e53d846269113
parentda070a9e53e0f4f8b8f1225755fbf5d74635262d (diff)
downloadgnunet-cafe3f8c7f404647d322e6c195f727a6e5a17224.tar.gz
gnunet-cafe3f8c7f404647d322e6c195f727a6e5a17224.zip
clean up
-rw-r--r--src/core/gnunet-service-core.c150
-rw-r--r--src/include/gnunet_constants.h4
2 files changed, 82 insertions, 72 deletions
diff --git a/src/core/gnunet-service-core.c b/src/core/gnunet-service-core.c
index 5c8145002..c85043041 100644
--- a/src/core/gnunet-service-core.c
+++ b/src/core/gnunet-service-core.c
@@ -77,11 +77,6 @@
77#define PAST_EXPIRATION_DISCARD_TIME GNUNET_TIME_UNIT_SECONDS 77#define PAST_EXPIRATION_DISCARD_TIME GNUNET_TIME_UNIT_SECONDS
78 78
79/** 79/**
80 * How long do we delay messages to get larger packet sizes (CORKing)?
81 */
82#define MAX_CORK_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
83
84/**
85 * What is the maximum delay for a SET_KEY message? 80 * What is the maximum delay for a SET_KEY message?
86 */ 81 */
87#define MAX_SET_KEY_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5) 82#define MAX_SET_KEY_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
@@ -784,7 +779,7 @@ send_to_client (struct Client *client,
784#if DEBUG_CORE_CLIENT 779#if DEBUG_CORE_CLIENT
785 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 780 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
786 "Preparing to send message of type %u to client.\n", 781 "Preparing to send message of type %u to client.\n",
787 ntohs (msg->type)); 782 (unsigned int) ntohs (msg->type));
788#endif 783#endif
789 GNUNET_SERVER_notification_context_unicast (notifier, 784 GNUNET_SERVER_notification_context_unicast (notifier,
790 client->client_handle, 785 client->client_handle,
@@ -816,7 +811,7 @@ send_to_all_clients (const struct GNUNET_MessageHeader *msg,
816#if DEBUG_CORE_CLIENT 811#if DEBUG_CORE_CLIENT
817 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 812 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
818 "Sending message of type %u to client.\n", 813 "Sending message of type %u to client.\n",
819 ntohs (msg->type)); 814 (unsigned int) ntohs (msg->type));
820#endif 815#endif
821 send_to_client (c, msg, can_drop); 816 send_to_client (c, msg, can_drop);
822 } 817 }
@@ -885,7 +880,7 @@ handle_client_init (void *cls,
885 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 880 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
886 "Client %p is interested in %u message types\n", 881 "Client %p is interested in %u message types\n",
887 c, 882 c,
888 c->tcnt); 883 (unsigned int) c->tcnt);
889#endif 884#endif
890 /* send init reply message */ 885 /* send init reply message */
891 irm.header.size = htons (sizeof (struct InitReplyMessage)); 886 irm.header.size = htons (sizeof (struct InitReplyMessage));
@@ -1156,8 +1151,10 @@ do_encrypt (struct Neighbour *n,
1156 GNUNET_STATISTICS_update (stats, gettext_noop ("# bytes encrypted"), size, GNUNET_NO); 1151 GNUNET_STATISTICS_update (stats, gettext_noop ("# bytes encrypted"), size, GNUNET_NO);
1157#if DEBUG_CORE 1152#if DEBUG_CORE
1158 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1153 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1159 "Encrypted %u bytes for `%4s' using key %u\n", size, 1154 "Encrypted %u bytes for `%4s' using key %u\n",
1160 GNUNET_i2s (&n->peer), n->encrypt_key.crc32); 1155 (unsigned int) size,
1156 GNUNET_i2s (&n->peer),
1157 (unsigned int) n->encrypt_key.crc32);
1161#endif 1158#endif
1162 return GNUNET_OK; 1159 return GNUNET_OK;
1163} 1160}
@@ -1207,14 +1204,13 @@ send_keep_alive (void *cls,
1207 pm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_PING); 1204 pm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_PING);
1208 pp.challenge = htonl (n->ping_challenge); 1205 pp.challenge = htonl (n->ping_challenge);
1209 pp.target = n->peer; 1206 pp.target = n->peer;
1210#if DEBUG_CORE 1207#if DEBUG_HANDSHAKE
1211 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1212 "Encrypting `%s' and `%s' messages for `%4s'.\n",
1213 "SET_KEY", "PING", GNUNET_i2s (&n->peer));
1214 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1208 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1215 "Sending `%s' to `%4s' with challenge %u encrypted using key %u\n", 1209 "Encrypting `%s' message with challenge %u for `%4s' using key %u.\n",
1216 "PING", 1210 "PING",
1217 GNUNET_i2s (&n->peer), n->ping_challenge, n->encrypt_key.crc32); 1211 (unsigned int) n->ping_challenge,
1212 GNUNET_i2s (&n->peer),
1213 (unsigned int) n->encrypt_key.crc32);
1218#endif 1214#endif
1219 do_encrypt (n, 1215 do_encrypt (n,
1220 &n->peer.hashPubKey, 1216 &n->peer.hashPubKey,
@@ -1343,8 +1339,9 @@ notify_encrypted_transmit_ready (void *cls, size_t size, void *buf)
1343#if DEBUG_CORE 1339#if DEBUG_CORE
1344 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1340 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1345 "Copied message of type %u and size %u into transport buffer for `%4s'\n", 1341 "Copied message of type %u and size %u into transport buffer for `%4s'\n",
1346 ntohs (((struct GNUNET_MessageHeader *) &m[1])->type), 1342 (unsigned int) ntohs (((struct GNUNET_MessageHeader *) &m[1])->type),
1347 ret, GNUNET_i2s (&n->peer)); 1343 (unsigned int) ret,
1344 GNUNET_i2s (&n->peer));
1348#endif 1345#endif
1349 process_encrypted_neighbour_queue (n); 1346 process_encrypted_neighbour_queue (n);
1350 } 1347 }
@@ -1353,8 +1350,8 @@ notify_encrypted_transmit_ready (void *cls, size_t size, void *buf)
1353#if DEBUG_CORE 1350#if DEBUG_CORE
1354 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1351 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1355 "Transmission of message of type %u and size %u failed\n", 1352 "Transmission of message of type %u and size %u failed\n",
1356 ntohs (((struct GNUNET_MessageHeader *) &m[1])->type), 1353 (unsigned int) ntohs (((struct GNUNET_MessageHeader *) &m[1])->type),
1357 m->size); 1354 (unsigned int) m->size);
1358#endif 1355#endif
1359 } 1356 }
1360 GNUNET_free (m); 1357 GNUNET_free (m);
@@ -1397,9 +1394,9 @@ process_encrypted_neighbour_queue (struct Neighbour *n)
1397#if DEBUG_CORE 1394#if DEBUG_CORE
1398 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1395 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1399 "Asking transport for transmission of %u bytes to `%4s' in next %llu ms\n", 1396 "Asking transport for transmission of %u bytes to `%4s' in next %llu ms\n",
1400 m->size, 1397 (unsigned int) m->size,
1401 GNUNET_i2s (&n->peer), 1398 GNUNET_i2s (&n->peer),
1402 GNUNET_TIME_absolute_get_remaining (m->deadline). 1399 (unsigned long long) GNUNET_TIME_absolute_get_remaining (m->deadline).
1403 value); 1400 value);
1404#endif 1401#endif
1405 n->th = 1402 n->th =
@@ -1467,7 +1464,9 @@ do_decrypt (struct Neighbour *n,
1467#if DEBUG_CORE 1464#if DEBUG_CORE
1468 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1465 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1469 "Decrypted %u bytes from `%4s' using key %u\n", 1466 "Decrypted %u bytes from `%4s' using key %u\n",
1470 size, GNUNET_i2s (&n->peer), n->decrypt_key.crc32); 1467 (unsigned int) size,
1468 GNUNET_i2s (&n->peer),
1469 (unsigned int) n->decrypt_key.crc32);
1471#endif 1470#endif
1472 return GNUNET_OK; 1471 return GNUNET_OK;
1473} 1472}
@@ -1537,7 +1536,7 @@ select_messages (struct Neighbour *n,
1537 off = 0; 1536 off = 0;
1538 /* maximum time we can wait before transmitting anything 1537 /* maximum time we can wait before transmitting anything
1539 and still make all of our deadlines */ 1538 and still make all of our deadlines */
1540 slack = MAX_CORK_DELAY; 1539 slack = GNUNET_CONSTANTS_MAX_CORK_DELAY;
1541 pos = n->messages; 1540 pos = n->messages;
1542 /* note that we use "*2" here because we want to look 1541 /* note that we use "*2" here because we want to look
1543 a bit further into the future; much more makes no 1542 a bit further into the future; much more makes no
@@ -1593,7 +1592,7 @@ select_messages (struct Neighbour *n,
1593 GNUNET_TIME_absolute_get_difference (now, pos->deadline)); 1592 GNUNET_TIME_absolute_get_difference (now, pos->deadline));
1594 pos->got_slack = GNUNET_YES; 1593 pos->got_slack = GNUNET_YES;
1595 pos->slack_deadline = GNUNET_TIME_absolute_min (pos->deadline, 1594 pos->slack_deadline = GNUNET_TIME_absolute_min (pos->deadline,
1596 GNUNET_TIME_relative_to_absolute (MAX_CORK_DELAY)); 1595 GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_MAX_CORK_DELAY));
1597 } 1596 }
1598 } 1597 }
1599 } 1598 }
@@ -1625,7 +1624,7 @@ select_messages (struct Neighbour *n,
1625 being met if we delay by one second or more; so just wait for 1624 being met if we delay by one second or more; so just wait for
1626 more data; but do not wait longer than 1s (since we don't want 1625 more data; but do not wait longer than 1s (since we don't want
1627 to delay messages for a really long time either). */ 1626 to delay messages for a really long time either). */
1628 *retry_time = MAX_CORK_DELAY; 1627 *retry_time = GNUNET_CONSTANTS_MAX_CORK_DELAY;
1629 /* reset do_transmit values for next time */ 1628 /* reset do_transmit values for next time */
1630 while (pos != last) 1629 while (pos != last)
1631 { 1630 {
@@ -1749,7 +1748,7 @@ batch_message (struct Neighbour *n,
1749#if DEBUG_HANDSHAKE 1748#if DEBUG_HANDSHAKE
1750 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1749 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1751 "Encrypting message of type %u\n", 1750 "Encrypting message of type %u\n",
1752 ntohs(((struct GNUNET_MessageHeader*)&pos[1])->type)); 1751 (unsigned int) ntohs(((struct GNUNET_MessageHeader*)&pos[1])->type));
1753#endif 1752#endif
1754 /* copy for encrypted transmission */ 1753 /* copy for encrypted transmission */
1755 memcpy (&buf[ret], &pos[1], pos->size); 1754 memcpy (&buf[ret], &pos[1], pos->size);
@@ -1759,8 +1758,8 @@ batch_message (struct Neighbour *n,
1759#if DEBUG_CORE 1758#if DEBUG_CORE
1760 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1759 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1761 "Adding plaintext message of size %u with deadline %llu ms to batch\n", 1760 "Adding plaintext message of size %u with deadline %llu ms to batch\n",
1762 pos->size, 1761 (unsigned int) pos->size,
1763 GNUNET_TIME_absolute_get_remaining (pos->deadline).value); 1762 (unsigned long long) GNUNET_TIME_absolute_get_remaining (pos->deadline).value);
1764#endif 1763#endif
1765 deadline->value = GNUNET_MIN (deadline->value, pos->deadline.value); 1764 deadline->value = GNUNET_MIN (deadline->value, pos->deadline.value);
1766 GNUNET_free (pos); 1765 GNUNET_free (pos);
@@ -2002,18 +2001,18 @@ process_plaintext_neighbour_queue (struct Neighbour *n)
2002 esize - sizeof (GNUNET_HashCode), 2001 esize - sizeof (GNUNET_HashCode),
2003 &ph->plaintext_hash); 2002 &ph->plaintext_hash);
2004 GNUNET_CRYPTO_hash (&ph->iv_seed, sizeof (uint32_t), &iv); 2003 GNUNET_CRYPTO_hash (&ph->iv_seed, sizeof (uint32_t), &iv);
2005#if DEBUG_CORE 2004#if DEBUG_HANDSHAKE
2006 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2005 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2007 "Hashed %u bytes of plaintext (`%s') using IV `%d'\n", 2006 "Hashed %u bytes of plaintext (`%s') using IV `%d'\n",
2008 esize - sizeof (GNUNET_HashCode), 2007 (unsigned int) (esize - sizeof (GNUNET_HashCode)),
2009 GNUNET_h2s (&ph->plaintext_hash), 2008 GNUNET_h2s (&ph->plaintext_hash),
2010 (int) ph->iv_seed); 2009 (int) ph->iv_seed);
2011#endif 2010#endif
2012 /* encrypt */ 2011 /* encrypt */
2013#if DEBUG_CORE 2012#if DEBUG_HANDSHAKE
2014 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2013 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2015 "Encrypting %u bytes of plaintext messages for `%4s' for transmission in %llums.\n", 2014 "Encrypting %u bytes of plaintext messages for `%4s' for transmission in %llums.\n",
2016 esize, 2015 (unsigned int) esize,
2017 GNUNET_i2s(&n->peer), 2016 GNUNET_i2s(&n->peer),
2018 (unsigned long long) GNUNET_TIME_absolute_get_remaining (deadline).value); 2017 (unsigned long long) GNUNET_TIME_absolute_get_remaining (deadline).value);
2019#endif 2018#endif
@@ -2147,7 +2146,7 @@ handle_client_send (void *cls,
2147 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2146 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2148 "Core received `%s' request, queueing %u bytes of plaintext data for transmission to `%4s'.\n", 2147 "Core received `%s' request, queueing %u bytes of plaintext data for transmission to `%4s'.\n",
2149 "SEND", 2148 "SEND",
2150 msize, 2149 (unsigned int) msize,
2151 GNUNET_i2s (&sm->peer)); 2150 GNUNET_i2s (&sm->peer));
2152#endif 2151#endif
2153 /* bound queue size */ 2152 /* bound queue size */
@@ -2180,9 +2179,9 @@ handle_client_send (void *cls,
2180 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2179 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2181 "Queue full (%u/%u), discarding new request (%u bytes of type %u)\n", 2180 "Queue full (%u/%u), discarding new request (%u bytes of type %u)\n",
2182 queue_size, 2181 queue_size,
2183 MAX_PEER_QUEUE_SIZE, 2182 (unsigned int) MAX_PEER_QUEUE_SIZE,
2184 msize, 2183 (unsigned int) msize,
2185 ntohs (message->type)); 2184 (unsigned int) ntohs (message->type));
2186#endif 2185#endif
2187 if (client != NULL) 2186 if (client != NULL)
2188 GNUNET_SERVER_receive_done (client, GNUNET_OK); 2187 GNUNET_SERVER_receive_done (client, GNUNET_OK);
@@ -2204,7 +2203,7 @@ handle_client_send (void *cls,
2204 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2203 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2205 "Adding transmission request for `%4s' of size %u to queue\n", 2204 "Adding transmission request for `%4s' of size %u to queue\n",
2206 GNUNET_i2s (&sm->peer), 2205 GNUNET_i2s (&sm->peer),
2207 msize); 2206 (unsigned int) msize);
2208#endif 2207#endif
2209 e = GNUNET_malloc (sizeof (struct MessageEntry) + msize); 2208 e = GNUNET_malloc (sizeof (struct MessageEntry) + msize);
2210 e->deadline = GNUNET_TIME_absolute_ntoh (sm->deadline); 2209 e->deadline = GNUNET_TIME_absolute_ntoh (sm->deadline);
@@ -2526,14 +2525,13 @@ send_key (struct Neighbour *n)
2526 pm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_PING); 2525 pm->header.type = htons (GNUNET_MESSAGE_TYPE_CORE_PING);
2527 pp.challenge = htonl (n->ping_challenge); 2526 pp.challenge = htonl (n->ping_challenge);
2528 pp.target = n->peer; 2527 pp.target = n->peer;
2529#if DEBUG_CORE 2528#if DEBUG_HANDSHAKE
2530 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2531 "Encrypting `%s' and `%s' messages for `%4s'.\n",
2532 "SET_KEY", "PING", GNUNET_i2s (&n->peer));
2533 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2529 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2534 "Sending `%s' to `%4s' with challenge %u encrypted using key %u\n", 2530 "Encrypting `%s' and `%s' messages with challenge %u for `%4s' using key %u.\n",
2535 "PING", 2531 "SET_KEY", "PING",
2536 GNUNET_i2s (&n->peer), n->ping_challenge, n->encrypt_key.crc32); 2532 (unsigned int) n->ping_challenge,
2533 GNUNET_i2s (&n->peer),
2534 (unsigned int) n->encrypt_key.crc32);
2537#endif 2535#endif
2538 do_encrypt (n, 2536 do_encrypt (n,
2539 &n->peer.hashPubKey, 2537 &n->peer.hashPubKey,
@@ -2663,15 +2661,13 @@ handle_ping (struct Neighbour *n, const struct PingMessage *m)
2663 sizeof (struct PingMessage) - 2661 sizeof (struct PingMessage) -
2664 sizeof (struct GNUNET_MessageHeader))) 2662 sizeof (struct GNUNET_MessageHeader)))
2665 return; 2663 return;
2666#if DEBUG_CORE 2664#if DEBUG_HANDSHAKE
2667 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2665 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2668 "Decrypted `%s' to `%4s' with challenge %u decrypted using key %u\n", 2666 "Decrypted `%s' to `%4s' with challenge %u decrypted using key %u\n",
2669 "PING", 2667 "PING",
2670 GNUNET_i2s (&t.target), 2668 GNUNET_i2s (&t.target),
2671 ntohl (t.challenge), n->decrypt_key.crc32); 2669 (unsigned int) ntohl (t.challenge),
2672 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2670 (unsigned int) n->decrypt_key.crc32);
2673 "Target of `%s' request is `%4s'.\n",
2674 "PING", GNUNET_i2s (&t.target));
2675#endif 2671#endif
2676 GNUNET_STATISTICS_update (stats, 2672 GNUNET_STATISTICS_update (stats,
2677 gettext_noop ("# PING messages decrypted"), 2673 gettext_noop ("# PING messages decrypted"),
@@ -2709,10 +2705,12 @@ handle_ping (struct Neighbour *n, const struct PingMessage *m)
2709 gettext_noop ("# PONG messages created"), 2705 gettext_noop ("# PONG messages created"),
2710 1, 2706 1,
2711 GNUNET_NO); 2707 GNUNET_NO);
2712#if DEBUG_CORE 2708#if DEBUG_HANDSHAKE
2713 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2709 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2714 "Encrypting `%s' with challenge %u using key %u\n", "PONG", 2710 "Encrypting `%s' with challenge %u using key %u\n",
2715 ntohl (t.challenge), n->encrypt_key.crc32); 2711 "PONG",
2712 (unsigned int) ntohl (t.challenge),
2713 (unsigned int) n->encrypt_key.crc32);
2716#endif 2714#endif
2717 /* trigger queue processing */ 2715 /* trigger queue processing */
2718 process_encrypted_neighbour_queue (n); 2716 process_encrypted_neighbour_queue (n);
@@ -2757,12 +2755,13 @@ handle_pong (struct Neighbour *n,
2757 GNUNET_break_op (0); 2755 GNUNET_break_op (0);
2758 return; 2756 return;
2759 } 2757 }
2760#if DEBUG_CORE 2758#if DEBUG_HANDSHAKE
2761 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2759 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2762 "Decrypted `%s' from `%4s' with challenge %u using key %u\n", 2760 "Decrypted `%s' from `%4s' with challenge %u using key %u\n",
2763 "PONG", 2761 "PONG",
2764 GNUNET_i2s (&t.target), 2762 GNUNET_i2s (&t.target),
2765 ntohl (t.challenge), n->decrypt_key.crc32); 2763 (unsigned int) ntohl (t.challenge),
2764 (unsigned int) n->decrypt_key.crc32);
2766#endif 2765#endif
2767 if ((0 != memcmp (&t.target, 2766 if ((0 != memcmp (&t.target,
2768 &n->peer, 2767 &n->peer,
@@ -2773,10 +2772,13 @@ handle_pong (struct Neighbour *n,
2773#if DEBUG_CORE 2772#if DEBUG_CORE
2774 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2773 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2775 "Received malformed `%s' wanted sender `%4s' with challenge %u\n", 2774 "Received malformed `%s' wanted sender `%4s' with challenge %u\n",
2776 "PONG", GNUNET_i2s (&n->peer), n->ping_challenge); 2775 "PONG",
2776 GNUNET_i2s (&n->peer),
2777 (unsigned int) n->ping_challenge);
2777 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2778 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2778 "Received malformed `%s' received from `%4s' with challenge %u\n", 2779 "Received malformed `%s' received from `%4s' with challenge %u\n",
2779 "PONG", GNUNET_i2s (&t.target), ntohl (t.challenge)); 2780 "PONG", GNUNET_i2s (&t.target),
2781 (unsigned int) ntohl (t.challenge));
2780#endif 2782#endif
2781 GNUNET_break_op (0); 2783 GNUNET_break_op (0);
2782 return; 2784 return;
@@ -2979,7 +2981,8 @@ handle_set_key (struct Neighbour *n, const struct SetKeyMessage *m)
2979#if DEBUG_CORE 2981#if DEBUG_CORE
2980 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2982 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2981 "Responding to `%s' with my own key (other peer has status %u).\n", 2983 "Responding to `%s' with my own key (other peer has status %u).\n",
2982 "SET_KEY", sender_status); 2984 "SET_KEY",
2985 (unsigned int) sender_status);
2983#endif 2986#endif
2984 send_key (n); 2987 send_key (n);
2985 } 2988 }
@@ -2991,7 +2994,8 @@ handle_set_key (struct Neighbour *n, const struct SetKeyMessage *m)
2991#if DEBUG_CORE 2994#if DEBUG_CORE
2992 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2995 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2993 "Responding to `%s' with my own key (other peer has status %u), I was already fully up.\n", 2996 "Responding to `%s' with my own key (other peer has status %u), I was already fully up.\n",
2994 "SET_KEY", sender_status); 2997 "SET_KEY",
2998 (unsigned int) sender_status);
2995#endif 2999#endif
2996 send_key (n); 3000 send_key (n);
2997 } 3001 }
@@ -3037,7 +3041,7 @@ send_p2p_message_to_client (struct Neighbour *sender,
3037 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3041 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3038 "Core service passes message from `%4s' of type %u to client.\n", 3042 "Core service passes message from `%4s' of type %u to client.\n",
3039 GNUNET_i2s(&sender->peer), 3043 GNUNET_i2s(&sender->peer),
3040 ntohs (((const struct GNUNET_MessageHeader *) m)->type)); 3044 (unsigned int) ntohs (((const struct GNUNET_MessageHeader *) m)->type));
3041#endif 3045#endif
3042 ntm = (struct NotifyTrafficMessage *) buf; 3046 ntm = (struct NotifyTrafficMessage *) buf;
3043 ntm->header.size = htons (msize + sizeof (struct NotifyTrafficMessage)); 3047 ntm->header.size = htons (msize + sizeof (struct NotifyTrafficMessage));
@@ -3072,13 +3076,13 @@ deliver_message (struct Neighbour *sender,
3072#if DEBUG_CORE 3076#if DEBUG_CORE
3073 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3077 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3074 "Received encapsulated message of type %u from `%4s'\n", 3078 "Received encapsulated message of type %u from `%4s'\n",
3075 type, 3079 (unsigned int) type,
3076 GNUNET_i2s (&sender->peer)); 3080 GNUNET_i2s (&sender->peer));
3077#endif 3081#endif
3078 GNUNET_snprintf (buf, 3082 GNUNET_snprintf (buf,
3079 sizeof(buf), 3083 sizeof(buf),
3080 gettext_noop ("# bytes of messages of type %u received"), 3084 gettext_noop ("# bytes of messages of type %u received"),
3081 type); 3085 (unsigned int) type);
3082 GNUNET_STATISTICS_set (stats, 3086 GNUNET_STATISTICS_set (stats,
3083 buf, 3087 buf,
3084 msize, 3088 msize,
@@ -3117,7 +3121,7 @@ deliver_message (struct Neighbour *sender,
3117#if DEBUG_CORE 3121#if DEBUG_CORE
3118 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3122 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3119 "Message of type %u from `%4s' not delivered to any client.\n", 3123 "Message of type %u from `%4s' not delivered to any client.\n",
3120 type, 3124 (unsigned int) type,
3121 GNUNET_i2s (&sender->peer)); 3125 GNUNET_i2s (&sender->peer));
3122#endif 3126#endif
3123 /* FIXME: stats... */ 3127 /* FIXME: stats... */
@@ -3231,10 +3235,10 @@ handle_encrypted_message (struct Neighbour *n,
3231 /* validate hash */ 3235 /* validate hash */
3232 GNUNET_CRYPTO_hash (&pt->sequence_number, 3236 GNUNET_CRYPTO_hash (&pt->sequence_number,
3233 size - ENCRYPTED_HEADER_SIZE - sizeof (GNUNET_HashCode), &ph); 3237 size - ENCRYPTED_HEADER_SIZE - sizeof (GNUNET_HashCode), &ph);
3234#if DEBUG_HANDSHAKE 3238#if DEBUG_HANDSHAKE
3235 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3239 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3236 "V-Hashed %u bytes of plaintext (`%s') using IV `%d'\n", 3240 "V-Hashed %u bytes of plaintext (`%s') using IV `%d'\n",
3237 size - ENCRYPTED_HEADER_SIZE - sizeof (GNUNET_HashCode), 3241 (unsigned int) (size - ENCRYPTED_HEADER_SIZE - sizeof (GNUNET_HashCode)),
3238 GNUNET_h2s (&ph), 3242 GNUNET_h2s (&ph),
3239 (int) m->iv_seed); 3243 (int) m->iv_seed);
3240#endif 3244#endif
@@ -3373,7 +3377,8 @@ handle_transport_receive (void *cls,
3373#if DEBUG_CORE 3377#if DEBUG_CORE
3374 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3378 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3375 "Received message of type %u from `%4s', demultiplexing.\n", 3379 "Received message of type %u from `%4s', demultiplexing.\n",
3376 ntohs (message->type), GNUNET_i2s (peer)); 3380 (unsigned int) ntohs (message->type),
3381 GNUNET_i2s (peer));
3377#endif 3382#endif
3378 if (0 == memcmp (peer, &my_identity, sizeof (struct GNUNET_PeerIdentity))) 3383 if (0 == memcmp (peer, &my_identity, sizeof (struct GNUNET_PeerIdentity)))
3379 { 3384 {
@@ -3389,10 +3394,10 @@ handle_transport_receive (void *cls,
3389 type = ntohs (message->type); 3394 type = ntohs (message->type);
3390 size = ntohs (message->size); 3395 size = ntohs (message->size);
3391#if DEBUG_HANDSHAKE 3396#if DEBUG_HANDSHAKE
3392 fprintf (stderr, 3397 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3393 "Received message of type %u from `%4s'\n", 3398 "Received message of type %u from `%4s'\n",
3394 type, 3399 (unsigned int) type,
3395 GNUNET_i2s (peer)); 3400 GNUNET_i2s (peer));
3396#endif 3401#endif
3397 switch (type) 3402 switch (type)
3398 { 3403 {
@@ -3473,7 +3478,8 @@ handle_transport_receive (void *cls,
3473 break; 3478 break;
3474 default: 3479 default:
3475 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 3480 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
3476 _("Unsupported message of type %u received.\n"), type); 3481 _("Unsupported message of type %u received.\n"),
3482 (unsigned int) type);
3477 return; 3483 return;
3478 } 3484 }
3479 if (n->status == PEER_STATE_KEY_CONFIRMED) 3485 if (n->status == PEER_STATE_KEY_CONFIRMED)
diff --git a/src/include/gnunet_constants.h b/src/include/gnunet_constants.h
index 035cc60b9..3b56f26d6 100644
--- a/src/include/gnunet_constants.h
+++ b/src/include/gnunet_constants.h
@@ -64,6 +64,10 @@ extern "C"
64 */ 64 */
65#define GNUNET_CONSTANTS_SERVICE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 10) 65#define GNUNET_CONSTANTS_SERVICE_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 10)
66 66
67/**
68 * How long do we delay messages to get larger packet sizes (CORKing)?
69 */
70#define GNUNET_CONSTANTS_MAX_CORK_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
67 71
68/** 72/**
69 * Until which load do we consider the peer overly idle 73 * Until which load do we consider the peer overly idle