summaryrefslogtreecommitdiff
path: root/src/dv
diff options
context:
space:
mode:
authorNathan S. Evans <evans@in.tum.de>2010-06-18 16:11:03 +0000
committerNathan S. Evans <evans@in.tum.de>2010-06-18 16:11:03 +0000
commitf68c5e63c9bf905e125f449eaa66d9969f74838c (patch)
tree1de49b904a763b8c44e8f02d7730e21821feeffc /src/dv
parentab728fdf2db6f2b8cef37d0c6add760c88acd526 (diff)
downloadgnunet-f68c5e63c9bf905e125f449eaa66d9969f74838c.tar.gz
gnunet-f68c5e63c9bf905e125f449eaa66d9969f74838c.zip
dv changes, better logging and so on
Diffstat (limited to 'src/dv')
-rw-r--r--src/dv/dv.h8
-rw-r--r--src/dv/dv_api.c12
-rw-r--r--src/dv/gnunet-service-dv.c146
-rw-r--r--src/dv/plugin_transport_dv.c41
-rw-r--r--src/dv/test_transport_api_dv.c11
-rw-r--r--src/dv/test_transport_dv_data.conf4
6 files changed, 159 insertions, 63 deletions
diff --git a/src/dv/dv.h b/src/dv/dv.h
index 1c087f6d7..8f0de1825 100644
--- a/src/dv/dv.h
+++ b/src/dv/dv.h
@@ -28,13 +28,13 @@
28 28
29#include "gnunet_common.h" 29#include "gnunet_common.h"
30 30
31#define DEBUG_DV_GOSSIP GNUNET_YES 31#define DEBUG_DV_GOSSIP GNUNET_NO
32#define DEBUG_DV_GOSSIP_SEND GNUNET_NO 32#define DEBUG_DV_GOSSIP_SEND GNUNET_NO
33#define DEBUG_DV_GOSSIP_RECEIPT GNUNET_NO 33#define DEBUG_DV_GOSSIP_RECEIPT GNUNET_NO
34#define DEBUG_DV_MESSAGES GNUNET_NO 34#define DEBUG_DV_MESSAGES GNUNET_YES
35#define DEBUG_DV GNUNET_NO 35#define DEBUG_DV GNUNET_NO
36#define DEBUG_DV_PEER_NUMBERS GNUNET_NO 36#define DEBUG_DV_PEER_NUMBERS GNUNET_NO
37#define DEBUG_MESSAGE_DROP GNUNET_YES 37#define DEBUG_MESSAGE_DROP GNUNET_NO
38 38
39typedef void (*GNUNET_DV_MessageReceivedHandler) (void *cls, 39typedef void (*GNUNET_DV_MessageReceivedHandler) (void *cls,
40 struct GNUNET_PeerIdentity *sender, 40 struct GNUNET_PeerIdentity *sender,
@@ -229,7 +229,7 @@ typedef struct
229{ 229{
230 struct GNUNET_MessageHeader header; 230 struct GNUNET_MessageHeader header;
231 231
232#if TRACK_MESSAGES 232#if DEBUG_DV_MESSAGES
233 /** 233 /**
234 * Unique ID for this message. 234 * Unique ID for this message.
235 */ 235 */
diff --git a/src/dv/dv_api.c b/src/dv/dv_api.c
index 25905828b..12801dcd7 100644
--- a/src/dv/dv_api.c
+++ b/src/dv/dv_api.c
@@ -345,10 +345,6 @@ void handle_message_receipt (void *cls,
345 GNUNET_HashCode uidhash; 345 GNUNET_HashCode uidhash;
346 struct SendCallbackContext *send_ctx; 346 struct SendCallbackContext *send_ctx;
347 347
348#if DEBUG_DV
349 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "dv api receives message!\n");
350#endif
351
352 if (msg == NULL) 348 if (msg == NULL)
353 { 349 {
354 return; /* Connection closed? */ 350 return; /* Connection closed? */
@@ -367,9 +363,6 @@ void handle_message_receipt (void *cls,
367 sender_address_len = ntohl(received_msg->sender_address_len); 363 sender_address_len = ntohl(received_msg->sender_address_len);
368 364
369 GNUNET_assert(ntohs(msg->size) == (sizeof(struct GNUNET_DV_MessageReceived) + packed_msg_len + sender_address_len)); 365 GNUNET_assert(ntohs(msg->size) == (sizeof(struct GNUNET_DV_MessageReceived) + packed_msg_len + sender_address_len));
370#if DEBUG_DV
371 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "dv api receives message, size checks out!\n");
372#endif
373 sender_address = GNUNET_malloc(sender_address_len); 366 sender_address = GNUNET_malloc(sender_address_len);
374 memcpy(sender_address, &received_msg[1], sender_address_len); 367 memcpy(sender_address, &received_msg[1], sender_address_len);
375 packed_msg_start = (char *)&received_msg[1]; 368 packed_msg_start = (char *)&received_msg[1];
@@ -399,13 +392,9 @@ void handle_message_receipt (void *cls,
399 send_result_msg = (struct GNUNET_DV_SendResultMessage *)msg; 392 send_result_msg = (struct GNUNET_DV_SendResultMessage *)msg;
400 hash_from_uid(ntohl(send_result_msg->uid), &uidhash); 393 hash_from_uid(ntohl(send_result_msg->uid), &uidhash);
401 send_ctx = GNUNET_CONTAINER_multihashmap_get(handle->send_callbacks, &uidhash); 394 send_ctx = GNUNET_CONTAINER_multihashmap_get(handle->send_callbacks, &uidhash);
402 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "got uid of %u or %u, hash of %s !!!!\n", ntohl(send_result_msg->uid), send_result_msg->uid, GNUNET_h2s(&uidhash));
403 395
404 if ((send_ctx != NULL) && (send_ctx->cont != NULL)) 396 if ((send_ctx != NULL) && (send_ctx->cont != NULL))
405 { 397 {
406#if DEBUG_DV
407 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "dv api notifies transport of send result (%u)!\n", ntohl(send_result_msg->result));
408#endif
409 if (ntohl(send_result_msg->result) == 0) 398 if (ntohl(send_result_msg->result) == 0)
410 { 399 {
411 send_ctx->cont(send_ctx->cont_cls, &send_ctx->target, GNUNET_OK); 400 send_ctx->cont(send_ctx->cont_cls, &send_ctx->target, GNUNET_OK);
@@ -458,7 +447,6 @@ int GNUNET_DV_send (struct GNUNET_DV_Handle *dv_handle,
458 GNUNET_HashCode uidhash; 447 GNUNET_HashCode uidhash;
459#if DEBUG_DV_MESSAGES 448#if DEBUG_DV_MESSAGES
460 dv_handle->uid_gen = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, UINT32_MAX); 449 dv_handle->uid_gen = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, UINT32_MAX);
461 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "GNUNET_DV_send called with message of size %d, address size %d, total size %d, uid %u\n", msgbuf_size, addrlen, sizeof(struct GNUNET_DV_SendMessage) + msgbuf_size + addrlen, dv_handle->uid_gen);
462#else 450#else
463 dv_handle->uid_gen++; 451 dv_handle->uid_gen++;
464#endif 452#endif
diff --git a/src/dv/gnunet-service-dv.c b/src/dv/gnunet-service-dv.c
index 99358b565..932784fcb 100644
--- a/src/dv/gnunet-service-dv.c
+++ b/src/dv/gnunet-service-dv.c
@@ -521,6 +521,13 @@ struct DV_SendContext
521 * Timeout for this message 521 * Timeout for this message
522 */ 522 */
523 struct GNUNET_TIME_Relative timeout; 523 struct GNUNET_TIME_Relative timeout;
524
525#if DEBUG_DV_MESSAGES
526 /**
527 * Unique ID for DV message
528 */
529 unsigned int uid;
530#endif
524}; 531};
525 532
526/** 533/**
@@ -957,12 +964,16 @@ send_message_via (const struct GNUNET_PeerIdentity *sender,
957 toSend->header.type = htons (GNUNET_MESSAGE_TYPE_DV_DATA); 964 toSend->header.type = htons (GNUNET_MESSAGE_TYPE_DV_DATA);
958 toSend->sender = htonl (sender_id); 965 toSend->sender = htonl (sender_id);
959 toSend->recipient = htonl (recipient_id); 966 toSend->recipient = htonl (recipient_id);
967#if DEBUG_DV_MESSAGES
968 toSend->uid = send_context->uid; /* Still sent around in network byte order */
969#endif
970
960 memcpy (&toSend[1], send_context->message, send_context->message_size); 971 memcpy (&toSend[1], send_context->message, send_context->message_size);
961 972
962#if DEBUG_DV 973#if DEBUG_DV
963 memcpy(&shortname, GNUNET_i2s(&specific_neighbor->identity), 4); 974 memcpy(&shortname, GNUNET_i2s(send_context->distant_peer), 4);
964 shortname[4] = '\0'; 975 shortname[4] = '\0';
965 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: Notifying core of send to destination `%s' via `%s' size %u\n", "DV", &shortname, GNUNET_i2s(&specific_neighbor->referrer->identity), msg_size); 976 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: Notifying core of send to destination `%s' via `%s' size %u\n", "DV", &shortname, GNUNET_i2s(recipient), msg_size);
966#endif 977#endif
967 978
968 GNUNET_CONTAINER_DLL_insert_after (core_pending_head, 979 GNUNET_CONTAINER_DLL_insert_after (core_pending_head,
@@ -973,8 +984,11 @@ send_message_via (const struct GNUNET_PeerIdentity *sender,
973 if (core_transmit_handle == NULL) 984 if (core_transmit_handle == NULL)
974 core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, send_context->importance, send_context->timeout, recipient, msg_size, &core_transmit_notify, NULL); 985 core_transmit_handle = GNUNET_CORE_notify_transmit_ready(coreAPI, send_context->importance, send_context->timeout, recipient, msg_size, &core_transmit_notify, NULL);
975 else 986 else
976 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "`%s': Failed to schedule pending transmission (must be one in progress!)\n", "dv service"); 987 {
977 988#if DEBUG_DV
989 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "`%s': Failed to schedule pending transmission (must be one in progress!)\n", "dv service");
990#endif
991 }
978 return GNUNET_YES; 992 return GNUNET_YES;
979} 993}
980 994
@@ -1026,6 +1040,9 @@ find_least_cost_peer (void *cls,
1026 * @param message the packed message 1040 * @param message the packed message
1027 * @param message_size size of the message 1041 * @param message_size size of the message
1028 * @param importance what priority to send this message with 1042 * @param importance what priority to send this message with
1043#if DEBUG_DV_MESSAGES
1044 * @param uid unique id for this message
1045#endif
1029 * @param timeout how long to possibly delay sending this message 1046 * @param timeout how long to possibly delay sending this message
1030 */ 1047 */
1031static int 1048static int
@@ -1034,7 +1051,11 @@ send_message (const struct GNUNET_PeerIdentity * recipient,
1034 const struct DistantNeighbor * specific_neighbor, 1051 const struct DistantNeighbor * specific_neighbor,
1035 const struct GNUNET_MessageHeader * message, 1052 const struct GNUNET_MessageHeader * message,
1036 size_t message_size, 1053 size_t message_size,
1037 unsigned int importance, struct GNUNET_TIME_Relative timeout) 1054 unsigned int importance,
1055#if DEBUG_DV_MESSAGES
1056 unsigned int uid,
1057#endif
1058 struct GNUNET_TIME_Relative timeout)
1038{ 1059{
1039 p2p_dv_MESSAGE_Data *toSend; 1060 p2p_dv_MESSAGE_Data *toSend;
1040 unsigned int msg_size; 1061 unsigned int msg_size;
@@ -1114,6 +1135,9 @@ send_message (const struct GNUNET_PeerIdentity * recipient,
1114 toSend->header.type = htons (GNUNET_MESSAGE_TYPE_DV_DATA); 1135 toSend->header.type = htons (GNUNET_MESSAGE_TYPE_DV_DATA);
1115 toSend->sender = htonl (sender_id); 1136 toSend->sender = htonl (sender_id);
1116 toSend->recipient = htonl (recipient_id); 1137 toSend->recipient = htonl (recipient_id);
1138#if DEBUG_DV_MESSAGES
1139 toSend->uid = htonl(uid);
1140#endif
1117#if DEBUG_DV_PEER_NUMBERS 1141#if DEBUG_DV_PEER_NUMBERS
1118 GNUNET_CRYPTO_hash_to_enc (&target->identity.hashPubKey, &encPeerTo); 1142 GNUNET_CRYPTO_hash_to_enc (&target->identity.hashPubKey, &encPeerTo);
1119 encPeerTo.encoding[4] = '\0'; 1143 encPeerTo.encoding[4] = '\0';
@@ -1206,9 +1230,7 @@ static int handle_dv_data_message (void *cls,
1206 struct CheckPeerContext checkPeerCtx; 1230 struct CheckPeerContext checkPeerCtx;
1207#endif 1231#endif
1208 char *sender_id; 1232 char *sender_id;
1209
1210 char *direct_id; 1233 char *direct_id;
1211
1212 int ret; 1234 int ret;
1213 size_t packed_message_size; 1235 size_t packed_message_size;
1214 char *cbuf; 1236 char *cbuf;
@@ -1299,9 +1321,9 @@ static int handle_dv_data_message (void *cls,
1299 { 1321 {
1300 packed_message = (struct GNUNET_MessageHeader *)&cbuf[offset]; 1322 packed_message = (struct GNUNET_MessageHeader *)&cbuf[offset];
1301 1323
1302#if DEBUG_DV 1324#if DEBUG_DV_MESSAGES
1303 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1325 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1304 "%s: Receives %s message for me, size %d type %d, cost %u!\n", "dv", "DV DATA", ntohs(packed_message->size), ntohs(packed_message->type), pos->cost); 1326 "%s: Receives %s message for me, uid %u, size %d type %d, cost %u from %s!\n", my_short_id, "DV DATA", ntohl(incoming->uid), ntohs(packed_message->size), ntohs(packed_message->type), pos->cost, GNUNET_i2s(&pos->identity));
1305#endif 1327#endif
1306 GNUNET_break_op (ntohs (packed_message->type) != GNUNET_MESSAGE_TYPE_DV_GOSSIP); 1328 GNUNET_break_op (ntohs (packed_message->type) != GNUNET_MESSAGE_TYPE_DV_GOSSIP);
1307 GNUNET_break_op (ntohs (packed_message->type) != GNUNET_MESSAGE_TYPE_DV_DATA); 1329 GNUNET_break_op (ntohs (packed_message->type) != GNUNET_MESSAGE_TYPE_DV_DATA);
@@ -1337,9 +1359,9 @@ static int handle_dv_data_message (void *cls,
1337 1359
1338 if (fdc.dest == NULL) 1360 if (fdc.dest == NULL)
1339 { 1361 {
1340#if DEBUG_DV 1362#if DEBUG_DV_MESSAGES
1341 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1363 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1342 "%s: Receives %s message for someone else that we don't know (id %u)!\n", "dv", "DV DATA", tid); 1364 "%s: Receives %s message uid %u for someone we don't know (id %u)!\n", my_short_id, "DV DATA", ntohl(incoming->uid), tid);
1343#endif 1365#endif
1344 return GNUNET_OK; 1366 return GNUNET_OK;
1345 } 1367 }
@@ -1352,10 +1374,10 @@ static int handle_dv_data_message (void *cls,
1352 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "\n\n\nLoopy loo message\n\n\n"); 1374 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "\n\n\nLoopy loo message\n\n\n");
1353#endif 1375#endif
1354 1376
1355#if DEBUG_MESSAGE_DROP 1377#if DEBUG_DV_MESSAGES
1356 direct_id = GNUNET_strdup(GNUNET_i2s(&dn->identity)); 1378 direct_id = GNUNET_strdup(GNUNET_i2s(&dn->identity));
1357 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1379 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1358 "%s: DROPPING MESSAGE type %d, routing loop! Message immediately from %s!\n", GNUNET_i2s(&my_identity), ntohs(((struct GNUNET_MessageHeader *)&incoming[1])->type), direct_id); 1380 "%s: DROPPING MESSAGE uid %u type %d, routing loop! Message immediately from %s!\n", my_short_id, ntohl(incoming->uid), ntohs(packed_message->type), direct_id);
1359#endif 1381#endif
1360 return GNUNET_OK; 1382 return GNUNET_OK;
1361 } 1383 }
@@ -1370,11 +1392,21 @@ static int handle_dv_data_message (void *cls,
1370 &original_sender, 1392 &original_sender,
1371 packed_message, DV_PRIORITY, DV_DELAY);*/ 1393 packed_message, DV_PRIORITY, DV_DELAY);*/
1372 1394
1373#if DEBUG_DV 1395#if DEBUG_DV_MESSAGES
1374 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1396 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1375 "%s: Sends message size %d on!\n", "dv", packed_message_size); 1397 "%s: FORWARD %s message for %s, uid %u, size %d type %d, cost %u!\n", my_short_id, "DV DATA", GNUNET_i2s(&destination), ntohl(incoming->uid), ntohs(packed_message->size), ntohs(packed_message->type), pos->cost);
1398#endif
1399
1400 ret = send_message(&destination,
1401 &original_sender,
1402 NULL,
1403 packed_message,
1404 packed_message_size,
1405 default_dv_priority,
1406#if DEBUG_DV_MESSAGES
1407 ntohl(incoming->uid),
1376#endif 1408#endif
1377 ret = send_message(&destination, &original_sender, NULL, packed_message, packed_message_size, default_dv_priority, GNUNET_TIME_relative_get_forever()); 1409 GNUNET_TIME_relative_get_forever());
1378 1410
1379 if (ret != GNUNET_SYSERR) 1411 if (ret != GNUNET_SYSERR)
1380 return GNUNET_OK; 1412 return GNUNET_OK;
@@ -1612,10 +1644,13 @@ void handle_dv_send_message (void *cls,
1612 struct GNUNET_PeerIdentity *direct; 1644 struct GNUNET_PeerIdentity *direct;
1613 struct GNUNET_MessageHeader *message_buf; 1645 struct GNUNET_MessageHeader *message_buf;
1614 char *temp_pos; 1646 char *temp_pos;
1615
1616 int offset; 1647 int offset;
1617 static struct GNUNET_CRYPTO_HashAsciiEncoded dest_hash; 1648 static struct GNUNET_CRYPTO_HashAsciiEncoded dest_hash;
1618 struct DV_SendContext *send_context; 1649 struct DV_SendContext *send_context;
1650#if DEBUG_DV_MESSAGES
1651 char *cbuf;
1652 struct GNUNET_MessageHeader *packed_message;
1653#endif
1619 1654
1620 if (client_handle == NULL) 1655 if (client_handle == NULL)
1621 { 1656 {
@@ -1663,12 +1698,19 @@ void handle_dv_send_message (void *cls,
1663 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s: asked to send message to `%s', but address is for `%s'!", "DV SERVICE", GNUNET_i2s(&send_msg->target), (const char *)&dest_hash.encoding); 1698 GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "%s: asked to send message to `%s', but address is for `%s'!", "DV SERVICE", GNUNET_i2s(&send_msg->target), (const char *)&dest_hash.encoding);
1664 } 1699 }
1665 1700
1666
1667 GNUNET_CRYPTO_hash_to_enc (&destination->hashPubKey, &dest_hash); /* GNUNET_i2s won't properly work, need to hash one ourselves */
1668 dest_hash.encoding[4] = '\0';
1669#if DEBUG_DV_MESSAGES 1701#if DEBUG_DV_MESSAGES
1670 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s DV SEND called with message of size %d type %d, destination `%s' via `%s'\n", my_short_id, message_size, ntohs(message_buf->type), (const char *)&dest_hash.encoding, GNUNET_i2s(direct)); 1702 cbuf = (char *)message_buf;
1703 offset = 0;
1704 while(offset < message_size)
1705 {
1706 packed_message = (struct GNUNET_MessageHeader *)&cbuf[offset];
1707 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: DV PLUGIN SEND uid %u type %d to %s\n", my_short_id, ntohl(send_msg->uid), ntohs(packed_message->type), GNUNET_i2s(destination));
1708 offset += ntohs(packed_message->size);
1709 }
1710 /*GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: DV PLUGIN SEND uid %u type %d to %s\n", my_short_id, ntohl(send_msg->uid), ntohs(message_buf->type), GNUNET_i2s(destination));*/
1671#endif 1711#endif
1712 GNUNET_CRYPTO_hash_to_enc (&destination->hashPubKey, &dest_hash); /* GNUNET_i2s won't properly work, need to hash one ourselves */
1713 dest_hash.encoding[4] = '\0';
1672 send_context = GNUNET_malloc(sizeof(struct DV_SendContext)); 1714 send_context = GNUNET_malloc(sizeof(struct DV_SendContext));
1673 1715
1674 send_result_msg = GNUNET_malloc(sizeof(struct GNUNET_DV_SendResultMessage)); 1716 send_result_msg = GNUNET_malloc(sizeof(struct GNUNET_DV_SendResultMessage));
@@ -1683,6 +1725,9 @@ void handle_dv_send_message (void *cls,
1683 send_context->message = message_buf; 1725 send_context->message = message_buf;
1684 send_context->message_size = message_size; 1726 send_context->message_size = message_size;
1685 send_context->send_result = send_result_msg; 1727 send_context->send_result = send_result_msg;
1728#if DEBUG_DV_MESSAGES
1729 send_context->uid = send_msg->uid;
1730#endif
1686 1731
1687 if (send_message_via(&my_identity, direct, send_context) != GNUNET_YES) 1732 if (send_message_via(&my_identity, direct, send_context) != GNUNET_YES)
1688 { 1733 {
@@ -1922,6 +1967,7 @@ static int free_direct_neighbors (void *cls,
1922 return GNUNET_YES; 1967 return GNUNET_YES;
1923} 1968}
1924 1969
1970
1925/** 1971/**
1926 * Task run during shutdown. 1972 * Task run during shutdown.
1927 * 1973 *
@@ -2268,6 +2314,8 @@ generate_hello_address (void *cls, size_t max, void *buf)
2268 size_t offset; 2314 size_t offset;
2269 size_t size; 2315 size_t size;
2270 size_t ret; 2316 size_t ret;
2317 char *addr1;
2318 char *addr2;
2271 2319
2272 if (hello_context->addresses_to_add == 0) 2320 if (hello_context->addresses_to_add == 0)
2273 return 0; 2321 return 0;
@@ -2283,6 +2331,11 @@ generate_hello_address (void *cls, size_t max, void *buf)
2283 offset += sizeof(struct GNUNET_PeerIdentity); 2331 offset += sizeof(struct GNUNET_PeerIdentity);
2284 /* Copy the direct peer identity to buffer */ 2332 /* Copy the direct peer identity to buffer */
2285 memcpy(&addr_buffer[offset], hello_context->direct_peer, sizeof(struct GNUNET_PeerIdentity)); 2333 memcpy(&addr_buffer[offset], hello_context->direct_peer, sizeof(struct GNUNET_PeerIdentity));
2334 addr1 = GNUNET_strdup(GNUNET_i2s(hello_context->direct_peer));
2335 addr2 = GNUNET_strdup(GNUNET_i2s(&hello_context->distant_peer));
2336 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: GIVING HELLO %s%s%s to TRANSPORT\n", my_short_id,my_short_id, addr1, addr2);
2337 GNUNET_free(addr1);
2338 GNUNET_free(addr2);
2286 ret = GNUNET_HELLO_add_address ("dv", 2339 ret = GNUNET_HELLO_add_address ("dv",
2287 GNUNET_TIME_relative_to_absolute 2340 GNUNET_TIME_relative_to_absolute
2288 (GNUNET_TIME_UNIT_HOURS), addr_buffer, size, 2341 (GNUNET_TIME_UNIT_HOURS), addr_buffer, size,
@@ -2442,6 +2495,51 @@ static int add_all_extended_peers (void *cls,
2442 return GNUNET_YES; 2495 return GNUNET_YES;
2443} 2496}
2444 2497
2498#if INSANE_GOSSIP
2499/**
2500 * Iterator over hash map entries.
2501 *
2502 * @param cls closure
2503 * @param key current key code
2504 * @param value value in the hash map
2505 * @return GNUNET_YES if we should continue to
2506 * iterate,
2507 * GNUNET_NO if not.
2508 */
2509static int gossip_all_to_all_iterator (void *cls,
2510 const GNUNET_HashCode * key,
2511 void *value)
2512{
2513 struct DirectNeighbor *direct = value;
2514
2515 GNUNET_CONTAINER_multihashmap_iterate (ctx.extended_neighbors, &add_all_extended_peers, direct->send_context);
2516
2517 if (direct->send_context->task != GNUNET_SCHEDULER_NO_TASK)
2518 GNUNET_SCHEDULER_cancel(sched, direct->send_context->task);
2519
2520 direct->send_context->task = GNUNET_SCHEDULER_add_now(sched, &neighbor_send_task, direct->send_context);
2521 return GNUNET_YES;
2522}
2523
2524/**
2525 * Task run during shutdown.
2526 *
2527 * @param cls unused
2528 * @param tc unused
2529 */
2530static void
2531gossip_all_to_all (void *cls,
2532 const struct GNUNET_SCHEDULER_TaskContext *tc)
2533{
2534 GNUNET_CONTAINER_multihashmap_iterate (ctx.direct_neighbors, &gossip_all_to_all_iterator, NULL);
2535
2536 GNUNET_SCHEDULER_add_delayed (sched,
2537 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5),
2538 &gossip_all_to_all,
2539 NULL);
2540
2541}
2542#endif
2445/** 2543/**
2446 * Iterate over all current direct peers, add newly connected peer 2544 * Iterate over all current direct peers, add newly connected peer
2447 * to the fast gossip list for that peer so we get DV routing 2545 * to the fast gossip list for that peer so we get DV routing
@@ -2769,6 +2867,12 @@ run (void *cls,
2769 GNUNET_TIME_UNIT_FOREVER_REL, 2867 GNUNET_TIME_UNIT_FOREVER_REL,
2770 &shutdown_task, 2868 &shutdown_task,
2771 NULL); 2869 NULL);
2870#if INSANE_GOSSIP
2871 GNUNET_SCHEDULER_add_delayed (sched,
2872 GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5),
2873 &gossip_all_to_all,
2874 NULL);
2875#endif
2772} 2876}
2773 2877
2774 2878
diff --git a/src/dv/plugin_transport_dv.c b/src/dv/plugin_transport_dv.c
index 43bbfad33..c35380bd0 100644
--- a/src/dv/plugin_transport_dv.c
+++ b/src/dv/plugin_transport_dv.c
@@ -240,24 +240,7 @@ dv_plugin_send (void *cls,
240{ 240{
241 int ret = 0; 241 int ret = 0;
242 struct Plugin *plugin = cls; 242 struct Plugin *plugin = cls;
243 const char *tempbuf; 243
244 int temp_size;
245#if DEBUG_DV
246 char *my_identity;
247 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "DV API: Received send request from transport, calling GNUNET_DV_send\n");
248 my_identity = GNUNET_strdup(GNUNET_i2s(plugin->env->my_identity));
249#endif
250 temp_size = htons(((struct GNUNET_MessageHeader *)msgbuf)->size);
251 if (msgbuf_size > temp_size)
252 {
253 tempbuf = &msgbuf[temp_size];
254#if DEBUG_DV
255 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s DV PLUGIN SEND SPECIAL type %d to %s\n", my_identity, ntohs(((struct GNUNET_MessageHeader *)tempbuf)->type), GNUNET_i2s(target));
256#endif
257 }
258#if DEBUG_DV
259 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s DV PLUGIN SEND type %d to %s\n", my_identity, ntohs(((struct GNUNET_MessageHeader *)msgbuf)->type), GNUNET_i2s(target));
260#endif
261 ret = GNUNET_DV_send(plugin->dv_handle, 244 ret = GNUNET_DV_send(plugin->dv_handle,
262 target, 245 target,
263 msgbuf, 246 msgbuf,
@@ -287,7 +270,7 @@ dv_plugin_send (void *cls,
287 */ 270 */
288static void 271static void
289dv_plugin_disconnect (void *cls, 272dv_plugin_disconnect (void *cls,
290 const struct GNUNET_PeerIdentity *target) 273 const struct GNUNET_PeerIdentity *target)
291{ 274{
292 // struct Plugin *plugin = cls; 275 // struct Plugin *plugin = cls;
293 // TODO: Add message type to send to dv service to "disconnect" a peer 276 // TODO: Add message type to send to dv service to "disconnect" a peer
@@ -318,7 +301,25 @@ dv_plugin_address_pretty_printer (void *cls,
318 GNUNET_TRANSPORT_AddressStringCallback 301 GNUNET_TRANSPORT_AddressStringCallback
319 asc, void *asc_cls) 302 asc, void *asc_cls)
320{ 303{
321 asc (asc_cls, NULL); 304 char *dest_peer;
305 char *via_peer;
306 char *print_string;
307 char *addr_buf = (char *)addr;
308
309 if (addrlen != sizeof(struct GNUNET_PeerIdentity) * 2)
310 {
311 asc (asc_cls, NULL);
312 }
313 else
314 {
315 dest_peer = GNUNET_strdup(GNUNET_i2s((struct GNUNET_PeerIdentity *)addr));
316 via_peer = GNUNET_strdup(GNUNET_i2s((struct GNUNET_PeerIdentity *)&addr_buf[sizeof(struct GNUNET_PeerIdentity)]));
317 GNUNET_asprintf(&print_string, "DV Peer `%s' via peer`%s'", dest_peer, via_peer);
318 asc (asc_cls, print_string);
319 asc (asc_cls, NULL);
320 GNUNET_free(dest_peer);
321 GNUNET_free(print_string);
322 }
322} 323}
323 324
324/** 325/**
diff --git a/src/dv/test_transport_api_dv.c b/src/dv/test_transport_api_dv.c
index fdf3ba2df..e0d956e86 100644
--- a/src/dv/test_transport_api_dv.c
+++ b/src/dv/test_transport_api_dv.c
@@ -296,12 +296,13 @@ process_mtype (void *cls,
296 if (pos->uid != ntohl(msg->uid)) 296 if (pos->uid != ntohl(msg->uid))
297 return GNUNET_OK; 297 return GNUNET_OK;
298 298
299 GNUNET_assert(0 == memcmp(peer, &pos->peer1->id, sizeof(struct GNUNET_PeerIdentity)));
299 if (total_other_expected_messages == 0) 300 if (total_other_expected_messages == 0)
300 { 301 {
301 total_messages_received++; 302 total_messages_received++;
302#if VERBOSE 303#if VERBOSE
303 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 304 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
304 "Received message from `%4s', type %d, distance %u.\n", GNUNET_i2s (peer), ntohs(message->type), distance); 305 "Received message from `%4s', type %d, uid %u, distance %u.\n", GNUNET_i2s (peer), ntohs(message->type), ntohl(msg->uid), distance);
305 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 306 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
306 "Total messages received %d, expected %d.\n", total_messages_received, expected_messages); 307 "Total messages received %d, expected %d.\n", total_messages_received, expected_messages);
307#endif 308#endif
@@ -311,7 +312,7 @@ process_mtype (void *cls,
311 total_other_messages++; 312 total_other_messages++;
312#if VERBOSE 313#if VERBOSE
313 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 314 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
314 "Received message from `%4s', type %d, distance %u.\n", GNUNET_i2s (peer), ntohs(message->type), distance); 315 "Received message from `%4s', type %d, uid %u, distance %u.\n", GNUNET_i2s (peer), ntohs(message->type), ntohl(msg->uid), distance);
315 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 316 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
316 "Total messages received %d, expected %d.\n", total_other_messages, total_other_expected_messages); 317 "Total messages received %d, expected %d.\n", total_other_messages, total_other_expected_messages);
317#endif 318#endif
@@ -320,7 +321,7 @@ process_mtype (void *cls,
320 if ((total_messages_received == expected_messages) && (total_other_messages == 0)) 321 if ((total_messages_received == expected_messages) && (total_other_messages == 0))
321 { 322 {
322 GNUNET_SCHEDULER_cancel (sched, die_task); 323 GNUNET_SCHEDULER_cancel (sched, die_task);
323 GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 40), &send_other_messages, NULL); 324 GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 45), &send_other_messages, NULL);
324 } 325 }
325 else if ((total_other_expected_messages > 0) && (total_other_messages == total_other_expected_messages)) 326 else if ((total_other_expected_messages > 0) && (total_other_messages == total_other_expected_messages))
326 { 327 {
@@ -801,7 +802,7 @@ static void all_connect_handler (void *cls,
801 temp_context->peer1 = d; 802 temp_context->peer1 = d;
802 temp_context->peer2 = second_daemon; 803 temp_context->peer2 = second_daemon;
803 temp_context->next = other_test_messages; 804 temp_context->next = other_test_messages;
804 temp_context->uid = total_connections; 805 temp_context->uid = total_connections + temp_total_other_messages;
805 temp_context->disconnect_task = GNUNET_SCHEDULER_NO_TASK; 806 temp_context->disconnect_task = GNUNET_SCHEDULER_NO_TASK;
806 other_test_messages = temp_context; 807 other_test_messages = temp_context;
807 } 808 }
@@ -818,6 +819,8 @@ static void all_connect_handler (void *cls,
818 fprintf(dotOutFile, "\tn%s -- n%s [color=red];\n", d->shortname, second_shortname); 819 fprintf(dotOutFile, "\tn%s -- n%s [color=red];\n", d->shortname, second_shortname);
819 else if (distance == 4) 820 else if (distance == 4)
820 fprintf(dotOutFile, "\tn%s -- n%s [color=green];\n", d->shortname, second_shortname); 821 fprintf(dotOutFile, "\tn%s -- n%s [color=green];\n", d->shortname, second_shortname);
822 else
823 fprintf(dotOutFile, "\tn%s -- n%s [color=brown];\n", d->shortname, second_shortname);
821 } 824 }
822 GNUNET_free(second_shortname); 825 GNUNET_free(second_shortname);
823} 826}
diff --git a/src/dv/test_transport_dv_data.conf b/src/dv/test_transport_dv_data.conf
index 848f9170a..3eeccec5e 100644
--- a/src/dv/test_transport_dv_data.conf
+++ b/src/dv/test_transport_dv_data.conf
@@ -43,7 +43,7 @@ PORT = 2570
43 43
44[dv] 44[dv]
45AUTOSTART = YES 45AUTOSTART = YES
46DEBUG = NO 46DEBUG = YES
47ACCEPT_FROM6 = ::1; 47ACCEPT_FROM6 = ::1;
48ACCEPT_FROM = 127.0.0.1; 48ACCEPT_FROM = 127.0.0.1;
49BINARY = gnunet-service-dv 49BINARY = gnunet-service-dv
@@ -57,7 +57,7 @@ HOSTNAME = localhost
57PORT = 2571 57PORT = 2571
58 58
59[testing] 59[testing]
60NUM_PEERS = 5 60NUM_PEERS = 10
61DEBUG = YES 61DEBUG = YES
62WEAKRANDOM = YES 62WEAKRANDOM = YES
63TOPOLOGY = CLIQUE 63TOPOLOGY = CLIQUE