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/dht | |
parent | 6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff) | |
download | gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip |
indentation
Diffstat (limited to 'src/dht')
-rw-r--r-- | src/dht/dht_api.c | 118 | ||||
-rw-r--r-- | src/dht/dht_api_find_peer.c | 12 | ||||
-rw-r--r-- | src/dht/dht_api_get_put.c | 43 | ||||
-rw-r--r-- | src/dht/dhtlog.c | 8 | ||||
-rw-r--r-- | src/dht/gnunet-dht-driver.c | 1029 | ||||
-rw-r--r-- | src/dht/gnunet-dht-get-peer.c | 17 | ||||
-rw-r--r-- | src/dht/gnunet-dht-get.c | 28 | ||||
-rw-r--r-- | src/dht/gnunet-dht-put.c | 15 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht.c | 572 | ||||
-rw-r--r-- | src/dht/plugin_dhtlog_dummy.c | 31 | ||||
-rw-r--r-- | src/dht/plugin_dhtlog_mysql.c | 678 | ||||
-rw-r--r-- | src/dht/plugin_dhtlog_mysql_dump.c | 107 | ||||
-rw-r--r-- | src/dht/plugin_dhtlog_mysql_dump_load.c | 109 | ||||
-rw-r--r-- | src/dht/test_dht_api.c | 53 | ||||
-rw-r--r-- | src/dht/test_dht_multipeer.c | 96 | ||||
-rw-r--r-- | src/dht/test_dht_twopeer.c | 90 | ||||
-rw-r--r-- | src/dht/test_dht_twopeer_path_tracking.c | 74 | ||||
-rw-r--r-- | src/dht/test_dht_twopeer_put_get.c | 103 | ||||
-rw-r--r-- | src/dht/test_dhtlog.c | 9 |
19 files changed, 1469 insertions, 1723 deletions
diff --git a/src/dht/dht_api.c b/src/dht/dht_api.c index 101751487..eded50efc 100644 --- a/src/dht/dht_api.c +++ b/src/dht/dht_api.c | |||
@@ -211,8 +211,8 @@ static size_t transmit_pending (void *cls, size_t size, void *buf); | |||
211 | * a demultiplexer which handles numerous message types | 211 | * a demultiplexer which handles numerous message types |
212 | * | 212 | * |
213 | */ | 213 | */ |
214 | static void | 214 | static void service_message_handler (void *cls, |
215 | service_message_handler (void *cls, const struct GNUNET_MessageHeader *msg); | 215 | const struct GNUNET_MessageHeader *msg); |
216 | 216 | ||
217 | 217 | ||
218 | 218 | ||
@@ -238,9 +238,8 @@ try_connect (struct GNUNET_DHT_Handle *handle) | |||
238 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 238 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
239 | "Starting to process replies from DHT\n"); | 239 | "Starting to process replies from DHT\n"); |
240 | #endif | 240 | #endif |
241 | GNUNET_CLIENT_receive (handle->client, | 241 | GNUNET_CLIENT_receive (handle->client, &service_message_handler, handle, |
242 | &service_message_handler, | 242 | GNUNET_TIME_UNIT_FOREVER_REL); |
243 | handle, GNUNET_TIME_UNIT_FOREVER_REL); | ||
244 | return GNUNET_YES; | 243 | return GNUNET_YES; |
245 | } | 244 | } |
246 | 245 | ||
@@ -262,8 +261,8 @@ add_request_to_pending (void *cls, const GNUNET_HashCode * key, void *value) | |||
262 | 261 | ||
263 | if (GNUNET_NO == rh->message->in_pending_queue) | 262 | if (GNUNET_NO == rh->message->in_pending_queue) |
264 | { | 263 | { |
265 | GNUNET_CONTAINER_DLL_insert (handle->pending_head, | 264 | GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail, |
266 | handle->pending_tail, rh->message); | 265 | rh->message); |
267 | rh->message->in_pending_queue = GNUNET_YES; | 266 | rh->message->in_pending_queue = GNUNET_YES; |
268 | } | 267 | } |
269 | return GNUNET_YES; | 268 | return GNUNET_YES; |
@@ -321,9 +320,8 @@ do_disconnect (struct GNUNET_DHT_Handle *handle) | |||
321 | GNUNET_assert (handle->reconnect_task == GNUNET_SCHEDULER_NO_TASK); | 320 | GNUNET_assert (handle->reconnect_task == GNUNET_SCHEDULER_NO_TASK); |
322 | GNUNET_CLIENT_disconnect (handle->client, GNUNET_NO); | 321 | GNUNET_CLIENT_disconnect (handle->client, GNUNET_NO); |
323 | handle->client = NULL; | 322 | handle->client = NULL; |
324 | handle->reconnect_task = GNUNET_SCHEDULER_add_delayed (handle->retry_time, | 323 | handle->reconnect_task = |
325 | &try_reconnect, | 324 | GNUNET_SCHEDULER_add_delayed (handle->retry_time, &try_reconnect, handle); |
326 | handle); | ||
327 | } | 325 | } |
328 | 326 | ||
329 | 327 | ||
@@ -344,11 +342,12 @@ process_pending_messages (struct GNUNET_DHT_Handle *handle) | |||
344 | return; | 342 | return; |
345 | if (NULL == (head = handle->pending_head)) | 343 | if (NULL == (head = handle->pending_head)) |
346 | return; | 344 | return; |
347 | handle->th = GNUNET_CLIENT_notify_transmit_ready (handle->client, | 345 | handle->th = |
348 | ntohs (head->msg->size), | 346 | GNUNET_CLIENT_notify_transmit_ready (handle->client, |
349 | GNUNET_TIME_UNIT_FOREVER_REL, | 347 | ntohs (head->msg->size), |
350 | GNUNET_YES, | 348 | GNUNET_TIME_UNIT_FOREVER_REL, |
351 | &transmit_pending, handle); | 349 | GNUNET_YES, &transmit_pending, |
350 | handle); | ||
352 | if (NULL == handle->th) | 351 | if (NULL == handle->th) |
353 | { | 352 | { |
354 | do_disconnect (handle); | 353 | do_disconnect (handle); |
@@ -385,8 +384,8 @@ transmit_pending (void *cls, size_t size, void *buf) | |||
385 | return 0; | 384 | return 0; |
386 | } | 385 | } |
387 | memcpy (buf, head->msg, tsize); | 386 | memcpy (buf, head->msg, tsize); |
388 | GNUNET_CONTAINER_DLL_remove (handle->pending_head, | 387 | GNUNET_CONTAINER_DLL_remove (handle->pending_head, handle->pending_tail, |
389 | handle->pending_tail, head); | 388 | head); |
390 | if (head->timeout_task != GNUNET_SCHEDULER_NO_TASK) | 389 | if (head->timeout_task != GNUNET_SCHEDULER_NO_TASK) |
391 | { | 390 | { |
392 | GNUNET_SCHEDULER_cancel (head->timeout_task); | 391 | GNUNET_SCHEDULER_cancel (head->timeout_task); |
@@ -394,8 +393,7 @@ transmit_pending (void *cls, size_t size, void *buf) | |||
394 | } | 393 | } |
395 | if (NULL != head->cont) | 394 | if (NULL != head->cont) |
396 | { | 395 | { |
397 | GNUNET_SCHEDULER_add_continuation (head->cont, | 396 | GNUNET_SCHEDULER_add_continuation (head->cont, head->cont_cls, |
398 | head->cont_cls, | ||
399 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 397 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
400 | head->cont = NULL; | 398 | head->cont = NULL; |
401 | head->cont_cls = NULL; | 399 | head->cont_cls = NULL; |
@@ -514,13 +512,12 @@ service_message_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
514 | GNUNET_h2s (&dht_msg->key), | 512 | GNUNET_h2s (&dht_msg->key), |
515 | GNUNET_CONTAINER_multihashmap_size (handle->active_requests)); | 513 | GNUNET_CONTAINER_multihashmap_size (handle->active_requests)); |
516 | GNUNET_CONTAINER_multihashmap_get_multiple (handle->active_requests, | 514 | GNUNET_CONTAINER_multihashmap_get_multiple (handle->active_requests, |
517 | &dht_msg->key, | 515 | &dht_msg->key, &process_reply, |
518 | &process_reply, (void *) dht_msg); | 516 | (void *) dht_msg); |
519 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 517 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
520 | "Continuing to process replies from DHT\n"); | 518 | "Continuing to process replies from DHT\n"); |
521 | GNUNET_CLIENT_receive (handle->client, | 519 | GNUNET_CLIENT_receive (handle->client, &service_message_handler, handle, |
522 | &service_message_handler, | 520 | GNUNET_TIME_UNIT_FOREVER_REL); |
523 | handle, GNUNET_TIME_UNIT_FOREVER_REL); | ||
524 | 521 | ||
525 | } | 522 | } |
526 | 523 | ||
@@ -574,14 +571,13 @@ GNUNET_DHT_disconnect (struct GNUNET_DHT_Handle *handle) | |||
574 | } | 571 | } |
575 | while (NULL != (pm = handle->pending_head)) | 572 | while (NULL != (pm = handle->pending_head)) |
576 | { | 573 | { |
577 | GNUNET_CONTAINER_DLL_remove (handle->pending_head, | 574 | GNUNET_CONTAINER_DLL_remove (handle->pending_head, handle->pending_tail, |
578 | handle->pending_tail, pm); | 575 | pm); |
579 | GNUNET_assert (GNUNET_YES == pm->free_on_send); | 576 | GNUNET_assert (GNUNET_YES == pm->free_on_send); |
580 | if (GNUNET_SCHEDULER_NO_TASK != pm->timeout_task) | 577 | if (GNUNET_SCHEDULER_NO_TASK != pm->timeout_task) |
581 | GNUNET_SCHEDULER_cancel (pm->timeout_task); | 578 | GNUNET_SCHEDULER_cancel (pm->timeout_task); |
582 | if (NULL != pm->cont) | 579 | if (NULL != pm->cont) |
583 | GNUNET_SCHEDULER_add_continuation (pm->cont, | 580 | GNUNET_SCHEDULER_add_continuation (pm->cont, pm->cont_cls, |
584 | pm->cont_cls, | ||
585 | GNUNET_SCHEDULER_REASON_TIMEOUT); | 581 | GNUNET_SCHEDULER_REASON_TIMEOUT); |
586 | pm->in_pending_queue = GNUNET_NO; | 582 | pm->in_pending_queue = GNUNET_NO; |
587 | GNUNET_free (pm); | 583 | GNUNET_free (pm); |
@@ -622,8 +618,8 @@ timeout_route_request (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
622 | return; | 618 | return; |
623 | } | 619 | } |
624 | handle = pending->handle; | 620 | handle = pending->handle; |
625 | GNUNET_CONTAINER_DLL_remove (handle->pending_head, | 621 | GNUNET_CONTAINER_DLL_remove (handle->pending_head, handle->pending_tail, |
626 | handle->pending_tail, pending); | 622 | pending); |
627 | if (pending->cont != NULL) | 623 | if (pending->cont != NULL) |
628 | pending->cont (pending->cont_cls, tc); | 624 | pending->cont (pending->cont_cls, tc); |
629 | GNUNET_free (pending); | 625 | GNUNET_free (pending); |
@@ -658,8 +654,7 @@ GNUNET_DHT_route_start (struct GNUNET_DHT_Handle *handle, | |||
658 | enum GNUNET_DHT_RouteOption options, | 654 | enum GNUNET_DHT_RouteOption options, |
659 | const struct GNUNET_MessageHeader *enc, | 655 | const struct GNUNET_MessageHeader *enc, |
660 | struct GNUNET_TIME_Relative timeout, | 656 | struct GNUNET_TIME_Relative timeout, |
661 | GNUNET_DHT_ReplyProcessor iter, | 657 | GNUNET_DHT_ReplyProcessor iter, void *iter_cls, |
662 | void *iter_cls, | ||
663 | GNUNET_SCHEDULER_Task cont, void *cont_cls) | 658 | GNUNET_SCHEDULER_Task cont, void *cont_cls) |
664 | { | 659 | { |
665 | struct PendingMessage *pending; | 660 | struct PendingMessage *pending; |
@@ -702,8 +697,7 @@ GNUNET_DHT_route_start (struct GNUNET_DHT_Handle *handle, | |||
702 | route_handle->dht_handle = handle; | 697 | route_handle->dht_handle = handle; |
703 | route_handle->uid = handle->uid_gen; | 698 | route_handle->uid = handle->uid_gen; |
704 | route_handle->message = pending; | 699 | route_handle->message = pending; |
705 | GNUNET_CONTAINER_multihashmap_put (handle->active_requests, | 700 | GNUNET_CONTAINER_multihashmap_put (handle->active_requests, key, |
706 | key, | ||
707 | route_handle, | 701 | route_handle, |
708 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 702 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
709 | } | 703 | } |
@@ -711,12 +705,11 @@ GNUNET_DHT_route_start (struct GNUNET_DHT_Handle *handle, | |||
711 | { | 705 | { |
712 | route_handle = NULL; | 706 | route_handle = NULL; |
713 | pending->free_on_send = GNUNET_YES; | 707 | pending->free_on_send = GNUNET_YES; |
714 | pending->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, | 708 | pending->timeout_task = |
715 | &timeout_route_request, | 709 | GNUNET_SCHEDULER_add_delayed (timeout, &timeout_route_request, pending); |
716 | pending); | ||
717 | } | 710 | } |
718 | GNUNET_CONTAINER_DLL_insert (handle->pending_head, | 711 | GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail, |
719 | handle->pending_tail, pending); | 712 | pending); |
720 | pending->in_pending_queue = GNUNET_YES; | 713 | pending->in_pending_queue = GNUNET_YES; |
721 | process_pending_messages (handle); | 714 | process_pending_messages (handle); |
722 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 715 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -755,21 +748,23 @@ GNUNET_DHT_route_stop (struct GNUNET_DHT_RouteHandle *route_handle) | |||
755 | pending->handle = handle; | 748 | pending->handle = handle; |
756 | pending->free_on_send = GNUNET_YES; | 749 | pending->free_on_send = GNUNET_YES; |
757 | pending->in_pending_queue = GNUNET_YES; | 750 | pending->in_pending_queue = GNUNET_YES; |
758 | GNUNET_CONTAINER_DLL_insert (handle->pending_head, | 751 | GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail, |
759 | handle->pending_tail, pending); | 752 | pending); |
760 | process_pending_messages (handle); | 753 | process_pending_messages (handle); |
761 | } | 754 | } |
762 | else | 755 | else |
763 | { | 756 | { |
764 | /* simply remove pending request from message queue before | 757 | /* simply remove pending request from message queue before |
765 | * transmission, no need to transmit STOP request! */ | 758 | * transmission, no need to transmit STOP request! */ |
766 | GNUNET_CONTAINER_DLL_remove (handle->pending_head, | 759 | GNUNET_CONTAINER_DLL_remove (handle->pending_head, handle->pending_tail, |
767 | handle->pending_tail, route_handle->message); | 760 | route_handle->message); |
768 | } | 761 | } |
769 | GNUNET_assert (GNUNET_YES == | 762 | GNUNET_assert (GNUNET_YES == |
770 | GNUNET_CONTAINER_multihashmap_remove | 763 | GNUNET_CONTAINER_multihashmap_remove (route_handle-> |
771 | (route_handle->dht_handle->active_requests, &route_handle->key, | 764 | dht_handle-> |
772 | route_handle)); | 765 | active_requests, |
766 | &route_handle->key, | ||
767 | route_handle)); | ||
773 | GNUNET_free (route_handle->message); | 768 | GNUNET_free (route_handle->message); |
774 | GNUNET_free (route_handle); | 769 | GNUNET_free (route_handle); |
775 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DHT route stop request processed\n"); | 770 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "DHT route stop request processed\n"); |
@@ -790,16 +785,16 @@ GNUNET_DHT_route_stop (struct GNUNET_DHT_RouteHandle *route_handle) | |||
790 | * @param cont_cls closure for cont | 785 | * @param cont_cls closure for cont |
791 | */ | 786 | */ |
792 | static void | 787 | static void |
793 | send_control_message (struct GNUNET_DHT_Handle *handle, | 788 | send_control_message (struct GNUNET_DHT_Handle *handle, uint16_t command, |
794 | uint16_t command, | 789 | uint16_t variable, GNUNET_SCHEDULER_Task cont, |
795 | uint16_t variable, | 790 | void *cont_cls) |
796 | GNUNET_SCHEDULER_Task cont, void *cont_cls) | ||
797 | { | 791 | { |
798 | struct GNUNET_DHT_ControlMessage *msg; | 792 | struct GNUNET_DHT_ControlMessage *msg; |
799 | struct PendingMessage *pending; | 793 | struct PendingMessage *pending; |
800 | 794 | ||
801 | pending = GNUNET_malloc (sizeof (struct PendingMessage) + | 795 | pending = |
802 | sizeof (struct GNUNET_DHT_ControlMessage)); | 796 | GNUNET_malloc (sizeof (struct PendingMessage) + |
797 | sizeof (struct GNUNET_DHT_ControlMessage)); | ||
803 | msg = (struct GNUNET_DHT_ControlMessage *) &pending[1]; | 798 | msg = (struct GNUNET_DHT_ControlMessage *) &pending[1]; |
804 | pending->msg = &msg->header; | 799 | pending->msg = &msg->header; |
805 | msg->header.size = htons (sizeof (struct GNUNET_DHT_ControlMessage)); | 800 | msg->header.size = htons (sizeof (struct GNUNET_DHT_ControlMessage)); |
@@ -810,8 +805,8 @@ send_control_message (struct GNUNET_DHT_Handle *handle, | |||
810 | pending->cont = cont; | 805 | pending->cont = cont; |
811 | pending->cont_cls = cont_cls; | 806 | pending->cont_cls = cont_cls; |
812 | pending->in_pending_queue = GNUNET_YES; | 807 | pending->in_pending_queue = GNUNET_YES; |
813 | GNUNET_CONTAINER_DLL_insert (handle->pending_head, | 808 | GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail, |
814 | handle->pending_tail, pending); | 809 | pending); |
815 | process_pending_messages (handle); | 810 | process_pending_messages (handle); |
816 | } | 811 | } |
817 | 812 | ||
@@ -831,8 +826,8 @@ void | |||
831 | GNUNET_DHT_find_peers (struct GNUNET_DHT_Handle *handle, | 826 | GNUNET_DHT_find_peers (struct GNUNET_DHT_Handle *handle, |
832 | GNUNET_SCHEDULER_Task cont, void *cont_cls) | 827 | GNUNET_SCHEDULER_Task cont, void *cont_cls) |
833 | { | 828 | { |
834 | send_control_message (handle, | 829 | send_control_message (handle, GNUNET_MESSAGE_TYPE_DHT_FIND_PEER, 0, cont, |
835 | GNUNET_MESSAGE_TYPE_DHT_FIND_PEER, 0, cont, cont_cls); | 830 | cont_cls); |
836 | } | 831 | } |
837 | 832 | ||
838 | 833 | ||
@@ -858,8 +853,7 @@ GNUNET_DHT_set_malicious_getter (struct GNUNET_DHT_Handle *handle, | |||
858 | GNUNET_break (0); | 853 | GNUNET_break (0); |
859 | return; | 854 | return; |
860 | } | 855 | } |
861 | send_control_message (handle, | 856 | send_control_message (handle, GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_GET, |
862 | GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_GET, | ||
863 | frequency.rel_value, cont, cont_cls); | 857 | frequency.rel_value, cont, cont_cls); |
864 | } | 858 | } |
865 | 859 | ||
@@ -883,8 +877,7 @@ GNUNET_DHT_set_malicious_putter (struct GNUNET_DHT_Handle *handle, | |||
883 | return; | 877 | return; |
884 | } | 878 | } |
885 | 879 | ||
886 | send_control_message (handle, | 880 | send_control_message (handle, GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_PUT, |
887 | GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_PUT, | ||
888 | frequency.rel_value, cont, cont_cls); | 881 | frequency.rel_value, cont, cont_cls); |
889 | } | 882 | } |
890 | 883 | ||
@@ -902,9 +895,8 @@ void | |||
902 | GNUNET_DHT_set_malicious_dropper (struct GNUNET_DHT_Handle *handle, | 895 | GNUNET_DHT_set_malicious_dropper (struct GNUNET_DHT_Handle *handle, |
903 | GNUNET_SCHEDULER_Task cont, void *cont_cls) | 896 | GNUNET_SCHEDULER_Task cont, void *cont_cls) |
904 | { | 897 | { |
905 | send_control_message (handle, | 898 | send_control_message (handle, GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_DROP, 0, cont, |
906 | GNUNET_MESSAGE_TYPE_DHT_MALICIOUS_DROP, 0, | 899 | cont_cls); |
907 | cont, cont_cls); | ||
908 | } | 900 | } |
909 | 901 | ||
910 | #endif | 902 | #endif |
diff --git a/src/dht/dht_api_find_peer.c b/src/dht/dht_api_find_peer.c index bcf1b50b7..a9ecc7b59 100644 --- a/src/dht/dht_api_find_peer.c +++ b/src/dht/dht_api_find_peer.c | |||
@@ -71,8 +71,7 @@ struct GNUNET_DHT_FindPeerHandle | |||
71 | * @param reply response | 71 | * @param reply response |
72 | */ | 72 | */ |
73 | static void | 73 | static void |
74 | find_peer_reply_iterator (void *cls, | 74 | find_peer_reply_iterator (void *cls, const GNUNET_HashCode * key, |
75 | const GNUNET_HashCode * key, | ||
76 | const struct GNUNET_PeerIdentity *const | 75 | const struct GNUNET_PeerIdentity *const |
77 | *outgoing_path, | 76 | *outgoing_path, |
78 | const struct GNUNET_MessageHeader *reply) | 77 | const struct GNUNET_MessageHeader *reply) |
@@ -127,12 +126,9 @@ GNUNET_DHT_find_peer_start (struct GNUNET_DHT_Handle *handle, | |||
127 | htons (sizeof (struct GNUNET_DHT_FindPeerMessage)); | 126 | htons (sizeof (struct GNUNET_DHT_FindPeerMessage)); |
128 | find_peer_msg.header.type = htons (GNUNET_MESSAGE_TYPE_DHT_FIND_PEER); | 127 | find_peer_msg.header.type = htons (GNUNET_MESSAGE_TYPE_DHT_FIND_PEER); |
129 | find_peer_handle->route_handle = | 128 | find_peer_handle->route_handle = |
130 | GNUNET_DHT_route_start (handle, key, | 129 | GNUNET_DHT_route_start (handle, key, 0, options, &find_peer_msg.header, |
131 | 0, options, | 130 | timeout, &find_peer_reply_iterator, |
132 | &find_peer_msg.header, | 131 | find_peer_handle, NULL, NULL); |
133 | timeout, | ||
134 | &find_peer_reply_iterator, find_peer_handle, | ||
135 | NULL, NULL); | ||
136 | GNUNET_break (find_peer_handle->route_handle != NULL); | 132 | GNUNET_break (find_peer_handle->route_handle != NULL); |
137 | return find_peer_handle; | 133 | return find_peer_handle; |
138 | } | 134 | } |
diff --git a/src/dht/dht_api_get_put.c b/src/dht/dht_api_get_put.c index 30b73e1f1..6b0bf1e26 100644 --- a/src/dht/dht_api_get_put.c +++ b/src/dht/dht_api_get_put.c | |||
@@ -52,16 +52,13 @@ | |||
52 | * @return GNUNET_YES if put message is queued for transmission | 52 | * @return GNUNET_YES if put message is queued for transmission |
53 | */ | 53 | */ |
54 | void | 54 | void |
55 | GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, | 55 | GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, const GNUNET_HashCode * key, |
56 | const GNUNET_HashCode * key, | ||
57 | uint32_t desired_replication_level, | 56 | uint32_t desired_replication_level, |
58 | enum GNUNET_DHT_RouteOption options, | 57 | enum GNUNET_DHT_RouteOption options, |
59 | enum GNUNET_BLOCK_Type type, | 58 | enum GNUNET_BLOCK_Type type, size_t size, const char *data, |
60 | size_t size, | ||
61 | const char *data, | ||
62 | struct GNUNET_TIME_Absolute exp, | 59 | struct GNUNET_TIME_Absolute exp, |
63 | struct GNUNET_TIME_Relative timeout, | 60 | struct GNUNET_TIME_Relative timeout, GNUNET_SCHEDULER_Task cont, |
64 | GNUNET_SCHEDULER_Task cont, void *cont_cls) | 61 | void *cont_cls) |
65 | { | 62 | { |
66 | char buf[GNUNET_SERVER_MAX_MESSAGE_SIZE]; | 63 | char buf[GNUNET_SERVER_MAX_MESSAGE_SIZE]; |
67 | struct GNUNET_DHT_PutMessage *put_msg; | 64 | struct GNUNET_DHT_PutMessage *put_msg; |
@@ -82,11 +79,9 @@ GNUNET_DHT_put (struct GNUNET_DHT_Handle *handle, | |||
82 | (unsigned int) (sizeof (struct GNUNET_DHT_PutMessage) + size), | 79 | (unsigned int) (sizeof (struct GNUNET_DHT_PutMessage) + size), |
83 | "PUT", type); | 80 | "PUT", type); |
84 | GNUNET_break (NULL == | 81 | GNUNET_break (NULL == |
85 | GNUNET_DHT_route_start (handle, | 82 | GNUNET_DHT_route_start (handle, key, desired_replication_level, |
86 | key, | 83 | options, &put_msg->header, timeout, |
87 | desired_replication_level, options, | 84 | NULL, NULL, cont, cont_cls)); |
88 | &put_msg->header, | ||
89 | timeout, NULL, NULL, cont, cont_cls)); | ||
90 | } | 85 | } |
91 | 86 | ||
92 | 87 | ||
@@ -126,8 +121,7 @@ struct GNUNET_DHT_GetHandle | |||
126 | * @param reply response | 121 | * @param reply response |
127 | */ | 122 | */ |
128 | static void | 123 | static void |
129 | get_reply_iterator (void *cls, | 124 | get_reply_iterator (void *cls, const GNUNET_HashCode * key, |
130 | const GNUNET_HashCode * key, | ||
131 | const struct GNUNET_PeerIdentity *const *outgoing_path, | 125 | const struct GNUNET_PeerIdentity *const *outgoing_path, |
132 | const struct GNUNET_MessageHeader *reply) | 126 | const struct GNUNET_MessageHeader *reply) |
133 | { | 127 | { |
@@ -177,10 +171,9 @@ get_reply_iterator (void *cls, | |||
177 | 171 | ||
178 | payload = ntohs (reply->size) - sizeof (struct GNUNET_DHT_GetResultMessage); | 172 | payload = ntohs (reply->size) - sizeof (struct GNUNET_DHT_GetResultMessage); |
179 | get_handle->iter (get_handle->iter_cls, | 173 | get_handle->iter (get_handle->iter_cls, |
180 | GNUNET_TIME_absolute_ntoh (result->expiration), | 174 | GNUNET_TIME_absolute_ntoh (result->expiration), key, |
181 | key, | 175 | outgoing_path, put_path, ntohs (result->type), payload, |
182 | outgoing_path, | 176 | &result[1]); |
183 | put_path, ntohs (result->type), payload, &result[1]); | ||
184 | GNUNET_free_non_null (put_path); | 177 | GNUNET_free_non_null (put_path); |
185 | } | 178 | } |
186 | 179 | ||
@@ -209,15 +202,13 @@ get_reply_iterator (void *cls, | |||
209 | struct GNUNET_DHT_GetHandle * | 202 | struct GNUNET_DHT_GetHandle * |
210 | GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle, | 203 | GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle, |
211 | struct GNUNET_TIME_Relative timeout, | 204 | struct GNUNET_TIME_Relative timeout, |
212 | enum GNUNET_BLOCK_Type type, | 205 | enum GNUNET_BLOCK_Type type, const GNUNET_HashCode * key, |
213 | const GNUNET_HashCode * key, | ||
214 | uint32_t desired_replication_level, | 206 | uint32_t desired_replication_level, |
215 | enum GNUNET_DHT_RouteOption options, | 207 | enum GNUNET_DHT_RouteOption options, |
216 | const struct GNUNET_CONTAINER_BloomFilter *bf, | 208 | const struct GNUNET_CONTAINER_BloomFilter *bf, |
217 | int32_t bf_mutator, | 209 | int32_t bf_mutator, const void *xquery, |
218 | const void *xquery, | 210 | size_t xquery_size, GNUNET_DHT_GetIterator iter, |
219 | size_t xquery_size, | 211 | void *iter_cls) |
220 | GNUNET_DHT_GetIterator iter, void *iter_cls) | ||
221 | { | 212 | { |
222 | struct GNUNET_DHT_GetHandle *get_handle; | 213 | struct GNUNET_DHT_GetHandle *get_handle; |
223 | char buf[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1]; | 214 | char buf[GNUNET_SERVER_MAX_MESSAGE_SIZE - 1]; |
@@ -237,8 +228,8 @@ GNUNET_DHT_get_start (struct GNUNET_DHT_Handle *handle, | |||
237 | get_handle->iter_cls = iter_cls; | 228 | get_handle->iter_cls = iter_cls; |
238 | get_msg = (struct GNUNET_DHT_GetMessage *) buf; | 229 | get_msg = (struct GNUNET_DHT_GetMessage *) buf; |
239 | get_msg->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_GET); | 230 | get_msg->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_GET); |
240 | get_msg->header.size = htons (sizeof (struct GNUNET_DHT_GetMessage) + | 231 | get_msg->header.size = |
241 | xquery_size + bf_size); | 232 | htons (sizeof (struct GNUNET_DHT_GetMessage) + xquery_size + bf_size); |
242 | get_msg->type = htonl ((uint32_t) type); | 233 | get_msg->type = htonl ((uint32_t) type); |
243 | get_msg->bf_mutator = bf_mutator; | 234 | get_msg->bf_mutator = bf_mutator; |
244 | get_msg->xquery_size = htons ((uint16_t) xquery_size); | 235 | get_msg->xquery_size = htons ((uint16_t) xquery_size); |
diff --git a/src/dht/dhtlog.c b/src/dht/dhtlog.c index 7b9c05268..d56ba6469 100644 --- a/src/dht/dhtlog.c +++ b/src/dht/dhtlog.c | |||
@@ -50,11 +50,11 @@ GNUNET_DHTLOG_connect (const struct GNUNET_CONFIGURATION_Handle *c) | |||
50 | plugin = GNUNET_malloc (sizeof (struct GNUNET_DHTLOG_Plugin)); | 50 | plugin = GNUNET_malloc (sizeof (struct GNUNET_DHTLOG_Plugin)); |
51 | plugin->cfg = c; | 51 | plugin->cfg = c; |
52 | if (GNUNET_OK == | 52 | if (GNUNET_OK == |
53 | GNUNET_CONFIGURATION_get_value_string (c, | 53 | GNUNET_CONFIGURATION_get_value_string (c, "DHTLOG", "PLUGIN", |
54 | "DHTLOG", "PLUGIN", &plugin_name)) | 54 | &plugin_name)) |
55 | { | 55 | { |
56 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 56 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Loading `%s' dhtlog plugin\n"), |
57 | _("Loading `%s' dhtlog plugin\n"), plugin_name); | 57 | plugin_name); |
58 | GNUNET_asprintf (&libname, "libgnunet_plugin_dhtlog_%s", plugin_name); | 58 | GNUNET_asprintf (&libname, "libgnunet_plugin_dhtlog_%s", plugin_name); |
59 | GNUNET_PLUGIN_load (libname, plugin); | 59 | GNUNET_PLUGIN_load (libname, plugin); |
60 | } | 60 | } |
diff --git a/src/dht/gnunet-dht-driver.c b/src/dht/gnunet-dht-driver.c index a5158fba5..d58e49e3b 100644 --- a/src/dht/gnunet-dht-driver.c +++ b/src/dht/gnunet-dht-driver.c | |||
@@ -850,8 +850,8 @@ update_meter (struct ProgressMeter *meter) | |||
850 | fprintf (stdout, "%sProgress: [0%%", meter->startup_string); | 850 | fprintf (stdout, "%sProgress: [0%%", meter->startup_string); |
851 | } | 851 | } |
852 | else | 852 | else |
853 | fprintf (stdout, "%d%%", (int) (((float) meter->completed | 853 | fprintf (stdout, "%d%%", |
854 | / meter->total) * 100)); | 854 | (int) (((float) meter->completed / meter->total) * 100)); |
855 | } | 855 | } |
856 | else if (meter->completed % meter->dotnum == 0) | 856 | else if (meter->completed % meter->dotnum == 0) |
857 | fprintf (stdout, "."); | 857 | fprintf (stdout, "."); |
@@ -922,10 +922,10 @@ put_disconnect_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
922 | GNUNET_DHT_disconnect (test_put->dht_handle); | 922 | GNUNET_DHT_disconnect (test_put->dht_handle); |
923 | test_put->dht_handle = NULL; | 923 | test_put->dht_handle = NULL; |
924 | if (replicate_same == GNUNET_NO) | 924 | if (replicate_same == GNUNET_NO) |
925 | test_put->daemon | 925 | test_put->daemon = |
926 | = GNUNET_TESTING_daemon_get (pg, | 926 | GNUNET_TESTING_daemon_get (pg, |
927 | GNUNET_CRYPTO_random_u32 | 927 | GNUNET_CRYPTO_random_u32 |
928 | (GNUNET_CRYPTO_QUALITY_WEAK, num_peers)); | 928 | (GNUNET_CRYPTO_QUALITY_WEAK, num_peers)); |
929 | } | 929 | } |
930 | 930 | ||
931 | /** | 931 | /** |
@@ -1010,11 +1010,10 @@ log_topology_cb (void *cls, const struct GNUNET_PeerIdentity *first, | |||
1010 | 1010 | ||
1011 | if ((first != NULL) && (second != NULL)) | 1011 | if ((first != NULL) && (second != NULL)) |
1012 | { | 1012 | { |
1013 | if ((topo_ctx->peers_seen != NULL) && (GNUNET_NO | 1013 | if ((topo_ctx->peers_seen != NULL) && |
1014 | == | 1014 | (GNUNET_NO == |
1015 | GNUNET_CONTAINER_multihashmap_contains | 1015 | GNUNET_CONTAINER_multihashmap_contains (topo_ctx->peers_seen, |
1016 | (topo_ctx->peers_seen, | 1016 | &first->hashPubKey))) |
1017 | &first->hashPubKey))) | ||
1018 | { | 1017 | { |
1019 | GNUNET_CONTAINER_multihashmap_put (topo_ctx->peers_seen, | 1018 | GNUNET_CONTAINER_multihashmap_put (topo_ctx->peers_seen, |
1020 | &first->hashPubKey, NULL, | 1019 | &first->hashPubKey, NULL, |
@@ -1109,15 +1108,14 @@ stats_handle (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
1109 | dhtlog_handle->add_generic_stat (peer, name, subsystem, value); | 1108 | dhtlog_handle->add_generic_stat (peer, name, subsystem, value); |
1110 | if (GNUNET_CONTAINER_multihashmap_contains (stats_map, &peer->hashPubKey)) | 1109 | if (GNUNET_CONTAINER_multihashmap_contains (stats_map, &peer->hashPubKey)) |
1111 | { | 1110 | { |
1112 | stats_ctx = GNUNET_CONTAINER_multihashmap_get (stats_map, | 1111 | stats_ctx = |
1113 | &peer->hashPubKey); | 1112 | GNUNET_CONTAINER_multihashmap_get (stats_map, &peer->hashPubKey); |
1114 | } | 1113 | } |
1115 | else | 1114 | else |
1116 | { | 1115 | { |
1117 | stats_ctx = GNUNET_malloc (sizeof (struct StatisticsIteratorContext)); | 1116 | stats_ctx = GNUNET_malloc (sizeof (struct StatisticsIteratorContext)); |
1118 | stats_ctx->peer = peer; | 1117 | stats_ctx->peer = peer; |
1119 | GNUNET_CONTAINER_multihashmap_put (stats_map, &peer->hashPubKey, | 1118 | GNUNET_CONTAINER_multihashmap_put (stats_map, &peer->hashPubKey, stats_ctx, |
1120 | stats_ctx, | ||
1121 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 1119 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
1122 | } | 1120 | } |
1123 | GNUNET_assert (stats_ctx != NULL); | 1121 | GNUNET_assert (stats_ctx != NULL); |
@@ -1329,8 +1327,8 @@ send_find_peer_request (void *cls, | |||
1329 | { | 1327 | { |
1330 | struct TestFindPeer *test_find_peer = cls; | 1328 | struct TestFindPeer *test_find_peer = cls; |
1331 | 1329 | ||
1332 | if (test_find_peer->find_peer_context->outstanding | 1330 | if (test_find_peer->find_peer_context->outstanding > |
1333 | > max_outstanding_find_peers) | 1331 | max_outstanding_find_peers) |
1334 | { | 1332 | { |
1335 | GNUNET_SCHEDULER_add_delayed (find_peer_offset, &send_find_peer_request, | 1333 | GNUNET_SCHEDULER_add_delayed (find_peer_offset, &send_find_peer_request, |
1336 | test_find_peer); | 1334 | test_find_peer); |
@@ -1345,8 +1343,8 @@ send_find_peer_request (void *cls, | |||
1345 | return; | 1343 | return; |
1346 | } | 1344 | } |
1347 | 1345 | ||
1348 | test_find_peer->dht_handle = GNUNET_DHT_connect (test_find_peer->daemon->cfg, | 1346 | test_find_peer->dht_handle = |
1349 | 1); | 1347 | GNUNET_DHT_connect (test_find_peer->daemon->cfg, 1); |
1350 | GNUNET_assert (test_find_peer->dht_handle != NULL); | 1348 | GNUNET_assert (test_find_peer->dht_handle != NULL); |
1351 | GNUNET_DHT_find_peers (test_find_peer->dht_handle, &handle_find_peer_sent, | 1349 | GNUNET_DHT_find_peers (test_find_peer->dht_handle, &handle_find_peer_sent, |
1352 | test_find_peer); | 1350 | test_find_peer); |
@@ -1365,12 +1363,12 @@ add_new_connection (struct FindPeerContext *find_peer_context, | |||
1365 | struct PeerCount *first_count; | 1363 | struct PeerCount *first_count; |
1366 | struct PeerCount *second_count; | 1364 | struct PeerCount *second_count; |
1367 | 1365 | ||
1368 | if (GNUNET_CONTAINER_multihashmap_contains (find_peer_context->peer_hash, | 1366 | if (GNUNET_CONTAINER_multihashmap_contains |
1369 | &first->hashPubKey)) | 1367 | (find_peer_context->peer_hash, &first->hashPubKey)) |
1370 | { | 1368 | { |
1371 | first_count | 1369 | first_count = |
1372 | = GNUNET_CONTAINER_multihashmap_get (find_peer_context->peer_hash, | 1370 | GNUNET_CONTAINER_multihashmap_get (find_peer_context->peer_hash, |
1373 | &first->hashPubKey); | 1371 | &first->hashPubKey); |
1374 | GNUNET_assert (first_count != NULL); | 1372 | GNUNET_assert (first_count != NULL); |
1375 | first_count->count++; | 1373 | first_count->count++; |
1376 | GNUNET_CONTAINER_heap_update_cost (find_peer_context->peer_min_heap, | 1374 | GNUNET_CONTAINER_heap_update_cost (find_peer_context->peer_min_heap, |
@@ -1382,20 +1380,20 @@ add_new_connection (struct FindPeerContext *find_peer_context, | |||
1382 | first_count = GNUNET_malloc (sizeof (struct PeerCount)); | 1380 | first_count = GNUNET_malloc (sizeof (struct PeerCount)); |
1383 | first_count->count = 1; | 1381 | first_count->count = 1; |
1384 | memcpy (&first_count->peer_id, first, sizeof (struct GNUNET_PeerIdentity)); | 1382 | memcpy (&first_count->peer_id, first, sizeof (struct GNUNET_PeerIdentity)); |
1385 | first_count->heap_node | 1383 | first_count->heap_node = |
1386 | = GNUNET_CONTAINER_heap_insert (find_peer_context->peer_min_heap, | 1384 | GNUNET_CONTAINER_heap_insert (find_peer_context->peer_min_heap, |
1387 | first_count, first_count->count); | 1385 | first_count, first_count->count); |
1388 | GNUNET_CONTAINER_multihashmap_put (find_peer_context->peer_hash, | 1386 | GNUNET_CONTAINER_multihashmap_put (find_peer_context->peer_hash, |
1389 | &first->hashPubKey, first_count, | 1387 | &first->hashPubKey, first_count, |
1390 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 1388 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
1391 | } | 1389 | } |
1392 | 1390 | ||
1393 | if (GNUNET_CONTAINER_multihashmap_contains (find_peer_context->peer_hash, | 1391 | if (GNUNET_CONTAINER_multihashmap_contains |
1394 | &second->hashPubKey)) | 1392 | (find_peer_context->peer_hash, &second->hashPubKey)) |
1395 | { | 1393 | { |
1396 | second_count | 1394 | second_count = |
1397 | = GNUNET_CONTAINER_multihashmap_get (find_peer_context->peer_hash, | 1395 | GNUNET_CONTAINER_multihashmap_get (find_peer_context->peer_hash, |
1398 | &second->hashPubKey); | 1396 | &second->hashPubKey); |
1399 | GNUNET_assert (second_count != NULL); | 1397 | GNUNET_assert (second_count != NULL); |
1400 | second_count->count++; | 1398 | second_count->count++; |
1401 | GNUNET_CONTAINER_heap_update_cost (find_peer_context->peer_min_heap, | 1399 | GNUNET_CONTAINER_heap_update_cost (find_peer_context->peer_min_heap, |
@@ -1408,9 +1406,9 @@ add_new_connection (struct FindPeerContext *find_peer_context, | |||
1408 | second_count->count = 1; | 1406 | second_count->count = 1; |
1409 | memcpy (&second_count->peer_id, second, | 1407 | memcpy (&second_count->peer_id, second, |
1410 | sizeof (struct GNUNET_PeerIdentity)); | 1408 | sizeof (struct GNUNET_PeerIdentity)); |
1411 | second_count->heap_node | 1409 | second_count->heap_node = |
1412 | = GNUNET_CONTAINER_heap_insert (find_peer_context->peer_min_heap, | 1410 | GNUNET_CONTAINER_heap_insert (find_peer_context->peer_min_heap, |
1413 | second_count, second_count->count); | 1411 | second_count, second_count->count); |
1414 | GNUNET_CONTAINER_multihashmap_put (find_peer_context->peer_hash, | 1412 | GNUNET_CONTAINER_multihashmap_put (find_peer_context->peer_hash, |
1415 | &second->hashPubKey, second_count, | 1413 | &second->hashPubKey, second_count, |
1416 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 1414 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
@@ -1456,19 +1454,19 @@ iterate_min_heap_peers (void *cls, struct GNUNET_CONTAINER_HeapNode *node, | |||
1456 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1454 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1457 | "Peer %s has 0 connections. Trying to connect to %s...\n", | 1455 | "Peer %s has 0 connections. Trying to connect to %s...\n", |
1458 | GNUNET_i2s (&peer_count->peer_id), d2->shortname); | 1456 | GNUNET_i2s (&peer_count->peer_id), d2->shortname); |
1459 | timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | 1457 | timeout = |
1460 | DEFAULT_CONNECT_TIMEOUT); | 1458 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |
1461 | if (GNUNET_TIME_relative_to_absolute (timeout).abs_value | 1459 | DEFAULT_CONNECT_TIMEOUT); |
1462 | > find_peer_context->endtime.abs_value) | 1460 | if (GNUNET_TIME_relative_to_absolute (timeout).abs_value > |
1461 | find_peer_context->endtime.abs_value) | ||
1463 | { | 1462 | { |
1464 | timeout = GNUNET_TIME_absolute_get_remaining (find_peer_context->endtime); | 1463 | timeout = GNUNET_TIME_absolute_get_remaining (find_peer_context->endtime); |
1465 | } | 1464 | } |
1466 | GNUNET_TESTING_daemons_connect (d1, d2, timeout, | 1465 | GNUNET_TESTING_daemons_connect (d1, d2, timeout, DEFAULT_RECONNECT_ATTEMPTS, |
1467 | DEFAULT_RECONNECT_ATTEMPTS, GNUNET_YES, | 1466 | GNUNET_YES, NULL, NULL); |
1468 | NULL, NULL); | ||
1469 | } | 1467 | } |
1470 | if (GNUNET_TIME_absolute_get_remaining (find_peer_context->endtime).rel_value | 1468 | if (GNUNET_TIME_absolute_get_remaining (find_peer_context->endtime). |
1471 | > 0) | 1469 | rel_value > 0) |
1472 | return GNUNET_YES; | 1470 | return GNUNET_YES; |
1473 | else | 1471 | else |
1474 | return GNUNET_NO; | 1472 | return GNUNET_NO; |
@@ -1477,10 +1475,10 @@ iterate_min_heap_peers (void *cls, struct GNUNET_CONTAINER_HeapNode *node, | |||
1477 | /** | 1475 | /** |
1478 | * Forward declaration. | 1476 | * Forward declaration. |
1479 | */ | 1477 | */ |
1480 | static void | 1478 | static void schedule_churn_find_peer_requests (void *cls, |
1481 | schedule_churn_find_peer_requests (void *cls, | 1479 | const struct |
1482 | const struct GNUNET_SCHEDULER_TaskContext | 1480 | GNUNET_SCHEDULER_TaskContext |
1483 | *tc); | 1481 | *tc); |
1484 | 1482 | ||
1485 | /** | 1483 | /** |
1486 | * Callback for iterating over all the peer connections of a peer group. | 1484 | * Callback for iterating over all the peer connections of a peer group. |
@@ -1557,11 +1555,12 @@ count_peers_churn_cb (void *cls, const struct GNUNET_PeerIdentity *first, | |||
1557 | */ | 1555 | */ |
1558 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1556 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1559 | "Out of %u peers, fewest connections is %d\n", | 1557 | "Out of %u peers, fewest connections is %d\n", |
1560 | GNUNET_CONTAINER_heap_get_size | 1558 | GNUNET_CONTAINER_heap_get_size (find_peer_context-> |
1561 | (find_peer_context->peer_min_heap), peer_count->count); | 1559 | peer_min_heap), |
1560 | peer_count->count); | ||
1562 | if ((peer_count->count == 0) && | 1561 | if ((peer_count->count == 0) && |
1563 | (GNUNET_TIME_absolute_get_remaining | 1562 | (GNUNET_TIME_absolute_get_remaining (find_peer_context->endtime). |
1564 | (find_peer_context->endtime).rel_value > 0)) | 1563 | rel_value > 0)) |
1565 | { | 1564 | { |
1566 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1565 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1567 | "Found peer with no connections, will choose some peer(s) at random to connect to!\n"); | 1566 | "Found peer with no connections, will choose some peer(s) at random to connect to!\n"); |
@@ -1571,9 +1570,8 @@ count_peers_churn_cb (void *cls, const struct GNUNET_PeerIdentity *first, | |||
1571 | GNUNET_SCHEDULER_add_now (&schedule_churn_find_peer_requests, | 1570 | GNUNET_SCHEDULER_add_now (&schedule_churn_find_peer_requests, |
1572 | find_peer_context); | 1571 | find_peer_context); |
1573 | } | 1572 | } |
1574 | else if ((GNUNET_TIME_absolute_get_remaining | 1573 | else if ((GNUNET_TIME_absolute_get_remaining (find_peer_context->endtime). |
1575 | (find_peer_context->endtime).rel_value > 0) && | 1574 | rel_value > 0) && (find_peer_context->last_sent != 0)) |
1576 | (find_peer_context->last_sent != 0)) | ||
1577 | { | 1575 | { |
1578 | GNUNET_SCHEDULER_add_now (&schedule_churn_find_peer_requests, | 1576 | GNUNET_SCHEDULER_add_now (&schedule_churn_find_peer_requests, |
1579 | find_peer_context); | 1577 | find_peer_context); |
@@ -1596,8 +1594,7 @@ count_peers_churn_cb (void *cls, const struct GNUNET_PeerIdentity *first, | |||
1596 | topo_ctx->cls = all_gets; | 1594 | topo_ctx->cls = all_gets; |
1597 | topo_ctx->timeout = DEFAULT_GET_TIMEOUT; | 1595 | topo_ctx->timeout = DEFAULT_GET_TIMEOUT; |
1598 | topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create (num_peers); | 1596 | topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create (num_peers); |
1599 | die_task | 1597 | die_task = |
1600 | = | ||
1601 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add | 1598 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add |
1602 | (GNUNET_TIME_relative_add | 1599 | (GNUNET_TIME_relative_add |
1603 | (DEFAULT_GET_TIMEOUT, | 1600 | (DEFAULT_GET_TIMEOUT, |
@@ -1609,8 +1606,7 @@ count_peers_churn_cb (void *cls, const struct GNUNET_PeerIdentity *first, | |||
1609 | } | 1606 | } |
1610 | else | 1607 | else |
1611 | { | 1608 | { |
1612 | die_task | 1609 | die_task = |
1613 | = | ||
1614 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add | 1610 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add |
1615 | (GNUNET_TIME_relative_add | 1611 | (GNUNET_TIME_relative_add |
1616 | (DEFAULT_GET_TIMEOUT, | 1612 | (DEFAULT_GET_TIMEOUT, |
@@ -1641,12 +1637,12 @@ schedule_churn_find_peer_requests (void *cls, | |||
1641 | 1637 | ||
1642 | if (find_peer_ctx->previous_peers == 0) /* First time, go slowly */ | 1638 | if (find_peer_ctx->previous_peers == 0) /* First time, go slowly */ |
1643 | find_peer_ctx->total = 1; | 1639 | find_peer_ctx->total = 1; |
1644 | else if (find_peer_ctx->current_peers - find_peer_ctx->previous_peers | 1640 | else if (find_peer_ctx->current_peers - find_peer_ctx->previous_peers < |
1645 | < MIN_FIND_PEER_CUTOFF) | 1641 | MIN_FIND_PEER_CUTOFF) |
1646 | find_peer_ctx->total = find_peer_ctx->total / 2; | 1642 | find_peer_ctx->total = find_peer_ctx->total / 2; |
1647 | else if (find_peer_ctx->current_peers - find_peer_ctx->previous_peers > MAX_FIND_PEER_CUTOFF) /* Found LOTS of peers, still go slowly */ | 1643 | else if (find_peer_ctx->current_peers - find_peer_ctx->previous_peers > MAX_FIND_PEER_CUTOFF) /* Found LOTS of peers, still go slowly */ |
1648 | find_peer_ctx->total = find_peer_ctx->last_sent - (find_peer_ctx->last_sent | 1644 | find_peer_ctx->total = |
1649 | / 4); | 1645 | find_peer_ctx->last_sent - (find_peer_ctx->last_sent / 4); |
1650 | else | 1646 | else |
1651 | find_peer_ctx->total = find_peer_ctx->last_sent * 4; | 1647 | find_peer_ctx->total = find_peer_ctx->last_sent * 4; |
1652 | 1648 | ||
@@ -1659,8 +1655,8 @@ schedule_churn_find_peer_requests (void *cls, | |||
1659 | find_peer_ctx->total); | 1655 | find_peer_ctx->total); |
1660 | 1656 | ||
1661 | if (find_peer_ctx->total > 0) | 1657 | if (find_peer_ctx->total > 0) |
1662 | find_peer_offset = GNUNET_TIME_relative_divide (find_peer_delay, | 1658 | find_peer_offset = |
1663 | find_peer_ctx->total); | 1659 | GNUNET_TIME_relative_divide (find_peer_delay, find_peer_ctx->total); |
1664 | else | 1660 | else |
1665 | { | 1661 | { |
1666 | find_peer_ctx->previous_peers = find_peer_ctx->current_peers; | 1662 | find_peer_ctx->previous_peers = find_peer_ctx->current_peers; |
@@ -1672,8 +1668,8 @@ schedule_churn_find_peer_requests (void *cls, | |||
1672 | { | 1668 | { |
1673 | test_find_peer = GNUNET_malloc (sizeof (struct TestFindPeer)); | 1669 | test_find_peer = GNUNET_malloc (sizeof (struct TestFindPeer)); |
1674 | /* If we have sent requests, choose peers with a low number of connections to send requests from */ | 1670 | /* If we have sent requests, choose peers with a low number of connections to send requests from */ |
1675 | peer_count | 1671 | peer_count = |
1676 | = GNUNET_CONTAINER_heap_remove_root (find_peer_ctx->peer_min_heap); | 1672 | GNUNET_CONTAINER_heap_remove_root (find_peer_ctx->peer_min_heap); |
1677 | GNUNET_assert (peer_count != NULL); | 1673 | GNUNET_assert (peer_count != NULL); |
1678 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1674 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1679 | "Sending find peer request from peer with %u connections\n", | 1675 | "Sending find peer request from peer with %u connections\n", |
@@ -1681,8 +1677,8 @@ schedule_churn_find_peer_requests (void *cls, | |||
1681 | GNUNET_CONTAINER_multihashmap_remove (find_peer_ctx->peer_hash, | 1677 | GNUNET_CONTAINER_multihashmap_remove (find_peer_ctx->peer_hash, |
1682 | &peer_count->peer_id.hashPubKey, | 1678 | &peer_count->peer_id.hashPubKey, |
1683 | peer_count); | 1679 | peer_count); |
1684 | test_find_peer->daemon | 1680 | test_find_peer->daemon = |
1685 | = GNUNET_TESTING_daemon_get_by_id (pg, &peer_count->peer_id); | 1681 | GNUNET_TESTING_daemon_get_by_id (pg, &peer_count->peer_id); |
1686 | GNUNET_assert (test_find_peer->daemon != NULL); | 1682 | GNUNET_assert (test_find_peer->daemon != NULL); |
1687 | test_find_peer->find_peer_context = find_peer_ctx; | 1683 | test_find_peer->find_peer_context = find_peer_ctx; |
1688 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 1684 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
@@ -1690,12 +1686,12 @@ schedule_churn_find_peer_requests (void *cls, | |||
1690 | &send_find_peer_request, test_find_peer); | 1686 | &send_find_peer_request, test_find_peer); |
1691 | } | 1687 | } |
1692 | 1688 | ||
1693 | if ((find_peer_ctx->peer_hash == NULL) && (find_peer_ctx->peer_min_heap | 1689 | if ((find_peer_ctx->peer_hash == NULL) && |
1694 | == NULL)) | 1690 | (find_peer_ctx->peer_min_heap == NULL)) |
1695 | { | 1691 | { |
1696 | find_peer_ctx->peer_hash = GNUNET_CONTAINER_multihashmap_create (num_peers); | 1692 | find_peer_ctx->peer_hash = GNUNET_CONTAINER_multihashmap_create (num_peers); |
1697 | find_peer_ctx->peer_min_heap | 1693 | find_peer_ctx->peer_min_heap = |
1698 | = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); | 1694 | GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); |
1699 | } | 1695 | } |
1700 | else | 1696 | else |
1701 | { | 1697 | { |
@@ -1764,9 +1760,9 @@ churn_complete (void *cls, const char *emsg) | |||
1764 | memcpy (&peer_count->peer_id, &temp_daemon->id, | 1760 | memcpy (&peer_count->peer_id, &temp_daemon->id, |
1765 | sizeof (struct GNUNET_PeerIdentity)); | 1761 | sizeof (struct GNUNET_PeerIdentity)); |
1766 | GNUNET_assert (peer_count->count == 0); | 1762 | GNUNET_assert (peer_count->count == 0); |
1767 | peer_count->heap_node | 1763 | peer_count->heap_node = |
1768 | = GNUNET_CONTAINER_heap_insert (find_peer_context->peer_min_heap, | 1764 | GNUNET_CONTAINER_heap_insert (find_peer_context->peer_min_heap, |
1769 | peer_count, peer_count->count); | 1765 | peer_count, peer_count->count); |
1770 | GNUNET_CONTAINER_multihashmap_put (find_peer_context->peer_hash, | 1766 | GNUNET_CONTAINER_multihashmap_put (find_peer_context->peer_hash, |
1771 | &temp_daemon->id.hashPubKey, | 1767 | &temp_daemon->id.hashPubKey, |
1772 | peer_count, | 1768 | peer_count, |
@@ -1775,10 +1771,9 @@ churn_complete (void *cls, const char *emsg) | |||
1775 | } | 1771 | } |
1776 | } | 1772 | } |
1777 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1773 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1778 | "Added %d peers to heap, total size %d\n", | 1774 | "Added %d peers to heap, total size %d\n", count_added, |
1779 | count_added, | 1775 | GNUNET_CONTAINER_heap_get_size (find_peer_context-> |
1780 | GNUNET_CONTAINER_heap_get_size | 1776 | peer_min_heap)); |
1781 | (find_peer_context->peer_min_heap)); | ||
1782 | GNUNET_SCHEDULER_add_delayed (DEFAULT_PEER_DISCONNECT_TIMEOUT, | 1777 | GNUNET_SCHEDULER_add_delayed (DEFAULT_PEER_DISCONNECT_TIMEOUT, |
1783 | &schedule_churn_get_topology, | 1778 | &schedule_churn_get_topology, |
1784 | find_peer_context); | 1779 | find_peer_context); |
@@ -1794,33 +1789,33 @@ churn_complete (void *cls, const char *emsg) | |||
1794 | topo_ctx->cls = all_gets; | 1789 | topo_ctx->cls = all_gets; |
1795 | topo_ctx->timeout = DEFAULT_GET_TIMEOUT; | 1790 | topo_ctx->timeout = DEFAULT_GET_TIMEOUT; |
1796 | topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create (num_peers); | 1791 | topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create (num_peers); |
1797 | calc_timeout = GNUNET_TIME_relative_add (DEFAULT_GET_TIMEOUT, | 1792 | calc_timeout = |
1798 | all_get_timeout); | 1793 | GNUNET_TIME_relative_add (DEFAULT_GET_TIMEOUT, all_get_timeout); |
1799 | calc_timeout | 1794 | calc_timeout = |
1800 | = GNUNET_TIME_relative_add (calc_timeout, | 1795 | GNUNET_TIME_relative_add (calc_timeout, |
1801 | DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT); | 1796 | DEFAULT_TOPOLOGY_CAPTURE_TIMEOUT); |
1802 | calc_timeout | 1797 | calc_timeout = |
1803 | = GNUNET_TIME_relative_add (calc_timeout, | 1798 | GNUNET_TIME_relative_add (calc_timeout, |
1804 | DEFAULT_PEER_DISCONNECT_TIMEOUT); | 1799 | DEFAULT_PEER_DISCONNECT_TIMEOUT); |
1805 | die_task | 1800 | die_task = |
1806 | = GNUNET_SCHEDULER_add_delayed (calc_timeout, &end_badly, | 1801 | GNUNET_SCHEDULER_add_delayed (calc_timeout, &end_badly, |
1807 | "from do gets (churn_complete)"); | 1802 | "from do gets (churn_complete)"); |
1808 | GNUNET_SCHEDULER_add_delayed (DEFAULT_PEER_DISCONNECT_TIMEOUT, | 1803 | GNUNET_SCHEDULER_add_delayed (DEFAULT_PEER_DISCONNECT_TIMEOUT, |
1809 | &capture_current_topology, topo_ctx); | 1804 | &capture_current_topology, topo_ctx); |
1810 | dhtlog_handle->insert_round (DHT_ROUND_GET, rounds_finished); | 1805 | dhtlog_handle->insert_round (DHT_ROUND_GET, rounds_finished); |
1811 | } | 1806 | } |
1812 | else | 1807 | else |
1813 | { | 1808 | { |
1814 | calc_timeout = GNUNET_TIME_relative_add (DEFAULT_GET_TIMEOUT, | 1809 | calc_timeout = |
1815 | all_get_timeout); | 1810 | GNUNET_TIME_relative_add (DEFAULT_GET_TIMEOUT, all_get_timeout); |
1816 | calc_timeout | 1811 | calc_timeout = |
1817 | = GNUNET_TIME_relative_add (calc_timeout, | 1812 | GNUNET_TIME_relative_add (calc_timeout, |
1818 | DEFAULT_PEER_DISCONNECT_TIMEOUT); | 1813 | DEFAULT_PEER_DISCONNECT_TIMEOUT); |
1819 | die_task | 1814 | die_task = |
1820 | = GNUNET_SCHEDULER_add_delayed (calc_timeout, &end_badly, | 1815 | GNUNET_SCHEDULER_add_delayed (calc_timeout, &end_badly, |
1821 | "from do gets (churn_complete)"); | 1816 | "from do gets (churn_complete)"); |
1822 | GNUNET_SCHEDULER_add_delayed (DEFAULT_PEER_DISCONNECT_TIMEOUT, | 1817 | GNUNET_SCHEDULER_add_delayed (DEFAULT_PEER_DISCONNECT_TIMEOUT, &do_get, |
1823 | &do_get, all_gets); | 1818 | all_gets); |
1824 | } | 1819 | } |
1825 | } | 1820 | } |
1826 | } | 1821 | } |
@@ -1880,10 +1875,10 @@ churn_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1880 | find_peer_context->previous_peers = 0; | 1875 | find_peer_context->previous_peers = 0; |
1881 | find_peer_context->current_peers = 0; | 1876 | find_peer_context->current_peers = 0; |
1882 | find_peer_context->endtime = GNUNET_TIME_relative_to_absolute (timeout); | 1877 | find_peer_context->endtime = GNUNET_TIME_relative_to_absolute (timeout); |
1883 | find_peer_context->peer_hash | 1878 | find_peer_context->peer_hash = |
1884 | = GNUNET_CONTAINER_multihashmap_create (num_peers); | 1879 | GNUNET_CONTAINER_multihashmap_create (num_peers); |
1885 | find_peer_context->peer_min_heap | 1880 | find_peer_context->peer_min_heap = |
1886 | = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); | 1881 | GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); |
1887 | } | 1882 | } |
1888 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1883 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1889 | "churn_peers: want %u total, %u running, starting %u, stopping %u\n", | 1884 | "churn_peers: want %u total, %u running, starting %u, stopping %u\n", |
@@ -1914,12 +1909,12 @@ get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1914 | /* Reset the uid (which item to search for) and the daemon (which peer to search from) for later get request iterations */ | 1909 | /* Reset the uid (which item to search for) and the daemon (which peer to search from) for later get request iterations */ |
1915 | if (get_from_same == GNUNET_NO) | 1910 | if (get_from_same == GNUNET_NO) |
1916 | { | 1911 | { |
1917 | test_get->uid = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 1912 | test_get->uid = |
1918 | num_puts); | 1913 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, num_puts); |
1919 | test_get->daemon | 1914 | test_get->daemon = |
1920 | = GNUNET_TESTING_daemon_get (pg, | 1915 | GNUNET_TESTING_daemon_get (pg, |
1921 | GNUNET_CRYPTO_random_u32 | 1916 | GNUNET_CRYPTO_random_u32 |
1922 | (GNUNET_CRYPTO_QUALITY_WEAK, num_peers)); | 1917 | (GNUNET_CRYPTO_QUALITY_WEAK, num_peers)); |
1923 | } | 1918 | } |
1924 | 1919 | ||
1925 | #if VERBOSE > 1 | 1920 | #if VERBOSE > 1 |
@@ -1986,8 +1981,7 @@ get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1986 | if (dhtlog_handle != NULL) | 1981 | if (dhtlog_handle != NULL) |
1987 | dhtlog_handle->insert_round (DHT_ROUND_GET, rounds_finished); | 1982 | dhtlog_handle->insert_round (DHT_ROUND_GET, rounds_finished); |
1988 | 1983 | ||
1989 | die_task | 1984 | die_task = |
1990 | = | ||
1991 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add | 1985 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add |
1992 | (GNUNET_TIME_relative_add | 1986 | (GNUNET_TIME_relative_add |
1993 | (GNUNET_TIME_relative_multiply | 1987 | (GNUNET_TIME_relative_multiply |
@@ -2004,8 +1998,7 @@ get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2004 | { | 1998 | { |
2005 | if (dhtlog_handle != NULL) | 1999 | if (dhtlog_handle != NULL) |
2006 | dhtlog_handle->insert_round (DHT_ROUND_NORMAL, rounds_finished); | 2000 | dhtlog_handle->insert_round (DHT_ROUND_NORMAL, rounds_finished); |
2007 | die_task | 2001 | die_task = |
2008 | = | ||
2009 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add | 2002 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add |
2010 | (GNUNET_TIME_relative_multiply | 2003 | (GNUNET_TIME_relative_multiply |
2011 | (GNUNET_TIME_UNIT_SECONDS, | 2004 | (GNUNET_TIME_UNIT_SECONDS, |
@@ -2133,21 +2126,18 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2133 | 2126 | ||
2134 | cumulative_num_gets++; | 2127 | cumulative_num_gets++; |
2135 | /* Insert the data at the first peer */ | 2128 | /* Insert the data at the first peer */ |
2136 | test_get->get_handle = GNUNET_DHT_get_start (test_get->dht_handle, get_delay, | 2129 | test_get->get_handle = |
2137 | GNUNET_BLOCK_TYPE_TEST, | 2130 | GNUNET_DHT_get_start (test_get->dht_handle, get_delay, |
2138 | &known_keys[test_get->uid], | 2131 | GNUNET_BLOCK_TYPE_TEST, &known_keys[test_get->uid], |
2139 | get_replication, | 2132 | get_replication, GNUNET_DHT_RO_NONE, NULL, 0, NULL, |
2140 | GNUNET_DHT_RO_NONE, NULL, 0, | 2133 | 0, &get_result_iterator, test_get); |
2141 | NULL, 0, &get_result_iterator, | ||
2142 | test_get); | ||
2143 | 2134 | ||
2144 | #if VERBOSE > 1 | 2135 | #if VERBOSE > 1 |
2145 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting get for uid %u from peer %s\n", | 2136 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting get for uid %u from peer %s\n", |
2146 | test_get->uid, test_get->daemon->shortname); | 2137 | test_get->uid, test_get->daemon->shortname); |
2147 | #endif | 2138 | #endif |
2148 | test_get->disconnect_task = GNUNET_SCHEDULER_add_delayed (get_timeout, | 2139 | test_get->disconnect_task = |
2149 | &get_stop_task, | 2140 | GNUNET_SCHEDULER_add_delayed (get_timeout, &get_stop_task, test_get); |
2150 | test_get); | ||
2151 | 2141 | ||
2152 | /* Schedule the next request in the linked list of get requests */ | 2142 | /* Schedule the next request in the linked list of get requests */ |
2153 | GNUNET_SCHEDULER_add_now (&do_get, test_get->next); | 2143 | GNUNET_SCHEDULER_add_now (&do_get, test_get->next); |
@@ -2171,14 +2161,14 @@ put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2171 | 2161 | ||
2172 | /* Reset the daemon (which peer to insert at) for later put request iterations */ | 2162 | /* Reset the daemon (which peer to insert at) for later put request iterations */ |
2173 | if (replicate_same == GNUNET_NO) | 2163 | if (replicate_same == GNUNET_NO) |
2174 | test_put->daemon | 2164 | test_put->daemon = |
2175 | = GNUNET_TESTING_daemon_get (pg, | 2165 | GNUNET_TESTING_daemon_get (pg, |
2176 | GNUNET_CRYPTO_random_u32 | 2166 | GNUNET_CRYPTO_random_u32 |
2177 | (GNUNET_CRYPTO_QUALITY_WEAK, num_peers)); | 2167 | (GNUNET_CRYPTO_QUALITY_WEAK, num_peers)); |
2178 | 2168 | ||
2179 | GNUNET_SCHEDULER_cancel (test_put->disconnect_task); | 2169 | GNUNET_SCHEDULER_cancel (test_put->disconnect_task); |
2180 | test_put->disconnect_task = GNUNET_SCHEDULER_add_now (&put_disconnect_task, | 2170 | test_put->disconnect_task = |
2181 | test_put); | 2171 | GNUNET_SCHEDULER_add_now (&put_disconnect_task, test_put); |
2182 | if (GNUNET_YES == update_meter (put_meter)) | 2172 | if (GNUNET_YES == update_meter (put_meter)) |
2183 | { | 2173 | { |
2184 | GNUNET_assert (outstanding_puts == 0); | 2174 | GNUNET_assert (outstanding_puts == 0); |
@@ -2190,8 +2180,7 @@ put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2190 | topo_ctx->cls = all_gets; | 2180 | topo_ctx->cls = all_gets; |
2191 | topo_ctx->timeout = DEFAULT_GET_TIMEOUT; | 2181 | topo_ctx->timeout = DEFAULT_GET_TIMEOUT; |
2192 | topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create (num_peers); | 2182 | topo_ctx->peers_seen = GNUNET_CONTAINER_multihashmap_create (num_peers); |
2193 | die_task | 2183 | die_task = |
2194 | = | ||
2195 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add | 2184 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add |
2196 | (GNUNET_TIME_relative_add | 2185 | (GNUNET_TIME_relative_add |
2197 | (DEFAULT_GET_TIMEOUT, all_get_timeout), | 2186 | (DEFAULT_GET_TIMEOUT, all_get_timeout), |
@@ -2203,8 +2192,7 @@ put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2203 | else | 2192 | else |
2204 | { | 2193 | { |
2205 | fprintf (stderr, "Scheduling die task (put finished)\n"); | 2194 | fprintf (stderr, "Scheduling die task (put finished)\n"); |
2206 | die_task | 2195 | die_task = |
2207 | = | ||
2208 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add | 2196 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_add |
2209 | (DEFAULT_GET_TIMEOUT, all_get_timeout), | 2197 | (DEFAULT_GET_TIMEOUT, all_get_timeout), |
2210 | &end_badly, | 2198 | &end_badly, |
@@ -2240,8 +2228,9 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2240 | 2228 | ||
2241 | for (i = 0; i < sizeof (data); i++) | 2229 | for (i = 0; i < sizeof (data); i++) |
2242 | { | 2230 | { |
2243 | memset (&data[i], GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 2231 | memset (&data[i], |
2244 | UINT32_MAX), 1); | 2232 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, UINT32_MAX), |
2233 | 1); | ||
2245 | } | 2234 | } |
2246 | 2235 | ||
2247 | if (outstanding_puts > max_outstanding_puts) | 2236 | if (outstanding_puts > max_outstanding_puts) |
@@ -2264,23 +2253,23 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2264 | put_replication, GNUNET_DHT_RO_NONE, GNUNET_BLOCK_TYPE_TEST, | 2253 | put_replication, GNUNET_DHT_RO_NONE, GNUNET_BLOCK_TYPE_TEST, |
2265 | sizeof (data), data, GNUNET_TIME_UNIT_FOREVER_ABS, put_delay, | 2254 | sizeof (data), data, GNUNET_TIME_UNIT_FOREVER_ABS, put_delay, |
2266 | &put_finished, test_put); | 2255 | &put_finished, test_put); |
2267 | test_put->disconnect_task | 2256 | test_put->disconnect_task = |
2268 | = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_get_forever (), | 2257 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_get_forever (), |
2269 | &put_disconnect_task, test_put); | 2258 | &put_disconnect_task, test_put); |
2270 | rand = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 2); | 2259 | rand = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 2); |
2271 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 2260 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
2272 | (GNUNET_TIME_UNIT_SECONDS, rand), &do_put, | 2261 | (GNUNET_TIME_UNIT_SECONDS, rand), &do_put, |
2273 | test_put->next); | 2262 | test_put->next); |
2274 | } | 2263 | } |
2275 | 2264 | ||
2276 | static void | 2265 | static void schedule_find_peer_requests (void *cls, |
2277 | schedule_find_peer_requests (void *cls, | 2266 | const struct |
2278 | const struct GNUNET_SCHEDULER_TaskContext *tc); | 2267 | GNUNET_SCHEDULER_TaskContext *tc); |
2279 | 2268 | ||
2280 | #if HAVE_MALICIOUS | 2269 | #if HAVE_MALICIOUS |
2281 | static void | 2270 | static void setup_malicious_peers (void *cls, |
2282 | setup_malicious_peers (void *cls, | 2271 | const struct GNUNET_SCHEDULER_TaskContext |
2283 | const struct GNUNET_SCHEDULER_TaskContext *tc); | 2272 | *tc); |
2284 | #endif | 2273 | #endif |
2285 | 2274 | ||
2286 | /** | 2275 | /** |
@@ -2325,18 +2314,17 @@ count_peers_cb (void *cls, const struct GNUNET_PeerIdentity *first, | |||
2325 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 2314 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
2326 | "Peer count finished (%u connections), %u new peers, connection estimate %u (target %u)\n", | 2315 | "Peer count finished (%u connections), %u new peers, connection estimate %u (target %u)\n", |
2327 | find_peer_context->current_peers, | 2316 | find_peer_context->current_peers, |
2328 | find_peer_context->current_peers | 2317 | find_peer_context->current_peers - |
2329 | - find_peer_context->previous_peers, | 2318 | find_peer_context->previous_peers, |
2330 | connection_estimate (num_peers, DEFAULT_BUCKET_SIZE), | 2319 | connection_estimate (num_peers, DEFAULT_BUCKET_SIZE), |
2331 | target_total_connections); | 2320 | target_total_connections); |
2332 | 2321 | ||
2333 | if ((find_peer_context->last_sent < 8) | 2322 | if ((find_peer_context->last_sent < 8) || |
2334 | || ((find_peer_context->current_peers < 2 | 2323 | ((find_peer_context->current_peers < |
2335 | * connection_estimate (num_peers, DEFAULT_BUCKET_SIZE)) | 2324 | 2 * connection_estimate (num_peers, DEFAULT_BUCKET_SIZE)) && |
2336 | && | 2325 | (GNUNET_TIME_absolute_get_remaining (find_peer_context->endtime). |
2337 | (GNUNET_TIME_absolute_get_remaining | 2326 | rel_value > 0) && |
2338 | (find_peer_context->endtime).rel_value > 0) && | 2327 | (find_peer_context->current_peers < target_total_connections))) |
2339 | (find_peer_context->current_peers < target_total_connections))) | ||
2340 | { | 2328 | { |
2341 | GNUNET_SCHEDULER_add_now (&schedule_find_peer_requests, | 2329 | GNUNET_SCHEDULER_add_now (&schedule_find_peer_requests, |
2342 | find_peer_context); | 2330 | find_peer_context); |
@@ -2381,8 +2369,8 @@ schedule_find_peer_requests (void *cls, | |||
2381 | if (find_peer_ctx->previous_peers == 0) /* First time, go slowly */ | 2369 | if (find_peer_ctx->previous_peers == 0) /* First time, go slowly */ |
2382 | find_peer_ctx->total = 1; | 2370 | find_peer_ctx->total = 1; |
2383 | else if (find_peer_ctx->current_peers - find_peer_ctx->previous_peers > MAX_FIND_PEER_CUTOFF) /* Found LOTS of peers, still go slowly */ | 2371 | else if (find_peer_ctx->current_peers - find_peer_ctx->previous_peers > MAX_FIND_PEER_CUTOFF) /* Found LOTS of peers, still go slowly */ |
2384 | find_peer_ctx->total = find_peer_ctx->last_sent - (find_peer_ctx->last_sent | 2372 | find_peer_ctx->total = |
2385 | / 8); | 2373 | find_peer_ctx->last_sent - (find_peer_ctx->last_sent / 8); |
2386 | else | 2374 | else |
2387 | find_peer_ctx->total = find_peer_ctx->last_sent * 2; | 2375 | find_peer_ctx->total = find_peer_ctx->last_sent * 2; |
2388 | 2376 | ||
@@ -2397,8 +2385,8 @@ schedule_find_peer_requests (void *cls, | |||
2397 | "Sending %u find peer messages (goal at least %u connections)\n", | 2385 | "Sending %u find peer messages (goal at least %u connections)\n", |
2398 | find_peer_ctx->total, target_total_connections); | 2386 | find_peer_ctx->total, target_total_connections); |
2399 | 2387 | ||
2400 | find_peer_offset = GNUNET_TIME_relative_divide (find_peer_delay, | 2388 | find_peer_offset = |
2401 | find_peer_ctx->total); | 2389 | GNUNET_TIME_relative_divide (find_peer_delay, find_peer_ctx->total); |
2402 | for (i = 0; i < find_peer_ctx->total; i++) | 2390 | for (i = 0; i < find_peer_ctx->total; i++) |
2403 | { | 2391 | { |
2404 | test_find_peer = GNUNET_malloc (sizeof (struct TestFindPeer)); | 2392 | test_find_peer = GNUNET_malloc (sizeof (struct TestFindPeer)); |
@@ -2418,9 +2406,10 @@ schedule_find_peer_requests (void *cls, | |||
2418 | * will be between 0 - 10, second between 10 - 20, etc. | 2406 | * will be between 0 - 10, second between 10 - 20, etc. |
2419 | */ | 2407 | */ |
2420 | random = (num_peers / find_peer_ctx->total) * i; | 2408 | random = (num_peers / find_peer_ctx->total) * i; |
2421 | random = random | 2409 | random = |
2422 | + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 2410 | random + GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, |
2423 | (num_peers / find_peer_ctx->total)); | 2411 | (num_peers / |
2412 | find_peer_ctx->total)); | ||
2424 | if (random >= num_peers) | 2413 | if (random >= num_peers) |
2425 | { | 2414 | { |
2426 | random = random - num_peers; | 2415 | random = random - num_peers; |
@@ -2432,12 +2421,14 @@ schedule_find_peer_requests (void *cls, | |||
2432 | } | 2421 | } |
2433 | else /* If we have sent requests, choose peers with a low number of connections to send requests from */ | 2422 | else /* If we have sent requests, choose peers with a low number of connections to send requests from */ |
2434 | { | 2423 | { |
2435 | peer_count | 2424 | peer_count = |
2436 | = GNUNET_CONTAINER_heap_remove_root (find_peer_ctx->peer_min_heap); | 2425 | GNUNET_CONTAINER_heap_remove_root (find_peer_ctx->peer_min_heap); |
2437 | GNUNET_assert (GNUNET_YES == | 2426 | GNUNET_assert (GNUNET_YES == |
2438 | GNUNET_CONTAINER_multihashmap_remove | 2427 | GNUNET_CONTAINER_multihashmap_remove (find_peer_ctx-> |
2439 | (find_peer_ctx->peer_hash, &peer_count->peer_id.hashPubKey, | 2428 | peer_hash, |
2440 | peer_count)); | 2429 | &peer_count->peer_id. |
2430 | hashPubKey, | ||
2431 | peer_count)); | ||
2441 | test_find_peer->daemon = | 2432 | test_find_peer->daemon = |
2442 | GNUNET_TESTING_daemon_get_by_id (pg, &peer_count->peer_id); | 2433 | GNUNET_TESTING_daemon_get_by_id (pg, &peer_count->peer_id); |
2443 | GNUNET_assert (test_find_peer->daemon != NULL); | 2434 | GNUNET_assert (test_find_peer->daemon != NULL); |
@@ -2449,12 +2440,12 @@ schedule_find_peer_requests (void *cls, | |||
2449 | &send_find_peer_request, test_find_peer); | 2440 | &send_find_peer_request, test_find_peer); |
2450 | } | 2441 | } |
2451 | 2442 | ||
2452 | if ((find_peer_ctx->peer_hash == NULL) && (find_peer_ctx->peer_min_heap | 2443 | if ((find_peer_ctx->peer_hash == NULL) && |
2453 | == NULL)) | 2444 | (find_peer_ctx->peer_min_heap == NULL)) |
2454 | { | 2445 | { |
2455 | find_peer_ctx->peer_hash = GNUNET_CONTAINER_multihashmap_create (num_peers); | 2446 | find_peer_ctx->peer_hash = GNUNET_CONTAINER_multihashmap_create (num_peers); |
2456 | find_peer_ctx->peer_min_heap | 2447 | find_peer_ctx->peer_min_heap = |
2457 | = GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); | 2448 | GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); |
2458 | } | 2449 | } |
2459 | else | 2450 | else |
2460 | { | 2451 | { |
@@ -2521,20 +2512,20 @@ setup_puts_and_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2521 | GNUNET_CRYPTO_hash_matching_bits (&known_keys[i], | 2512 | GNUNET_CRYPTO_hash_matching_bits (&known_keys[i], |
2522 | &sybil_target)); | 2513 | &sybil_target)); |
2523 | } | 2514 | } |
2524 | temp_peer = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 2515 | temp_peer = |
2525 | num_peers); | 2516 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, num_peers); |
2526 | test_put->daemon = GNUNET_TESTING_daemon_get (pg, temp_peer); | 2517 | test_put->daemon = GNUNET_TESTING_daemon_get (pg, temp_peer); |
2527 | /* Don't start PUTs at malicious peers! */ | 2518 | /* Don't start PUTs at malicious peers! */ |
2528 | if (malicious_bloom != NULL) | 2519 | if (malicious_bloom != NULL) |
2529 | { | 2520 | { |
2530 | count = 0; | 2521 | count = 0; |
2531 | hash_from_uid (temp_peer, &uid_hash); | 2522 | hash_from_uid (temp_peer, &uid_hash); |
2532 | while ((GNUNET_YES | 2523 | while ((GNUNET_YES == |
2533 | == GNUNET_CONTAINER_bloomfilter_test (malicious_bloom, &uid_hash)) | 2524 | GNUNET_CONTAINER_bloomfilter_test (malicious_bloom, &uid_hash)) && |
2534 | && (count < num_peers)) | 2525 | (count < num_peers)) |
2535 | { | 2526 | { |
2536 | temp_peer = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 2527 | temp_peer = |
2537 | num_peers); | 2528 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, num_peers); |
2538 | hash_from_uid (temp_peer, &uid_hash); | 2529 | hash_from_uid (temp_peer, &uid_hash); |
2539 | test_put->daemon = GNUNET_TESTING_daemon_get (pg, temp_peer); | 2530 | test_put->daemon = GNUNET_TESTING_daemon_get (pg, temp_peer); |
2540 | count++; | 2531 | count++; |
@@ -2551,28 +2542,28 @@ setup_puts_and_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2551 | for (i = 0; i < num_gets; i++) | 2542 | for (i = 0; i < num_gets; i++) |
2552 | { | 2543 | { |
2553 | test_get = GNUNET_malloc (sizeof (struct TestGetContext)); | 2544 | test_get = GNUNET_malloc (sizeof (struct TestGetContext)); |
2554 | test_get->uid = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 2545 | test_get->uid = |
2555 | num_puts); | 2546 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, num_puts); |
2556 | #if REMEMBER | 2547 | #if REMEMBER |
2557 | while (remember[test_get->uid][temp_daemon] == 1) | 2548 | while (remember[test_get->uid][temp_daemon] == 1) |
2558 | temp_daemon = | 2549 | temp_daemon = |
2559 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, num_peers); | 2550 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, num_peers); |
2560 | remember[test_get->uid][temp_daemon] = 1; | 2551 | remember[test_get->uid][temp_daemon] = 1; |
2561 | #endif | 2552 | #endif |
2562 | temp_peer = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 2553 | temp_peer = |
2563 | num_peers); | 2554 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, num_peers); |
2564 | test_get->daemon = GNUNET_TESTING_daemon_get (pg, temp_peer); | 2555 | test_get->daemon = GNUNET_TESTING_daemon_get (pg, temp_peer); |
2565 | /* Don't start GETs at malicious peers! */ | 2556 | /* Don't start GETs at malicious peers! */ |
2566 | if (malicious_bloom != NULL) | 2557 | if (malicious_bloom != NULL) |
2567 | { | 2558 | { |
2568 | hash_from_uid (temp_peer, &uid_hash); | 2559 | hash_from_uid (temp_peer, &uid_hash); |
2569 | count = 0; | 2560 | count = 0; |
2570 | while ((GNUNET_YES | 2561 | while ((GNUNET_YES == |
2571 | == GNUNET_CONTAINER_bloomfilter_test (malicious_bloom, &uid_hash)) | 2562 | GNUNET_CONTAINER_bloomfilter_test (malicious_bloom, &uid_hash)) && |
2572 | && (count < num_peers)) | 2563 | (count < num_peers)) |
2573 | { | 2564 | { |
2574 | temp_peer = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, | 2565 | temp_peer = |
2575 | num_peers); | 2566 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, num_peers); |
2576 | hash_from_uid (temp_peer, &uid_hash); | 2567 | hash_from_uid (temp_peer, &uid_hash); |
2577 | test_get->daemon = GNUNET_TESTING_daemon_get (pg, temp_peer); | 2568 | test_get->daemon = GNUNET_TESTING_daemon_get (pg, temp_peer); |
2578 | count++; | 2569 | count++; |
@@ -2586,8 +2577,7 @@ setup_puts_and_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2586 | } | 2577 | } |
2587 | 2578 | ||
2588 | /*GNUNET_SCHEDULER_cancel (die_task); */ | 2579 | /*GNUNET_SCHEDULER_cancel (die_task); */ |
2589 | die_task | 2580 | die_task = |
2590 | = | ||
2591 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 2581 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
2592 | (GNUNET_TIME_UNIT_SECONDS, num_puts * 2), | 2582 | (GNUNET_TIME_UNIT_SECONDS, num_puts * 2), |
2593 | &end_badly, "from do puts"); | 2583 | &end_badly, "from do puts"); |
@@ -2660,8 +2650,7 @@ continue_puts_and_gets (void *cls, | |||
2660 | "Scheduling find peer requests during \"settle\" time.\n"); | 2650 | "Scheduling find peer requests during \"settle\" time.\n"); |
2661 | find_peer_context = GNUNET_malloc (sizeof (struct FindPeerContext)); | 2651 | find_peer_context = GNUNET_malloc (sizeof (struct FindPeerContext)); |
2662 | find_peer_context->count_peers_cb = &count_peers_cb; | 2652 | find_peer_context->count_peers_cb = &count_peers_cb; |
2663 | find_peer_context->endtime | 2653 | find_peer_context->endtime = |
2664 | = | ||
2665 | GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply | 2654 | GNUNET_TIME_relative_to_absolute (GNUNET_TIME_relative_multiply |
2666 | (GNUNET_TIME_UNIT_SECONDS, | 2655 | (GNUNET_TIME_UNIT_SECONDS, |
2667 | settle_time)); | 2656 | settle_time)); |
@@ -2690,8 +2679,8 @@ malicious_disconnect_task (void *cls, | |||
2690 | ctx->dht_handle = NULL; | 2679 | ctx->dht_handle = NULL; |
2691 | GNUNET_free (ctx); | 2680 | GNUNET_free (ctx); |
2692 | 2681 | ||
2693 | if (malicious_completed == malicious_getters + malicious_putters | 2682 | if (malicious_completed == |
2694 | + malicious_droppers) | 2683 | malicious_getters + malicious_putters + malicious_droppers) |
2695 | { | 2684 | { |
2696 | fprintf (stderr, "Finished setting all malicious peers up!\n"); | 2685 | fprintf (stderr, "Finished setting all malicious peers up!\n"); |
2697 | } | 2686 | } |
@@ -2757,9 +2746,9 @@ set_malicious (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2757 | break; | 2746 | break; |
2758 | } | 2747 | } |
2759 | 2748 | ||
2760 | ctx->disconnect_task | 2749 | ctx->disconnect_task = |
2761 | = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 2750 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
2762 | &malicious_disconnect_task, ctx); | 2751 | &malicious_disconnect_task, ctx); |
2763 | } | 2752 | } |
2764 | 2753 | ||
2765 | /** | 2754 | /** |
@@ -2890,16 +2879,17 @@ setup_malicious_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2890 | 2879 | ||
2891 | #if ONLY_TESTING | 2880 | #if ONLY_TESTING |
2892 | /* Forward declaration */ | 2881 | /* Forward declaration */ |
2893 | static void | 2882 | static void topology_callback (void *cls, |
2894 | topology_callback (void *cls, | 2883 | const struct GNUNET_PeerIdentity *first, |
2895 | const struct GNUNET_PeerIdentity *first, | 2884 | const struct GNUNET_PeerIdentity *second, |
2896 | const struct GNUNET_PeerIdentity *second, | 2885 | uint32_t distance, |
2897 | uint32_t distance, | 2886 | const struct GNUNET_CONFIGURATION_Handle |
2898 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, | 2887 | *first_cfg, |
2899 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, | 2888 | const struct GNUNET_CONFIGURATION_Handle |
2900 | struct GNUNET_TESTING_Daemon *first_daemon, | 2889 | *second_cfg, |
2901 | struct GNUNET_TESTING_Daemon *second_daemon, | 2890 | struct GNUNET_TESTING_Daemon *first_daemon, |
2902 | const char *emsg); | 2891 | struct GNUNET_TESTING_Daemon *second_daemon, |
2892 | const char *emsg); | ||
2903 | 2893 | ||
2904 | /** | 2894 | /** |
2905 | * Retry connecting two specific peers until they connect, | 2895 | * Retry connecting two specific peers until they connect, |
@@ -2920,8 +2910,7 @@ repeat_connect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2920 | repeat_connect_peer2->cfgfile); | 2910 | repeat_connect_peer2->cfgfile); |
2921 | 2911 | ||
2922 | repeat_connect_task = GNUNET_SCHEDULER_NO_TASK; | 2912 | repeat_connect_task = GNUNET_SCHEDULER_NO_TASK; |
2923 | GNUNET_TESTING_daemons_connect (repeat_connect_peer1, | 2913 | GNUNET_TESTING_daemons_connect (repeat_connect_peer1, repeat_connect_peer2, |
2924 | repeat_connect_peer2, | ||
2925 | GNUNET_TIME_relative_multiply | 2914 | GNUNET_TIME_relative_multiply |
2926 | (GNUNET_TIME_UNIT_SECONDS, 60), 2, | 2915 | (GNUNET_TIME_UNIT_SECONDS, 60), 2, |
2927 | &topology_callback, NULL); | 2916 | &topology_callback, NULL); |
@@ -2989,9 +2978,9 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, | |||
2989 | } | 2978 | } |
2990 | #endif | 2979 | #endif |
2991 | 2980 | ||
2992 | if (GNUNET_TIME_absolute_get_difference (connect_last_time, | 2981 | if (GNUNET_TIME_absolute_get_difference |
2993 | GNUNET_TIME_absolute_get | 2982 | (connect_last_time, |
2994 | ()).rel_value > | 2983 | GNUNET_TIME_absolute_get ()).rel_value > |
2995 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | 2984 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |
2996 | CONN_UPDATE_DURATION).rel_value) | 2985 | CONN_UPDATE_DURATION).rel_value) |
2997 | { | 2986 | { |
@@ -3002,19 +2991,19 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, | |||
3002 | new_failed_connections = failed_connections - previous_failed_connections; | 2991 | new_failed_connections = failed_connections - previous_failed_connections; |
3003 | 2992 | ||
3004 | /* Get duration in seconds */ | 2993 | /* Get duration in seconds */ |
3005 | duration | 2994 | duration = |
3006 | = GNUNET_TIME_absolute_get_difference (connect_last_time, | 2995 | GNUNET_TIME_absolute_get_difference (connect_last_time, |
3007 | GNUNET_TIME_absolute_get | 2996 | GNUNET_TIME_absolute_get ()). |
3008 | ()).rel_value / 1000; | 2997 | rel_value / 1000; |
3009 | total_duration = | 2998 | total_duration = |
3010 | GNUNET_TIME_absolute_get_difference (connect_start_time, | 2999 | GNUNET_TIME_absolute_get_difference (connect_start_time, |
3011 | GNUNET_TIME_absolute_get | 3000 | GNUNET_TIME_absolute_get ()). |
3012 | ()).rel_value / 1000; | 3001 | rel_value / 1000; |
3013 | 3002 | ||
3014 | failed_conns_per_sec_recent = (double) new_failed_connections | 3003 | failed_conns_per_sec_recent = |
3015 | / (double) duration; | 3004 | (double) new_failed_connections / (double) duration; |
3016 | failed_conns_per_sec_total = (double) failed_connections | 3005 | failed_conns_per_sec_total = |
3017 | / (double) total_duration; | 3006 | (double) failed_connections / (double) total_duration; |
3018 | conns_per_sec_recent = (double) new_connections / (double) duration; | 3007 | conns_per_sec_recent = (double) new_connections / (double) duration; |
3019 | conns_per_sec_total = (double) total_connections / (double) total_duration; | 3008 | conns_per_sec_total = (double) total_connections / (double) total_duration; |
3020 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 3009 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
@@ -3025,14 +3014,13 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, | |||
3025 | previous_connections = total_connections; | 3014 | previous_connections = total_connections; |
3026 | previous_failed_connections = failed_connections; | 3015 | previous_failed_connections = failed_connections; |
3027 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 3016 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
3028 | "have %llu total_connections, %llu failed\n", | 3017 | "have %llu total_connections, %llu failed\n", total_connections, |
3029 | total_connections, failed_connections); | 3018 | failed_connections); |
3030 | #if ONLY_TESTING | 3019 | #if ONLY_TESTING |
3031 | /* These conditions likely mean we've entered the death spiral of doom */ | 3020 | /* These conditions likely mean we've entered the death spiral of doom */ |
3032 | if ((total_connections > 20000) && | 3021 | if ((total_connections > 20000) && (conns_per_sec_recent < 5.0) && |
3033 | (conns_per_sec_recent < 5.0) && | 3022 | (conns_per_sec_total > 10.0) && (emsg != NULL) && |
3034 | (conns_per_sec_total > 10.0) && | 3023 | (repeat_connect_mode == GNUNET_NO)) |
3035 | (emsg != NULL) && (repeat_connect_mode == GNUNET_NO)) | ||
3036 | { | 3024 | { |
3037 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 3025 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
3038 | "Entering repeat connection attempt mode!\n"); | 3026 | "Entering repeat connection attempt mode!\n"); |
@@ -3096,10 +3084,10 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, | |||
3096 | dhtlog_handle->insert_topology (expected_connections); | 3084 | dhtlog_handle->insert_topology (expected_connections); |
3097 | } | 3085 | } |
3098 | 3086 | ||
3099 | total_duration | 3087 | total_duration = |
3100 | = GNUNET_TIME_absolute_get_difference (connect_start_time, | 3088 | GNUNET_TIME_absolute_get_difference (connect_start_time, |
3101 | GNUNET_TIME_absolute_get | 3089 | GNUNET_TIME_absolute_get ()). |
3102 | ()).rel_value / 1000; | 3090 | rel_value / 1000; |
3103 | failed_conns_per_sec_total = | 3091 | failed_conns_per_sec_total = |
3104 | (long double) failed_connections / total_duration; | 3092 | (long double) failed_connections / total_duration; |
3105 | conns_per_sec_total = (long double) total_connections / total_duration; | 3093 | conns_per_sec_total = (long double) total_connections / total_duration; |
@@ -3162,9 +3150,9 @@ topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, | |||
3162 | else if (total_connections + failed_connections == expected_connections) | 3150 | else if (total_connections + failed_connections == expected_connections) |
3163 | { | 3151 | { |
3164 | GNUNET_SCHEDULER_cancel (die_task); | 3152 | GNUNET_SCHEDULER_cancel (die_task); |
3165 | die_task | 3153 | die_task = |
3166 | = GNUNET_SCHEDULER_add_now (&end_badly, | 3154 | GNUNET_SCHEDULER_add_now (&end_badly, |
3167 | "from topology_callback (too many failed connections)"); | 3155 | "from topology_callback (too many failed connections)"); |
3168 | } | 3156 | } |
3169 | } | 3157 | } |
3170 | 3158 | ||
@@ -3200,8 +3188,7 @@ peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id, | |||
3200 | 3188 | ||
3201 | GNUNET_asprintf (&revision_str, "%llu", revision); | 3189 | GNUNET_asprintf (&revision_str, "%llu", revision); |
3202 | if (GNUNET_YES == insert_gauger_data) | 3190 | if (GNUNET_YES == insert_gauger_data) |
3203 | GAUGER_ID ("DHT_TESTING", | 3191 | GAUGER_ID ("DHT_TESTING", "peer_startup_time", |
3204 | "peer_startup_time", | ||
3205 | GNUNET_TIME_absolute_get_duration (peer_start_time).rel_value / | 3192 | GNUNET_TIME_absolute_get_duration (peer_start_time).rel_value / |
3206 | (double) num_peers, "ms/peer", revision_str); | 3193 | (double) num_peers, "ms/peer", revision_str); |
3207 | GNUNET_free (revision_str); | 3194 | GNUNET_free (revision_str); |
@@ -3210,28 +3197,26 @@ peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id, | |||
3210 | if ((pg != NULL) && (peers_left == 0)) | 3197 | if ((pg != NULL) && (peers_left == 0)) |
3211 | { | 3198 | { |
3212 | connect_start_time = GNUNET_TIME_absolute_get (); | 3199 | connect_start_time = GNUNET_TIME_absolute_get (); |
3213 | expected_connections | 3200 | expected_connections = |
3214 | = GNUNET_TESTING_connect_topology (pg, | 3201 | GNUNET_TESTING_connect_topology (pg, connect_topology, |
3215 | connect_topology, | 3202 | connect_topology_option, |
3216 | connect_topology_option, | 3203 | connect_topology_option_modifier, |
3217 | connect_topology_option_modifier, | 3204 | connect_timeout, connect_attempts, |
3218 | connect_timeout, | 3205 | NULL, NULL); |
3219 | connect_attempts, NULL, NULL); | 3206 | |
3220 | 3207 | peer_connect_meter = | |
3221 | peer_connect_meter = create_meter (expected_connections, | 3208 | create_meter (expected_connections, "Peer connection ", GNUNET_YES); |
3222 | "Peer connection ", GNUNET_YES); | ||
3223 | fprintf (stderr, "Have %d expected connections\n", expected_connections); | 3209 | fprintf (stderr, "Have %d expected connections\n", expected_connections); |
3224 | } | 3210 | } |
3225 | 3211 | ||
3226 | if (expected_connections == 0) | 3212 | if (expected_connections == 0) |
3227 | { | 3213 | { |
3228 | die_task | 3214 | die_task = |
3229 | = GNUNET_SCHEDULER_add_now (&end_badly, | 3215 | GNUNET_SCHEDULER_add_now (&end_badly, |
3230 | "from connect topology (bad return)"); | 3216 | "from connect topology (bad return)"); |
3231 | } | 3217 | } |
3232 | 3218 | ||
3233 | die_task | 3219 | die_task = |
3234 | = | ||
3235 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 3220 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
3236 | (GNUNET_TIME_UNIT_SECONDS, | 3221 | (GNUNET_TIME_UNIT_SECONDS, |
3237 | DEFAULT_CONNECT_TIMEOUT * | 3222 | DEFAULT_CONNECT_TIMEOUT * |
@@ -3248,9 +3233,9 @@ create_topology () | |||
3248 | unsigned int create_expected_connections; | 3233 | unsigned int create_expected_connections; |
3249 | 3234 | ||
3250 | peers_left = num_peers; /* Reset counter */ | 3235 | peers_left = num_peers; /* Reset counter */ |
3251 | create_expected_connections | 3236 | create_expected_connections = |
3252 | = GNUNET_TESTING_create_topology (pg, topology, blacklist_topology, | 3237 | GNUNET_TESTING_create_topology (pg, topology, blacklist_topology, |
3253 | blacklist_transports); | 3238 | blacklist_transports); |
3254 | if (create_expected_connections > 0) | 3239 | if (create_expected_connections > 0) |
3255 | { | 3240 | { |
3256 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 3241 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
@@ -3262,13 +3247,13 @@ create_topology () | |||
3262 | else | 3247 | else |
3263 | { | 3248 | { |
3264 | GNUNET_SCHEDULER_cancel (die_task); | 3249 | GNUNET_SCHEDULER_cancel (die_task); |
3265 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, | 3250 | die_task = |
3266 | "from create topology (bad return)"); | 3251 | GNUNET_SCHEDULER_add_now (&end_badly, |
3252 | "from create topology (bad return)"); | ||
3267 | } | 3253 | } |
3268 | GNUNET_free_non_null (blacklist_transports); | 3254 | GNUNET_free_non_null (blacklist_transports); |
3269 | GNUNET_SCHEDULER_cancel (die_task); | 3255 | GNUNET_SCHEDULER_cancel (die_task); |
3270 | die_task | 3256 | die_task = |
3271 | = | ||
3272 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 3257 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
3273 | (seconds_per_peer_start, num_peers), | 3258 | (seconds_per_peer_start, num_peers), |
3274 | &end_badly, | 3259 | &end_badly, |
@@ -3297,8 +3282,8 @@ hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id, | |||
3297 | 3282 | ||
3298 | #if VERBOSE > 1 | 3283 | #if VERBOSE > 1 |
3299 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3284 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3300 | "Hostkey (%d/%d) created for peer `%s'\n", | 3285 | "Hostkey (%d/%d) created for peer `%s'\n", num_peers - peers_left, |
3301 | num_peers - peers_left, num_peers, GNUNET_i2s (id)); | 3286 | num_peers, GNUNET_i2s (id)); |
3302 | #endif | 3287 | #endif |
3303 | 3288 | ||
3304 | peers_left--; | 3289 | peers_left--; |
@@ -3310,22 +3295,18 @@ hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id, | |||
3310 | GNUNET_asprintf (&revision_str, "%llu", revision); | 3295 | GNUNET_asprintf (&revision_str, "%llu", revision); |
3311 | if (GNUNET_YES == insert_gauger_data) | 3296 | if (GNUNET_YES == insert_gauger_data) |
3312 | { | 3297 | { |
3313 | if (GNUNET_YES == GNUNET_CONFIGURATION_have_value (config, "TESTING", | 3298 | if (GNUNET_YES == |
3314 | "HOSTKEYSFILE")) | 3299 | GNUNET_CONFIGURATION_have_value (config, "TESTING", "HOSTKEYSFILE")) |
3315 | { | 3300 | { |
3316 | GAUGER_ID ("DHT_TESTING", | 3301 | GAUGER_ID ("DHT_TESTING", "HOSTKEY_GENERATION", |
3317 | "HOSTKEY_GENERATION", | 3302 | GNUNET_TIME_absolute_get_duration (hostkey_start_time). |
3318 | GNUNET_TIME_absolute_get_duration | 3303 | rel_value / (double) num_peers, "ms/hostkey", revision_str); |
3319 | (hostkey_start_time).rel_value / (double) num_peers, | ||
3320 | "ms/hostkey", revision_str); | ||
3321 | } | 3304 | } |
3322 | else | 3305 | else |
3323 | { | 3306 | { |
3324 | GAUGER_ID ("DHT_TESTING", | 3307 | GAUGER_ID ("DHT_TESTING", "HOSTKEY_GENERATION_REAL", |
3325 | "HOSTKEY_GENERATION_REAL", | 3308 | GNUNET_TIME_absolute_get_duration (hostkey_start_time). |
3326 | GNUNET_TIME_absolute_get_duration | 3309 | rel_value / (double) num_peers, "ms/hostkey", revision_str); |
3327 | (hostkey_start_time).rel_value / (double) num_peers, | ||
3328 | "ms/hostkey", revision_str); | ||
3329 | } | 3310 | } |
3330 | } | 3311 | } |
3331 | 3312 | ||
@@ -3334,9 +3315,9 @@ hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id, | |||
3334 | GNUNET_SCHEDULER_cancel (die_task); | 3315 | GNUNET_SCHEDULER_cancel (die_task); |
3335 | /* Set up task in case topology creation doesn't finish | 3316 | /* Set up task in case topology creation doesn't finish |
3336 | * within a reasonable amount of time */ | 3317 | * within a reasonable amount of time */ |
3337 | die_task = GNUNET_SCHEDULER_add_delayed (DEFAULT_TOPOLOGY_TIMEOUT, | 3318 | die_task = |
3338 | &end_badly, | 3319 | GNUNET_SCHEDULER_add_delayed (DEFAULT_TOPOLOGY_TIMEOUT, &end_badly, |
3339 | "from create_topology"); | 3320 | "from create_topology"); |
3340 | GNUNET_SCHEDULER_add_now (&create_topology, NULL); | 3321 | GNUNET_SCHEDULER_add_now (&create_topology, NULL); |
3341 | ok = 0; | 3322 | ok = 0; |
3342 | } | 3323 | } |
@@ -3379,18 +3360,18 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
3379 | rounds_finished = 0; | 3360 | rounds_finished = 0; |
3380 | memset (&trial_info, 0, sizeof (struct GNUNET_DHTLOG_TrialInfo)); | 3361 | memset (&trial_info, 0, sizeof (struct GNUNET_DHTLOG_TrialInfo)); |
3381 | /* Get path from configuration file */ | 3362 | /* Get path from configuration file */ |
3382 | if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_string (cfg, "paths", | 3363 | if (GNUNET_YES != |
3383 | "servicehome", | 3364 | GNUNET_CONFIGURATION_get_value_string (cfg, "paths", "servicehome", |
3384 | &test_directory)) | 3365 | &test_directory)) |
3385 | { | 3366 | { |
3386 | ok = 404; | 3367 | ok = 404; |
3387 | return; | 3368 | return; |
3388 | } | 3369 | } |
3389 | 3370 | ||
3390 | /* Get number of peers to start from configuration */ | 3371 | /* Get number of peers to start from configuration */ |
3391 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, "testing", | 3372 | if (GNUNET_SYSERR == |
3392 | "num_peers", | 3373 | GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "num_peers", |
3393 | &num_peers)) | 3374 | &num_peers)) |
3394 | { | 3375 | { |
3395 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 3376 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
3396 | "Number of peers must be specified in section %s option %s\n", | 3377 | "Number of peers must be specified in section %s option %s\n", |
@@ -3398,11 +3379,12 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
3398 | } | 3379 | } |
3399 | GNUNET_assert (num_peers > 0 && num_peers < ULONG_MAX); | 3380 | GNUNET_assert (num_peers > 0 && num_peers < ULONG_MAX); |
3400 | 3381 | ||
3401 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "testing", | 3382 | if (GNUNET_OK == |
3402 | "connect_timeout", | 3383 | GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_timeout", |
3403 | &temp_config_number)) | 3384 | &temp_config_number)) |
3404 | connect_timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | 3385 | connect_timeout = |
3405 | temp_config_number); | 3386 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |
3387 | temp_config_number); | ||
3406 | else | 3388 | else |
3407 | { | 3389 | { |
3408 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", | 3390 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", |
@@ -3410,28 +3392,29 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
3410 | return; | 3392 | return; |
3411 | } | 3393 | } |
3412 | 3394 | ||
3413 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "testing", | 3395 | if (GNUNET_OK != |
3414 | "connect_attempts", | 3396 | GNUNET_CONFIGURATION_get_value_number (cfg, "testing", "connect_attempts", |
3415 | &connect_attempts)) | 3397 | &connect_attempts)) |
3416 | { | 3398 | { |
3417 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", | 3399 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", |
3418 | "testing", "connect_attempts"); | 3400 | "testing", "connect_attempts"); |
3419 | return; | 3401 | return; |
3420 | } | 3402 | } |
3421 | 3403 | ||
3422 | if (GNUNET_OK | 3404 | if (GNUNET_OK != |
3423 | != GNUNET_CONFIGURATION_get_value_number (cfg, "testing", | 3405 | GNUNET_CONFIGURATION_get_value_number (cfg, "testing", |
3424 | "max_outstanding_connections", | 3406 | "max_outstanding_connections", |
3425 | &max_outstanding_connections)) | 3407 | &max_outstanding_connections)) |
3426 | { | 3408 | { |
3427 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", | 3409 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", |
3428 | "testing", "max_outstanding_connections"); | 3410 | "testing", "max_outstanding_connections"); |
3429 | return; | 3411 | return; |
3430 | } | 3412 | } |
3431 | 3413 | ||
3432 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "testing", | 3414 | if (GNUNET_OK != |
3433 | "max_concurrent_ssh", | 3415 | GNUNET_CONFIGURATION_get_value_number (cfg, "testing", |
3434 | &max_concurrent_ssh)) | 3416 | "max_concurrent_ssh", |
3417 | &max_concurrent_ssh)) | ||
3435 | { | 3418 | { |
3436 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", | 3419 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Must provide option %s:%s!\n", |
3437 | "testing", "max_concurrent_ssh"); | 3420 | "testing", "max_concurrent_ssh"); |
@@ -3441,18 +3424,19 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
3441 | /** | 3424 | /** |
3442 | * Get DHT specific testing options. | 3425 | * Get DHT specific testing options. |
3443 | */ | 3426 | */ |
3444 | if ((GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht_testing", | 3427 | if ((GNUNET_YES == |
3445 | "mysql_logging")) | 3428 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht_testing", |
3446 | || (GNUNET_YES | 3429 | "mysql_logging")) || |
3447 | == GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht_testing", | 3430 | (GNUNET_YES == |
3448 | "mysql_logging_extended")) | 3431 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht_testing", |
3449 | || (GNUNET_YES | 3432 | "mysql_logging_extended")) || |
3450 | == GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht_testing", | 3433 | (GNUNET_YES == |
3451 | "mysql_logging_minimal"))) | 3434 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht_testing", |
3435 | "mysql_logging_minimal"))) | ||
3452 | { | 3436 | { |
3453 | if (GNUNET_YES | 3437 | if (GNUNET_YES == |
3454 | == GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht_testing", | 3438 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht_testing", |
3455 | "mysql_logging_minimal")) | 3439 | "mysql_logging_minimal")) |
3456 | dhtlog_minimal = GNUNET_YES; | 3440 | dhtlog_minimal = GNUNET_YES; |
3457 | 3441 | ||
3458 | dhtlog_handle = GNUNET_DHTLOG_connect (cfg); | 3442 | dhtlog_handle = GNUNET_DHTLOG_connect (cfg); |
@@ -3465,8 +3449,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
3465 | } | 3449 | } |
3466 | } | 3450 | } |
3467 | 3451 | ||
3468 | stop_closest = GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht", | 3452 | stop_closest = |
3469 | "stop_on_closest"); | 3453 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht", "stop_on_closest"); |
3470 | if (stop_closest == GNUNET_SYSERR) | 3454 | if (stop_closest == GNUNET_SYSERR) |
3471 | stop_closest = GNUNET_NO; | 3455 | stop_closest = GNUNET_NO; |
3472 | 3456 | ||
@@ -3474,21 +3458,21 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
3474 | if (stop_found == GNUNET_SYSERR) | 3458 | if (stop_found == GNUNET_SYSERR) |
3475 | stop_found = GNUNET_NO; | 3459 | stop_found = GNUNET_NO; |
3476 | 3460 | ||
3477 | strict_kademlia = GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht", | 3461 | strict_kademlia = |
3478 | "strict_kademlia"); | 3462 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht", "strict_kademlia"); |
3479 | if (strict_kademlia == GNUNET_SYSERR) | 3463 | if (strict_kademlia == GNUNET_SYSERR) |
3480 | strict_kademlia = GNUNET_NO; | 3464 | strict_kademlia = GNUNET_NO; |
3481 | 3465 | ||
3482 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (cfg, "dht_testing", | 3466 | if (GNUNET_OK != |
3483 | "comment", | 3467 | GNUNET_CONFIGURATION_get_value_string (cfg, "dht_testing", "comment", |
3484 | &trialmessage)) | 3468 | &trialmessage)) |
3485 | trialmessage = NULL; | 3469 | trialmessage = NULL; |
3486 | 3470 | ||
3487 | churn_data = NULL; | 3471 | churn_data = NULL; |
3488 | /** Check for a churn file to do churny simulation */ | 3472 | /** Check for a churn file to do churny simulation */ |
3489 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, "dht_testing", | 3473 | if (GNUNET_OK == |
3490 | "churn_file", | 3474 | GNUNET_CONFIGURATION_get_value_string (cfg, "dht_testing", "churn_file", |
3491 | &churn_filename)) | 3475 | &churn_filename)) |
3492 | { | 3476 | { |
3493 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Reading churn data from %s\n", | 3477 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Reading churn data from %s\n", |
3494 | churn_filename); | 3478 | churn_filename); |
@@ -3511,8 +3495,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
3511 | 3495 | ||
3512 | churn_data = GNUNET_malloc_large (frstat.st_size); | 3496 | churn_data = GNUNET_malloc_large (frstat.st_size); |
3513 | GNUNET_assert (churn_data != NULL); | 3497 | GNUNET_assert (churn_data != NULL); |
3514 | if (frstat.st_size != GNUNET_DISK_fn_read (churn_filename, churn_data, | 3498 | if (frstat.st_size != |
3515 | frstat.st_size)) | 3499 | GNUNET_DISK_fn_read (churn_filename, churn_data, frstat.st_size)) |
3516 | { | 3500 | { |
3517 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 3501 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
3518 | "Could not read file %s specified for churn, ending test!", | 3502 | "Could not read file %s specified for churn, ending test!", |
@@ -3551,10 +3535,10 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
3551 | } | 3535 | } |
3552 | } | 3536 | } |
3553 | 3537 | ||
3554 | if (GNUNET_OK | 3538 | if (GNUNET_OK != |
3555 | != GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", | 3539 | GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", |
3556 | "churns_per_round", | 3540 | "churns_per_round", |
3557 | &churns_per_round)) | 3541 | &churns_per_round)) |
3558 | { | 3542 | { |
3559 | churns_per_round = (unsigned long long) churn_rounds; | 3543 | churns_per_round = (unsigned long long) churn_rounds; |
3560 | } | 3544 | } |
@@ -3570,8 +3554,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
3570 | ret = sscanf (buf, "%u", &churn_array[line_number]); | 3554 | ret = sscanf (buf, "%u", &churn_array[line_number]); |
3571 | if (1 == ret) | 3555 | if (1 == ret) |
3572 | { | 3556 | { |
3573 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 3557 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Read %u peers in round %u\n", |
3574 | "Read %u peers in round %u\n", | ||
3575 | churn_array[line_number], line_number); | 3558 | churn_array[line_number], line_number); |
3576 | line_number++; | 3559 | line_number++; |
3577 | } | 3560 | } |
@@ -3591,9 +3574,9 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
3591 | GNUNET_free_non_null (churn_data); | 3574 | GNUNET_free_non_null (churn_data); |
3592 | 3575 | ||
3593 | /* Check for a hostfile containing user@host:port triples */ | 3576 | /* Check for a hostfile containing user@host:port triples */ |
3594 | if (GNUNET_OK | 3577 | if (GNUNET_OK != |
3595 | != GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "hostfile", | 3578 | GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "hostfile", |
3596 | &hostfile)) | 3579 | &hostfile)) |
3597 | hostfile = NULL; | 3580 | hostfile = NULL; |
3598 | 3581 | ||
3599 | hosts = NULL; | 3582 | hosts = NULL; |
@@ -3602,8 +3585,9 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
3602 | if (hostfile != NULL) | 3585 | if (hostfile != NULL) |
3603 | { | 3586 | { |
3604 | if (GNUNET_OK != GNUNET_DISK_file_test (hostfile)) | 3587 | if (GNUNET_OK != GNUNET_DISK_file_test (hostfile)) |
3605 | GNUNET_DISK_fn_write (hostfile, NULL, 0, GNUNET_DISK_PERM_USER_READ | 3588 | GNUNET_DISK_fn_write (hostfile, NULL, 0, |
3606 | | GNUNET_DISK_PERM_USER_WRITE); | 3589 | GNUNET_DISK_PERM_USER_READ | |
3590 | GNUNET_DISK_PERM_USER_WRITE); | ||
3607 | if ((0 != STAT (hostfile, &frstat)) || (frstat.st_size == 0)) | 3591 | if ((0 != STAT (hostfile, &frstat)) || (frstat.st_size == 0)) |
3608 | { | 3592 | { |
3609 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 3593 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -3638,9 +3622,9 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
3638 | { | 3622 | { |
3639 | data[count] = '\0'; | 3623 | data[count] = '\0'; |
3640 | temphost = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Host)); | 3624 | temphost = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Host)); |
3641 | ret = sscanf (buf, "%a[a-zA-Z0-9_]@%a[a-zA-Z0-9.]:%hd", | 3625 | ret = |
3642 | &temphost->username, &temphost->hostname, | 3626 | sscanf (buf, "%a[a-zA-Z0-9_]@%a[a-zA-Z0-9.]:%hd", |
3643 | &temphost->port); | 3627 | &temphost->username, &temphost->hostname, &temphost->port); |
3644 | if (3 == ret) | 3628 | if (3 == ret) |
3645 | { | 3629 | { |
3646 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3630 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -3664,124 +3648,134 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
3664 | } | 3648 | } |
3665 | } | 3649 | } |
3666 | GNUNET_free_non_null (data); | 3650 | GNUNET_free_non_null (data); |
3667 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", | 3651 | if (GNUNET_OK != |
3668 | "malicious_getters", | 3652 | GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", |
3669 | &malicious_getters)) | 3653 | "malicious_getters", |
3654 | &malicious_getters)) | ||
3670 | malicious_getters = 0; | 3655 | malicious_getters = 0; |
3671 | 3656 | ||
3672 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", | 3657 | if (GNUNET_OK != |
3673 | "malicious_putters", | 3658 | GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", |
3674 | &malicious_putters)) | 3659 | "malicious_putters", |
3660 | &malicious_putters)) | ||
3675 | malicious_putters = 0; | 3661 | malicious_putters = 0; |
3676 | 3662 | ||
3677 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", | 3663 | if (GNUNET_OK != |
3678 | "malicious_droppers", | 3664 | GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", |
3679 | &malicious_droppers)) | 3665 | "malicious_droppers", |
3666 | &malicious_droppers)) | ||
3680 | malicious_droppers = 0; | 3667 | malicious_droppers = 0; |
3681 | 3668 | ||
3682 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", | 3669 | if (GNUNET_OK != |
3683 | "settle_time", | 3670 | GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", "settle_time", |
3684 | &settle_time)) | 3671 | &settle_time)) |
3685 | settle_time = 0; | 3672 | settle_time = 0; |
3686 | 3673 | ||
3687 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | 3674 | if (GNUNET_SYSERR == |
3688 | "dht_testing", | 3675 | GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", "num_puts", |
3689 | "num_puts", | 3676 | &num_puts)) |
3690 | &num_puts)) | ||
3691 | num_puts = num_peers; | 3677 | num_puts = num_peers; |
3692 | 3678 | ||
3693 | if (GNUNET_SYSERR | 3679 | if (GNUNET_SYSERR == |
3694 | == GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", | 3680 | GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", |
3695 | "put_replication", | 3681 | "put_replication", |
3696 | &put_replication)) | 3682 | &put_replication)) |
3697 | put_replication = DEFAULT_PUT_REPLICATION; | 3683 | put_replication = DEFAULT_PUT_REPLICATION; |
3698 | 3684 | ||
3699 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | 3685 | if (GNUNET_SYSERR == |
3700 | "dht_testing", | 3686 | GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", "num_gets", |
3701 | "num_gets", | 3687 | &num_gets)) |
3702 | &num_gets)) | ||
3703 | num_gets = num_peers; | 3688 | num_gets = num_peers; |
3704 | 3689 | ||
3705 | if (GNUNET_SYSERR | 3690 | if (GNUNET_SYSERR == |
3706 | == GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", | 3691 | GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", |
3707 | "get_replication", | 3692 | "get_replication", |
3708 | &get_replication)) | 3693 | &get_replication)) |
3709 | get_replication = DEFAULT_GET_REPLICATION; | 3694 | get_replication = DEFAULT_GET_REPLICATION; |
3710 | 3695 | ||
3711 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", | 3696 | if (GNUNET_OK == |
3712 | "find_peer_delay", | 3697 | GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", |
3713 | &temp_config_number)) | 3698 | "find_peer_delay", |
3714 | find_peer_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | 3699 | &temp_config_number)) |
3715 | temp_config_number); | 3700 | find_peer_delay = |
3701 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | ||
3702 | temp_config_number); | ||
3716 | else | 3703 | else |
3717 | find_peer_delay = DEFAULT_FIND_PEER_DELAY; | 3704 | find_peer_delay = DEFAULT_FIND_PEER_DELAY; |
3718 | 3705 | ||
3719 | if (GNUNET_OK | 3706 | if (GNUNET_OK == |
3720 | == GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", | 3707 | GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", |
3721 | "concurrent_find_peers", | 3708 | "concurrent_find_peers", |
3722 | &temp_config_number)) | 3709 | &temp_config_number)) |
3723 | max_outstanding_find_peers = temp_config_number; | 3710 | max_outstanding_find_peers = temp_config_number; |
3724 | else | 3711 | else |
3725 | max_outstanding_find_peers = DEFAULT_MAX_OUTSTANDING_FIND_PEERS; | 3712 | max_outstanding_find_peers = DEFAULT_MAX_OUTSTANDING_FIND_PEERS; |
3726 | 3713 | ||
3727 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", | 3714 | if (GNUNET_OK == |
3728 | "get_timeout", | 3715 | GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", "get_timeout", |
3729 | &temp_config_number)) | 3716 | &temp_config_number)) |
3730 | get_timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | 3717 | get_timeout = |
3731 | temp_config_number); | 3718 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |
3719 | temp_config_number); | ||
3732 | else | 3720 | else |
3733 | get_timeout = DEFAULT_GET_TIMEOUT; | 3721 | get_timeout = DEFAULT_GET_TIMEOUT; |
3734 | 3722 | ||
3735 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", | 3723 | if (GNUNET_OK == |
3736 | "concurrent_puts", | 3724 | GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", |
3737 | &temp_config_number)) | 3725 | "concurrent_puts", |
3726 | &temp_config_number)) | ||
3738 | max_outstanding_puts = temp_config_number; | 3727 | max_outstanding_puts = temp_config_number; |
3739 | else | 3728 | else |
3740 | max_outstanding_puts = DEFAULT_MAX_OUTSTANDING_PUTS; | 3729 | max_outstanding_puts = DEFAULT_MAX_OUTSTANDING_PUTS; |
3741 | 3730 | ||
3742 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", | 3731 | if (GNUNET_OK == |
3743 | "concurrent_gets", | 3732 | GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", |
3744 | &temp_config_number)) | 3733 | "concurrent_gets", |
3734 | &temp_config_number)) | ||
3745 | max_outstanding_gets = temp_config_number; | 3735 | max_outstanding_gets = temp_config_number; |
3746 | else | 3736 | else |
3747 | max_outstanding_gets = DEFAULT_MAX_OUTSTANDING_GETS; | 3737 | max_outstanding_gets = DEFAULT_MAX_OUTSTANDING_GETS; |
3748 | 3738 | ||
3749 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", | 3739 | if (GNUNET_OK == |
3750 | "timeout", | 3740 | GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", "timeout", |
3751 | &temp_config_number)) | 3741 | &temp_config_number)) |
3752 | all_get_timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | 3742 | all_get_timeout = |
3753 | temp_config_number); | 3743 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |
3744 | temp_config_number); | ||
3754 | else | 3745 | else |
3755 | all_get_timeout.rel_value = get_timeout.rel_value * num_gets; | 3746 | all_get_timeout.rel_value = get_timeout.rel_value * num_gets; |
3756 | 3747 | ||
3757 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", | 3748 | if (GNUNET_OK == |
3758 | "get_delay", | 3749 | GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", "get_delay", |
3759 | &temp_config_number)) | 3750 | &temp_config_number)) |
3760 | get_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | 3751 | get_delay = |
3761 | temp_config_number); | 3752 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |
3753 | temp_config_number); | ||
3762 | else | 3754 | else |
3763 | get_delay = DEFAULT_GET_DELAY; | 3755 | get_delay = DEFAULT_GET_DELAY; |
3764 | 3756 | ||
3765 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", | 3757 | if (GNUNET_OK == |
3766 | "put_delay", | 3758 | GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", "put_delay", |
3767 | &temp_config_number)) | 3759 | &temp_config_number)) |
3768 | put_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | 3760 | put_delay = |
3769 | temp_config_number); | 3761 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |
3762 | temp_config_number); | ||
3770 | else | 3763 | else |
3771 | put_delay = DEFAULT_PUT_DELAY; | 3764 | put_delay = DEFAULT_PUT_DELAY; |
3772 | 3765 | ||
3773 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", | 3766 | if (GNUNET_OK == |
3774 | "peer_start_timeout", | 3767 | GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", |
3775 | &temp_config_number)) | 3768 | "peer_start_timeout", |
3776 | seconds_per_peer_start | 3769 | &temp_config_number)) |
3777 | = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | 3770 | seconds_per_peer_start = |
3778 | temp_config_number); | 3771 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, |
3772 | temp_config_number); | ||
3779 | else | 3773 | else |
3780 | seconds_per_peer_start = DEFAULT_SECONDS_PER_PEER_START; | 3774 | seconds_per_peer_start = DEFAULT_SECONDS_PER_PEER_START; |
3781 | 3775 | ||
3782 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", | 3776 | if (GNUNET_OK == |
3783 | "data_size", | 3777 | GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", "data_size", |
3784 | &temp_config_number)) | 3778 | &temp_config_number)) |
3785 | test_data_size = temp_config_number; | 3779 | test_data_size = temp_config_number; |
3786 | else | 3780 | else |
3787 | test_data_size = DEFAULT_TEST_DATA_SIZE; | 3781 | test_data_size = DEFAULT_TEST_DATA_SIZE; |
@@ -3789,39 +3783,42 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
3789 | /** | 3783 | /** |
3790 | * Get DHT testing related options. | 3784 | * Get DHT testing related options. |
3791 | */ | 3785 | */ |
3792 | if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (cfg, "DHT_TESTING", | 3786 | if (GNUNET_YES == |
3793 | "REPLICATE_SAME")) | 3787 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "DHT_TESTING", |
3788 | "REPLICATE_SAME")) | ||
3794 | replicate_same = GNUNET_YES; | 3789 | replicate_same = GNUNET_YES; |
3795 | 3790 | ||
3796 | if (GNUNET_SYSERR | 3791 | if (GNUNET_SYSERR == |
3797 | == GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", | 3792 | GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", |
3798 | "target_completions", | 3793 | "target_completions", |
3799 | &target_completions)) | 3794 | &target_completions)) |
3800 | target_completions = 0; /* Not required, on stack */ | 3795 | target_completions = 0; /* Not required, on stack */ |
3801 | 3796 | ||
3802 | if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (cfg, "DHT_TESTING", | 3797 | if (GNUNET_YES == |
3803 | "GET_FROM_SAME")) | 3798 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "DHT_TESTING", |
3799 | "GET_FROM_SAME")) | ||
3804 | get_from_same = GNUNET_YES; | 3800 | get_from_same = GNUNET_YES; |
3805 | 3801 | ||
3806 | if (GNUNET_NO | 3802 | if (GNUNET_NO == |
3807 | == GNUNET_CONFIGURATION_get_value_time (cfg, "DHT_TESTING", | 3803 | GNUNET_CONFIGURATION_get_value_time (cfg, "DHT_TESTING", |
3808 | "MALICIOUS_GET_FREQUENCY", | 3804 | "MALICIOUS_GET_FREQUENCY", |
3809 | &malicious_get_frequency)) | 3805 | &malicious_get_frequency)) |
3810 | malicious_get_frequency = DEFAULT_MALICIOUS_GET_FREQUENCY; | 3806 | malicious_get_frequency = DEFAULT_MALICIOUS_GET_FREQUENCY; |
3811 | 3807 | ||
3812 | if (GNUNET_NO | 3808 | if (GNUNET_NO == |
3813 | == GNUNET_CONFIGURATION_get_value_time (cfg, "DHT_TESTING", | 3809 | GNUNET_CONFIGURATION_get_value_time (cfg, "DHT_TESTING", |
3814 | "MALICIOUS_PUT_FREQUENCY", | 3810 | "MALICIOUS_PUT_FREQUENCY", |
3815 | &malicious_put_frequency)) | 3811 | &malicious_put_frequency)) |
3816 | malicious_put_frequency = DEFAULT_MALICIOUS_PUT_FREQUENCY; | 3812 | malicious_put_frequency = DEFAULT_MALICIOUS_PUT_FREQUENCY; |
3817 | 3813 | ||
3818 | if (GNUNET_YES | 3814 | if (GNUNET_YES == |
3819 | == GNUNET_CONFIGURATION_get_value_yesno (cfg, "DHT_TESTING", | 3815 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "DHT_TESTING", |
3820 | "MALICIOUS_AFTER_SETTLE")) | 3816 | "MALICIOUS_AFTER_SETTLE")) |
3821 | malicious_after_settle = GNUNET_YES; | 3817 | malicious_after_settle = GNUNET_YES; |
3822 | 3818 | ||
3823 | if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (cfg, "DHT_TESTING", | 3819 | if (GNUNET_YES == |
3824 | "MALICIOUS_SYBIL")) | 3820 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "DHT_TESTING", |
3821 | "MALICIOUS_SYBIL")) | ||
3825 | { | 3822 | { |
3826 | /* Set up the malicious target at random for this round */ | 3823 | /* Set up the malicious target at random for this round */ |
3827 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, | 3824 | GNUNET_CRYPTO_hash_create_random (GNUNET_CRYPTO_QUALITY_WEAK, |
@@ -3836,81 +3833,83 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
3836 | while (1 << k < malicious_droppers) | 3833 | while (1 << k < malicious_droppers) |
3837 | k++; | 3834 | k++; |
3838 | if (malicious_droppers > 0) | 3835 | if (malicious_droppers > 0) |
3839 | malicious_bloom = GNUNET_CONTAINER_bloomfilter_init (NULL, 1 << k, | 3836 | malicious_bloom = |
3840 | DHT_BLOOM_K); | 3837 | GNUNET_CONTAINER_bloomfilter_init (NULL, 1 << k, DHT_BLOOM_K); |
3841 | 3838 | ||
3842 | /* The normal behavior of the DHT is to do find peer requests | 3839 | /* The normal behavior of the DHT is to do find peer requests |
3843 | * on its own. Only if this is explicitly turned off should | 3840 | * on its own. Only if this is explicitly turned off should |
3844 | * the testing driver issue find peer requests (even though | 3841 | * the testing driver issue find peer requests (even though |
3845 | * this is likely the default when testing). | 3842 | * this is likely the default when testing). |
3846 | */ | 3843 | */ |
3847 | if (GNUNET_NO == GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht", | 3844 | if (GNUNET_NO == |
3848 | "do_find_peer")) | 3845 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht", "do_find_peer")) |
3849 | do_find_peer = GNUNET_YES; | 3846 | do_find_peer = GNUNET_YES; |
3850 | 3847 | ||
3851 | if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht_testing", | 3848 | if (GNUNET_YES == |
3852 | "insert_gauger_data")) | 3849 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht_testing", |
3850 | "insert_gauger_data")) | ||
3853 | insert_gauger_data = GNUNET_YES; | 3851 | insert_gauger_data = GNUNET_YES; |
3854 | 3852 | ||
3855 | if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht", | 3853 | if (GNUNET_YES == |
3856 | "republish")) | 3854 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht", "republish")) |
3857 | in_dht_replication = GNUNET_YES; | 3855 | in_dht_replication = GNUNET_YES; |
3858 | 3856 | ||
3859 | if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_number (cfg, "DHT_TESTING", | 3857 | if (GNUNET_YES != |
3860 | "TRIAL_TO_RUN", | 3858 | GNUNET_CONFIGURATION_get_value_number (cfg, "DHT_TESTING", "TRIAL_TO_RUN", |
3861 | &trial_to_run)) | 3859 | &trial_to_run)) |
3862 | trial_to_run = 0; | 3860 | trial_to_run = 0; |
3863 | 3861 | ||
3864 | if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_number (cfg, "DHT_TESTING", | 3862 | if (GNUNET_YES != |
3865 | "REVISION", | 3863 | GNUNET_CONFIGURATION_get_value_number (cfg, "DHT_TESTING", "REVISION", |
3866 | &revision)) | 3864 | &revision)) |
3867 | revision = 0; | 3865 | revision = 0; |
3868 | 3866 | ||
3869 | if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_number (cfg, "DHT_TESTING", | 3867 | if (GNUNET_YES == |
3870 | "FIND_PEER_DELAY", | 3868 | GNUNET_CONFIGURATION_get_value_number (cfg, "DHT_TESTING", |
3871 | &temp_config_number)) | 3869 | "FIND_PEER_DELAY", |
3872 | find_peer_delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | 3870 | &temp_config_number)) |
3873 | temp_config_number); | 3871 | find_peer_delay = |
3872 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, | ||
3873 | temp_config_number); | ||
3874 | else | 3874 | else |
3875 | find_peer_delay = DEFAULT_FIND_PEER_DELAY; | 3875 | find_peer_delay = DEFAULT_FIND_PEER_DELAY; |
3876 | 3876 | ||
3877 | if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_number (cfg, "DHT_TESTING", | 3877 | if (GNUNET_YES != |
3878 | "ROUND_DELAY", | 3878 | GNUNET_CONFIGURATION_get_value_number (cfg, "DHT_TESTING", "ROUND_DELAY", |
3879 | &round_delay)) | 3879 | &round_delay)) |
3880 | round_delay = 0; | 3880 | round_delay = 0; |
3881 | 3881 | ||
3882 | if (GNUNET_NO | 3882 | if (GNUNET_NO == |
3883 | == GNUNET_CONFIGURATION_get_value_number (cfg, "DHT_TESTING", | 3883 | GNUNET_CONFIGURATION_get_value_number (cfg, "DHT_TESTING", |
3884 | "OUTSTANDING_FIND_PEERS", | 3884 | "OUTSTANDING_FIND_PEERS", |
3885 | &max_outstanding_find_peers)) | 3885 | &max_outstanding_find_peers)) |
3886 | max_outstanding_find_peers = DEFAULT_MAX_OUTSTANDING_FIND_PEERS; | 3886 | max_outstanding_find_peers = DEFAULT_MAX_OUTSTANDING_FIND_PEERS; |
3887 | 3887 | ||
3888 | if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht", | 3888 | if (GNUNET_YES == |
3889 | "strict_kademlia")) | 3889 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht", "strict_kademlia")) |
3890 | max_outstanding_find_peers = max_outstanding_find_peers * 1; | 3890 | max_outstanding_find_peers = max_outstanding_find_peers * 1; |
3891 | 3891 | ||
3892 | find_peer_offset = GNUNET_TIME_relative_divide (find_peer_delay, | 3892 | find_peer_offset = |
3893 | max_outstanding_find_peers); | 3893 | GNUNET_TIME_relative_divide (find_peer_delay, max_outstanding_find_peers); |
3894 | 3894 | ||
3895 | if (GNUNET_SYSERR == GNUNET_CONFIGURATION_get_value_number (cfg, | 3895 | if (GNUNET_SYSERR == |
3896 | "dht_testing", | 3896 | GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", "num_rounds", |
3897 | "num_rounds", | 3897 | &total_rounds)) |
3898 | &total_rounds)) | ||
3899 | total_rounds = 1; | 3898 | total_rounds = 1; |
3900 | 3899 | ||
3901 | if ((GNUNET_SYSERR | 3900 | if ((GNUNET_SYSERR == |
3902 | == GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", | 3901 | GNUNET_CONFIGURATION_get_value_number (cfg, "dht_testing", |
3903 | "target_total_connections", | 3902 | "target_total_connections", |
3904 | &target_total_connections)) | 3903 | &target_total_connections)) || |
3905 | || (target_total_connections == 0)) | 3904 | (target_total_connections == 0)) |
3906 | target_total_connections = connection_estimate (num_peers, | 3905 | target_total_connections = |
3907 | DEFAULT_BUCKET_SIZE); | 3906 | connection_estimate (num_peers, DEFAULT_BUCKET_SIZE); |
3908 | 3907 | ||
3909 | topology_str = NULL; | 3908 | topology_str = NULL; |
3910 | if ((GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", | 3909 | if ((GNUNET_YES == |
3911 | "topology", | 3910 | GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "topology", |
3912 | &topology_str)) | 3911 | &topology_str)) && |
3913 | && (GNUNET_NO == GNUNET_TESTING_topology_get (&topology, topology_str))) | 3912 | (GNUNET_NO == GNUNET_TESTING_topology_get (&topology, topology_str))) |
3914 | { | 3913 | { |
3915 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 3914 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
3916 | "Invalid topology `%s' given for section %s option %s\n", | 3915 | "Invalid topology `%s' given for section %s option %s\n", |
@@ -3918,9 +3917,9 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
3918 | topology = GNUNET_TESTING_TOPOLOGY_CLIQUE; /* Defaults to NONE, so set better default here */ | 3917 | topology = GNUNET_TESTING_TOPOLOGY_CLIQUE; /* Defaults to NONE, so set better default here */ |
3919 | } | 3918 | } |
3920 | 3919 | ||
3921 | if (GNUNET_OK | 3920 | if (GNUNET_OK != |
3922 | != GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "percentage", | 3921 | GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "percentage", |
3923 | &topology_percentage_str)) | 3922 | &topology_percentage_str)) |
3924 | topology_percentage = 0.5; | 3923 | topology_percentage = 0.5; |
3925 | else | 3924 | else |
3926 | { | 3925 | { |
@@ -3928,9 +3927,9 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
3928 | GNUNET_free (topology_percentage_str); | 3927 | GNUNET_free (topology_percentage_str); |
3929 | } | 3928 | } |
3930 | 3929 | ||
3931 | if (GNUNET_OK | 3930 | if (GNUNET_OK != |
3932 | != GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "probability", | 3931 | GNUNET_CONFIGURATION_get_value_string (cfg, "testing", "probability", |
3933 | &topology_probability_str)) | 3932 | &topology_probability_str)) |
3934 | topology_probability = 0.5; | 3933 | topology_probability = 0.5; |
3935 | else | 3934 | else |
3936 | { | 3935 | { |
@@ -3938,12 +3937,12 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
3938 | GNUNET_free (topology_probability_str); | 3937 | GNUNET_free (topology_probability_str); |
3939 | } | 3938 | } |
3940 | 3939 | ||
3941 | if ((GNUNET_YES | 3940 | if ((GNUNET_YES == |
3942 | == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", | 3941 | GNUNET_CONFIGURATION_get_value_string (cfg, "testing", |
3943 | "connect_topology", | 3942 | "connect_topology", |
3944 | &connect_topology_str)) | 3943 | &connect_topology_str)) && |
3945 | && (GNUNET_NO == GNUNET_TESTING_topology_get (&connect_topology, | 3944 | (GNUNET_NO == |
3946 | connect_topology_str))) | 3945 | GNUNET_TESTING_topology_get (&connect_topology, connect_topology_str))) |
3947 | { | 3946 | { |
3948 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 3947 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
3949 | "Invalid connect topology `%s' given for section %s option %s\n", | 3948 | "Invalid connect topology `%s' given for section %s option %s\n", |
@@ -3951,13 +3950,13 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
3951 | } | 3950 | } |
3952 | GNUNET_free_non_null (connect_topology_str); | 3951 | GNUNET_free_non_null (connect_topology_str); |
3953 | 3952 | ||
3954 | if ((GNUNET_YES | 3953 | if ((GNUNET_YES == |
3955 | == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", | 3954 | GNUNET_CONFIGURATION_get_value_string (cfg, "testing", |
3956 | "connect_topology_option", | 3955 | "connect_topology_option", |
3957 | &connect_topology_option_str)) | 3956 | &connect_topology_option_str)) && |
3958 | && (GNUNET_NO | 3957 | (GNUNET_NO == |
3959 | == GNUNET_TESTING_topology_option_get (&connect_topology_option, | 3958 | GNUNET_TESTING_topology_option_get (&connect_topology_option, |
3960 | connect_topology_option_str))) | 3959 | connect_topology_option_str))) |
3961 | { | 3960 | { |
3962 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 3961 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
3963 | "Invalid connect topology option `%s' given for section %s option %s\n", | 3962 | "Invalid connect topology option `%s' given for section %s option %s\n", |
@@ -3967,14 +3966,14 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
3967 | } | 3966 | } |
3968 | GNUNET_free_non_null (connect_topology_option_str); | 3967 | GNUNET_free_non_null (connect_topology_option_str); |
3969 | 3968 | ||
3970 | if (GNUNET_YES | 3969 | if (GNUNET_YES == |
3971 | == GNUNET_CONFIGURATION_get_value_string (cfg, | 3970 | GNUNET_CONFIGURATION_get_value_string (cfg, "testing", |
3972 | "testing", | 3971 | "connect_topology_option_modifier", |
3973 | "connect_topology_option_modifier", | 3972 | &connect_topology_option_modifier_string)) |
3974 | &connect_topology_option_modifier_string)) | ||
3975 | { | 3973 | { |
3976 | if (sscanf (connect_topology_option_modifier_string, "%lf", | 3974 | if (sscanf |
3977 | &connect_topology_option_modifier) != 1) | 3975 | (connect_topology_option_modifier_string, "%lf", |
3976 | &connect_topology_option_modifier) != 1) | ||
3978 | { | 3977 | { |
3979 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 3978 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
3980 | _ | 3979 | _ |
@@ -3985,18 +3984,19 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
3985 | GNUNET_free (connect_topology_option_modifier_string); | 3984 | GNUNET_free (connect_topology_option_modifier_string); |
3986 | } | 3985 | } |
3987 | 3986 | ||
3988 | if (GNUNET_YES | 3987 | if (GNUNET_YES != |
3989 | != GNUNET_CONFIGURATION_get_value_string (cfg, "testing", | 3988 | GNUNET_CONFIGURATION_get_value_string (cfg, "testing", |
3990 | "blacklist_transports", | 3989 | "blacklist_transports", |
3991 | &blacklist_transports)) | 3990 | &blacklist_transports)) |
3992 | blacklist_transports = NULL; | 3991 | blacklist_transports = NULL; |
3993 | 3992 | ||
3994 | if ((GNUNET_YES | 3993 | if ((GNUNET_YES == |
3995 | == GNUNET_CONFIGURATION_get_value_string (cfg, "testing", | 3994 | GNUNET_CONFIGURATION_get_value_string (cfg, "testing", |
3996 | "blacklist_topology", | 3995 | "blacklist_topology", |
3997 | &blacklist_topology_str)) | 3996 | &blacklist_topology_str)) && |
3998 | && (GNUNET_NO == GNUNET_TESTING_topology_get (&blacklist_topology, | 3997 | (GNUNET_NO == |
3999 | blacklist_topology_str))) | 3998 | GNUNET_TESTING_topology_get (&blacklist_topology, |
3999 | blacklist_topology_str))) | ||
4000 | { | 4000 | { |
4001 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 4001 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
4002 | "Invalid topology `%s' given for section %s option %s\n", | 4002 | "Invalid topology `%s' given for section %s option %s\n", |
@@ -4009,8 +4009,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
4009 | peers_left = num_peers; | 4009 | peers_left = num_peers; |
4010 | 4010 | ||
4011 | /* Set up a task to end testing if peer start fails */ | 4011 | /* Set up a task to end testing if peer start fails */ |
4012 | die_task | 4012 | die_task = |
4013 | = | ||
4014 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 4013 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
4015 | (seconds_per_peer_start, num_peers), | 4014 | (seconds_per_peer_start, num_peers), |
4016 | &end_badly, | 4015 | &end_badly, |
@@ -4025,8 +4024,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
4025 | trial_info.blacklist_topology = blacklist_topology; | 4024 | trial_info.blacklist_topology = blacklist_topology; |
4026 | trial_info.connect_topology = connect_topology; | 4025 | trial_info.connect_topology = connect_topology; |
4027 | trial_info.connect_topology_option = connect_topology_option; | 4026 | trial_info.connect_topology_option = connect_topology_option; |
4028 | trial_info.connect_topology_option_modifier | 4027 | trial_info.connect_topology_option_modifier = |
4029 | = connect_topology_option_modifier; | 4028 | connect_topology_option_modifier; |
4030 | trial_info.topology_percentage = topology_percentage; | 4029 | trial_info.topology_percentage = topology_percentage; |
4031 | trial_info.topology_probability = topology_probability; | 4030 | trial_info.topology_probability = topology_probability; |
4032 | trial_info.puts = num_puts; | 4031 | trial_info.puts = num_puts; |
@@ -4059,8 +4058,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
4059 | put_meter = create_meter (num_puts, "Puts completed ", GNUNET_YES); | 4058 | put_meter = create_meter (num_puts, "Puts completed ", GNUNET_YES); |
4060 | get_meter = create_meter (num_gets, "Gets completed ", GNUNET_YES); | 4059 | get_meter = create_meter (num_gets, "Gets completed ", GNUNET_YES); |
4061 | hostkey_start_time = GNUNET_TIME_absolute_get (); | 4060 | hostkey_start_time = GNUNET_TIME_absolute_get (); |
4062 | pg = GNUNET_TESTING_daemons_start (cfg, | 4061 | pg = GNUNET_TESTING_daemons_start (cfg, peers_left, |
4063 | peers_left, | ||
4064 | max_outstanding_connections, | 4062 | max_outstanding_connections, |
4065 | max_concurrent_ssh, | 4063 | max_concurrent_ssh, |
4066 | GNUNET_TIME_relative_multiply | 4064 | GNUNET_TIME_relative_multiply |
@@ -4088,8 +4086,9 @@ main (int argc, char *argv[]) | |||
4088 | GNUNET_GETOPT_OPTION_END | 4086 | GNUNET_GETOPT_OPTION_END |
4089 | }; | 4087 | }; |
4090 | 4088 | ||
4091 | ret = GNUNET_PROGRAM_run (argc, argv, "gnunet-dht-driver", "nohelp", options, | 4089 | ret = |
4092 | &run, &ok); | 4090 | GNUNET_PROGRAM_run (argc, argv, "gnunet-dht-driver", "nohelp", options, |
4091 | &run, &ok); | ||
4093 | 4092 | ||
4094 | if (malicious_bloom != NULL) | 4093 | if (malicious_bloom != NULL) |
4095 | GNUNET_CONTAINER_bloomfilter_free (malicious_bloom); | 4094 | GNUNET_CONTAINER_bloomfilter_free (malicious_bloom); |
diff --git a/src/dht/gnunet-dht-get-peer.c b/src/dht/gnunet-dht-get-peer.c index 6ca88d232..2de7e93be 100644 --- a/src/dht/gnunet-dht-get-peer.c +++ b/src/dht/gnunet-dht-get-peer.c | |||
@@ -126,9 +126,8 @@ find_peer_processor (void *cls, const struct GNUNET_HELLO_Message *hello) | |||
126 | * @param c configuration | 126 | * @param c configuration |
127 | */ | 127 | */ |
128 | static void | 128 | static void |
129 | run (void *cls, | 129 | run (void *cls, char *const *args, const char *cfgfile, |
130 | char *const *args, | 130 | const struct GNUNET_CONFIGURATION_Handle *c) |
131 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) | ||
132 | { | 131 | { |
133 | struct GNUNET_TIME_Relative timeout; | 132 | struct GNUNET_TIME_Relative timeout; |
134 | GNUNET_HashCode key; | 133 | GNUNET_HashCode key; |
@@ -164,11 +163,9 @@ run (void *cls, | |||
164 | if (verbose) | 163 | if (verbose) |
165 | fprintf (stderr, "Issuing FIND PEER request for %s!\n", query_key); | 164 | fprintf (stderr, "Issuing FIND PEER request for %s!\n", query_key); |
166 | 165 | ||
167 | find_peer_handle = GNUNET_DHT_find_peer_start (dht_handle, | 166 | find_peer_handle = |
168 | timeout, | 167 | GNUNET_DHT_find_peer_start (dht_handle, timeout, &key, GNUNET_DHT_RO_NONE, |
169 | &key, | 168 | &find_peer_processor, NULL); |
170 | GNUNET_DHT_RO_NONE, | ||
171 | &find_peer_processor, NULL); | ||
172 | if (NULL == find_peer_handle) | 169 | if (NULL == find_peer_handle) |
173 | { | 170 | { |
174 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | 171 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); |
@@ -207,9 +204,7 @@ int | |||
207 | main (int argc, char *const *argv) | 204 | main (int argc, char *const *argv) |
208 | { | 205 | { |
209 | return (GNUNET_OK == | 206 | return (GNUNET_OK == |
210 | GNUNET_PROGRAM_run (argc, | 207 | GNUNET_PROGRAM_run (argc, argv, "gnunet-dht-get-peer", |
211 | argv, | ||
212 | "gnunet-dht-get-peer", | ||
213 | gettext_noop | 208 | gettext_noop |
214 | ("Issue a GET PEER request to the GNUnet DHT, print results."), | 209 | ("Issue a GET PEER request to the GNUnet DHT, print results."), |
215 | options, &run, NULL)) ? ret : 1; | 210 | options, &run, NULL)) ? ret : 1; |
diff --git a/src/dht/gnunet-dht-get.c b/src/dht/gnunet-dht-get.c index b807a798f..161f0f41b 100644 --- a/src/dht/gnunet-dht-get.c +++ b/src/dht/gnunet-dht-get.c | |||
@@ -117,15 +117,14 @@ cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
117 | * @param data pointer to the result data | 117 | * @param data pointer to the result data |
118 | */ | 118 | */ |
119 | void | 119 | void |
120 | get_result_iterator (void *cls, | 120 | get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp, |
121 | struct GNUNET_TIME_Absolute exp, | ||
122 | const GNUNET_HashCode * key, | 121 | const GNUNET_HashCode * key, |
123 | const struct GNUNET_PeerIdentity *const *get_path, | 122 | const struct GNUNET_PeerIdentity *const *get_path, |
124 | const struct GNUNET_PeerIdentity *const *put_path, | 123 | const struct GNUNET_PeerIdentity *const *put_path, |
125 | enum GNUNET_BLOCK_Type type, size_t size, const void *data) | 124 | enum GNUNET_BLOCK_Type type, size_t size, const void *data) |
126 | { | 125 | { |
127 | fprintf (stdout, "Result %d, type %d:\n%.*s\n", | 126 | fprintf (stdout, "Result %d, type %d:\n%.*s\n", result_count, type, |
128 | result_count, type, (unsigned int) size, (char *) data); | 127 | (unsigned int) size, (char *) data); |
129 | result_count++; | 128 | result_count++; |
130 | } | 129 | } |
131 | 130 | ||
@@ -139,9 +138,8 @@ get_result_iterator (void *cls, | |||
139 | * @param c configuration | 138 | * @param c configuration |
140 | */ | 139 | */ |
141 | static void | 140 | static void |
142 | run (void *cls, | 141 | run (void *cls, char *const *args, const char *cfgfile, |
143 | char *const *args, | 142 | const struct GNUNET_CONFIGURATION_Handle *c) |
144 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) | ||
145 | { | 143 | { |
146 | struct GNUNET_TIME_Relative timeout; | 144 | struct GNUNET_TIME_Relative timeout; |
147 | GNUNET_HashCode key; | 145 | GNUNET_HashCode key; |
@@ -181,14 +179,10 @@ run (void *cls, | |||
181 | fprintf (stderr, "Issuing GET request for %s!\n", query_key); | 179 | fprintf (stderr, "Issuing GET request for %s!\n", query_key); |
182 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining | 180 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining |
183 | (absolute_timeout), &cleanup_task, NULL); | 181 | (absolute_timeout), &cleanup_task, NULL); |
184 | get_handle = GNUNET_DHT_get_start (dht_handle, | 182 | get_handle = |
185 | timeout, | 183 | GNUNET_DHT_get_start (dht_handle, timeout, query_type, &key, |
186 | query_type, | 184 | DEFAULT_GET_REPLICATION, GNUNET_DHT_RO_NONE, NULL, |
187 | &key, | 185 | 0, NULL, 0, &get_result_iterator, NULL); |
188 | DEFAULT_GET_REPLICATION, | ||
189 | GNUNET_DHT_RO_NONE, | ||
190 | NULL, 0, | ||
191 | NULL, 0, &get_result_iterator, NULL); | ||
192 | 186 | ||
193 | } | 187 | } |
194 | 188 | ||
@@ -224,9 +218,7 @@ int | |||
224 | main (int argc, char *const *argv) | 218 | main (int argc, char *const *argv) |
225 | { | 219 | { |
226 | return (GNUNET_OK == | 220 | return (GNUNET_OK == |
227 | GNUNET_PROGRAM_run (argc, | 221 | GNUNET_PROGRAM_run (argc, argv, "gnunet-dht-get", |
228 | argv, | ||
229 | "gnunet-dht-get", | ||
230 | gettext_noop | 222 | gettext_noop |
231 | ("Issue a GET request to the GNUnet DHT, prints results."), | 223 | ("Issue a GET request to the GNUnet DHT, prints results."), |
232 | options, &run, NULL)) ? ret : 1; | 224 | options, &run, NULL)) ? ret : 1; |
diff --git a/src/dht/gnunet-dht-put.c b/src/dht/gnunet-dht-put.c index b76b92c2b..4a752ea24 100644 --- a/src/dht/gnunet-dht-put.c +++ b/src/dht/gnunet-dht-put.c | |||
@@ -105,9 +105,8 @@ message_sent_cont (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
105 | * @param c configuration | 105 | * @param c configuration |
106 | */ | 106 | */ |
107 | static void | 107 | static void |
108 | run (void *cls, | 108 | run (void *cls, char *const *args, const char *cfgfile, |
109 | char *const *args, | 109 | const struct GNUNET_CONFIGURATION_Handle *c) |
110 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) | ||
111 | { | 110 | { |
112 | struct GNUNET_TIME_Relative timeout; | 111 | struct GNUNET_TIME_Relative timeout; |
113 | struct GNUNET_TIME_Absolute expiration; | 112 | struct GNUNET_TIME_Absolute expiration; |
@@ -147,9 +146,9 @@ run (void *cls, | |||
147 | if (verbose) | 146 | if (verbose) |
148 | fprintf (stderr, _("Issuing put request for `%s' with data `%s'!\n"), | 147 | fprintf (stderr, _("Issuing put request for `%s' with data `%s'!\n"), |
149 | query_key, data); | 148 | query_key, data); |
150 | GNUNET_DHT_put (dht_handle, &key, DEFAULT_PUT_REPLICATION, | 149 | GNUNET_DHT_put (dht_handle, &key, DEFAULT_PUT_REPLICATION, GNUNET_DHT_RO_NONE, |
151 | GNUNET_DHT_RO_NONE, query_type, strlen (data), data, | 150 | query_type, strlen (data), data, expiration, timeout, |
152 | expiration, timeout, &message_sent_cont, NULL); | 151 | &message_sent_cont, NULL); |
153 | 152 | ||
154 | } | 153 | } |
155 | 154 | ||
@@ -191,9 +190,7 @@ int | |||
191 | main (int argc, char *const *argv) | 190 | main (int argc, char *const *argv) |
192 | { | 191 | { |
193 | return (GNUNET_OK == | 192 | return (GNUNET_OK == |
194 | GNUNET_PROGRAM_run (argc, | 193 | GNUNET_PROGRAM_run (argc, argv, "gnunet-dht-put", |
195 | argv, | ||
196 | "gnunet-dht-put", | ||
197 | gettext_noop | 194 | gettext_noop |
198 | ("Issue a PUT request to the GNUnet DHT insert DATA under KEY."), | 195 | ("Issue a PUT request to the GNUnet DHT insert DATA under KEY."), |
199 | options, &run, NULL)) ? ret : 1; | 196 | options, &run, NULL)) ? ret : 1; |
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c index 19250d07b..1721e73af 100644 --- a/src/dht/gnunet-service-dht.c +++ b/src/dht/gnunet-service-dht.c | |||
@@ -984,9 +984,8 @@ get_average_send_delay () | |||
984 | } | 984 | } |
985 | 985 | ||
986 | average_time = GNUNET_TIME_relative_divide (average_time, divisor); | 986 | average_time = GNUNET_TIME_relative_divide (average_time, divisor); |
987 | fprintf (stderr, | 987 | fprintf (stderr, "Avg send delay: %u sends is %llu\n", divisor, |
988 | "Avg send delay: %u sends is %llu\n", | 988 | (unsigned long long) average_time.abs_value); |
989 | divisor, (unsigned long long) average_time.abs_value); | ||
990 | return average_time; | 989 | return average_time; |
991 | } | 990 | } |
992 | #endif | 991 | #endif |
@@ -1088,8 +1087,7 @@ try_core_send (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1088 | if (reply_counter >= MAX_REPLY_TIMES) | 1087 | if (reply_counter >= MAX_REPLY_TIMES) |
1089 | reply_counter = 0; | 1088 | reply_counter = 0; |
1090 | peer->th = | 1089 | peer->th = |
1091 | GNUNET_CORE_notify_transmit_ready (coreAPI, | 1090 | GNUNET_CORE_notify_transmit_ready (coreAPI, GNUNET_YES, |
1092 | GNUNET_YES, | ||
1093 | pending->importance, | 1091 | pending->importance, |
1094 | pending->timeout, &peer->id, ssize, | 1092 | pending->timeout, &peer->id, ssize, |
1095 | &core_transmit_notify, peer); | 1093 | &core_transmit_notify, peer); |
@@ -1162,8 +1160,7 @@ forward_result_message (const struct GNUNET_MessageHeader *msg, | |||
1162 | result_message->hop_count = htonl (msg_ctx->hop_count + 1); | 1160 | result_message->hop_count = htonl (msg_ctx->hop_count + 1); |
1163 | GNUNET_assert (GNUNET_OK == | 1161 | GNUNET_assert (GNUNET_OK == |
1164 | GNUNET_CONTAINER_bloomfilter_get_raw_data (msg_ctx->bloom, | 1162 | GNUNET_CONTAINER_bloomfilter_get_raw_data (msg_ctx->bloom, |
1165 | result_message-> | 1163 | result_message->bloomfilter, |
1166 | bloomfilter, | ||
1167 | DHT_BLOOM_SIZE)); | 1164 | DHT_BLOOM_SIZE)); |
1168 | result_message->unique_id = GNUNET_htonll (msg_ctx->unique_id); | 1165 | result_message->unique_id = GNUNET_htonll (msg_ctx->unique_id); |
1169 | memcpy (&result_message->key, &msg_ctx->key, sizeof (GNUNET_HashCode)); | 1166 | memcpy (&result_message->key, &msg_ctx->key, sizeof (GNUNET_HashCode)); |
@@ -1177,8 +1174,8 @@ forward_result_message (const struct GNUNET_MessageHeader *msg, | |||
1177 | msg_ctx->path_history_len * (sizeof (struct GNUNET_PeerIdentity))); | 1174 | msg_ctx->path_history_len * (sizeof (struct GNUNET_PeerIdentity))); |
1178 | #if DEBUG_DHT > 1 | 1175 | #if DEBUG_DHT > 1 |
1179 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1176 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1180 | "%s:%s Adding pending message size %d for peer %s\n", | 1177 | "%s:%s Adding pending message size %d for peer %s\n", my_short_id, |
1181 | my_short_id, "DHT", msize, GNUNET_i2s (&peer->id)); | 1178 | "DHT", msize, GNUNET_i2s (&peer->id)); |
1182 | #endif | 1179 | #endif |
1183 | peer->pending_count++; | 1180 | peer->pending_count++; |
1184 | increment_stats ("# pending messages scheduled"); | 1181 | increment_stats ("# pending messages scheduled"); |
@@ -1477,9 +1474,9 @@ find_peer_by_id (const struct GNUNET_PeerIdentity *peer) | |||
1477 | } | 1474 | } |
1478 | 1475 | ||
1479 | /* Forward declaration */ | 1476 | /* Forward declaration */ |
1480 | static void | 1477 | static void update_core_preference (void *cls, |
1481 | update_core_preference (void *cls, | 1478 | const struct GNUNET_SCHEDULER_TaskContext |
1482 | const struct GNUNET_SCHEDULER_TaskContext *tc); | 1479 | *tc); |
1483 | /** | 1480 | /** |
1484 | * Function called with statistics about the given peer. | 1481 | * Function called with statistics about the given peer. |
1485 | * | 1482 | * |
@@ -1532,14 +1529,12 @@ update_core_preference (void *cls, | |||
1532 | matching = 63; | 1529 | matching = 63; |
1533 | } | 1530 | } |
1534 | preference = 1LL << matching; | 1531 | preference = 1LL << matching; |
1535 | peer->info_ctx = GNUNET_CORE_peer_change_preference (coreAPI, | 1532 | peer->info_ctx = |
1536 | &peer->id, | 1533 | GNUNET_CORE_peer_change_preference (coreAPI, &peer->id, |
1537 | GNUNET_TIME_UNIT_FOREVER_REL, | 1534 | GNUNET_TIME_UNIT_FOREVER_REL, |
1538 | GNUNET_BANDWIDTH_VALUE_MAX, | 1535 | GNUNET_BANDWIDTH_VALUE_MAX, 0, |
1539 | 0, | 1536 | preference, |
1540 | preference, | 1537 | &update_core_preference_finish, peer); |
1541 | &update_core_preference_finish, | ||
1542 | peer); | ||
1543 | } | 1538 | } |
1544 | 1539 | ||
1545 | 1540 | ||
@@ -1557,12 +1552,12 @@ static void | |||
1557 | remove_peer (struct PeerInfo *peer, unsigned int bucket) | 1552 | remove_peer (struct PeerInfo *peer, unsigned int bucket) |
1558 | { | 1553 | { |
1559 | GNUNET_assert (k_buckets[bucket].peers_size > 0); | 1554 | GNUNET_assert (k_buckets[bucket].peers_size > 0); |
1560 | GNUNET_CONTAINER_DLL_remove (k_buckets[bucket].head, | 1555 | GNUNET_CONTAINER_DLL_remove (k_buckets[bucket].head, k_buckets[bucket].tail, |
1561 | k_buckets[bucket].tail, peer); | 1556 | peer); |
1562 | k_buckets[bucket].peers_size--; | 1557 | k_buckets[bucket].peers_size--; |
1563 | #if CHANGE_LOWEST | 1558 | #if CHANGE_LOWEST |
1564 | if ((bucket == lowest_bucket) && (k_buckets[lowest_bucket].peers_size == 0) | 1559 | if ((bucket == lowest_bucket) && (k_buckets[lowest_bucket].peers_size == 0) && |
1565 | && (lowest_bucket < MAX_BUCKETS - 1)) | 1560 | (lowest_bucket < MAX_BUCKETS - 1)) |
1566 | lowest_bucket++; | 1561 | lowest_bucket++; |
1567 | #endif | 1562 | #endif |
1568 | } | 1563 | } |
@@ -1589,8 +1584,8 @@ delete_peer (struct PeerInfo *peer, unsigned int bucket) | |||
1589 | if (peer_pos == NULL) | 1584 | if (peer_pos == NULL) |
1590 | { | 1585 | { |
1591 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1586 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1592 | "%s:%s: Expected peer `%s' in bucket %d\n", my_short_id, | 1587 | "%s:%s: Expected peer `%s' in bucket %d\n", my_short_id, "DHT", |
1593 | "DHT", GNUNET_i2s (&peer->id), bucket); | 1588 | GNUNET_i2s (&peer->id), bucket); |
1594 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1589 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1595 | "%s:%s: Lowest bucket: %d, find_current_bucket: %d, peer resides in bucket: %d\n", | 1590 | "%s:%s: Lowest bucket: %d, find_current_bucket: %d, peer resides in bucket: %d\n", |
1596 | my_short_id, "DHT", lowest_bucket, | 1591 | my_short_id, "DHT", lowest_bucket, |
@@ -1677,8 +1672,7 @@ enable_next_bucket () | |||
1677 | while (pos != NULL) | 1672 | while (pos != NULL) |
1678 | { | 1673 | { |
1679 | if (find_bucket (&pos->id.hashPubKey) < lowest_bucket) | 1674 | if (find_bucket (&pos->id.hashPubKey) < lowest_bucket) |
1680 | GNUNET_CONTAINER_multihashmap_put (to_remove, &pos->id.hashPubKey, | 1675 | GNUNET_CONTAINER_multihashmap_put (to_remove, &pos->id.hashPubKey, pos, |
1681 | pos, | ||
1682 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 1676 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
1683 | pos = pos->next; | 1677 | pos = pos->next; |
1684 | } | 1678 | } |
@@ -1747,8 +1741,8 @@ find_closest_peer (const GNUNET_HashCode * hc) | |||
1747 | * @param msg_ctx the context of the message (hop count, bloom, etc.) | 1741 | * @param msg_ctx the context of the message (hop count, bloom, etc.) |
1748 | */ | 1742 | */ |
1749 | static void | 1743 | static void |
1750 | forward_message (const struct GNUNET_MessageHeader *msg, | 1744 | forward_message (const struct GNUNET_MessageHeader *msg, struct PeerInfo *peer, |
1751 | struct PeerInfo *peer, struct DHT_MessageContext *msg_ctx) | 1745 | struct DHT_MessageContext *msg_ctx) |
1752 | { | 1746 | { |
1753 | struct GNUNET_DHT_P2PRouteMessage *route_message; | 1747 | struct GNUNET_DHT_P2PRouteMessage *route_message; |
1754 | struct P2PPendingMessage *pending; | 1748 | struct P2PPendingMessage *pending; |
@@ -1758,8 +1752,8 @@ forward_message (const struct GNUNET_MessageHeader *msg, | |||
1758 | 1752 | ||
1759 | increment_stats (STAT_ROUTE_FORWARDS); | 1753 | increment_stats (STAT_ROUTE_FORWARDS); |
1760 | GNUNET_assert (peer != NULL); | 1754 | GNUNET_assert (peer != NULL); |
1761 | if ((msg_ctx->closest != GNUNET_YES) | 1755 | if ((msg_ctx->closest != GNUNET_YES) && |
1762 | && (peer == find_closest_peer (&msg_ctx->key))) | 1756 | (peer == find_closest_peer (&msg_ctx->key))) |
1763 | increment_stats (STAT_ROUTE_FORWARDS_CLOSEST); | 1757 | increment_stats (STAT_ROUTE_FORWARDS_CLOSEST); |
1764 | 1758 | ||
1765 | msize = | 1759 | msize = |
@@ -1782,8 +1776,7 @@ forward_message (const struct GNUNET_MessageHeader *msg, | |||
1782 | if (msg_ctx->bloom != NULL) | 1776 | if (msg_ctx->bloom != NULL) |
1783 | GNUNET_assert (GNUNET_OK == | 1777 | GNUNET_assert (GNUNET_OK == |
1784 | GNUNET_CONTAINER_bloomfilter_get_raw_data (msg_ctx->bloom, | 1778 | GNUNET_CONTAINER_bloomfilter_get_raw_data (msg_ctx->bloom, |
1785 | route_message-> | 1779 | route_message->bloomfilter, |
1786 | bloomfilter, | ||
1787 | DHT_BLOOM_SIZE)); | 1780 | DHT_BLOOM_SIZE)); |
1788 | memcpy (&route_message->key, &msg_ctx->key, sizeof (GNUNET_HashCode)); | 1781 | memcpy (&route_message->key, &msg_ctx->key, sizeof (GNUNET_HashCode)); |
1789 | memcpy (&route_message[1], msg, ntohs (msg->size)); | 1782 | memcpy (&route_message[1], msg, ntohs (msg->size)); |
@@ -1801,8 +1794,8 @@ forward_message (const struct GNUNET_MessageHeader *msg, | |||
1801 | } | 1794 | } |
1802 | #if DEBUG_DHT > 1 | 1795 | #if DEBUG_DHT > 1 |
1803 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1796 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1804 | "%s:%s Adding pending message size %d for peer %s\n", | 1797 | "%s:%s Adding pending message size %d for peer %s\n", my_short_id, |
1805 | my_short_id, "DHT", msize, GNUNET_i2s (&peer->id)); | 1798 | "DHT", msize, GNUNET_i2s (&peer->id)); |
1806 | #endif | 1799 | #endif |
1807 | peer->pending_count++; | 1800 | peer->pending_count++; |
1808 | increment_stats ("# pending messages scheduled"); | 1801 | increment_stats ("# pending messages scheduled"); |
@@ -1835,9 +1828,8 @@ periodic_ping_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1835 | 1828 | ||
1836 | memset (&msg_ctx, 0, sizeof (struct DHT_MessageContext)); | 1829 | memset (&msg_ctx, 0, sizeof (struct DHT_MessageContext)); |
1837 | #if DEBUG_PING | 1830 | #if DEBUG_PING |
1838 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1831 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "%s:%s Sending periodic ping to %s\n", |
1839 | "%s:%s Sending periodic ping to %s\n", my_short_id, "DHT", | 1832 | my_short_id, "DHT", GNUNET_i2s (&peer->id)); |
1840 | GNUNET_i2s (&peer->id)); | ||
1841 | #endif | 1833 | #endif |
1842 | forward_message (&ping_message, peer, &msg_ctx); | 1834 | forward_message (&ping_message, peer, &msg_ctx); |
1843 | peer->ping_task = | 1835 | peer->ping_task = |
@@ -1864,8 +1856,8 @@ schedule_ping_messages () | |||
1864 | { | 1856 | { |
1865 | if ((count < bucket_size) && (pos->ping_task == GNUNET_SCHEDULER_NO_TASK)) | 1857 | if ((count < bucket_size) && (pos->ping_task == GNUNET_SCHEDULER_NO_TASK)) |
1866 | GNUNET_SCHEDULER_add_now (&periodic_ping_task, pos); | 1858 | GNUNET_SCHEDULER_add_now (&periodic_ping_task, pos); |
1867 | else if ((count >= bucket_size) | 1859 | else if ((count >= bucket_size) && |
1868 | && (pos->ping_task != GNUNET_SCHEDULER_NO_TASK)) | 1860 | (pos->ping_task != GNUNET_SCHEDULER_NO_TASK)) |
1869 | { | 1861 | { |
1870 | GNUNET_SCHEDULER_cancel (pos->ping_task); | 1862 | GNUNET_SCHEDULER_cancel (pos->ping_task); |
1871 | pos->ping_task = GNUNET_SCHEDULER_NO_TASK; | 1863 | pos->ping_task = GNUNET_SCHEDULER_NO_TASK; |
@@ -1893,8 +1885,8 @@ process_pending_messages (struct ClientList *client) | |||
1893 | 1885 | ||
1894 | client->transmit_handle = | 1886 | client->transmit_handle = |
1895 | GNUNET_SERVER_notify_transmit_ready (client->client_handle, | 1887 | GNUNET_SERVER_notify_transmit_ready (client->client_handle, |
1896 | ntohs (client->pending_head-> | 1888 | ntohs (client->pending_head->msg-> |
1897 | msg->size), | 1889 | size), |
1898 | GNUNET_TIME_UNIT_FOREVER_REL, | 1890 | GNUNET_TIME_UNIT_FOREVER_REL, |
1899 | &send_generic_reply, client); | 1891 | &send_generic_reply, client); |
1900 | } | 1892 | } |
@@ -1930,8 +1922,8 @@ send_generic_reply (void *cls, size_t size, void *buf) | |||
1930 | while ((NULL != (reply = client->pending_head)) && | 1922 | while ((NULL != (reply = client->pending_head)) && |
1931 | (size >= off + (msize = ntohs (reply->msg->size)))) | 1923 | (size >= off + (msize = ntohs (reply->msg->size)))) |
1932 | { | 1924 | { |
1933 | GNUNET_CONTAINER_DLL_remove (client->pending_head, | 1925 | GNUNET_CONTAINER_DLL_remove (client->pending_head, client->pending_tail, |
1934 | client->pending_tail, reply); | 1926 | reply); |
1935 | memcpy (&cbuf[off], reply->msg, msize); | 1927 | memcpy (&cbuf[off], reply->msg, msize); |
1936 | GNUNET_free (reply); | 1928 | GNUNET_free (reply); |
1937 | off += msize; | 1929 | off += msize; |
@@ -1956,8 +1948,7 @@ static void | |||
1956 | add_pending_message (struct ClientList *client, | 1948 | add_pending_message (struct ClientList *client, |
1957 | struct PendingMessage *pending_message) | 1949 | struct PendingMessage *pending_message) |
1958 | { | 1950 | { |
1959 | GNUNET_CONTAINER_DLL_insert_after (client->pending_head, | 1951 | GNUNET_CONTAINER_DLL_insert_after (client->pending_head, client->pending_tail, |
1960 | client->pending_tail, | ||
1961 | client->pending_tail, pending_message); | 1952 | client->pending_tail, pending_message); |
1962 | process_pending_messages (client); | 1953 | process_pending_messages (client); |
1963 | } | 1954 | } |
@@ -1987,8 +1978,8 @@ send_reply_to_client (struct ClientList *client, | |||
1987 | unsigned int i; | 1978 | unsigned int i; |
1988 | #endif | 1979 | #endif |
1989 | #if DEBUG_DHT | 1980 | #if DEBUG_DHT |
1990 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1981 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s:%s': Sending reply to client.\n", |
1991 | "`%s:%s': Sending reply to client.\n", my_short_id, "DHT"); | 1982 | my_short_id, "DHT"); |
1992 | #endif | 1983 | #endif |
1993 | msize = ntohs (message->size); | 1984 | msize = ntohs (message->size); |
1994 | tsize = | 1985 | tsize = |
@@ -2049,14 +2040,13 @@ consider_peer (struct GNUNET_PeerIdentity *peer) | |||
2049 | 2040 | ||
2050 | if ((GNUNET_YES == | 2041 | if ((GNUNET_YES == |
2051 | GNUNET_CONTAINER_multihashmap_contains (all_known_peers, | 2042 | GNUNET_CONTAINER_multihashmap_contains (all_known_peers, |
2052 | &peer->hashPubKey)) | 2043 | &peer->hashPubKey)) || |
2053 | || (0 == | 2044 | (0 == memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity)))) |
2054 | memcmp (&my_identity, peer, sizeof (struct GNUNET_PeerIdentity)))) | ||
2055 | return GNUNET_NO; /* We already know this peer (are connected even!) */ | 2045 | return GNUNET_NO; /* We already know this peer (are connected even!) */ |
2056 | bucket = find_current_bucket (&peer->hashPubKey); | 2046 | bucket = find_current_bucket (&peer->hashPubKey); |
2057 | 2047 | ||
2058 | if ((k_buckets[bucket].peers_size < bucket_size) | 2048 | if ((k_buckets[bucket].peers_size < bucket_size) || |
2059 | || ((bucket == lowest_bucket) && (lowest_bucket > 0))) | 2049 | ((bucket == lowest_bucket) && (lowest_bucket > 0))) |
2060 | return GNUNET_YES; | 2050 | return GNUNET_YES; |
2061 | 2051 | ||
2062 | return GNUNET_NO; | 2052 | return GNUNET_NO; |
@@ -2083,8 +2073,8 @@ remove_forward_entry (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2083 | if (record->head == NULL) /* No more entries in DLL */ | 2073 | if (record->head == NULL) /* No more entries in DLL */ |
2084 | { | 2074 | { |
2085 | GNUNET_assert (GNUNET_YES == | 2075 | GNUNET_assert (GNUNET_YES == |
2086 | GNUNET_CONTAINER_multihashmap_remove | 2076 | GNUNET_CONTAINER_multihashmap_remove (forward_list.hashmap, |
2087 | (forward_list.hashmap, &record->key, record)); | 2077 | &record->key, record)); |
2088 | GNUNET_free (record); | 2078 | GNUNET_free (record); |
2089 | } | 2079 | } |
2090 | if (source_info->find_peers_responded != NULL) | 2080 | if (source_info->find_peers_responded != NULL) |
@@ -2127,10 +2117,10 @@ route_result_message (struct GNUNET_MessageHeader *msg, | |||
2127 | GNUNET_break_op (0); | 2117 | GNUNET_break_op (0); |
2128 | 2118 | ||
2129 | hello_msg = &msg[1]; | 2119 | hello_msg = &msg[1]; |
2130 | if ((ntohs (hello_msg->type) != GNUNET_MESSAGE_TYPE_HELLO) | 2120 | if ((ntohs (hello_msg->type) != GNUNET_MESSAGE_TYPE_HELLO) || |
2131 | || (GNUNET_SYSERR == | 2121 | (GNUNET_SYSERR == |
2132 | GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) | 2122 | GNUNET_HELLO_get_id ((const struct GNUNET_HELLO_Message *) hello_msg, |
2133 | hello_msg, &new_peer))) | 2123 | &new_peer))) |
2134 | { | 2124 | { |
2135 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 2125 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
2136 | "%s:%s Received non-HELLO message type in find peer result message!\n", | 2126 | "%s:%s Received non-HELLO message type in find peer result message!\n", |
@@ -2168,13 +2158,10 @@ route_result_message (struct GNUNET_MessageHeader *msg, | |||
2168 | #if DEBUG_DHT_ROUTING | 2158 | #if DEBUG_DHT_ROUTING |
2169 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) | 2159 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) |
2170 | { | 2160 | { |
2171 | dhtlog_handle->insert_route (NULL, | 2161 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_RESULT, |
2172 | msg_ctx->unique_id, | 2162 | msg_ctx->hop_count, GNUNET_SYSERR, |
2173 | DHTLOG_RESULT, | 2163 | &my_identity, &msg_ctx->key, msg_ctx->peer, |
2174 | msg_ctx->hop_count, | 2164 | NULL); |
2175 | GNUNET_SYSERR, | ||
2176 | &my_identity, | ||
2177 | &msg_ctx->key, msg_ctx->peer, NULL); | ||
2178 | } | 2165 | } |
2179 | #endif | 2166 | #endif |
2180 | if (msg_ctx->bloom != NULL) | 2167 | if (msg_ctx->bloom != NULL) |
@@ -2216,10 +2203,10 @@ route_result_message (struct GNUNET_MessageHeader *msg, | |||
2216 | #if DEBUG_DHT_ROUTING | 2203 | #if DEBUG_DHT_ROUTING |
2217 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) | 2204 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) |
2218 | { | 2205 | { |
2219 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, | 2206 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_RESULT, |
2220 | DHTLOG_RESULT, msg_ctx->hop_count, | 2207 | msg_ctx->hop_count, GNUNET_YES, |
2221 | GNUNET_YES, &my_identity, | 2208 | &my_identity, &msg_ctx->key, msg_ctx->peer, |
2222 | &msg_ctx->key, msg_ctx->peer, NULL); | 2209 | NULL); |
2223 | } | 2210 | } |
2224 | #endif | 2211 | #endif |
2225 | increment_stats (STAT_RESULTS_TO_CLIENT); | 2212 | increment_stats (STAT_RESULTS_TO_CLIENT); |
@@ -2268,12 +2255,10 @@ route_result_message (struct GNUNET_MessageHeader *msg, | |||
2268 | #if DEBUG_DHT_ROUTING | 2255 | #if DEBUG_DHT_ROUTING |
2269 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) | 2256 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) |
2270 | { | 2257 | { |
2271 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, | 2258 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_RESULT, |
2272 | DHTLOG_RESULT, | 2259 | msg_ctx->hop_count, GNUNET_NO, |
2273 | msg_ctx->hop_count, | 2260 | &my_identity, &msg_ctx->key, |
2274 | GNUNET_NO, &my_identity, | 2261 | msg_ctx->peer, &pos->source); |
2275 | &msg_ctx->key, msg_ctx->peer, | ||
2276 | &pos->source); | ||
2277 | } | 2262 | } |
2278 | #endif | 2263 | #endif |
2279 | forward_result_message (msg, peer_info, msg_ctx); | 2264 | forward_result_message (msg, peer_info, msg_ctx); |
@@ -2320,11 +2305,9 @@ route_result_message (struct GNUNET_MessageHeader *msg, | |||
2320 | * to stop iteration. | 2305 | * to stop iteration. |
2321 | */ | 2306 | */ |
2322 | static int | 2307 | static int |
2323 | datacache_get_iterator (void *cls, | 2308 | datacache_get_iterator (void *cls, struct GNUNET_TIME_Absolute exp, |
2324 | struct GNUNET_TIME_Absolute exp, | 2309 | const GNUNET_HashCode * key, size_t size, |
2325 | const GNUNET_HashCode * key, | 2310 | const char *data, enum GNUNET_BLOCK_Type type) |
2326 | size_t size, const char *data, | ||
2327 | enum GNUNET_BLOCK_Type type) | ||
2328 | { | 2311 | { |
2329 | struct DHT_MessageContext *msg_ctx = cls; | 2312 | struct DHT_MessageContext *msg_ctx = cls; |
2330 | struct DHT_MessageContext *new_msg_ctx; | 2313 | struct DHT_MessageContext *new_msg_ctx; |
@@ -2346,29 +2329,25 @@ datacache_get_iterator (void *cls, | |||
2346 | 2329 | ||
2347 | put_entry = (const struct DHTPutEntry *) data; | 2330 | put_entry = (const struct DHTPutEntry *) data; |
2348 | 2331 | ||
2349 | if (size != sizeof (struct DHTPutEntry) + | 2332 | if (size != |
2350 | put_entry->data_size + | 2333 | sizeof (struct DHTPutEntry) + put_entry->data_size + |
2351 | (put_entry->path_length * sizeof (struct GNUNET_PeerIdentity))) | 2334 | (put_entry->path_length * sizeof (struct GNUNET_PeerIdentity))) |
2352 | { | 2335 | { |
2353 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 2336 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
2354 | "Path + data size doesn't add up for data inserted into datacache!\nData size %d, path length %d, expected %d, got %d\n", | 2337 | "Path + data size doesn't add up for data inserted into datacache!\nData size %d, path length %d, expected %d, got %d\n", |
2355 | put_entry->data_size, put_entry->path_length, | 2338 | put_entry->data_size, put_entry->path_length, |
2356 | sizeof (struct DHTPutEntry) + put_entry->data_size | 2339 | sizeof (struct DHTPutEntry) + put_entry->data_size + |
2357 | + | ||
2358 | (put_entry->path_length * sizeof (struct GNUNET_PeerIdentity)), | 2340 | (put_entry->path_length * sizeof (struct GNUNET_PeerIdentity)), |
2359 | size); | 2341 | size); |
2360 | msg_ctx->do_forward = GNUNET_NO; | 2342 | msg_ctx->do_forward = GNUNET_NO; |
2361 | return GNUNET_OK; | 2343 | return GNUNET_OK; |
2362 | } | 2344 | } |
2363 | 2345 | ||
2364 | eval = GNUNET_BLOCK_evaluate (block_context, | 2346 | eval = |
2365 | type, | 2347 | GNUNET_BLOCK_evaluate (block_context, type, key, &msg_ctx->reply_bf, |
2366 | key, | 2348 | msg_ctx->reply_bf_mutator, msg_ctx->xquery, |
2367 | &msg_ctx->reply_bf, | 2349 | msg_ctx->xquery_size, &put_entry[1], |
2368 | msg_ctx->reply_bf_mutator, | 2350 | put_entry->data_size); |
2369 | msg_ctx->xquery, | ||
2370 | msg_ctx->xquery_size, &put_entry[1], | ||
2371 | put_entry->data_size); | ||
2372 | 2351 | ||
2373 | switch (eval) | 2352 | switch (eval) |
2374 | { | 2353 | { |
@@ -2437,14 +2416,14 @@ datacache_get_iterator (void *cls, | |||
2437 | break; | 2416 | break; |
2438 | case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE: | 2417 | case GNUNET_BLOCK_EVALUATION_OK_DUPLICATE: |
2439 | #if DEBUG_DHT | 2418 | #if DEBUG_DHT |
2440 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2419 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s:%s': Duplicate block error\n", |
2441 | "`%s:%s': Duplicate block error\n", my_short_id, "DHT"); | 2420 | my_short_id, "DHT"); |
2442 | #endif | 2421 | #endif |
2443 | break; | 2422 | break; |
2444 | case GNUNET_BLOCK_EVALUATION_RESULT_INVALID: | 2423 | case GNUNET_BLOCK_EVALUATION_RESULT_INVALID: |
2445 | #if DEBUG_DHT | 2424 | #if DEBUG_DHT |
2446 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 2425 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "`%s:%s': Invalid request error\n", |
2447 | "`%s:%s': Invalid request error\n", my_short_id, "DHT"); | 2426 | my_short_id, "DHT"); |
2448 | #endif | 2427 | #endif |
2449 | break; | 2428 | break; |
2450 | case GNUNET_BLOCK_EVALUATION_REQUEST_VALID: | 2429 | case GNUNET_BLOCK_EVALUATION_REQUEST_VALID: |
@@ -2478,9 +2457,8 @@ datacache_get_iterator (void *cls, | |||
2478 | * @param msg the message to be routed | 2457 | * @param msg the message to be routed |
2479 | * @param msg_ctx the context containing all pertinent information about the message | 2458 | * @param msg_ctx the context containing all pertinent information about the message |
2480 | */ | 2459 | */ |
2481 | static void | 2460 | static void route_message (const struct GNUNET_MessageHeader *msg, |
2482 | route_message (const struct GNUNET_MessageHeader *msg, | 2461 | struct DHT_MessageContext *msg_ctx); |
2483 | struct DHT_MessageContext *msg_ctx); | ||
2484 | 2462 | ||
2485 | 2463 | ||
2486 | /** | 2464 | /** |
@@ -2535,17 +2513,16 @@ handle_dht_get (const struct GNUNET_MessageHeader *msg, | |||
2535 | } | 2513 | } |
2536 | else | 2514 | else |
2537 | { | 2515 | { |
2538 | msg_ctx->reply_bf = GNUNET_CONTAINER_bloomfilter_init (end, | 2516 | msg_ctx->reply_bf = |
2539 | bf_size, | 2517 | GNUNET_CONTAINER_bloomfilter_init (end, bf_size, |
2540 | GNUNET_DHT_GET_BLOOMFILTER_K); | 2518 | GNUNET_DHT_GET_BLOOMFILTER_K); |
2541 | } | 2519 | } |
2542 | type = (enum GNUNET_BLOCK_Type) ntohl (get_msg->type); | 2520 | type = (enum GNUNET_BLOCK_Type) ntohl (get_msg->type); |
2543 | #if DEBUG_DHT | 2521 | #if DEBUG_DHT |
2544 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2522 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2545 | "`%s:%s': Received `%s' request, message type %u, key %s, uid %llu\n", | 2523 | "`%s:%s': Received `%s' request, message type %u, key %s, uid %llu\n", |
2546 | my_short_id, | 2524 | my_short_id, "DHT", "GET", type, GNUNET_h2s (&msg_ctx->key), |
2547 | "DHT", "GET", | 2525 | msg_ctx->unique_id); |
2548 | type, GNUNET_h2s (&msg_ctx->key), msg_ctx->unique_id); | ||
2549 | #endif | 2526 | #endif |
2550 | increment_stats (STAT_GETS); | 2527 | increment_stats (STAT_GETS); |
2551 | results = 0; | 2528 | results = 0; |
@@ -2558,10 +2535,9 @@ handle_dht_get (const struct GNUNET_MessageHeader *msg, | |||
2558 | #endif | 2535 | #endif |
2559 | msg_ctx->do_forward = GNUNET_YES; | 2536 | msg_ctx->do_forward = GNUNET_YES; |
2560 | if (datacache != NULL) | 2537 | if (datacache != NULL) |
2561 | results | 2538 | results = |
2562 | = GNUNET_DATACACHE_get (datacache, | 2539 | GNUNET_DATACACHE_get (datacache, &msg_ctx->key, type, |
2563 | &msg_ctx->key, type, | 2540 | &datacache_get_iterator, msg_ctx); |
2564 | &datacache_get_iterator, msg_ctx); | ||
2565 | #if DEBUG_DHT | 2541 | #if DEBUG_DHT |
2566 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2542 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2567 | "`%s:%s': Found %d results for `%s' request uid %llu\n", | 2543 | "`%s:%s': Found %d results for `%s' request uid %llu\n", |
@@ -2573,30 +2549,25 @@ handle_dht_get (const struct GNUNET_MessageHeader *msg, | |||
2573 | if ((debug_routes) && (dhtlog_handle != NULL)) | 2549 | if ((debug_routes) && (dhtlog_handle != NULL)) |
2574 | { | 2550 | { |
2575 | dhtlog_handle->insert_query (NULL, msg_ctx->unique_id, DHTLOG_GET, | 2551 | dhtlog_handle->insert_query (NULL, msg_ctx->unique_id, DHTLOG_GET, |
2576 | msg_ctx->hop_count, GNUNET_YES, | 2552 | msg_ctx->hop_count, GNUNET_YES, &my_identity, |
2577 | &my_identity, &msg_ctx->key); | 2553 | &msg_ctx->key); |
2578 | } | 2554 | } |
2579 | 2555 | ||
2580 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) | 2556 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) |
2581 | { | 2557 | { |
2582 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, | 2558 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, |
2583 | msg_ctx->hop_count, GNUNET_YES, | 2559 | msg_ctx->hop_count, GNUNET_YES, &my_identity, |
2584 | &my_identity, &msg_ctx->key, | 2560 | &msg_ctx->key, msg_ctx->peer, NULL); |
2585 | msg_ctx->peer, NULL); | ||
2586 | } | 2561 | } |
2587 | #endif | 2562 | #endif |
2588 | } | 2563 | } |
2589 | else | 2564 | else |
2590 | { | 2565 | { |
2591 | /* check query valid */ | 2566 | /* check query valid */ |
2592 | if (GNUNET_BLOCK_EVALUATION_REQUEST_INVALID | 2567 | if (GNUNET_BLOCK_EVALUATION_REQUEST_INVALID == |
2593 | == GNUNET_BLOCK_evaluate (block_context, | 2568 | GNUNET_BLOCK_evaluate (block_context, type, &msg_ctx->key, |
2594 | type, | 2569 | &msg_ctx->reply_bf, msg_ctx->reply_bf_mutator, |
2595 | &msg_ctx->key, | 2570 | msg_ctx->xquery, msg_ctx->xquery_size, NULL, 0)) |
2596 | &msg_ctx->reply_bf, | ||
2597 | msg_ctx->reply_bf_mutator, | ||
2598 | msg_ctx->xquery, | ||
2599 | msg_ctx->xquery_size, NULL, 0)) | ||
2600 | { | 2571 | { |
2601 | GNUNET_break_op (0); | 2572 | GNUNET_break_op (0); |
2602 | msg_ctx->do_forward = GNUNET_NO; | 2573 | msg_ctx->do_forward = GNUNET_NO; |
@@ -2609,8 +2580,8 @@ handle_dht_get (const struct GNUNET_MessageHeader *msg, | |||
2609 | if ((debug_routes) && (dhtlog_handle != NULL)) | 2580 | if ((debug_routes) && (dhtlog_handle != NULL)) |
2610 | { | 2581 | { |
2611 | dhtlog_handle->insert_query (NULL, msg_ctx->unique_id, DHTLOG_GET, | 2582 | dhtlog_handle->insert_query (NULL, msg_ctx->unique_id, DHTLOG_GET, |
2612 | msg_ctx->hop_count, GNUNET_NO, | 2583 | msg_ctx->hop_count, GNUNET_NO, &my_identity, |
2613 | &my_identity, &msg_ctx->key); | 2584 | &msg_ctx->key); |
2614 | } | 2585 | } |
2615 | #endif | 2586 | #endif |
2616 | } | 2587 | } |
@@ -2667,11 +2638,10 @@ handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg, | |||
2667 | ntohs (find_msg->size) - sizeof (struct GNUNET_DHT_FindPeerMessage); | 2638 | ntohs (find_msg->size) - sizeof (struct GNUNET_DHT_FindPeerMessage); |
2668 | other_hello = GNUNET_malloc (other_hello_size); | 2639 | other_hello = GNUNET_malloc (other_hello_size); |
2669 | memcpy (other_hello, &find_peer_message[1], other_hello_size); | 2640 | memcpy (other_hello, &find_peer_message[1], other_hello_size); |
2670 | if ((GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) other_hello) == | 2641 | if ((GNUNET_HELLO_size ((struct GNUNET_HELLO_Message *) other_hello) == 0) |
2671 | 0) | ||
2672 | || (GNUNET_OK != | 2642 | || (GNUNET_OK != |
2673 | GNUNET_HELLO_get_id ((struct GNUNET_HELLO_Message *) | 2643 | GNUNET_HELLO_get_id ((struct GNUNET_HELLO_Message *) other_hello, |
2674 | other_hello, &peer_id))) | 2644 | &peer_id))) |
2675 | { | 2645 | { |
2676 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 2646 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
2677 | "Received invalid HELLO message in find peer request!\n"); | 2647 | "Received invalid HELLO message in find peer request!\n"); |
@@ -2802,8 +2772,8 @@ handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg, | |||
2802 | memcpy (&find_peer_result[1], my_hello, hello_size); | 2772 | memcpy (&find_peer_result[1], my_hello, hello_size); |
2803 | #if DEBUG_DHT | 2773 | #if DEBUG_DHT |
2804 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2774 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2805 | "`%s': Sending hello size %d to requesting peer.\n", | 2775 | "`%s': Sending hello size %d to requesting peer.\n", "DHT", |
2806 | "DHT", hello_size); | 2776 | hello_size); |
2807 | #endif | 2777 | #endif |
2808 | 2778 | ||
2809 | new_msg_ctx = GNUNET_malloc (sizeof (struct DHT_MessageContext)); | 2779 | new_msg_ctx = GNUNET_malloc (sizeof (struct DHT_MessageContext)); |
@@ -2829,8 +2799,8 @@ handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg, | |||
2829 | if ((debug_routes) && (dhtlog_handle != NULL)) | 2799 | if ((debug_routes) && (dhtlog_handle != NULL)) |
2830 | { | 2800 | { |
2831 | dhtlog_handle->insert_query (NULL, msg_ctx->unique_id, DHTLOG_FIND_PEER, | 2801 | dhtlog_handle->insert_query (NULL, msg_ctx->unique_id, DHTLOG_FIND_PEER, |
2832 | msg_ctx->hop_count, GNUNET_YES, | 2802 | msg_ctx->hop_count, GNUNET_YES, &my_identity, |
2833 | &my_identity, &msg_ctx->key); | 2803 | &msg_ctx->key); |
2834 | } | 2804 | } |
2835 | #endif | 2805 | #endif |
2836 | GNUNET_free_non_null (other_hello); | 2806 | GNUNET_free_non_null (other_hello); |
@@ -2845,8 +2815,8 @@ handle_dht_find_peer (const struct GNUNET_MessageHeader *find_msg, | |||
2845 | * @param cls closure (a struct RepublishContext) | 2815 | * @param cls closure (a struct RepublishContext) |
2846 | * @param tc runtime context for this task | 2816 | * @param tc runtime context for this task |
2847 | */ | 2817 | */ |
2848 | static void | 2818 | static void republish_content (void *cls, |
2849 | republish_content (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 2819 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
2850 | 2820 | ||
2851 | /** | 2821 | /** |
2852 | * Server handler for initiating local dht put requests | 2822 | * Server handler for initiating local dht put requests |
@@ -2881,8 +2851,8 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg, | |||
2881 | /** Log routes that die due to high load! */ | 2851 | /** Log routes that die due to high load! */ |
2882 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, | 2852 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, |
2883 | msg_ctx->hop_count, GNUNET_SYSERR, | 2853 | msg_ctx->hop_count, GNUNET_SYSERR, |
2884 | &my_identity, &msg_ctx->key, | 2854 | &my_identity, &msg_ctx->key, msg_ctx->peer, |
2885 | msg_ctx->peer, NULL); | 2855 | NULL); |
2886 | } | 2856 | } |
2887 | #endif | 2857 | #endif |
2888 | return; | 2858 | return; |
@@ -2900,8 +2870,8 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg, | |||
2900 | { | 2870 | { |
2901 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, | 2871 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, |
2902 | msg_ctx->hop_count, GNUNET_SYSERR, | 2872 | msg_ctx->hop_count, GNUNET_SYSERR, |
2903 | &my_identity, &msg_ctx->key, | 2873 | &my_identity, &msg_ctx->key, msg_ctx->peer, |
2904 | msg_ctx->peer, NULL); | 2874 | NULL); |
2905 | } | 2875 | } |
2906 | #endif | 2876 | #endif |
2907 | /* invalid reply */ | 2877 | /* invalid reply */ |
@@ -2916,8 +2886,8 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg, | |||
2916 | { | 2886 | { |
2917 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, | 2887 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, |
2918 | msg_ctx->hop_count, GNUNET_SYSERR, | 2888 | msg_ctx->hop_count, GNUNET_SYSERR, |
2919 | &my_identity, &msg_ctx->key, | 2889 | &my_identity, &msg_ctx->key, msg_ctx->peer, |
2920 | msg_ctx->peer, NULL); | 2890 | NULL); |
2921 | } | 2891 | } |
2922 | #endif | 2892 | #endif |
2923 | /* invalid wrapper: key mismatch! */ | 2893 | /* invalid wrapper: key mismatch! */ |
@@ -2938,8 +2908,8 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg, | |||
2938 | if ((debug_routes) && (dhtlog_handle != NULL)) | 2908 | if ((debug_routes) && (dhtlog_handle != NULL)) |
2939 | { | 2909 | { |
2940 | dhtlog_handle->insert_query (NULL, msg_ctx->unique_id, DHTLOG_PUT, | 2910 | dhtlog_handle->insert_query (NULL, msg_ctx->unique_id, DHTLOG_PUT, |
2941 | msg_ctx->hop_count, GNUNET_NO, | 2911 | msg_ctx->hop_count, GNUNET_NO, &my_identity, |
2942 | &my_identity, &msg_ctx->key); | 2912 | &msg_ctx->key); |
2943 | } | 2913 | } |
2944 | } | 2914 | } |
2945 | #endif | 2915 | #endif |
@@ -2961,16 +2931,15 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg, | |||
2961 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) | 2931 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) |
2962 | { | 2932 | { |
2963 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, | 2933 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, |
2964 | msg_ctx->hop_count, GNUNET_YES, | 2934 | msg_ctx->hop_count, GNUNET_YES, &my_identity, |
2965 | &my_identity, &msg_ctx->key, msg_ctx->peer, | 2935 | &msg_ctx->key, msg_ctx->peer, NULL); |
2966 | NULL); | ||
2967 | } | 2936 | } |
2968 | 2937 | ||
2969 | if ((debug_routes) && (dhtlog_handle != NULL)) | 2938 | if ((debug_routes) && (dhtlog_handle != NULL)) |
2970 | { | 2939 | { |
2971 | dhtlog_handle->insert_query (NULL, msg_ctx->unique_id, DHTLOG_PUT, | 2940 | dhtlog_handle->insert_query (NULL, msg_ctx->unique_id, DHTLOG_PUT, |
2972 | msg_ctx->hop_count, GNUNET_YES, | 2941 | msg_ctx->hop_count, GNUNET_YES, &my_identity, |
2973 | &my_identity, &msg_ctx->key); | 2942 | &msg_ctx->key); |
2974 | } | 2943 | } |
2975 | #endif | 2944 | #endif |
2976 | 2945 | ||
@@ -2995,10 +2964,10 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg, | |||
2995 | msg_ctx->path_history_len * sizeof (struct GNUNET_PeerIdentity)); | 2964 | msg_ctx->path_history_len * sizeof (struct GNUNET_PeerIdentity)); |
2996 | } | 2965 | } |
2997 | 2966 | ||
2998 | ret = GNUNET_DATACACHE_put (datacache, &msg_ctx->key, put_size, | 2967 | ret = |
2999 | (const char *) put_entry, put_type, | 2968 | GNUNET_DATACACHE_put (datacache, &msg_ctx->key, put_size, |
3000 | GNUNET_TIME_absolute_ntoh | 2969 | (const char *) put_entry, put_type, |
3001 | (put_msg->expiration)); | 2970 | GNUNET_TIME_absolute_ntoh (put_msg->expiration)); |
3002 | GNUNET_free (put_entry); | 2971 | GNUNET_free (put_entry); |
3003 | 2972 | ||
3004 | if ((ret == GNUNET_YES) && (do_republish == GNUNET_YES)) | 2973 | if ((ret == GNUNET_YES) && (do_republish == GNUNET_YES)) |
@@ -3006,8 +2975,8 @@ handle_dht_put (const struct GNUNET_MessageHeader *msg, | |||
3006 | put_context = GNUNET_malloc (sizeof (struct RepublishContext)); | 2975 | put_context = GNUNET_malloc (sizeof (struct RepublishContext)); |
3007 | memcpy (&put_context->key, &msg_ctx->key, sizeof (GNUNET_HashCode)); | 2976 | memcpy (&put_context->key, &msg_ctx->key, sizeof (GNUNET_HashCode)); |
3008 | put_context->type = put_type; | 2977 | put_context->type = put_type; |
3009 | GNUNET_SCHEDULER_add_delayed (dht_republish_frequency, | 2978 | GNUNET_SCHEDULER_add_delayed (dht_republish_frequency, &republish_content, |
3010 | &republish_content, put_context); | 2979 | put_context); |
3011 | } | 2980 | } |
3012 | } | 2981 | } |
3013 | else | 2982 | else |
@@ -3102,17 +3071,16 @@ get_forward_count (unsigned int hop_count, size_t target_replication) | |||
3102 | if (GNUNET_YES == paper_forwarding) | 3071 | if (GNUNET_YES == paper_forwarding) |
3103 | { | 3072 | { |
3104 | /* FIXME: re-run replication trials with this formula */ | 3073 | /* FIXME: re-run replication trials with this formula */ |
3105 | target_value = 1 + (target_replication - 1.0) / (diameter | 3074 | target_value = |
3106 | + | 3075 | 1 + (target_replication - 1.0) / (diameter + |
3107 | ((float) | 3076 | ((float) (target_replication - 1.0) * |
3108 | (target_replication - | 3077 | hop_count)); |
3109 | 1.0) * hop_count)); | ||
3110 | /* Set forward count to floor of target_value */ | 3078 | /* Set forward count to floor of target_value */ |
3111 | forward_count = (unsigned int) target_value; | 3079 | forward_count = (unsigned int) target_value; |
3112 | /* Subtract forward_count (floor) from target_value (yields value between 0 and 1) */ | 3080 | /* Subtract forward_count (floor) from target_value (yields value between 0 and 1) */ |
3113 | target_value = target_value - forward_count; | 3081 | target_value = target_value - forward_count; |
3114 | random_value = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, | 3082 | random_value = |
3115 | UINT32_MAX); | 3083 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, UINT32_MAX); |
3116 | 3084 | ||
3117 | if (random_value < (target_value * UINT32_MAX)) | 3085 | if (random_value < (target_value * UINT32_MAX)) |
3118 | forward_count += 1; | 3086 | forward_count += 1; |
@@ -3121,10 +3089,9 @@ get_forward_count (unsigned int hop_count, size_t target_replication) | |||
3121 | { | 3089 | { |
3122 | random_value = 0; | 3090 | random_value = 0; |
3123 | forward_count = 1; | 3091 | forward_count = 1; |
3124 | target_value = target_replication / (diameter | 3092 | target_value = |
3125 | + | 3093 | target_replication / (diameter + |
3126 | ((float) target_replication * | 3094 | ((float) target_replication * hop_count)); |
3127 | hop_count)); | ||
3128 | if (target_value > 1) | 3095 | if (target_value > 1) |
3129 | { | 3096 | { |
3130 | /* Set forward count to floor of target_value */ | 3097 | /* Set forward count to floor of target_value */ |
@@ -3133,8 +3100,8 @@ get_forward_count (unsigned int hop_count, size_t target_replication) | |||
3133 | target_value = target_value - forward_count; | 3100 | target_value = target_value - forward_count; |
3134 | } | 3101 | } |
3135 | else | 3102 | else |
3136 | random_value = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, | 3103 | random_value = |
3137 | UINT32_MAX); | 3104 | GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_STRONG, UINT32_MAX); |
3138 | 3105 | ||
3139 | if (random_value < (target_value * UINT32_MAX)) | 3106 | if (random_value < (target_value * UINT32_MAX)) |
3140 | forward_count += 1; | 3107 | forward_count += 1; |
@@ -3176,9 +3143,9 @@ am_closest_peer (const GNUNET_HashCode * target, | |||
3176 | count = 0; | 3143 | count = 0; |
3177 | while ((pos != NULL) && (count < bucket_size)) | 3144 | while ((pos != NULL) && (count < bucket_size)) |
3178 | { | 3145 | { |
3179 | if ((bloom != NULL) | 3146 | if ((bloom != NULL) && |
3180 | && (GNUNET_YES == | 3147 | (GNUNET_YES == |
3181 | GNUNET_CONTAINER_bloomfilter_test (bloom, &pos->id.hashPubKey))) | 3148 | GNUNET_CONTAINER_bloomfilter_test (bloom, &pos->id.hashPubKey))) |
3182 | { | 3149 | { |
3183 | pos = pos->next; | 3150 | pos = pos->next; |
3184 | continue; /* Skip already checked entries */ | 3151 | continue; /* Skip already checked entries */ |
@@ -3216,8 +3183,8 @@ am_closest_peer (const GNUNET_HashCode * target, | |||
3216 | * | 3183 | * |
3217 | */ | 3184 | */ |
3218 | static unsigned long long | 3185 | static unsigned long long |
3219 | converge_distance (const GNUNET_HashCode * target, | 3186 | converge_distance (const GNUNET_HashCode * target, struct PeerInfo *peer, |
3220 | struct PeerInfo *peer, unsigned int hops) | 3187 | unsigned int hops) |
3221 | { | 3188 | { |
3222 | unsigned long long ret; | 3189 | unsigned long long ret; |
3223 | unsigned int other_matching_bits; | 3190 | unsigned int other_matching_bits; |
@@ -3298,8 +3265,8 @@ converge_distance (const GNUNET_HashCode * target, | |||
3298 | errno = 0; | 3265 | errno = 0; |
3299 | feclearexcept (FE_ALL_EXCEPT); | 3266 | feclearexcept (FE_ALL_EXCEPT); |
3300 | ret = (unsigned long long) pow (other_matching_bits, calc_value); | 3267 | ret = (unsigned long long) pow (other_matching_bits, calc_value); |
3301 | if ((errno != 0) || fetestexcept (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | | 3268 | if ((errno != 0) || |
3302 | FE_UNDERFLOW)) | 3269 | fetestexcept (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW)) |
3303 | { | 3270 | { |
3304 | if (0 != fetestexcept (FE_OVERFLOW)) | 3271 | if (0 != fetestexcept (FE_OVERFLOW)) |
3305 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "FE_OVERFLOW\n"); | 3272 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "FE_OVERFLOW\n"); |
@@ -3542,10 +3509,10 @@ select_peer (const GNUNET_HashCode * target, | |||
3542 | break; /* overflow case */ | 3509 | break; /* overflow case */ |
3543 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3510 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3544 | "Choose %d matching bits (%d bits match me) (%.2f percent) converge ret %llu\n", | 3511 | "Choose %d matching bits (%d bits match me) (%.2f percent) converge ret %llu\n", |
3545 | GNUNET_CRYPTO_hash_matching_bits (&sorted_closest[i]->id. | 3512 | GNUNET_CRYPTO_hash_matching_bits (&sorted_closest[i]-> |
3546 | hashPubKey, target), | 3513 | id.hashPubKey, target), |
3547 | GNUNET_CRYPTO_hash_matching_bits (&sorted_closest[i]->id. | 3514 | GNUNET_CRYPTO_hash_matching_bits (&sorted_closest[i]-> |
3548 | hashPubKey, | 3515 | id.hashPubKey, |
3549 | &my_identity.hashPubKey), | 3516 | &my_identity.hashPubKey), |
3550 | (temp_converge_distance / (double) total_distance) * 100, | 3517 | (temp_converge_distance / (double) total_distance) * 100, |
3551 | temp_converge_distance); | 3518 | temp_converge_distance); |
@@ -3576,8 +3543,8 @@ select_peer (const GNUNET_HashCode * target, | |||
3576 | target), | 3543 | target), |
3577 | GNUNET_CRYPTO_hash_matching_bits (&pos->id.hashPubKey, | 3544 | GNUNET_CRYPTO_hash_matching_bits (&pos->id.hashPubKey, |
3578 | &my_identity.hashPubKey), | 3545 | &my_identity.hashPubKey), |
3579 | (temp_converge_distance / (double) total_distance) * | 3546 | (temp_converge_distance / (double) total_distance) * 100, |
3580 | 100, temp_converge_distance); | 3547 | temp_converge_distance); |
3581 | pos = pos->next; | 3548 | pos = pos->next; |
3582 | count++; | 3549 | count++; |
3583 | } | 3550 | } |
@@ -3608,8 +3575,8 @@ select_peer (const GNUNET_HashCode * target, | |||
3608 | target), | 3575 | target), |
3609 | GNUNET_CRYPTO_hash_matching_bits (&pos->id.hashPubKey, | 3576 | GNUNET_CRYPTO_hash_matching_bits (&pos->id.hashPubKey, |
3610 | &my_identity.hashPubKey), | 3577 | &my_identity.hashPubKey), |
3611 | (temp_converge_distance / (double) total_distance) * | 3578 | (temp_converge_distance / (double) total_distance) * 100, |
3612 | 100, temp_converge_distance); | 3579 | temp_converge_distance); |
3613 | pos = pos->next; | 3580 | pos = pos->next; |
3614 | count++; | 3581 | count++; |
3615 | } | 3582 | } |
@@ -3750,8 +3717,9 @@ cache_response (struct DHT_MessageContext *msg_ctx) | |||
3750 | if (record->head == NULL) /* No more entries in DLL */ | 3717 | if (record->head == NULL) /* No more entries in DLL */ |
3751 | { | 3718 | { |
3752 | GNUNET_assert (GNUNET_YES == | 3719 | GNUNET_assert (GNUNET_YES == |
3753 | GNUNET_CONTAINER_multihashmap_remove | 3720 | GNUNET_CONTAINER_multihashmap_remove (forward_list.hashmap, |
3754 | (forward_list.hashmap, &record->key, record)); | 3721 | &record->key, |
3722 | record)); | ||
3755 | GNUNET_free (record); | 3723 | GNUNET_free (record); |
3756 | } | 3724 | } |
3757 | if (source_info->delete_task != GNUNET_SCHEDULER_NO_TASK) | 3725 | if (source_info->delete_task != GNUNET_SCHEDULER_NO_TASK) |
@@ -3864,8 +3832,8 @@ route_message (const struct GNUNET_MessageHeader *msg, | |||
3864 | { | 3832 | { |
3865 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, | 3833 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, |
3866 | msg_ctx->hop_count, GNUNET_SYSERR, | 3834 | msg_ctx->hop_count, GNUNET_SYSERR, |
3867 | &my_identity, &msg_ctx->key, | 3835 | &my_identity, &msg_ctx->key, msg_ctx->peer, |
3868 | msg_ctx->peer, NULL); | 3836 | NULL); |
3869 | } | 3837 | } |
3870 | #endif | 3838 | #endif |
3871 | if (msg_ctx->bloom != NULL) | 3839 | if (msg_ctx->bloom != NULL) |
@@ -3887,8 +3855,8 @@ route_message (const struct GNUNET_MessageHeader *msg, | |||
3887 | msg_ctx->bloom = | 3855 | msg_ctx->bloom = |
3888 | GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); | 3856 | GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); |
3889 | 3857 | ||
3890 | if ((stop_on_closest == GNUNET_YES) && (msg_ctx->closest == GNUNET_YES) | 3858 | if ((stop_on_closest == GNUNET_YES) && (msg_ctx->closest == GNUNET_YES) && |
3891 | && (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_DHT_PUT)) | 3859 | (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_DHT_PUT)) |
3892 | target_forward_count = 0; | 3860 | target_forward_count = 0; |
3893 | 3861 | ||
3894 | /** | 3862 | /** |
@@ -3906,9 +3874,9 @@ route_message (const struct GNUNET_MessageHeader *msg, | |||
3906 | * testing driver) we will ignore this restriction for FIND_PEER messages so that | 3874 | * testing driver) we will ignore this restriction for FIND_PEER messages so that |
3907 | * routing tables still get constructed. | 3875 | * routing tables still get constructed. |
3908 | */ | 3876 | */ |
3909 | if ((GNUNET_YES == strict_kademlia) && (msg_ctx->closest == GNUNET_YES) | 3877 | if ((GNUNET_YES == strict_kademlia) && (msg_ctx->closest == GNUNET_YES) && |
3910 | && (msg_ctx->hop_count > 0) | 3878 | (msg_ctx->hop_count > 0) && |
3911 | && (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_DHT_FIND_PEER)) | 3879 | (ntohs (msg->type) != GNUNET_MESSAGE_TYPE_DHT_FIND_PEER)) |
3912 | target_forward_count = 0; | 3880 | target_forward_count = 0; |
3913 | 3881 | ||
3914 | 3882 | ||
@@ -3942,8 +3910,7 @@ route_message (const struct GNUNET_MessageHeader *msg, | |||
3942 | GNUNET_TIME_absolute_get ().abs_value); | 3910 | GNUNET_TIME_absolute_get ().abs_value); |
3943 | recent_req->bloom = | 3911 | recent_req->bloom = |
3944 | GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); | 3912 | GNUNET_CONTAINER_bloomfilter_init (NULL, DHT_BLOOM_SIZE, DHT_BLOOM_K); |
3945 | GNUNET_CONTAINER_multihashmap_put (recent.hashmap, &unique_hash, | 3913 | GNUNET_CONTAINER_multihashmap_put (recent.hashmap, &unique_hash, recent_req, |
3946 | recent_req, | ||
3947 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 3914 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
3948 | } | 3915 | } |
3949 | 3916 | ||
@@ -3988,8 +3955,7 @@ route_message (const struct GNUNET_MessageHeader *msg, | |||
3988 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3955 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3989 | "`%s:%s': Forwarding request key %s uid %llu to peer %s (closest %s, bits %d, distance %u)\n", | 3956 | "`%s:%s': Forwarding request key %s uid %llu to peer %s (closest %s, bits %d, distance %u)\n", |
3990 | my_short_id, "DHT", GNUNET_h2s (&msg_ctx->key), | 3957 | my_short_id, "DHT", GNUNET_h2s (&msg_ctx->key), |
3991 | msg_ctx->unique_id, GNUNET_i2s (&selected->id), | 3958 | msg_ctx->unique_id, GNUNET_i2s (&selected->id), nearest_buf, |
3992 | nearest_buf, | ||
3993 | GNUNET_CRYPTO_hash_matching_bits (&nearest->id.hashPubKey, | 3959 | GNUNET_CRYPTO_hash_matching_bits (&nearest->id.hashPubKey, |
3994 | msg_ctx->key), | 3960 | msg_ctx->key), |
3995 | distance (&nearest->id.hashPubKey, msg_ctx->key)); | 3961 | distance (&nearest->id.hashPubKey, msg_ctx->key)); |
@@ -3998,10 +3964,9 @@ route_message (const struct GNUNET_MessageHeader *msg, | |||
3998 | #if DEBUG_DHT_ROUTING | 3964 | #if DEBUG_DHT_ROUTING |
3999 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) | 3965 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) |
4000 | { | 3966 | { |
4001 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, | 3967 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, |
4002 | DHTLOG_ROUTE, msg_ctx->hop_count, | 3968 | msg_ctx->hop_count, GNUNET_NO, |
4003 | GNUNET_NO, &my_identity, | 3969 | &my_identity, &msg_ctx->key, msg_ctx->peer, |
4004 | &msg_ctx->key, msg_ctx->peer, | ||
4005 | &selected->id); | 3970 | &selected->id); |
4006 | } | 3971 | } |
4007 | #endif | 3972 | #endif |
@@ -4026,9 +3991,8 @@ route_message (const struct GNUNET_MessageHeader *msg, | |||
4026 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) | 3991 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) |
4027 | { | 3992 | { |
4028 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, | 3993 | dhtlog_handle->insert_route (NULL, msg_ctx->unique_id, DHTLOG_ROUTE, |
4029 | msg_ctx->hop_count, ret, | 3994 | msg_ctx->hop_count, ret, &my_identity, |
4030 | &my_identity, &msg_ctx->key, msg_ctx->peer, | 3995 | &msg_ctx->key, msg_ctx->peer, NULL); |
4031 | NULL); | ||
4032 | } | 3996 | } |
4033 | #endif | 3997 | #endif |
4034 | } | 3998 | } |
@@ -4061,15 +4025,15 @@ demultiplex_message (const struct GNUNET_MessageHeader *msg, | |||
4061 | break; | 4025 | break; |
4062 | case GNUNET_MESSAGE_TYPE_DHT_FIND_PEER: /* Check if closest and not started by us, check options, add to requests seen */ | 4026 | case GNUNET_MESSAGE_TYPE_DHT_FIND_PEER: /* Check if closest and not started by us, check options, add to requests seen */ |
4063 | increment_stats (STAT_FIND_PEER); | 4027 | increment_stats (STAT_FIND_PEER); |
4064 | if (((msg_ctx->hop_count > 0) | 4028 | if (((msg_ctx->hop_count > 0) && |
4065 | && (0 != | 4029 | (0 != |
4066 | memcmp (msg_ctx->peer, &my_identity, | 4030 | memcmp (msg_ctx->peer, &my_identity, |
4067 | sizeof (struct GNUNET_PeerIdentity)))) | 4031 | sizeof (struct GNUNET_PeerIdentity)))) || |
4068 | || (msg_ctx->client != NULL)) | 4032 | (msg_ctx->client != NULL)) |
4069 | { | 4033 | { |
4070 | cache_response (msg_ctx); | 4034 | cache_response (msg_ctx); |
4071 | if ((msg_ctx->closest == GNUNET_YES) | 4035 | if ((msg_ctx->closest == GNUNET_YES) || |
4072 | || (msg_ctx->msg_options == GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE)) | 4036 | (msg_ctx->msg_options == GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE)) |
4073 | handle_dht_find_peer (msg, msg_ctx); | 4037 | handle_dht_find_peer (msg, msg_ctx); |
4074 | } | 4038 | } |
4075 | else | 4039 | else |
@@ -4080,8 +4044,7 @@ demultiplex_message (const struct GNUNET_MessageHeader *msg, | |||
4080 | if ((debug_routes) && (dhtlog_handle != NULL)) | 4044 | if ((debug_routes) && (dhtlog_handle != NULL)) |
4081 | { | 4045 | { |
4082 | dhtlog_handle->insert_dhtkey (NULL, &msg_ctx->key); | 4046 | dhtlog_handle->insert_dhtkey (NULL, &msg_ctx->key); |
4083 | dhtlog_handle->insert_query (NULL, msg_ctx->unique_id, | 4047 | dhtlog_handle->insert_query (NULL, msg_ctx->unique_id, DHTLOG_FIND_PEER, |
4084 | DHTLOG_FIND_PEER, | ||
4085 | msg_ctx->hop_count, GNUNET_NO, | 4048 | msg_ctx->hop_count, GNUNET_NO, |
4086 | &my_identity, &msg_ctx->key); | 4049 | &my_identity, &msg_ctx->key); |
4087 | } | 4050 | } |
@@ -4113,10 +4076,9 @@ demultiplex_message (const struct GNUNET_MessageHeader *msg, | |||
4113 | * to stop iteration. | 4076 | * to stop iteration. |
4114 | */ | 4077 | */ |
4115 | static int | 4078 | static int |
4116 | republish_content_iterator (void *cls, | 4079 | republish_content_iterator (void *cls, struct GNUNET_TIME_Absolute exp, |
4117 | struct GNUNET_TIME_Absolute exp, | 4080 | const GNUNET_HashCode * key, size_t size, |
4118 | const GNUNET_HashCode * key, | 4081 | const char *data, uint32_t type) |
4119 | size_t size, const char *data, uint32_t type) | ||
4120 | { | 4082 | { |
4121 | 4083 | ||
4122 | struct DHT_MessageContext *new_msg_ctx; | 4084 | struct DHT_MessageContext *new_msg_ctx; |
@@ -4227,8 +4189,8 @@ find_client_records (void *cls, const GNUNET_HashCode * key, void *value) | |||
4227 | if (record->head == NULL) /* No more entries in DLL */ | 4189 | if (record->head == NULL) /* No more entries in DLL */ |
4228 | { | 4190 | { |
4229 | GNUNET_assert (GNUNET_YES == | 4191 | GNUNET_assert (GNUNET_YES == |
4230 | GNUNET_CONTAINER_multihashmap_remove | 4192 | GNUNET_CONTAINER_multihashmap_remove (forward_list.hashmap, |
4231 | (forward_list.hashmap, &record->key, record)); | 4193 | &record->key, record)); |
4232 | GNUNET_free (record); | 4194 | GNUNET_free (record); |
4233 | } | 4195 | } |
4234 | return GNUNET_YES; | 4196 | return GNUNET_YES; |
@@ -4274,8 +4236,8 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | |||
4274 | 4236 | ||
4275 | while (NULL != (reply = found->pending_head)) | 4237 | while (NULL != (reply = found->pending_head)) |
4276 | { | 4238 | { |
4277 | GNUNET_CONTAINER_DLL_remove (found->pending_head, | 4239 | GNUNET_CONTAINER_DLL_remove (found->pending_head, found->pending_tail, |
4278 | found->pending_tail, reply); | 4240 | reply); |
4279 | GNUNET_free (reply); | 4241 | GNUNET_free (reply); |
4280 | } | 4242 | } |
4281 | GNUNET_CONTAINER_multihashmap_iterate (forward_list.hashmap, | 4243 | GNUNET_CONTAINER_multihashmap_iterate (forward_list.hashmap, |
@@ -4354,13 +4316,13 @@ malicious_put_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
4354 | #endif | 4316 | #endif |
4355 | increment_stats (STAT_PUT_START); | 4317 | increment_stats (STAT_PUT_START); |
4356 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4318 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4357 | "%s:%s Sending malicious PUT message with hash %s\n", | 4319 | "%s:%s Sending malicious PUT message with hash %s\n", my_short_id, |
4358 | my_short_id, "DHT", GNUNET_h2s (&key)); | 4320 | "DHT", GNUNET_h2s (&key)); |
4359 | demultiplex_message (&put_message.header, &msg_ctx); | 4321 | demultiplex_message (&put_message.header, &msg_ctx); |
4360 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 4322 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
4361 | (GNUNET_TIME_UNIT_MILLISECONDS, | 4323 | (GNUNET_TIME_UNIT_MILLISECONDS, |
4362 | malicious_put_frequency), | 4324 | malicious_put_frequency), &malicious_put_task, |
4363 | &malicious_put_task, NULL); | 4325 | NULL); |
4364 | } | 4326 | } |
4365 | 4327 | ||
4366 | 4328 | ||
@@ -4404,13 +4366,13 @@ malicious_get_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
4404 | #endif | 4366 | #endif |
4405 | increment_stats (STAT_GET_START); | 4367 | increment_stats (STAT_GET_START); |
4406 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4368 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4407 | "%s:%s Sending malicious GET message with hash %s\n", | 4369 | "%s:%s Sending malicious GET message with hash %s\n", my_short_id, |
4408 | my_short_id, "DHT", GNUNET_h2s (&key)); | 4370 | "DHT", GNUNET_h2s (&key)); |
4409 | demultiplex_message (&get_message.header, &msg_ctx); | 4371 | demultiplex_message (&get_message.header, &msg_ctx); |
4410 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 4372 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
4411 | (GNUNET_TIME_UNIT_MILLISECONDS, | 4373 | (GNUNET_TIME_UNIT_MILLISECONDS, |
4412 | malicious_get_frequency), | 4374 | malicious_get_frequency), &malicious_get_task, |
4413 | &malicious_get_task, NULL); | 4375 | NULL); |
4414 | } | 4376 | } |
4415 | #endif | 4377 | #endif |
4416 | 4378 | ||
@@ -4511,8 +4473,7 @@ send_find_peer_message (void *cls, | |||
4511 | temp_bloom); | 4473 | temp_bloom); |
4512 | GNUNET_assert (GNUNET_OK == | 4474 | GNUNET_assert (GNUNET_OK == |
4513 | GNUNET_CONTAINER_bloomfilter_get_raw_data (temp_bloom, | 4475 | GNUNET_CONTAINER_bloomfilter_get_raw_data (temp_bloom, |
4514 | find_peer_msg-> | 4476 | find_peer_msg->bloomfilter, |
4515 | bloomfilter, | ||
4516 | DHT_BLOOM_SIZE)); | 4477 | DHT_BLOOM_SIZE)); |
4517 | GNUNET_CONTAINER_bloomfilter_free (temp_bloom); | 4478 | GNUNET_CONTAINER_bloomfilter_free (temp_bloom); |
4518 | memset (&msg_ctx, 0, sizeof (struct DHT_MessageContext)); | 4479 | memset (&msg_ctx, 0, sizeof (struct DHT_MessageContext)); |
@@ -4541,7 +4502,8 @@ send_find_peer_message (void *cls, | |||
4541 | } | 4502 | } |
4542 | else | 4503 | else |
4543 | { | 4504 | { |
4544 | next_send_time.rel_value = DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value + | 4505 | next_send_time.rel_value = |
4506 | DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value + | ||
4545 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, | 4507 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, |
4546 | DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value - | 4508 | DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value - |
4547 | DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value); | 4509 | DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value); |
@@ -4553,8 +4515,8 @@ send_find_peer_message (void *cls, | |||
4553 | find_peer_context.start = GNUNET_TIME_absolute_get (); | 4515 | find_peer_context.start = GNUNET_TIME_absolute_get (); |
4554 | if (GNUNET_YES == do_find_peer) | 4516 | if (GNUNET_YES == do_find_peer) |
4555 | { | 4517 | { |
4556 | GNUNET_SCHEDULER_add_delayed (next_send_time, | 4518 | GNUNET_SCHEDULER_add_delayed (next_send_time, &send_find_peer_message, |
4557 | &send_find_peer_message, NULL); | 4519 | NULL); |
4558 | } | 4520 | } |
4559 | } | 4521 | } |
4560 | 4522 | ||
@@ -4568,8 +4530,7 @@ send_find_peer_message (void *cls, | |||
4568 | * @param message the actual message received | 4530 | * @param message the actual message received |
4569 | */ | 4531 | */ |
4570 | static void | 4532 | static void |
4571 | handle_dht_local_route_request (void *cls, | 4533 | handle_dht_local_route_request (void *cls, struct GNUNET_SERVER_Client *client, |
4572 | struct GNUNET_SERVER_Client *client, | ||
4573 | const struct GNUNET_MessageHeader *message) | 4534 | const struct GNUNET_MessageHeader *message) |
4574 | { | 4535 | { |
4575 | const struct GNUNET_DHT_RouteMessage *dht_msg = | 4536 | const struct GNUNET_DHT_RouteMessage *dht_msg = |
@@ -4581,10 +4542,7 @@ handle_dht_local_route_request (void *cls, | |||
4581 | #if DEBUG_DHT | 4542 | #if DEBUG_DHT |
4582 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4543 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4583 | "`%s:%s': Received `%s' request from client, message type %d, key %s, uid %llu\n", | 4544 | "`%s:%s': Received `%s' request from client, message type %d, key %s, uid %llu\n", |
4584 | my_short_id, | 4545 | my_short_id, "DHT", "GENERIC", ntohs (message->type), |
4585 | "DHT", | ||
4586 | "GENERIC", | ||
4587 | ntohs (message->type), | ||
4588 | GNUNET_h2s (&dht_msg->key), GNUNET_ntohll (dht_msg->unique_id)); | 4546 | GNUNET_h2s (&dht_msg->key), GNUNET_ntohll (dht_msg->unique_id)); |
4589 | #endif | 4547 | #endif |
4590 | #if DEBUG_DHT_ROUTING | 4548 | #if DEBUG_DHT_ROUTING |
@@ -4625,9 +4583,9 @@ handle_dht_local_route_request (void *cls, | |||
4625 | #if DEBUG_DHT_ROUTING | 4583 | #if DEBUG_DHT_ROUTING |
4626 | if ((debug_routes) && (dhtlog_handle != NULL)) | 4584 | if ((debug_routes) && (dhtlog_handle != NULL)) |
4627 | { | 4585 | { |
4628 | dhtlog_handle->insert_query (NULL, msg_ctx.unique_id, | 4586 | dhtlog_handle->insert_query (NULL, msg_ctx.unique_id, DHTLOG_GET, |
4629 | DHTLOG_GET, msg_ctx.hop_count, | 4587 | msg_ctx.hop_count, GNUNET_NO, &my_identity, |
4630 | GNUNET_NO, &my_identity, &msg_ctx.key); | 4588 | &msg_ctx.key); |
4631 | } | 4589 | } |
4632 | #endif | 4590 | #endif |
4633 | } | 4591 | } |
@@ -4636,9 +4594,9 @@ handle_dht_local_route_request (void *cls, | |||
4636 | #if DEBUG_DHT_ROUTING | 4594 | #if DEBUG_DHT_ROUTING |
4637 | if ((debug_routes) && (dhtlog_handle != NULL)) | 4595 | if ((debug_routes) && (dhtlog_handle != NULL)) |
4638 | { | 4596 | { |
4639 | dhtlog_handle->insert_query (NULL, msg_ctx.unique_id, | 4597 | dhtlog_handle->insert_query (NULL, msg_ctx.unique_id, DHTLOG_PUT, |
4640 | DHTLOG_PUT, msg_ctx.hop_count, | 4598 | msg_ctx.hop_count, GNUNET_NO, &my_identity, |
4641 | GNUNET_NO, &my_identity, &msg_ctx.key); | 4599 | &msg_ctx.key); |
4642 | } | 4600 | } |
4643 | #endif | 4601 | #endif |
4644 | } | 4602 | } |
@@ -4719,8 +4677,8 @@ handle_dht_control_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
4719 | #endif | 4677 | #endif |
4720 | default: | 4678 | default: |
4721 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 4679 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
4722 | "%s:%s Unknown control command type `%d'!\n", | 4680 | "%s:%s Unknown control command type `%d'!\n", my_short_id, |
4723 | my_short_id, "DHT", ntohs (dht_control_msg->command)); | 4681 | "DHT", ntohs (dht_control_msg->command)); |
4724 | break; | 4682 | break; |
4725 | } | 4683 | } |
4726 | 4684 | ||
@@ -4787,8 +4745,7 @@ handle_dht_local_route_stop (void *cls, struct GNUNET_SERVER_Client *client, | |||
4787 | * | 4745 | * |
4788 | */ | 4746 | */ |
4789 | static int | 4747 | static int |
4790 | handle_dht_p2p_route_request (void *cls, | 4748 | handle_dht_p2p_route_request (void *cls, const struct GNUNET_PeerIdentity *peer, |
4791 | const struct GNUNET_PeerIdentity *peer, | ||
4792 | const struct GNUNET_MessageHeader *message, | 4749 | const struct GNUNET_MessageHeader *message, |
4793 | const struct GNUNET_TRANSPORT_ATS_Information | 4750 | const struct GNUNET_TRANSPORT_ATS_Information |
4794 | *atsi) | 4751 | *atsi) |
@@ -4809,8 +4766,8 @@ handle_dht_p2p_route_request (void *cls, | |||
4809 | if (ntohs (enc_msg->type) == GNUNET_MESSAGE_TYPE_DHT_P2P_PING) /* Throw these away. FIXME: Don't throw these away? (reply) */ | 4766 | if (ntohs (enc_msg->type) == GNUNET_MESSAGE_TYPE_DHT_P2P_PING) /* Throw these away. FIXME: Don't throw these away? (reply) */ |
4810 | { | 4767 | { |
4811 | #if DEBUG_PING | 4768 | #if DEBUG_PING |
4812 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4769 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s:%s Received P2P Ping message.\n", |
4813 | "%s:%s Received P2P Ping message.\n", my_short_id, "DHT"); | 4770 | my_short_id, "DHT"); |
4814 | #endif | 4771 | #endif |
4815 | return GNUNET_YES; | 4772 | return GNUNET_YES; |
4816 | } | 4773 | } |
@@ -4827,12 +4784,10 @@ handle_dht_p2p_route_request (void *cls, | |||
4827 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) | 4784 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) |
4828 | { | 4785 | { |
4829 | /** Log routes that die due to high load! */ | 4786 | /** Log routes that die due to high load! */ |
4830 | dhtlog_handle->insert_route (NULL, | 4787 | dhtlog_handle->insert_route (NULL, GNUNET_ntohll (incoming->unique_id), |
4831 | GNUNET_ntohll (incoming->unique_id), | 4788 | DHTLOG_ROUTE, ntohl (incoming->hop_count), |
4832 | DHTLOG_ROUTE, | 4789 | GNUNET_SYSERR, &my_identity, &incoming->key, |
4833 | ntohl (incoming->hop_count), | 4790 | peer, NULL); |
4834 | GNUNET_SYSERR, &my_identity, | ||
4835 | &incoming->key, peer, NULL); | ||
4836 | } | 4791 | } |
4837 | #endif | 4792 | #endif |
4838 | return GNUNET_YES; | 4793 | return GNUNET_YES; |
@@ -4848,12 +4803,10 @@ handle_dht_p2p_route_request (void *cls, | |||
4848 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) | 4803 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) |
4849 | { | 4804 | { |
4850 | /** Log routes that die due to high load! */ | 4805 | /** Log routes that die due to high load! */ |
4851 | dhtlog_handle->insert_route (NULL, | 4806 | dhtlog_handle->insert_route (NULL, GNUNET_ntohll (incoming->unique_id), |
4852 | GNUNET_ntohll (incoming->unique_id), | 4807 | DHTLOG_ROUTE, ntohl (incoming->hop_count), |
4853 | DHTLOG_ROUTE, | 4808 | GNUNET_SYSERR, &my_identity, &incoming->key, |
4854 | ntohl (incoming->hop_count), | 4809 | peer, NULL); |
4855 | GNUNET_SYSERR, &my_identity, | ||
4856 | &incoming->key, peer, NULL); | ||
4857 | } | 4810 | } |
4858 | #endif | 4811 | #endif |
4859 | return GNUNET_YES; | 4812 | return GNUNET_YES; |
@@ -4911,8 +4864,7 @@ handle_dht_p2p_route_request (void *cls, | |||
4911 | * | 4864 | * |
4912 | */ | 4865 | */ |
4913 | static int | 4866 | static int |
4914 | handle_dht_p2p_route_result (void *cls, | 4867 | handle_dht_p2p_route_result (void *cls, const struct GNUNET_PeerIdentity *peer, |
4915 | const struct GNUNET_PeerIdentity *peer, | ||
4916 | const struct GNUNET_MessageHeader *message, | 4868 | const struct GNUNET_MessageHeader *message, |
4917 | const struct GNUNET_TRANSPORT_ATS_Information | 4869 | const struct GNUNET_TRANSPORT_ATS_Information |
4918 | *atsi) | 4870 | *atsi) |
@@ -4944,12 +4896,10 @@ handle_dht_p2p_route_result (void *cls, | |||
4944 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) | 4896 | if ((debug_routes_extended) && (dhtlog_handle != NULL)) |
4945 | { | 4897 | { |
4946 | /** Log routes that die due to high load! */ | 4898 | /** Log routes that die due to high load! */ |
4947 | dhtlog_handle->insert_route (NULL, | 4899 | dhtlog_handle->insert_route (NULL, GNUNET_ntohll (incoming->unique_id), |
4948 | GNUNET_ntohll (incoming->unique_id), | 4900 | DHTLOG_ROUTE, ntohl (incoming->hop_count), |
4949 | DHTLOG_ROUTE, | 4901 | GNUNET_SYSERR, &my_identity, &incoming->key, |
4950 | ntohl (incoming->hop_count), | 4902 | peer, NULL); |
4951 | GNUNET_SYSERR, &my_identity, | ||
4952 | &incoming->key, peer, NULL); | ||
4953 | } | 4903 | } |
4954 | #endif | 4904 | #endif |
4955 | return GNUNET_YES; | 4905 | return GNUNET_YES; |
@@ -4977,8 +4927,7 @@ handle_dht_p2p_route_result (void *cls, | |||
4977 | #if DEBUG_DHT | 4927 | #if DEBUG_DHT |
4978 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4928 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4979 | "Return message indicated a path was included, but sizes are wrong: Total size %d, enc size %d, left %d, expected %d\n", | 4929 | "Return message indicated a path was included, but sizes are wrong: Total size %d, enc size %d, left %d, expected %d\n", |
4980 | ntohs (message->size), | 4930 | ntohs (message->size), ntohs (enc_msg->size), |
4981 | ntohs (enc_msg->size), | ||
4982 | ntohs (message->size) - | 4931 | ntohs (message->size) - |
4983 | sizeof (struct GNUNET_DHT_P2PRouteResultMessage) - | 4932 | sizeof (struct GNUNET_DHT_P2PRouteResultMessage) - |
4984 | ntohs (enc_msg->size), | 4933 | ntohs (enc_msg->size), |
@@ -5055,8 +5004,8 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
5055 | if (coreAPI != NULL) | 5004 | if (coreAPI != NULL) |
5056 | { | 5005 | { |
5057 | #if DEBUG_DHT | 5006 | #if DEBUG_DHT |
5058 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 5007 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s:%s Disconnecting core!\n", |
5059 | "%s:%s Disconnecting core!\n", my_short_id, "DHT"); | 5008 | my_short_id, "DHT"); |
5060 | #endif | 5009 | #endif |
5061 | GNUNET_CORE_disconnect (coreAPI); | 5010 | GNUNET_CORE_disconnect (coreAPI); |
5062 | coreAPI = NULL; | 5011 | coreAPI = NULL; |
@@ -5077,8 +5026,8 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
5077 | if (datacache != NULL) | 5026 | if (datacache != NULL) |
5078 | { | 5027 | { |
5079 | #if DEBUG_DHT | 5028 | #if DEBUG_DHT |
5080 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 5029 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s:%s Destroying datacache!\n", |
5081 | "%s:%s Destroying datacache!\n", my_short_id, "DHT"); | 5030 | my_short_id, "DHT"); |
5082 | #endif | 5031 | #endif |
5083 | GNUNET_DATACACHE_destroy (datacache); | 5032 | GNUNET_DATACACHE_destroy (datacache); |
5084 | datacache = NULL; | 5033 | datacache = NULL; |
@@ -5112,8 +5061,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
5112 | * @param publicKey the public key of this peer | 5061 | * @param publicKey the public key of this peer |
5113 | */ | 5062 | */ |
5114 | void | 5063 | void |
5115 | core_init (void *cls, | 5064 | core_init (void *cls, struct GNUNET_CORE_Handle *server, |
5116 | struct GNUNET_CORE_Handle *server, | ||
5117 | const struct GNUNET_PeerIdentity *identity, | 5065 | const struct GNUNET_PeerIdentity *identity, |
5118 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) | 5066 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) |
5119 | { | 5067 | { |
@@ -5121,9 +5069,8 @@ core_init (void *cls, | |||
5121 | if (server == NULL) | 5069 | if (server == NULL) |
5122 | { | 5070 | { |
5123 | #if DEBUG_DHT | 5071 | #if DEBUG_DHT |
5124 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 5072 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s: Connection to core FAILED!\n", |
5125 | "%s: Connection to core FAILED!\n", "dht", | 5073 | "dht", GNUNET_i2s (identity)); |
5126 | GNUNET_i2s (identity)); | ||
5127 | #endif | 5074 | #endif |
5128 | GNUNET_SCHEDULER_cancel (cleanup_task); | 5075 | GNUNET_SCHEDULER_cancel (cleanup_task); |
5129 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | 5076 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); |
@@ -5175,8 +5122,7 @@ static struct GNUNET_CORE_MessageHandler core_handlers[] = { | |||
5175 | * @param atsi performance data | 5122 | * @param atsi performance data |
5176 | */ | 5123 | */ |
5177 | static void | 5124 | static void |
5178 | handle_core_connect (void *cls, | 5125 | handle_core_connect (void *cls, const struct GNUNET_PeerIdentity *peer, |
5179 | const struct GNUNET_PeerIdentity *peer, | ||
5180 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 5126 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
5181 | { | 5127 | { |
5182 | struct PeerInfo *ret; | 5128 | struct PeerInfo *ret; |
@@ -5242,8 +5188,8 @@ handle_core_connect (void *cls, | |||
5242 | if ((GNUNET_CRYPTO_hash_matching_bits | 5188 | if ((GNUNET_CRYPTO_hash_matching_bits |
5243 | (&my_identity.hashPubKey, &peer->hashPubKey) > 0) && | 5189 | (&my_identity.hashPubKey, &peer->hashPubKey) > 0) && |
5244 | (k_buckets[peer_bucket].peers_size <= bucket_size)) | 5190 | (k_buckets[peer_bucket].peers_size <= bucket_size)) |
5245 | ret->preference_task = GNUNET_SCHEDULER_add_now (&update_core_preference, | 5191 | ret->preference_task = |
5246 | ret); | 5192 | GNUNET_SCHEDULER_add_now (&update_core_preference, ret); |
5247 | #endif | 5193 | #endif |
5248 | if ((k_buckets[lowest_bucket].peers_size) >= bucket_size) | 5194 | if ((k_buckets[lowest_bucket].peers_size) >= bucket_size) |
5249 | enable_next_bucket (); | 5195 | enable_next_bucket (); |
@@ -5251,8 +5197,7 @@ handle_core_connect (void *cls, | |||
5251 | schedule_ping_messages (); | 5197 | schedule_ping_messages (); |
5252 | #endif | 5198 | #endif |
5253 | newly_found_peers++; | 5199 | newly_found_peers++; |
5254 | GNUNET_CONTAINER_multihashmap_put (all_known_peers, &peer->hashPubKey, | 5200 | GNUNET_CONTAINER_multihashmap_put (all_known_peers, &peer->hashPubKey, ret, |
5255 | ret, | ||
5256 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 5201 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
5257 | increment_stats (STAT_PEERS_KNOWN); | 5202 | increment_stats (STAT_PEERS_KNOWN); |
5258 | 5203 | ||
@@ -5324,8 +5269,7 @@ handle_core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
5324 | * @param c configuration to use | 5269 | * @param c configuration to use |
5325 | */ | 5270 | */ |
5326 | static void | 5271 | static void |
5327 | run (void *cls, | 5272 | run (void *cls, struct GNUNET_SERVER_Handle *server, |
5328 | struct GNUNET_SERVER_Handle *server, | ||
5329 | const struct GNUNET_CONFIGURATION_Handle *c) | 5273 | const struct GNUNET_CONFIGURATION_Handle *c) |
5330 | { | 5274 | { |
5331 | struct GNUNET_TIME_Relative next_send_time; | 5275 | struct GNUNET_TIME_Relative next_send_time; |
@@ -5351,8 +5295,8 @@ run (void *cls, | |||
5351 | 5295 | ||
5352 | if (coreAPI == NULL) | 5296 | if (coreAPI == NULL) |
5353 | return; | 5297 | return; |
5354 | transport_handle = GNUNET_TRANSPORT_connect (cfg, | 5298 | transport_handle = |
5355 | NULL, NULL, NULL, NULL, NULL); | 5299 | GNUNET_TRANSPORT_connect (cfg, NULL, NULL, NULL, NULL, NULL); |
5356 | if (transport_handle != NULL) | 5300 | if (transport_handle != NULL) |
5357 | GNUNET_TRANSPORT_get_hello (transport_handle, &process_hello, NULL); | 5301 | GNUNET_TRANSPORT_get_hello (transport_handle, &process_hello, NULL); |
5358 | else | 5302 | else |
@@ -5397,21 +5341,21 @@ run (void *cls, | |||
5397 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht", "malicious_getter")) | 5341 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht", "malicious_getter")) |
5398 | { | 5342 | { |
5399 | malicious_getter = GNUNET_YES; | 5343 | malicious_getter = GNUNET_YES; |
5400 | if (GNUNET_NO == GNUNET_CONFIGURATION_get_value_number (cfg, "DHT", | 5344 | if (GNUNET_NO == |
5401 | "MALICIOUS_GET_FREQUENCY", | 5345 | GNUNET_CONFIGURATION_get_value_number (cfg, "DHT", |
5402 | &malicious_get_frequency)) | 5346 | "MALICIOUS_GET_FREQUENCY", |
5347 | &malicious_get_frequency)) | ||
5403 | malicious_get_frequency = DEFAULT_MALICIOUS_GET_FREQUENCY; | 5348 | malicious_get_frequency = DEFAULT_MALICIOUS_GET_FREQUENCY; |
5404 | } | 5349 | } |
5405 | 5350 | ||
5406 | if (GNUNET_YES != GNUNET_CONFIGURATION_get_value_number (cfg, "DHT", | 5351 | if (GNUNET_YES != |
5407 | "MAX_HOPS", | 5352 | GNUNET_CONFIGURATION_get_value_number (cfg, "DHT", "MAX_HOPS", &max_hops)) |
5408 | &max_hops)) | ||
5409 | { | 5353 | { |
5410 | max_hops = DEFAULT_MAX_HOPS; | 5354 | max_hops = DEFAULT_MAX_HOPS; |
5411 | } | 5355 | } |
5412 | 5356 | ||
5413 | if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_yesno (cfg, "DHT", | 5357 | if (GNUNET_YES == |
5414 | "USE_MAX_HOPS")) | 5358 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "DHT", "USE_MAX_HOPS")) |
5415 | { | 5359 | { |
5416 | use_max_hops = GNUNET_YES; | 5360 | use_max_hops = GNUNET_YES; |
5417 | } | 5361 | } |
@@ -5420,9 +5364,10 @@ run (void *cls, | |||
5420 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht", "malicious_putter")) | 5364 | GNUNET_CONFIGURATION_get_value_yesno (cfg, "dht", "malicious_putter")) |
5421 | { | 5365 | { |
5422 | malicious_putter = GNUNET_YES; | 5366 | malicious_putter = GNUNET_YES; |
5423 | if (GNUNET_NO == GNUNET_CONFIGURATION_get_value_number (cfg, "DHT", | 5367 | if (GNUNET_NO == |
5424 | "MALICIOUS_PUT_FREQUENCY", | 5368 | GNUNET_CONFIGURATION_get_value_number (cfg, "DHT", |
5425 | &malicious_put_frequency)) | 5369 | "MALICIOUS_PUT_FREQUENCY", |
5370 | &malicious_put_frequency)) | ||
5426 | malicious_put_frequency = DEFAULT_MALICIOUS_PUT_FREQUENCY; | 5371 | malicious_put_frequency = DEFAULT_MALICIOUS_PUT_FREQUENCY; |
5427 | } | 5372 | } |
5428 | 5373 | ||
@@ -5570,19 +5515,21 @@ run (void *cls, | |||
5570 | GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); | 5515 | GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HEAP_ORDER_MIN); |
5571 | if (GNUNET_YES == do_find_peer) | 5516 | if (GNUNET_YES == do_find_peer) |
5572 | { | 5517 | { |
5573 | next_send_time.rel_value = DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value + | 5518 | next_send_time.rel_value = |
5519 | DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value + | ||
5574 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, | 5520 | GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_STRONG, |
5575 | (DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value / | 5521 | (DHT_MAXIMUM_FIND_PEER_INTERVAL.rel_value / |
5576 | 2) - | 5522 | 2) - |
5577 | DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value); | 5523 | DHT_MINIMUM_FIND_PEER_INTERVAL.rel_value); |
5578 | find_peer_context.start = GNUNET_TIME_absolute_get (); | 5524 | find_peer_context.start = GNUNET_TIME_absolute_get (); |
5579 | GNUNET_SCHEDULER_add_delayed (next_send_time, | 5525 | GNUNET_SCHEDULER_add_delayed (next_send_time, &send_find_peer_message, |
5580 | &send_find_peer_message, &find_peer_context); | 5526 | &find_peer_context); |
5581 | } | 5527 | } |
5582 | 5528 | ||
5583 | /* Scheduled the task to clean up when shutdown is called */ | 5529 | /* Scheduled the task to clean up when shutdown is called */ |
5584 | cleanup_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 5530 | cleanup_task = |
5585 | &shutdown_task, NULL); | 5531 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
5532 | &shutdown_task, NULL); | ||
5586 | } | 5533 | } |
5587 | 5534 | ||
5588 | /** | 5535 | /** |
@@ -5597,11 +5544,10 @@ main (int argc, char *const *argv) | |||
5597 | { | 5544 | { |
5598 | int ret; | 5545 | int ret; |
5599 | 5546 | ||
5600 | ret = (GNUNET_OK == | 5547 | ret = |
5601 | GNUNET_SERVICE_run (argc, | 5548 | (GNUNET_OK == |
5602 | argv, | 5549 | GNUNET_SERVICE_run (argc, argv, "dht", GNUNET_SERVICE_OPTION_NONE, &run, |
5603 | "dht", | 5550 | NULL)) ? 0 : 1; |
5604 | GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1; | ||
5605 | if (NULL != recent.hashmap) | 5551 | if (NULL != recent.hashmap) |
5606 | { | 5552 | { |
5607 | GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap_size (recent.hashmap)); | 5553 | GNUNET_assert (0 == GNUNET_CONTAINER_multihashmap_size (recent.hashmap)); |
diff --git a/src/dht/plugin_dhtlog_dummy.c b/src/dht/plugin_dhtlog_dummy.c index 2250c0330..a411c5934 100644 --- a/src/dht/plugin_dhtlog_dummy.c +++ b/src/dht/plugin_dhtlog_dummy.c | |||
@@ -135,8 +135,8 @@ update_trials (unsigned int gets_succeeded) | |||
135 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure | 135 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure |
136 | */ | 136 | */ |
137 | int | 137 | int |
138 | add_generic_stat (const struct GNUNET_PeerIdentity *peer, | 138 | add_generic_stat (const struct GNUNET_PeerIdentity *peer, const char *name, |
139 | const char *name, const char *section, uint64_t value) | 139 | const char *section, uint64_t value) |
140 | { | 140 | { |
141 | return GNUNET_OK; | 141 | return GNUNET_OK; |
142 | } | 142 | } |
@@ -193,9 +193,8 @@ add_query (unsigned long long *sqlqueryuid, unsigned long long queryid, | |||
193 | */ | 193 | */ |
194 | int | 194 | int |
195 | add_route (unsigned long long *sqlqueryuid, unsigned long long queryid, | 195 | add_route (unsigned long long *sqlqueryuid, unsigned long long queryid, |
196 | unsigned int type, unsigned int hops, | 196 | unsigned int type, unsigned int hops, int succeeded, |
197 | int succeeded, const struct GNUNET_PeerIdentity *node, | 197 | const struct GNUNET_PeerIdentity *node, const GNUNET_HashCode * key, |
198 | const GNUNET_HashCode * key, | ||
199 | const struct GNUNET_PeerIdentity *from_node, | 198 | const struct GNUNET_PeerIdentity *from_node, |
200 | const struct GNUNET_PeerIdentity *to_node) | 199 | const struct GNUNET_PeerIdentity *to_node) |
201 | { | 200 | { |
@@ -282,16 +281,18 @@ set_malicious (struct GNUNET_PeerIdentity *peer) | |||
282 | * | 281 | * |
283 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure | 282 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure |
284 | */ | 283 | */ |
285 | int insert_stat | 284 | int insert_stat (const struct GNUNET_PeerIdentity *peer, |
286 | (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests, | 285 | unsigned int route_requests, unsigned int route_forwards, |
287 | unsigned int route_forwards, unsigned int result_requests, | 286 | unsigned int result_requests, unsigned int client_requests, |
288 | unsigned int client_requests, unsigned int result_forwards, | 287 | unsigned int result_forwards, unsigned int gets, |
289 | unsigned int gets, unsigned int puts, | 288 | unsigned int puts, unsigned int data_inserts, |
290 | unsigned int data_inserts, unsigned int find_peer_requests, | 289 | unsigned int find_peer_requests, |
291 | unsigned int find_peers_started, unsigned int gets_started, | 290 | unsigned int find_peers_started, unsigned int gets_started, |
292 | unsigned int puts_started, unsigned int find_peer_responses_received, | 291 | unsigned int puts_started, |
293 | unsigned int get_responses_received, unsigned int find_peer_responses_sent, | 292 | unsigned int find_peer_responses_received, |
294 | unsigned int get_responses_sent) | 293 | unsigned int get_responses_received, |
294 | unsigned int find_peer_responses_sent, | ||
295 | unsigned int get_responses_sent) | ||
295 | { | 296 | { |
296 | return GNUNET_OK; | 297 | return GNUNET_OK; |
297 | } | 298 | } |
diff --git a/src/dht/plugin_dhtlog_mysql.c b/src/dht/plugin_dhtlog_mysql.c index c653f912a..33028fb09 100644 --- a/src/dht/plugin_dhtlog_mysql.c +++ b/src/dht/plugin_dhtlog_mysql.c | |||
@@ -73,8 +73,7 @@ struct StatementHandle | |||
73 | * @param values values returned by MySQL | 73 | * @param values values returned by MySQL |
74 | * @return GNUNET_OK to continue iterating, GNUNET_SYSERR to abort | 74 | * @return GNUNET_OK to continue iterating, GNUNET_SYSERR to abort |
75 | */ | 75 | */ |
76 | typedef int (*GNUNET_MysqlDataProcessor) (void *cls, | 76 | typedef int (*GNUNET_MysqlDataProcessor) (void *cls, unsigned int num_values, |
77 | unsigned int num_values, | ||
78 | MYSQL_BIND * values); | 77 | MYSQL_BIND * values); |
79 | 78 | ||
80 | static unsigned long max_varchar_len; | 79 | static unsigned long max_varchar_len; |
@@ -203,128 +202,121 @@ itable () | |||
203 | { | 202 | { |
204 | #define MRUNS(a) (GNUNET_OK != run_statement (a) ) | 203 | #define MRUNS(a) (GNUNET_OK != run_statement (a) ) |
205 | 204 | ||
206 | if (MRUNS ("CREATE TABLE IF NOT EXISTS `dhtkeys` (" | 205 | if (MRUNS |
207 | "dhtkeyuid int(10) unsigned NOT NULL auto_increment COMMENT 'Unique Key given to each query'," | 206 | ("CREATE TABLE IF NOT EXISTS `dhtkeys` (" |
208 | "`dhtkey` varchar(255) NOT NULL COMMENT 'The ASCII value of the key being searched for'," | 207 | "dhtkeyuid int(10) unsigned NOT NULL auto_increment COMMENT 'Unique Key given to each query'," |
209 | "trialuid int(10) unsigned NOT NULL," | 208 | "`dhtkey` varchar(255) NOT NULL COMMENT 'The ASCII value of the key being searched for'," |
210 | "keybits blob NOT NULL," | 209 | "trialuid int(10) unsigned NOT NULL," "keybits blob NOT NULL," |
211 | "UNIQUE KEY `dhtkeyuid` (`dhtkeyuid`)" | 210 | "UNIQUE KEY `dhtkeyuid` (`dhtkeyuid`)" |
212 | ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1")) | 211 | ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1")) |
213 | return GNUNET_SYSERR; | 212 | return GNUNET_SYSERR; |
214 | 213 | ||
215 | if (MRUNS ("CREATE TABLE IF NOT EXISTS `nodes` (" | 214 | if (MRUNS |
216 | "`nodeuid` int(10) unsigned NOT NULL auto_increment," | 215 | ("CREATE TABLE IF NOT EXISTS `nodes` (" |
217 | "`trialuid` int(10) unsigned NOT NULL," | 216 | "`nodeuid` int(10) unsigned NOT NULL auto_increment," |
218 | "`nodeid` varchar(255) NOT NULL," | 217 | "`trialuid` int(10) unsigned NOT NULL," "`nodeid` varchar(255) NOT NULL," |
219 | "`nodebits` blob NOT NULL," | 218 | "`nodebits` blob NOT NULL," "PRIMARY KEY (`nodeuid`)" |
220 | "PRIMARY KEY (`nodeuid`)" | 219 | ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1")) |
221 | ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1")) | ||
222 | return GNUNET_SYSERR; | 220 | return GNUNET_SYSERR; |
223 | 221 | ||
224 | if (MRUNS ("CREATE TABLE IF NOT EXISTS `queries` (" | 222 | if (MRUNS |
225 | "`trialuid` int(10) unsigned NOT NULL," | 223 | ("CREATE TABLE IF NOT EXISTS `queries` (" |
226 | "`queryuid` int(10) unsigned NOT NULL auto_increment," | 224 | "`trialuid` int(10) unsigned NOT NULL," |
227 | "`dhtqueryid` bigint(20) NOT NULL," | 225 | "`queryuid` int(10) unsigned NOT NULL auto_increment," |
228 | "`querytype` enum('1','2','3','4','5') NOT NULL," | 226 | "`dhtqueryid` bigint(20) NOT NULL," |
229 | "`hops` int(10) unsigned NOT NULL," | 227 | "`querytype` enum('1','2','3','4','5') NOT NULL," |
230 | "`succeeded` tinyint NOT NULL," | 228 | "`hops` int(10) unsigned NOT NULL," "`succeeded` tinyint NOT NULL," |
231 | "`nodeuid` int(10) unsigned NOT NULL," | 229 | "`nodeuid` int(10) unsigned NOT NULL," |
232 | "`time` timestamp NOT NULL default CURRENT_TIMESTAMP," | 230 | "`time` timestamp NOT NULL default CURRENT_TIMESTAMP," |
233 | "`dhtkeyuid` int(10) unsigned NOT NULL," | 231 | "`dhtkeyuid` int(10) unsigned NOT NULL," "PRIMARY KEY (`queryuid`)" |
234 | "PRIMARY KEY (`queryuid`)" | 232 | ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1")) |
235 | ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1")) | ||
236 | return GNUNET_SYSERR; | 233 | return GNUNET_SYSERR; |
237 | 234 | ||
238 | if (MRUNS ("CREATE TABLE IF NOT EXISTS `routes` (" | 235 | if (MRUNS |
239 | "`trialuid` int(10) unsigned NOT NULL," | 236 | ("CREATE TABLE IF NOT EXISTS `routes` (" |
240 | "`queryuid` int(10) unsigned NOT NULL auto_increment," | 237 | "`trialuid` int(10) unsigned NOT NULL," |
241 | "`dhtqueryid` bigint(20) NOT NULL," | 238 | "`queryuid` int(10) unsigned NOT NULL auto_increment," |
242 | "`querytype` enum('1','2','3','4','5') NOT NULL," | 239 | "`dhtqueryid` bigint(20) NOT NULL," |
243 | "`hops` int(10) unsigned NOT NULL," | 240 | "`querytype` enum('1','2','3','4','5') NOT NULL," |
244 | "`succeeded` tinyint NOT NULL," | 241 | "`hops` int(10) unsigned NOT NULL," "`succeeded` tinyint NOT NULL," |
245 | "`nodeuid` int(10) unsigned NOT NULL," | 242 | "`nodeuid` int(10) unsigned NOT NULL," |
246 | "`time` timestamp NOT NULL default CURRENT_TIMESTAMP," | 243 | "`time` timestamp NOT NULL default CURRENT_TIMESTAMP," |
247 | "`dhtkeyuid` int(10) unsigned NOT NULL," | 244 | "`dhtkeyuid` int(10) unsigned NOT NULL," |
248 | "`from_node` int(10) unsigned NOT NULL," | 245 | "`from_node` int(10) unsigned NOT NULL," |
249 | "`to_node` int(10) unsigned NOT NULL," | 246 | "`to_node` int(10) unsigned NOT NULL," "PRIMARY KEY (`queryuid`)" |
250 | "PRIMARY KEY (`queryuid`)" | 247 | ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1")) |
251 | ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1")) | ||
252 | return GNUNET_SYSERR; | 248 | return GNUNET_SYSERR; |
253 | 249 | ||
254 | if (MRUNS ("CREATE TABLE IF NOT EXISTS `trials` (" | 250 | if (MRUNS |
255 | "`trialuid` int(10) unsigned NOT NULL auto_increment," | 251 | ("CREATE TABLE IF NOT EXISTS `trials` (" |
256 | "`other_trial_identifier` int(10) unsigned NOT NULL default '0'," | 252 | "`trialuid` int(10) unsigned NOT NULL auto_increment," |
257 | "`numnodes` int(10) unsigned NOT NULL," | 253 | "`other_trial_identifier` int(10) unsigned NOT NULL default '0'," |
258 | "`topology` int(10) NOT NULL," | 254 | "`numnodes` int(10) unsigned NOT NULL," "`topology` int(10) NOT NULL," |
259 | "`blacklist_topology` int(11) NOT NULL," | 255 | "`blacklist_topology` int(11) NOT NULL," |
260 | "`connect_topology` int(11) NOT NULL," | 256 | "`connect_topology` int(11) NOT NULL," |
261 | "`connect_topology_option` int(11) NOT NULL," | 257 | "`connect_topology_option` int(11) NOT NULL," |
262 | "`topology_percentage` float NOT NULL," | 258 | "`topology_percentage` float NOT NULL," |
263 | "`topology_probability` float NOT NULL," | 259 | "`topology_probability` float NOT NULL," |
264 | "`connect_topology_option_modifier` float NOT NULL," | 260 | "`connect_topology_option_modifier` float NOT NULL," |
265 | "`starttime` datetime NOT NULL," | 261 | "`starttime` datetime NOT NULL," "`endtime` datetime NOT NULL," |
266 | "`endtime` datetime NOT NULL," | 262 | "`puts` int(10) unsigned NOT NULL," "`gets` int(10) unsigned NOT NULL," |
267 | "`puts` int(10) unsigned NOT NULL," | 263 | "`concurrent` int(10) unsigned NOT NULL," |
268 | "`gets` int(10) unsigned NOT NULL," | 264 | "`settle_time` int(10) unsigned NOT NULL," |
269 | "`concurrent` int(10) unsigned NOT NULL," | 265 | "`totalConnections` int(10) unsigned NOT NULL," |
270 | "`settle_time` int(10) unsigned NOT NULL," | 266 | "`message` text NOT NULL," "`num_rounds` int(10) unsigned NOT NULL," |
271 | "`totalConnections` int(10) unsigned NOT NULL," | 267 | "`malicious_getters` int(10) unsigned NOT NULL," |
272 | "`message` text NOT NULL," | 268 | "`malicious_putters` int(10) unsigned NOT NULL," |
273 | "`num_rounds` int(10) unsigned NOT NULL," | 269 | "`malicious_droppers` int(10) unsigned NOT NULL," |
274 | "`malicious_getters` int(10) unsigned NOT NULL," | 270 | "`topology_modifier` double NOT NULL," |
275 | "`malicious_putters` int(10) unsigned NOT NULL," | 271 | "`malicious_get_frequency` int(10) unsigned NOT NULL," |
276 | "`malicious_droppers` int(10) unsigned NOT NULL," | 272 | "`malicious_put_frequency` int(10) unsigned NOT NULL," |
277 | "`topology_modifier` double NOT NULL," | 273 | "`stop_closest` int(10) unsigned NOT NULL," |
278 | "`malicious_get_frequency` int(10) unsigned NOT NULL," | 274 | "`stop_found` int(10) unsigned NOT NULL," |
279 | "`malicious_put_frequency` int(10) unsigned NOT NULL," | 275 | "`strict_kademlia` int(10) unsigned NOT NULL," |
280 | "`stop_closest` int(10) unsigned NOT NULL," | 276 | "`gets_succeeded` int(10) unsigned NOT NULL," |
281 | "`stop_found` int(10) unsigned NOT NULL," | 277 | "PRIMARY KEY (`trialuid`)," "UNIQUE KEY `trialuid` (`trialuid`)" |
282 | "`strict_kademlia` int(10) unsigned NOT NULL," | 278 | ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1")) |
283 | "`gets_succeeded` int(10) unsigned NOT NULL," | ||
284 | "PRIMARY KEY (`trialuid`)," | ||
285 | "UNIQUE KEY `trialuid` (`trialuid`)" | ||
286 | ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1")) | ||
287 | return GNUNET_SYSERR; | 279 | return GNUNET_SYSERR; |
288 | 280 | ||
289 | if (MRUNS ("CREATE TABLE IF NOT EXISTS `topology` (" | 281 | if (MRUNS |
290 | "`topology_uid` int(10) unsigned NOT NULL AUTO_INCREMENT," | 282 | ("CREATE TABLE IF NOT EXISTS `topology` (" |
291 | "`trialuid` int(10) unsigned NOT NULL," | 283 | "`topology_uid` int(10) unsigned NOT NULL AUTO_INCREMENT," |
292 | "`date` datetime NOT NULL," | 284 | "`trialuid` int(10) unsigned NOT NULL," "`date` datetime NOT NULL," |
293 | "`connections` int(10) unsigned NOT NULL," | 285 | "`connections` int(10) unsigned NOT NULL," |
294 | "PRIMARY KEY (`topology_uid`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1")) | 286 | "PRIMARY KEY (`topology_uid`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1")) |
295 | return GNUNET_SYSERR; | 287 | return GNUNET_SYSERR; |
296 | 288 | ||
297 | if (MRUNS ("CREATE TABLE IF NOT EXISTS `extended_topology` (" | 289 | if (MRUNS |
298 | "`extended_uid` int(10) unsigned NOT NULL AUTO_INCREMENT," | 290 | ("CREATE TABLE IF NOT EXISTS `extended_topology` (" |
299 | "`topology_uid` int(10) unsigned NOT NULL," | 291 | "`extended_uid` int(10) unsigned NOT NULL AUTO_INCREMENT," |
300 | "`uid_first` int(10) unsigned NOT NULL," | 292 | "`topology_uid` int(10) unsigned NOT NULL," |
301 | "`uid_second` int(10) unsigned NOT NULL," | 293 | "`uid_first` int(10) unsigned NOT NULL," |
302 | "PRIMARY KEY (`extended_uid`)" | 294 | "`uid_second` int(10) unsigned NOT NULL," "PRIMARY KEY (`extended_uid`)" |
303 | ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1")) | 295 | ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1")) |
304 | return GNUNET_SYSERR; | 296 | return GNUNET_SYSERR; |
305 | 297 | ||
306 | if (MRUNS ("CREATE TABLE IF NOT EXISTS `node_statistics` (" | 298 | if (MRUNS |
307 | "`stat_uid` int(10) unsigned NOT NULL AUTO_INCREMENT," | 299 | ("CREATE TABLE IF NOT EXISTS `node_statistics` (" |
308 | "`trialuid` int(10) unsigned NOT NULL," | 300 | "`stat_uid` int(10) unsigned NOT NULL AUTO_INCREMENT," |
309 | "`nodeuid` int(10) unsigned NOT NULL," | 301 | "`trialuid` int(10) unsigned NOT NULL," |
310 | "`route_requests` int(10) unsigned NOT NULL," | 302 | "`nodeuid` int(10) unsigned NOT NULL," |
311 | "`route_forwards` int(10) unsigned NOT NULL," | 303 | "`route_requests` int(10) unsigned NOT NULL," |
312 | "`result_requests` int(10) unsigned NOT NULL," | 304 | "`route_forwards` int(10) unsigned NOT NULL," |
313 | "`client_results` int(10) unsigned NOT NULL," | 305 | "`result_requests` int(10) unsigned NOT NULL," |
314 | "`result_forwards` int(10) unsigned NOT NULL," | 306 | "`client_results` int(10) unsigned NOT NULL," |
315 | "`gets` int(10) unsigned NOT NULL," | 307 | "`result_forwards` int(10) unsigned NOT NULL," |
316 | "`puts` int(10) unsigned NOT NULL," | 308 | "`gets` int(10) unsigned NOT NULL," "`puts` int(10) unsigned NOT NULL," |
317 | "`data_inserts` int(10) unsigned NOT NULL," | 309 | "`data_inserts` int(10) unsigned NOT NULL," |
318 | "`find_peer_requests` int(10) unsigned NOT NULL," | 310 | "`find_peer_requests` int(10) unsigned NOT NULL," |
319 | "`find_peers_started` int(10) unsigned NOT NULL," | 311 | "`find_peers_started` int(10) unsigned NOT NULL," |
320 | "`gets_started` int(10) unsigned NOT NULL," | 312 | "`gets_started` int(10) unsigned NOT NULL," |
321 | "`puts_started` int(10) unsigned NOT NULL," | 313 | "`puts_started` int(10) unsigned NOT NULL," |
322 | "`find_peer_responses_received` int(10) unsigned NOT NULL," | 314 | "`find_peer_responses_received` int(10) unsigned NOT NULL," |
323 | "`get_responses_received` int(10) unsigned NOT NULL," | 315 | "`get_responses_received` int(10) unsigned NOT NULL," |
324 | "`find_peer_responses_sent` int(10) unsigned NOT NULL," | 316 | "`find_peer_responses_sent` int(10) unsigned NOT NULL," |
325 | "`get_responses_sent` int(10) unsigned NOT NULL," | 317 | "`get_responses_sent` int(10) unsigned NOT NULL," |
326 | "PRIMARY KEY (`stat_uid`)" | 318 | "PRIMARY KEY (`stat_uid`)" |
327 | ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;")) | 319 | ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;")) |
328 | return GNUNET_SYSERR; | 320 | return GNUNET_SYSERR; |
329 | 321 | ||
330 | if (MRUNS ("SET AUTOCOMMIT = 1")) | 322 | if (MRUNS ("SET AUTOCOMMIT = 1")) |
@@ -388,37 +380,37 @@ iopen (struct GNUNET_DHTLOG_Plugin *plugin) | |||
388 | if (conn == NULL) | 380 | if (conn == NULL) |
389 | return GNUNET_SYSERR; | 381 | return GNUNET_SYSERR; |
390 | 382 | ||
391 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (plugin->cfg, | 383 | if (GNUNET_OK != |
392 | "MYSQL", "DATABASE", | 384 | GNUNET_CONFIGURATION_get_value_string (plugin->cfg, "MYSQL", "DATABASE", |
393 | &database)) | 385 | &database)) |
394 | { | 386 | { |
395 | database = GNUNET_strdup ("gnunet"); | 387 | database = GNUNET_strdup ("gnunet"); |
396 | } | 388 | } |
397 | 389 | ||
398 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (plugin->cfg, | 390 | if (GNUNET_OK != |
399 | "MYSQL", "USER", | 391 | GNUNET_CONFIGURATION_get_value_string (plugin->cfg, "MYSQL", "USER", |
400 | &user)) | 392 | &user)) |
401 | { | 393 | { |
402 | user = GNUNET_strdup ("dht"); | 394 | user = GNUNET_strdup ("dht"); |
403 | } | 395 | } |
404 | 396 | ||
405 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (plugin->cfg, | 397 | if (GNUNET_OK != |
406 | "MYSQL", "PASSWORD", | 398 | GNUNET_CONFIGURATION_get_value_string (plugin->cfg, "MYSQL", "PASSWORD", |
407 | &password)) | 399 | &password)) |
408 | { | 400 | { |
409 | password = GNUNET_strdup ("dhttest**"); | 401 | password = GNUNET_strdup ("dhttest**"); |
410 | } | 402 | } |
411 | 403 | ||
412 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (plugin->cfg, | 404 | if (GNUNET_OK != |
413 | "MYSQL", "SERVER", | 405 | GNUNET_CONFIGURATION_get_value_string (plugin->cfg, "MYSQL", "SERVER", |
414 | &server)) | 406 | &server)) |
415 | { | 407 | { |
416 | server = GNUNET_strdup ("localhost"); | 408 | server = GNUNET_strdup ("localhost"); |
417 | } | 409 | } |
418 | 410 | ||
419 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (plugin->cfg, | 411 | if (GNUNET_OK != |
420 | "MYSQL", "MYSQL_PORT", | 412 | GNUNET_CONFIGURATION_get_value_number (plugin->cfg, "MYSQL", "MYSQL_PORT", |
421 | &port)) | 413 | &port)) |
422 | { | 414 | { |
423 | port = 0; | 415 | port = 0; |
424 | } | 416 | } |
@@ -434,9 +426,8 @@ iopen (struct GNUNET_DHTLOG_Plugin *plugin) | |||
434 | mysql_options (conn, MYSQL_SET_CHARSET_NAME, "UTF8"); | 426 | mysql_options (conn, MYSQL_SET_CHARSET_NAME, "UTF8"); |
435 | mysql_options (conn, MYSQL_OPT_READ_TIMEOUT, (const void *) &timeout); | 427 | mysql_options (conn, MYSQL_OPT_READ_TIMEOUT, (const void *) &timeout); |
436 | mysql_options (conn, MYSQL_OPT_WRITE_TIMEOUT, (const void *) &timeout); | 428 | mysql_options (conn, MYSQL_OPT_WRITE_TIMEOUT, (const void *) &timeout); |
437 | mysql_real_connect (conn, server, user, password, | 429 | mysql_real_connect (conn, server, user, password, database, |
438 | database, (unsigned int) port, NULL, | 430 | (unsigned int) port, NULL, CLIENT_IGNORE_SIGPIPE); |
439 | CLIENT_IGNORE_SIGPIPE); | ||
440 | 431 | ||
441 | GNUNET_free_non_null (server); | 432 | GNUNET_free_non_null (server); |
442 | GNUNET_free_non_null (password); | 433 | GNUNET_free_non_null (password); |
@@ -508,8 +499,8 @@ prepare_statement (struct StatementHandle *ret) | |||
508 | 499 | ||
509 | if (mysql_stmt_prepare (ret->statement, ret->query, strlen (ret->query))) | 500 | if (mysql_stmt_prepare (ret->statement, ret->query, strlen (ret->query))) |
510 | { | 501 | { |
511 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 502 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "mysql_stmt_prepare `%s', %s", |
512 | "mysql_stmt_prepare `%s', %s", ret->query, mysql_error (conn)); | 503 | ret->query, mysql_error (conn)); |
513 | mysql_stmt_close (ret->statement); | 504 | mysql_stmt_close (ret->statement); |
514 | ret->statement = NULL; | 505 | ret->statement = NULL; |
515 | return GNUNET_SYSERR; | 506 | return GNUNET_SYSERR; |
@@ -588,8 +579,8 @@ init_params (struct StatementHandle *s, va_list ap) | |||
588 | { | 579 | { |
589 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 580 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
590 | _("`%s' failed at %s:%d with error: %s\n"), | 581 | _("`%s' failed at %s:%d with error: %s\n"), |
591 | "mysql_stmt_bind_param", | 582 | "mysql_stmt_bind_param", __FILE__, __LINE__, |
592 | __FILE__, __LINE__, mysql_stmt_error (s->statement)); | 583 | mysql_stmt_error (s->statement)); |
593 | return GNUNET_SYSERR; | 584 | return GNUNET_SYSERR; |
594 | } | 585 | } |
595 | 586 | ||
@@ -597,8 +588,8 @@ init_params (struct StatementHandle *s, va_list ap) | |||
597 | { | 588 | { |
598 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 589 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
599 | _("`%s' failed at %s:%d with error: %s\n"), | 590 | _("`%s' failed at %s:%d with error: %s\n"), |
600 | "mysql_stmt_execute", | 591 | "mysql_stmt_execute", __FILE__, __LINE__, |
601 | __FILE__, __LINE__, mysql_stmt_error (s->statement)); | 592 | mysql_stmt_error (s->statement)); |
602 | return GNUNET_SYSERR; | 593 | return GNUNET_SYSERR; |
603 | } | 594 | } |
604 | 595 | ||
@@ -623,10 +614,9 @@ init_params (struct StatementHandle *s, va_list ap) | |||
623 | */ | 614 | */ |
624 | int | 615 | int |
625 | prepared_statement_run_select (struct StatementHandle *s, | 616 | prepared_statement_run_select (struct StatementHandle *s, |
626 | unsigned int result_size, | 617 | unsigned int result_size, MYSQL_BIND * results, |
627 | MYSQL_BIND * results, | 618 | GNUNET_MysqlDataProcessor processor, |
628 | GNUNET_MysqlDataProcessor | 619 | void *processor_cls, ...) |
629 | processor, void *processor_cls, ...) | ||
630 | { | 620 | { |
631 | va_list ap; | 621 | va_list ap; |
632 | int ret; | 622 | int ret; |
@@ -656,8 +646,8 @@ prepared_statement_run_select (struct StatementHandle *s, | |||
656 | { | 646 | { |
657 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 647 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
658 | _("`%s' failed at %s:%d with error: %s\n"), | 648 | _("`%s' failed at %s:%d with error: %s\n"), |
659 | "mysql_stmt_bind_result", | 649 | "mysql_stmt_bind_result", __FILE__, __LINE__, |
660 | __FILE__, __LINE__, mysql_stmt_error (s->statement)); | 650 | mysql_stmt_error (s->statement)); |
661 | return GNUNET_SYSERR; | 651 | return GNUNET_SYSERR; |
662 | } | 652 | } |
663 | 653 | ||
@@ -671,8 +661,8 @@ prepared_statement_run_select (struct StatementHandle *s, | |||
671 | { | 661 | { |
672 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 662 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
673 | _("`%s' failed at %s:%d with error: %s\n"), | 663 | _("`%s' failed at %s:%d with error: %s\n"), |
674 | "mysql_stmt_fetch", | 664 | "mysql_stmt_fetch", __FILE__, __LINE__, |
675 | __FILE__, __LINE__, mysql_stmt_error (s->statement)); | 665 | mysql_stmt_error (s->statement)); |
676 | return GNUNET_SYSERR; | 666 | return GNUNET_SYSERR; |
677 | } | 667 | } |
678 | if (processor != NULL) | 668 | if (processor != NULL) |
@@ -700,17 +690,11 @@ get_node_uid (unsigned long long *nodeuid, const GNUNET_HashCode * peerHash) | |||
700 | GNUNET_CRYPTO_hash_to_enc (peerHash, &encPeer); | 690 | GNUNET_CRYPTO_hash_to_enc (peerHash, &encPeer); |
701 | p_len = strlen ((char *) &encPeer); | 691 | p_len = strlen ((char *) &encPeer); |
702 | 692 | ||
703 | if (1 != prepared_statement_run_select (get_nodeuid, | 693 | if (1 != |
704 | 1, | 694 | prepared_statement_run_select (get_nodeuid, 1, rbind, return_ok, NULL, |
705 | rbind, | 695 | MYSQL_TYPE_LONGLONG, ¤t_trial, |
706 | return_ok, | 696 | GNUNET_YES, MYSQL_TYPE_VAR_STRING, |
707 | NULL, | 697 | &encPeer, max_varchar_len, &p_len, -1)) |
708 | MYSQL_TYPE_LONGLONG, | ||
709 | ¤t_trial, | ||
710 | GNUNET_YES, | ||
711 | MYSQL_TYPE_VAR_STRING, | ||
712 | &encPeer, | ||
713 | max_varchar_len, &p_len, -1)) | ||
714 | { | 698 | { |
715 | #if DEBUG_DHTLOG | 699 | #if DEBUG_DHTLOG |
716 | fprintf (stderr, "FAILED\n"); | 700 | fprintf (stderr, "FAILED\n"); |
@@ -731,8 +715,8 @@ get_current_trial (unsigned long long *trialuid) | |||
731 | rbind[0].buffer = trialuid; | 715 | rbind[0].buffer = trialuid; |
732 | 716 | ||
733 | if ((GNUNET_OK != | 717 | if ((GNUNET_OK != |
734 | prepared_statement_run_select (get_trial, | 718 | prepared_statement_run_select (get_trial, 1, rbind, return_ok, NULL, |
735 | 1, rbind, return_ok, NULL, -1))) | 719 | -1))) |
736 | { | 720 | { |
737 | return GNUNET_SYSERR; | 721 | return GNUNET_SYSERR; |
738 | } | 722 | } |
@@ -751,8 +735,8 @@ get_current_topology (unsigned long long *topologyuid) | |||
751 | rbind[0].buffer = topologyuid; | 735 | rbind[0].buffer = topologyuid; |
752 | 736 | ||
753 | if ((GNUNET_OK != | 737 | if ((GNUNET_OK != |
754 | prepared_statement_run_select (get_topology, | 738 | prepared_statement_run_select (get_topology, 1, rbind, return_ok, NULL, |
755 | 1, rbind, return_ok, NULL, -1))) | 739 | -1))) |
756 | { | 740 | { |
757 | return GNUNET_SYSERR; | 741 | return GNUNET_SYSERR; |
758 | } | 742 | } |
@@ -779,16 +763,11 @@ get_dhtkey_uid (unsigned long long *dhtkeyuid, const GNUNET_HashCode * key) | |||
779 | current_trial); | 763 | current_trial); |
780 | #endif | 764 | #endif |
781 | if ((GNUNET_OK != | 765 | if ((GNUNET_OK != |
782 | prepared_statement_run_select (get_dhtkeyuid, | 766 | prepared_statement_run_select (get_dhtkeyuid, 1, rbind, return_ok, NULL, |
783 | 1, | 767 | MYSQL_TYPE_VAR_STRING, &encKey, |
784 | rbind, | 768 | max_varchar_len, &k_len, |
785 | return_ok, NULL, | 769 | MYSQL_TYPE_LONGLONG, ¤t_trial, |
786 | MYSQL_TYPE_VAR_STRING, | 770 | GNUNET_YES, -1))) |
787 | &encKey, | ||
788 | max_varchar_len, | ||
789 | &k_len, | ||
790 | MYSQL_TYPE_LONGLONG, | ||
791 | ¤t_trial, GNUNET_YES, -1))) | ||
792 | { | 771 | { |
793 | return GNUNET_SYSERR; | 772 | return GNUNET_SYSERR; |
794 | } | 773 | } |
@@ -860,51 +839,46 @@ add_trial (struct GNUNET_DHTLOG_TrialInfo *trial_info) | |||
860 | 839 | ||
861 | stmt = mysql_stmt_init (conn); | 840 | stmt = mysql_stmt_init (conn); |
862 | if (GNUNET_OK != | 841 | if (GNUNET_OK != |
863 | (ret = prepared_statement_run (insert_trial, ¤t_trial, | 842 | (ret = |
864 | MYSQL_TYPE_LONG, | 843 | prepared_statement_run (insert_trial, ¤t_trial, MYSQL_TYPE_LONG, |
865 | &trial_info->other_identifier, GNUNET_YES, | 844 | &trial_info->other_identifier, GNUNET_YES, |
866 | MYSQL_TYPE_LONG, &trial_info->num_nodes, | 845 | MYSQL_TYPE_LONG, &trial_info->num_nodes, |
867 | GNUNET_YES, MYSQL_TYPE_LONG, | 846 | GNUNET_YES, MYSQL_TYPE_LONG, |
868 | &trial_info->topology, GNUNET_YES, | 847 | &trial_info->topology, GNUNET_YES, |
869 | MYSQL_TYPE_FLOAT, | 848 | MYSQL_TYPE_FLOAT, |
870 | &trial_info->topology_percentage, | 849 | &trial_info->topology_percentage, |
871 | MYSQL_TYPE_FLOAT, | 850 | MYSQL_TYPE_FLOAT, |
872 | &trial_info->topology_probability, | 851 | &trial_info->topology_probability, |
873 | MYSQL_TYPE_LONG, | 852 | MYSQL_TYPE_LONG, &trial_info->blacklist_topology, |
874 | &trial_info->blacklist_topology, | 853 | GNUNET_YES, MYSQL_TYPE_LONG, |
875 | GNUNET_YES, MYSQL_TYPE_LONG, | 854 | &trial_info->connect_topology, GNUNET_YES, |
876 | &trial_info->connect_topology, GNUNET_YES, | 855 | MYSQL_TYPE_LONG, |
877 | MYSQL_TYPE_LONG, | 856 | &trial_info->connect_topology_option, GNUNET_YES, |
878 | &trial_info->connect_topology_option, | 857 | MYSQL_TYPE_FLOAT, |
879 | GNUNET_YES, MYSQL_TYPE_FLOAT, | 858 | &trial_info->connect_topology_option_modifier, |
880 | &trial_info->connect_topology_option_modifier, | 859 | MYSQL_TYPE_LONG, &trial_info->puts, GNUNET_YES, |
881 | MYSQL_TYPE_LONG, &trial_info->puts, | 860 | MYSQL_TYPE_LONG, &trial_info->gets, GNUNET_YES, |
882 | GNUNET_YES, MYSQL_TYPE_LONG, | 861 | MYSQL_TYPE_LONG, &trial_info->concurrent, |
883 | &trial_info->gets, GNUNET_YES, | 862 | GNUNET_YES, MYSQL_TYPE_LONG, |
884 | MYSQL_TYPE_LONG, &trial_info->concurrent, | 863 | &trial_info->settle_time, GNUNET_YES, |
885 | GNUNET_YES, MYSQL_TYPE_LONG, | 864 | MYSQL_TYPE_LONG, &trial_info->num_rounds, |
886 | &trial_info->settle_time, GNUNET_YES, | 865 | GNUNET_YES, MYSQL_TYPE_LONG, |
887 | MYSQL_TYPE_LONG, &trial_info->num_rounds, | 866 | &trial_info->malicious_getters, GNUNET_YES, |
888 | GNUNET_YES, MYSQL_TYPE_LONG, | 867 | MYSQL_TYPE_LONG, &trial_info->malicious_putters, |
889 | &trial_info->malicious_getters, GNUNET_YES, | 868 | GNUNET_YES, MYSQL_TYPE_LONG, |
890 | MYSQL_TYPE_LONG, | 869 | &trial_info->malicious_droppers, GNUNET_YES, |
891 | &trial_info->malicious_putters, GNUNET_YES, | 870 | MYSQL_TYPE_LONG, |
892 | MYSQL_TYPE_LONG, | 871 | &trial_info->malicious_get_frequency, GNUNET_YES, |
893 | &trial_info->malicious_droppers, | 872 | MYSQL_TYPE_LONG, |
894 | GNUNET_YES, MYSQL_TYPE_LONG, | 873 | &trial_info->malicious_put_frequency, GNUNET_YES, |
895 | &trial_info->malicious_get_frequency, | 874 | MYSQL_TYPE_LONG, &trial_info->stop_closest, |
896 | GNUNET_YES, MYSQL_TYPE_LONG, | 875 | GNUNET_YES, MYSQL_TYPE_LONG, |
897 | &trial_info->malicious_put_frequency, | 876 | &trial_info->stop_found, GNUNET_YES, |
898 | GNUNET_YES, MYSQL_TYPE_LONG, | 877 | MYSQL_TYPE_LONG, &trial_info->strict_kademlia, |
899 | &trial_info->stop_closest, GNUNET_YES, | 878 | GNUNET_YES, MYSQL_TYPE_LONG, |
900 | MYSQL_TYPE_LONG, &trial_info->stop_found, | 879 | &trial_info->gets_succeeded, GNUNET_YES, |
901 | GNUNET_YES, MYSQL_TYPE_LONG, | 880 | MYSQL_TYPE_BLOB, trial_info->message, |
902 | &trial_info->strict_kademlia, GNUNET_YES, | 881 | max_varchar_len + max_varchar_len, &m_len, -1))) |
903 | MYSQL_TYPE_LONG, | ||
904 | &trial_info->gets_succeeded, GNUNET_YES, | ||
905 | MYSQL_TYPE_BLOB, trial_info->message, | ||
906 | max_varchar_len + max_varchar_len, &m_len, | ||
907 | -1))) | ||
908 | { | 882 | { |
909 | if (ret == GNUNET_SYSERR) | 883 | if (ret == GNUNET_SYSERR) |
910 | { | 884 | { |
@@ -935,11 +909,11 @@ add_round (unsigned int round_type, unsigned int round_count) | |||
935 | int ret; | 909 | int ret; |
936 | 910 | ||
937 | stmt = mysql_stmt_init (conn); | 911 | stmt = mysql_stmt_init (conn); |
938 | ret = prepared_statement_run (insert_round, | 912 | ret = |
939 | NULL, | 913 | prepared_statement_run (insert_round, NULL, MYSQL_TYPE_LONGLONG, |
940 | MYSQL_TYPE_LONGLONG, ¤t_trial, GNUNET_YES, | 914 | ¤t_trial, GNUNET_YES, MYSQL_TYPE_LONG, |
941 | MYSQL_TYPE_LONG, &round_type, GNUNET_YES, | 915 | &round_type, GNUNET_YES, MYSQL_TYPE_LONG, |
942 | MYSQL_TYPE_LONG, &round_count, GNUNET_YES, -1); | 916 | &round_count, GNUNET_YES, -1); |
943 | mysql_stmt_close (stmt); | 917 | mysql_stmt_close (stmt); |
944 | if (ret != GNUNET_OK) | 918 | if (ret != GNUNET_OK) |
945 | return GNUNET_SYSERR; | 919 | return GNUNET_SYSERR; |
@@ -966,14 +940,13 @@ add_round_details (unsigned int round_type, unsigned int round_count, | |||
966 | int ret; | 940 | int ret; |
967 | 941 | ||
968 | stmt = mysql_stmt_init (conn); | 942 | stmt = mysql_stmt_init (conn); |
969 | ret = prepared_statement_run (insert_round_details, | 943 | ret = |
970 | NULL, | 944 | prepared_statement_run (insert_round_details, NULL, MYSQL_TYPE_LONGLONG, |
971 | MYSQL_TYPE_LONGLONG, ¤t_trial, GNUNET_YES, | 945 | ¤t_trial, GNUNET_YES, MYSQL_TYPE_LONG, |
972 | MYSQL_TYPE_LONG, &round_type, GNUNET_YES, | 946 | &round_type, GNUNET_YES, MYSQL_TYPE_LONG, |
973 | MYSQL_TYPE_LONG, &round_count, GNUNET_YES, | 947 | &round_count, GNUNET_YES, MYSQL_TYPE_LONG, |
974 | MYSQL_TYPE_LONG, &num_messages, GNUNET_YES, | 948 | &num_messages, GNUNET_YES, MYSQL_TYPE_LONG, |
975 | MYSQL_TYPE_LONG, &num_messages_succeeded, | 949 | &num_messages_succeeded, GNUNET_YES, -1); |
976 | GNUNET_YES, -1); | ||
977 | mysql_stmt_close (stmt); | 950 | mysql_stmt_close (stmt); |
978 | if (ret != GNUNET_OK) | 951 | if (ret != GNUNET_OK) |
979 | return GNUNET_SYSERR; | 952 | return GNUNET_SYSERR; |
@@ -1007,10 +980,10 @@ int | |||
1007 | add_stat (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests, | 980 | add_stat (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests, |
1008 | unsigned int route_forwards, unsigned int result_requests, | 981 | unsigned int route_forwards, unsigned int result_requests, |
1009 | unsigned int client_requests, unsigned int result_forwards, | 982 | unsigned int client_requests, unsigned int result_forwards, |
1010 | unsigned int gets, unsigned int puts, | 983 | unsigned int gets, unsigned int puts, unsigned int data_inserts, |
1011 | unsigned int data_inserts, unsigned int find_peer_requests, | 984 | unsigned int find_peer_requests, unsigned int find_peers_started, |
1012 | unsigned int find_peers_started, unsigned int gets_started, | 985 | unsigned int gets_started, unsigned int puts_started, |
1013 | unsigned int puts_started, unsigned int find_peer_responses_received, | 986 | unsigned int find_peer_responses_received, |
1014 | unsigned int get_responses_received, | 987 | unsigned int get_responses_received, |
1015 | unsigned int find_peer_responses_sent, | 988 | unsigned int find_peer_responses_sent, |
1016 | unsigned int get_responses_sent) | 989 | unsigned int get_responses_sent) |
@@ -1030,33 +1003,28 @@ add_stat (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests, | |||
1030 | 1003 | ||
1031 | stmt = mysql_stmt_init (conn); | 1004 | stmt = mysql_stmt_init (conn); |
1032 | if (GNUNET_OK != | 1005 | if (GNUNET_OK != |
1033 | (ret = prepared_statement_run (insert_stat, | 1006 | (ret = |
1034 | &return_uid, | 1007 | prepared_statement_run (insert_stat, &return_uid, MYSQL_TYPE_LONGLONG, |
1035 | MYSQL_TYPE_LONGLONG, ¤t_trial, | 1008 | ¤t_trial, GNUNET_YES, MYSQL_TYPE_LONGLONG, |
1036 | GNUNET_YES, MYSQL_TYPE_LONGLONG, &peer_uid, | 1009 | &peer_uid, GNUNET_YES, MYSQL_TYPE_LONG, |
1037 | GNUNET_YES, MYSQL_TYPE_LONG, | 1010 | &route_requests, GNUNET_YES, MYSQL_TYPE_LONG, |
1038 | &route_requests, GNUNET_YES, | 1011 | &route_forwards, GNUNET_YES, MYSQL_TYPE_LONG, |
1039 | MYSQL_TYPE_LONG, &route_forwards, | 1012 | &result_requests, GNUNET_YES, MYSQL_TYPE_LONG, |
1040 | GNUNET_YES, MYSQL_TYPE_LONG, | 1013 | &client_requests, GNUNET_YES, MYSQL_TYPE_LONG, |
1041 | &result_requests, GNUNET_YES, | 1014 | &result_forwards, GNUNET_YES, MYSQL_TYPE_LONG, |
1042 | MYSQL_TYPE_LONG, &client_requests, | 1015 | &gets, GNUNET_YES, MYSQL_TYPE_LONG, &puts, |
1043 | GNUNET_YES, MYSQL_TYPE_LONG, | 1016 | GNUNET_YES, MYSQL_TYPE_LONG, &data_inserts, |
1044 | &result_forwards, GNUNET_YES, | 1017 | GNUNET_YES, MYSQL_TYPE_LONG, &find_peer_requests, |
1045 | MYSQL_TYPE_LONG, &gets, GNUNET_YES, | 1018 | GNUNET_YES, MYSQL_TYPE_LONG, &find_peers_started, |
1046 | MYSQL_TYPE_LONG, &puts, GNUNET_YES, | 1019 | GNUNET_YES, MYSQL_TYPE_LONG, &gets_started, |
1047 | MYSQL_TYPE_LONG, &data_inserts, GNUNET_YES, | 1020 | GNUNET_YES, MYSQL_TYPE_LONG, &puts_started, |
1048 | MYSQL_TYPE_LONG, &find_peer_requests, | 1021 | GNUNET_YES, MYSQL_TYPE_LONG, |
1049 | GNUNET_YES, MYSQL_TYPE_LONG, | 1022 | &find_peer_responses_received, GNUNET_YES, |
1050 | &find_peers_started, GNUNET_YES, | 1023 | MYSQL_TYPE_LONG, &get_responses_received, |
1051 | MYSQL_TYPE_LONG, &gets_started, GNUNET_YES, | 1024 | GNUNET_YES, MYSQL_TYPE_LONG, |
1052 | MYSQL_TYPE_LONG, &puts_started, GNUNET_YES, | 1025 | &find_peer_responses_sent, GNUNET_YES, |
1053 | MYSQL_TYPE_LONG, | 1026 | MYSQL_TYPE_LONG, &get_responses_sent, GNUNET_YES, |
1054 | &find_peer_responses_received, GNUNET_YES, | 1027 | -1))) |
1055 | MYSQL_TYPE_LONG, &get_responses_received, | ||
1056 | GNUNET_YES, MYSQL_TYPE_LONG, | ||
1057 | &find_peer_responses_sent, GNUNET_YES, | ||
1058 | MYSQL_TYPE_LONG, &get_responses_sent, | ||
1059 | GNUNET_YES, -1))) | ||
1060 | { | 1028 | { |
1061 | if (ret == GNUNET_SYSERR) | 1029 | if (ret == GNUNET_SYSERR) |
1062 | { | 1030 | { |
@@ -1080,8 +1048,8 @@ add_stat (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests, | |||
1080 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure | 1048 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure |
1081 | */ | 1049 | */ |
1082 | int | 1050 | int |
1083 | add_generic_stat (const struct GNUNET_PeerIdentity *peer, | 1051 | add_generic_stat (const struct GNUNET_PeerIdentity *peer, const char *name, |
1084 | const char *name, const char *section, uint64_t value) | 1052 | const char *section, uint64_t value) |
1085 | { | 1053 | { |
1086 | unsigned long long peer_uid; | 1054 | unsigned long long peer_uid; |
1087 | unsigned long long section_len; | 1055 | unsigned long long section_len; |
@@ -1100,16 +1068,14 @@ add_generic_stat (const struct GNUNET_PeerIdentity *peer, | |||
1100 | name_len = strlen (name); | 1068 | name_len = strlen (name); |
1101 | 1069 | ||
1102 | if (GNUNET_OK != | 1070 | if (GNUNET_OK != |
1103 | (ret = prepared_statement_run (insert_generic_stat, | 1071 | (ret = |
1104 | NULL, | 1072 | prepared_statement_run (insert_generic_stat, NULL, MYSQL_TYPE_LONGLONG, |
1105 | MYSQL_TYPE_LONGLONG, ¤t_trial, | 1073 | ¤t_trial, GNUNET_YES, MYSQL_TYPE_LONGLONG, |
1106 | GNUNET_YES, MYSQL_TYPE_LONGLONG, &peer_uid, | 1074 | &peer_uid, GNUNET_YES, MYSQL_TYPE_VAR_STRING, |
1107 | GNUNET_YES, MYSQL_TYPE_VAR_STRING, | 1075 | §ion, max_varchar_len, §ion_len, |
1108 | §ion, max_varchar_len, §ion_len, | 1076 | MYSQL_TYPE_VAR_STRING, &name, max_varchar_len, |
1109 | MYSQL_TYPE_VAR_STRING, &name, | 1077 | &name_len, MYSQL_TYPE_LONGLONG, &value, |
1110 | max_varchar_len, &name_len, | 1078 | GNUNET_YES, -1))) |
1111 | MYSQL_TYPE_LONGLONG, &value, GNUNET_YES, | ||
1112 | -1))) | ||
1113 | { | 1079 | { |
1114 | if (ret == GNUNET_SYSERR) | 1080 | if (ret == GNUNET_SYSERR) |
1115 | { | 1081 | { |
@@ -1157,18 +1123,12 @@ add_dhtkey (unsigned long long *dhtkeyuid, const GNUNET_HashCode * dhtkey) | |||
1157 | } | 1123 | } |
1158 | 1124 | ||
1159 | if (GNUNET_OK != | 1125 | if (GNUNET_OK != |
1160 | (ret = prepared_statement_run (insert_dhtkey, | 1126 | (ret = |
1161 | dhtkeyuid, | 1127 | prepared_statement_run (insert_dhtkey, dhtkeyuid, MYSQL_TYPE_VAR_STRING, |
1162 | MYSQL_TYPE_VAR_STRING, | 1128 | &encKey, max_varchar_len, &k_len, |
1163 | &encKey, | 1129 | MYSQL_TYPE_LONG, ¤t_trial, GNUNET_YES, |
1164 | max_varchar_len, | 1130 | MYSQL_TYPE_BLOB, dhtkey, |
1165 | &k_len, | 1131 | sizeof (GNUNET_HashCode), &h_len, -1))) |
1166 | MYSQL_TYPE_LONG, | ||
1167 | ¤t_trial, | ||
1168 | GNUNET_YES, | ||
1169 | MYSQL_TYPE_BLOB, | ||
1170 | dhtkey, | ||
1171 | sizeof (GNUNET_HashCode), &h_len, -1))) | ||
1172 | { | 1132 | { |
1173 | if (ret == GNUNET_SYSERR) | 1133 | if (ret == GNUNET_SYSERR) |
1174 | { | 1134 | { |
@@ -1204,13 +1164,12 @@ add_node (unsigned long long *nodeuid, struct GNUNET_PeerIdentity *node) | |||
1204 | p_len = (unsigned long) strlen ((char *) &encPeer); | 1164 | p_len = (unsigned long) strlen ((char *) &encPeer); |
1205 | h_len = sizeof (GNUNET_HashCode); | 1165 | h_len = sizeof (GNUNET_HashCode); |
1206 | if (GNUNET_OK != | 1166 | if (GNUNET_OK != |
1207 | (ret = prepared_statement_run (insert_node, | 1167 | (ret = |
1208 | nodeuid, | 1168 | prepared_statement_run (insert_node, nodeuid, MYSQL_TYPE_LONGLONG, |
1209 | MYSQL_TYPE_LONGLONG, ¤t_trial, | 1169 | ¤t_trial, GNUNET_YES, |
1210 | GNUNET_YES, MYSQL_TYPE_VAR_STRING, | 1170 | MYSQL_TYPE_VAR_STRING, &encPeer, max_varchar_len, |
1211 | &encPeer, max_varchar_len, &p_len, | 1171 | &p_len, MYSQL_TYPE_BLOB, &node->hashPubKey, |
1212 | MYSQL_TYPE_BLOB, &node->hashPubKey, | 1172 | sizeof (GNUNET_HashCode), &h_len, -1))) |
1213 | sizeof (GNUNET_HashCode), &h_len, -1))) | ||
1214 | { | 1173 | { |
1215 | if (ret == GNUNET_SYSERR) | 1174 | if (ret == GNUNET_SYSERR) |
1216 | { | 1175 | { |
@@ -1233,11 +1192,10 @@ update_trials (unsigned int gets_succeeded) | |||
1233 | int ret; | 1192 | int ret; |
1234 | 1193 | ||
1235 | if (GNUNET_OK != | 1194 | if (GNUNET_OK != |
1236 | (ret = prepared_statement_run (update_trial, | 1195 | (ret = |
1237 | NULL, | 1196 | prepared_statement_run (update_trial, NULL, MYSQL_TYPE_LONG, |
1238 | MYSQL_TYPE_LONG, &gets_succeeded, | 1197 | &gets_succeeded, GNUNET_YES, MYSQL_TYPE_LONGLONG, |
1239 | GNUNET_YES, MYSQL_TYPE_LONGLONG, | 1198 | ¤t_trial, GNUNET_YES, -1))) |
1240 | ¤t_trial, GNUNET_YES, -1))) | ||
1241 | { | 1199 | { |
1242 | if (ret == GNUNET_SYSERR) | 1200 | if (ret == GNUNET_SYSERR) |
1243 | { | 1201 | { |
@@ -1270,11 +1228,11 @@ set_malicious (struct GNUNET_PeerIdentity *peer) | |||
1270 | p_len = strlen (temp_str); | 1228 | p_len = strlen (temp_str); |
1271 | 1229 | ||
1272 | if (GNUNET_OK != | 1230 | if (GNUNET_OK != |
1273 | (ret = prepared_statement_run (update_node_malicious, | 1231 | (ret = |
1274 | NULL, | 1232 | prepared_statement_run (update_node_malicious, NULL, MYSQL_TYPE_LONGLONG, |
1275 | MYSQL_TYPE_LONGLONG, ¤t_trial, | 1233 | ¤t_trial, GNUNET_YES, |
1276 | GNUNET_YES, MYSQL_TYPE_VAR_STRING, | 1234 | MYSQL_TYPE_VAR_STRING, temp_str, max_varchar_len, |
1277 | temp_str, max_varchar_len, &p_len, -1))) | 1235 | &p_len, -1))) |
1278 | { | 1236 | { |
1279 | if (ret == GNUNET_SYSERR) | 1237 | if (ret == GNUNET_SYSERR) |
1280 | { | 1238 | { |
@@ -1298,13 +1256,11 @@ add_connections (unsigned int totalConnections) | |||
1298 | int ret; | 1256 | int ret; |
1299 | 1257 | ||
1300 | if (GNUNET_OK != | 1258 | if (GNUNET_OK != |
1301 | (ret = prepared_statement_run (update_connection, | 1259 | (ret = |
1302 | NULL, | 1260 | prepared_statement_run (update_connection, NULL, MYSQL_TYPE_LONG, |
1303 | MYSQL_TYPE_LONG, | 1261 | &totalConnections, GNUNET_YES, |
1304 | &totalConnections, | 1262 | MYSQL_TYPE_LONGLONG, ¤t_trial, GNUNET_YES, |
1305 | GNUNET_YES, | 1263 | -1))) |
1306 | MYSQL_TYPE_LONGLONG, | ||
1307 | ¤t_trial, GNUNET_YES, -1))) | ||
1308 | { | 1264 | { |
1309 | if (ret == GNUNET_SYSERR) | 1265 | if (ret == GNUNET_SYSERR) |
1310 | { | 1266 | { |
@@ -1341,8 +1297,8 @@ add_query (unsigned long long *sqlqueryuid, unsigned long long queryid, | |||
1341 | peer_uid = 0; | 1297 | peer_uid = 0; |
1342 | key_uid = 0; | 1298 | key_uid = 0; |
1343 | 1299 | ||
1344 | if ((node != NULL) | 1300 | if ((node != NULL) && |
1345 | && (GNUNET_OK == get_node_uid (&peer_uid, &node->hashPubKey))) | 1301 | (GNUNET_OK == get_node_uid (&peer_uid, &node->hashPubKey))) |
1346 | { | 1302 | { |
1347 | 1303 | ||
1348 | } | 1304 | } |
@@ -1365,28 +1321,15 @@ add_query (unsigned long long *sqlqueryuid, unsigned long long queryid, | |||
1365 | } | 1321 | } |
1366 | 1322 | ||
1367 | if (GNUNET_OK != | 1323 | if (GNUNET_OK != |
1368 | (ret = prepared_statement_run (insert_query, | 1324 | (ret = |
1369 | sqlqueryuid, | 1325 | prepared_statement_run (insert_query, sqlqueryuid, MYSQL_TYPE_LONGLONG, |
1370 | MYSQL_TYPE_LONGLONG, | 1326 | ¤t_trial, GNUNET_YES, MYSQL_TYPE_LONG, |
1371 | ¤t_trial, | 1327 | &type, GNUNET_NO, MYSQL_TYPE_LONG, &hops, |
1372 | GNUNET_YES, | 1328 | GNUNET_YES, MYSQL_TYPE_LONGLONG, &key_uid, |
1373 | MYSQL_TYPE_LONG, | 1329 | GNUNET_YES, MYSQL_TYPE_LONGLONG, &queryid, |
1374 | &type, | 1330 | GNUNET_YES, MYSQL_TYPE_LONG, &succeeded, |
1375 | GNUNET_NO, | 1331 | GNUNET_NO, MYSQL_TYPE_LONGLONG, &peer_uid, |
1376 | MYSQL_TYPE_LONG, | 1332 | GNUNET_YES, -1))) |
1377 | &hops, | ||
1378 | GNUNET_YES, | ||
1379 | MYSQL_TYPE_LONGLONG, | ||
1380 | &key_uid, | ||
1381 | GNUNET_YES, | ||
1382 | MYSQL_TYPE_LONGLONG, | ||
1383 | &queryid, | ||
1384 | GNUNET_YES, | ||
1385 | MYSQL_TYPE_LONG, | ||
1386 | &succeeded, | ||
1387 | GNUNET_NO, | ||
1388 | MYSQL_TYPE_LONGLONG, | ||
1389 | &peer_uid, GNUNET_YES, -1))) | ||
1390 | { | 1333 | { |
1391 | if (ret == GNUNET_SYSERR) | 1334 | if (ret == GNUNET_SYSERR) |
1392 | { | 1335 | { |
@@ -1416,9 +1359,8 @@ add_query (unsigned long long *sqlqueryuid, unsigned long long queryid, | |||
1416 | */ | 1359 | */ |
1417 | int | 1360 | int |
1418 | add_route (unsigned long long *sqlqueryuid, unsigned long long queryid, | 1361 | add_route (unsigned long long *sqlqueryuid, unsigned long long queryid, |
1419 | unsigned int type, unsigned int hops, | 1362 | unsigned int type, unsigned int hops, int succeeded, |
1420 | int succeeded, const struct GNUNET_PeerIdentity *node, | 1363 | const struct GNUNET_PeerIdentity *node, const GNUNET_HashCode * key, |
1421 | const GNUNET_HashCode * key, | ||
1422 | const struct GNUNET_PeerIdentity *from_node, | 1364 | const struct GNUNET_PeerIdentity *from_node, |
1423 | const struct GNUNET_PeerIdentity *to_node) | 1365 | const struct GNUNET_PeerIdentity *to_node) |
1424 | { | 1366 | { |
@@ -1457,34 +1399,17 @@ add_route (unsigned long long *sqlqueryuid, unsigned long long queryid, | |||
1457 | return GNUNET_SYSERR; | 1399 | return GNUNET_SYSERR; |
1458 | 1400 | ||
1459 | if (GNUNET_OK != | 1401 | if (GNUNET_OK != |
1460 | (ret = prepared_statement_run (insert_route, | 1402 | (ret = |
1461 | sqlqueryuid, | 1403 | prepared_statement_run (insert_route, sqlqueryuid, MYSQL_TYPE_LONGLONG, |
1462 | MYSQL_TYPE_LONGLONG, | 1404 | ¤t_trial, GNUNET_YES, MYSQL_TYPE_LONG, |
1463 | ¤t_trial, | 1405 | &type, GNUNET_NO, MYSQL_TYPE_LONG, &hops, |
1464 | GNUNET_YES, | 1406 | GNUNET_YES, MYSQL_TYPE_LONGLONG, &key_uid, |
1465 | MYSQL_TYPE_LONG, | 1407 | GNUNET_YES, MYSQL_TYPE_LONGLONG, &queryid, |
1466 | &type, | 1408 | GNUNET_YES, MYSQL_TYPE_LONG, &succeeded, |
1467 | GNUNET_NO, | 1409 | GNUNET_NO, MYSQL_TYPE_LONGLONG, &peer_uid, |
1468 | MYSQL_TYPE_LONG, | 1410 | GNUNET_YES, MYSQL_TYPE_LONGLONG, &from_uid, |
1469 | &hops, | 1411 | GNUNET_YES, MYSQL_TYPE_LONGLONG, &to_uid, |
1470 | GNUNET_YES, | 1412 | GNUNET_YES, -1))) |
1471 | MYSQL_TYPE_LONGLONG, | ||
1472 | &key_uid, | ||
1473 | GNUNET_YES, | ||
1474 | MYSQL_TYPE_LONGLONG, | ||
1475 | &queryid, | ||
1476 | GNUNET_YES, | ||
1477 | MYSQL_TYPE_LONG, | ||
1478 | &succeeded, | ||
1479 | GNUNET_NO, | ||
1480 | MYSQL_TYPE_LONGLONG, | ||
1481 | &peer_uid, | ||
1482 | GNUNET_YES, | ||
1483 | MYSQL_TYPE_LONGLONG, | ||
1484 | &from_uid, | ||
1485 | GNUNET_YES, | ||
1486 | MYSQL_TYPE_LONGLONG, | ||
1487 | &to_uid, GNUNET_YES, -1))) | ||
1488 | { | 1413 | { |
1489 | if (ret == GNUNET_SYSERR) | 1414 | if (ret == GNUNET_SYSERR) |
1490 | { | 1415 | { |
@@ -1513,13 +1438,10 @@ update_current_topology (unsigned int connections) | |||
1513 | get_current_topology (&topologyuid); | 1438 | get_current_topology (&topologyuid); |
1514 | 1439 | ||
1515 | if (GNUNET_OK != | 1440 | if (GNUNET_OK != |
1516 | (ret = prepared_statement_run (update_topology, | 1441 | (ret = |
1517 | NULL, | 1442 | prepared_statement_run (update_topology, NULL, MYSQL_TYPE_LONG, |
1518 | MYSQL_TYPE_LONG, | 1443 | &connections, GNUNET_YES, MYSQL_TYPE_LONGLONG, |
1519 | &connections, | 1444 | &topologyuid, GNUNET_YES, -1))) |
1520 | GNUNET_YES, | ||
1521 | MYSQL_TYPE_LONGLONG, | ||
1522 | &topologyuid, GNUNET_YES, -1))) | ||
1523 | { | 1445 | { |
1524 | if (ret == GNUNET_SYSERR) | 1446 | if (ret == GNUNET_SYSERR) |
1525 | { | 1447 | { |
@@ -1545,11 +1467,10 @@ add_topology (int num_connections) | |||
1545 | int ret; | 1467 | int ret; |
1546 | 1468 | ||
1547 | if (GNUNET_OK != | 1469 | if (GNUNET_OK != |
1548 | (ret = prepared_statement_run (insert_topology, | 1470 | (ret = |
1549 | NULL, | 1471 | prepared_statement_run (insert_topology, NULL, MYSQL_TYPE_LONGLONG, |
1550 | MYSQL_TYPE_LONGLONG, ¤t_trial, | 1472 | ¤t_trial, GNUNET_YES, MYSQL_TYPE_LONG, |
1551 | GNUNET_YES, MYSQL_TYPE_LONG, | 1473 | &num_connections, GNUNET_YES, -1))) |
1552 | &num_connections, GNUNET_YES, -1))) | ||
1553 | { | 1474 | { |
1554 | if (ret == GNUNET_SYSERR) | 1475 | if (ret == GNUNET_SYSERR) |
1555 | { | 1476 | { |
@@ -1586,16 +1507,11 @@ add_extended_topology (const struct GNUNET_PeerIdentity *first, | |||
1586 | return GNUNET_SYSERR; | 1507 | return GNUNET_SYSERR; |
1587 | 1508 | ||
1588 | if (GNUNET_OK != | 1509 | if (GNUNET_OK != |
1589 | (ret = prepared_statement_run (extend_topology, | 1510 | (ret = |
1590 | NULL, | 1511 | prepared_statement_run (extend_topology, NULL, MYSQL_TYPE_LONGLONG, |
1591 | MYSQL_TYPE_LONGLONG, | 1512 | &topologyuid, GNUNET_YES, MYSQL_TYPE_LONGLONG, |
1592 | &topologyuid, | 1513 | &first_uid, GNUNET_YES, MYSQL_TYPE_LONGLONG, |
1593 | GNUNET_YES, | 1514 | &second_uid, GNUNET_YES, -1))) |
1594 | MYSQL_TYPE_LONGLONG, | ||
1595 | &first_uid, | ||
1596 | GNUNET_YES, | ||
1597 | MYSQL_TYPE_LONGLONG, | ||
1598 | &second_uid, GNUNET_YES, -1))) | ||
1599 | { | 1515 | { |
1600 | if (ret == GNUNET_SYSERR) | 1516 | if (ret == GNUNET_SYSERR) |
1601 | { | 1517 | { |
diff --git a/src/dht/plugin_dhtlog_mysql_dump.c b/src/dht/plugin_dhtlog_mysql_dump.c index 25958044c..bbb1da0c9 100644 --- a/src/dht/plugin_dhtlog_mysql_dump.c +++ b/src/dht/plugin_dhtlog_mysql_dump.c | |||
@@ -162,24 +162,16 @@ static int | |||
162 | iopen () | 162 | iopen () |
163 | { | 163 | { |
164 | #define PINIT(a) (GNUNET_OK != (prepared_statement_create(a))) | 164 | #define PINIT(a) (GNUNET_OK != (prepared_statement_create(a))) |
165 | if (PINIT (INSERT_QUERIES_STMT) || | 165 | if (PINIT (INSERT_QUERIES_STMT) || PINIT (INSERT_ROUTES_STMT) || |
166 | PINIT (INSERT_ROUTES_STMT) || | 166 | PINIT (INSERT_ROUND_STMT) || PINIT (INSERT_ROUND_DETAILS_STMT) || |
167 | PINIT (INSERT_ROUND_STMT) || | 167 | PINIT (INSERT_TRIALS_STMT) || PINIT (SET_MALICIOUS_STMT) || |
168 | PINIT (INSERT_ROUND_DETAILS_STMT) || | 168 | PINIT (INSERT_GENERIC_STAT_STMT) || PINIT (INSERT_STAT_STMT) || |
169 | PINIT (INSERT_TRIALS_STMT) || | 169 | PINIT (INSERT_NODES_STMT) || PINIT (INSERT_DHTKEY_STMT) || |
170 | PINIT (SET_MALICIOUS_STMT) || | 170 | PINIT (UPDATE_TRIALS_STMT) || PINIT (GET_DHTKEYUID_STMT) || |
171 | PINIT (INSERT_GENERIC_STAT_STMT) || | 171 | PINIT (GET_NODEUID_STMT) || PINIT (UPDATE_CONNECTIONS_STMT) || |
172 | PINIT (INSERT_STAT_STMT) || | 172 | PINIT (INSERT_TOPOLOGY_STMT) || PINIT (EXTEND_TOPOLOGY_STMT) || |
173 | PINIT (INSERT_NODES_STMT) || | 173 | PINIT (UPDATE_TOPOLOGY_STMT) || PINIT (GET_TRIAL_STMT) || |
174 | PINIT (INSERT_DHTKEY_STMT) || | 174 | PINIT (GET_TOPOLOGY_STMT)) |
175 | PINIT (UPDATE_TRIALS_STMT) || | ||
176 | PINIT (GET_DHTKEYUID_STMT) || | ||
177 | PINIT (GET_NODEUID_STMT) || | ||
178 | PINIT (UPDATE_CONNECTIONS_STMT) || | ||
179 | PINIT (INSERT_TOPOLOGY_STMT) || | ||
180 | PINIT (EXTEND_TOPOLOGY_STMT) || | ||
181 | PINIT (UPDATE_TOPOLOGY_STMT) || | ||
182 | PINIT (GET_TRIAL_STMT) || PINIT (GET_TOPOLOGY_STMT)) | ||
183 | { | 175 | { |
184 | return GNUNET_SYSERR; | 176 | return GNUNET_SYSERR; |
185 | } | 177 | } |
@@ -325,8 +317,10 @@ add_extended_topology (const struct GNUNET_PeerIdentity *first, | |||
325 | if (ret < 0) | 317 | if (ret < 0) |
326 | return GNUNET_SYSERR; | 318 | return GNUNET_SYSERR; |
327 | 319 | ||
328 | ret = fprintf (outfile, "execute extend_topology using " | 320 | ret = |
329 | "@temp_first_node, @temp_second_node;\n"); | 321 | fprintf (outfile, |
322 | "execute extend_topology using " | ||
323 | "@temp_first_node, @temp_second_node;\n"); | ||
330 | 324 | ||
331 | if (ret >= 0) | 325 | if (ret >= 0) |
332 | return GNUNET_OK; | 326 | return GNUNET_OK; |
@@ -376,13 +370,13 @@ add_trial (struct GNUNET_DHTLOG_TrialInfo *trial_info) | |||
376 | 370 | ||
377 | if (ret < 0) | 371 | if (ret < 0) |
378 | return GNUNET_SYSERR; | 372 | return GNUNET_SYSERR; |
379 | ret = fprintf (outfile, "execute insert_trial using " | 373 | ret = |
380 | "@date, @oid, @num, @topology, @t_p, @t_pr," | 374 | fprintf (outfile, |
381 | " @bl, @connect, @c_t_o," | 375 | "execute insert_trial using " |
382 | "@c_t_o_m, @puts, @gets," | 376 | "@date, @oid, @num, @topology, @t_p, @t_pr," |
383 | "@concurrent, @settle, @rounds," | 377 | " @bl, @connect, @c_t_o," "@c_t_o_m, @puts, @gets," |
384 | "@m_gets, @m_puts, @m_drops," | 378 | "@concurrent, @settle, @rounds," "@m_gets, @m_puts, @m_drops," |
385 | "@m_g_f, @m_p_f, @s_c, @s_f," "@s_k, @g_s, @message;\n"); | 379 | "@m_g_f, @m_p_f, @s_c, @s_f," "@s_k, @g_s, @message;\n"); |
386 | if (ret < 0) | 380 | if (ret < 0) |
387 | return GNUNET_SYSERR; | 381 | return GNUNET_SYSERR; |
388 | ret = fprintf (outfile, "execute select_trial;\n"); | 382 | ret = fprintf (outfile, "execute select_trial;\n"); |
@@ -404,8 +398,8 @@ add_trial (struct GNUNET_DHTLOG_TrialInfo *trial_info) | |||
404 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure | 398 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure |
405 | */ | 399 | */ |
406 | int | 400 | int |
407 | add_generic_stat (const struct GNUNET_PeerIdentity *peer, | 401 | add_generic_stat (const struct GNUNET_PeerIdentity *peer, const char *name, |
408 | const char *name, const char *section, uint64_t value) | 402 | const char *section, uint64_t value) |
409 | { | 403 | { |
410 | int ret; | 404 | int ret; |
411 | 405 | ||
@@ -466,10 +460,10 @@ int | |||
466 | add_stat (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests, | 460 | add_stat (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests, |
467 | unsigned int route_forwards, unsigned int result_requests, | 461 | unsigned int route_forwards, unsigned int result_requests, |
468 | unsigned int client_requests, unsigned int result_forwards, | 462 | unsigned int client_requests, unsigned int result_forwards, |
469 | unsigned int gets, unsigned int puts, | 463 | unsigned int gets, unsigned int puts, unsigned int data_inserts, |
470 | unsigned int data_inserts, unsigned int find_peer_requests, | 464 | unsigned int find_peer_requests, unsigned int find_peers_started, |
471 | unsigned int find_peers_started, unsigned int gets_started, | 465 | unsigned int gets_started, unsigned int puts_started, |
472 | unsigned int puts_started, unsigned int find_peer_responses_received, | 466 | unsigned int find_peer_responses_received, |
473 | unsigned int get_responses_received, | 467 | unsigned int get_responses_received, |
474 | unsigned int find_peer_responses_sent, | 468 | unsigned int find_peer_responses_sent, |
475 | unsigned int get_responses_sent) | 469 | unsigned int get_responses_sent) |
@@ -489,25 +483,27 @@ add_stat (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests, | |||
489 | if (ret < 0) | 483 | if (ret < 0) |
490 | return GNUNET_SYSERR; | 484 | return GNUNET_SYSERR; |
491 | 485 | ||
492 | ret = fprintf (outfile, "set @r_r = %u, @r_f = %u, @res_r = %u, @c_r = %u, " | 486 | ret = |
493 | "@res_f = %u, @gets = %u, @puts = %u, @d_i = %u, " | 487 | fprintf (outfile, |
494 | "@f_p_r = %u, @f_p_s = %u, @g_s = %u, @p_s = %u, " | 488 | "set @r_r = %u, @r_f = %u, @res_r = %u, @c_r = %u, " |
495 | "@f_p_r_r = %u, @g_r_r = %u, @f_p_r_s = %u, @g_r_s = %u;\n", | 489 | "@res_f = %u, @gets = %u, @puts = %u, @d_i = %u, " |
496 | route_requests, route_forwards, result_requests, | 490 | "@f_p_r = %u, @f_p_s = %u, @g_s = %u, @p_s = %u, " |
497 | client_requests, result_forwards, gets, puts, | 491 | "@f_p_r_r = %u, @g_r_r = %u, @f_p_r_s = %u, @g_r_s = %u;\n", |
498 | data_inserts, find_peer_requests, find_peers_started, | 492 | route_requests, route_forwards, result_requests, client_requests, |
499 | gets_started, puts_started, find_peer_responses_received, | 493 | result_forwards, gets, puts, data_inserts, find_peer_requests, |
500 | get_responses_received, find_peer_responses_sent, | 494 | find_peers_started, gets_started, puts_started, |
501 | get_responses_sent); | 495 | find_peer_responses_received, get_responses_received, |
496 | find_peer_responses_sent, get_responses_sent); | ||
502 | 497 | ||
503 | if (ret < 0) | 498 | if (ret < 0) |
504 | return GNUNET_SYSERR; | 499 | return GNUNET_SYSERR; |
505 | 500 | ||
506 | ret = fprintf (outfile, "execute insert_stat using " | 501 | ret = |
507 | "@temp_trial, @temp_node, @r_r, @r_f, @res_r, @c_r, " | 502 | fprintf (outfile, |
508 | "@res_f, @gets, @puts, @d_i, " | 503 | "execute insert_stat using " |
509 | "@f_p_r, @f_p_s, @g_s, @p_s, " | 504 | "@temp_trial, @temp_node, @r_r, @r_f, @res_r, @c_r, " |
510 | "@f_p_r_r, @g_r_r, @f_p_r_s, @g_r_s;\n"); | 505 | "@res_f, @gets, @puts, @d_i, " "@f_p_r, @f_p_s, @g_s, @p_s, " |
506 | "@f_p_r_r, @g_r_r, @f_p_r_s, @g_r_s;\n"); | ||
511 | if (ret < 0) | 507 | if (ret < 0) |
512 | return GNUNET_SYSERR; | 508 | return GNUNET_SYSERR; |
513 | return GNUNET_OK; | 509 | return GNUNET_OK; |
@@ -784,9 +780,8 @@ add_query (unsigned long long *sqlqueryuid, unsigned long long queryid, | |||
784 | */ | 780 | */ |
785 | int | 781 | int |
786 | add_route (unsigned long long *sqlqueryuid, unsigned long long queryid, | 782 | add_route (unsigned long long *sqlqueryuid, unsigned long long queryid, |
787 | unsigned int type, unsigned int hops, | 783 | unsigned int type, unsigned int hops, int succeeded, |
788 | int succeeded, const struct GNUNET_PeerIdentity *node, | 784 | const struct GNUNET_PeerIdentity *node, const GNUNET_HashCode * key, |
789 | const GNUNET_HashCode * key, | ||
790 | const struct GNUNET_PeerIdentity *from_node, | 785 | const struct GNUNET_PeerIdentity *from_node, |
791 | const struct GNUNET_PeerIdentity *to_node) | 786 | const struct GNUNET_PeerIdentity *to_node) |
792 | { | 787 | { |
@@ -882,15 +877,15 @@ libgnunet_plugin_dhtlog_mysql_dump_init (void *cls) | |||
882 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 877 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
883 | "MySQL (DUMP) DHT Logger: initializing\n"); | 878 | "MySQL (DUMP) DHT Logger: initializing\n"); |
884 | 879 | ||
885 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (plugin->cfg, | 880 | if (GNUNET_OK != |
886 | "MYSQLDUMP", "PATH", | 881 | GNUNET_CONFIGURATION_get_value_string (plugin->cfg, "MYSQLDUMP", "PATH", |
887 | &outfile_path)) | 882 | &outfile_path)) |
888 | { | 883 | { |
889 | outfile_path = GNUNET_strdup (""); | 884 | outfile_path = GNUNET_strdup (""); |
890 | } | 885 | } |
891 | 886 | ||
892 | GNUNET_asprintf (&outfile_name, | 887 | GNUNET_asprintf (&outfile_name, "%s%s-%d", outfile_path, "mysqldump", |
893 | "%s%s-%d", outfile_path, "mysqldump", getpid ()); | 888 | getpid ()); |
894 | 889 | ||
895 | fn = GNUNET_STRINGS_filename_expand (outfile_name); | 890 | fn = GNUNET_STRINGS_filename_expand (outfile_name); |
896 | 891 | ||
diff --git a/src/dht/plugin_dhtlog_mysql_dump_load.c b/src/dht/plugin_dhtlog_mysql_dump_load.c index 7c3f67942..fada2029e 100644 --- a/src/dht/plugin_dhtlog_mysql_dump_load.c +++ b/src/dht/plugin_dhtlog_mysql_dump_load.c | |||
@@ -222,31 +222,33 @@ add_trial (struct GNUNET_DHTLOG_TrialInfo *trial_info) | |||
222 | if (outfile == NULL) | 222 | if (outfile == NULL) |
223 | return GNUNET_SYSERR; | 223 | return GNUNET_SYSERR; |
224 | 224 | ||
225 | ret = fprintf (outfile, "INSERT INTO trials " | 225 | ret = |
226 | "(starttime, other_trial_identifier, numnodes, topology," | 226 | fprintf (outfile, |
227 | "blacklist_topology, connect_topology, connect_topology_option," | 227 | "INSERT INTO trials " |
228 | "connect_topology_option_modifier, topology_percentage, topology_probability," | 228 | "(starttime, other_trial_identifier, numnodes, topology," |
229 | "puts, gets, " | 229 | "blacklist_topology, connect_topology, connect_topology_option," |
230 | "concurrent, settle_time, num_rounds, malicious_getters," | 230 | "connect_topology_option_modifier, topology_percentage, topology_probability," |
231 | "malicious_putters, malicious_droppers, malicious_get_frequency," | 231 | "puts, gets, " |
232 | "malicious_put_frequency, stop_closest, stop_found, strict_kademlia, " | 232 | "concurrent, settle_time, num_rounds, malicious_getters," |
233 | "gets_succeeded, message) " | 233 | "malicious_putters, malicious_droppers, malicious_get_frequency," |
234 | "VALUES (\"%s\", %u, %u, %u, %u, %u, %u, %f, %f, %f, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, \"%s\");\n", | 234 | "malicious_put_frequency, stop_closest, stop_found, strict_kademlia, " |
235 | get_sql_time (), trial_info->other_identifier, | 235 | "gets_succeeded, message) " |
236 | trial_info->num_nodes, trial_info->topology, | 236 | "VALUES (\"%s\", %u, %u, %u, %u, %u, %u, %f, %f, %f, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u, \"%s\");\n", |
237 | trial_info->blacklist_topology, trial_info->connect_topology, | 237 | get_sql_time (), trial_info->other_identifier, |
238 | trial_info->connect_topology_option, | 238 | trial_info->num_nodes, trial_info->topology, |
239 | trial_info->connect_topology_option_modifier, | 239 | trial_info->blacklist_topology, trial_info->connect_topology, |
240 | trial_info->topology_percentage, | 240 | trial_info->connect_topology_option, |
241 | trial_info->topology_probability, trial_info->puts, | 241 | trial_info->connect_topology_option_modifier, |
242 | trial_info->gets, trial_info->concurrent, | 242 | trial_info->topology_percentage, |
243 | trial_info->settle_time, trial_info->num_rounds, | 243 | trial_info->topology_probability, trial_info->puts, |
244 | trial_info->malicious_getters, trial_info->malicious_putters, | 244 | trial_info->gets, trial_info->concurrent, |
245 | trial_info->malicious_droppers, | 245 | trial_info->settle_time, trial_info->num_rounds, |
246 | trial_info->malicious_get_frequency, | 246 | trial_info->malicious_getters, trial_info->malicious_putters, |
247 | trial_info->malicious_put_frequency, trial_info->stop_closest, | 247 | trial_info->malicious_droppers, |
248 | trial_info->stop_found, trial_info->strict_kademlia, | 248 | trial_info->malicious_get_frequency, |
249 | trial_info->gets_succeeded, trial_info->message); | 249 | trial_info->malicious_put_frequency, trial_info->stop_closest, |
250 | trial_info->stop_found, trial_info->strict_kademlia, | ||
251 | trial_info->gets_succeeded, trial_info->message); | ||
250 | 252 | ||
251 | if (ret < 0) | 253 | if (ret < 0) |
252 | return GNUNET_SYSERR; | 254 | return GNUNET_SYSERR; |
@@ -273,8 +275,8 @@ add_trial (struct GNUNET_DHTLOG_TrialInfo *trial_info) | |||
273 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure | 275 | * @return GNUNET_OK on success, GNUNET_SYSERR on failure |
274 | */ | 276 | */ |
275 | int | 277 | int |
276 | add_generic_stat (const struct GNUNET_PeerIdentity *peer, | 278 | add_generic_stat (const struct GNUNET_PeerIdentity *peer, const char *name, |
277 | const char *name, const char *section, uint64_t value) | 279 | const char *section, uint64_t value) |
278 | { | 280 | { |
279 | if (outfile == NULL) | 281 | if (outfile == NULL) |
280 | return GNUNET_SYSERR; | 282 | return GNUNET_SYSERR; |
@@ -315,10 +317,10 @@ int | |||
315 | add_stat (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests, | 317 | add_stat (const struct GNUNET_PeerIdentity *peer, unsigned int route_requests, |
316 | unsigned int route_forwards, unsigned int result_requests, | 318 | unsigned int route_forwards, unsigned int result_requests, |
317 | unsigned int client_requests, unsigned int result_forwards, | 319 | unsigned int client_requests, unsigned int result_forwards, |
318 | unsigned int gets, unsigned int puts, | 320 | unsigned int gets, unsigned int puts, unsigned int data_inserts, |
319 | unsigned int data_inserts, unsigned int find_peer_requests, | 321 | unsigned int find_peer_requests, unsigned int find_peers_started, |
320 | unsigned int find_peers_started, unsigned int gets_started, | 322 | unsigned int gets_started, unsigned int puts_started, |
321 | unsigned int puts_started, unsigned int find_peer_responses_received, | 323 | unsigned int find_peer_responses_received, |
322 | unsigned int get_responses_received, | 324 | unsigned int get_responses_received, |
323 | unsigned int find_peer_responses_sent, | 325 | unsigned int find_peer_responses_sent, |
324 | unsigned int get_responses_sent) | 326 | unsigned int get_responses_sent) |
@@ -568,9 +570,8 @@ add_query (unsigned long long *sqlqueryuid, unsigned long long queryid, | |||
568 | */ | 570 | */ |
569 | int | 571 | int |
570 | add_route (unsigned long long *sqlqueryuid, unsigned long long queryid, | 572 | add_route (unsigned long long *sqlqueryuid, unsigned long long queryid, |
571 | unsigned int type, unsigned int hops, | 573 | unsigned int type, unsigned int hops, int succeeded, |
572 | int succeeded, const struct GNUNET_PeerIdentity *node, | 574 | const struct GNUNET_PeerIdentity *node, const GNUNET_HashCode * key, |
573 | const GNUNET_HashCode * key, | ||
574 | const struct GNUNET_PeerIdentity *from_node, | 575 | const struct GNUNET_PeerIdentity *from_node, |
575 | const struct GNUNET_PeerIdentity *to_node) | 576 | const struct GNUNET_PeerIdentity *to_node) |
576 | { | 577 | { |
@@ -636,15 +637,15 @@ libgnunet_plugin_dhtlog_mysql_dump_load_init (void *cls) | |||
636 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 637 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
637 | "MySQL (DUMP) DHT Logger: initializing\n"); | 638 | "MySQL (DUMP) DHT Logger: initializing\n"); |
638 | 639 | ||
639 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (plugin->cfg, | 640 | if (GNUNET_OK != |
640 | "MYSQLDUMP", "PATH", | 641 | GNUNET_CONFIGURATION_get_value_string (plugin->cfg, "MYSQLDUMP", "PATH", |
641 | &outfile_path)) | 642 | &outfile_path)) |
642 | { | 643 | { |
643 | outfile_path = GNUNET_strdup (""); | 644 | outfile_path = GNUNET_strdup (""); |
644 | } | 645 | } |
645 | 646 | ||
646 | GNUNET_asprintf (&outfile_name, | 647 | GNUNET_asprintf (&outfile_name, "%s%s-%d", outfile_path, "mysqldump", |
647 | "%s%s-%d", outfile_path, "mysqldump", getpid ()); | 648 | getpid ()); |
648 | 649 | ||
649 | fn = GNUNET_STRINGS_filename_expand (outfile_name); | 650 | fn = GNUNET_STRINGS_filename_expand (outfile_name); |
650 | 651 | ||
@@ -674,8 +675,8 @@ libgnunet_plugin_dhtlog_mysql_dump_load_init (void *cls) | |||
674 | } | 675 | } |
675 | 676 | ||
676 | GNUNET_free (outfile_name); | 677 | GNUNET_free (outfile_name); |
677 | GNUNET_asprintf (&outfile_name, | 678 | GNUNET_asprintf (&outfile_name, "%s%s-%d", outfile_path, "mysqldump_nodes", |
678 | "%s%s-%d", outfile_path, "mysqldump_nodes", getpid ()); | 679 | getpid ()); |
679 | GNUNET_free (fn); | 680 | GNUNET_free (fn); |
680 | fn = GNUNET_STRINGS_filename_expand (outfile_name); | 681 | fn = GNUNET_STRINGS_filename_expand (outfile_name); |
681 | 682 | ||
@@ -705,8 +706,8 @@ libgnunet_plugin_dhtlog_mysql_dump_load_init (void *cls) | |||
705 | } | 706 | } |
706 | 707 | ||
707 | GNUNET_free (outfile_name); | 708 | GNUNET_free (outfile_name); |
708 | GNUNET_asprintf (&outfile_name, | 709 | GNUNET_asprintf (&outfile_name, "%s%s-%d", outfile_path, "mysqldump_routes", |
709 | "%s%s-%d", outfile_path, "mysqldump_routes", getpid ()); | 710 | getpid ()); |
710 | 711 | ||
711 | GNUNET_free (fn); | 712 | GNUNET_free (fn); |
712 | fn = GNUNET_STRINGS_filename_expand (outfile_name); | 713 | fn = GNUNET_STRINGS_filename_expand (outfile_name); |
@@ -737,8 +738,8 @@ libgnunet_plugin_dhtlog_mysql_dump_load_init (void *cls) | |||
737 | } | 738 | } |
738 | 739 | ||
739 | GNUNET_free (outfile_name); | 740 | GNUNET_free (outfile_name); |
740 | GNUNET_asprintf (&outfile_name, | 741 | GNUNET_asprintf (&outfile_name, "%s%s-%d", outfile_path, "mysqldump_queries", |
741 | "%s%s-%d", outfile_path, "mysqldump_queries", getpid ()); | 742 | getpid ()); |
742 | 743 | ||
743 | GNUNET_free (fn); | 744 | GNUNET_free (fn); |
744 | fn = GNUNET_STRINGS_filename_expand (outfile_name); | 745 | fn = GNUNET_STRINGS_filename_expand (outfile_name); |
@@ -769,8 +770,8 @@ libgnunet_plugin_dhtlog_mysql_dump_load_init (void *cls) | |||
769 | } | 770 | } |
770 | 771 | ||
771 | GNUNET_free (outfile_name); | 772 | GNUNET_free (outfile_name); |
772 | GNUNET_asprintf (&outfile_name, | 773 | GNUNET_asprintf (&outfile_name, "%s%s-%d", outfile_path, "mysqldump_stats", |
773 | "%s%s-%d", outfile_path, "mysqldump_stats", getpid ()); | 774 | getpid ()); |
774 | 775 | ||
775 | GNUNET_free (fn); | 776 | GNUNET_free (fn); |
776 | fn = GNUNET_STRINGS_filename_expand (outfile_name); | 777 | fn = GNUNET_STRINGS_filename_expand (outfile_name); |
@@ -801,9 +802,8 @@ libgnunet_plugin_dhtlog_mysql_dump_load_init (void *cls) | |||
801 | } | 802 | } |
802 | 803 | ||
803 | GNUNET_free (outfile_name); | 804 | GNUNET_free (outfile_name); |
804 | GNUNET_asprintf (&outfile_name, | 805 | GNUNET_asprintf (&outfile_name, "%s%s-%d", outfile_path, |
805 | "%s%s-%d", | 806 | "mysqldump_generic_stats", getpid ()); |
806 | outfile_path, "mysqldump_generic_stats", getpid ()); | ||
807 | GNUNET_free (fn); | 807 | GNUNET_free (fn); |
808 | fn = GNUNET_STRINGS_filename_expand (outfile_name); | 808 | fn = GNUNET_STRINGS_filename_expand (outfile_name); |
809 | 809 | ||
@@ -833,8 +833,8 @@ libgnunet_plugin_dhtlog_mysql_dump_load_init (void *cls) | |||
833 | } | 833 | } |
834 | 834 | ||
835 | GNUNET_free (outfile_name); | 835 | GNUNET_free (outfile_name); |
836 | GNUNET_asprintf (&outfile_name, | 836 | GNUNET_asprintf (&outfile_name, "%s%s-%d", outfile_path, "mysqldump_dhtkey", |
837 | "%s%s-%d", outfile_path, "mysqldump_dhtkey", getpid ()); | 837 | getpid ()); |
838 | GNUNET_free (fn); | 838 | GNUNET_free (fn); |
839 | fn = GNUNET_STRINGS_filename_expand (outfile_name); | 839 | fn = GNUNET_STRINGS_filename_expand (outfile_name); |
840 | 840 | ||
@@ -864,9 +864,8 @@ libgnunet_plugin_dhtlog_mysql_dump_load_init (void *cls) | |||
864 | } | 864 | } |
865 | 865 | ||
866 | GNUNET_free (outfile_name); | 866 | GNUNET_free (outfile_name); |
867 | GNUNET_asprintf (&outfile_name, | 867 | GNUNET_asprintf (&outfile_name, "%s%s-%d", outfile_path, |
868 | "%s%s-%d", | 868 | "mysqldump_extended_topology", getpid ()); |
869 | outfile_path, "mysqldump_extended_topology", getpid ()); | ||
870 | GNUNET_free (fn); | 869 | GNUNET_free (fn); |
871 | fn = GNUNET_STRINGS_filename_expand (outfile_name); | 870 | fn = GNUNET_STRINGS_filename_expand (outfile_name); |
872 | 871 | ||
diff --git a/src/dht/test_dht_api.c b/src/dht/test_dht_api.c index 407e2279b..9fc5c2d7a 100644 --- a/src/dht/test_dht_api.c +++ b/src/dht/test_dht_api.c | |||
@@ -237,8 +237,8 @@ test_find_peer_processor (void *cls, const struct GNUNET_HELLO_Message *hello) | |||
237 | * @param cls closure | 237 | * @param cls closure |
238 | * @param tc context information (why was this task triggered now?) | 238 | * @param tc context information (why was this task triggered now?) |
239 | */ | 239 | */ |
240 | void | 240 | void retry_find_peer_stop (void *cls, |
241 | retry_find_peer_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 241 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
242 | 242 | ||
243 | /** | 243 | /** |
244 | * Retry the find_peer task on timeout. | 244 | * Retry the find_peer task on timeout. |
@@ -330,8 +330,7 @@ test_find_peer (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
330 | retry_context.next_timeout = BASE_TIMEOUT; | 330 | retry_context.next_timeout = BASE_TIMEOUT; |
331 | retry_context.peer_ctx = peer; | 331 | retry_context.peer_ctx = peer; |
332 | 332 | ||
333 | peer->find_peer_handle | 333 | peer->find_peer_handle = |
334 | = | ||
335 | GNUNET_DHT_find_peer_start (peer->dht_handle, retry_context.next_timeout, | 334 | GNUNET_DHT_find_peer_start (peer->dht_handle, retry_context.next_timeout, |
336 | &hash, GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, | 335 | &hash, GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, |
337 | &test_find_peer_processor, &retry_context); | 336 | &test_find_peer_processor, &retry_context); |
@@ -374,8 +373,7 @@ test_get_stop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
374 | } | 373 | } |
375 | 374 | ||
376 | void | 375 | void |
377 | test_get_iterator (void *cls, | 376 | test_get_iterator (void *cls, struct GNUNET_TIME_Absolute exp, |
378 | struct GNUNET_TIME_Absolute exp, | ||
379 | const GNUNET_HashCode * key, | 377 | const GNUNET_HashCode * key, |
380 | const struct GNUNET_PeerIdentity *const *get_path, | 378 | const struct GNUNET_PeerIdentity *const *get_path, |
381 | const struct GNUNET_PeerIdentity *const *put_path, | 379 | const struct GNUNET_PeerIdentity *const *put_path, |
@@ -409,13 +407,10 @@ test_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
409 | retry_context.next_timeout = BASE_TIMEOUT; | 407 | retry_context.next_timeout = BASE_TIMEOUT; |
410 | 408 | ||
411 | peer->get_handle = | 409 | peer->get_handle = |
412 | GNUNET_DHT_get_start (peer->dht_handle, | 410 | GNUNET_DHT_get_start (peer->dht_handle, TOTAL_TIMEOUT, |
413 | TOTAL_TIMEOUT, | 411 | GNUNET_BLOCK_TYPE_TEST, &hash, |
414 | GNUNET_BLOCK_TYPE_TEST, | 412 | DEFAULT_GET_REPLICATION, GNUNET_DHT_RO_NONE, NULL, |
415 | &hash, | 413 | 0, NULL, 0, &test_get_iterator, NULL); |
416 | DEFAULT_GET_REPLICATION, | ||
417 | GNUNET_DHT_RO_NONE, | ||
418 | NULL, 0, NULL, 0, &test_get_iterator, NULL); | ||
419 | 414 | ||
420 | if (peer->get_handle == NULL) | 415 | if (peer->get_handle == NULL) |
421 | { | 416 | { |
@@ -450,11 +445,8 @@ test_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
450 | 445 | ||
451 | GNUNET_assert (peer->dht_handle != NULL); | 446 | GNUNET_assert (peer->dht_handle != NULL); |
452 | 447 | ||
453 | GNUNET_DHT_put (peer->dht_handle, &hash, | 448 | GNUNET_DHT_put (peer->dht_handle, &hash, DEFAULT_PUT_REPLICATION, |
454 | DEFAULT_PUT_REPLICATION, | 449 | GNUNET_DHT_RO_NONE, GNUNET_BLOCK_TYPE_TEST, data_size, data, |
455 | GNUNET_DHT_RO_NONE, | ||
456 | GNUNET_BLOCK_TYPE_TEST, | ||
457 | data_size, data, | ||
458 | GNUNET_TIME_relative_to_absolute (TOTAL_TIMEOUT), | 450 | GNUNET_TIME_relative_to_absolute (TOTAL_TIMEOUT), |
459 | TOTAL_TIMEOUT, &test_get, &p1); | 451 | TOTAL_TIMEOUT, &test_get, &p1); |
460 | GNUNET_free (data); | 452 | GNUNET_free (data); |
@@ -465,28 +457,29 @@ setup_peer (struct PeerContext *p, const char *cfgname) | |||
465 | { | 457 | { |
466 | p->cfg = GNUNET_CONFIGURATION_create (); | 458 | p->cfg = GNUNET_CONFIGURATION_create (); |
467 | #if START_ARM | 459 | #if START_ARM |
468 | p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", | 460 | p->arm_proc = |
469 | "gnunet-service-arm", | 461 | GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", |
462 | "gnunet-service-arm", | ||
470 | #if VERBOSE_ARM | 463 | #if VERBOSE_ARM |
471 | "-L", "DEBUG", | 464 | "-L", "DEBUG", |
472 | #endif | 465 | #endif |
473 | "-c", cfgname, NULL); | 466 | "-c", cfgname, NULL); |
474 | #endif | 467 | #endif |
475 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); | 468 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); |
476 | 469 | ||
477 | } | 470 | } |
478 | 471 | ||
479 | static void | 472 | static void |
480 | run (void *cls, | 473 | run (void *cls, char *const *args, const char *cfgfile, |
481 | char *const *args, | 474 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
482 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
483 | { | 475 | { |
484 | GNUNET_assert (ok == 1); | 476 | GNUNET_assert (ok == 1); |
485 | OKPP; | 477 | OKPP; |
486 | 478 | ||
487 | die_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 479 | die_task = |
488 | (GNUNET_TIME_UNIT_MINUTES, 1), | 480 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
489 | &end_badly, NULL); | 481 | (GNUNET_TIME_UNIT_MINUTES, 1), &end_badly, |
482 | NULL); | ||
490 | 483 | ||
491 | setup_peer (&p1, "test_dht_api_peer1.conf"); | 484 | setup_peer (&p1, "test_dht_api_peer1.conf"); |
492 | 485 | ||
@@ -512,8 +505,8 @@ check () | |||
512 | }; | 505 | }; |
513 | 506 | ||
514 | ok = 1; | 507 | ok = 1; |
515 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | 508 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, |
516 | argv, "test-dht-api", "nohelp", options, &run, &ok); | 509 | "test-dht-api", "nohelp", options, &run, &ok); |
517 | stop_arm (&p1); | 510 | stop_arm (&p1); |
518 | return ok; | 511 | return ok; |
519 | } | 512 | } |
diff --git a/src/dht/test_dht_multipeer.c b/src/dht/test_dht_multipeer.c index 3bbf44be1..779aff88d 100644 --- a/src/dht/test_dht_multipeer.c +++ b/src/dht/test_dht_multipeer.c | |||
@@ -394,8 +394,7 @@ get_stop_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
394 | * @param data pointer to the result data | 394 | * @param data pointer to the result data |
395 | */ | 395 | */ |
396 | void | 396 | void |
397 | get_result_iterator (void *cls, | 397 | get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp, |
398 | struct GNUNET_TIME_Absolute exp, | ||
399 | const GNUNET_HashCode * key, | 398 | const GNUNET_HashCode * key, |
400 | const struct GNUNET_PeerIdentity *const *get_path, | 399 | const struct GNUNET_PeerIdentity *const *get_path, |
401 | const struct GNUNET_PeerIdentity *const *put_path, | 400 | const struct GNUNET_PeerIdentity *const *put_path, |
@@ -473,15 +472,11 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
473 | /* Insert the data at the first peer */ | 472 | /* Insert the data at the first peer */ |
474 | GNUNET_assert (test_get->dht_handle != NULL); | 473 | GNUNET_assert (test_get->dht_handle != NULL); |
475 | outstanding_gets++; | 474 | outstanding_gets++; |
476 | test_get->get_handle = GNUNET_DHT_get_start (test_get->dht_handle, | 475 | test_get->get_handle = |
477 | GNUNET_TIME_UNIT_FOREVER_REL, | 476 | GNUNET_DHT_get_start (test_get->dht_handle, GNUNET_TIME_UNIT_FOREVER_REL, |
478 | GNUNET_BLOCK_TYPE_TEST, | 477 | GNUNET_BLOCK_TYPE_TEST, &key, |
479 | &key, | 478 | DEFAULT_GET_REPLICATION, route_option, NULL, 0, |
480 | DEFAULT_GET_REPLICATION, | 479 | NULL, 0, &get_result_iterator, test_get); |
481 | route_option, | ||
482 | NULL, 0, | ||
483 | NULL, 0, | ||
484 | &get_result_iterator, test_get); | ||
485 | #if VERBOSE | 480 | #if VERBOSE |
486 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting get for uid %u from peer %s\n", | 481 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting get for uid %u from peer %s\n", |
487 | test_get->uid, test_get->daemon->shortname); | 482 | test_get->uid, test_get->daemon->shortname); |
@@ -546,14 +541,10 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
546 | 541 | ||
547 | GNUNET_assert (test_put->dht_handle != NULL); | 542 | GNUNET_assert (test_put->dht_handle != NULL); |
548 | outstanding_puts++; | 543 | outstanding_puts++; |
549 | GNUNET_DHT_put (test_put->dht_handle, | 544 | GNUNET_DHT_put (test_put->dht_handle, &key, DEFAULT_PUT_REPLICATION, |
550 | &key, | 545 | route_option, GNUNET_BLOCK_TYPE_TEST, sizeof (data), data, |
551 | DEFAULT_PUT_REPLICATION, | 546 | GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TIME_UNIT_FOREVER_REL, |
552 | route_option, | 547 | &put_finished, test_put); |
553 | GNUNET_BLOCK_TYPE_TEST, | ||
554 | sizeof (data), data, | ||
555 | GNUNET_TIME_UNIT_FOREVER_ABS, | ||
556 | GNUNET_TIME_UNIT_FOREVER_REL, &put_finished, test_put); | ||
557 | test_put->disconnect_task = | 548 | test_put->disconnect_task = |
558 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_get_forever (), | 549 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_get_forever (), |
559 | &put_disconnect_task, test_put); | 550 | &put_disconnect_task, test_put); |
@@ -616,10 +607,8 @@ setup_puts_and_gets (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
616 | * failure (peers failed to connect). | 607 | * failure (peers failed to connect). |
617 | */ | 608 | */ |
618 | void | 609 | void |
619 | topology_callback (void *cls, | 610 | topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, |
620 | const struct GNUNET_PeerIdentity *first, | 611 | const struct GNUNET_PeerIdentity *second, uint32_t distance, |
621 | const struct GNUNET_PeerIdentity *second, | ||
622 | uint32_t distance, | ||
623 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, | 612 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, |
624 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, | 613 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, |
625 | struct GNUNET_TESTING_Daemon *first_daemon, | 614 | struct GNUNET_TESTING_Daemon *first_daemon, |
@@ -653,9 +642,9 @@ topology_callback (void *cls, | |||
653 | total_connections); | 642 | total_connections); |
654 | #endif | 643 | #endif |
655 | GNUNET_SCHEDULER_cancel (die_task); | 644 | GNUNET_SCHEDULER_cancel (die_task); |
656 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 645 | die_task = |
657 | &end_badly, | 646 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, |
658 | "from setup puts/gets"); | 647 | "from setup puts/gets"); |
659 | 648 | ||
660 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 649 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
661 | (GNUNET_TIME_UNIT_SECONDS, 2), | 650 | (GNUNET_TIME_UNIT_SECONDS, 2), |
@@ -671,8 +660,7 @@ topology_callback (void *cls, | |||
671 | } | 660 | } |
672 | 661 | ||
673 | static void | 662 | static void |
674 | peers_started_callback (void *cls, | 663 | peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id, |
675 | const struct GNUNET_PeerIdentity *id, | ||
676 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 664 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
677 | struct GNUNET_TESTING_Daemon *d, const char *emsg) | 665 | struct GNUNET_TESTING_Daemon *d, const char *emsg) |
678 | { | 666 | { |
@@ -702,16 +690,14 @@ peers_started_callback (void *cls, | |||
702 | expected_connections = -1; | 690 | expected_connections = -1; |
703 | if ((pg != NULL) && (peers_left == 0)) | 691 | if ((pg != NULL) && (peers_left == 0)) |
704 | { | 692 | { |
705 | expected_connections = GNUNET_TESTING_connect_topology (pg, | 693 | expected_connections = |
706 | connection_topology, | 694 | GNUNET_TESTING_connect_topology (pg, connection_topology, |
707 | connect_topology_option, | 695 | connect_topology_option, |
708 | connect_topology_option_modifier, | 696 | connect_topology_option_modifier, |
709 | TIMEOUT, | 697 | TIMEOUT, num_peers, NULL, NULL); |
710 | num_peers, | ||
711 | NULL, NULL); | ||
712 | #if VERBOSE | 698 | #if VERBOSE |
713 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 699 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Have %d expected connections\n", |
714 | "Have %d expected connections\n", expected_connections); | 700 | expected_connections); |
715 | #endif | 701 | #endif |
716 | } | 702 | } |
717 | 703 | ||
@@ -722,9 +708,9 @@ peers_started_callback (void *cls, | |||
722 | "from connect topology (bad return)"); | 708 | "from connect topology (bad return)"); |
723 | } | 709 | } |
724 | 710 | ||
725 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 711 | die_task = |
726 | &end_badly, | 712 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, |
727 | "from connect topology (timeout)"); | 713 | "from connect topology (timeout)"); |
728 | 714 | ||
729 | ok = 0; | 715 | ok = 0; |
730 | } | 716 | } |
@@ -751,9 +737,9 @@ create_topology () | |||
751 | "from create topology (bad return)"); | 737 | "from create topology (bad return)"); |
752 | } | 738 | } |
753 | GNUNET_SCHEDULER_cancel (die_task); | 739 | GNUNET_SCHEDULER_cancel (die_task); |
754 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 740 | die_task = |
755 | &end_badly, | 741 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, |
756 | "from continue startup (timeout)"); | 742 | "from continue startup (timeout)"); |
757 | } | 743 | } |
758 | 744 | ||
759 | /** | 745 | /** |
@@ -765,8 +751,7 @@ create_topology () | |||
765 | * @param emsg non-null on failure | 751 | * @param emsg non-null on failure |
766 | */ | 752 | */ |
767 | void | 753 | void |
768 | hostkey_callback (void *cls, | 754 | hostkey_callback (void *cls, const struct GNUNET_PeerIdentity *id, |
769 | const struct GNUNET_PeerIdentity *id, | ||
770 | struct GNUNET_TESTING_Daemon *d, const char *emsg) | 755 | struct GNUNET_TESTING_Daemon *d, const char *emsg) |
771 | { | 756 | { |
772 | if (emsg != NULL) | 757 | if (emsg != NULL) |
@@ -777,8 +762,8 @@ hostkey_callback (void *cls, | |||
777 | 762 | ||
778 | #if VERBOSE > 1 | 763 | #if VERBOSE > 1 |
779 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 764 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
780 | "Hostkey (%d/%d) created for peer `%s'\n", | 765 | "Hostkey (%d/%d) created for peer `%s'\n", num_peers - peers_left, |
781 | num_peers - peers_left, num_peers, GNUNET_i2s (id)); | 766 | num_peers, GNUNET_i2s (id)); |
782 | #endif | 767 | #endif |
783 | 768 | ||
784 | 769 | ||
@@ -792,9 +777,9 @@ hostkey_callback (void *cls, | |||
792 | GNUNET_SCHEDULER_cancel (die_task); | 777 | GNUNET_SCHEDULER_cancel (die_task); |
793 | /* Set up task in case topology creation doesn't finish | 778 | /* Set up task in case topology creation doesn't finish |
794 | * within a reasonable amount of time */ | 779 | * within a reasonable amount of time */ |
795 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 780 | die_task = |
796 | &end_badly, | 781 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, |
797 | "from create_topology"); | 782 | "from create_topology"); |
798 | GNUNET_SCHEDULER_add_now (&create_topology, NULL); | 783 | GNUNET_SCHEDULER_add_now (&create_topology, NULL); |
799 | ok = 0; | 784 | ok = 0; |
800 | } | 785 | } |
@@ -802,9 +787,8 @@ hostkey_callback (void *cls, | |||
802 | 787 | ||
803 | 788 | ||
804 | static void | 789 | static void |
805 | run (void *cls, | 790 | run (void *cls, char *const *args, const char *cfgfile, |
806 | char *const *args, | 791 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
807 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
808 | { | 792 | { |
809 | char *topology_str; | 793 | char *topology_str; |
810 | char *connect_topology_str; | 794 | char *connect_topology_str; |
@@ -962,9 +946,9 @@ check () | |||
962 | GNUNET_GETOPT_OPTION_END | 946 | GNUNET_GETOPT_OPTION_END |
963 | }; | 947 | }; |
964 | /* Run the run function as a new program */ | 948 | /* Run the run function as a new program */ |
965 | ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | 949 | ret = |
966 | argv, "test-dht-multipeer", "nohelp", | 950 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, |
967 | options, &run, &ok); | 951 | "test-dht-multipeer", "nohelp", options, &run, &ok); |
968 | if (ret != GNUNET_OK) | 952 | if (ret != GNUNET_OK) |
969 | { | 953 | { |
970 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 954 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
diff --git a/src/dht/test_dht_twopeer.c b/src/dht/test_dht_twopeer.c index 6ba3799dc..50a27a093 100644 --- a/src/dht/test_dht_twopeer.c +++ b/src/dht/test_dht_twopeer.c | |||
@@ -155,8 +155,7 @@ static void do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | |||
155 | * @param data pointer to the result data | 155 | * @param data pointer to the result data |
156 | */ | 156 | */ |
157 | void | 157 | void |
158 | get_result_iterator (void *cls, | 158 | get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp, |
159 | struct GNUNET_TIME_Absolute exp, | ||
160 | const GNUNET_HashCode * key, | 159 | const GNUNET_HashCode * key, |
161 | const struct GNUNET_PeerIdentity *const *get_path, | 160 | const struct GNUNET_PeerIdentity *const *get_path, |
162 | const struct GNUNET_PeerIdentity *const *put_path, | 161 | const struct GNUNET_PeerIdentity *const *put_path, |
@@ -200,8 +199,8 @@ get_result_iterator (void *cls, | |||
200 | 199 | ||
201 | } | 200 | } |
202 | 201 | ||
203 | static void | 202 | static void stop_retry_get (void *cls, |
204 | stop_retry_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 203 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
205 | 204 | ||
206 | static void | 205 | static void |
207 | get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 206 | get_stop_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
@@ -260,24 +259,20 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
260 | (GNUNET_TIME_UNIT_SECONDS, 10), | 259 | (GNUNET_TIME_UNIT_SECONDS, 10), |
261 | &stop_retry_get, get_context); | 260 | &stop_retry_get, get_context); |
262 | 261 | ||
263 | get_context->get_handle = GNUNET_DHT_get_start (get_context->dht_handle, | 262 | get_context->get_handle = |
264 | GNUNET_TIME_relative_multiply | 263 | GNUNET_DHT_get_start (get_context->dht_handle, |
265 | (GNUNET_TIME_UNIT_SECONDS, 5), | 264 | GNUNET_TIME_relative_multiply |
266 | GNUNET_BLOCK_TYPE_DHT_HELLO, | 265 | (GNUNET_TIME_UNIT_SECONDS, 5), |
267 | &get_context-> | 266 | GNUNET_BLOCK_TYPE_DHT_HELLO, |
268 | peer->hashPubKey, | 267 | &get_context->peer->hashPubKey, |
269 | DEFAULT_GET_REPLICATION, | 268 | DEFAULT_GET_REPLICATION, GNUNET_DHT_RO_NONE, NULL, |
270 | GNUNET_DHT_RO_NONE, NULL, 0, | 269 | 0, NULL, 0, &get_result_iterator, get_context); |
271 | NULL, 0, &get_result_iterator, | ||
272 | get_context); | ||
273 | } | 270 | } |
274 | 271 | ||
275 | 272 | ||
276 | void | 273 | void |
277 | topology_callback (void *cls, | 274 | topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, |
278 | const struct GNUNET_PeerIdentity *first, | 275 | const struct GNUNET_PeerIdentity *second, uint32_t distance, |
279 | const struct GNUNET_PeerIdentity *second, | ||
280 | uint32_t distance, | ||
281 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, | 276 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, |
282 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, | 277 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, |
283 | struct GNUNET_TESTING_Daemon *first_daemon, | 278 | struct GNUNET_TESTING_Daemon *first_daemon, |
@@ -311,8 +306,8 @@ topology_callback (void *cls, | |||
311 | total_connections); | 306 | total_connections); |
312 | #endif | 307 | #endif |
313 | GNUNET_SCHEDULER_cancel (die_task); | 308 | GNUNET_SCHEDULER_cancel (die_task); |
314 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 309 | die_task = |
315 | &end_badly, "from test gets"); | 310 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "from test gets"); |
316 | 311 | ||
317 | curr_get_ctx.dht_handle = peer1dht; | 312 | curr_get_ctx.dht_handle = peer1dht; |
318 | curr_get_ctx.peer = &peer2id; | 313 | curr_get_ctx.peer = &peer2id; |
@@ -334,12 +329,10 @@ connect_topology (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
334 | { | 329 | { |
335 | expected_connections = -1; | 330 | expected_connections = -1; |
336 | if ((pg != NULL) && (peers_left == 0)) | 331 | if ((pg != NULL) && (peers_left == 0)) |
337 | expected_connections = GNUNET_TESTING_connect_topology (pg, | 332 | expected_connections = |
338 | GNUNET_TESTING_TOPOLOGY_CLIQUE, | 333 | GNUNET_TESTING_connect_topology (pg, GNUNET_TESTING_TOPOLOGY_CLIQUE, |
339 | GNUNET_TESTING_TOPOLOGY_OPTION_ALL, | 334 | GNUNET_TESTING_TOPOLOGY_OPTION_ALL, |
340 | 0.0, | 335 | 0.0, TIMEOUT, 12, NULL, NULL); |
341 | TIMEOUT, 12, NULL, | ||
342 | NULL); | ||
343 | 336 | ||
344 | GNUNET_SCHEDULER_cancel (die_task); | 337 | GNUNET_SCHEDULER_cancel (die_task); |
345 | if (expected_connections == GNUNET_SYSERR) | 338 | if (expected_connections == GNUNET_SYSERR) |
@@ -348,14 +341,13 @@ connect_topology (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
348 | "from connect topology (bad return)"); | 341 | "from connect topology (bad return)"); |
349 | 342 | ||
350 | 343 | ||
351 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 344 | die_task = |
352 | &end_badly, | 345 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, |
353 | "from connect topology (timeout)"); | 346 | "from connect topology (timeout)"); |
354 | } | 347 | } |
355 | 348 | ||
356 | static void | 349 | static void |
357 | peers_started_callback (void *cls, | 350 | peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id, |
358 | const struct GNUNET_PeerIdentity *id, | ||
359 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 351 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
360 | struct GNUNET_TESTING_Daemon *d, const char *emsg) | 352 | struct GNUNET_TESTING_Daemon *d, const char *emsg) |
361 | { | 353 | { |
@@ -399,9 +391,9 @@ peers_started_callback (void *cls, | |||
399 | GNUNET_SCHEDULER_cancel (die_task); | 391 | GNUNET_SCHEDULER_cancel (die_task); |
400 | /* Set up task in case topology creation doesn't finish | 392 | /* Set up task in case topology creation doesn't finish |
401 | * within a reasonable amount of time */ | 393 | * within a reasonable amount of time */ |
402 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 394 | die_task = |
403 | &end_badly, | 395 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, |
404 | "from peers_started_callback"); | 396 | "from peers_started_callback"); |
405 | 397 | ||
406 | GNUNET_SCHEDULER_add_now (&connect_topology, NULL); | 398 | GNUNET_SCHEDULER_add_now (&connect_topology, NULL); |
407 | ok = 0; | 399 | ok = 0; |
@@ -409,9 +401,8 @@ peers_started_callback (void *cls, | |||
409 | } | 401 | } |
410 | 402 | ||
411 | static void | 403 | static void |
412 | run (void *cls, | 404 | run (void *cls, char *const *args, const char *cfgfile, |
413 | char *const *args, | 405 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
414 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
415 | { | 406 | { |
416 | 407 | ||
417 | if (GNUNET_YES != | 408 | if (GNUNET_YES != |
@@ -431,18 +422,13 @@ run (void *cls, | |||
431 | total_gets = num_peers; | 422 | total_gets = num_peers; |
432 | gets_succeeded = 0; | 423 | gets_succeeded = 0; |
433 | /* Set up a task to end testing if peer start fails */ | 424 | /* Set up a task to end testing if peer start fails */ |
434 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 425 | die_task = |
435 | &end_badly, | 426 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, |
436 | "didn't start all daemons in reasonable amount of time!!!"); | 427 | "didn't start all daemons in reasonable amount of time!!!"); |
437 | 428 | ||
438 | pg = GNUNET_TESTING_daemons_start (cfg, | 429 | pg = GNUNET_TESTING_daemons_start (cfg, num_peers, 10, num_peers, TIMEOUT, |
439 | num_peers, | 430 | NULL, NULL, &peers_started_callback, NULL, |
440 | 10, | 431 | &topology_callback, NULL, NULL); |
441 | num_peers, | ||
442 | TIMEOUT, | ||
443 | NULL, NULL, | ||
444 | &peers_started_callback, | ||
445 | NULL, &topology_callback, NULL, NULL); | ||
446 | 432 | ||
447 | } | 433 | } |
448 | 434 | ||
@@ -462,9 +448,9 @@ check () | |||
462 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 448 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
463 | GNUNET_GETOPT_OPTION_END | 449 | GNUNET_GETOPT_OPTION_END |
464 | }; | 450 | }; |
465 | ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | 451 | ret = |
466 | argv, "test-dht-twopeer", "nohelp", | 452 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, |
467 | options, &run, &ok); | 453 | "test-dht-twopeer", "nohelp", options, &run, &ok); |
468 | if (ret != GNUNET_OK) | 454 | if (ret != GNUNET_OK) |
469 | { | 455 | { |
470 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 456 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
diff --git a/src/dht/test_dht_twopeer_path_tracking.c b/src/dht/test_dht_twopeer_path_tracking.c index ab0b1edd2..9985939ae 100644 --- a/src/dht/test_dht_twopeer_path_tracking.c +++ b/src/dht/test_dht_twopeer_path_tracking.c | |||
@@ -188,8 +188,7 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
188 | * @param data pointer to the result data | 188 | * @param data pointer to the result data |
189 | */ | 189 | */ |
190 | void | 190 | void |
191 | get_result_iterator (void *cls, | 191 | get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp, |
192 | struct GNUNET_TIME_Absolute exp, | ||
193 | const GNUNET_HashCode * key, | 192 | const GNUNET_HashCode * key, |
194 | const struct GNUNET_PeerIdentity *const *get_path, | 193 | const struct GNUNET_PeerIdentity *const *get_path, |
195 | const struct GNUNET_PeerIdentity *const *put_path, | 194 | const struct GNUNET_PeerIdentity *const *put_path, |
@@ -262,9 +261,9 @@ static void | |||
262 | put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 261 | put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
263 | { | 262 | { |
264 | GNUNET_SCHEDULER_cancel (die_task); | 263 | GNUNET_SCHEDULER_cancel (die_task); |
265 | die_task = GNUNET_SCHEDULER_add_delayed (GET_TIMEOUT, | 264 | die_task = |
266 | &end_badly, | 265 | GNUNET_SCHEDULER_add_delayed (GET_TIMEOUT, &end_badly, |
267 | "waiting for get response (data not found)"); | 266 | "waiting for get response (data not found)"); |
268 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 267 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
269 | (GNUNET_TIME_UNIT_SECONDS, 10), &do_get, NULL); | 268 | (GNUNET_TIME_UNIT_SECONDS, 10), &do_get, NULL); |
270 | } | 269 | } |
@@ -282,13 +281,9 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
282 | memset (data, 43, sizeof (data)); | 281 | memset (data, 43, sizeof (data)); |
283 | 282 | ||
284 | /* Insert the data at the first peer */ | 283 | /* Insert the data at the first peer */ |
285 | GNUNET_DHT_put (peer1dht, | 284 | GNUNET_DHT_put (peer1dht, &key, DEFAULT_PUT_REPLICATION, |
286 | &key, | 285 | GNUNET_DHT_RO_RECORD_ROUTE, GNUNET_BLOCK_TYPE_TEST, |
287 | DEFAULT_PUT_REPLICATION, | 286 | sizeof (data), data, GNUNET_TIME_UNIT_FOREVER_ABS, |
288 | GNUNET_DHT_RO_RECORD_ROUTE, | ||
289 | GNUNET_BLOCK_TYPE_TEST, | ||
290 | sizeof (data), data, | ||
291 | GNUNET_TIME_UNIT_FOREVER_ABS, | ||
292 | GNUNET_TIME_UNIT_FOREVER_REL, &put_finished, NULL); | 287 | GNUNET_TIME_UNIT_FOREVER_REL, &put_finished, NULL); |
293 | } | 288 | } |
294 | 289 | ||
@@ -302,10 +297,8 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
302 | * failure (peers failed to connect). | 297 | * failure (peers failed to connect). |
303 | */ | 298 | */ |
304 | void | 299 | void |
305 | topology_callback (void *cls, | 300 | topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, |
306 | const struct GNUNET_PeerIdentity *first, | 301 | const struct GNUNET_PeerIdentity *second, uint32_t distance, |
307 | const struct GNUNET_PeerIdentity *second, | ||
308 | uint32_t distance, | ||
309 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, | 302 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, |
310 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, | 303 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, |
311 | struct GNUNET_TESTING_Daemon *first_daemon, | 304 | struct GNUNET_TESTING_Daemon *first_daemon, |
@@ -339,8 +332,8 @@ topology_callback (void *cls, | |||
339 | total_connections); | 332 | total_connections); |
340 | #endif | 333 | #endif |
341 | GNUNET_SCHEDULER_cancel (die_task); | 334 | GNUNET_SCHEDULER_cancel (die_task); |
342 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 335 | die_task = |
343 | &end_badly, "from test gets"); | 336 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "from test gets"); |
344 | 337 | ||
345 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 338 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
346 | (GNUNET_TIME_UNIT_SECONDS, 2), &do_put, NULL); | 339 | (GNUNET_TIME_UNIT_SECONDS, 2), &do_put, NULL); |
@@ -367,8 +360,7 @@ topology_callback (void *cls, | |||
367 | * @param emsg NULL if peer started, non-NULL on error | 360 | * @param emsg NULL if peer started, non-NULL on error |
368 | */ | 361 | */ |
369 | static void | 362 | static void |
370 | peers_started_callback (void *cls, | 363 | peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id, |
371 | const struct GNUNET_PeerIdentity *id, | ||
372 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 364 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
373 | struct GNUNET_TESTING_Daemon *d, const char *emsg) | 365 | struct GNUNET_TESTING_Daemon *d, const char *emsg) |
374 | { | 366 | { |
@@ -415,12 +407,10 @@ peers_started_callback (void *cls, | |||
415 | if ((pg != NULL)) /* Sanity check */ | 407 | if ((pg != NULL)) /* Sanity check */ |
416 | { | 408 | { |
417 | /* Connect peers in a "straight line" topology, return the number of expected connections */ | 409 | /* Connect peers in a "straight line" topology, return the number of expected connections */ |
418 | expected_connections = GNUNET_TESTING_connect_topology (pg, | 410 | expected_connections = |
419 | GNUNET_TESTING_TOPOLOGY_LINE, | 411 | GNUNET_TESTING_connect_topology (pg, GNUNET_TESTING_TOPOLOGY_LINE, |
420 | GNUNET_TESTING_TOPOLOGY_OPTION_ALL, | 412 | GNUNET_TESTING_TOPOLOGY_OPTION_ALL, |
421 | 0.0, | 413 | 0.0, TIMEOUT, 2, NULL, NULL); |
422 | TIMEOUT, | ||
423 | 2, NULL, NULL); | ||
424 | } | 414 | } |
425 | 415 | ||
426 | /* Cancel current timeout fail task */ | 416 | /* Cancel current timeout fail task */ |
@@ -431,17 +421,16 @@ peers_started_callback (void *cls, | |||
431 | "from connect topology (bad return)"); | 421 | "from connect topology (bad return)"); |
432 | 422 | ||
433 | /* Schedule timeout on failure task */ | 423 | /* Schedule timeout on failure task */ |
434 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 424 | die_task = |
435 | &end_badly, | 425 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, |
436 | "from connect topology (timeout)"); | 426 | "from connect topology (timeout)"); |
437 | ok = 0; | 427 | ok = 0; |
438 | } | 428 | } |
439 | } | 429 | } |
440 | 430 | ||
441 | static void | 431 | static void |
442 | run (void *cls, | 432 | run (void *cls, char *const *args, const char *cfgfile, |
443 | char *const *args, | 433 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
444 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
445 | { | 434 | { |
446 | 435 | ||
447 | /* Get path from configuration file */ | 436 | /* Get path from configuration file */ |
@@ -463,20 +452,18 @@ run (void *cls, | |||
463 | peers_left = num_peers; | 452 | peers_left = num_peers; |
464 | 453 | ||
465 | /* Set up a task to end testing if peer start fails */ | 454 | /* Set up a task to end testing if peer start fails */ |
466 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 455 | die_task = |
467 | &end_badly, | 456 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, |
468 | "didn't start all daemons in reasonable amount of time!!!"); | 457 | "didn't start all daemons in reasonable amount of time!!!"); |
469 | 458 | ||
470 | /* Start num_peers peers, call peers_started_callback on peer start, topology_callback on peer connect */ | 459 | /* Start num_peers peers, call peers_started_callback on peer start, topology_callback on peer connect */ |
471 | /* Read the API documentation for other parameters! */ | 460 | /* Read the API documentation for other parameters! */ |
472 | pg = GNUNET_TESTING_daemons_start (cfg, peers_left, /* Total number of peers */ | 461 | pg = GNUNET_TESTING_daemons_start (cfg, peers_left, /* Total number of peers */ |
473 | peers_left, /* Number of outstanding connections */ | 462 | peers_left, /* Number of outstanding connections */ |
474 | peers_left, /* Number of parallel ssh connections, or peers being started at once */ | 463 | peers_left, /* Number of parallel ssh connections, or peers being started at once */ |
475 | TIMEOUT, | 464 | TIMEOUT, NULL, NULL, |
476 | NULL, | 465 | &peers_started_callback, NULL, |
477 | NULL, | 466 | &topology_callback, NULL, NULL); |
478 | &peers_started_callback, | ||
479 | NULL, &topology_callback, NULL, NULL); | ||
480 | 467 | ||
481 | } | 468 | } |
482 | 469 | ||
@@ -498,9 +485,10 @@ check () | |||
498 | GNUNET_GETOPT_OPTION_END | 485 | GNUNET_GETOPT_OPTION_END |
499 | }; | 486 | }; |
500 | /* Run the run function as a new program */ | 487 | /* Run the run function as a new program */ |
501 | ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | 488 | ret = |
502 | argv, "test-dht-twopeer-put-get", "nohelp", | 489 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, |
503 | options, &run, &ok); | 490 | "test-dht-twopeer-put-get", "nohelp", options, &run, |
491 | &ok); | ||
504 | if (ret != GNUNET_OK) | 492 | if (ret != GNUNET_OK) |
505 | { | 493 | { |
506 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 494 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
diff --git a/src/dht/test_dht_twopeer_put_get.c b/src/dht/test_dht_twopeer_put_get.c index 9db0ca385..8e77837b2 100644 --- a/src/dht/test_dht_twopeer_put_get.c +++ b/src/dht/test_dht_twopeer_put_get.c | |||
@@ -210,13 +210,12 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
210 | * @param data pointer to the result data | 210 | * @param data pointer to the result data |
211 | */ | 211 | */ |
212 | void | 212 | void |
213 | get_result_iterator (void *cls, | 213 | get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp, |
214 | struct GNUNET_TIME_Absolute exp, | ||
215 | const GNUNET_HashCode * key, | 214 | const GNUNET_HashCode * key, |
216 | const struct GNUNET_PeerIdentity *const *get_path, | 215 | const struct GNUNET_PeerIdentity *const *get_path, |
217 | const struct GNUNET_PeerIdentity *const *put_path, | 216 | const struct GNUNET_PeerIdentity *const *put_path, |
218 | enum GNUNET_BLOCK_Type type, | 217 | enum GNUNET_BLOCK_Type type, size_t size, |
219 | size_t size, const void *result_data) | 218 | const void *result_data) |
220 | { | 219 | { |
221 | GNUNET_HashCode original_key; /* Key data was stored data under */ | 220 | GNUNET_HashCode original_key; /* Key data was stored data under */ |
222 | char original_data[4]; /* Made up data that was stored */ | 221 | char original_data[4]; /* Made up data that was stored */ |
@@ -273,9 +272,7 @@ do_get (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
273 | #else | 272 | #else |
274 | GNUNET_BLOCK_TYPE_TEST, | 273 | GNUNET_BLOCK_TYPE_TEST, |
275 | #endif | 274 | #endif |
276 | &key, | 275 | &key, DEFAULT_GET_REPLICATION, GNUNET_DHT_RO_NONE, |
277 | DEFAULT_GET_REPLICATION, | ||
278 | GNUNET_DHT_RO_NONE, | ||
279 | NULL, 0, NULL, 0, &get_result_iterator, NULL); | 276 | NULL, 0, NULL, 0, &get_result_iterator, NULL); |
280 | } | 277 | } |
281 | 278 | ||
@@ -287,9 +284,9 @@ static void | |||
287 | put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 284 | put_finished (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
288 | { | 285 | { |
289 | GNUNET_SCHEDULER_cancel (die_task); | 286 | GNUNET_SCHEDULER_cancel (die_task); |
290 | die_task = GNUNET_SCHEDULER_add_delayed (GET_TIMEOUT, | 287 | die_task = |
291 | &end_badly, | 288 | GNUNET_SCHEDULER_add_delayed (GET_TIMEOUT, &end_badly, |
292 | "waiting for get response (data not found)"); | 289 | "waiting for get response (data not found)"); |
293 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 290 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
294 | (GNUNET_TIME_UNIT_SECONDS, 10), &do_get, NULL); | 291 | (GNUNET_TIME_UNIT_SECONDS, 10), &do_get, NULL); |
295 | } | 292 | } |
@@ -309,14 +306,10 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
309 | memset (data, 43, sizeof (data)); | 306 | memset (data, 43, sizeof (data)); |
310 | 307 | ||
311 | /* Insert the data at the first peer */ | 308 | /* Insert the data at the first peer */ |
312 | GNUNET_DHT_put (peer1dht, | 309 | GNUNET_DHT_put (peer1dht, &key, DEFAULT_PUT_REPLICATION, GNUNET_DHT_RO_NONE, |
313 | &key, | 310 | GNUNET_BLOCK_TYPE_TEST, sizeof (data), data, |
314 | DEFAULT_PUT_REPLICATION, | 311 | GNUNET_TIME_UNIT_FOREVER_ABS, GNUNET_TIME_UNIT_FOREVER_REL, |
315 | GNUNET_DHT_RO_NONE, | 312 | &put_finished, NULL); |
316 | GNUNET_BLOCK_TYPE_TEST, | ||
317 | sizeof (data), data, | ||
318 | GNUNET_TIME_UNIT_FOREVER_ABS, | ||
319 | GNUNET_TIME_UNIT_FOREVER_REL, &put_finished, NULL); | ||
320 | } | 313 | } |
321 | #else | 314 | #else |
322 | 315 | ||
@@ -353,24 +346,19 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
353 | GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS); | 346 | GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS); |
354 | 347 | ||
355 | /* Sign the block */ | 348 | /* Sign the block */ |
356 | if (GNUNET_OK != GNUNET_CRYPTO_rsa_sign (my_private_key, | 349 | if (GNUNET_OK != |
357 | &data.purpose, &data.signature)) | 350 | GNUNET_CRYPTO_rsa_sign (my_private_key, &data.purpose, &data.signature)) |
358 | { | 351 | { |
359 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "could not sign DNS_Record\n"); | 352 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "could not sign DNS_Record\n"); |
360 | return; | 353 | return; |
361 | } | 354 | } |
362 | GNUNET_CRYPTO_rsa_key_free (my_private_key); | 355 | GNUNET_CRYPTO_rsa_key_free (my_private_key); |
363 | 356 | ||
364 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 357 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Putting with key %08x\n", |
365 | "Putting with key %08x\n", | ||
366 | *((unsigned int *) &data.service_descriptor)); | 358 | *((unsigned int *) &data.service_descriptor)); |
367 | 359 | ||
368 | GNUNET_DHT_put (peer1dht, | 360 | GNUNET_DHT_put (peer1dht, &data.service_descriptor, DEFAULT_PUT_REPLICATION, |
369 | &data.service_descriptor, | 361 | GNUNET_DHT_RO_NONE, GNUNET_BLOCK_TYPE_DNS, size, |
370 | DEFAULT_PUT_REPLICATION, | ||
371 | GNUNET_DHT_RO_NONE, | ||
372 | GNUNET_BLOCK_TYPE_DNS, | ||
373 | size, | ||
374 | (char *) &data, | 362 | (char *) &data, |
375 | GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS), | 363 | GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_HOURS), |
376 | GNUNET_TIME_UNIT_MINUTES, &put_finished, NULL); | 364 | GNUNET_TIME_UNIT_MINUTES, &put_finished, NULL); |
@@ -387,10 +375,8 @@ do_put (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
387 | * failure (peers failed to connect). | 375 | * failure (peers failed to connect). |
388 | */ | 376 | */ |
389 | void | 377 | void |
390 | topology_callback (void *cls, | 378 | topology_callback (void *cls, const struct GNUNET_PeerIdentity *first, |
391 | const struct GNUNET_PeerIdentity *first, | 379 | const struct GNUNET_PeerIdentity *second, uint32_t distance, |
392 | const struct GNUNET_PeerIdentity *second, | ||
393 | uint32_t distance, | ||
394 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, | 380 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, |
395 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, | 381 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, |
396 | struct GNUNET_TESTING_Daemon *first_daemon, | 382 | struct GNUNET_TESTING_Daemon *first_daemon, |
@@ -424,8 +410,8 @@ topology_callback (void *cls, | |||
424 | total_connections); | 410 | total_connections); |
425 | #endif | 411 | #endif |
426 | GNUNET_SCHEDULER_cancel (die_task); | 412 | GNUNET_SCHEDULER_cancel (die_task); |
427 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 413 | die_task = |
428 | &end_badly, "from test gets"); | 414 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "from test gets"); |
429 | 415 | ||
430 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 416 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
431 | (GNUNET_TIME_UNIT_SECONDS, 2), &do_put, NULL); | 417 | (GNUNET_TIME_UNIT_SECONDS, 2), &do_put, NULL); |
@@ -452,8 +438,7 @@ topology_callback (void *cls, | |||
452 | * @param emsg NULL if peer started, non-NULL on error | 438 | * @param emsg NULL if peer started, non-NULL on error |
453 | */ | 439 | */ |
454 | static void | 440 | static void |
455 | peers_started_callback (void *cls, | 441 | peers_started_callback (void *cls, const struct GNUNET_PeerIdentity *id, |
456 | const struct GNUNET_PeerIdentity *id, | ||
457 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 442 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
458 | struct GNUNET_TESTING_Daemon *d, const char *emsg) | 443 | struct GNUNET_TESTING_Daemon *d, const char *emsg) |
459 | { | 444 | { |
@@ -500,12 +485,10 @@ peers_started_callback (void *cls, | |||
500 | if ((pg != NULL)) /* Sanity check */ | 485 | if ((pg != NULL)) /* Sanity check */ |
501 | { | 486 | { |
502 | /* Connect peers in a "straight line" topology, return the number of expected connections */ | 487 | /* Connect peers in a "straight line" topology, return the number of expected connections */ |
503 | expected_connections = GNUNET_TESTING_connect_topology (pg, | 488 | expected_connections = |
504 | GNUNET_TESTING_TOPOLOGY_LINE, | 489 | GNUNET_TESTING_connect_topology (pg, GNUNET_TESTING_TOPOLOGY_LINE, |
505 | GNUNET_TESTING_TOPOLOGY_OPTION_ALL, | 490 | GNUNET_TESTING_TOPOLOGY_OPTION_ALL, |
506 | 0.0, | 491 | 0.0, TIMEOUT, 12, NULL, NULL); |
507 | TIMEOUT, | ||
508 | 12, NULL, NULL); | ||
509 | } | 492 | } |
510 | 493 | ||
511 | /* Cancel current timeout fail task */ | 494 | /* Cancel current timeout fail task */ |
@@ -516,17 +499,16 @@ peers_started_callback (void *cls, | |||
516 | "from connect topology (bad return)"); | 499 | "from connect topology (bad return)"); |
517 | 500 | ||
518 | /* Schedule timeout on failure task */ | 501 | /* Schedule timeout on failure task */ |
519 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 502 | die_task = |
520 | &end_badly, | 503 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, |
521 | "from connect topology (timeout)"); | 504 | "from connect topology (timeout)"); |
522 | ok = 0; | 505 | ok = 0; |
523 | } | 506 | } |
524 | } | 507 | } |
525 | 508 | ||
526 | static void | 509 | static void |
527 | run (void *cls, | 510 | run (void *cls, char *const *args, const char *cfgfile, |
528 | char *const *args, | 511 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
529 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
530 | { | 512 | { |
531 | 513 | ||
532 | /* Get path from configuration file */ | 514 | /* Get path from configuration file */ |
@@ -548,21 +530,15 @@ run (void *cls, | |||
548 | peers_left = num_peers; | 530 | peers_left = num_peers; |
549 | 531 | ||
550 | /* Set up a task to end testing if peer start fails */ | 532 | /* Set up a task to end testing if peer start fails */ |
551 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 533 | die_task = |
552 | &end_badly, | 534 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, |
553 | "didn't start all daemons in reasonable amount of time!!!"); | 535 | "didn't start all daemons in reasonable amount of time!!!"); |
554 | 536 | ||
555 | /* Start num_peers peers, call peers_started_callback on peer start, topology_callback on peer connect */ | 537 | /* Start num_peers peers, call peers_started_callback on peer start, topology_callback on peer connect */ |
556 | /* Read the API documentation for other parameters! */ | 538 | /* Read the API documentation for other parameters! */ |
557 | pg = GNUNET_TESTING_daemons_start (cfg, | 539 | pg = GNUNET_TESTING_daemons_start (cfg, num_peers, 2, 2, TIMEOUT, NULL, NULL, |
558 | num_peers, | 540 | &peers_started_callback, NULL, |
559 | 2, | 541 | &topology_callback, NULL, NULL); |
560 | 2, | ||
561 | TIMEOUT, | ||
562 | NULL, | ||
563 | NULL, | ||
564 | &peers_started_callback, | ||
565 | NULL, &topology_callback, NULL, NULL); | ||
566 | 542 | ||
567 | } | 543 | } |
568 | 544 | ||
@@ -584,9 +560,10 @@ check () | |||
584 | GNUNET_GETOPT_OPTION_END | 560 | GNUNET_GETOPT_OPTION_END |
585 | }; | 561 | }; |
586 | /* Run the run function as a new program */ | 562 | /* Run the run function as a new program */ |
587 | ret = GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | 563 | ret = |
588 | argv, "test-dht-twopeer-put-get", "nohelp", | 564 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, |
589 | options, &run, &ok); | 565 | "test-dht-twopeer-put-get", "nohelp", options, &run, |
566 | &ok); | ||
590 | if (ret != GNUNET_OK) | 567 | if (ret != GNUNET_OK) |
591 | { | 568 | { |
592 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 569 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
diff --git a/src/dht/test_dhtlog.c b/src/dht/test_dhtlog.c index 4021f5db5..89ec97d6c 100644 --- a/src/dht/test_dhtlog.c +++ b/src/dht/test_dhtlog.c | |||
@@ -195,9 +195,8 @@ test (struct GNUNET_DHTLOG_Handle *api) | |||
195 | 195 | ||
196 | 196 | ||
197 | static void | 197 | static void |
198 | run (void *cls, | 198 | run (void *cls, char *const *args, const char *cfgfile, |
199 | char *const *args, | 199 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
200 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
201 | { | 200 | { |
202 | struct GNUNET_DHTLOG_Handle *api; | 201 | struct GNUNET_DHTLOG_Handle *api; |
203 | 202 | ||
@@ -229,8 +228,8 @@ check () | |||
229 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 228 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
230 | GNUNET_GETOPT_OPTION_END | 229 | GNUNET_GETOPT_OPTION_END |
231 | }; | 230 | }; |
232 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | 231 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, argv, |
233 | argv, "test-dhtlog-api", "nohelp", options, &run, NULL); | 232 | "test-dhtlog-api", "nohelp", options, &run, NULL); |
234 | if (ok != 0) | 233 | if (ok != 0) |
235 | fprintf (stderr, "Test failed with error code: %d\n", ok); | 234 | fprintf (stderr, "Test failed with error code: %d\n", ok); |
236 | return ok; | 235 | return ok; |