diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
commit | 5746309cb4be2073d550ad7a6885e918631dbc38 (patch) | |
tree | 89455bc4aadf977816b38df13f990372cd81d71a /src/dv | |
parent | 6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff) | |
download | gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip |
indentation
Diffstat (limited to 'src/dv')
-rw-r--r-- | src/dv/dv_api.c | 49 | ||||
-rw-r--r-- | src/dv/gnunet-service-dv.c | 280 | ||||
-rw-r--r-- | src/dv/plugin_transport_dv.c | 50 | ||||
-rw-r--r-- | src/dv/test_transport_api_dv.c | 183 |
4 files changed, 233 insertions, 329 deletions
diff --git a/src/dv/dv_api.c b/src/dv/dv_api.c index 7a250b5a6..3450e5844 100644 --- a/src/dv/dv_api.c +++ b/src/dv/dv_api.c | |||
@@ -282,15 +282,13 @@ process_pending_message (struct GNUNET_DV_Handle *handle) | |||
282 | handle->current->next = NULL; | 282 | handle->current->next = NULL; |
283 | 283 | ||
284 | if (NULL == | 284 | if (NULL == |
285 | (handle->th = GNUNET_CLIENT_notify_transmit_ready (handle->client, | 285 | (handle->th = |
286 | ntohs | 286 | GNUNET_CLIENT_notify_transmit_ready (handle->client, |
287 | (handle->current-> | 287 | ntohs (handle->current->msg->header. |
288 | msg->header.size), | 288 | size), |
289 | handle->current-> | 289 | handle->current->msg->timeout, |
290 | msg->timeout, | 290 | GNUNET_YES, &transmit_pending, |
291 | GNUNET_YES, | 291 | handle))) |
292 | &transmit_pending, | ||
293 | handle))) | ||
294 | { | 292 | { |
295 | #if DEBUG_DV | 293 | #if DEBUG_DV |
296 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 294 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -397,12 +395,10 @@ handle_message_receipt (void *cls, const struct GNUNET_MessageHeader *msg) | |||
397 | ntohl (received_msg->distance)); | 395 | ntohl (received_msg->distance)); |
398 | #endif | 396 | #endif |
399 | 397 | ||
400 | handle->receive_handler (handle->receive_cls, | 398 | handle->receive_handler (handle->receive_cls, &received_msg->sender, |
401 | &received_msg->sender, | 399 | packed_msg, packed_msg_len, |
402 | packed_msg, | 400 | ntohl (received_msg->distance), sender_address, |
403 | packed_msg_len, | 401 | sender_address_len); |
404 | ntohl (received_msg->distance), | ||
405 | sender_address, sender_address_len); | ||
406 | 402 | ||
407 | GNUNET_free (sender_address); | 403 | GNUNET_free (sender_address); |
408 | break; | 404 | break; |
@@ -431,9 +427,8 @@ handle_message_receipt (void *cls, const struct GNUNET_MessageHeader *msg) | |||
431 | default: | 427 | default: |
432 | break; | 428 | break; |
433 | } | 429 | } |
434 | GNUNET_CLIENT_receive (handle->client, | 430 | GNUNET_CLIENT_receive (handle->client, &handle_message_receipt, handle, |
435 | &handle_message_receipt, | 431 | GNUNET_TIME_UNIT_FOREVER_REL); |
436 | handle, GNUNET_TIME_UNIT_FOREVER_REL); | ||
437 | } | 432 | } |
438 | 433 | ||
439 | /** | 434 | /** |
@@ -454,14 +449,11 @@ handle_message_receipt (void *cls, const struct GNUNET_MessageHeader *msg) | |||
454 | */ | 449 | */ |
455 | int | 450 | int |
456 | GNUNET_DV_send (struct GNUNET_DV_Handle *dv_handle, | 451 | GNUNET_DV_send (struct GNUNET_DV_Handle *dv_handle, |
457 | const struct GNUNET_PeerIdentity *target, | 452 | const struct GNUNET_PeerIdentity *target, const char *msgbuf, |
458 | const char *msgbuf, | 453 | size_t msgbuf_size, unsigned int priority, |
459 | size_t msgbuf_size, | 454 | struct GNUNET_TIME_Relative timeout, const void *addr, |
460 | unsigned int priority, | 455 | size_t addrlen, GNUNET_TRANSPORT_TransmitContinuation cont, |
461 | struct GNUNET_TIME_Relative timeout, | 456 | void *cont_cls) |
462 | const void *addr, | ||
463 | size_t addrlen, | ||
464 | GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) | ||
465 | { | 457 | { |
466 | struct GNUNET_DV_SendMessage *msg; | 458 | struct GNUNET_DV_SendMessage *msg; |
467 | struct SendCallbackContext *send_ctx; | 459 | struct SendCallbackContext *send_ctx; |
@@ -537,9 +529,8 @@ transmit_start (void *cls, size_t size, void *buf) | |||
537 | memcpy (buf, start_context->message, tsize); | 529 | memcpy (buf, start_context->message, tsize); |
538 | GNUNET_free (start_context->message); | 530 | GNUNET_free (start_context->message); |
539 | GNUNET_free (start_context); | 531 | GNUNET_free (start_context); |
540 | GNUNET_CLIENT_receive (handle->client, | 532 | GNUNET_CLIENT_receive (handle->client, &handle_message_receipt, handle, |
541 | &handle_message_receipt, | 533 | GNUNET_TIME_UNIT_FOREVER_REL); |
542 | handle, GNUNET_TIME_UNIT_FOREVER_REL); | ||
543 | 534 | ||
544 | 535 | ||
545 | return tsize; | 536 | return tsize; |
diff --git a/src/dv/gnunet-service-dv.c b/src/dv/gnunet-service-dv.c index 4b68f69b1..876d056ac 100644 --- a/src/dv/gnunet-service-dv.c +++ b/src/dv/gnunet-service-dv.c | |||
@@ -662,8 +662,7 @@ static unsigned long long max_table_size; | |||
662 | * respective neighbor. | 662 | * respective neighbor. |
663 | */ | 663 | */ |
664 | static int | 664 | static int |
665 | find_destination (void *cls, | 665 | find_destination (void *cls, struct GNUNET_CONTAINER_HeapNode *node, |
666 | struct GNUNET_CONTAINER_HeapNode *node, | ||
667 | void *element, GNUNET_CONTAINER_HeapCostType cost) | 666 | void *element, GNUNET_CONTAINER_HeapCostType cost) |
668 | { | 667 | { |
669 | struct FindDestinationContext *fdc = cls; | 668 | struct FindDestinationContext *fdc = cls; |
@@ -752,21 +751,20 @@ transmit_to_plugin (void *cls, size_t size, void *buf) | |||
752 | while ((NULL != (reply = plugin_pending_head)) && | 751 | while ((NULL != (reply = plugin_pending_head)) && |
753 | (size >= off + (msize = ntohs (reply->msg->size)))) | 752 | (size >= off + (msize = ntohs (reply->msg->size)))) |
754 | { | 753 | { |
755 | GNUNET_CONTAINER_DLL_remove (plugin_pending_head, | 754 | GNUNET_CONTAINER_DLL_remove (plugin_pending_head, plugin_pending_tail, |
756 | plugin_pending_tail, reply); | 755 | reply); |
757 | memcpy (&cbuf[off], reply->msg, msize); | 756 | memcpy (&cbuf[off], reply->msg, msize); |
758 | GNUNET_free (reply); | 757 | GNUNET_free (reply); |
759 | off += msize; | 758 | off += msize; |
760 | } | 759 | } |
761 | 760 | ||
762 | if (plugin_pending_head != NULL) | 761 | if (plugin_pending_head != NULL) |
763 | plugin_transmit_handle = GNUNET_SERVER_notify_transmit_ready (client_handle, | 762 | plugin_transmit_handle = |
764 | ntohs | 763 | GNUNET_SERVER_notify_transmit_ready (client_handle, |
765 | (plugin_pending_head->msg-> | 764 | ntohs (plugin_pending_head-> |
766 | size), | 765 | msg->size), |
767 | GNUNET_TIME_UNIT_FOREVER_REL, | 766 | GNUNET_TIME_UNIT_FOREVER_REL, |
768 | &transmit_to_plugin, | 767 | &transmit_to_plugin, NULL); |
769 | NULL); | ||
770 | 768 | ||
771 | return off; | 769 | return off; |
772 | } | 770 | } |
@@ -783,8 +781,7 @@ transmit_to_plugin (void *cls, size_t size, void *buf) | |||
783 | */ | 781 | */ |
784 | void | 782 | void |
785 | send_to_plugin (const struct GNUNET_PeerIdentity *sender, | 783 | send_to_plugin (const struct GNUNET_PeerIdentity *sender, |
786 | const struct GNUNET_MessageHeader *message, | 784 | const struct GNUNET_MessageHeader *message, size_t message_size, |
787 | size_t message_size, | ||
788 | struct GNUNET_PeerIdentity *distant_neighbor, size_t cost) | 785 | struct GNUNET_PeerIdentity *distant_neighbor, size_t cost) |
789 | { | 786 | { |
790 | struct GNUNET_DV_MessageReceived *received_msg; | 787 | struct GNUNET_DV_MessageReceived *received_msg; |
@@ -877,14 +874,13 @@ try_core_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
877 | return; /* Message send already in progress */ | 874 | return; /* Message send already in progress */ |
878 | 875 | ||
879 | if ((pending != NULL) && (coreAPI != NULL)) | 876 | if ((pending != NULL) && (coreAPI != NULL)) |
880 | core_transmit_handle = GNUNET_CORE_notify_transmit_ready (coreAPI, | 877 | core_transmit_handle = |
881 | GNUNET_YES, | 878 | GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_YES, |
882 | pending->importance, | 879 | pending->importance, |
883 | pending->timeout, | 880 | pending->timeout, |
884 | &pending->recipient, | 881 | &pending->recipient, |
885 | pending->msg_size, | 882 | pending->msg_size, |
886 | &core_transmit_notify, | 883 | &core_transmit_notify, NULL); |
887 | NULL); | ||
888 | } | 884 | } |
889 | 885 | ||
890 | 886 | ||
@@ -1003,9 +999,9 @@ send_message_via (const struct GNUNET_PeerIdentity *sender, | |||
1003 | find_context.via = recipient; | 999 | find_context.via = recipient; |
1004 | find_context.tid = 0; | 1000 | find_context.tid = 0; |
1005 | GNUNET_CONTAINER_multihashmap_get_multiple (extended_neighbors, | 1001 | GNUNET_CONTAINER_multihashmap_get_multiple (extended_neighbors, |
1006 | &send_context-> | 1002 | &send_context->distant_peer-> |
1007 | distant_peer->hashPubKey, | 1003 | hashPubKey, &find_specific_id, |
1008 | &find_specific_id, &find_context); | 1004 | &find_context); |
1009 | 1005 | ||
1010 | if (find_context.tid == 0) | 1006 | if (find_context.tid == 0) |
1011 | { | 1007 | { |
@@ -1019,8 +1015,9 @@ send_message_via (const struct GNUNET_PeerIdentity *sender, | |||
1019 | if (0 == (memcmp (&my_identity, sender, sizeof (struct GNUNET_PeerIdentity)))) | 1015 | if (0 == (memcmp (&my_identity, sender, sizeof (struct GNUNET_PeerIdentity)))) |
1020 | { | 1016 | { |
1021 | sender_id = 0; | 1017 | sender_id = 0; |
1022 | source = GNUNET_CONTAINER_multihashmap_get (extended_neighbors, | 1018 | source = |
1023 | &sender->hashPubKey); | 1019 | GNUNET_CONTAINER_multihashmap_get (extended_neighbors, |
1020 | &sender->hashPubKey); | ||
1024 | if (source != NULL) | 1021 | if (source != NULL) |
1025 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1022 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1026 | "%s: send_message_via found %s, myself in extended peer list???\n", | 1023 | "%s: send_message_via found %s, myself in extended peer list???\n", |
@@ -1028,8 +1025,9 @@ send_message_via (const struct GNUNET_PeerIdentity *sender, | |||
1028 | } | 1025 | } |
1029 | else | 1026 | else |
1030 | { | 1027 | { |
1031 | source = GNUNET_CONTAINER_multihashmap_get (extended_neighbors, | 1028 | source = |
1032 | &sender->hashPubKey); | 1029 | GNUNET_CONTAINER_multihashmap_get (extended_neighbors, |
1030 | &sender->hashPubKey); | ||
1033 | if (source == NULL) | 1031 | if (source == NULL) |
1034 | { | 1032 | { |
1035 | /* sender unknown to us, drop! */ | 1033 | /* sender unknown to us, drop! */ |
@@ -1067,8 +1065,7 @@ send_message_via (const struct GNUNET_PeerIdentity *sender, | |||
1067 | "DV", &shortname, GNUNET_i2s (recipient), msg_size); | 1065 | "DV", &shortname, GNUNET_i2s (recipient), msg_size); |
1068 | #endif | 1066 | #endif |
1069 | 1067 | ||
1070 | GNUNET_CONTAINER_DLL_insert_after (core_pending_head, | 1068 | GNUNET_CONTAINER_DLL_insert_after (core_pending_head, core_pending_tail, |
1071 | core_pending_tail, | ||
1072 | core_pending_tail, pending_message); | 1069 | core_pending_tail, pending_message); |
1073 | 1070 | ||
1074 | GNUNET_SCHEDULER_add_now (try_core_send, NULL); | 1071 | GNUNET_SCHEDULER_add_now (try_core_send, NULL); |
@@ -1117,10 +1114,9 @@ static int | |||
1117 | send_message (const struct GNUNET_PeerIdentity *recipient, | 1114 | send_message (const struct GNUNET_PeerIdentity *recipient, |
1118 | const struct GNUNET_PeerIdentity *sender, | 1115 | const struct GNUNET_PeerIdentity *sender, |
1119 | const struct DistantNeighbor *specific_neighbor, | 1116 | const struct DistantNeighbor *specific_neighbor, |
1120 | const struct GNUNET_MessageHeader *message, | 1117 | const struct GNUNET_MessageHeader *message, size_t message_size, |
1121 | size_t message_size, | 1118 | unsigned int importance, unsigned int uid, |
1122 | unsigned int importance, | 1119 | struct GNUNET_TIME_Relative timeout) |
1123 | unsigned int uid, struct GNUNET_TIME_Relative timeout) | ||
1124 | { | 1120 | { |
1125 | p2p_dv_MESSAGE_Data *toSend; | 1121 | p2p_dv_MESSAGE_Data *toSend; |
1126 | unsigned int msg_size; | 1122 | unsigned int msg_size; |
@@ -1160,12 +1156,13 @@ send_message (const struct GNUNET_PeerIdentity *recipient, | |||
1160 | } | 1156 | } |
1161 | recipient_id = target->referrer_id; | 1157 | recipient_id = target->referrer_id; |
1162 | 1158 | ||
1163 | source = GNUNET_CONTAINER_multihashmap_get (extended_neighbors, | 1159 | source = |
1164 | &sender->hashPubKey); | 1160 | GNUNET_CONTAINER_multihashmap_get (extended_neighbors, |
1161 | &sender->hashPubKey); | ||
1165 | if (source == NULL) | 1162 | if (source == NULL) |
1166 | { | 1163 | { |
1167 | if (0 != (memcmp (&my_identity, | 1164 | if (0 != |
1168 | sender, sizeof (struct GNUNET_PeerIdentity)))) | 1165 | (memcmp (&my_identity, sender, sizeof (struct GNUNET_PeerIdentity)))) |
1169 | { | 1166 | { |
1170 | /* sender unknown to us, drop! */ | 1167 | /* sender unknown to us, drop! */ |
1171 | return GNUNET_SYSERR; | 1168 | return GNUNET_SYSERR; |
@@ -1229,8 +1226,7 @@ send_message (const struct GNUNET_PeerIdentity *recipient, | |||
1229 | "%s: Sending message, but anticipate recipient will not know sender!!!\n\n\n", | 1226 | "%s: Sending message, but anticipate recipient will not know sender!!!\n\n\n", |
1230 | my_short_id); | 1227 | my_short_id); |
1231 | } | 1228 | } |
1232 | GNUNET_CONTAINER_DLL_insert_after (core_pending_head, | 1229 | GNUNET_CONTAINER_DLL_insert_after (core_pending_head, core_pending_tail, |
1233 | core_pending_tail, | ||
1234 | core_pending_tail, pending_message); | 1230 | core_pending_tail, pending_message); |
1235 | #if DEBUG_DV | 1231 | #if DEBUG_DV |
1236 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1232 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -1292,8 +1288,7 @@ checkPeerID (void *cls, const GNUNET_HashCode * key, void *value) | |||
1292 | * @param message the actual message | 1288 | * @param message the actual message |
1293 | */ | 1289 | */ |
1294 | void | 1290 | void |
1295 | tokenized_message_handler (void *cls, | 1291 | tokenized_message_handler (void *cls, void *client, |
1296 | void *client, | ||
1297 | const struct GNUNET_MessageHeader *message) | 1292 | const struct GNUNET_MessageHeader *message) |
1298 | { | 1293 | { |
1299 | struct TokenizedMessageContext *ctx = client; | 1294 | struct TokenizedMessageContext *ctx = client; |
@@ -1335,13 +1330,9 @@ send_message_delayed (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1335 | 1330 | ||
1336 | if (msg_ctx != NULL) | 1331 | if (msg_ctx != NULL) |
1337 | { | 1332 | { |
1338 | send_message (&msg_ctx->dest, | 1333 | send_message (&msg_ctx->dest, &msg_ctx->sender, NULL, msg_ctx->message, |
1339 | &msg_ctx->sender, | 1334 | msg_ctx->message_size, default_dv_priority, msg_ctx->uid, |
1340 | NULL, | 1335 | GNUNET_TIME_relative_get_forever ()); |
1341 | msg_ctx->message, | ||
1342 | msg_ctx->message_size, | ||
1343 | default_dv_priority, | ||
1344 | msg_ctx->uid, GNUNET_TIME_relative_get_forever ()); | ||
1345 | GNUNET_free (msg_ctx->message); | 1336 | GNUNET_free (msg_ctx->message); |
1346 | GNUNET_free (msg_ctx); | 1337 | GNUNET_free (msg_ctx); |
1347 | } | 1338 | } |
@@ -1404,8 +1395,7 @@ get_atsi_latency (const struct GNUNET_TRANSPORT_ATS_Information *atsi) | |||
1404 | * @param atsi transport ATS information (latency, distance, etc.) | 1395 | * @param atsi transport ATS information (latency, distance, etc.) |
1405 | */ | 1396 | */ |
1406 | static int | 1397 | static int |
1407 | handle_dv_data_message (void *cls, | 1398 | handle_dv_data_message (void *cls, const struct GNUNET_PeerIdentity *peer, |
1408 | const struct GNUNET_PeerIdentity *peer, | ||
1409 | const struct GNUNET_MessageHeader *message, | 1399 | const struct GNUNET_MessageHeader *message, |
1410 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 1400 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
1411 | { | 1401 | { |
@@ -1478,8 +1468,9 @@ handle_dv_data_message (void *cls, | |||
1478 | } | 1468 | } |
1479 | else | 1469 | else |
1480 | { | 1470 | { |
1481 | pos = GNUNET_CONTAINER_multihashmap_get (extended_neighbors, | 1471 | pos = |
1482 | &peer->hashPubKey); | 1472 | GNUNET_CONTAINER_multihashmap_get (extended_neighbors, |
1473 | &peer->hashPubKey); | ||
1483 | } | 1474 | } |
1484 | #else | 1475 | #else |
1485 | pos = dn->referee_head; | 1476 | pos = dn->referee_head; |
@@ -1547,11 +1538,9 @@ handle_dv_data_message (void *cls, | |||
1547 | tkm_ctx.peer = peer; | 1538 | tkm_ctx.peer = peer; |
1548 | tkm_ctx.distant = pos; | 1539 | tkm_ctx.distant = pos; |
1549 | tkm_ctx.uid = ntohl (incoming->uid); | 1540 | tkm_ctx.uid = ntohl (incoming->uid); |
1550 | if (GNUNET_OK != GNUNET_SERVER_mst_receive (coreMST, | 1541 | if (GNUNET_OK != |
1551 | &tkm_ctx, | 1542 | GNUNET_SERVER_mst_receive (coreMST, &tkm_ctx, cbuf, packed_message_size, |
1552 | cbuf, | 1543 | GNUNET_NO, GNUNET_NO)) |
1553 | packed_message_size, | ||
1554 | GNUNET_NO, GNUNET_NO)) | ||
1555 | { | 1544 | { |
1556 | GNUNET_break_op (0); | 1545 | GNUNET_break_op (0); |
1557 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1546 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
@@ -1634,14 +1623,11 @@ handle_dv_data_message (void *cls, | |||
1634 | else | 1623 | else |
1635 | #endif | 1624 | #endif |
1636 | { | 1625 | { |
1637 | ret = send_message (destination, | 1626 | ret = |
1638 | original_sender, | 1627 | send_message (destination, original_sender, NULL, packed_message, |
1639 | NULL, | 1628 | packed_message_size, default_dv_priority, |
1640 | packed_message, | 1629 | ntohl (incoming->uid), |
1641 | packed_message_size, | 1630 | GNUNET_TIME_relative_get_forever ()); |
1642 | default_dv_priority, | ||
1643 | ntohl (incoming->uid), | ||
1644 | GNUNET_TIME_relative_get_forever ()); | ||
1645 | } | 1631 | } |
1646 | if (ret != GNUNET_SYSERR) | 1632 | if (ret != GNUNET_SYSERR) |
1647 | return GNUNET_OK; | 1633 | return GNUNET_OK; |
@@ -1756,17 +1742,17 @@ neighbor_send_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1756 | (about->hidden == GNUNET_NO) && | 1742 | (about->hidden == GNUNET_NO) && |
1757 | #endif | 1743 | #endif |
1758 | (to != NULL) && | 1744 | (to != NULL) && |
1759 | (0 != memcmp (&about->identity, | 1745 | (0 != |
1760 | &to->identity, sizeof (struct GNUNET_PeerIdentity))) && | 1746 | memcmp (&about->identity, &to->identity, |
1761 | (about->pkey != NULL)) | 1747 | sizeof (struct GNUNET_PeerIdentity))) && (about->pkey != NULL)) |
1762 | { | 1748 | { |
1763 | #if DEBUG_DV_GOSSIP_SEND | 1749 | #if DEBUG_DV_GOSSIP_SEND |
1764 | encPeerAbout = GNUNET_strdup (GNUNET_i2s (&about->identity)); | 1750 | encPeerAbout = GNUNET_strdup (GNUNET_i2s (&about->identity)); |
1765 | encPeerTo = GNUNET_strdup (GNUNET_i2s (&to->identity)); | 1751 | encPeerTo = GNUNET_strdup (GNUNET_i2s (&to->identity)); |
1766 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1752 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1767 | "%s: Sending info about peer %s id %u to directly connected peer %s\n", | 1753 | "%s: Sending info about peer %s id %u to directly connected peer %s\n", |
1768 | GNUNET_i2s (&my_identity), | 1754 | GNUNET_i2s (&my_identity), encPeerAbout, about->our_id, |
1769 | encPeerAbout, about->our_id, encPeerTo); | 1755 | encPeerTo); |
1770 | GNUNET_free (encPeerAbout); | 1756 | GNUNET_free (encPeerAbout); |
1771 | GNUNET_free (encPeerTo); | 1757 | GNUNET_free (encPeerTo); |
1772 | #endif | 1758 | #endif |
@@ -1791,8 +1777,7 @@ neighbor_send_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1791 | memcpy (&message->neighbor, &about->identity, | 1777 | memcpy (&message->neighbor, &about->identity, |
1792 | sizeof (struct GNUNET_PeerIdentity)); | 1778 | sizeof (struct GNUNET_PeerIdentity)); |
1793 | 1779 | ||
1794 | GNUNET_CONTAINER_DLL_insert_after (core_pending_head, | 1780 | GNUNET_CONTAINER_DLL_insert_after (core_pending_head, core_pending_tail, |
1795 | core_pending_tail, | ||
1796 | core_pending_tail, pending_message); | 1781 | core_pending_tail, pending_message); |
1797 | 1782 | ||
1798 | GNUNET_SCHEDULER_add_now (try_core_send, NULL); | 1783 | GNUNET_SCHEDULER_add_now (try_core_send, NULL); |
@@ -1834,14 +1819,13 @@ neighbor_send_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1834 | * @param message the actual message | 1819 | * @param message the actual message |
1835 | */ | 1820 | */ |
1836 | static void | 1821 | static void |
1837 | handle_start (void *cls, | 1822 | handle_start (void *cls, struct GNUNET_SERVER_Client *client, |
1838 | struct GNUNET_SERVER_Client *client, | ||
1839 | const struct GNUNET_MessageHeader *message) | 1823 | const struct GNUNET_MessageHeader *message) |
1840 | { | 1824 | { |
1841 | 1825 | ||
1842 | #if DEBUG_DV | 1826 | #if DEBUG_DV |
1843 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1827 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received `%s' request from client\n", |
1844 | "Received `%s' request from client\n", "START"); | 1828 | "START"); |
1845 | #endif | 1829 | #endif |
1846 | 1830 | ||
1847 | client_handle = client; | 1831 | client_handle = client; |
@@ -1886,8 +1870,7 @@ send_iterator (void *cls, const GNUNET_HashCode * key, void *abs_value) | |||
1886 | * @param message the actual message | 1870 | * @param message the actual message |
1887 | */ | 1871 | */ |
1888 | void | 1872 | void |
1889 | handle_dv_send_message (void *cls, | 1873 | handle_dv_send_message (void *cls, struct GNUNET_SERVER_Client *client, |
1890 | struct GNUNET_SERVER_Client *client, | ||
1891 | const struct GNUNET_MessageHeader *message) | 1874 | const struct GNUNET_MessageHeader *message) |
1892 | { | 1875 | { |
1893 | struct GNUNET_DV_SendMessage *send_msg; | 1876 | struct GNUNET_DV_SendMessage *send_msg; |
@@ -2139,8 +2122,8 @@ distant_neighbor_free (struct DistantNeighbor *referee) | |||
2139 | referrer = referee->referrer; | 2122 | referrer = referee->referrer; |
2140 | if (referrer != NULL) | 2123 | if (referrer != NULL) |
2141 | { | 2124 | { |
2142 | GNUNET_CONTAINER_DLL_remove (referrer->referee_head, | 2125 | GNUNET_CONTAINER_DLL_remove (referrer->referee_head, referrer->referee_tail, |
2143 | referrer->referee_tail, referee); | 2126 | referee); |
2144 | } | 2127 | } |
2145 | GNUNET_CONTAINER_heap_remove_node (referee->max_loc); | 2128 | GNUNET_CONTAINER_heap_remove_node (referee->max_loc); |
2146 | GNUNET_CONTAINER_heap_remove_node (referee->min_loc); | 2129 | GNUNET_CONTAINER_heap_remove_node (referee->min_loc); |
@@ -2191,8 +2174,8 @@ direct_neighbor_free (struct DirectNeighbor *direct) | |||
2191 | * @return GNUNET_YES to continue iteration, GNUNET_NO to stop | 2174 | * @return GNUNET_YES to continue iteration, GNUNET_NO to stop |
2192 | */ | 2175 | */ |
2193 | static int | 2176 | static int |
2194 | schedule_disconnect_messages (void *cls, | 2177 | schedule_disconnect_messages (void *cls, const GNUNET_HashCode * key, |
2195 | const GNUNET_HashCode * key, void *value) | 2178 | void *value) |
2196 | { | 2179 | { |
2197 | struct DisconnectContext *disconnect_context = cls; | 2180 | struct DisconnectContext *disconnect_context = cls; |
2198 | struct DirectNeighbor *disconnected = disconnect_context->direct; | 2181 | struct DirectNeighbor *disconnected = disconnect_context->direct; |
@@ -2219,8 +2202,7 @@ schedule_disconnect_messages (void *cls, | |||
2219 | disconnect_message->header.type = htons (GNUNET_MESSAGE_TYPE_DV_DISCONNECT); | 2202 | disconnect_message->header.type = htons (GNUNET_MESSAGE_TYPE_DV_DISCONNECT); |
2220 | disconnect_message->peer_id = htonl (disconnect_context->distant->our_id); | 2203 | disconnect_message->peer_id = htonl (disconnect_context->distant->our_id); |
2221 | 2204 | ||
2222 | GNUNET_CONTAINER_DLL_insert_after (core_pending_head, | 2205 | GNUNET_CONTAINER_DLL_insert_after (core_pending_head, core_pending_tail, |
2223 | core_pending_tail, | ||
2224 | core_pending_tail, pending_message); | 2206 | core_pending_tail, pending_message); |
2225 | 2207 | ||
2226 | GNUNET_SCHEDULER_add_now (try_core_send, NULL); | 2208 | GNUNET_SCHEDULER_add_now (try_core_send, NULL); |
@@ -2305,8 +2287,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2305 | * To be called on core init/fail. | 2287 | * To be called on core init/fail. |
2306 | */ | 2288 | */ |
2307 | void | 2289 | void |
2308 | core_init (void *cls, | 2290 | core_init (void *cls, struct GNUNET_CORE_Handle *server, |
2309 | struct GNUNET_CORE_Handle *server, | ||
2310 | const struct GNUNET_PeerIdentity *identity, | 2291 | const struct GNUNET_PeerIdentity *identity, |
2311 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) | 2292 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) |
2312 | { | 2293 | { |
@@ -2404,8 +2385,8 @@ update_matching_neighbors (void *cls, const GNUNET_HashCode * key, void *value) | |||
2404 | * @return GNUNET_YES to continue iteration, GNUNET_NO otherwise | 2385 | * @return GNUNET_YES to continue iteration, GNUNET_NO otherwise |
2405 | */ | 2386 | */ |
2406 | static int | 2387 | static int |
2407 | add_distant_all_direct_neighbors (void *cls, | 2388 | add_distant_all_direct_neighbors (void *cls, const GNUNET_HashCode * key, |
2408 | const GNUNET_HashCode * key, void *value) | 2389 | void *value) |
2409 | { | 2390 | { |
2410 | struct DirectNeighbor *direct = (struct DirectNeighbor *) value; | 2391 | struct DirectNeighbor *direct = (struct DirectNeighbor *) value; |
2411 | struct DistantNeighbor *distant = (struct DistantNeighbor *) cls; | 2392 | struct DistantNeighbor *distant = (struct DistantNeighbor *) cls; |
@@ -2541,13 +2522,13 @@ addUpdateNeighbor (const struct GNUNET_PeerIdentity *peer, | |||
2541 | #if DEBUG_DV_PEER_NUMBERS | 2522 | #if DEBUG_DV_PEER_NUMBERS |
2542 | char *encAbout; | 2523 | char *encAbout; |
2543 | 2524 | ||
2544 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2525 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s Received sender id (%u)!\n", |
2545 | "%s Received sender id (%u)!\n", "DV SERVICE", referrer_peer_id); | 2526 | "DV SERVICE", referrer_peer_id); |
2546 | #endif | 2527 | #endif |
2547 | 2528 | ||
2548 | now = GNUNET_TIME_absolute_get (); | 2529 | now = GNUNET_TIME_absolute_get (); |
2549 | neighbor = GNUNET_CONTAINER_multihashmap_get (extended_neighbors, | 2530 | neighbor = |
2550 | &peer->hashPubKey); | 2531 | GNUNET_CONTAINER_multihashmap_get (extended_neighbors, &peer->hashPubKey); |
2551 | neighbor_update = GNUNET_malloc (sizeof (struct NeighborUpdateInfo)); | 2532 | neighbor_update = GNUNET_malloc (sizeof (struct NeighborUpdateInfo)); |
2552 | neighbor_update->neighbor = neighbor; | 2533 | neighbor_update->neighbor = neighbor; |
2553 | neighbor_update->cost = cost; | 2534 | neighbor_update->cost = cost; |
@@ -2576,11 +2557,9 @@ addUpdateNeighbor (const struct GNUNET_PeerIdentity *peer, | |||
2576 | 2557 | ||
2577 | /* Either we do not know this peer, or we already do but via a different immediate peer */ | 2558 | /* Either we do not know this peer, or we already do but via a different immediate peer */ |
2578 | if ((neighbor == NULL) || | 2559 | if ((neighbor == NULL) || |
2579 | (GNUNET_CONTAINER_multihashmap_get_multiple (extended_neighbors, | 2560 | (GNUNET_CONTAINER_multihashmap_get_multiple |
2580 | &peer->hashPubKey, | 2561 | (extended_neighbors, &peer->hashPubKey, &update_matching_neighbors, |
2581 | &update_matching_neighbors, | 2562 | neighbor_update) != GNUNET_SYSERR)) |
2582 | neighbor_update) != | ||
2583 | GNUNET_SYSERR)) | ||
2584 | { | 2563 | { |
2585 | #if AT_MOST_ONE | 2564 | #if AT_MOST_ONE |
2586 | if ((neighbor != NULL) && (cost < neighbor->cost)) /* New cost is less than old, remove old */ | 2565 | if ((neighbor != NULL) && (cost < neighbor->cost)) /* New cost is less than old, remove old */ |
@@ -2630,12 +2609,12 @@ addUpdateNeighbor (const struct GNUNET_PeerIdentity *peer, | |||
2630 | } | 2609 | } |
2631 | 2610 | ||
2632 | neighbor = GNUNET_malloc (sizeof (struct DistantNeighbor)); | 2611 | neighbor = GNUNET_malloc (sizeof (struct DistantNeighbor)); |
2633 | GNUNET_CONTAINER_DLL_insert (referrer->referee_head, | 2612 | GNUNET_CONTAINER_DLL_insert (referrer->referee_head, referrer->referee_tail, |
2634 | referrer->referee_tail, neighbor); | 2613 | neighbor); |
2635 | neighbor->max_loc = GNUNET_CONTAINER_heap_insert (neighbor_max_heap, | 2614 | neighbor->max_loc = |
2636 | neighbor, cost); | 2615 | GNUNET_CONTAINER_heap_insert (neighbor_max_heap, neighbor, cost); |
2637 | neighbor->min_loc = GNUNET_CONTAINER_heap_insert (neighbor_min_heap, | 2616 | neighbor->min_loc = |
2638 | neighbor, cost); | 2617 | GNUNET_CONTAINER_heap_insert (neighbor_min_heap, neighbor, cost); |
2639 | neighbor->referrer = referrer; | 2618 | neighbor->referrer = referrer; |
2640 | memcpy (&neighbor->identity, peer, sizeof (struct GNUNET_PeerIdentity)); | 2619 | memcpy (&neighbor->identity, peer, sizeof (struct GNUNET_PeerIdentity)); |
2641 | if (pkey != NULL) /* pkey will be null on direct neighbor addition */ | 2620 | if (pkey != NULL) /* pkey will be null on direct neighbor addition */ |
@@ -2679,12 +2658,11 @@ addUpdateNeighbor (const struct GNUNET_PeerIdentity *peer, | |||
2679 | atsi[0].value = htonl (referrer->pending_messages[i].distance); | 2658 | atsi[0].value = htonl (referrer->pending_messages[i].distance); |
2680 | atsi[1].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DELAY); | 2659 | atsi[1].type = htonl (GNUNET_TRANSPORT_ATS_QUALITY_NET_DELAY); |
2681 | atsi[1].value = | 2660 | atsi[1].value = |
2682 | htonl ((uint32_t) referrer->pending_messages[i]. | 2661 | htonl ((uint32_t) referrer->pending_messages[i].latency. |
2683 | latency.rel_value); | 2662 | rel_value); |
2684 | atsi[2].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); | 2663 | atsi[2].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); |
2685 | atsi[2].value = htonl (0); | 2664 | atsi[2].value = htonl (0); |
2686 | handle_dv_data_message (NULL, | 2665 | handle_dv_data_message (NULL, &referrer->pending_messages[i].sender, |
2687 | &referrer->pending_messages[i].sender, | ||
2688 | referrer->pending_messages[i].message, | 2666 | referrer->pending_messages[i].message, |
2689 | (const struct GNUNET_TRANSPORT_ATS_Information | 2667 | (const struct GNUNET_TRANSPORT_ATS_Information |
2690 | *) &atsi); | 2668 | *) &atsi); |
@@ -2733,9 +2711,8 @@ addUpdateNeighbor (const struct GNUNET_PeerIdentity *peer, | |||
2733 | #endif | 2711 | #endif |
2734 | } | 2712 | } |
2735 | #if DEBUG_DV | 2713 | #if DEBUG_DV |
2736 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2714 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s: Size of extended_neighbors is %d\n", |
2737 | "%s: Size of extended_neighbors is %d\n", "dv", | 2715 | "dv", GNUNET_CONTAINER_multihashmap_size (extended_neighbors)); |
2738 | GNUNET_CONTAINER_multihashmap_size (extended_neighbors)); | ||
2739 | #endif | 2716 | #endif |
2740 | 2717 | ||
2741 | GNUNET_free (neighbor_update); | 2718 | GNUNET_free (neighbor_update); |
@@ -2756,8 +2733,7 @@ addUpdateNeighbor (const struct GNUNET_PeerIdentity *peer, | |||
2756 | * @param atsi performance data | 2733 | * @param atsi performance data |
2757 | */ | 2734 | */ |
2758 | static int | 2735 | static int |
2759 | handle_dv_disconnect_message (void *cls, | 2736 | handle_dv_disconnect_message (void *cls, const struct GNUNET_PeerIdentity *peer, |
2760 | const struct GNUNET_PeerIdentity *peer, | ||
2761 | const struct GNUNET_MessageHeader *message, | 2737 | const struct GNUNET_MessageHeader *message, |
2762 | const struct GNUNET_TRANSPORT_ATS_Information | 2738 | const struct GNUNET_TRANSPORT_ATS_Information |
2763 | *atsi) | 2739 | *atsi) |
@@ -2772,8 +2748,8 @@ handle_dv_disconnect_message (void *cls, | |||
2772 | return GNUNET_SYSERR; /* invalid message */ | 2748 | return GNUNET_SYSERR; /* invalid message */ |
2773 | } | 2749 | } |
2774 | 2750 | ||
2775 | referrer = GNUNET_CONTAINER_multihashmap_get (direct_neighbors, | 2751 | referrer = |
2776 | &peer->hashPubKey); | 2752 | GNUNET_CONTAINER_multihashmap_get (direct_neighbors, &peer->hashPubKey); |
2777 | if (referrer == NULL) | 2753 | if (referrer == NULL) |
2778 | return GNUNET_OK; | 2754 | return GNUNET_OK; |
2779 | 2755 | ||
@@ -2806,8 +2782,7 @@ handle_dv_disconnect_message (void *cls, | |||
2806 | * @param atsi performance data | 2782 | * @param atsi performance data |
2807 | */ | 2783 | */ |
2808 | static int | 2784 | static int |
2809 | handle_dv_gossip_message (void *cls, | 2785 | handle_dv_gossip_message (void *cls, const struct GNUNET_PeerIdentity *peer, |
2810 | const struct GNUNET_PeerIdentity *peer, | ||
2811 | const struct GNUNET_MessageHeader *message, | 2786 | const struct GNUNET_MessageHeader *message, |
2812 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 2787 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
2813 | { | 2788 | { |
@@ -2834,14 +2809,14 @@ handle_dv_gossip_message (void *cls, | |||
2834 | GNUNET_free (encPeerFrom); | 2809 | GNUNET_free (encPeerFrom); |
2835 | #endif | 2810 | #endif |
2836 | 2811 | ||
2837 | referrer = GNUNET_CONTAINER_multihashmap_get (direct_neighbors, | 2812 | referrer = |
2838 | &peer->hashPubKey); | 2813 | GNUNET_CONTAINER_multihashmap_get (direct_neighbors, &peer->hashPubKey); |
2839 | if (referrer == NULL) | 2814 | if (referrer == NULL) |
2840 | return GNUNET_OK; | 2815 | return GNUNET_OK; |
2841 | 2816 | ||
2842 | addUpdateNeighbor (&enc_message->neighbor, &enc_message->pkey, | 2817 | addUpdateNeighbor (&enc_message->neighbor, &enc_message->pkey, |
2843 | ntohl (enc_message->neighbor_id), | 2818 | ntohl (enc_message->neighbor_id), referrer, |
2844 | referrer, ntohl (enc_message->cost) + 1); | 2819 | ntohl (enc_message->cost) + 1); |
2845 | 2820 | ||
2846 | return GNUNET_OK; | 2821 | return GNUNET_OK; |
2847 | } | 2822 | } |
@@ -2897,8 +2872,8 @@ add_all_extended_peers (void *cls, const GNUNET_HashCode * key, void *value) | |||
2897 | * GNUNET_NO if not. | 2872 | * GNUNET_NO if not. |
2898 | */ | 2873 | */ |
2899 | static int | 2874 | static int |
2900 | gossip_all_to_all_iterator (void *cls, | 2875 | gossip_all_to_all_iterator (void *cls, const GNUNET_HashCode * key, |
2901 | const GNUNET_HashCode * key, void *abs_value) | 2876 | void *abs_value) |
2902 | { | 2877 | { |
2903 | struct DirectNeighbor *direct = abs_value; | 2878 | struct DirectNeighbor *direct = abs_value; |
2904 | 2879 | ||
@@ -3007,8 +2982,7 @@ add_all_direct_neighbors (void *cls, const GNUNET_HashCode * key, void *value) | |||
3007 | * @param err_msg NULL if successful, otherwise contains error message | 2982 | * @param err_msg NULL if successful, otherwise contains error message |
3008 | */ | 2983 | */ |
3009 | static void | 2984 | static void |
3010 | process_peerinfo (void *cls, | 2985 | process_peerinfo (void *cls, const struct GNUNET_PeerIdentity *peer, |
3011 | const struct GNUNET_PeerIdentity *peer, | ||
3012 | const struct GNUNET_HELLO_Message *hello, const char *err_msg) | 2986 | const struct GNUNET_HELLO_Message *hello, const char *err_msg) |
3013 | { | 2987 | { |
3014 | struct PeerIteratorContext *peerinfo_iterator = cls; | 2988 | struct PeerIteratorContext *peerinfo_iterator = cls; |
@@ -3034,13 +3008,12 @@ process_peerinfo (void *cls, | |||
3034 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 3008 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
3035 | "Failed to get peerinfo information for this peer, retrying!\n"); | 3009 | "Failed to get peerinfo information for this peer, retrying!\n"); |
3036 | #endif | 3010 | #endif |
3037 | peerinfo_iterator->ic = GNUNET_PEERINFO_iterate (peerinfo_handle, | 3011 | peerinfo_iterator->ic = |
3038 | &peerinfo_iterator->neighbor-> | 3012 | GNUNET_PEERINFO_iterate (peerinfo_handle, |
3039 | identity, | 3013 | &peerinfo_iterator->neighbor->identity, |
3040 | GNUNET_TIME_relative_multiply | 3014 | GNUNET_TIME_relative_multiply |
3041 | (GNUNET_TIME_UNIT_SECONDS, | 3015 | (GNUNET_TIME_UNIT_SECONDS, 3), |
3042 | 3), &process_peerinfo, | 3016 | &process_peerinfo, peerinfo_iterator); |
3043 | peerinfo_iterator); | ||
3044 | } | 3017 | } |
3045 | else | 3018 | else |
3046 | { | 3019 | { |
@@ -3111,8 +3084,7 @@ process_peerinfo (void *cls, | |||
3111 | * @param atsi performance data | 3084 | * @param atsi performance data |
3112 | */ | 3085 | */ |
3113 | static void | 3086 | static void |
3114 | handle_core_connect (void *cls, | 3087 | handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer, |
3115 | const struct GNUNET_PeerIdentity *peer, | ||
3116 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 3088 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
3117 | { | 3089 | { |
3118 | struct DirectNeighbor *neighbor; | 3090 | struct DirectNeighbor *neighbor; |
@@ -3146,12 +3118,11 @@ handle_core_connect (void *cls, | |||
3146 | about = addUpdateNeighbor (peer, NULL, 0, neighbor, DIRECT_NEIGHBOR_COST); | 3118 | about = addUpdateNeighbor (peer, NULL, 0, neighbor, DIRECT_NEIGHBOR_COST); |
3147 | peerinfo_iterator->distant = about; | 3119 | peerinfo_iterator->distant = about; |
3148 | peerinfo_iterator->neighbor = neighbor; | 3120 | peerinfo_iterator->neighbor = neighbor; |
3149 | peerinfo_iterator->ic = GNUNET_PEERINFO_iterate (peerinfo_handle, | 3121 | peerinfo_iterator->ic = |
3150 | peer, | 3122 | GNUNET_PEERINFO_iterate (peerinfo_handle, peer, |
3151 | GNUNET_TIME_relative_multiply | 3123 | GNUNET_TIME_relative_multiply |
3152 | (GNUNET_TIME_UNIT_SECONDS, | 3124 | (GNUNET_TIME_UNIT_SECONDS, 3), |
3153 | 3), &process_peerinfo, | 3125 | &process_peerinfo, peerinfo_iterator); |
3154 | peerinfo_iterator); | ||
3155 | 3126 | ||
3156 | if ((about != NULL) && (about->pkey == NULL)) | 3127 | if ((about != NULL) && (about->pkey == NULL)) |
3157 | { | 3128 | { |
@@ -3257,9 +3228,9 @@ handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
3257 | } | 3228 | } |
3258 | 3229 | ||
3259 | GNUNET_assert (neighbor->referee_tail == NULL); | 3230 | GNUNET_assert (neighbor->referee_tail == NULL); |
3260 | if (GNUNET_NO == GNUNET_CONTAINER_multihashmap_remove (direct_neighbors, | 3231 | if (GNUNET_NO == |
3261 | &peer->hashPubKey, | 3232 | GNUNET_CONTAINER_multihashmap_remove (direct_neighbors, &peer->hashPubKey, |
3262 | neighbor)) | 3233 | neighbor)) |
3263 | { | 3234 | { |
3264 | GNUNET_break (0); | 3235 | GNUNET_break (0); |
3265 | } | 3236 | } |
@@ -3278,8 +3249,7 @@ handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
3278 | * @param c configuration to use | 3249 | * @param c configuration to use |
3279 | */ | 3250 | */ |
3280 | static void | 3251 | static void |
3281 | run (void *cls, | 3252 | run (void *cls, struct GNUNET_SERVER_Handle *server, |
3282 | struct GNUNET_SERVER_Handle *server, | ||
3283 | const struct GNUNET_CONFIGURATION_Handle *c) | 3253 | const struct GNUNET_CONFIGURATION_Handle *c) |
3284 | { | 3254 | { |
3285 | unsigned long long max_hosts; | 3255 | unsigned long long max_hosts; |
@@ -3321,12 +3291,9 @@ run (void *cls, | |||
3321 | 3291 | ||
3322 | GNUNET_SERVER_add_handlers (server, plugin_handlers); | 3292 | GNUNET_SERVER_add_handlers (server, plugin_handlers); |
3323 | coreAPI = GNUNET_CORE_connect (cfg, 1, NULL, /* FIXME: anything we want to pass around? */ | 3293 | coreAPI = GNUNET_CORE_connect (cfg, 1, NULL, /* FIXME: anything we want to pass around? */ |
3324 | &core_init, | 3294 | &core_init, &handle_core_connect, |
3325 | &handle_core_connect, | 3295 | &handle_core_disconnect, NULL, NULL, GNUNET_NO, |
3326 | &handle_core_disconnect, | 3296 | NULL, GNUNET_NO, core_handlers); |
3327 | NULL, | ||
3328 | NULL, | ||
3329 | GNUNET_NO, NULL, GNUNET_NO, core_handlers); | ||
3330 | 3297 | ||
3331 | if (coreAPI == NULL) | 3298 | if (coreAPI == NULL) |
3332 | return; | 3299 | return; |
@@ -3342,8 +3309,9 @@ run (void *cls, | |||
3342 | } | 3309 | } |
3343 | 3310 | ||
3344 | /* Scheduled the task to clean up when shutdown is called */ | 3311 | /* Scheduled the task to clean up when shutdown is called */ |
3345 | cleanup_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 3312 | cleanup_task = |
3346 | &shutdown_task, NULL); | 3313 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
3314 | &shutdown_task, NULL); | ||
3347 | } | 3315 | } |
3348 | 3316 | ||
3349 | 3317 | ||
@@ -3358,8 +3326,6 @@ int | |||
3358 | main (int argc, char *const *argv) | 3326 | main (int argc, char *const *argv) |
3359 | { | 3327 | { |
3360 | return (GNUNET_OK == | 3328 | return (GNUNET_OK == |
3361 | GNUNET_SERVICE_run (argc, | 3329 | GNUNET_SERVICE_run (argc, argv, "dv", GNUNET_SERVICE_OPTION_NONE, |
3362 | argv, | 3330 | &run, NULL)) ? 0 : 1; |
3363 | "dv", | ||
3364 | GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1; | ||
3365 | } | 3331 | } |
diff --git a/src/dv/plugin_transport_dv.c b/src/dv/plugin_transport_dv.c index 2803e347e..bd73e7e20 100644 --- a/src/dv/plugin_transport_dv.c +++ b/src/dv/plugin_transport_dv.c | |||
@@ -145,11 +145,8 @@ struct Plugin | |||
145 | * Handler for messages received from the DV service. | 145 | * Handler for messages received from the DV service. |
146 | */ | 146 | */ |
147 | void | 147 | void |
148 | handle_dv_message_received (void *cls, | 148 | handle_dv_message_received (void *cls, struct GNUNET_PeerIdentity *sender, |
149 | struct GNUNET_PeerIdentity *sender, | 149 | char *msg, size_t msg_len, uint32_t distance, |
150 | char *msg, | ||
151 | size_t msg_len, | ||
152 | uint32_t distance, | ||
153 | char *sender_address, size_t sender_address_len) | 150 | char *sender_address, size_t sender_address_len) |
154 | { | 151 | { |
155 | struct Plugin *plugin = cls; | 152 | struct Plugin *plugin = cls; |
@@ -158,8 +155,7 @@ handle_dv_message_received (void *cls, | |||
158 | char *my_id; | 155 | char *my_id; |
159 | 156 | ||
160 | my_id = GNUNET_strdup (GNUNET_i2s (plugin->env->my_identity)); | 157 | my_id = GNUNET_strdup (GNUNET_i2s (plugin->env->my_identity)); |
161 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, | 158 | GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "plugin_transport_dv", |
162 | "plugin_transport_dv", | ||
163 | _("%s Received message from %s of type %d, distance %u!\n"), | 159 | _("%s Received message from %s of type %d, distance %u!\n"), |
164 | my_id, GNUNET_i2s (sender), | 160 | my_id, GNUNET_i2s (sender), |
165 | ntohs (((struct GNUNET_MessageHeader *) msg)->type), | 161 | ntohs (((struct GNUNET_MessageHeader *) msg)->type), |
@@ -173,8 +169,7 @@ handle_dv_message_received (void *cls, | |||
173 | ats[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); | 169 | ats[1].type = htonl (GNUNET_TRANSPORT_ATS_ARRAY_TERMINATOR); |
174 | ats[1].value = htonl (0); | 170 | ats[1].value = htonl (0); |
175 | 171 | ||
176 | plugin->env->receive (plugin->env->cls, | 172 | plugin->env->receive (plugin->env->cls, sender, |
177 | sender, | ||
178 | (struct GNUNET_MessageHeader *) msg, | 173 | (struct GNUNET_MessageHeader *) msg, |
179 | (const struct GNUNET_TRANSPORT_ATS_Information *) &ats, | 174 | (const struct GNUNET_TRANSPORT_ATS_Information *) &ats, |
180 | 2, NULL, sender_address, sender_address_len); | 175 | 2, NULL, sender_address, sender_address_len); |
@@ -214,26 +209,18 @@ handle_dv_message_received (void *cls, | |||
214 | * and does NOT mean that the message was not transmitted (DV) | 209 | * and does NOT mean that the message was not transmitted (DV) |
215 | */ | 210 | */ |
216 | static ssize_t | 211 | static ssize_t |
217 | dv_plugin_send (void *cls, | 212 | dv_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target, |
218 | const struct GNUNET_PeerIdentity *target, | 213 | const char *msgbuf, size_t msgbuf_size, unsigned int priority, |
219 | const char *msgbuf, | 214 | struct GNUNET_TIME_Relative timeout, struct Session *session, |
220 | size_t msgbuf_size, | 215 | const void *addr, size_t addrlen, int force_address, |
221 | unsigned int priority, | ||
222 | struct GNUNET_TIME_Relative timeout, | ||
223 | struct Session *session, | ||
224 | const void *addr, | ||
225 | size_t addrlen, | ||
226 | int force_address, | ||
227 | GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) | 216 | GNUNET_TRANSPORT_TransmitContinuation cont, void *cont_cls) |
228 | { | 217 | { |
229 | int ret = 0; | 218 | int ret = 0; |
230 | struct Plugin *plugin = cls; | 219 | struct Plugin *plugin = cls; |
231 | 220 | ||
232 | ret = GNUNET_DV_send (plugin->dv_handle, | 221 | ret = |
233 | target, | 222 | GNUNET_DV_send (plugin->dv_handle, target, msgbuf, msgbuf_size, priority, |
234 | msgbuf, | 223 | timeout, addr, addrlen, cont, cont_cls); |
235 | msgbuf_size, | ||
236 | priority, timeout, addr, addrlen, cont, cont_cls); | ||
237 | return ret; | 224 | return ret; |
238 | } | 225 | } |
239 | 226 | ||
@@ -270,14 +257,11 @@ dv_plugin_disconnect (void *cls, const struct GNUNET_PeerIdentity *target) | |||
270 | * @param asc_cls closure for asc | 257 | * @param asc_cls closure for asc |
271 | */ | 258 | */ |
272 | static void | 259 | static void |
273 | dv_plugin_address_pretty_printer (void *cls, | 260 | dv_plugin_address_pretty_printer (void *cls, const char *type, const void *addr, |
274 | const char *type, | 261 | size_t addrlen, int numeric, |
275 | const void *addr, | ||
276 | size_t addrlen, | ||
277 | int numeric, | ||
278 | struct GNUNET_TIME_Relative timeout, | 262 | struct GNUNET_TIME_Relative timeout, |
279 | GNUNET_TRANSPORT_AddressStringCallback | 263 | GNUNET_TRANSPORT_AddressStringCallback asc, |
280 | asc, void *asc_cls) | 264 | void *asc_cls) |
281 | { | 265 | { |
282 | char *dest_peer; | 266 | char *dest_peer; |
283 | char *via_peer; | 267 | char *via_peer; |
@@ -337,8 +321,8 @@ address_to_string (void *cls, const void *addr, size_t addrlen) | |||
337 | peer_hash.encoding[4] = '\0'; | 321 | peer_hash.encoding[4] = '\0'; |
338 | GNUNET_CRYPTO_hash_to_enc (&via->hashPubKey, &via_hash); | 322 | GNUNET_CRYPTO_hash_to_enc (&via->hashPubKey, &via_hash); |
339 | via_hash.encoding[4] = '\0'; | 323 | via_hash.encoding[4] = '\0'; |
340 | GNUNET_snprintf (return_buffer, | 324 | GNUNET_snprintf (return_buffer, sizeof (return_buffer), "%s:%s", &peer_hash, |
341 | sizeof (return_buffer), "%s:%s", &peer_hash, &via_hash); | 325 | &via_hash); |
342 | } | 326 | } |
343 | else | 327 | else |
344 | return NULL; | 328 | return NULL; |
diff --git a/src/dv/test_transport_api_dv.c b/src/dv/test_transport_api_dv.c index 5d9d367e1..fee8eea81 100644 --- a/src/dv/test_transport_api_dv.c +++ b/src/dv/test_transport_api_dv.c | |||
@@ -285,15 +285,13 @@ disconnect_cores (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
285 | 285 | ||
286 | /* Disconnect from the respective cores */ | 286 | /* Disconnect from the respective cores */ |
287 | #if VERBOSE | 287 | #if VERBOSE |
288 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 288 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from peer 1 `%4s'\n", |
289 | "Disconnecting from peer 1 `%4s'\n", | ||
290 | GNUNET_i2s (&pos->peer1->id)); | 289 | GNUNET_i2s (&pos->peer1->id)); |
291 | #endif | 290 | #endif |
292 | if (pos->peer1handle != NULL) | 291 | if (pos->peer1handle != NULL) |
293 | GNUNET_CORE_disconnect (pos->peer1handle); | 292 | GNUNET_CORE_disconnect (pos->peer1handle); |
294 | #if VERBOSE | 293 | #if VERBOSE |
295 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 294 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from peer 2 `%4s'\n", |
296 | "Disconnecting from peer 2 `%4s'\n", | ||
297 | GNUNET_i2s (&pos->peer2->id)); | 295 | GNUNET_i2s (&pos->peer2->id)); |
298 | #endif | 296 | #endif |
299 | if (pos->peer2handle != NULL) | 297 | if (pos->peer2handle != NULL) |
@@ -384,8 +382,8 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
384 | } | 382 | } |
385 | } | 383 | } |
386 | 384 | ||
387 | static void | 385 | static void send_other_messages (void *cls, |
388 | send_other_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 386 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
389 | 387 | ||
390 | /** | 388 | /** |
391 | * Get distance information from 'atsi'. | 389 | * Get distance information from 'atsi'. |
@@ -409,8 +407,7 @@ get_atsi_distance (const struct GNUNET_TRANSPORT_ATS_Information *atsi) | |||
409 | } | 407 | } |
410 | 408 | ||
411 | static int | 409 | static int |
412 | process_mtype (void *cls, | 410 | process_mtype (void *cls, const struct GNUNET_PeerIdentity *peer, |
413 | const struct GNUNET_PeerIdentity *peer, | ||
414 | const struct GNUNET_MessageHeader *message, | 411 | const struct GNUNET_MessageHeader *message, |
415 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 412 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
416 | { | 413 | { |
@@ -460,9 +457,9 @@ process_mtype (void *cls, | |||
460 | (total_other_messages == 0)) | 457 | (total_other_messages == 0)) |
461 | { | 458 | { |
462 | GNUNET_SCHEDULER_cancel (die_task); | 459 | GNUNET_SCHEDULER_cancel (die_task); |
463 | die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, | 460 | die_task = |
464 | &end_badly, | 461 | GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly, |
465 | "waiting for DV peers to connect!"); | 462 | "waiting for DV peers to connect!"); |
466 | /* | 463 | /* |
467 | * if ((num_peers == 3) && (total_other_expected_messages == 2)) | 464 | * if ((num_peers == 3) && (total_other_expected_messages == 2)) |
468 | * { | 465 | * { |
@@ -527,9 +524,7 @@ static struct GNUNET_CORE_MessageHandler handlers[] = { | |||
527 | * @param atsi performance data for the connection | 524 | * @param atsi performance data for the connection |
528 | */ | 525 | */ |
529 | static void | 526 | static void |
530 | connect_notify_peer2 (void *cls, | 527 | connect_notify_peer2 (void *cls, const struct GNUNET_PeerIdentity *peer, |
531 | const struct | ||
532 | GNUNET_PeerIdentity *peer, | ||
533 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 528 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
534 | { | 529 | { |
535 | struct TestMessageContext *pos = cls; | 530 | struct TestMessageContext *pos = cls; |
@@ -541,14 +536,11 @@ connect_notify_peer2 (void *cls, | |||
541 | "Core connection from `%s' to `%4s' verfied, sending message!\n", | 536 | "Core connection from `%s' to `%4s' verfied, sending message!\n", |
542 | GNUNET_i2s (&pos->peer2->id), GNUNET_h2s (&peer->hashPubKey)); | 537 | GNUNET_i2s (&pos->peer2->id), GNUNET_h2s (&peer->hashPubKey)); |
543 | #endif | 538 | #endif |
544 | if (NULL == GNUNET_CORE_notify_transmit_ready (pos->peer1handle, | 539 | if (NULL == |
545 | GNUNET_YES, | 540 | GNUNET_CORE_notify_transmit_ready (pos->peer1handle, GNUNET_YES, 0, |
546 | 0, | 541 | TIMEOUT, &pos->peer2->id, |
547 | TIMEOUT, | 542 | sizeof (struct GNUNET_TestMessage), |
548 | &pos->peer2->id, | 543 | &transmit_ready, pos)) |
549 | sizeof (struct | ||
550 | GNUNET_TestMessage), | ||
551 | &transmit_ready, pos)) | ||
552 | { | 544 | { |
553 | /* This probably shouldn't happen, but it does (timing issue?) */ | 545 | /* This probably shouldn't happen, but it does (timing issue?) */ |
554 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 546 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
@@ -565,8 +557,7 @@ connect_notify_peer2 (void *cls, | |||
565 | } | 557 | } |
566 | 558 | ||
567 | static void | 559 | static void |
568 | init_notify_peer2 (void *cls, | 560 | init_notify_peer2 (void *cls, struct GNUNET_CORE_Handle *server, |
569 | struct GNUNET_CORE_Handle *server, | ||
570 | const struct GNUNET_PeerIdentity *my_identity, | 561 | const struct GNUNET_PeerIdentity *my_identity, |
571 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded | 562 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded |
572 | *publicKey) | 563 | *publicKey) |
@@ -588,9 +579,7 @@ init_notify_peer2 (void *cls, | |||
588 | * @param atsi performance data for the connection | 579 | * @param atsi performance data for the connection |
589 | */ | 580 | */ |
590 | static void | 581 | static void |
591 | connect_notify_peer1 (void *cls, | 582 | connect_notify_peer1 (void *cls, const struct GNUNET_PeerIdentity *peer, |
592 | const struct | ||
593 | GNUNET_PeerIdentity *peer, | ||
594 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 583 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
595 | { | 584 | { |
596 | struct TestMessageContext *pos = cls; | 585 | struct TestMessageContext *pos = cls; |
@@ -605,21 +594,15 @@ connect_notify_peer1 (void *cls, | |||
605 | /* | 594 | /* |
606 | * Connect to the receiving peer | 595 | * Connect to the receiving peer |
607 | */ | 596 | */ |
608 | pos->peer2handle = GNUNET_CORE_connect (pos->peer2->cfg, | 597 | pos->peer2handle = |
609 | 1, | 598 | GNUNET_CORE_connect (pos->peer2->cfg, 1, pos, &init_notify_peer2, |
610 | pos, | 599 | &connect_notify_peer2, NULL, NULL, NULL, |
611 | &init_notify_peer2, | 600 | GNUNET_YES, NULL, GNUNET_YES, handlers); |
612 | &connect_notify_peer2, | ||
613 | NULL, | ||
614 | NULL, NULL, | ||
615 | GNUNET_YES, NULL, GNUNET_YES, | ||
616 | handlers); | ||
617 | } | 601 | } |
618 | } | 602 | } |
619 | 603 | ||
620 | static void | 604 | static void |
621 | init_notify_peer1 (void *cls, | 605 | init_notify_peer1 (void *cls, struct GNUNET_CORE_Handle *server, |
622 | struct GNUNET_CORE_Handle *server, | ||
623 | const struct GNUNET_PeerIdentity *my_identity, | 606 | const struct GNUNET_PeerIdentity *my_identity, |
624 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded | 607 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded |
625 | *publicKey) | 608 | *publicKey) |
@@ -643,9 +626,9 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
643 | 626 | ||
644 | if (die_task == GNUNET_SCHEDULER_NO_TASK) | 627 | if (die_task == GNUNET_SCHEDULER_NO_TASK) |
645 | { | 628 | { |
646 | die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, | 629 | die_task = |
647 | &end_badly, | 630 | GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly, |
648 | "from create topology (timeout)"); | 631 | "from create topology (timeout)"); |
649 | } | 632 | } |
650 | 633 | ||
651 | if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS) | 634 | if (total_server_connections >= MAX_OUTSTANDING_CONNECTIONS) |
@@ -663,16 +646,10 @@ send_test_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
663 | /* | 646 | /* |
664 | * Connect to the sending peer | 647 | * Connect to the sending peer |
665 | */ | 648 | */ |
666 | pos->peer1handle = GNUNET_CORE_connect (pos->peer1->cfg, | 649 | pos->peer1handle = |
667 | 1, | 650 | GNUNET_CORE_connect (pos->peer1->cfg, 1, pos, &init_notify_peer1, |
668 | pos, | 651 | &connect_notify_peer1, NULL, NULL, NULL, GNUNET_NO, |
669 | &init_notify_peer1, | 652 | NULL, GNUNET_NO, no_handlers); |
670 | &connect_notify_peer1, | ||
671 | NULL, | ||
672 | NULL, | ||
673 | NULL, | ||
674 | GNUNET_NO, NULL, GNUNET_NO, | ||
675 | no_handlers); | ||
676 | 653 | ||
677 | GNUNET_assert (pos->peer1handle != NULL); | 654 | GNUNET_assert (pos->peer1handle != NULL); |
678 | 655 | ||
@@ -773,10 +750,8 @@ send_other_messages (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
773 | } | 750 | } |
774 | 751 | ||
775 | static void | 752 | static void |
776 | topology_callback (void *cls, | 753 | topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, |
777 | const struct GNUNET_PeerIdentity *first, | 754 | const struct GNUNET_PeerIdentity *second, uint32_t distance, |
778 | const struct GNUNET_PeerIdentity *second, | ||
779 | uint32_t distance, | ||
780 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, | 755 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, |
781 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, | 756 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, |
782 | struct GNUNET_TESTING_Daemon *first_daemon, | 757 | struct GNUNET_TESTING_Daemon *first_daemon, |
@@ -859,15 +834,14 @@ connect_topology () | |||
859 | expected_connections = -1; | 834 | expected_connections = -1; |
860 | if ((pg != NULL) && (peers_left == 0)) | 835 | if ((pg != NULL) && (peers_left == 0)) |
861 | { | 836 | { |
862 | expected_connections = GNUNET_TESTING_connect_topology (pg, | 837 | expected_connections = |
863 | connection_topology, | 838 | GNUNET_TESTING_connect_topology (pg, connection_topology, |
864 | connect_topology_option, | 839 | connect_topology_option, |
865 | connect_topology_option_modifier, | 840 | connect_topology_option_modifier, |
866 | TIMEOUT, | 841 | TIMEOUT, 12, NULL, NULL); |
867 | 12, NULL, NULL); | ||
868 | #if VERBOSE | 842 | #if VERBOSE |
869 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 843 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Have %d expected connections\n", |
870 | "Have %d expected connections\n", expected_connections); | 844 | expected_connections); |
871 | #endif | 845 | #endif |
872 | } | 846 | } |
873 | 847 | ||
@@ -879,9 +853,9 @@ connect_topology () | |||
879 | "from connect topology (bad return)"); | 853 | "from connect topology (bad return)"); |
880 | } | 854 | } |
881 | 855 | ||
882 | die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, | 856 | die_task = |
883 | &end_badly, | 857 | GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly, |
884 | "from connect topology (timeout)"); | 858 | "from connect topology (timeout)"); |
885 | } | 859 | } |
886 | 860 | ||
887 | static void | 861 | static void |
@@ -905,9 +879,9 @@ create_topology () | |||
905 | "from create topology (bad return)"); | 879 | "from create topology (bad return)"); |
906 | } | 880 | } |
907 | GNUNET_SCHEDULER_cancel (die_task); | 881 | GNUNET_SCHEDULER_cancel (die_task); |
908 | die_task = GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, | 882 | die_task = |
909 | &end_badly, | 883 | GNUNET_SCHEDULER_add_delayed (TEST_TIMEOUT, &end_badly, |
910 | "from continue startup (timeout)"); | 884 | "from continue startup (timeout)"); |
911 | } | 885 | } |
912 | 886 | ||
913 | /** | 887 | /** |
@@ -919,9 +893,7 @@ create_topology () | |||
919 | * @param distance reported distance (DV) to 'other' | 893 | * @param distance reported distance (DV) to 'other' |
920 | */ | 894 | */ |
921 | static void | 895 | static void |
922 | all_connect_handler (void *cls, | 896 | all_connect_handler (void *cls, const struct GNUNET_PeerIdentity *peer, |
923 | const struct | ||
924 | GNUNET_PeerIdentity *peer, | ||
925 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 897 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
926 | { | 898 | { |
927 | struct GNUNET_TESTING_Daemon *d = cls; | 899 | struct GNUNET_TESTING_Daemon *d = cls; |
@@ -940,8 +912,8 @@ all_connect_handler (void *cls, | |||
940 | 912 | ||
941 | #if VERBOSE | 913 | #if VERBOSE |
942 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 914 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
943 | "connected peer %s to peer %s, distance %u\n", | 915 | "connected peer %s to peer %s, distance %u\n", d->shortname, |
944 | d->shortname, second_shortname, distance); | 916 | second_shortname, distance); |
945 | #endif | 917 | #endif |
946 | 918 | ||
947 | second_daemon = | 919 | second_daemon = |
@@ -993,8 +965,7 @@ all_connect_handler (void *cls, | |||
993 | } | 965 | } |
994 | 966 | ||
995 | static void | 967 | static void |
996 | peers_started_callback (void *cls, | 968 | peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id, |
997 | const struct GNUNET_PeerIdentity *id, | ||
998 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 969 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
999 | struct GNUNET_TESTING_Daemon *d, const char *emsg) | 970 | struct GNUNET_TESTING_Daemon *d, const char *emsg) |
1000 | { | 971 | { |
@@ -1017,13 +988,9 @@ peers_started_callback (void *cls, | |||
1017 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); | 988 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)); |
1018 | 989 | ||
1019 | new_peer = GNUNET_malloc (sizeof (struct PeerContext)); | 990 | new_peer = GNUNET_malloc (sizeof (struct PeerContext)); |
1020 | new_peer->peer_handle = GNUNET_CORE_connect (cfg, | 991 | new_peer->peer_handle = |
1021 | 1, | 992 | GNUNET_CORE_connect (cfg, 1, d, NULL, &all_connect_handler, NULL, NULL, |
1022 | d, NULL, | 993 | NULL, GNUNET_NO, NULL, GNUNET_NO, no_handlers); |
1023 | &all_connect_handler, | ||
1024 | NULL, NULL, NULL, | ||
1025 | GNUNET_NO, NULL, GNUNET_NO, | ||
1026 | no_handlers); | ||
1027 | new_peer->daemon = d; | 994 | new_peer->daemon = d; |
1028 | new_peer->next = all_peers; | 995 | new_peer->next = all_peers; |
1029 | all_peers = new_peer; | 996 | all_peers = new_peer; |
@@ -1038,10 +1005,10 @@ peers_started_callback (void *cls, | |||
1038 | GNUNET_SCHEDULER_cancel (die_task); | 1005 | GNUNET_SCHEDULER_cancel (die_task); |
1039 | /* Set up task in case topology creation doesn't finish | 1006 | /* Set up task in case topology creation doesn't finish |
1040 | * within a reasonable amount of time */ | 1007 | * within a reasonable amount of time */ |
1041 | die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 1008 | die_task = |
1042 | (GNUNET_TIME_UNIT_MINUTES, 5), | 1009 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
1043 | &end_badly, | 1010 | (GNUNET_TIME_UNIT_MINUTES, 5), &end_badly, |
1044 | "from peers_started_callback"); | 1011 | "from peers_started_callback"); |
1045 | 1012 | ||
1046 | connect_topology (); | 1013 | connect_topology (); |
1047 | ok = 0; | 1014 | ok = 0; |
@@ -1057,8 +1024,7 @@ peers_started_callback (void *cls, | |||
1057 | * @param emsg non-null on failure | 1024 | * @param emsg non-null on failure |
1058 | */ | 1025 | */ |
1059 | static void | 1026 | static void |
1060 | hostkey_callback (void *cls, | 1027 | hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id, |
1061 | const struct GNUNET_PeerIdentity *id, | ||
1062 | struct GNUNET_TESTING_Daemon *d, const char *emsg) | 1028 | struct GNUNET_TESTING_Daemon *d, const char *emsg) |
1063 | { | 1029 | { |
1064 | if (emsg != NULL) | 1030 | if (emsg != NULL) |
@@ -1068,8 +1034,8 @@ hostkey_callback (void *cls, | |||
1068 | } | 1034 | } |
1069 | 1035 | ||
1070 | #if VERBOSE | 1036 | #if VERBOSE |
1071 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1037 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Hostkey created for peer `%s'\n", |
1072 | "Hostkey created for peer `%s'\n", GNUNET_i2s (id)); | 1038 | GNUNET_i2s (id)); |
1073 | #endif | 1039 | #endif |
1074 | peers_left--; | 1040 | peers_left--; |
1075 | if (peers_left == 0) | 1041 | if (peers_left == 0) |
@@ -1081,19 +1047,18 @@ hostkey_callback (void *cls, | |||
1081 | GNUNET_SCHEDULER_cancel (die_task); | 1047 | GNUNET_SCHEDULER_cancel (die_task); |
1082 | /* Set up task in case topology creation doesn't finish | 1048 | /* Set up task in case topology creation doesn't finish |
1083 | * within a reasonable amount of time */ | 1049 | * within a reasonable amount of time */ |
1084 | die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 1050 | die_task = |
1085 | (GNUNET_TIME_UNIT_MINUTES, 5), | 1051 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
1086 | &end_badly, | 1052 | (GNUNET_TIME_UNIT_MINUTES, 5), &end_badly, |
1087 | "from hostkey_callback"); | 1053 | "from hostkey_callback"); |
1088 | GNUNET_SCHEDULER_add_now (&create_topology, NULL); | 1054 | GNUNET_SCHEDULER_add_now (&create_topology, NULL); |
1089 | ok = 0; | 1055 | ok = 0; |
1090 | } | 1056 | } |
1091 | } | 1057 | } |
1092 | 1058 | ||
1093 | static void | 1059 | static void |
1094 | run (void *cls, | 1060 | run (void *cls, char *const *args, const char *cfgfile, |
1095 | char *const *args, | 1061 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
1096 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
1097 | { | 1062 | { |
1098 | char *topology_str; | 1063 | char *topology_str; |
1099 | char *connect_topology_str; | 1064 | char *connect_topology_str; |
@@ -1216,20 +1181,18 @@ run (void *cls, | |||
1216 | peers_left = num_peers; | 1181 | peers_left = num_peers; |
1217 | 1182 | ||
1218 | /* Set up a task to end testing if peer start fails */ | 1183 | /* Set up a task to end testing if peer start fails */ |
1219 | die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 1184 | die_task = |
1220 | (GNUNET_TIME_UNIT_MINUTES, 5), | 1185 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
1221 | &end_badly, | 1186 | (GNUNET_TIME_UNIT_MINUTES, 5), &end_badly, |
1222 | "didn't start all daemons in reasonable amount of time!!!"); | 1187 | "didn't start all daemons in reasonable amount of time!!!"); |
1223 | 1188 | ||
1224 | peer_daemon_hash = GNUNET_CONTAINER_multihashmap_create (peers_left); | 1189 | peer_daemon_hash = GNUNET_CONTAINER_multihashmap_create (peers_left); |
1225 | pg = GNUNET_TESTING_daemons_start (cfg, peers_left, /* Total number of peers */ | 1190 | pg = GNUNET_TESTING_daemons_start (cfg, peers_left, /* Total number of peers */ |
1226 | peers_left, /* Number of outstanding connections */ | 1191 | peers_left, /* Number of outstanding connections */ |
1227 | peers_left, /* Number of parallel ssh connections, or peers being started at once */ | 1192 | peers_left, /* Number of parallel ssh connections, or peers being started at once */ |
1228 | TIMEOUT, | 1193 | TIMEOUT, &hostkey_callback, NULL, |
1229 | &hostkey_callback, | 1194 | &peers_started_callback, NULL, |
1230 | NULL, | 1195 | &topology_callback, NULL, NULL); |
1231 | &peers_started_callback, | ||
1232 | NULL, &topology_callback, NULL, NULL); | ||
1233 | 1196 | ||
1234 | } | 1197 | } |
1235 | 1198 | ||
@@ -1249,9 +1212,9 @@ check () | |||
1249 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 1212 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
1250 | GNUNET_GETOPT_OPTION_END | 1213 | GNUNET_GETOPT_OPTION_END |
1251 | }; | 1214 | }; |
1252 | ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | 1215 | ret = |
1253 | argv, "test-transport-dv", "nohelp", | 1216 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, |
1254 | options, &run, &ok); | 1217 | "test-transport-dv", "nohelp", options, &run, &ok); |
1255 | if (ret != GNUNET_OK) | 1218 | if (ret != GNUNET_OK) |
1256 | { | 1219 | { |
1257 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1220 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |