diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-08-31 10:36:28 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-08-31 10:36:28 +0000 |
commit | a94a1861d123fe850d2ab5ae74cbb59b132a15ea (patch) | |
tree | a16d2518067d13f2463e83cd9dc66bdd6b733621 /src/testbed | |
parent | d0c55c3ee57913977b1497ea0e6f20573820b206 (diff) | |
download | gnunet-a94a1861d123fe850d2ab5ae74cbb59b132a15ea.tar.gz gnunet-a94a1861d123fe850d2ab5ae74cbb59b132a15ea.zip |
adhering to indentation standard
Diffstat (limited to 'src/testbed')
23 files changed, 1494 insertions, 1452 deletions
diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c index 560740315..9abf6bfd5 100644 --- a/src/testbed/gnunet-service-testbed.c +++ b/src/testbed/gnunet-service-testbed.c | |||
@@ -79,7 +79,7 @@ struct Context | |||
79 | * The TESTING system handle for starting peers locally | 79 | * The TESTING system handle for starting peers locally |
80 | */ | 80 | */ |
81 | struct GNUNET_TESTING_System *system; | 81 | struct GNUNET_TESTING_System *system; |
82 | 82 | ||
83 | /** | 83 | /** |
84 | * Event mask of event to be responded in this context | 84 | * Event mask of event to be responded in this context |
85 | */ | 85 | */ |
@@ -106,12 +106,12 @@ struct MessageQueue | |||
106 | * The client to send the message to | 106 | * The client to send the message to |
107 | */ | 107 | */ |
108 | struct GNUNET_SERVER_Client *client; | 108 | struct GNUNET_SERVER_Client *client; |
109 | 109 | ||
110 | /** | 110 | /** |
111 | * next pointer for DLL | 111 | * next pointer for DLL |
112 | */ | 112 | */ |
113 | struct MessageQueue *next; | 113 | struct MessageQueue *next; |
114 | 114 | ||
115 | /** | 115 | /** |
116 | * prev pointer for DLL | 116 | * prev pointer for DLL |
117 | */ | 117 | */ |
@@ -184,28 +184,27 @@ struct Slave | |||
184 | * States of LCFContext | 184 | * States of LCFContext |
185 | */ | 185 | */ |
186 | enum LCFContextState | 186 | enum LCFContextState |
187 | { | 187 | { |
188 | /** | 188 | /** |
189 | * The Context has been initialized; Nothing has been done on it | 189 | * The Context has been initialized; Nothing has been done on it |
190 | */ | 190 | */ |
191 | INIT, | 191 | INIT, |
192 | 192 | ||
193 | /** | 193 | /** |
194 | * Delegated host has been registered at the forwarding controller | 194 | * Delegated host has been registered at the forwarding controller |
195 | */ | 195 | */ |
196 | DELEGATED_HOST_REGISTERED, | 196 | DELEGATED_HOST_REGISTERED, |
197 | 197 | ||
198 | /** | 198 | /** |
199 | * The slave host has been registred at the forwarding controller | 199 | * The slave host has been registred at the forwarding controller |
200 | */ | 200 | */ |
201 | SLAVE_HOST_REGISTERED, | 201 | SLAVE_HOST_REGISTERED, |
202 | 202 | ||
203 | /** | 203 | /** |
204 | * The context has been finished (may have error) | 204 | * The context has been finished (may have error) |
205 | */ | 205 | */ |
206 | FINISHED | 206 | FINISHED |
207 | 207 | }; | |
208 | }; | ||
209 | 208 | ||
210 | 209 | ||
211 | /** | 210 | /** |
@@ -285,13 +284,13 @@ struct Peer | |||
285 | { | 284 | { |
286 | union | 285 | union |
287 | { | 286 | { |
288 | struct | 287 | struct |
289 | { | 288 | { |
290 | /** | 289 | /** |
291 | * The peer handle from testing API | 290 | * The peer handle from testing API |
292 | */ | 291 | */ |
293 | struct GNUNET_TESTING_Peer *peer; | 292 | struct GNUNET_TESTING_Peer *peer; |
294 | 293 | ||
295 | /** | 294 | /** |
296 | * The modified (by GNUNET_TESTING_peer_configure) configuration this | 295 | * The modified (by GNUNET_TESTING_peer_configure) configuration this |
297 | * peer is configured with | 296 | * peer is configured with |
@@ -308,7 +307,7 @@ struct Peer | |||
308 | struct GNUNET_TESTBED_Controller *controller; | 307 | struct GNUNET_TESTBED_Controller *controller; |
309 | 308 | ||
310 | } remote; | 309 | } remote; |
311 | 310 | ||
312 | } details; | 311 | } details; |
313 | 312 | ||
314 | /** | 313 | /** |
@@ -328,23 +327,23 @@ struct Peer | |||
328 | * State information for overlay connect context | 327 | * State information for overlay connect context |
329 | */ | 328 | */ |
330 | enum OCCState | 329 | enum OCCState |
331 | { | 330 | { |
332 | /** | 331 | /** |
333 | * Initial state | 332 | * Initial state |
334 | */ | 333 | */ |
335 | OCC_STATE_INIT, | 334 | OCC_STATE_INIT, |
336 | 335 | ||
337 | /** | 336 | /** |
338 | * Peer 1 has connected to peer0 | 337 | * Peer 1 has connected to peer0 |
339 | */ | 338 | */ |
340 | OCC_STATE_PEER0_SUCCESS, | 339 | OCC_STATE_PEER0_SUCCESS, |
341 | 340 | ||
342 | /** | 341 | /** |
343 | * Peer 2 has connected to peer1 | 342 | * Peer 2 has connected to peer1 |
344 | */ | 343 | */ |
345 | OCC_STATE_PEER1_SUCCESS, | 344 | OCC_STATE_PEER1_SUCCESS, |
346 | 345 | ||
347 | }; | 346 | }; |
348 | 347 | ||
349 | 348 | ||
350 | /** | 349 | /** |
@@ -366,7 +365,7 @@ struct OverlayConnectContext | |||
366 | * The other peer | 365 | * The other peer |
367 | */ | 366 | */ |
368 | struct Peer *other_peer; | 367 | struct Peer *other_peer; |
369 | 368 | ||
370 | /** | 369 | /** |
371 | * Transport handle of the first peer to offer second peer's HELLO | 370 | * Transport handle of the first peer to offer second peer's HELLO |
372 | */ | 371 | */ |
@@ -386,7 +385,7 @@ struct OverlayConnectContext | |||
386 | * HELLO of the other peer | 385 | * HELLO of the other peer |
387 | */ | 386 | */ |
388 | struct GNUNET_MessageHeader *hello; | 387 | struct GNUNET_MessageHeader *hello; |
389 | 388 | ||
390 | /** | 389 | /** |
391 | * Get hello handle for the other peer | 390 | * Get hello handle for the other peer |
392 | */ | 391 | */ |
@@ -396,7 +395,7 @@ struct OverlayConnectContext | |||
396 | * The error message we send if this overlay connect operation has timed out | 395 | * The error message we send if this overlay connect operation has timed out |
397 | */ | 396 | */ |
398 | char *emsg; | 397 | char *emsg; |
399 | 398 | ||
400 | /** | 399 | /** |
401 | * The peer identity of the first peer | 400 | * The peer identity of the first peer |
402 | */ | 401 | */ |
@@ -417,7 +416,7 @@ struct OverlayConnectContext | |||
417 | * connect to peer 2 | 416 | * connect to peer 2 |
418 | */ | 417 | */ |
419 | GNUNET_SCHEDULER_TaskIdentifier send_hello_task; | 418 | GNUNET_SCHEDULER_TaskIdentifier send_hello_task; |
420 | 419 | ||
421 | /** | 420 | /** |
422 | * The id of the overlay connect timeout task | 421 | * The id of the overlay connect timeout task |
423 | */ | 422 | */ |
@@ -450,7 +449,7 @@ struct ForwardedOperationContext | |||
450 | /** | 449 | /** |
451 | * Closure pointer | 450 | * Closure pointer |
452 | */ | 451 | */ |
453 | void *cls; | 452 | void *cls; |
454 | 453 | ||
455 | /** | 454 | /** |
456 | * Task ID for the timeout task | 455 | * Task ID for the timeout task |
@@ -460,7 +459,7 @@ struct ForwardedOperationContext | |||
460 | /** | 459 | /** |
461 | * The id of the operation that has been forwarded | 460 | * The id of the operation that has been forwarded |
462 | */ | 461 | */ |
463 | uint64_t operation_id; | 462 | uint64_t operation_id; |
464 | 463 | ||
465 | }; | 464 | }; |
466 | 465 | ||
@@ -479,7 +478,7 @@ struct LinkControllersContext | |||
479 | * The ID of the operation | 478 | * The ID of the operation |
480 | */ | 479 | */ |
481 | uint64_t operation_id; | 480 | uint64_t operation_id; |
482 | 481 | ||
483 | /** | 482 | /** |
484 | * Pointer to the slave handle if we are directly starting/connecting to the controller | 483 | * Pointer to the slave handle if we are directly starting/connecting to the controller |
485 | */ | 484 | */ |
@@ -614,11 +613,11 @@ transmit_ready_notify (void *cls, size_t size, void *buf) | |||
614 | GNUNET_free (mq_entry); | 613 | GNUNET_free (mq_entry); |
615 | mq_entry = mq_head; | 614 | mq_entry = mq_head; |
616 | if (NULL != mq_entry) | 615 | if (NULL != mq_entry) |
617 | transmit_handle = | 616 | transmit_handle = |
618 | GNUNET_SERVER_notify_transmit_ready (mq_entry->client, | 617 | GNUNET_SERVER_notify_transmit_ready (mq_entry->client, |
619 | ntohs (mq_entry->msg->size), | 618 | ntohs (mq_entry->msg->size), |
620 | GNUNET_TIME_UNIT_FOREVER_REL, | 619 | GNUNET_TIME_UNIT_FOREVER_REL, |
621 | &transmit_ready_notify, NULL); | 620 | &transmit_ready_notify, NULL); |
622 | return size; | 621 | return size; |
623 | } | 622 | } |
624 | 623 | ||
@@ -640,18 +639,18 @@ queue_message (struct GNUNET_SERVER_Client *client, | |||
640 | type = ntohs (msg->type); | 639 | type = ntohs (msg->type); |
641 | size = ntohs (msg->size); | 640 | size = ntohs (msg->size); |
642 | GNUNET_assert ((GNUNET_MESSAGE_TYPE_TESTBED_INIT <= type) && | 641 | GNUNET_assert ((GNUNET_MESSAGE_TYPE_TESTBED_INIT <= type) && |
643 | (GNUNET_MESSAGE_TYPE_TESTBED_MAX > type)); | 642 | (GNUNET_MESSAGE_TYPE_TESTBED_MAX > type)); |
644 | mq_entry = GNUNET_malloc (sizeof (struct MessageQueue)); | 643 | mq_entry = GNUNET_malloc (sizeof (struct MessageQueue)); |
645 | mq_entry->msg = msg; | 644 | mq_entry->msg = msg; |
646 | mq_entry->client = client; | 645 | mq_entry->client = client; |
647 | LOG_DEBUG ( "Queueing message of type %u, size %u for sending\n", type, | 646 | LOG_DEBUG ("Queueing message of type %u, size %u for sending\n", type, |
648 | ntohs (msg->size)); | 647 | ntohs (msg->size)); |
649 | GNUNET_CONTAINER_DLL_insert_tail (mq_head, mq_tail, mq_entry); | 648 | GNUNET_CONTAINER_DLL_insert_tail (mq_head, mq_tail, mq_entry); |
650 | if (NULL == transmit_handle) | 649 | if (NULL == transmit_handle) |
651 | transmit_handle = | 650 | transmit_handle = |
652 | GNUNET_SERVER_notify_transmit_ready (client, size, | 651 | GNUNET_SERVER_notify_transmit_ready (client, size, |
653 | GNUNET_TIME_UNIT_FOREVER_REL, | 652 | GNUNET_TIME_UNIT_FOREVER_REL, |
654 | &transmit_ready_notify, NULL); | 653 | &transmit_ready_notify, NULL); |
655 | } | 654 | } |
656 | 655 | ||
657 | 656 | ||
@@ -676,7 +675,7 @@ TESTBED_realloc (void *ptr, size_t size, size_t new_size) | |||
676 | /** | 675 | /** |
677 | * Function to add a host to the current list of known hosts | 676 | * Function to add a host to the current list of known hosts |
678 | * | 677 | * |
679 | * @param host the host to add | 678 | * @param host the host to add |
680 | * @return GNUNET_OK on success; GNUNET_SYSERR on failure due to host-id | 679 | * @return GNUNET_OK on success; GNUNET_SYSERR on failure due to host-id |
681 | * already in use | 680 | * already in use |
682 | */ | 681 | */ |
@@ -688,11 +687,11 @@ host_list_add (struct GNUNET_TESTBED_Host *host) | |||
688 | host_id = GNUNET_TESTBED_host_get_id_ (host); | 687 | host_id = GNUNET_TESTBED_host_get_id_ (host); |
689 | if (host_list_size <= host_id) | 688 | if (host_list_size <= host_id) |
690 | { | 689 | { |
691 | host_list = | 690 | host_list = |
692 | TESTBED_realloc (host_list, | 691 | TESTBED_realloc (host_list, |
693 | sizeof (struct GNUNET_TESTBED_Host *) * host_list_size, | 692 | sizeof (struct GNUNET_TESTBED_Host *) * host_list_size, |
694 | sizeof (struct GNUNET_TESTBED_Host *) * | 693 | sizeof (struct GNUNET_TESTBED_Host *) * |
695 | (host_list_size + LIST_GROW_STEP)); | 694 | (host_list_size + LIST_GROW_STEP)); |
696 | host_list_size += LIST_GROW_STEP; | 695 | host_list_size += LIST_GROW_STEP; |
697 | } | 696 | } |
698 | if (NULL != host_list[host_id]) | 697 | if (NULL != host_list[host_id]) |
@@ -715,11 +714,10 @@ route_list_add (struct Route *route) | |||
715 | { | 714 | { |
716 | if (route->dest >= route_list_size) | 715 | if (route->dest >= route_list_size) |
717 | { | 716 | { |
718 | route_list = | 717 | route_list = |
719 | TESTBED_realloc (route_list, | 718 | TESTBED_realloc (route_list, sizeof (struct Route *) * route_list_size, |
720 | sizeof (struct Route *) * route_list_size, | 719 | sizeof (struct Route *) * (route_list_size + |
721 | sizeof (struct Route *) * | 720 | LIST_GROW_STEP)); |
722 | (route_list_size + LIST_GROW_STEP)); | ||
723 | route_list_size += LIST_GROW_STEP; | 721 | route_list_size += LIST_GROW_STEP; |
724 | } | 722 | } |
725 | GNUNET_assert (NULL == route_list[route->dest]); | 723 | GNUNET_assert (NULL == route_list[route->dest]); |
@@ -735,12 +733,12 @@ route_list_add (struct Route *route) | |||
735 | static void | 733 | static void |
736 | slave_list_add (struct Slave *slave) | 734 | slave_list_add (struct Slave *slave) |
737 | { | 735 | { |
738 | if (slave->host_id >= slave_list_size) | 736 | if (slave->host_id >= slave_list_size) |
739 | { | 737 | { |
740 | slave_list = TESTBED_realloc (slave_list, | 738 | slave_list = |
741 | sizeof (struct Slave *) *slave_list_size, | 739 | TESTBED_realloc (slave_list, sizeof (struct Slave *) * slave_list_size, |
742 | sizeof (struct Slave *) * | 740 | sizeof (struct Slave *) * (slave_list_size + |
743 | (slave_list_size + LIST_GROW_STEP)); | 741 | LIST_GROW_STEP)); |
744 | slave_list_size += LIST_GROW_STEP; | 742 | slave_list_size += LIST_GROW_STEP; |
745 | } | 743 | } |
746 | GNUNET_assert (NULL == slave_list[slave->host_id]); | 744 | GNUNET_assert (NULL == slave_list[slave->host_id]); |
@@ -757,15 +755,15 @@ static void | |||
757 | peer_list_add (struct Peer *peer) | 755 | peer_list_add (struct Peer *peer) |
758 | { | 756 | { |
759 | uint32_t orig_size; | 757 | uint32_t orig_size; |
760 | 758 | ||
761 | orig_size = peer_list_size; | 759 | orig_size = peer_list_size; |
762 | if (peer->id >= peer_list_size) | 760 | if (peer->id >= peer_list_size) |
763 | { | 761 | { |
764 | while (peer->id >= peer_list_size) | 762 | while (peer->id >= peer_list_size) |
765 | peer_list_size += LIST_GROW_STEP; | 763 | peer_list_size += LIST_GROW_STEP; |
766 | peer_list = TESTBED_realloc (peer_list, | 764 | peer_list = |
767 | sizeof (struct Peer *) * orig_size, | 765 | TESTBED_realloc (peer_list, sizeof (struct Peer *) * orig_size, |
768 | sizeof (struct Peer *) * peer_list_size); | 766 | sizeof (struct Peer *) * peer_list_size); |
769 | } | 767 | } |
770 | GNUNET_assert (NULL == peer_list[peer->id]); | 768 | GNUNET_assert (NULL == peer_list[peer->id]); |
771 | peer_list[peer->id] = peer; | 769 | peer_list[peer->id] = peer; |
@@ -797,8 +795,8 @@ peer_list_remove (struct Peer *peer) | |||
797 | } | 795 | } |
798 | if (orig_size == peer_list_size) | 796 | if (orig_size == peer_list_size) |
799 | return; | 797 | return; |
800 | peer_list = GNUNET_realloc (peer_list, sizeof (struct Peer *) | 798 | peer_list = |
801 | * peer_list_size); | 799 | GNUNET_realloc (peer_list, sizeof (struct Peer *) * peer_list_size); |
802 | } | 800 | } |
803 | 801 | ||
804 | 802 | ||
@@ -814,8 +812,8 @@ static struct Route * | |||
814 | find_dest_route (uint32_t host_id) | 812 | find_dest_route (uint32_t host_id) |
815 | { | 813 | { |
816 | struct Route *route; | 814 | struct Route *route; |
817 | 815 | ||
818 | while(NULL != (route = route_list[host_id])) | 816 | while (NULL != (route = route_list[host_id])) |
819 | { | 817 | { |
820 | if (route->thru == master_context->host_id) | 818 | if (route->thru == master_context->host_id) |
821 | break; | 819 | break; |
@@ -847,14 +845,13 @@ route_message (uint32_t host_id, const struct GNUNET_MessageHeader *msg) | |||
847 | */ | 845 | */ |
848 | static void | 846 | static void |
849 | send_operation_fail_msg (struct GNUNET_SERVER_Client *client, | 847 | send_operation_fail_msg (struct GNUNET_SERVER_Client *client, |
850 | uint64_t operation_id, | 848 | uint64_t operation_id, const char *emsg) |
851 | const char *emsg) | ||
852 | { | 849 | { |
853 | struct GNUNET_TESTBED_OperationFailureEventMessage *msg; | 850 | struct GNUNET_TESTBED_OperationFailureEventMessage *msg; |
854 | uint16_t msize; | 851 | uint16_t msize; |
855 | uint16_t emsg_len; | 852 | uint16_t emsg_len; |
856 | 853 | ||
857 | msize = sizeof (struct GNUNET_TESTBED_OperationFailureEventMessage); | 854 | msize = sizeof (struct GNUNET_TESTBED_OperationFailureEventMessage); |
858 | emsg_len = (NULL == emsg) ? 0 : strlen (emsg) + 1; | 855 | emsg_len = (NULL == emsg) ? 0 : strlen (emsg) + 1; |
859 | msize += emsg_len; | 856 | msize += emsg_len; |
860 | msg = GNUNET_malloc (msize); | 857 | msg = GNUNET_malloc (msize); |
@@ -876,18 +873,18 @@ send_operation_fail_msg (struct GNUNET_SERVER_Client *client, | |||
876 | */ | 873 | */ |
877 | static void | 874 | static void |
878 | send_operation_success_msg (struct GNUNET_SERVER_Client *client, | 875 | send_operation_success_msg (struct GNUNET_SERVER_Client *client, |
879 | uint64_t operation_id) | 876 | uint64_t operation_id) |
880 | { | 877 | { |
881 | struct GNUNET_TESTBED_GenericOperationSuccessEventMessage *msg; | 878 | struct GNUNET_TESTBED_GenericOperationSuccessEventMessage *msg; |
882 | uint16_t msize; | 879 | uint16_t msize; |
883 | 880 | ||
884 | msize = sizeof (struct GNUNET_TESTBED_GenericOperationSuccessEventMessage); | 881 | msize = sizeof (struct GNUNET_TESTBED_GenericOperationSuccessEventMessage); |
885 | msg = GNUNET_malloc (msize); | 882 | msg = GNUNET_malloc (msize); |
886 | msg->header.size = htons (msize); | 883 | msg->header.size = htons (msize); |
887 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_GENERICOPSUCCESS); | 884 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_GENERICOPSUCCESS); |
888 | msg->operation_id = GNUNET_htonll (operation_id); | 885 | msg->operation_id = GNUNET_htonll (operation_id); |
889 | msg->event_type = htonl (GNUNET_TESTBED_ET_OPERATION_FINISHED); | 886 | msg->event_type = htonl (GNUNET_TESTBED_ET_OPERATION_FINISHED); |
890 | queue_message (client, &msg->header); | 887 | queue_message (client, &msg->header); |
891 | } | 888 | } |
892 | 889 | ||
893 | 890 | ||
@@ -923,19 +920,19 @@ lcf_proc_cc (void *cls, const char *emsg) | |||
923 | lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf); | 920 | lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf); |
924 | break; | 921 | break; |
925 | case DELEGATED_HOST_REGISTERED: | 922 | case DELEGATED_HOST_REGISTERED: |
926 | if (NULL != emsg) | 923 | if (NULL != emsg) |
927 | goto registration_error; | 924 | goto registration_error; |
928 | lcf->state = SLAVE_HOST_REGISTERED; | 925 | lcf->state = SLAVE_HOST_REGISTERED; |
929 | lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf); | 926 | lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf); |
930 | break; | 927 | break; |
931 | default: | 928 | default: |
932 | GNUNET_assert (0); /* Shouldn't reach here */ | 929 | GNUNET_assert (0); /* Shouldn't reach here */ |
933 | } | 930 | } |
934 | return; | 931 | return; |
935 | 932 | ||
936 | registration_error: | 933 | registration_error: |
937 | LOG (GNUNET_ERROR_TYPE_WARNING, | 934 | LOG (GNUNET_ERROR_TYPE_WARNING, "Host registration failed with message: %s\n", |
938 | "Host registration failed with message: %s\n", emsg); | 935 | emsg); |
939 | lcf->state = FINISHED; | 936 | lcf->state = FINISHED; |
940 | lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf); | 937 | lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf); |
941 | } | 938 | } |
@@ -953,15 +950,15 @@ forwarded_operation_reply_relay (void *cls, | |||
953 | const struct GNUNET_MessageHeader *msg) | 950 | const struct GNUNET_MessageHeader *msg) |
954 | { | 951 | { |
955 | struct ForwardedOperationContext *fopc = cls; | 952 | struct ForwardedOperationContext *fopc = cls; |
956 | struct GNUNET_MessageHeader *dup_msg; | 953 | struct GNUNET_MessageHeader *dup_msg; |
957 | uint16_t msize; | 954 | uint16_t msize; |
958 | 955 | ||
959 | msize = ntohs (msg->size); | 956 | msize = ntohs (msg->size); |
960 | dup_msg = GNUNET_malloc (msize); | 957 | dup_msg = GNUNET_malloc (msize); |
961 | (void) memcpy (dup_msg, msg, msize); | 958 | (void) memcpy (dup_msg, msg, msize); |
962 | queue_message (fopc->client, dup_msg); | 959 | queue_message (fopc->client, dup_msg); |
963 | GNUNET_SERVER_client_drop (fopc->client); | 960 | GNUNET_SERVER_client_drop (fopc->client); |
964 | GNUNET_SCHEDULER_cancel (fopc->timeout_task); | 961 | GNUNET_SCHEDULER_cancel (fopc->timeout_task); |
965 | GNUNET_free (fopc); | 962 | GNUNET_free (fopc); |
966 | } | 963 | } |
967 | 964 | ||
@@ -974,15 +971,14 @@ forwarded_operation_reply_relay (void *cls, | |||
974 | */ | 971 | */ |
975 | static void | 972 | static void |
976 | forwarded_operation_timeout (void *cls, | 973 | forwarded_operation_timeout (void *cls, |
977 | const struct GNUNET_SCHEDULER_TaskContext | 974 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
978 | *tc) | ||
979 | { | 975 | { |
980 | struct ForwardedOperationContext *fopc = cls; | 976 | struct ForwardedOperationContext *fopc = cls; |
981 | 977 | ||
982 | GNUNET_TESTBED_forward_operation_msg_cancel_ (fopc->opc); | 978 | GNUNET_TESTBED_forward_operation_msg_cancel_ (fopc->opc); |
983 | send_operation_fail_msg (fopc->client, fopc->operation_id, "Timeout"); | 979 | send_operation_fail_msg (fopc->client, fopc->operation_id, "Timeout"); |
984 | GNUNET_SERVER_client_drop (fopc->client); | 980 | GNUNET_SERVER_client_drop (fopc->client); |
985 | GNUNET_free (fopc); | 981 | GNUNET_free (fopc); |
986 | } | 982 | } |
987 | 983 | ||
988 | 984 | ||
@@ -998,19 +994,19 @@ lcf_proc_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
998 | struct LCFContext *lcf = cls; | 994 | struct LCFContext *lcf = cls; |
999 | struct LCFContextQueue *lcfq; | 995 | struct LCFContextQueue *lcfq; |
1000 | struct ForwardedOperationContext *fopc; | 996 | struct ForwardedOperationContext *fopc; |
1001 | 997 | ||
1002 | lcf_proc_task_id = GNUNET_SCHEDULER_NO_TASK; | 998 | lcf_proc_task_id = GNUNET_SCHEDULER_NO_TASK; |
1003 | switch (lcf->state) | 999 | switch (lcf->state) |
1004 | { | 1000 | { |
1005 | case INIT: | 1001 | case INIT: |
1006 | if (GNUNET_NO == | 1002 | if (GNUNET_NO == |
1007 | GNUNET_TESTBED_is_host_registered_ (host_list[lcf->delegated_host_id], | 1003 | GNUNET_TESTBED_is_host_registered_ (host_list[lcf->delegated_host_id], |
1008 | lcf->gateway->controller)) | 1004 | lcf->gateway->controller)) |
1009 | { | 1005 | { |
1010 | lcf->rhandle = | 1006 | lcf->rhandle = |
1011 | GNUNET_TESTBED_register_host (lcf->gateway->controller, | 1007 | GNUNET_TESTBED_register_host (lcf->gateway->controller, |
1012 | host_list[lcf->delegated_host_id], | 1008 | host_list[lcf->delegated_host_id], |
1013 | lcf_proc_cc, lcf); | 1009 | lcf_proc_cc, lcf); |
1014 | } | 1010 | } |
1015 | else | 1011 | else |
1016 | { | 1012 | { |
@@ -1020,13 +1016,13 @@ lcf_proc_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1020 | break; | 1016 | break; |
1021 | case DELEGATED_HOST_REGISTERED: | 1017 | case DELEGATED_HOST_REGISTERED: |
1022 | if (GNUNET_NO == | 1018 | if (GNUNET_NO == |
1023 | GNUNET_TESTBED_is_host_registered_ (host_list[lcf->slave_host_id], | 1019 | GNUNET_TESTBED_is_host_registered_ (host_list[lcf->slave_host_id], |
1024 | lcf->gateway->controller)) | 1020 | lcf->gateway->controller)) |
1025 | { | 1021 | { |
1026 | lcf->rhandle = | 1022 | lcf->rhandle = |
1027 | GNUNET_TESTBED_register_host (lcf->gateway->controller, | 1023 | GNUNET_TESTBED_register_host (lcf->gateway->controller, |
1028 | host_list[lcf->slave_host_id], | 1024 | host_list[lcf->slave_host_id], |
1029 | lcf_proc_cc, lcf); | 1025 | lcf_proc_cc, lcf); |
1030 | } | 1026 | } |
1031 | else | 1027 | else |
1032 | { | 1028 | { |
@@ -1038,15 +1034,15 @@ lcf_proc_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1038 | fopc = GNUNET_malloc (sizeof (struct ForwardedOperationContext)); | 1034 | fopc = GNUNET_malloc (sizeof (struct ForwardedOperationContext)); |
1039 | fopc->client = lcf->client; | 1035 | fopc->client = lcf->client; |
1040 | fopc->operation_id = lcf->operation_id; | 1036 | fopc->operation_id = lcf->operation_id; |
1041 | fopc->opc = | 1037 | fopc->opc = |
1042 | GNUNET_TESTBED_forward_operation_msg_ (lcf->gateway->controller, | 1038 | GNUNET_TESTBED_forward_operation_msg_ (lcf->gateway->controller, |
1043 | lcf->operation_id, | 1039 | lcf->operation_id, |
1044 | &lcf->msg->header, | 1040 | &lcf->msg->header, |
1045 | &forwarded_operation_reply_relay, | 1041 | &forwarded_operation_reply_relay, |
1046 | fopc); | 1042 | fopc); |
1047 | fopc->timeout_task = | 1043 | fopc->timeout_task = |
1048 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 1044 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &forwarded_operation_timeout, |
1049 | &forwarded_operation_timeout, fopc); | 1045 | fopc); |
1050 | lcf->state = FINISHED; | 1046 | lcf->state = FINISHED; |
1051 | lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf); | 1047 | lcf_proc_task_id = GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcf); |
1052 | break; | 1048 | break; |
@@ -1058,8 +1054,8 @@ lcf_proc_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1058 | GNUNET_CONTAINER_DLL_remove (lcfq_head, lcfq_tail, lcfq); | 1054 | GNUNET_CONTAINER_DLL_remove (lcfq_head, lcfq_tail, lcfq); |
1059 | GNUNET_free (lcfq); | 1055 | GNUNET_free (lcfq); |
1060 | if (NULL != lcfq_head) | 1056 | if (NULL != lcfq_head) |
1061 | lcf_proc_task_id = | 1057 | lcf_proc_task_id = |
1062 | GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcfq_head->lcf); | 1058 | GNUNET_SCHEDULER_add_now (&lcf_proc_task, lcfq_head->lcf); |
1063 | } | 1059 | } |
1064 | } | 1060 | } |
1065 | 1061 | ||
@@ -1070,9 +1066,9 @@ lcf_proc_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1070 | * @param cls struct Slave * | 1066 | * @param cls struct Slave * |
1071 | * @param event information about the event | 1067 | * @param event information about the event |
1072 | */ | 1068 | */ |
1073 | static void | 1069 | static void |
1074 | slave_event_callback (void *cls, | 1070 | slave_event_callback (void *cls, |
1075 | const struct GNUNET_TESTBED_EventInformation *event) | 1071 | const struct GNUNET_TESTBED_EventInformation *event) |
1076 | { | 1072 | { |
1077 | GNUNET_break (0); | 1073 | GNUNET_break (0); |
1078 | } | 1074 | } |
@@ -1087,9 +1083,8 @@ slave_event_callback (void *cls, | |||
1087 | * @param status GNUNET_OK if the startup is successfull; GNUNET_SYSERR if not, | 1083 | * @param status GNUNET_OK if the startup is successfull; GNUNET_SYSERR if not, |
1088 | * GNUNET_TESTBED_controller_stop() shouldn't be called in this case | 1084 | * GNUNET_TESTBED_controller_stop() shouldn't be called in this case |
1089 | */ | 1085 | */ |
1090 | static void | 1086 | static void |
1091 | slave_status_callback (void *cls, | 1087 | slave_status_callback (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, |
1092 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
1093 | int status) | 1088 | int status) |
1094 | { | 1089 | { |
1095 | struct LinkControllersContext *lcc = cls; | 1090 | struct LinkControllersContext *lcc = cls; |
@@ -1097,20 +1092,19 @@ slave_status_callback (void *cls, | |||
1097 | if (GNUNET_SYSERR == status) | 1092 | if (GNUNET_SYSERR == status) |
1098 | { | 1093 | { |
1099 | lcc->slave->controller_proc = NULL; | 1094 | lcc->slave->controller_proc = NULL; |
1100 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1095 | LOG (GNUNET_ERROR_TYPE_WARNING, "Unexpected slave shutdown\n"); |
1101 | "Unexpected slave shutdown\n"); | 1096 | GNUNET_SCHEDULER_shutdown (); /* We too shutdown */ |
1102 | GNUNET_SCHEDULER_shutdown (); /* We too shutdown */ | ||
1103 | return; | 1097 | return; |
1104 | } | 1098 | } |
1105 | lcc->slave->controller = | 1099 | lcc->slave->controller = |
1106 | GNUNET_TESTBED_controller_connect (cfg, host_list[lcc->slave->host_id], | 1100 | GNUNET_TESTBED_controller_connect (cfg, host_list[lcc->slave->host_id], |
1107 | master_context->event_mask, | 1101 | master_context->event_mask, |
1108 | &slave_event_callback, lcc->slave); | 1102 | &slave_event_callback, lcc->slave); |
1109 | if (NULL != lcc->slave->controller) | 1103 | if (NULL != lcc->slave->controller) |
1110 | send_operation_success_msg (lcc->client, lcc->operation_id); | 1104 | send_operation_success_msg (lcc->client, lcc->operation_id); |
1111 | else | 1105 | else |
1112 | send_operation_fail_msg (lcc->client, lcc->operation_id, | 1106 | send_operation_fail_msg (lcc->client, lcc->operation_id, |
1113 | "Could not connect to delegated controller"); | 1107 | "Could not connect to delegated controller"); |
1114 | GNUNET_SERVER_client_drop (lcc->client); | 1108 | GNUNET_SERVER_client_drop (lcc->client); |
1115 | GNUNET_free (lcc); | 1109 | GNUNET_free (lcc); |
1116 | } | 1110 | } |
@@ -1123,9 +1117,8 @@ slave_status_callback (void *cls, | |||
1123 | * @param client identification of the client | 1117 | * @param client identification of the client |
1124 | * @param message the actual message | 1118 | * @param message the actual message |
1125 | */ | 1119 | */ |
1126 | static void | 1120 | static void |
1127 | handle_init (void *cls, | 1121 | handle_init (void *cls, struct GNUNET_SERVER_Client *client, |
1128 | struct GNUNET_SERVER_Client *client, | ||
1129 | const struct GNUNET_MessageHeader *message) | 1122 | const struct GNUNET_MessageHeader *message) |
1130 | { | 1123 | { |
1131 | const struct GNUNET_TESTBED_InitMessage *msg; | 1124 | const struct GNUNET_TESTBED_InitMessage *msg; |
@@ -1147,23 +1140,24 @@ handle_init (void *cls, | |||
1147 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1140 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
1148 | return; | 1141 | return; |
1149 | } | 1142 | } |
1150 | msize -= sizeof (struct GNUNET_TESTBED_InitMessage); | 1143 | msize -= sizeof (struct GNUNET_TESTBED_InitMessage); |
1151 | controller_hostname = (const char *) &msg[1]; | 1144 | controller_hostname = (const char *) &msg[1]; |
1152 | if ('\0' != controller_hostname[msize - 1]) | 1145 | if ('\0' != controller_hostname[msize - 1]) |
1153 | { | 1146 | { |
1154 | GNUNET_break (0); | 1147 | GNUNET_break (0); |
1155 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1148 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
1156 | return; | 1149 | return; |
1157 | } | 1150 | } |
1158 | master_context = GNUNET_malloc (sizeof (struct Context)); | 1151 | master_context = GNUNET_malloc (sizeof (struct Context)); |
1159 | master_context->client = client; | 1152 | master_context->client = client; |
1160 | master_context->host_id = ntohl (msg->host_id); | 1153 | master_context->host_id = ntohl (msg->host_id); |
1161 | master_context->master_ip = GNUNET_strdup (controller_hostname); | 1154 | master_context->master_ip = GNUNET_strdup (controller_hostname); |
1162 | LOG_DEBUG ("Master Controller IP: %s\n", master_context->master_ip); | 1155 | LOG_DEBUG ("Master Controller IP: %s\n", master_context->master_ip); |
1163 | master_context->system = | 1156 | master_context->system = |
1164 | GNUNET_TESTING_system_create ("testbed", master_context->master_ip); | 1157 | GNUNET_TESTING_system_create ("testbed", master_context->master_ip); |
1165 | host = GNUNET_TESTBED_host_create_with_id (master_context->host_id, | 1158 | host = |
1166 | NULL, NULL, 0); | 1159 | GNUNET_TESTBED_host_create_with_id (master_context->host_id, NULL, NULL, |
1160 | 0); | ||
1167 | host_list_add (host); | 1161 | host_list_add (host); |
1168 | master_context->event_mask = GNUNET_ntohll (msg->event_mask); | 1162 | master_context->event_mask = GNUNET_ntohll (msg->event_mask); |
1169 | GNUNET_SERVER_client_keep (client); | 1163 | GNUNET_SERVER_client_keep (client); |
@@ -1180,9 +1174,8 @@ handle_init (void *cls, | |||
1180 | * @param client identification of the client | 1174 | * @param client identification of the client |
1181 | * @param message the actual message | 1175 | * @param message the actual message |
1182 | */ | 1176 | */ |
1183 | static void | 1177 | static void |
1184 | handle_add_host (void *cls, | 1178 | handle_add_host (void *cls, struct GNUNET_SERVER_Client *client, |
1185 | struct GNUNET_SERVER_Client *client, | ||
1186 | const struct GNUNET_MessageHeader *message) | 1179 | const struct GNUNET_MessageHeader *message) |
1187 | { | 1180 | { |
1188 | struct GNUNET_TESTBED_Host *host; | 1181 | struct GNUNET_TESTBED_Host *host; |
@@ -1196,39 +1189,41 @@ handle_add_host (void *cls, | |||
1196 | uint16_t hostname_length; | 1189 | uint16_t hostname_length; |
1197 | uint16_t reply_size; | 1190 | uint16_t reply_size; |
1198 | uint16_t msize; | 1191 | uint16_t msize; |
1199 | 1192 | ||
1200 | msg = (const struct GNUNET_TESTBED_AddHostMessage *) message; | 1193 | msg = (const struct GNUNET_TESTBED_AddHostMessage *) message; |
1201 | msize = ntohs (msg->header.size); | 1194 | msize = ntohs (msg->header.size); |
1202 | username = (char *) &(msg[1]); | 1195 | username = (char *) &(msg[1]); |
1203 | username_length = ntohs (msg->user_name_length); | 1196 | username_length = ntohs (msg->user_name_length); |
1204 | GNUNET_assert (msize > (sizeof (struct GNUNET_TESTBED_AddHostMessage) | 1197 | GNUNET_assert (msize > (sizeof (struct GNUNET_TESTBED_AddHostMessage) + username_length + 1)); /* msg must contain hostname */ |
1205 | + username_length + 1)); /* msg must contain hostname */ | ||
1206 | if (0 != username_length) | 1198 | if (0 != username_length) |
1207 | GNUNET_assert ('\0' == username[username_length]); | 1199 | GNUNET_assert ('\0' == username[username_length]); |
1208 | username_length = (0 == username_length) ? 0 : username_length + 1; | 1200 | username_length = (0 == username_length) ? 0 : username_length + 1; |
1209 | hostname = username + username_length; | 1201 | hostname = username + username_length; |
1210 | hostname_length = msize - (sizeof (struct GNUNET_TESTBED_AddHostMessage) | 1202 | hostname_length = |
1211 | + username_length); | 1203 | msize - (sizeof (struct GNUNET_TESTBED_AddHostMessage) + username_length); |
1212 | GNUNET_assert ('\0' == hostname[hostname_length - 1]); | 1204 | GNUNET_assert ('\0' == hostname[hostname_length - 1]); |
1213 | GNUNET_assert (strlen (hostname) == hostname_length - 1); | 1205 | GNUNET_assert (strlen (hostname) == hostname_length - 1); |
1214 | host_id = ntohl (msg->host_id); | 1206 | host_id = ntohl (msg->host_id); |
1215 | LOG_DEBUG ("Received ADDHOST message\n"); | 1207 | LOG_DEBUG ("Received ADDHOST message\n"); |
1216 | LOG_DEBUG ("-------host id: %u\n", host_id); | 1208 | LOG_DEBUG ("-------host id: %u\n", host_id); |
1217 | if (NULL != hostname) LOG_DEBUG ("-------hostname: %s\n", hostname); | 1209 | if (NULL != hostname) |
1218 | if (0 != username_length) LOG_DEBUG ("-------username: %s\n", username); | 1210 | LOG_DEBUG ("-------hostname: %s\n", hostname); |
1219 | else | 1211 | if (0 != username_length) |
1212 | LOG_DEBUG ("-------username: %s\n", username); | ||
1213 | else | ||
1220 | { | 1214 | { |
1221 | LOG_DEBUG ("-------username: NULL\n"); | 1215 | LOG_DEBUG ("-------username: NULL\n"); |
1222 | username = NULL; | 1216 | username = NULL; |
1223 | } | 1217 | } |
1224 | LOG_DEBUG ("-------ssh port: %u\n", ntohs (msg->ssh_port)); | 1218 | LOG_DEBUG ("-------ssh port: %u\n", ntohs (msg->ssh_port)); |
1225 | host = GNUNET_TESTBED_host_create_with_id (host_id, hostname, username, | 1219 | host = |
1226 | ntohs (msg->ssh_port)); | 1220 | GNUNET_TESTBED_host_create_with_id (host_id, hostname, username, |
1221 | ntohs (msg->ssh_port)); | ||
1227 | GNUNET_assert (NULL != host); | 1222 | GNUNET_assert (NULL != host); |
1228 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1223 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
1229 | reply_size = sizeof (struct GNUNET_TESTBED_HostConfirmedMessage); | 1224 | reply_size = sizeof (struct GNUNET_TESTBED_HostConfirmedMessage); |
1230 | if (GNUNET_OK != host_list_add (host)) | 1225 | if (GNUNET_OK != host_list_add (host)) |
1231 | { | 1226 | { |
1232 | /* We are unable to add a host */ | 1227 | /* We are unable to add a host */ |
1233 | emsg = "A host exists with given host-id"; | 1228 | emsg = "A host exists with given host-id"; |
1234 | LOG_DEBUG ("%s: %u", emsg, host_id); | 1229 | LOG_DEBUG ("%s: %u", emsg, host_id); |
@@ -1238,10 +1233,10 @@ handle_add_host (void *cls, | |||
1238 | memcpy (&reply[1], emsg, strlen (emsg) + 1); | 1233 | memcpy (&reply[1], emsg, strlen (emsg) + 1); |
1239 | } | 1234 | } |
1240 | else | 1235 | else |
1241 | reply = GNUNET_malloc (reply_size); | 1236 | reply = GNUNET_malloc (reply_size); |
1242 | reply->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_ADDHOSTCONFIRM); | 1237 | reply->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_ADDHOSTCONFIRM); |
1243 | reply->header.size = htons (reply_size); | 1238 | reply->header.size = htons (reply_size); |
1244 | reply->host_id = htonl (host_id); | 1239 | reply->host_id = htonl (host_id); |
1245 | queue_message (client, &reply->header); | 1240 | queue_message (client, &reply->header); |
1246 | } | 1241 | } |
1247 | 1242 | ||
@@ -1256,9 +1251,8 @@ handle_add_host (void *cls, | |||
1256 | * iterate, | 1251 | * iterate, |
1257 | * GNUNET_NO if not. | 1252 | * GNUNET_NO if not. |
1258 | */ | 1253 | */ |
1259 | int ss_exists_iterator (void *cls, | 1254 | int |
1260 | const struct GNUNET_HashCode * key, | 1255 | ss_exists_iterator (void *cls, const struct GNUNET_HashCode *key, void *value) |
1261 | void *value) | ||
1262 | { | 1256 | { |
1263 | struct SharedService *queried_ss = cls; | 1257 | struct SharedService *queried_ss = cls; |
1264 | struct SharedService *ss = value; | 1258 | struct SharedService *ss = value; |
@@ -1277,9 +1271,8 @@ int ss_exists_iterator (void *cls, | |||
1277 | * @param client identification of the client | 1271 | * @param client identification of the client |
1278 | * @param message the actual message | 1272 | * @param message the actual message |
1279 | */ | 1273 | */ |
1280 | static void | 1274 | static void |
1281 | handle_configure_shared_service (void *cls, | 1275 | handle_configure_shared_service (void *cls, struct GNUNET_SERVER_Client *client, |
1282 | struct GNUNET_SERVER_Client *client, | ||
1283 | const struct GNUNET_MessageHeader *message) | 1276 | const struct GNUNET_MessageHeader *message) |
1284 | { | 1277 | { |
1285 | const struct GNUNET_TESTBED_ConfigureSharedServiceMessage *msg; | 1278 | const struct GNUNET_TESTBED_ConfigureSharedServiceMessage *msg; |
@@ -1288,7 +1281,7 @@ handle_configure_shared_service (void *cls, | |||
1288 | struct GNUNET_HashCode hash; | 1281 | struct GNUNET_HashCode hash; |
1289 | uint16_t msg_size; | 1282 | uint16_t msg_size; |
1290 | uint16_t service_name_size; | 1283 | uint16_t service_name_size; |
1291 | 1284 | ||
1292 | msg = (const struct GNUNET_TESTBED_ConfigureSharedServiceMessage *) message; | 1285 | msg = (const struct GNUNET_TESTBED_ConfigureSharedServiceMessage *) message; |
1293 | msg_size = ntohs (message->size); | 1286 | msg_size = ntohs (message->size); |
1294 | if (msg_size <= sizeof (struct GNUNET_TESTBED_ConfigureSharedServiceMessage)) | 1287 | if (msg_size <= sizeof (struct GNUNET_TESTBED_ConfigureSharedServiceMessage)) |
@@ -1297,8 +1290,8 @@ handle_configure_shared_service (void *cls, | |||
1297 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1290 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
1298 | return; | 1291 | return; |
1299 | } | 1292 | } |
1300 | service_name_size = msg_size - | 1293 | service_name_size = |
1301 | sizeof (struct GNUNET_TESTBED_ConfigureSharedServiceMessage); | 1294 | msg_size - sizeof (struct GNUNET_TESTBED_ConfigureSharedServiceMessage); |
1302 | service_name = (char *) &msg[1]; | 1295 | service_name = (char *) &msg[1]; |
1303 | if ('\0' != service_name[service_name_size - 1]) | 1296 | if ('\0' != service_name[service_name_size - 1]) |
1304 | { | 1297 | { |
@@ -1319,7 +1312,7 @@ handle_configure_shared_service (void *cls, | |||
1319 | ss->name = strdup (service_name); | 1312 | ss->name = strdup (service_name); |
1320 | ss->num_shared = ntohl (msg->num_peers); | 1313 | ss->num_shared = ntohl (msg->num_peers); |
1321 | GNUNET_CRYPTO_hash (ss->name, service_name_size, &hash); | 1314 | GNUNET_CRYPTO_hash (ss->name, service_name_size, &hash); |
1322 | if (GNUNET_SYSERR == | 1315 | if (GNUNET_SYSERR == |
1323 | GNUNET_CONTAINER_multihashmap_get_multiple (ss_map, &hash, | 1316 | GNUNET_CONTAINER_multihashmap_get_multiple (ss_map, &hash, |
1324 | &ss_exists_iterator, ss)) | 1317 | &ss_exists_iterator, ss)) |
1325 | { | 1318 | { |
@@ -1331,7 +1324,7 @@ handle_configure_shared_service (void *cls, | |||
1331 | return; | 1324 | return; |
1332 | } | 1325 | } |
1333 | GNUNET_CONTAINER_multihashmap_put (ss_map, &hash, ss, | 1326 | GNUNET_CONTAINER_multihashmap_put (ss_map, &hash, ss, |
1334 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 1327 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
1335 | } | 1328 | } |
1336 | 1329 | ||
1337 | 1330 | ||
@@ -1342,9 +1335,8 @@ handle_configure_shared_service (void *cls, | |||
1342 | * @param client identification of the client | 1335 | * @param client identification of the client |
1343 | * @param message the actual message | 1336 | * @param message the actual message |
1344 | */ | 1337 | */ |
1345 | static void | 1338 | static void |
1346 | handle_link_controllers (void *cls, | 1339 | handle_link_controllers (void *cls, struct GNUNET_SERVER_Client *client, |
1347 | struct GNUNET_SERVER_Client *client, | ||
1348 | const struct GNUNET_MessageHeader *message) | 1340 | const struct GNUNET_MessageHeader *message) |
1349 | { | 1341 | { |
1350 | const struct GNUNET_TESTBED_ControllerLinkMessage *msg; | 1342 | const struct GNUNET_TESTBED_ControllerLinkMessage *msg; |
@@ -1352,13 +1344,13 @@ handle_link_controllers (void *cls, | |||
1352 | struct LCFContextQueue *lcfq; | 1344 | struct LCFContextQueue *lcfq; |
1353 | struct Route *route; | 1345 | struct Route *route; |
1354 | struct Route *new_route; | 1346 | struct Route *new_route; |
1355 | char *config; | 1347 | char *config; |
1356 | uLongf dest_size; | 1348 | uLongf dest_size; |
1357 | size_t config_size; | 1349 | size_t config_size; |
1358 | uint32_t delegated_host_id; | 1350 | uint32_t delegated_host_id; |
1359 | uint32_t slave_host_id; | 1351 | uint32_t slave_host_id; |
1360 | uint16_t msize; | 1352 | uint16_t msize; |
1361 | 1353 | ||
1362 | if (NULL == master_context) | 1354 | if (NULL == master_context) |
1363 | { | 1355 | { |
1364 | GNUNET_break (0); | 1356 | GNUNET_break (0); |
@@ -1381,7 +1373,7 @@ handle_link_controllers (void *cls, | |||
1381 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1373 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
1382 | return; | 1374 | return; |
1383 | } | 1375 | } |
1384 | if ((delegated_host_id >= host_list_size) || | 1376 | if ((delegated_host_id >= host_list_size) || |
1385 | (NULL == host_list[delegated_host_id])) | 1377 | (NULL == host_list[delegated_host_id])) |
1386 | { | 1378 | { |
1387 | LOG (GNUNET_ERROR_TYPE_WARNING, "Delegated host not registered with us\n"); | 1379 | LOG (GNUNET_ERROR_TYPE_WARNING, "Delegated host not registered with us\n"); |
@@ -1400,28 +1392,28 @@ handle_link_controllers (void *cls, | |||
1400 | LOG (GNUNET_ERROR_TYPE_WARNING, "Slave and delegated host are same\n"); | 1392 | LOG (GNUNET_ERROR_TYPE_WARNING, "Slave and delegated host are same\n"); |
1401 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1393 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
1402 | return; | 1394 | return; |
1403 | } | 1395 | } |
1404 | 1396 | ||
1405 | if (slave_host_id == master_context->host_id) /* Link from us */ | 1397 | if (slave_host_id == master_context->host_id) /* Link from us */ |
1406 | { | 1398 | { |
1407 | struct Slave *slave; | 1399 | struct Slave *slave; |
1408 | 1400 | ||
1409 | msize -= sizeof (struct GNUNET_TESTBED_ControllerLinkMessage); | 1401 | msize -= sizeof (struct GNUNET_TESTBED_ControllerLinkMessage); |
1410 | config_size = ntohs (msg->config_size); | 1402 | config_size = ntohs (msg->config_size); |
1411 | if ((delegated_host_id < slave_list_size) && | 1403 | if ((delegated_host_id < slave_list_size) && (NULL != slave_list[delegated_host_id])) /* We have already added */ |
1412 | (NULL != slave_list[delegated_host_id])) /* We have already added */ | ||
1413 | { | 1404 | { |
1414 | LOG (GNUNET_ERROR_TYPE_WARNING, "Host %u already connected\n", | 1405 | LOG (GNUNET_ERROR_TYPE_WARNING, "Host %u already connected\n", |
1415 | delegated_host_id); | 1406 | delegated_host_id); |
1416 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1407 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
1417 | return; | 1408 | return; |
1418 | } | 1409 | } |
1419 | config = GNUNET_malloc (config_size); | 1410 | config = GNUNET_malloc (config_size); |
1420 | dest_size = (uLongf) config_size; | 1411 | dest_size = (uLongf) config_size; |
1421 | if (Z_OK != uncompress ((Bytef *) config, &dest_size, | 1412 | if (Z_OK != |
1422 | (const Bytef *) &msg[1], (uLong) msize)) | 1413 | uncompress ((Bytef *) config, &dest_size, (const Bytef *) &msg[1], |
1414 | (uLong) msize)) | ||
1423 | { | 1415 | { |
1424 | GNUNET_break (0); /* Compression error */ | 1416 | GNUNET_break (0); /* Compression error */ |
1425 | GNUNET_free (config); | 1417 | GNUNET_free (config); |
1426 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1418 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
1427 | return; | 1419 | return; |
@@ -1433,50 +1425,51 @@ handle_link_controllers (void *cls, | |||
1433 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1425 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
1434 | return; | 1426 | return; |
1435 | } | 1427 | } |
1436 | cfg = GNUNET_CONFIGURATION_create (); /* Free here or in lcfcontext */ | 1428 | cfg = GNUNET_CONFIGURATION_create (); /* Free here or in lcfcontext */ |
1437 | if (GNUNET_OK != GNUNET_CONFIGURATION_deserialize (cfg, config, config_size, | 1429 | if (GNUNET_OK != |
1438 | GNUNET_NO)) | 1430 | GNUNET_CONFIGURATION_deserialize (cfg, config, config_size, GNUNET_NO)) |
1439 | { | 1431 | { |
1440 | GNUNET_break (0); /* Configuration parsing error */ | 1432 | GNUNET_break (0); /* Configuration parsing error */ |
1441 | GNUNET_free (config); | 1433 | GNUNET_free (config); |
1442 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1434 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
1443 | return; | 1435 | return; |
1444 | } | 1436 | } |
1445 | GNUNET_free (config); | 1437 | GNUNET_free (config); |
1446 | if ((delegated_host_id < slave_list_size) && | 1438 | if ((delegated_host_id < slave_list_size) && |
1447 | (NULL != slave_list[delegated_host_id])) | 1439 | (NULL != slave_list[delegated_host_id])) |
1448 | { | 1440 | { |
1449 | GNUNET_break (0); /* Configuration parsing error */ | 1441 | GNUNET_break (0); /* Configuration parsing error */ |
1450 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1442 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
1451 | return; | 1443 | return; |
1452 | } | 1444 | } |
1453 | slave = GNUNET_malloc (sizeof (struct Slave)); | 1445 | slave = GNUNET_malloc (sizeof (struct Slave)); |
1454 | slave->host_id = delegated_host_id; | 1446 | slave->host_id = delegated_host_id; |
1455 | slave_list_add (slave); | 1447 | slave_list_add (slave); |
1456 | if (1 == msg->is_subordinate) | 1448 | if (1 == msg->is_subordinate) |
1457 | { | 1449 | { |
1458 | struct LinkControllersContext *lcc; | 1450 | struct LinkControllersContext *lcc; |
1451 | |||
1459 | lcc = GNUNET_malloc (sizeof (struct LinkControllersContext)); | 1452 | lcc = GNUNET_malloc (sizeof (struct LinkControllersContext)); |
1460 | lcc->operation_id = GNUNET_ntohll (msg->operation_id); | 1453 | lcc->operation_id = GNUNET_ntohll (msg->operation_id); |
1461 | GNUNET_SERVER_client_keep (client); | 1454 | GNUNET_SERVER_client_keep (client); |
1462 | lcc->client = client; | 1455 | lcc->client = client; |
1463 | lcc->slave = slave; | 1456 | lcc->slave = slave; |
1464 | slave->controller_proc = | 1457 | slave->controller_proc = |
1465 | GNUNET_TESTBED_controller_start (master_context->master_ip, | 1458 | GNUNET_TESTBED_controller_start (master_context->master_ip, |
1466 | host_list[slave->host_id], | 1459 | host_list[slave->host_id], cfg, |
1467 | cfg, &slave_status_callback, | 1460 | &slave_status_callback, lcc); |
1468 | lcc); | ||
1469 | } | 1461 | } |
1470 | else { | 1462 | else |
1471 | slave->controller = | 1463 | { |
1472 | GNUNET_TESTBED_controller_connect (cfg, host_list[slave->host_id], | 1464 | slave->controller = |
1473 | master_context->event_mask, | 1465 | GNUNET_TESTBED_controller_connect (cfg, host_list[slave->host_id], |
1474 | &slave_event_callback, slave); | 1466 | master_context->event_mask, |
1467 | &slave_event_callback, slave); | ||
1475 | if (NULL != slave->controller) | 1468 | if (NULL != slave->controller) |
1476 | send_operation_success_msg (client, GNUNET_ntohll (msg->operation_id)); | 1469 | send_operation_success_msg (client, GNUNET_ntohll (msg->operation_id)); |
1477 | else | 1470 | else |
1478 | send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id), | 1471 | send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id), |
1479 | "Could not connect to delegated controller"); | 1472 | "Could not connect to delegated controller"); |
1480 | } | 1473 | } |
1481 | GNUNET_CONFIGURATION_destroy (cfg); | 1474 | GNUNET_CONFIGURATION_destroy (cfg); |
1482 | new_route = GNUNET_malloc (sizeof (struct Route)); | 1475 | new_route = GNUNET_malloc (sizeof (struct Route)); |
@@ -1499,9 +1492,9 @@ handle_link_controllers (void *cls, | |||
1499 | lcfq->lcf->delegated_host_id = delegated_host_id; | 1492 | lcfq->lcf->delegated_host_id = delegated_host_id; |
1500 | lcfq->lcf->slave_host_id = slave_host_id; | 1493 | lcfq->lcf->slave_host_id = slave_host_id; |
1501 | route = find_dest_route (slave_host_id); | 1494 | route = find_dest_route (slave_host_id); |
1502 | GNUNET_assert (NULL != route); /* because we add routes carefully */ | 1495 | GNUNET_assert (NULL != route); /* because we add routes carefully */ |
1503 | GNUNET_assert (route->dest < slave_list_size); | 1496 | GNUNET_assert (route->dest < slave_list_size); |
1504 | GNUNET_assert (NULL != slave_list[route->dest]); | 1497 | GNUNET_assert (NULL != slave_list[route->dest]); |
1505 | lcfq->lcf->state = INIT; | 1498 | lcfq->lcf->state = INIT; |
1506 | lcfq->lcf->operation_id = GNUNET_ntohll (msg->operation_id); | 1499 | lcfq->lcf->operation_id = GNUNET_ntohll (msg->operation_id); |
1507 | lcfq->lcf->gateway = slave_list[route->dest]; | 1500 | lcfq->lcf->gateway = slave_list[route->dest]; |
@@ -1518,7 +1511,7 @@ handle_link_controllers (void *cls, | |||
1518 | else | 1511 | else |
1519 | GNUNET_CONTAINER_DLL_insert_tail (lcfq_head, lcfq_tail, lcfq); | 1512 | GNUNET_CONTAINER_DLL_insert_tail (lcfq_head, lcfq_tail, lcfq); |
1520 | /* FIXME: Adding a new route should happen after the controllers are linked | 1513 | /* FIXME: Adding a new route should happen after the controllers are linked |
1521 | successfully */ | 1514 | * successfully */ |
1522 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1515 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
1523 | new_route = GNUNET_malloc (sizeof (struct Route)); | 1516 | new_route = GNUNET_malloc (sizeof (struct Route)); |
1524 | new_route->dest = delegated_host_id; | 1517 | new_route->dest = delegated_host_id; |
@@ -1539,13 +1532,12 @@ peer_create_forward_timeout (void *cls, | |||
1539 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 1532 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
1540 | { | 1533 | { |
1541 | struct ForwardedOperationContext *fo_ctxt = cls; | 1534 | struct ForwardedOperationContext *fo_ctxt = cls; |
1542 | 1535 | ||
1543 | /* send error msg to client */ | 1536 | /* send error msg to client */ |
1544 | send_operation_fail_msg (fo_ctxt->client, fo_ctxt->operation_id, | 1537 | send_operation_fail_msg (fo_ctxt->client, fo_ctxt->operation_id, "Timedout"); |
1545 | "Timedout"); | ||
1546 | GNUNET_SERVER_client_drop (fo_ctxt->client); | 1538 | GNUNET_SERVER_client_drop (fo_ctxt->client); |
1547 | GNUNET_TESTBED_forward_operation_msg_cancel_ (fo_ctxt->opc); | 1539 | GNUNET_TESTBED_forward_operation_msg_cancel_ (fo_ctxt->opc); |
1548 | GNUNET_free (fo_ctxt); | 1540 | GNUNET_free (fo_ctxt); |
1549 | } | 1541 | } |
1550 | 1542 | ||
1551 | 1543 | ||
@@ -1557,33 +1549,32 @@ peer_create_forward_timeout (void *cls, | |||
1557 | * @param msg the peer create success message | 1549 | * @param msg the peer create success message |
1558 | */ | 1550 | */ |
1559 | static void | 1551 | static void |
1560 | peer_create_success_cb (void *cls, | 1552 | peer_create_success_cb (void *cls, const struct GNUNET_MessageHeader *msg) |
1561 | const struct GNUNET_MessageHeader *msg) | ||
1562 | { | 1553 | { |
1563 | struct ForwardedOperationContext *fo_ctxt = cls; | 1554 | struct ForwardedOperationContext *fo_ctxt = cls; |
1564 | const struct GNUNET_TESTBED_PeerCreateSuccessEventMessage *success_msg; | 1555 | const struct GNUNET_TESTBED_PeerCreateSuccessEventMessage *success_msg; |
1565 | struct GNUNET_MessageHeader *dup_msg; | 1556 | struct GNUNET_MessageHeader *dup_msg; |
1566 | struct Peer *peer; | 1557 | struct Peer *peer; |
1567 | uint16_t msize; | 1558 | uint16_t msize; |
1568 | 1559 | ||
1569 | GNUNET_SCHEDULER_cancel (fo_ctxt->timeout_task); | 1560 | GNUNET_SCHEDULER_cancel (fo_ctxt->timeout_task); |
1570 | if (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_TESTBED_PEERCREATESUCCESS) | 1561 | if (ntohs (msg->type) == GNUNET_MESSAGE_TYPE_TESTBED_PEERCREATESUCCESS) |
1571 | { | 1562 | { |
1572 | success_msg | 1563 | success_msg = |
1573 | = (const struct GNUNET_TESTBED_PeerCreateSuccessEventMessage *) msg; | 1564 | (const struct GNUNET_TESTBED_PeerCreateSuccessEventMessage *) msg; |
1574 | peer = GNUNET_malloc (sizeof (struct Peer)); | 1565 | peer = GNUNET_malloc (sizeof (struct Peer)); |
1575 | peer->is_remote = GNUNET_YES; | 1566 | peer->is_remote = GNUNET_YES; |
1576 | peer->id = ntohl (success_msg->peer_id); | 1567 | peer->id = ntohl (success_msg->peer_id); |
1577 | GNUNET_assert (NULL != fo_ctxt->cls); | 1568 | GNUNET_assert (NULL != fo_ctxt->cls); |
1578 | peer->details.remote.controller = fo_ctxt->cls; | 1569 | peer->details.remote.controller = fo_ctxt->cls; |
1579 | peer_list_add (peer); | 1570 | peer_list_add (peer); |
1580 | } | 1571 | } |
1581 | msize = ntohs (msg->size); | 1572 | msize = ntohs (msg->size); |
1582 | dup_msg = GNUNET_malloc (msize); | 1573 | dup_msg = GNUNET_malloc (msize); |
1583 | (void) memcpy (dup_msg, msg, msize); | 1574 | (void) memcpy (dup_msg, msg, msize); |
1584 | queue_message (fo_ctxt->client, dup_msg); | 1575 | queue_message (fo_ctxt->client, dup_msg); |
1585 | GNUNET_SERVER_client_drop (fo_ctxt->client); | 1576 | GNUNET_SERVER_client_drop (fo_ctxt->client); |
1586 | GNUNET_free (fo_ctxt); | 1577 | GNUNET_free (fo_ctxt); |
1587 | } | 1578 | } |
1588 | 1579 | ||
1589 | 1580 | ||
@@ -1595,9 +1586,8 @@ peer_create_success_cb (void *cls, | |||
1595 | * @param client identification of the client | 1586 | * @param client identification of the client |
1596 | * @param message the actual message | 1587 | * @param message the actual message |
1597 | */ | 1588 | */ |
1598 | static void | 1589 | static void |
1599 | handle_peer_create (void *cls, | 1590 | handle_peer_create (void *cls, struct GNUNET_SERVER_Client *client, |
1600 | struct GNUNET_SERVER_Client *client, | ||
1601 | const struct GNUNET_MessageHeader *message) | 1591 | const struct GNUNET_MessageHeader *message) |
1602 | { | 1592 | { |
1603 | const struct GNUNET_TESTBED_PeerCreateMessage *msg; | 1593 | const struct GNUNET_TESTBED_PeerCreateMessage *msg; |
@@ -1613,7 +1603,7 @@ handle_peer_create (void *cls, | |||
1613 | uint32_t host_id; | 1603 | uint32_t host_id; |
1614 | uint32_t peer_id; | 1604 | uint32_t peer_id; |
1615 | uint16_t msize; | 1605 | uint16_t msize; |
1616 | 1606 | ||
1617 | 1607 | ||
1618 | msize = ntohs (message->size); | 1608 | msize = ntohs (message->size); |
1619 | if (msize <= sizeof (struct GNUNET_TESTBED_PeerCreateMessage)) | 1609 | if (msize <= sizeof (struct GNUNET_TESTBED_PeerCreateMessage)) |
@@ -1635,31 +1625,33 @@ handle_peer_create (void *cls, | |||
1635 | if (host_id == master_context->host_id) | 1625 | if (host_id == master_context->host_id) |
1636 | { | 1626 | { |
1637 | char *emsg; | 1627 | char *emsg; |
1638 | 1628 | ||
1639 | /* We are responsible for this peer */ | 1629 | /* We are responsible for this peer */ |
1640 | msize -= sizeof (struct GNUNET_TESTBED_PeerCreateMessage); | 1630 | msize -= sizeof (struct GNUNET_TESTBED_PeerCreateMessage); |
1641 | config_size = ntohl (msg->config_size); | 1631 | config_size = ntohl (msg->config_size); |
1642 | config = GNUNET_malloc (config_size); | 1632 | config = GNUNET_malloc (config_size); |
1643 | dest_size = config_size; | 1633 | dest_size = config_size; |
1644 | if (Z_OK != (ret = uncompress ((Bytef *) config, (uLongf *) &dest_size, | 1634 | if (Z_OK != |
1645 | (const Bytef *) &msg[1], (uLong) msize))) | 1635 | (ret = |
1636 | uncompress ((Bytef *) config, (uLongf *) & dest_size, | ||
1637 | (const Bytef *) &msg[1], (uLong) msize))) | ||
1646 | { | 1638 | { |
1647 | GNUNET_break (0); /* uncompression error */ | 1639 | GNUNET_break (0); /* uncompression error */ |
1648 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1640 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
1649 | return; | 1641 | return; |
1650 | } | 1642 | } |
1651 | if (config_size != dest_size) | 1643 | if (config_size != dest_size) |
1652 | { | 1644 | { |
1653 | GNUNET_break (0);/* Uncompressed config size mismatch */ | 1645 | GNUNET_break (0); /* Uncompressed config size mismatch */ |
1654 | GNUNET_free (config); | 1646 | GNUNET_free (config); |
1655 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1647 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
1656 | return; | 1648 | return; |
1657 | } | 1649 | } |
1658 | cfg = GNUNET_CONFIGURATION_create (); | 1650 | cfg = GNUNET_CONFIGURATION_create (); |
1659 | if (GNUNET_OK != GNUNET_CONFIGURATION_deserialize (cfg, config, config_size, | 1651 | if (GNUNET_OK != |
1660 | GNUNET_NO)) | 1652 | GNUNET_CONFIGURATION_deserialize (cfg, config, config_size, GNUNET_NO)) |
1661 | { | 1653 | { |
1662 | GNUNET_break (0); /* Configuration parsing error */ | 1654 | GNUNET_break (0); /* Configuration parsing error */ |
1663 | GNUNET_free (config); | 1655 | GNUNET_free (config); |
1664 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1656 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
1665 | return; | 1657 | return; |
@@ -1670,11 +1662,11 @@ handle_peer_create (void *cls, | |||
1670 | peer->details.local.cfg = cfg; | 1662 | peer->details.local.cfg = cfg; |
1671 | peer->id = peer_id; | 1663 | peer->id = peer_id; |
1672 | LOG_DEBUG ("Creating peer with id: %u\n", peer->id); | 1664 | LOG_DEBUG ("Creating peer with id: %u\n", peer->id); |
1673 | peer->details.local.peer = | 1665 | peer->details.local.peer = |
1674 | GNUNET_TESTING_peer_configure (master_context->system, | 1666 | GNUNET_TESTING_peer_configure (master_context->system, |
1675 | peer->details.local.cfg, peer->id, | 1667 | peer->details.local.cfg, peer->id, |
1676 | NULL /* Peer id */, | 1668 | NULL /* Peer id */ , |
1677 | &emsg); | 1669 | &emsg); |
1678 | if (NULL == peer->details.local.peer) | 1670 | if (NULL == peer->details.local.peer) |
1679 | { | 1671 | { |
1680 | LOG (GNUNET_ERROR_TYPE_WARNING, "Configuring peer failed: %s\n", emsg); | 1672 | LOG (GNUNET_ERROR_TYPE_WARNING, "Configuring peer failed: %s\n", emsg); |
@@ -1685,8 +1677,11 @@ handle_peer_create (void *cls, | |||
1685 | return; | 1677 | return; |
1686 | } | 1678 | } |
1687 | peer_list_add (peer); | 1679 | peer_list_add (peer); |
1688 | reply = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_PeerCreateSuccessEventMessage)); | 1680 | reply = |
1689 | reply->header.size = htons (sizeof (struct GNUNET_TESTBED_PeerCreateSuccessEventMessage)); | 1681 | GNUNET_malloc (sizeof |
1682 | (struct GNUNET_TESTBED_PeerCreateSuccessEventMessage)); | ||
1683 | reply->header.size = | ||
1684 | htons (sizeof (struct GNUNET_TESTBED_PeerCreateSuccessEventMessage)); | ||
1690 | reply->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_PEERCREATESUCCESS); | 1685 | reply->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_PEERCREATESUCCESS); |
1691 | reply->peer_id = msg->peer_id; | 1686 | reply->peer_id = msg->peer_id; |
1692 | reply->operation_id = msg->operation_id; | 1687 | reply->operation_id = msg->operation_id; |
@@ -1694,7 +1689,7 @@ handle_peer_create (void *cls, | |||
1694 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1689 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
1695 | return; | 1690 | return; |
1696 | } | 1691 | } |
1697 | 1692 | ||
1698 | /* Forward peer create request */ | 1693 | /* Forward peer create request */ |
1699 | route = find_dest_route (host_id); | 1694 | route = find_dest_route (host_id); |
1700 | if (NULL == route) | 1695 | if (NULL == route) |
@@ -1706,17 +1701,18 @@ handle_peer_create (void *cls, | |||
1706 | fo_ctxt = GNUNET_malloc (sizeof (struct ForwardedOperationContext)); | 1701 | fo_ctxt = GNUNET_malloc (sizeof (struct ForwardedOperationContext)); |
1707 | GNUNET_SERVER_client_keep (client); | 1702 | GNUNET_SERVER_client_keep (client); |
1708 | fo_ctxt->client = client; | 1703 | fo_ctxt->client = client; |
1709 | fo_ctxt->operation_id = GNUNET_ntohll (msg->operation_id); | 1704 | fo_ctxt->operation_id = GNUNET_ntohll (msg->operation_id); |
1710 | fo_ctxt->cls = slave_list[route->dest]->controller; | 1705 | fo_ctxt->cls = slave_list[route->dest]->controller; |
1711 | fo_ctxt->opc = | 1706 | fo_ctxt->opc = |
1712 | GNUNET_TESTBED_forward_operation_msg_ (slave_list[route->dest]->controller, | 1707 | GNUNET_TESTBED_forward_operation_msg_ (slave_list |
1713 | fo_ctxt->operation_id, | 1708 | [route->dest]->controller, |
1714 | &msg->header, | 1709 | fo_ctxt->operation_id, |
1715 | peer_create_success_cb, fo_ctxt); | 1710 | &msg->header, |
1716 | fo_ctxt->timeout_task = | 1711 | peer_create_success_cb, fo_ctxt); |
1717 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 1712 | fo_ctxt->timeout_task = |
1718 | &peer_create_forward_timeout, fo_ctxt); | 1713 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &peer_create_forward_timeout, |
1719 | 1714 | fo_ctxt); | |
1715 | |||
1720 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1716 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
1721 | } | 1717 | } |
1722 | 1718 | ||
@@ -1728,20 +1724,19 @@ handle_peer_create (void *cls, | |||
1728 | * @param client identification of the client | 1724 | * @param client identification of the client |
1729 | * @param message the actual message | 1725 | * @param message the actual message |
1730 | */ | 1726 | */ |
1731 | static void | 1727 | static void |
1732 | handle_peer_destroy (void *cls, | 1728 | handle_peer_destroy (void *cls, struct GNUNET_SERVER_Client *client, |
1733 | struct GNUNET_SERVER_Client *client, | ||
1734 | const struct GNUNET_MessageHeader *message) | 1729 | const struct GNUNET_MessageHeader *message) |
1735 | { | 1730 | { |
1736 | const struct GNUNET_TESTBED_PeerDestroyMessage *msg; | 1731 | const struct GNUNET_TESTBED_PeerDestroyMessage *msg; |
1737 | struct ForwardedOperationContext *fopc; | 1732 | struct ForwardedOperationContext *fopc; |
1738 | struct Peer *peer; | 1733 | struct Peer *peer; |
1739 | uint32_t peer_id; | 1734 | uint32_t peer_id; |
1740 | 1735 | ||
1741 | msg = (const struct GNUNET_TESTBED_PeerDestroyMessage *) message; | 1736 | msg = (const struct GNUNET_TESTBED_PeerDestroyMessage *) message; |
1742 | peer_id = ntohl (msg->peer_id); | 1737 | peer_id = ntohl (msg->peer_id); |
1743 | LOG_DEBUG ("Received peer destory on peer: %u and operation id: %ul\n", | 1738 | LOG_DEBUG ("Received peer destory on peer: %u and operation id: %ul\n", |
1744 | peer_id, GNUNET_ntohll (msg->operation_id)); | 1739 | peer_id, GNUNET_ntohll (msg->operation_id)); |
1745 | if ((peer_list_size <= peer_id) || (NULL == peer_list[peer_id])) | 1740 | if ((peer_list_size <= peer_id) || (NULL == peer_list[peer_id])) |
1746 | { | 1741 | { |
1747 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1742 | LOG (GNUNET_ERROR_TYPE_ERROR, |
@@ -1756,18 +1751,17 @@ handle_peer_destroy (void *cls, | |||
1756 | { | 1751 | { |
1757 | /* Forward the destory message to sub controller */ | 1752 | /* Forward the destory message to sub controller */ |
1758 | fopc = GNUNET_malloc (sizeof (struct ForwardedOperationContext)); | 1753 | fopc = GNUNET_malloc (sizeof (struct ForwardedOperationContext)); |
1759 | GNUNET_SERVER_client_keep (client); | 1754 | GNUNET_SERVER_client_keep (client); |
1760 | fopc->client = client; | 1755 | fopc->client = client; |
1761 | fopc->operation_id = GNUNET_ntohll (msg->operation_id); | 1756 | fopc->operation_id = GNUNET_ntohll (msg->operation_id); |
1762 | fopc->opc = | 1757 | fopc->opc = |
1763 | GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote.controller, | 1758 | GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote.controller, |
1764 | fopc->operation_id, | 1759 | fopc->operation_id, &msg->header, |
1765 | &msg->header, | 1760 | &forwarded_operation_reply_relay, |
1766 | &forwarded_operation_reply_relay, | 1761 | fopc); |
1767 | fopc); | ||
1768 | fopc->timeout_task = | 1762 | fopc->timeout_task = |
1769 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 1763 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &forwarded_operation_timeout, |
1770 | &forwarded_operation_timeout, fopc); | 1764 | fopc); |
1771 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1765 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
1772 | return; | 1766 | return; |
1773 | } | 1767 | } |
@@ -1787,10 +1781,9 @@ handle_peer_destroy (void *cls, | |||
1787 | * @param client identification of the client | 1781 | * @param client identification of the client |
1788 | * @param message the actual message | 1782 | * @param message the actual message |
1789 | */ | 1783 | */ |
1790 | static void | 1784 | static void |
1791 | handle_peer_start (void *cls, | 1785 | handle_peer_start (void *cls, struct GNUNET_SERVER_Client *client, |
1792 | struct GNUNET_SERVER_Client *client, | 1786 | const struct GNUNET_MessageHeader *message) |
1793 | const struct GNUNET_MessageHeader *message) | ||
1794 | { | 1787 | { |
1795 | const struct GNUNET_TESTBED_PeerStartMessage *msg; | 1788 | const struct GNUNET_TESTBED_PeerStartMessage *msg; |
1796 | struct GNUNET_TESTBED_PeerEventMessage *reply; | 1789 | struct GNUNET_TESTBED_PeerEventMessage *reply; |
@@ -1800,12 +1793,11 @@ handle_peer_start (void *cls, | |||
1800 | 1793 | ||
1801 | msg = (const struct GNUNET_TESTBED_PeerStartMessage *) message; | 1794 | msg = (const struct GNUNET_TESTBED_PeerStartMessage *) message; |
1802 | peer_id = ntohl (msg->peer_id); | 1795 | peer_id = ntohl (msg->peer_id); |
1803 | if ((peer_id >= peer_list_size) | 1796 | if ((peer_id >= peer_list_size) || (NULL == peer_list[peer_id])) |
1804 | || (NULL == peer_list[peer_id])) | ||
1805 | { | 1797 | { |
1806 | GNUNET_break (0); | 1798 | GNUNET_break (0); |
1807 | LOG (GNUNET_ERROR_TYPE_ERROR, | 1799 | LOG (GNUNET_ERROR_TYPE_ERROR, |
1808 | "Asked to start a non existent peer with id: %u\n", peer_id); | 1800 | "Asked to start a non existent peer with id: %u\n", peer_id); |
1809 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1801 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
1810 | return; | 1802 | return; |
1811 | } | 1803 | } |
@@ -1813,23 +1805,21 @@ handle_peer_start (void *cls, | |||
1813 | if (GNUNET_YES == peer->is_remote) | 1805 | if (GNUNET_YES == peer->is_remote) |
1814 | { | 1806 | { |
1815 | fopc = GNUNET_malloc (sizeof (struct ForwardedOperationContext)); | 1807 | fopc = GNUNET_malloc (sizeof (struct ForwardedOperationContext)); |
1816 | GNUNET_SERVER_client_keep (client); | 1808 | GNUNET_SERVER_client_keep (client); |
1817 | fopc->client = client; | 1809 | fopc->client = client; |
1818 | fopc->operation_id = GNUNET_ntohll (msg->operation_id); | 1810 | fopc->operation_id = GNUNET_ntohll (msg->operation_id); |
1819 | fopc->opc = | 1811 | fopc->opc = |
1820 | GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote.controller, | 1812 | GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote.controller, |
1821 | fopc->operation_id, | 1813 | fopc->operation_id, &msg->header, |
1822 | &msg->header, | 1814 | &forwarded_operation_reply_relay, |
1823 | &forwarded_operation_reply_relay, | 1815 | fopc); |
1824 | fopc); | ||
1825 | fopc->timeout_task = | 1816 | fopc->timeout_task = |
1826 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 1817 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &forwarded_operation_timeout, |
1827 | &forwarded_operation_timeout, fopc); | 1818 | fopc); |
1828 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1819 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
1829 | return; | 1820 | return; |
1830 | } | 1821 | } |
1831 | if (GNUNET_OK != | 1822 | if (GNUNET_OK != GNUNET_TESTING_peer_start (peer->details.local.peer)) |
1832 | GNUNET_TESTING_peer_start (peer->details.local.peer)) | ||
1833 | { | 1823 | { |
1834 | send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id), | 1824 | send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id), |
1835 | "Failed to start"); | 1825 | "Failed to start"); |
@@ -1855,10 +1845,9 @@ handle_peer_start (void *cls, | |||
1855 | * @param client identification of the client | 1845 | * @param client identification of the client |
1856 | * @param message the actual message | 1846 | * @param message the actual message |
1857 | */ | 1847 | */ |
1858 | static void | 1848 | static void |
1859 | handle_peer_stop (void *cls, | 1849 | handle_peer_stop (void *cls, struct GNUNET_SERVER_Client *client, |
1860 | struct GNUNET_SERVER_Client *client, | 1850 | const struct GNUNET_MessageHeader *message) |
1861 | const struct GNUNET_MessageHeader *message) | ||
1862 | { | 1851 | { |
1863 | const struct GNUNET_TESTBED_PeerStopMessage *msg; | 1852 | const struct GNUNET_TESTBED_PeerStopMessage *msg; |
1864 | struct GNUNET_TESTBED_PeerEventMessage *reply; | 1853 | struct GNUNET_TESTBED_PeerEventMessage *reply; |
@@ -1869,7 +1858,7 @@ handle_peer_stop (void *cls, | |||
1869 | msg = (const struct GNUNET_TESTBED_PeerStopMessage *) message; | 1858 | msg = (const struct GNUNET_TESTBED_PeerStopMessage *) message; |
1870 | peer_id = ntohl (msg->peer_id); | 1859 | peer_id = ntohl (msg->peer_id); |
1871 | if ((peer_id >= peer_list_size) || (NULL == peer_list[peer_id])) | 1860 | if ((peer_id >= peer_list_size) || (NULL == peer_list[peer_id])) |
1872 | { | 1861 | { |
1873 | send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id), | 1862 | send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id), |
1874 | "Peer not found"); | 1863 | "Peer not found"); |
1875 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1864 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
@@ -1879,23 +1868,21 @@ handle_peer_stop (void *cls, | |||
1879 | if (GNUNET_YES == peer->is_remote) | 1868 | if (GNUNET_YES == peer->is_remote) |
1880 | { | 1869 | { |
1881 | fopc = GNUNET_malloc (sizeof (struct ForwardedOperationContext)); | 1870 | fopc = GNUNET_malloc (sizeof (struct ForwardedOperationContext)); |
1882 | GNUNET_SERVER_client_keep (client); | 1871 | GNUNET_SERVER_client_keep (client); |
1883 | fopc->client = client; | 1872 | fopc->client = client; |
1884 | fopc->operation_id = GNUNET_ntohll (msg->operation_id); | 1873 | fopc->operation_id = GNUNET_ntohll (msg->operation_id); |
1885 | fopc->opc = | 1874 | fopc->opc = |
1886 | GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote.controller, | 1875 | GNUNET_TESTBED_forward_operation_msg_ (peer->details.remote.controller, |
1887 | fopc->operation_id, | 1876 | fopc->operation_id, &msg->header, |
1888 | &msg->header, | 1877 | &forwarded_operation_reply_relay, |
1889 | &forwarded_operation_reply_relay, | 1878 | fopc); |
1890 | fopc); | ||
1891 | fopc->timeout_task = | 1879 | fopc->timeout_task = |
1892 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 1880 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &forwarded_operation_timeout, |
1893 | &forwarded_operation_timeout, fopc); | 1881 | fopc); |
1894 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1882 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
1895 | return; | 1883 | return; |
1896 | } | 1884 | } |
1897 | if (GNUNET_OK != | 1885 | if (GNUNET_OK != GNUNET_TESTING_peer_stop (peer->details.local.peer)) |
1898 | GNUNET_TESTING_peer_stop (peer->details.local.peer)) | ||
1899 | { | 1886 | { |
1900 | send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id), | 1887 | send_operation_fail_msg (client, GNUNET_ntohll (msg->operation_id), |
1901 | "Peer not running"); | 1888 | "Peer not running"); |
@@ -1921,9 +1908,8 @@ handle_peer_stop (void *cls, | |||
1921 | * @param client identification of the client | 1908 | * @param client identification of the client |
1922 | * @param message the actual message | 1909 | * @param message the actual message |
1923 | */ | 1910 | */ |
1924 | static void | 1911 | static void |
1925 | handle_peer_get_config (void *cls, | 1912 | handle_peer_get_config (void *cls, struct GNUNET_SERVER_Client *client, |
1926 | struct GNUNET_SERVER_Client *client, | ||
1927 | const struct GNUNET_MessageHeader *message) | 1913 | const struct GNUNET_MessageHeader *message) |
1928 | { | 1914 | { |
1929 | const struct GNUNET_TESTBED_PeerGetConfigurationMessage *msg; | 1915 | const struct GNUNET_TESTBED_PeerGetConfigurationMessage *msg; |
@@ -1932,10 +1918,10 @@ handle_peer_get_config (void *cls, | |||
1932 | char *config; | 1918 | char *config; |
1933 | char *xconfig; | 1919 | char *xconfig; |
1934 | size_t c_size; | 1920 | size_t c_size; |
1935 | size_t xc_size; | 1921 | size_t xc_size; |
1936 | uint32_t peer_id; | 1922 | uint32_t peer_id; |
1937 | uint16_t msize; | 1923 | uint16_t msize; |
1938 | 1924 | ||
1939 | msg = (const struct GNUNET_TESTBED_PeerGetConfigurationMessage *) message; | 1925 | msg = (const struct GNUNET_TESTBED_PeerGetConfigurationMessage *) message; |
1940 | peer_id = ntohl (msg->peer_id); | 1926 | peer_id = ntohl (msg->peer_id); |
1941 | if ((peer_id >= peer_list_size) || (NULL == peer_list[peer_id])) | 1927 | if ((peer_id >= peer_list_size) || (NULL == peer_list[peer_id])) |
@@ -1954,12 +1940,13 @@ handle_peer_get_config (void *cls, | |||
1954 | return; | 1940 | return; |
1955 | } | 1941 | } |
1956 | config = | 1942 | config = |
1957 | GNUNET_CONFIGURATION_serialize (peer_list[peer_id]->details.local.cfg, | 1943 | GNUNET_CONFIGURATION_serialize (peer_list[peer_id]->details.local.cfg, |
1958 | &c_size); | 1944 | &c_size); |
1959 | xc_size = GNUNET_TESTBED_compress_config_ (config, c_size, &xconfig); | 1945 | xc_size = GNUNET_TESTBED_compress_config_ (config, c_size, &xconfig); |
1960 | GNUNET_free (config); | 1946 | GNUNET_free (config); |
1961 | msize = xc_size + sizeof (struct | 1947 | msize = |
1962 | GNUNET_TESTBED_PeerConfigurationInformationMessage); | 1948 | xc_size + |
1949 | sizeof (struct GNUNET_TESTBED_PeerConfigurationInformationMessage); | ||
1963 | reply = GNUNET_realloc (xconfig, msize); | 1950 | reply = GNUNET_realloc (xconfig, msize); |
1964 | (void) memmove (&reply[1], reply, xc_size); | 1951 | (void) memmove (&reply[1], reply, xc_size); |
1965 | reply->header.size = htons (msize); | 1952 | reply->header.size = htons (msize); |
@@ -2030,11 +2017,10 @@ timeout_overlay_connect (void *cls, | |||
2030 | * @param ats performance data | 2017 | * @param ats performance data |
2031 | * @param ats_count number of entries in ats (excluding 0-termination) | 2018 | * @param ats_count number of entries in ats (excluding 0-termination) |
2032 | */ | 2019 | */ |
2033 | static void | 2020 | static void |
2034 | overlay_connect_notify (void *cls, | 2021 | overlay_connect_notify (void *cls, const struct GNUNET_PeerIdentity *new_peer, |
2035 | const struct GNUNET_PeerIdentity * new_peer, | 2022 | const struct GNUNET_ATS_Information *ats, |
2036 | const struct GNUNET_ATS_Information * ats, | 2023 | unsigned int ats_count) |
2037 | unsigned int ats_count) | ||
2038 | { | 2024 | { |
2039 | struct OverlayConnectContext *occ = cls; | 2025 | struct OverlayConnectContext *occ = cls; |
2040 | struct GNUNET_TESTBED_ConnectionEventMessage *msg; | 2026 | struct GNUNET_TESTBED_ConnectionEventMessage *msg; |
@@ -2042,16 +2028,18 @@ overlay_connect_notify (void *cls, | |||
2042 | char *other_peer_str; | 2028 | char *other_peer_str; |
2043 | 2029 | ||
2044 | LOG_DEBUG ("Overlay connect notify\n"); | 2030 | LOG_DEBUG ("Overlay connect notify\n"); |
2045 | if (0 == memcmp (new_peer, &occ->peer_identity, | 2031 | if (0 == |
2046 | sizeof (struct GNUNET_PeerIdentity))) | 2032 | memcmp (new_peer, &occ->peer_identity, |
2033 | sizeof (struct GNUNET_PeerIdentity))) | ||
2047 | return; | 2034 | return; |
2048 | new_peer_str = GNUNET_strdup (GNUNET_i2s (new_peer)); | 2035 | new_peer_str = GNUNET_strdup (GNUNET_i2s (new_peer)); |
2049 | other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity)); | 2036 | other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity)); |
2050 | if (0 != memcmp (new_peer, &occ->other_peer_identity, | 2037 | if (0 != |
2051 | sizeof (struct GNUNET_PeerIdentity))) | 2038 | memcmp (new_peer, &occ->other_peer_identity, |
2039 | sizeof (struct GNUNET_PeerIdentity))) | ||
2052 | { | 2040 | { |
2053 | LOG_DEBUG ("Unexpected peer %4s connected to peer %4s\n", | 2041 | LOG_DEBUG ("Unexpected peer %4s connected to peer %4s\n", new_peer_str, |
2054 | new_peer_str, other_peer_str); | 2042 | other_peer_str); |
2055 | GNUNET_free (new_peer_str); | 2043 | GNUNET_free (new_peer_str); |
2056 | GNUNET_free (other_peer_str); | 2044 | GNUNET_free (other_peer_str); |
2057 | return; | 2045 | return; |
@@ -2074,8 +2062,8 @@ overlay_connect_notify (void *cls, | |||
2074 | /* Peer 1 has connected connect to peer2 - now send overlay connect success message */ | 2062 | /* Peer 1 has connected connect to peer2 - now send overlay connect success message */ |
2075 | LOG_DEBUG ("Peers connected - Sending overlay connect success\n"); | 2063 | LOG_DEBUG ("Peers connected - Sending overlay connect success\n"); |
2076 | msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_ConnectionEventMessage)); | 2064 | msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_ConnectionEventMessage)); |
2077 | msg->header.size = htons (sizeof (struct | 2065 | msg->header.size = |
2078 | GNUNET_TESTBED_ConnectionEventMessage)); | 2066 | htons (sizeof (struct GNUNET_TESTBED_ConnectionEventMessage)); |
2079 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_PEERCONEVENT); | 2067 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_PEERCONEVENT); |
2080 | msg->event_type = htonl (GNUNET_TESTBED_ET_CONNECT); | 2068 | msg->event_type = htonl (GNUNET_TESTBED_ET_CONNECT); |
2081 | msg->peer1 = htonl (occ->peer->id); | 2069 | msg->peer1 = htonl (occ->peer->id); |
@@ -2098,12 +2086,13 @@ send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2098 | return; | 2086 | return; |
2099 | GNUNET_assert (NULL != occ->hello); | 2087 | GNUNET_assert (NULL != occ->hello); |
2100 | other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity)); | 2088 | other_peer_str = GNUNET_strdup (GNUNET_i2s (&occ->other_peer_identity)); |
2101 | LOG_DEBUG ("Offering HELLO of %s to %s\n", other_peer_str, GNUNET_i2s (&occ->peer_identity)); | 2089 | LOG_DEBUG ("Offering HELLO of %s to %s\n", other_peer_str, |
2090 | GNUNET_i2s (&occ->peer_identity)); | ||
2102 | GNUNET_free (other_peer_str); | 2091 | GNUNET_free (other_peer_str); |
2103 | GNUNET_TRANSPORT_offer_hello (occ->p1th, occ->hello, NULL, NULL); | 2092 | GNUNET_TRANSPORT_offer_hello (occ->p1th, occ->hello, NULL, NULL); |
2104 | GNUNET_TRANSPORT_try_connect (occ->p1th, &occ->other_peer_identity); | 2093 | GNUNET_TRANSPORT_try_connect (occ->p1th, &occ->other_peer_identity); |
2105 | occ->send_hello_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | 2094 | occ->send_hello_task = |
2106 | &send_hello, occ); | 2095 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &send_hello, occ); |
2107 | } | 2096 | } |
2108 | 2097 | ||
2109 | /** | 2098 | /** |
@@ -2112,7 +2101,7 @@ send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2112 | * @param cls empty flag to set | 2101 | * @param cls empty flag to set |
2113 | * @param address the HELLO | 2102 | * @param address the HELLO |
2114 | * @param expiration expiration of the HELLO | 2103 | * @param expiration expiration of the HELLO |
2115 | * @return | 2104 | * @return |
2116 | */ | 2105 | */ |
2117 | static int | 2106 | static int |
2118 | test_address (void *cls, const struct GNUNET_HELLO_Address *address, | 2107 | test_address (void *cls, const struct GNUNET_HELLO_Address *address, |
@@ -2132,28 +2121,29 @@ test_address (void *cls, const struct GNUNET_HELLO_Address *address, | |||
2132 | * @param cls closure | 2121 | * @param cls closure |
2133 | * @param hello our updated HELLO | 2122 | * @param hello our updated HELLO |
2134 | */ | 2123 | */ |
2135 | static void | 2124 | static void |
2136 | hello_update_cb (void *cls, const struct GNUNET_MessageHeader *hello) | 2125 | hello_update_cb (void *cls, const struct GNUNET_MessageHeader *hello) |
2137 | { | 2126 | { |
2138 | struct OverlayConnectContext *occ = cls; | 2127 | struct OverlayConnectContext *occ = cls; |
2139 | int empty; | 2128 | int empty; |
2140 | uint16_t msize; | 2129 | uint16_t msize; |
2141 | 2130 | ||
2142 | msize = ntohs (hello->size); | 2131 | msize = ntohs (hello->size); |
2143 | if (msize < 0) | 2132 | if (msize < 0) |
2144 | { | 2133 | { |
2145 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 2134 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
2146 | "HELLO message of peer %s is of size 0\n", | 2135 | "HELLO message of peer %s is of size 0\n", |
2147 | &occ->other_peer_identity); | 2136 | &occ->other_peer_identity); |
2148 | return; | 2137 | return; |
2149 | } | 2138 | } |
2150 | empty = GNUNET_YES; | 2139 | empty = GNUNET_YES; |
2151 | (void) | 2140 | (void) GNUNET_HELLO_iterate_addresses ((const struct GNUNET_HELLO_Message *) |
2152 | GNUNET_HELLO_iterate_addresses ((const struct GNUNET_HELLO_Message *) hello, | 2141 | hello, GNUNET_NO, &test_address, |
2153 | GNUNET_NO, &test_address, &empty); | 2142 | &empty); |
2154 | if (GNUNET_YES == empty) | 2143 | if (GNUNET_YES == empty) |
2155 | { | 2144 | { |
2156 | LOG_DEBUG ("HELLO of %s is empty\n", GNUNET_i2s (&occ->other_peer_identity)); | 2145 | LOG_DEBUG ("HELLO of %s is empty\n", |
2146 | GNUNET_i2s (&occ->other_peer_identity)); | ||
2157 | return; | 2147 | return; |
2158 | } | 2148 | } |
2159 | LOG_DEBUG ("Received HELLO of %s\n", GNUNET_i2s (&occ->other_peer_identity)); | 2149 | LOG_DEBUG ("Received HELLO of %s\n", GNUNET_i2s (&occ->other_peer_identity)); |
@@ -2163,7 +2153,7 @@ hello_update_cb (void *cls, const struct GNUNET_MessageHeader *hello) | |||
2163 | occ->ghh = NULL; | 2153 | occ->ghh = NULL; |
2164 | GNUNET_TRANSPORT_disconnect (occ->p2th); | 2154 | GNUNET_TRANSPORT_disconnect (occ->p2th); |
2165 | occ->p2th = NULL; | 2155 | occ->p2th = NULL; |
2166 | GNUNET_free_non_null (occ->emsg); | 2156 | GNUNET_free_non_null (occ->emsg); |
2167 | occ->emsg = GNUNET_strdup ("Timeout while offering HELLO to other peer"); | 2157 | occ->emsg = GNUNET_strdup ("Timeout while offering HELLO to other peer"); |
2168 | occ->send_hello_task = GNUNET_SCHEDULER_add_now (&send_hello, occ); | 2158 | occ->send_hello_task = GNUNET_SCHEDULER_add_now (&send_hello, occ); |
2169 | } | 2159 | } |
@@ -2180,39 +2170,40 @@ hello_update_cb (void *cls, const struct GNUNET_MessageHeader *hello) | |||
2180 | * @param server handle to the server, NULL if we failed | 2170 | * @param server handle to the server, NULL if we failed |
2181 | * @param my_identity ID of this peer, NULL if we failed | 2171 | * @param my_identity ID of this peer, NULL if we failed |
2182 | */ | 2172 | */ |
2183 | static void | 2173 | static void |
2184 | core_startup_cb (void *cls, struct GNUNET_CORE_Handle * server, | 2174 | core_startup_cb (void *cls, struct GNUNET_CORE_Handle *server, |
2185 | const struct GNUNET_PeerIdentity *my_identity) | 2175 | const struct GNUNET_PeerIdentity *my_identity) |
2186 | { | 2176 | { |
2187 | struct OverlayConnectContext *occ = cls; | 2177 | struct OverlayConnectContext *occ = cls; |
2188 | 2178 | ||
2189 | GNUNET_free_non_null (occ->emsg); | 2179 | GNUNET_free_non_null (occ->emsg); |
2190 | occ->emsg = NULL; | 2180 | occ->emsg = NULL; |
2191 | memcpy (&occ->peer_identity, my_identity, sizeof (struct GNUNET_PeerIdentity)); | 2181 | memcpy (&occ->peer_identity, my_identity, |
2182 | sizeof (struct GNUNET_PeerIdentity)); | ||
2192 | occ->p1th = | 2183 | occ->p1th = |
2193 | GNUNET_TRANSPORT_connect (occ->peer->details.local.cfg, | 2184 | GNUNET_TRANSPORT_connect (occ->peer->details.local.cfg, |
2194 | &occ->peer_identity, NULL, NULL, NULL, NULL); | 2185 | &occ->peer_identity, NULL, NULL, NULL, NULL); |
2195 | /* Connect to the transport of 2nd peer and get its HELLO message */ | 2186 | /* Connect to the transport of 2nd peer and get its HELLO message */ |
2196 | GNUNET_TESTING_peer_get_identity (occ->other_peer->details.local.peer, | 2187 | GNUNET_TESTING_peer_get_identity (occ->other_peer->details.local.peer, |
2197 | &occ->other_peer_identity); | 2188 | &occ->other_peer_identity); |
2198 | occ->p2th = | 2189 | occ->p2th = |
2199 | GNUNET_TRANSPORT_connect (occ->other_peer->details.local.cfg, | 2190 | GNUNET_TRANSPORT_connect (occ->other_peer->details.local.cfg, |
2200 | &occ->other_peer_identity, | 2191 | &occ->other_peer_identity, NULL, NULL, NULL, |
2201 | NULL, NULL, NULL, NULL); | 2192 | NULL); |
2202 | if ((NULL == occ->p1th) || (NULL == occ->p2th)) | 2193 | if ((NULL == occ->p1th) || (NULL == occ->p2th)) |
2203 | { | 2194 | { |
2204 | occ->emsg = GNUNET_strdup ("Cannot connect to TRANSPORTs of peers"); | 2195 | occ->emsg = GNUNET_strdup ("Cannot connect to TRANSPORTs of peers"); |
2205 | goto send_failure; | 2196 | goto send_failure; |
2206 | } | 2197 | } |
2207 | LOG_DEBUG ("Acquiring HELLO of peer %s\n", GNUNET_i2s | 2198 | LOG_DEBUG ("Acquiring HELLO of peer %s\n", |
2208 | (&occ->other_peer_identity)); | 2199 | GNUNET_i2s (&occ->other_peer_identity)); |
2209 | occ->emsg = GNUNET_strdup ("Timeout while acquiring HELLO message"); | 2200 | occ->emsg = GNUNET_strdup ("Timeout while acquiring HELLO message"); |
2210 | occ->ghh = GNUNET_TRANSPORT_get_hello (occ->p2th, &hello_update_cb, occ); | 2201 | occ->ghh = GNUNET_TRANSPORT_get_hello (occ->p2th, &hello_update_cb, occ); |
2211 | return; | 2202 | return; |
2212 | 2203 | ||
2213 | send_failure: | 2204 | send_failure: |
2214 | GNUNET_SCHEDULER_cancel (occ->timeout_task); | 2205 | GNUNET_SCHEDULER_cancel (occ->timeout_task); |
2215 | occ->timeout_task = GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ); | 2206 | occ->timeout_task = GNUNET_SCHEDULER_add_now (&timeout_overlay_connect, occ); |
2216 | } | 2207 | } |
2217 | 2208 | ||
2218 | 2209 | ||
@@ -2223,13 +2214,13 @@ core_startup_cb (void *cls, struct GNUNET_CORE_Handle * server, | |||
2223 | * @param client identification of the client | 2214 | * @param client identification of the client |
2224 | * @param message the actual message | 2215 | * @param message the actual message |
2225 | */ | 2216 | */ |
2226 | static void | 2217 | static void |
2227 | handle_overlay_connect (void *cls, | 2218 | handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client, |
2228 | struct GNUNET_SERVER_Client *client, | ||
2229 | const struct GNUNET_MessageHeader *message) | 2219 | const struct GNUNET_MessageHeader *message) |
2230 | { | 2220 | { |
2231 | const struct GNUNET_TESTBED_OverlayConnectMessage *msg; | 2221 | const struct GNUNET_TESTBED_OverlayConnectMessage *msg; |
2232 | struct OverlayConnectContext *occ; | 2222 | struct OverlayConnectContext *occ; |
2223 | |||
2233 | struct GNUNET_CORE_MessageHandler no_handlers[] = { | 2224 | struct GNUNET_CORE_MessageHandler no_handlers[] = { |
2234 | {NULL, 0, 0} | 2225 | {NULL, 0, 0} |
2235 | }; | 2226 | }; |
@@ -2244,7 +2235,7 @@ handle_overlay_connect (void *cls, | |||
2244 | GNUNET_assert (p2 < peer_list_size); | 2235 | GNUNET_assert (p2 < peer_list_size); |
2245 | GNUNET_assert (NULL != peer_list[p2]); | 2236 | GNUNET_assert (NULL != peer_list[p2]); |
2246 | /* FIXME: Add cases where we have to forward overlay connect message to sub | 2237 | /* FIXME: Add cases where we have to forward overlay connect message to sub |
2247 | controllers */ | 2238 | * controllers */ |
2248 | occ = GNUNET_malloc (sizeof (struct OverlayConnectContext)); | 2239 | occ = GNUNET_malloc (sizeof (struct OverlayConnectContext)); |
2249 | GNUNET_SERVER_client_keep (client); | 2240 | GNUNET_SERVER_client_keep (client); |
2250 | occ->client = client; | 2241 | occ->client = client; |
@@ -2253,15 +2244,15 @@ handle_overlay_connect (void *cls, | |||
2253 | occ->other_peer = peer_list[p2]; | 2244 | occ->other_peer = peer_list[p2]; |
2254 | occ->op_id = GNUNET_ntohll (msg->operation_id); | 2245 | occ->op_id = GNUNET_ntohll (msg->operation_id); |
2255 | occ->timeout_task = | 2246 | occ->timeout_task = |
2256 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 2247 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
2257 | (GNUNET_TIME_UNIT_SECONDS, 30), | 2248 | (GNUNET_TIME_UNIT_SECONDS, 30), |
2258 | &timeout_overlay_connect, occ); | 2249 | &timeout_overlay_connect, occ); |
2259 | /* Connect to the core of 1st peer and wait for the 2nd peer to connect */ | 2250 | /* Connect to the core of 1st peer and wait for the 2nd peer to connect */ |
2260 | occ->emsg = GNUNET_strdup ("Timeout while connecting to CORE"); | 2251 | occ->emsg = GNUNET_strdup ("Timeout while connecting to CORE"); |
2261 | occ->ch = | 2252 | occ->ch = |
2262 | GNUNET_CORE_connect (occ->peer->details.local.cfg, occ, &core_startup_cb, | 2253 | GNUNET_CORE_connect (occ->peer->details.local.cfg, occ, &core_startup_cb, |
2263 | &overlay_connect_notify, NULL, NULL, GNUNET_NO, NULL, | 2254 | &overlay_connect_notify, NULL, NULL, GNUNET_NO, NULL, |
2264 | GNUNET_NO, no_handlers); | 2255 | GNUNET_NO, no_handlers); |
2265 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 2256 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
2266 | } | 2257 | } |
2267 | 2258 | ||
@@ -2276,14 +2267,13 @@ handle_overlay_connect (void *cls, | |||
2276 | * iterate, | 2267 | * iterate, |
2277 | * GNUNET_NO if not. | 2268 | * GNUNET_NO if not. |
2278 | */ | 2269 | */ |
2279 | static int | 2270 | static int |
2280 | ss_map_free_iterator (void *cls, | 2271 | ss_map_free_iterator (void *cls, const struct GNUNET_HashCode *key, void *value) |
2281 | const struct GNUNET_HashCode * key, void *value) | ||
2282 | { | 2272 | { |
2283 | struct SharedService *ss = value; | 2273 | struct SharedService *ss = value; |
2284 | 2274 | ||
2285 | GNUNET_assert (GNUNET_YES == | 2275 | GNUNET_assert (GNUNET_YES == |
2286 | GNUNET_CONTAINER_multihashmap_remove (ss_map, key, value)); | 2276 | GNUNET_CONTAINER_multihashmap_remove (ss_map, key, value)); |
2287 | GNUNET_free (ss->name); | 2277 | GNUNET_free (ss->name); |
2288 | GNUNET_free (ss); | 2278 | GNUNET_free (ss); |
2289 | return GNUNET_YES; | 2279 | return GNUNET_YES; |
@@ -2297,8 +2287,7 @@ ss_map_free_iterator (void *cls, | |||
2297 | * @param tc the TaskContext from scheduler | 2287 | * @param tc the TaskContext from scheduler |
2298 | */ | 2288 | */ |
2299 | static void | 2289 | static void |
2300 | shutdown_task (void *cls, | 2290 | shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
2301 | const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
2302 | { | 2291 | { |
2303 | struct LCFContextQueue *lcfq; | 2292 | struct LCFContextQueue *lcfq; |
2304 | uint32_t id; | 2293 | uint32_t id; |
@@ -2307,7 +2296,7 @@ shutdown_task (void *cls, | |||
2307 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutting down testbed service\n"); | 2296 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Shutting down testbed service\n"); |
2308 | (void) GNUNET_CONTAINER_multihashmap_iterate (ss_map, &ss_map_free_iterator, | 2297 | (void) GNUNET_CONTAINER_multihashmap_iterate (ss_map, &ss_map_free_iterator, |
2309 | NULL); | 2298 | NULL); |
2310 | GNUNET_CONTAINER_multihashmap_destroy (ss_map); | 2299 | GNUNET_CONTAINER_multihashmap_destroy (ss_map); |
2311 | if (NULL != lcfq_head) | 2300 | if (NULL != lcfq_head) |
2312 | { | 2301 | { |
2313 | if (GNUNET_SCHEDULER_NO_TASK != lcf_proc_task_id) | 2302 | if (GNUNET_SCHEDULER_NO_TASK != lcf_proc_task_id) |
@@ -2331,10 +2320,10 @@ shutdown_task (void *cls, | |||
2331 | if (NULL != peer_list[id]) | 2320 | if (NULL != peer_list[id]) |
2332 | { | 2321 | { |
2333 | if (GNUNET_NO == peer_list[id]->is_remote) | 2322 | if (GNUNET_NO == peer_list[id]->is_remote) |
2334 | { | 2323 | { |
2335 | GNUNET_TESTING_peer_destroy (peer_list[id]->details.local.peer); | 2324 | GNUNET_TESTING_peer_destroy (peer_list[id]->details.local.peer); |
2336 | GNUNET_CONFIGURATION_destroy (peer_list[id]->details.local.cfg); | 2325 | GNUNET_CONFIGURATION_destroy (peer_list[id]->details.local.cfg); |
2337 | } | 2326 | } |
2338 | GNUNET_free (peer_list[id]); | 2327 | GNUNET_free (peer_list[id]); |
2339 | } | 2328 | } |
2340 | GNUNET_free_non_null (peer_list); | 2329 | GNUNET_free_non_null (peer_list); |
@@ -2353,12 +2342,12 @@ shutdown_task (void *cls, | |||
2353 | if (NULL != slave_list[id]) | 2342 | if (NULL != slave_list[id]) |
2354 | { | 2343 | { |
2355 | if (NULL != slave_list[id]->controller) | 2344 | if (NULL != slave_list[id]->controller) |
2356 | GNUNET_TESTBED_controller_disconnect (slave_list[id]->controller); | 2345 | GNUNET_TESTBED_controller_disconnect (slave_list[id]->controller); |
2357 | if (NULL != slave_list[id]->controller_proc) | 2346 | if (NULL != slave_list[id]->controller_proc) |
2358 | GNUNET_TESTBED_controller_stop (slave_list[id]->controller_proc); | 2347 | GNUNET_TESTBED_controller_stop (slave_list[id]->controller_proc); |
2359 | } | 2348 | } |
2360 | if (NULL != master_context) | 2349 | if (NULL != master_context) |
2361 | { | 2350 | { |
2362 | GNUNET_free_non_null (master_context->master_ip); | 2351 | GNUNET_free_non_null (master_context->master_ip); |
2363 | if (NULL != master_context->system) | 2352 | if (NULL != master_context->system) |
2364 | GNUNET_TESTING_system_destroy (master_context->system, GNUNET_YES); | 2353 | GNUNET_TESTING_system_destroy (master_context->system, GNUNET_YES); |
@@ -2384,10 +2373,10 @@ client_disconnect_cb (void *cls, struct GNUNET_SERVER_Client *client) | |||
2384 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Master client disconnected\n"); | 2373 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Master client disconnected\n"); |
2385 | GNUNET_SERVER_client_drop (client); | 2374 | GNUNET_SERVER_client_drop (client); |
2386 | /* should not be needed as we're terminated by failure to read | 2375 | /* should not be needed as we're terminated by failure to read |
2387 | from stdin, but if stdin fails for some reason, this shouldn't | 2376 | * from stdin, but if stdin fails for some reason, this shouldn't |
2388 | hurt for now --- might need to revise this later if we ever | 2377 | * hurt for now --- might need to revise this later if we ever |
2389 | decide that master connections might be temporarily down | 2378 | * decide that master connections might be temporarily down |
2390 | for some reason */ | 2379 | * for some reason */ |
2391 | //GNUNET_SCHEDULER_shutdown (); | 2380 | //GNUNET_SCHEDULER_shutdown (); |
2392 | } | 2381 | } |
2393 | } | 2382 | } |
@@ -2400,43 +2389,37 @@ client_disconnect_cb (void *cls, struct GNUNET_SERVER_Client *client) | |||
2400 | * @param server the initialized server | 2389 | * @param server the initialized server |
2401 | * @param cfg configuration to use | 2390 | * @param cfg configuration to use |
2402 | */ | 2391 | */ |
2403 | static void | 2392 | static void |
2404 | testbed_run (void *cls, | 2393 | testbed_run (void *cls, struct GNUNET_SERVER_Handle *server, |
2405 | struct GNUNET_SERVER_Handle *server, | ||
2406 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 2394 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
2407 | { | 2395 | { |
2408 | static const struct GNUNET_SERVER_MessageHandler message_handlers[] = | 2396 | static const struct GNUNET_SERVER_MessageHandler message_handlers[] = { |
2409 | { | 2397 | {&handle_init, NULL, GNUNET_MESSAGE_TYPE_TESTBED_INIT, 0}, |
2410 | {&handle_init, NULL, GNUNET_MESSAGE_TYPE_TESTBED_INIT, 0}, | 2398 | {&handle_add_host, NULL, GNUNET_MESSAGE_TYPE_TESTBED_ADDHOST, 0}, |
2411 | {&handle_add_host, NULL, GNUNET_MESSAGE_TYPE_TESTBED_ADDHOST, 0}, | 2399 | {&handle_configure_shared_service, NULL, |
2412 | {&handle_configure_shared_service, NULL, | 2400 | GNUNET_MESSAGE_TYPE_TESTBED_SERVICESHARE, 0}, |
2413 | GNUNET_MESSAGE_TYPE_TESTBED_SERVICESHARE, 0}, | 2401 | {&handle_link_controllers, NULL, |
2414 | {&handle_link_controllers, NULL, | 2402 | GNUNET_MESSAGE_TYPE_TESTBED_LCONTROLLERS, 0}, |
2415 | GNUNET_MESSAGE_TYPE_TESTBED_LCONTROLLERS, 0}, | 2403 | {&handle_peer_create, NULL, GNUNET_MESSAGE_TYPE_TESTBED_CREATEPEER, 0}, |
2416 | {&handle_peer_create, NULL, GNUNET_MESSAGE_TYPE_TESTBED_CREATEPEER, 0}, | 2404 | {&handle_peer_destroy, NULL, GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER, |
2417 | {&handle_peer_destroy, NULL, GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER, | 2405 | sizeof (struct GNUNET_TESTBED_PeerDestroyMessage)}, |
2418 | sizeof (struct GNUNET_TESTBED_PeerDestroyMessage)}, | 2406 | {&handle_peer_start, NULL, GNUNET_MESSAGE_TYPE_TESTBED_STARTPEER, |
2419 | {&handle_peer_start, NULL, GNUNET_MESSAGE_TYPE_TESTBED_STARTPEER, | 2407 | sizeof (struct GNUNET_TESTBED_PeerStartMessage)}, |
2420 | sizeof (struct GNUNET_TESTBED_PeerStartMessage)}, | 2408 | {&handle_peer_stop, NULL, GNUNET_MESSAGE_TYPE_TESTBED_STOPPEER, |
2421 | {&handle_peer_stop, NULL, GNUNET_MESSAGE_TYPE_TESTBED_STOPPEER, | 2409 | sizeof (struct GNUNET_TESTBED_PeerStopMessage)}, |
2422 | sizeof (struct GNUNET_TESTBED_PeerStopMessage)}, | 2410 | {&handle_peer_get_config, NULL, GNUNET_MESSAGE_TYPE_TESTBED_GETPEERCONFIG, |
2423 | {&handle_peer_get_config, NULL, GNUNET_MESSAGE_TYPE_TESTBED_GETPEERCONFIG, | 2411 | sizeof (struct GNUNET_TESTBED_PeerGetConfigurationMessage)}, |
2424 | sizeof (struct GNUNET_TESTBED_PeerGetConfigurationMessage)}, | 2412 | {&handle_overlay_connect, NULL, GNUNET_MESSAGE_TYPE_TESTBED_OLCONNECT, |
2425 | {&handle_overlay_connect, NULL, GNUNET_MESSAGE_TYPE_TESTBED_OLCONNECT, | 2413 | sizeof (struct GNUNET_TESTBED_OverlayConnectMessage)}, |
2426 | sizeof (struct GNUNET_TESTBED_OverlayConnectMessage)}, | 2414 | {NULL} |
2427 | {NULL} | 2415 | }; |
2428 | }; | 2416 | |
2429 | 2417 | GNUNET_SERVER_add_handlers (server, message_handlers); | |
2430 | GNUNET_SERVER_add_handlers (server, | 2418 | GNUNET_SERVER_disconnect_notify (server, &client_disconnect_cb, NULL); |
2431 | message_handlers); | ||
2432 | GNUNET_SERVER_disconnect_notify (server, | ||
2433 | &client_disconnect_cb, | ||
2434 | NULL); | ||
2435 | ss_map = GNUNET_CONTAINER_multihashmap_create (5); | 2419 | ss_map = GNUNET_CONTAINER_multihashmap_create (5); |
2436 | shutdown_task_id = | 2420 | shutdown_task_id = |
2437 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 2421 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
2438 | &shutdown_task, | 2422 | &shutdown_task, NULL); |
2439 | NULL); | ||
2440 | LOG_DEBUG ("Testbed startup complete\n"); | 2423 | LOG_DEBUG ("Testbed startup complete\n"); |
2441 | } | 2424 | } |
2442 | 2425 | ||
@@ -2444,15 +2427,11 @@ testbed_run (void *cls, | |||
2444 | /** | 2427 | /** |
2445 | * The starting point of execution | 2428 | * The starting point of execution |
2446 | */ | 2429 | */ |
2447 | int main (int argc, char *const *argv) | 2430 | int |
2431 | main (int argc, char *const *argv) | ||
2448 | { | 2432 | { |
2449 | //sleep (15); /* Debugging */ | 2433 | //sleep (15); /* Debugging */ |
2450 | return | 2434 | return (GNUNET_OK == |
2451 | (GNUNET_OK == | 2435 | GNUNET_SERVICE_run (argc, argv, "testbed", GNUNET_SERVICE_OPTION_NONE, |
2452 | GNUNET_SERVICE_run (argc, | 2436 | &testbed_run, NULL)) ? 0 : 1; |
2453 | argv, | ||
2454 | "testbed", | ||
2455 | GNUNET_SERVICE_OPTION_NONE, | ||
2456 | &testbed_run, | ||
2457 | NULL)) ? 0 : 1; | ||
2458 | } | 2437 | } |
diff --git a/src/testbed/gnunet-testbed-helper.c b/src/testbed/gnunet-testbed-helper.c index 94a384ab2..e06472998 100644 --- a/src/testbed/gnunet-testbed-helper.c +++ b/src/testbed/gnunet-testbed-helper.c | |||
@@ -26,7 +26,7 @@ | |||
26 | * with ports and paths fixed so that gnunet-service-testbed runs | 26 | * with ports and paths fixed so that gnunet-service-testbed runs |
27 | * without any hurdles. This binary also kills the testbed service | 27 | * without any hurdles. This binary also kills the testbed service |
28 | * should the connection from the remote controller is dropped | 28 | * should the connection from the remote controller is dropped |
29 | * @author Sree Harsha Totakura <sreeharsha@totakura.in> | 29 | * @author Sree Harsha Totakura <sreeharsha@totakura.in> |
30 | */ | 30 | */ |
31 | 31 | ||
32 | 32 | ||
@@ -150,7 +150,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
150 | (void) GNUNET_DISK_file_close (stdin_fd); | 150 | (void) GNUNET_DISK_file_close (stdin_fd); |
151 | if (NULL != stdout_fd) | 151 | if (NULL != stdout_fd) |
152 | (void) GNUNET_DISK_file_close (stdout_fd); | 152 | (void) GNUNET_DISK_file_close (stdout_fd); |
153 | GNUNET_SERVER_mst_destroy (tokenizer); | 153 | GNUNET_SERVER_mst_destroy (tokenizer); |
154 | tokenizer = NULL; | 154 | tokenizer = NULL; |
155 | if (NULL != testbed) | 155 | if (NULL != testbed) |
156 | { | 156 | { |
@@ -188,8 +188,9 @@ write_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
188 | GNUNET_free (wc); | 188 | GNUNET_free (wc); |
189 | return; | 189 | return; |
190 | } | 190 | } |
191 | bytes_wrote = GNUNET_DISK_file_write (stdout_fd, wc->data + wc->pos, | 191 | bytes_wrote = |
192 | wc->length - wc->pos); | 192 | GNUNET_DISK_file_write (stdout_fd, wc->data + wc->pos, |
193 | wc->length - wc->pos); | ||
193 | GNUNET_assert (GNUNET_SYSERR != bytes_wrote); | 194 | GNUNET_assert (GNUNET_SYSERR != bytes_wrote); |
194 | wc->pos += bytes_wrote; | 195 | wc->pos += bytes_wrote; |
195 | if (wc->pos == wc->length) | 196 | if (wc->pos == wc->length) |
@@ -198,8 +199,9 @@ write_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
198 | GNUNET_free (wc); | 199 | GNUNET_free (wc); |
199 | return; | 200 | return; |
200 | } | 201 | } |
201 | write_task_id = GNUNET_SCHEDULER_add_write_file | 202 | write_task_id = |
202 | (GNUNET_TIME_UNIT_FOREVER_REL, stdout_fd, &write_task, wc); | 203 | GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, stdout_fd, |
204 | &write_task, wc); | ||
203 | } | 205 | } |
204 | 206 | ||
205 | 207 | ||
@@ -215,7 +217,7 @@ write_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
215 | * | 217 | * |
216 | * @return GNUNET_OK on success, GNUNET_SYSERR to stop further processing | 218 | * @return GNUNET_OK on success, GNUNET_SYSERR to stop further processing |
217 | */ | 219 | */ |
218 | static int | 220 | static int |
219 | tokenizer_cb (void *cls, void *client, | 221 | tokenizer_cb (void *cls, void *client, |
220 | const struct GNUNET_MessageHeader *message) | 222 | const struct GNUNET_MessageHeader *message) |
221 | { | 223 | { |
@@ -234,8 +236,7 @@ tokenizer_cb (void *cls, void *client, | |||
234 | if ((sizeof (struct GNUNET_TESTBED_HelperInit) >= ntohs (message->size)) || | 236 | if ((sizeof (struct GNUNET_TESTBED_HelperInit) >= ntohs (message->size)) || |
235 | (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT != ntohs (message->type))) | 237 | (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT != ntohs (message->type))) |
236 | { | 238 | { |
237 | LOG (GNUNET_ERROR_TYPE_WARNING, | 239 | LOG (GNUNET_ERROR_TYPE_WARNING, "Received unexpected message -- exiting\n"); |
238 | "Received unexpected message -- exiting\n"); | ||
239 | goto error; | 240 | goto error; |
240 | } | 241 | } |
241 | msg = (const struct GNUNET_TESTBED_HelperInit *) message; | 242 | msg = (const struct GNUNET_TESTBED_HelperInit *) message; |
@@ -243,28 +244,30 @@ tokenizer_cb (void *cls, void *client, | |||
243 | controller = (char *) &msg[1]; | 244 | controller = (char *) &msg[1]; |
244 | if ('\0' != controller[cname_size]) | 245 | if ('\0' != controller[cname_size]) |
245 | { | 246 | { |
246 | LOG (GNUNET_ERROR_TYPE_WARNING, | 247 | LOG (GNUNET_ERROR_TYPE_WARNING, |
247 | "Controller name cannot be empty -- exiting\n"); | 248 | "Controller name cannot be empty -- exiting\n"); |
248 | goto error; | 249 | goto error; |
249 | } | 250 | } |
250 | ul_config_size = (uLongf) ntohs (msg->config_size); | 251 | ul_config_size = (uLongf) ntohs (msg->config_size); |
251 | config = GNUNET_malloc (ul_config_size); | 252 | config = GNUNET_malloc (ul_config_size); |
252 | xconfig_size = ntohs (message->size) - | 253 | xconfig_size = |
253 | (cname_size + 1 + sizeof (struct GNUNET_TESTBED_HelperInit)); | 254 | ntohs (message->size) - (cname_size + 1 + |
254 | if (Z_OK != uncompress ((Bytef *) config, &ul_config_size, | 255 | sizeof (struct GNUNET_TESTBED_HelperInit)); |
255 | (const Bytef *) (controller + cname_size + 1), | 256 | if (Z_OK != |
256 | (uLongf) xconfig_size)) | 257 | uncompress ((Bytef *) config, &ul_config_size, |
258 | (const Bytef *) (controller + cname_size + 1), | ||
259 | (uLongf) xconfig_size)) | ||
257 | { | 260 | { |
258 | LOG (GNUNET_ERROR_TYPE_WARNING, | 261 | LOG (GNUNET_ERROR_TYPE_WARNING, |
259 | "Error while uncompressing config -- exiting\n"); | 262 | "Error while uncompressing config -- exiting\n"); |
260 | GNUNET_free (config); | 263 | GNUNET_free (config); |
261 | goto error; | 264 | goto error; |
262 | } | 265 | } |
263 | cfg = GNUNET_CONFIGURATION_create (); | 266 | cfg = GNUNET_CONFIGURATION_create (); |
264 | if (GNUNET_OK != GNUNET_CONFIGURATION_deserialize (cfg, config, | 267 | if (GNUNET_OK != |
265 | ul_config_size, GNUNET_NO)) | 268 | GNUNET_CONFIGURATION_deserialize (cfg, config, ul_config_size, GNUNET_NO)) |
266 | { | 269 | { |
267 | LOG (GNUNET_ERROR_TYPE_WARNING, | 270 | LOG (GNUNET_ERROR_TYPE_WARNING, |
268 | "Unable to deserialize config -- exiting\n"); | 271 | "Unable to deserialize config -- exiting\n"); |
269 | GNUNET_free (config); | 272 | GNUNET_free (config); |
270 | goto error; | 273 | goto error; |
@@ -272,26 +275,30 @@ tokenizer_cb (void *cls, void *client, | |||
272 | GNUNET_free (config); | 275 | GNUNET_free (config); |
273 | test_system = GNUNET_TESTING_system_create ("testbed-helper", controller); | 276 | test_system = GNUNET_TESTING_system_create ("testbed-helper", controller); |
274 | GNUNET_assert (NULL != test_system); | 277 | GNUNET_assert (NULL != test_system); |
275 | GNUNET_assert (GNUNET_OK == GNUNET_TESTING_configuration_create | 278 | GNUNET_assert (GNUNET_OK == |
276 | (test_system, cfg)); | 279 | GNUNET_TESTING_configuration_create (test_system, cfg)); |
277 | GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string | 280 | GNUNET_assert (GNUNET_OK == |
278 | (cfg, "PATHS", "DEFAULTCONFIG", &config)); | 281 | GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", |
282 | "DEFAULTCONFIG", | ||
283 | &config)); | ||
279 | if (GNUNET_OK != GNUNET_CONFIGURATION_write (cfg, config)) | 284 | if (GNUNET_OK != GNUNET_CONFIGURATION_write (cfg, config)) |
280 | { | 285 | { |
281 | LOG (GNUNET_ERROR_TYPE_WARNING, | 286 | LOG (GNUNET_ERROR_TYPE_WARNING, |
282 | "Unable to write config file: %s -- exiting\n", config); | 287 | "Unable to write config file: %s -- exiting\n", config); |
283 | GNUNET_CONFIGURATION_destroy (cfg); | 288 | GNUNET_CONFIGURATION_destroy (cfg); |
284 | GNUNET_free (config); | 289 | GNUNET_free (config); |
285 | goto error; | 290 | goto error; |
286 | } | 291 | } |
287 | LOG_DEBUG ("Staring testbed with config: %s\n", config); | 292 | LOG_DEBUG ("Staring testbed with config: %s\n", config); |
288 | testbed = GNUNET_OS_start_process | 293 | testbed = |
289 | (GNUNET_YES, GNUNET_OS_INHERIT_STD_ERR /*verbose? */, NULL, NULL, | 294 | GNUNET_OS_start_process (GNUNET_YES, |
290 | "gnunet-service-testbed", "gnunet-service-testbed", "-c", config, NULL); | 295 | GNUNET_OS_INHERIT_STD_ERR /*verbose? */ , NULL, |
296 | NULL, "gnunet-service-testbed", | ||
297 | "gnunet-service-testbed", "-c", config, NULL); | ||
291 | GNUNET_free (config); | 298 | GNUNET_free (config); |
292 | if (NULL == testbed) | 299 | if (NULL == testbed) |
293 | { | 300 | { |
294 | LOG (GNUNET_ERROR_TYPE_WARNING, | 301 | LOG (GNUNET_ERROR_TYPE_WARNING, |
295 | "Error staring gnunet-service-testbed -- exiting\n"); | 302 | "Error staring gnunet-service-testbed -- exiting\n"); |
296 | GNUNET_CONFIGURATION_destroy (cfg); | 303 | GNUNET_CONFIGURATION_destroy (cfg); |
297 | goto error; | 304 | goto error; |
@@ -300,8 +307,8 @@ tokenizer_cb (void *cls, void *client, | |||
300 | config = GNUNET_CONFIGURATION_serialize (cfg, &config_size); | 307 | config = GNUNET_CONFIGURATION_serialize (cfg, &config_size); |
301 | GNUNET_CONFIGURATION_destroy (cfg); | 308 | GNUNET_CONFIGURATION_destroy (cfg); |
302 | cfg = NULL; | 309 | cfg = NULL; |
303 | xconfig_size = GNUNET_TESTBED_compress_config_ (config, config_size, | 310 | xconfig_size = |
304 | &xconfig); | 311 | GNUNET_TESTBED_compress_config_ (config, config_size, &xconfig); |
305 | GNUNET_free (config); | 312 | GNUNET_free (config); |
306 | wc = GNUNET_malloc (sizeof (struct WriteContext)); | 313 | wc = GNUNET_malloc (sizeof (struct WriteContext)); |
307 | wc->length = xconfig_size + sizeof (struct GNUNET_TESTBED_HelperReply); | 314 | wc->length = xconfig_size + sizeof (struct GNUNET_TESTBED_HelperReply); |
@@ -311,11 +318,12 @@ tokenizer_cb (void *cls, void *client, | |||
311 | reply->header.size = htons ((uint16_t) wc->length); | 318 | reply->header.size = htons ((uint16_t) wc->length); |
312 | reply->config_size = htons ((uint16_t) config_size); | 319 | reply->config_size = htons ((uint16_t) config_size); |
313 | wc->data = reply; | 320 | wc->data = reply; |
314 | write_task_id = GNUNET_SCHEDULER_add_write_file | 321 | write_task_id = |
315 | (GNUNET_TIME_UNIT_FOREVER_REL, stdout_fd, &write_task, wc); | 322 | GNUNET_SCHEDULER_add_write_file (GNUNET_TIME_UNIT_FOREVER_REL, stdout_fd, |
323 | &write_task, wc); | ||
316 | return GNUNET_OK; | 324 | return GNUNET_OK; |
317 | 325 | ||
318 | error: | 326 | error: |
319 | status = GNUNET_SYSERR; | 327 | status = GNUNET_SYSERR; |
320 | GNUNET_SCHEDULER_shutdown (); | 328 | GNUNET_SCHEDULER_shutdown (); |
321 | return GNUNET_SYSERR; | 329 | return GNUNET_SYSERR; |
@@ -336,7 +344,7 @@ read_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
336 | 344 | ||
337 | read_task_id = GNUNET_SCHEDULER_NO_TASK; | 345 | read_task_id = GNUNET_SCHEDULER_NO_TASK; |
338 | if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) | 346 | if (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason)) |
339 | return; | 347 | return; |
340 | sread = GNUNET_DISK_file_read (stdin_fd, buf, sizeof (buf)); | 348 | sread = GNUNET_DISK_file_read (stdin_fd, buf, sizeof (buf)); |
341 | if ((GNUNET_SYSERR == sread) || (0 == sread)) | 349 | if ((GNUNET_SYSERR == sread) || (0 == sread)) |
342 | { | 350 | { |
@@ -351,16 +359,16 @@ read_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
351 | } | 359 | } |
352 | LOG_DEBUG ("Read %u bytes\n", sread); | 360 | LOG_DEBUG ("Read %u bytes\n", sread); |
353 | if (GNUNET_OK != | 361 | if (GNUNET_OK != |
354 | GNUNET_SERVER_mst_receive (tokenizer, NULL, buf, sread, | 362 | GNUNET_SERVER_mst_receive (tokenizer, NULL, buf, sread, GNUNET_NO, |
355 | GNUNET_NO, GNUNET_NO)) | 363 | GNUNET_NO)) |
356 | { | 364 | { |
357 | GNUNET_break (0); | 365 | GNUNET_break (0); |
358 | GNUNET_SCHEDULER_shutdown (); | 366 | GNUNET_SCHEDULER_shutdown (); |
359 | return; | 367 | return; |
360 | } | 368 | } |
361 | read_task_id = /* No timeout while reading */ | 369 | read_task_id = /* No timeout while reading */ |
362 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, | 370 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, stdin_fd, |
363 | stdin_fd, &read_task, NULL); | 371 | &read_task, NULL); |
364 | } | 372 | } |
365 | 373 | ||
366 | 374 | ||
@@ -372,19 +380,19 @@ read_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
372 | * @param cfgfile name of the configuration file used (for saving, can be NULL!) | 380 | * @param cfgfile name of the configuration file used (for saving, can be NULL!) |
373 | * @param cfg configuration | 381 | * @param cfg configuration |
374 | */ | 382 | */ |
375 | static void | 383 | static void |
376 | run (void *cls, char *const *args, const char *cfgfile, | 384 | run (void *cls, char *const *args, const char *cfgfile, |
377 | const struct GNUNET_CONFIGURATION_Handle * cfg) | 385 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
378 | { | 386 | { |
379 | LOG_DEBUG ("Starting testbed helper...\n"); | 387 | LOG_DEBUG ("Starting testbed helper...\n"); |
380 | tokenizer = GNUNET_SERVER_mst_create (&tokenizer_cb, NULL); | 388 | tokenizer = GNUNET_SERVER_mst_create (&tokenizer_cb, NULL); |
381 | stdin_fd = GNUNET_DISK_get_handle_from_native (stdin); | 389 | stdin_fd = GNUNET_DISK_get_handle_from_native (stdin); |
382 | stdout_fd = GNUNET_DISK_get_handle_from_native (stdout); | 390 | stdout_fd = GNUNET_DISK_get_handle_from_native (stdout); |
383 | read_task_id = | 391 | read_task_id = |
384 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, | 392 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, stdin_fd, |
385 | stdin_fd, &read_task, NULL); | 393 | &read_task, NULL); |
386 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 394 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, |
387 | &shutdown_task, NULL); | 395 | NULL); |
388 | } | 396 | } |
389 | 397 | ||
390 | 398 | ||
@@ -400,8 +408,8 @@ sighandler_child_death () | |||
400 | GNUNET_assert (GNUNET_OK == GNUNET_OS_process_wait (testbed)); | 408 | GNUNET_assert (GNUNET_OK == GNUNET_OS_process_wait (testbed)); |
401 | GNUNET_OS_process_destroy (testbed); | 409 | GNUNET_OS_process_destroy (testbed); |
402 | testbed = NULL; | 410 | testbed = NULL; |
403 | GNUNET_SCHEDULER_shutdown (); /* We are done too! */ | 411 | GNUNET_SCHEDULER_shutdown (); /* We are done too! */ |
404 | } | 412 | } |
405 | } | 413 | } |
406 | 414 | ||
407 | 415 | ||
@@ -412,9 +420,11 @@ sighandler_child_death () | |||
412 | * @param argv command line arg array | 420 | * @param argv command line arg array |
413 | * @return return code | 421 | * @return return code |
414 | */ | 422 | */ |
415 | int main (int argc, char **argv) | 423 | int |
424 | main (int argc, char **argv) | ||
416 | { | 425 | { |
417 | struct GNUNET_SIGNAL_Context *shc_chld; | 426 | struct GNUNET_SIGNAL_Context *shc_chld; |
427 | |||
418 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 428 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
419 | GNUNET_GETOPT_OPTION_END | 429 | GNUNET_GETOPT_OPTION_END |
420 | }; | 430 | }; |
@@ -423,10 +433,11 @@ int main (int argc, char **argv) | |||
423 | status = GNUNET_OK; | 433 | status = GNUNET_OK; |
424 | in_shutdown = GNUNET_NO; | 434 | in_shutdown = GNUNET_NO; |
425 | shc_chld = | 435 | shc_chld = |
426 | GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD, &sighandler_child_death); | 436 | GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD, &sighandler_child_death); |
427 | ret = GNUNET_PROGRAM_run (argc, argv, "gnunet-testbed-helper", | 437 | ret = |
428 | "Helper for starting gnunet-service-testbed", | 438 | GNUNET_PROGRAM_run (argc, argv, "gnunet-testbed-helper", |
429 | options, &run, NULL); | 439 | "Helper for starting gnunet-service-testbed", options, |
440 | &run, NULL); | ||
430 | GNUNET_SIGNAL_handler_uninstall (shc_chld); | 441 | GNUNET_SIGNAL_handler_uninstall (shc_chld); |
431 | shc_chld = NULL; | 442 | shc_chld = NULL; |
432 | if (GNUNET_OK != ret) | 443 | if (GNUNET_OK != ret) |
diff --git a/src/testbed/test_gnunet_testbed_helper.c b/src/testbed/test_gnunet_testbed_helper.c index 0026b4923..92eb07f03 100644 --- a/src/testbed/test_gnunet_testbed_helper.c +++ b/src/testbed/test_gnunet_testbed_helper.c | |||
@@ -21,7 +21,7 @@ | |||
21 | /** | 21 | /** |
22 | * @file testbed/test_gnunet_testbed_helper.c | 22 | * @file testbed/test_gnunet_testbed_helper.c |
23 | * @brief Testcase for testing gnunet-testbed-helper.c | 23 | * @brief Testcase for testing gnunet-testbed-helper.c |
24 | * @author Sree Harsha Totakura <sreeharsha@totakura.in> | 24 | * @author Sree Harsha Totakura <sreeharsha@totakura.in> |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "platform.h" | 27 | #include "platform.h" |
@@ -84,7 +84,7 @@ static int result; | |||
84 | */ | 84 | */ |
85 | static void | 85 | static void |
86 | do_shutdown (void *cls, const const struct GNUNET_SCHEDULER_TaskContext *tc) | 86 | do_shutdown (void *cls, const const struct GNUNET_SCHEDULER_TaskContext *tc) |
87 | { | 87 | { |
88 | if (GNUNET_SCHEDULER_NO_TASK != abort_task) | 88 | if (GNUNET_SCHEDULER_NO_TASK != abort_task) |
89 | GNUNET_SCHEDULER_cancel (abort_task); | 89 | GNUNET_SCHEDULER_cancel (abort_task); |
90 | GNUNET_HELPER_stop (helper); | 90 | GNUNET_HELPER_stop (helper); |
@@ -115,13 +115,13 @@ do_abort (void *cls, const const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
115 | 115 | ||
116 | /** | 116 | /** |
117 | * Continuation function. | 117 | * Continuation function. |
118 | * | 118 | * |
119 | * @param cls closure | 119 | * @param cls closure |
120 | * @param result GNUNET_OK on success, | 120 | * @param result GNUNET_OK on success, |
121 | * GNUNET_NO if helper process died | 121 | * GNUNET_NO if helper process died |
122 | * GNUNET_SYSERR during GNUNET_HELPER_stop | 122 | * GNUNET_SYSERR during GNUNET_HELPER_stop |
123 | */ | 123 | */ |
124 | static void | 124 | static void |
125 | cont_cb (void *cls, int result) | 125 | cont_cb (void *cls, int result) |
126 | { | 126 | { |
127 | shandle = NULL; | 127 | shandle = NULL; |
@@ -142,32 +142,35 @@ cont_cb (void *cls, int result) | |||
142 | * | 142 | * |
143 | * @return GNUNET_OK on success, GNUNET_SYSERR to stop further processing | 143 | * @return GNUNET_OK on success, GNUNET_SYSERR to stop further processing |
144 | */ | 144 | */ |
145 | static int | 145 | static int |
146 | mst_cb (void *cls, void *client, const struct GNUNET_MessageHeader *message) | 146 | mst_cb (void *cls, void *client, const struct GNUNET_MessageHeader *message) |
147 | { | 147 | { |
148 | const struct GNUNET_TESTBED_HelperReply *msg; | 148 | const struct GNUNET_TESTBED_HelperReply *msg; |
149 | char *config; | 149 | char *config; |
150 | uLongf config_size; | 150 | uLongf config_size; |
151 | uLongf xconfig_size; | 151 | uLongf xconfig_size; |
152 | 152 | ||
153 | msg = (const struct GNUNET_TESTBED_HelperReply *) message; | 153 | msg = (const struct GNUNET_TESTBED_HelperReply *) message; |
154 | config_size = 0; | 154 | config_size = 0; |
155 | xconfig_size = 0; | 155 | xconfig_size = 0; |
156 | GNUNET_assert (sizeof (struct GNUNET_TESTBED_HelperReply) | 156 | GNUNET_assert (sizeof (struct GNUNET_TESTBED_HelperReply) < |
157 | < ntohs (msg->header.size)); | 157 | ntohs (msg->header.size)); |
158 | GNUNET_assert (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_REPLY | 158 | GNUNET_assert (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_REPLY == |
159 | == ntohs (msg->header.type)); | 159 | ntohs (msg->header.type)); |
160 | config_size = (uLongf) ntohs (msg->config_size); | 160 | config_size = (uLongf) ntohs (msg->config_size); |
161 | xconfig_size = (uLongf) (ntohs (msg->header.size) | 161 | xconfig_size = |
162 | - sizeof (struct GNUNET_TESTBED_HelperReply)); | 162 | (uLongf) (ntohs (msg->header.size) - |
163 | sizeof (struct GNUNET_TESTBED_HelperReply)); | ||
163 | config = GNUNET_malloc (config_size); | 164 | config = GNUNET_malloc (config_size); |
164 | GNUNET_assert (Z_OK == uncompress ((Bytef *) config, &config_size, | 165 | GNUNET_assert (Z_OK == |
165 | (const Bytef *) &msg[1], xconfig_size)); | 166 | uncompress ((Bytef *) config, &config_size, |
167 | (const Bytef *) &msg[1], xconfig_size)); | ||
166 | GNUNET_free (config); | 168 | GNUNET_free (config); |
167 | if (GNUNET_SCHEDULER_NO_TASK == shutdown_task) | 169 | if (GNUNET_SCHEDULER_NO_TASK == shutdown_task) |
168 | shutdown_task = GNUNET_SCHEDULER_add_delayed | 170 | shutdown_task = |
169 | (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), | 171 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
170 | &do_shutdown, NULL); | 172 | (GNUNET_TIME_UNIT_SECONDS, 1), |
173 | &do_shutdown, NULL); | ||
171 | return GNUNET_OK; | 174 | return GNUNET_OK; |
172 | } | 175 | } |
173 | 176 | ||
@@ -178,7 +181,7 @@ mst_cb (void *cls, void *client, const struct GNUNET_MessageHeader *message) | |||
178 | * | 181 | * |
179 | * @param cls the closure from GNUNET_HELPER_start() | 182 | * @param cls the closure from GNUNET_HELPER_start() |
180 | */ | 183 | */ |
181 | static void | 184 | static void |
182 | exp_cb (void *cls) | 185 | exp_cb (void *cls) |
183 | { | 186 | { |
184 | helper = NULL; | 187 | helper = NULL; |
@@ -194,29 +197,29 @@ exp_cb (void *cls) | |||
194 | * @param cfgfile name of the configuration file used (for saving, can be NULL!) | 197 | * @param cfgfile name of the configuration file used (for saving, can be NULL!) |
195 | * @param cfg configuration | 198 | * @param cfg configuration |
196 | */ | 199 | */ |
197 | static void | 200 | static void |
198 | run (void *cls, char *const *args, const char *cfgfile, | 201 | run (void *cls, char *const *args, const char *cfgfile, |
199 | const struct GNUNET_CONFIGURATION_Handle * cfg2) | 202 | const struct GNUNET_CONFIGURATION_Handle *cfg2) |
200 | { | 203 | { |
201 | static char * const binary_argv[] = { | 204 | static char *const binary_argv[] = { |
202 | "gnunet-testbed-helper", | 205 | "gnunet-testbed-helper", |
203 | NULL | 206 | NULL |
204 | }; | 207 | }; |
205 | const char *controller_name = "127.0.0.1"; | 208 | const char *controller_name = "127.0.0.1"; |
206 | 209 | ||
207 | helper = GNUNET_HELPER_start (GNUNET_YES, | 210 | helper = |
208 | "gnunet-testbed-helper", | 211 | GNUNET_HELPER_start (GNUNET_YES, "gnunet-testbed-helper", binary_argv, |
209 | binary_argv, | 212 | &mst_cb, &exp_cb, NULL); |
210 | &mst_cb, &exp_cb, NULL); | ||
211 | GNUNET_assert (NULL != helper); | 213 | GNUNET_assert (NULL != helper); |
212 | cfg = GNUNET_CONFIGURATION_dup (cfg2); | 214 | cfg = GNUNET_CONFIGURATION_dup (cfg2); |
213 | msg = GNUNET_TESTBED_create_helper_init_msg_ (controller_name, cfg); | 215 | msg = GNUNET_TESTBED_create_helper_init_msg_ (controller_name, cfg); |
214 | shandle = GNUNET_HELPER_send (helper, | 216 | shandle = |
215 | &msg->header, | 217 | GNUNET_HELPER_send (helper, &msg->header, GNUNET_NO, &cont_cb, NULL); |
216 | GNUNET_NO, &cont_cb, NULL); | ||
217 | GNUNET_assert (NULL != shandle); | 218 | GNUNET_assert (NULL != shandle); |
218 | abort_task = GNUNET_SCHEDULER_add_delayed | 219 | abort_task = |
219 | (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1), &do_abort, NULL); | 220 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
221 | (GNUNET_TIME_UNIT_MINUTES, 1), &do_abort, | ||
222 | NULL); | ||
220 | } | 223 | } |
221 | 224 | ||
222 | 225 | ||
@@ -227,17 +230,18 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
227 | * @param argv command line arg array | 230 | * @param argv command line arg array |
228 | * @return return code | 231 | * @return return code |
229 | */ | 232 | */ |
230 | int main (int argc, char **argv) | 233 | int |
234 | main (int argc, char **argv) | ||
231 | { | 235 | { |
232 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 236 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
233 | GNUNET_GETOPT_OPTION_END | 237 | GNUNET_GETOPT_OPTION_END |
234 | }; | 238 | }; |
235 | 239 | ||
236 | result = GNUNET_OK; | 240 | result = GNUNET_OK; |
237 | if (GNUNET_OK != | 241 | if (GNUNET_OK != |
238 | GNUNET_PROGRAM_run (argc, argv, "test_gnunet_testbed_helper", | 242 | GNUNET_PROGRAM_run (argc, argv, "test_gnunet_testbed_helper", |
239 | "Testcase for testing gnunet-testbed-helper.c", | 243 | "Testcase for testing gnunet-testbed-helper.c", |
240 | options, &run, NULL)) | 244 | options, &run, NULL)) |
241 | return 1; | 245 | return 1; |
242 | return (GNUNET_OK == result) ? 0 : 1; | 246 | return (GNUNET_OK == result) ? 0 : 1; |
243 | } | 247 | } |
diff --git a/src/testbed/test_testbed_api.c b/src/testbed/test_testbed_api.c index 32f65542c..caa3d09fd 100644 --- a/src/testbed/test_testbed_api.c +++ b/src/testbed/test_testbed_api.c | |||
@@ -102,27 +102,27 @@ static int result; | |||
102 | * Enumeration of sub testcases | 102 | * Enumeration of sub testcases |
103 | */ | 103 | */ |
104 | enum Test | 104 | enum Test |
105 | { | 105 | { |
106 | /** | 106 | /** |
107 | * Test cases which are not covered by the below ones | 107 | * Test cases which are not covered by the below ones |
108 | */ | 108 | */ |
109 | OTHER, | 109 | OTHER, |
110 | 110 | ||
111 | /** | 111 | /** |
112 | * Test where we get a peer config from controller | 112 | * Test where we get a peer config from controller |
113 | */ | 113 | */ |
114 | PEER_GETCONFIG, | 114 | PEER_GETCONFIG, |
115 | 115 | ||
116 | /** | 116 | /** |
117 | * Test where we connect to a service running on the peer | 117 | * Test where we connect to a service running on the peer |
118 | */ | 118 | */ |
119 | PEER_SERVICE_CONNECT, | 119 | PEER_SERVICE_CONNECT, |
120 | 120 | ||
121 | /** | 121 | /** |
122 | * Test where we get a peer's identity from controller | 122 | * Test where we get a peer's identity from controller |
123 | */ | 123 | */ |
124 | PEER_DESTROY, | 124 | PEER_DESTROY, |
125 | }; | 125 | }; |
126 | 126 | ||
127 | /** | 127 | /** |
128 | * Testing status | 128 | * Testing status |
@@ -170,7 +170,7 @@ do_abort (void *cls, const const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
170 | /** | 170 | /** |
171 | * Adapter function called to establish a connection to | 171 | * Adapter function called to establish a connection to |
172 | * a service. | 172 | * a service. |
173 | * | 173 | * |
174 | * @param cls closure | 174 | * @param cls closure |
175 | * @param cfg configuration of the peer to connect to; will be available until | 175 | * @param cfg configuration of the peer to connect to; will be available until |
176 | * GNUNET_TESTBED_operation_done() is called on the operation returned | 176 | * GNUNET_TESTBED_operation_done() is called on the operation returned |
@@ -178,8 +178,7 @@ do_abort (void *cls, const const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
178 | * @return service handle to return in 'op_result', NULL on error | 178 | * @return service handle to return in 'op_result', NULL on error |
179 | */ | 179 | */ |
180 | static void * | 180 | static void * |
181 | dht_connect_adapter (void *cls, | 181 | dht_connect_adapter (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) |
182 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
183 | { | 182 | { |
184 | GNUNET_assert (NULL == cls); | 183 | GNUNET_assert (NULL == cls); |
185 | GNUNET_assert (OTHER == sub_test); | 184 | GNUNET_assert (OTHER == sub_test); |
@@ -192,13 +191,12 @@ dht_connect_adapter (void *cls, | |||
192 | /** | 191 | /** |
193 | * Adapter function called to destroy a connection to | 192 | * Adapter function called to destroy a connection to |
194 | * a service. | 193 | * a service. |
195 | * | 194 | * |
196 | * @param cls closure | 195 | * @param cls closure |
197 | * @param op_result service handle returned from the connect adapter | 196 | * @param op_result service handle returned from the connect adapter |
198 | */ | 197 | */ |
199 | static void | 198 | static void |
200 | dht_disconnect_adapter (void *cls, | 199 | dht_disconnect_adapter (void *cls, void *op_result) |
201 | void *op_result) | ||
202 | { | 200 | { |
203 | if (NULL != op_result) | 201 | if (NULL != op_result) |
204 | GNUNET_DHT_disconnect (op_result); | 202 | GNUNET_DHT_disconnect (op_result); |
@@ -217,20 +215,20 @@ dht_disconnect_adapter (void *cls, | |||
217 | * @param cls closure | 215 | * @param cls closure |
218 | * @param event information about the event | 216 | * @param event information about the event |
219 | */ | 217 | */ |
220 | static void | 218 | static void |
221 | controller_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event) | 219 | controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) |
222 | { | 220 | { |
223 | switch (event->type) | 221 | switch (event->type) |
224 | { | 222 | { |
225 | case GNUNET_TESTBED_ET_OPERATION_FINISHED: | 223 | case GNUNET_TESTBED_ET_OPERATION_FINISHED: |
226 | switch(sub_test) | 224 | switch (sub_test) |
227 | { | 225 | { |
228 | case PEER_GETCONFIG: | 226 | case PEER_GETCONFIG: |
229 | GNUNET_assert (event->details.operation_finished.operation == operation); | 227 | GNUNET_assert (event->details.operation_finished.operation == operation); |
230 | GNUNET_assert (NULL == event->details.operation_finished.op_cls); | 228 | GNUNET_assert (NULL == event->details.operation_finished.op_cls); |
231 | GNUNET_assert (NULL == event->details.operation_finished.emsg); | 229 | GNUNET_assert (NULL == event->details.operation_finished.emsg); |
232 | GNUNET_assert (GNUNET_TESTBED_PIT_CONFIGURATION == | 230 | GNUNET_assert (GNUNET_TESTBED_PIT_CONFIGURATION == |
233 | event->details.operation_finished.pit); | 231 | event->details.operation_finished.pit); |
234 | GNUNET_assert (NULL != event->details.operation_finished.op_result.cfg); | 232 | GNUNET_assert (NULL != event->details.operation_finished.op_result.cfg); |
235 | sub_test = PEER_DESTROY; | 233 | sub_test = PEER_DESTROY; |
236 | GNUNET_TESTBED_operation_done (operation); | 234 | GNUNET_TESTBED_operation_done (operation); |
@@ -241,9 +239,9 @@ controller_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
241 | GNUNET_assert (NULL == event->details.operation_finished.op_cls); | 239 | GNUNET_assert (NULL == event->details.operation_finished.op_cls); |
242 | GNUNET_assert (NULL == event->details.operation_finished.emsg); | 240 | GNUNET_assert (NULL == event->details.operation_finished.emsg); |
243 | GNUNET_assert (GNUNET_TESTBED_PIT_GENERIC == | 241 | GNUNET_assert (GNUNET_TESTBED_PIT_GENERIC == |
244 | event->details.operation_finished.pit); | 242 | event->details.operation_finished.pit); |
245 | GNUNET_assert (NULL == | 243 | GNUNET_assert (NULL == |
246 | event->details.operation_finished.op_result.generic); | 244 | event->details.operation_finished.op_result.generic); |
247 | GNUNET_TESTBED_operation_done (operation); | 245 | GNUNET_TESTBED_operation_done (operation); |
248 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 246 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
249 | break; | 247 | break; |
@@ -252,27 +250,26 @@ controller_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
252 | GNUNET_assert (NULL == event->details.operation_finished.op_cls); | 250 | GNUNET_assert (NULL == event->details.operation_finished.op_cls); |
253 | GNUNET_assert (NULL == event->details.operation_finished.emsg); | 251 | GNUNET_assert (NULL == event->details.operation_finished.emsg); |
254 | GNUNET_assert (GNUNET_TESTBED_PIT_GENERIC == | 252 | GNUNET_assert (GNUNET_TESTBED_PIT_GENERIC == |
255 | event->details.operation_finished.pit); | 253 | event->details.operation_finished.pit); |
256 | GNUNET_assert (NULL != dht_handle); | 254 | GNUNET_assert (NULL != dht_handle); |
257 | GNUNET_assert (event->details.operation_finished.op_result.generic | 255 | GNUNET_assert (event->details.operation_finished.op_result.generic == |
258 | == dht_handle); | 256 | dht_handle); |
259 | GNUNET_TESTBED_operation_done (operation); /* This results in call to | 257 | GNUNET_TESTBED_operation_done (operation); /* This results in call to |
260 | * disconnect adapter */ | 258 | * disconnect adapter */ |
261 | break; | 259 | break; |
262 | case OTHER: | 260 | case OTHER: |
263 | GNUNET_assert (0); | 261 | GNUNET_assert (0); |
264 | break; | 262 | break; |
265 | } | 263 | } |
266 | break; | 264 | break; |
267 | case GNUNET_TESTBED_ET_PEER_START: | 265 | case GNUNET_TESTBED_ET_PEER_START: |
268 | GNUNET_assert (event->details.peer_start.host == host); | 266 | GNUNET_assert (event->details.peer_start.host == host); |
269 | GNUNET_assert (event->details.peer_start.peer == peer); | 267 | GNUNET_assert (event->details.peer_start.peer == peer); |
270 | GNUNET_assert (OTHER == sub_test); | 268 | GNUNET_assert (OTHER == sub_test); |
271 | GNUNET_TESTBED_operation_done (operation); | 269 | GNUNET_TESTBED_operation_done (operation); |
272 | operation = GNUNET_TESTBED_service_connect (NULL, peer, "dht", | 270 | operation = |
273 | &dht_connect_adapter, | 271 | GNUNET_TESTBED_service_connect (NULL, peer, "dht", &dht_connect_adapter, |
274 | &dht_disconnect_adapter, | 272 | &dht_disconnect_adapter, NULL); |
275 | NULL); | ||
276 | GNUNET_assert (NULL != operation); | 273 | GNUNET_assert (NULL != operation); |
277 | break; | 274 | break; |
278 | case GNUNET_TESTBED_ET_PEER_STOP: | 275 | case GNUNET_TESTBED_ET_PEER_STOP: |
@@ -281,12 +278,12 @@ controller_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
281 | result = GNUNET_YES; | 278 | result = GNUNET_YES; |
282 | sub_test = PEER_GETCONFIG; | 279 | sub_test = PEER_GETCONFIG; |
283 | GNUNET_TESTBED_operation_done (operation); | 280 | GNUNET_TESTBED_operation_done (operation); |
284 | operation = | 281 | operation = |
285 | GNUNET_TESTBED_peer_get_information (peer, | 282 | GNUNET_TESTBED_peer_get_information (peer, |
286 | GNUNET_TESTBED_PIT_CONFIGURATION); | 283 | GNUNET_TESTBED_PIT_CONFIGURATION); |
287 | break; | 284 | break; |
288 | default: | 285 | default: |
289 | GNUNET_assert (0); /* We should never reach this state */ | 286 | GNUNET_assert (0); /* We should never reach this state */ |
290 | } | 287 | } |
291 | } | 288 | } |
292 | 289 | ||
@@ -301,11 +298,10 @@ controller_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
301 | * @param emsg NULL if peer is not NULL; else MAY contain the error description | 298 | * @param emsg NULL if peer is not NULL; else MAY contain the error description |
302 | */ | 299 | */ |
303 | static void | 300 | static void |
304 | peer_create_cb (void *cls, | 301 | peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg) |
305 | struct GNUNET_TESTBED_Peer *peer, const char *emsg) | ||
306 | { | 302 | { |
307 | struct GNUNET_TESTBED_Peer **peer_ptr; | 303 | struct GNUNET_TESTBED_Peer **peer_ptr; |
308 | 304 | ||
309 | peer_ptr = cls; | 305 | peer_ptr = cls; |
310 | GNUNET_assert (NULL != peer); | 306 | GNUNET_assert (NULL != peer); |
311 | GNUNET_assert (NULL != peer_ptr); | 307 | GNUNET_assert (NULL != peer_ptr); |
@@ -322,12 +318,14 @@ peer_create_cb (void *cls, | |||
322 | * @param cls the host which has been registered | 318 | * @param cls the host which has been registered |
323 | * @param emsg the error message; NULL if host registration is successful | 319 | * @param emsg the error message; NULL if host registration is successful |
324 | */ | 320 | */ |
325 | static void | 321 | static void |
326 | registration_comp (void *cls, const char *emsg) | 322 | registration_comp (void *cls, const char *emsg) |
327 | { | 323 | { |
328 | GNUNET_assert (cls == neighbour); | 324 | GNUNET_assert (cls == neighbour); |
329 | reg_handle = NULL; | 325 | reg_handle = NULL; |
330 | operation = GNUNET_TESTBED_peer_create (controller, host, cfg, &peer_create_cb, &peer); | 326 | operation = |
327 | GNUNET_TESTBED_peer_create (controller, host, cfg, &peer_create_cb, | ||
328 | &peer); | ||
331 | GNUNET_assert (NULL != operation); | 329 | GNUNET_assert (NULL != operation); |
332 | } | 330 | } |
333 | 331 | ||
@@ -341,9 +339,8 @@ registration_comp (void *cls, const char *emsg) | |||
341 | * @param status GNUNET_OK if the startup is successfull; GNUNET_SYSERR if not, | 339 | * @param status GNUNET_OK if the startup is successfull; GNUNET_SYSERR if not, |
342 | * GNUNET_TESTBED_controller_stop() shouldn't be called in this case | 340 | * GNUNET_TESTBED_controller_stop() shouldn't be called in this case |
343 | */ | 341 | */ |
344 | static void | 342 | static void |
345 | status_cb (void *cls, | 343 | status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, int status) |
346 | const struct GNUNET_CONFIGURATION_Handle *cfg, int status) | ||
347 | { | 344 | { |
348 | uint64_t event_mask; | 345 | uint64_t event_mask; |
349 | 346 | ||
@@ -353,21 +350,22 @@ status_cb (void *cls, | |||
353 | event_mask |= (1L << GNUNET_TESTBED_ET_PEER_STOP); | 350 | event_mask |= (1L << GNUNET_TESTBED_ET_PEER_STOP); |
354 | event_mask |= (1L << GNUNET_TESTBED_ET_CONNECT); | 351 | event_mask |= (1L << GNUNET_TESTBED_ET_CONNECT); |
355 | event_mask |= (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED); | 352 | event_mask |= (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED); |
356 | controller = GNUNET_TESTBED_controller_connect (cfg, host, event_mask, | 353 | controller = |
357 | &controller_cb, NULL); | 354 | GNUNET_TESTBED_controller_connect (cfg, host, event_mask, &controller_cb, |
355 | NULL); | ||
358 | GNUNET_assert (NULL != controller); | 356 | GNUNET_assert (NULL != controller); |
359 | neighbour = GNUNET_TESTBED_host_create ("localhost", NULL, 0); | 357 | neighbour = GNUNET_TESTBED_host_create ("localhost", NULL, 0); |
360 | GNUNET_assert (NULL != neighbour); | 358 | GNUNET_assert (NULL != neighbour); |
361 | reg_handle = | 359 | reg_handle = |
362 | GNUNET_TESTBED_register_host (controller, neighbour, ®istration_comp, | 360 | GNUNET_TESTBED_register_host (controller, neighbour, ®istration_comp, |
363 | neighbour); | 361 | neighbour); |
364 | GNUNET_assert (NULL != reg_handle); | 362 | GNUNET_assert (NULL != reg_handle); |
365 | } | 363 | } |
366 | 364 | ||
367 | 365 | ||
368 | 366 | ||
369 | /** | 367 | /** |
370 | * Main run function. | 368 | * Main run function. |
371 | * | 369 | * |
372 | * @param cls NULL | 370 | * @param cls NULL |
373 | * @param args arguments passed to GNUNET_PROGRAM_run | 371 | * @param args arguments passed to GNUNET_PROGRAM_run |
@@ -381,30 +379,35 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
381 | host = GNUNET_TESTBED_host_create (NULL, NULL, 0); | 379 | host = GNUNET_TESTBED_host_create (NULL, NULL, 0); |
382 | GNUNET_assert (NULL != host); | 380 | GNUNET_assert (NULL != host); |
383 | cfg = GNUNET_CONFIGURATION_dup (config); | 381 | cfg = GNUNET_CONFIGURATION_dup (config); |
384 | cp = GNUNET_TESTBED_controller_start ("127.0.0.1", host, cfg, status_cb, NULL); | 382 | cp = GNUNET_TESTBED_controller_start ("127.0.0.1", host, cfg, status_cb, |
385 | abort_task = GNUNET_SCHEDULER_add_delayed | 383 | NULL); |
386 | (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5), &do_abort, NULL); | 384 | abort_task = |
385 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | ||
386 | (GNUNET_TIME_UNIT_MINUTES, 5), &do_abort, | ||
387 | NULL); | ||
387 | } | 388 | } |
388 | 389 | ||
389 | 390 | ||
390 | /** | 391 | /** |
391 | * Main function | 392 | * Main function |
392 | */ | 393 | */ |
393 | int main (int argc, char **argv) | 394 | int |
395 | main (int argc, char **argv) | ||
394 | { | 396 | { |
395 | int ret; | 397 | int ret; |
398 | |||
396 | char *const argv2[] = { "test_testbed_api", | 399 | char *const argv2[] = { "test_testbed_api", |
397 | "-c", "test_testbed_api.conf", | 400 | "-c", "test_testbed_api.conf", |
398 | NULL | 401 | NULL |
399 | }; | 402 | }; |
400 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 403 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
401 | GNUNET_GETOPT_OPTION_END | 404 | GNUNET_GETOPT_OPTION_END |
402 | }; | 405 | }; |
403 | 406 | ||
404 | result = GNUNET_SYSERR; | 407 | result = GNUNET_SYSERR; |
405 | ret = GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, | 408 | ret = |
406 | "test_testbed_api", "nohelp", options, &run, | 409 | GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, |
407 | NULL); | 410 | "test_testbed_api", "nohelp", options, &run, NULL); |
408 | if ((GNUNET_OK != ret) || (GNUNET_OK != result)) | 411 | if ((GNUNET_OK != ret) || (GNUNET_OK != result)) |
409 | return 1; | 412 | return 1; |
410 | return 0; | 413 | return 0; |
diff --git a/src/testbed/test_testbed_api_2peers.c b/src/testbed/test_testbed_api_2peers.c index 4c85ce2a3..61b14ffbf 100644 --- a/src/testbed/test_testbed_api_2peers.c +++ b/src/testbed/test_testbed_api_2peers.c | |||
@@ -51,9 +51,9 @@ struct PeerContext | |||
51 | { | 51 | { |
52 | /** | 52 | /** |
53 | * The peer handle | 53 | * The peer handle |
54 | */ | 54 | */ |
55 | struct GNUNET_TESTBED_Peer *peer; | 55 | struct GNUNET_TESTBED_Peer *peer; |
56 | 56 | ||
57 | /** | 57 | /** |
58 | * Operations involving this peer | 58 | * Operations involving this peer |
59 | */ | 59 | */ |
@@ -119,38 +119,38 @@ static GNUNET_SCHEDULER_TaskIdentifier abort_task; | |||
119 | * Different stages in testing | 119 | * Different stages in testing |
120 | */ | 120 | */ |
121 | enum Stage | 121 | enum Stage |
122 | { | 122 | { |
123 | 123 | ||
124 | /** | 124 | /** |
125 | * Initial stage | 125 | * Initial stage |
126 | */ | 126 | */ |
127 | INIT, | 127 | INIT, |
128 | 128 | ||
129 | /** | 129 | /** |
130 | * peers are created | 130 | * peers are created |
131 | */ | 131 | */ |
132 | PEERS_CREATED, | 132 | PEERS_CREATED, |
133 | 133 | ||
134 | /** | 134 | /** |
135 | * peers are started | 135 | * peers are started |
136 | */ | 136 | */ |
137 | PEERS_STARTED, | 137 | PEERS_STARTED, |
138 | 138 | ||
139 | /** | 139 | /** |
140 | * peers are connected | 140 | * peers are connected |
141 | */ | 141 | */ |
142 | PEERS_CONNECTED, | 142 | PEERS_CONNECTED, |
143 | 143 | ||
144 | /** | 144 | /** |
145 | * peers are stopped | 145 | * peers are stopped |
146 | */ | 146 | */ |
147 | PEERS_STOPPED, | 147 | PEERS_STOPPED, |
148 | 148 | ||
149 | /** | 149 | /** |
150 | * Final success stage | 150 | * Final success stage |
151 | */ | 151 | */ |
152 | SUCCESS | 152 | SUCCESS |
153 | }; | 153 | }; |
154 | 154 | ||
155 | /** | 155 | /** |
156 | * The testing result | 156 | * The testing result |
@@ -202,99 +202,98 @@ do_abort (void *cls, const const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
202 | * @param cls closure | 202 | * @param cls closure |
203 | * @param event information about the event | 203 | * @param event information about the event |
204 | */ | 204 | */ |
205 | static void | 205 | static void |
206 | controller_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event) | 206 | controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) |
207 | { | 207 | { |
208 | switch (event->type) | 208 | switch (event->type) |
209 | { | 209 | { |
210 | case GNUNET_TESTBED_ET_OPERATION_FINISHED: /* Will be reached when we destroy peers */ | 210 | case GNUNET_TESTBED_ET_OPERATION_FINISHED: /* Will be reached when we destroy peers */ |
211 | GNUNET_assert (PEERS_STOPPED == result); | 211 | GNUNET_assert (PEERS_STOPPED == result); |
212 | GNUNET_assert (NULL == event->details.operation_finished.op_cls); | 212 | GNUNET_assert (NULL == event->details.operation_finished.op_cls); |
213 | GNUNET_assert (NULL == event->details.operation_finished.emsg); | 213 | GNUNET_assert (NULL == event->details.operation_finished.emsg); |
214 | GNUNET_assert (GNUNET_TESTBED_PIT_GENERIC == | 214 | GNUNET_assert (GNUNET_TESTBED_PIT_GENERIC == |
215 | event->details.operation_finished.pit); | 215 | event->details.operation_finished.pit); |
216 | GNUNET_assert (NULL == | 216 | GNUNET_assert (NULL == event->details.operation_finished.op_result.generic); |
217 | event->details.operation_finished.op_result.generic); | 217 | if (event->details.operation_finished.operation == peer1.operation) |
218 | if (event->details.operation_finished.operation == peer1.operation) | 218 | { |
219 | { | 219 | GNUNET_TESTBED_operation_done (peer1.operation); |
220 | GNUNET_TESTBED_operation_done (peer1.operation); | 220 | peer1.operation = NULL; |
221 | peer1.operation = NULL; | 221 | peer1.peer = NULL; |
222 | peer1.peer = NULL; | 222 | } |
223 | } | 223 | else if (event->details.operation_finished.operation == peer2.operation) |
224 | else if (event->details.operation_finished.operation == peer2.operation) | 224 | { |
225 | { | 225 | GNUNET_TESTBED_operation_done (peer2.operation); |
226 | GNUNET_TESTBED_operation_done (peer2.operation); | 226 | peer2.operation = NULL; |
227 | peer2.operation = NULL; | 227 | peer2.peer = NULL; |
228 | peer2.peer = NULL; | 228 | } |
229 | } | 229 | else |
230 | else | 230 | GNUNET_assert (0); |
231 | GNUNET_assert (0); | 231 | if ((NULL == peer1.peer) && (NULL == peer2.peer)) |
232 | if ((NULL == peer1.peer) && (NULL == peer2.peer)) | 232 | { |
233 | { | 233 | result = SUCCESS; |
234 | result = SUCCESS; | 234 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
235 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 235 | } |
236 | } | 236 | break; |
237 | break; | 237 | case GNUNET_TESTBED_ET_PEER_START: |
238 | case GNUNET_TESTBED_ET_PEER_START: | 238 | GNUNET_assert (INIT == result); |
239 | GNUNET_assert (INIT == result); | 239 | GNUNET_assert (event->details.peer_start.host == host); |
240 | GNUNET_assert (event->details.peer_start.host == host); | 240 | if (event->details.peer_start.peer == peer1.peer) |
241 | if (event->details.peer_start.peer == peer1.peer) | 241 | { |
242 | { | 242 | peer1.is_running = GNUNET_YES; |
243 | peer1.is_running = GNUNET_YES; | 243 | GNUNET_TESTBED_operation_done (peer1.operation); |
244 | GNUNET_TESTBED_operation_done (peer1.operation); | 244 | peer1.operation = NULL; |
245 | peer1.operation = NULL; | 245 | } |
246 | } | 246 | else if (event->details.peer_start.peer == peer2.peer) |
247 | else if (event->details.peer_start.peer == peer2.peer) | 247 | { |
248 | { | 248 | peer2.is_running = GNUNET_YES; |
249 | peer2.is_running = GNUNET_YES; | 249 | GNUNET_TESTBED_operation_done (peer2.operation); |
250 | GNUNET_TESTBED_operation_done (peer2.operation); | 250 | peer2.operation = NULL; |
251 | peer2.operation = NULL; | 251 | } |
252 | } | 252 | else |
253 | else | 253 | GNUNET_assert (0); |
254 | GNUNET_assert (0); | 254 | if ((GNUNET_YES == peer1.is_running) && (GNUNET_YES == peer2.is_running)) |
255 | if ((GNUNET_YES == peer1.is_running) && (GNUNET_YES == peer2.is_running)) | 255 | { |
256 | { | 256 | result = PEERS_STARTED; |
257 | result = PEERS_STARTED; | 257 | common_operation = |
258 | common_operation = | 258 | GNUNET_TESTBED_overlay_connect (NULL, peer1.peer, peer2.peer); |
259 | GNUNET_TESTBED_overlay_connect (NULL, peer1.peer, peer2.peer); | 259 | } |
260 | } | 260 | break; |
261 | break; | 261 | case GNUNET_TESTBED_ET_PEER_STOP: |
262 | case GNUNET_TESTBED_ET_PEER_STOP: | 262 | GNUNET_assert (PEERS_CONNECTED == result); |
263 | GNUNET_assert (PEERS_CONNECTED == result); | 263 | if (event->details.peer_stop.peer == peer1.peer) |
264 | if (event->details.peer_stop.peer == peer1.peer) | 264 | { |
265 | { | 265 | peer1.is_running = GNUNET_NO; |
266 | peer1.is_running = GNUNET_NO; | 266 | GNUNET_TESTBED_operation_done (peer1.operation); |
267 | GNUNET_TESTBED_operation_done (peer1.operation); | 267 | peer1.operation = GNUNET_TESTBED_peer_destroy (peer1.peer); |
268 | peer1.operation = GNUNET_TESTBED_peer_destroy (peer1.peer); | 268 | } |
269 | } | 269 | else if (event->details.peer_stop.peer == peer2.peer) |
270 | else if (event->details.peer_stop.peer == peer2.peer) | 270 | { |
271 | { | 271 | peer2.is_running = GNUNET_NO; |
272 | peer2.is_running = GNUNET_NO; | 272 | GNUNET_TESTBED_operation_done (peer2.operation); |
273 | GNUNET_TESTBED_operation_done (peer2.operation); | 273 | peer2.operation = GNUNET_TESTBED_peer_destroy (peer2.peer); |
274 | peer2.operation = GNUNET_TESTBED_peer_destroy (peer2.peer); | 274 | } |
275 | } | 275 | else |
276 | else | 276 | GNUNET_assert (0); |
277 | GNUNET_assert (0); | 277 | if ((GNUNET_NO == peer1.is_running) && (GNUNET_NO == peer2.is_running)) |
278 | if ((GNUNET_NO == peer1.is_running) && (GNUNET_NO == peer2.is_running)) | 278 | result = PEERS_STOPPED; |
279 | result = PEERS_STOPPED; | 279 | break; |
280 | break; | 280 | case GNUNET_TESTBED_ET_CONNECT: |
281 | case GNUNET_TESTBED_ET_CONNECT: | 281 | GNUNET_assert (PEERS_STARTED == result); |
282 | GNUNET_assert (PEERS_STARTED == result); | 282 | GNUNET_assert (NULL == peer1.operation); |
283 | GNUNET_assert (NULL == peer1.operation); | 283 | GNUNET_assert (NULL == peer2.operation); |
284 | GNUNET_assert (NULL == peer2.operation); | 284 | GNUNET_assert (NULL != common_operation); |
285 | GNUNET_assert (NULL != common_operation); | 285 | GNUNET_assert ((event->details.peer_connect.peer1 == peer1.peer) && |
286 | GNUNET_assert ((event->details.peer_connect.peer1 == peer1.peer) | 286 | (event->details.peer_connect.peer2 == peer2.peer)); |
287 | && (event->details.peer_connect.peer2 == peer2.peer)); | 287 | GNUNET_TESTBED_operation_done (common_operation); |
288 | GNUNET_TESTBED_operation_done (common_operation); | 288 | common_operation = NULL; |
289 | common_operation = NULL; | 289 | result = PEERS_CONNECTED; |
290 | result = PEERS_CONNECTED; | 290 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers connected\n"); |
291 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers connected\n"); | 291 | peer1.operation = GNUNET_TESTBED_peer_stop (peer1.peer); |
292 | peer1.operation = GNUNET_TESTBED_peer_stop (peer1.peer); | 292 | peer2.operation = GNUNET_TESTBED_peer_stop (peer2.peer); |
293 | peer2.operation = GNUNET_TESTBED_peer_stop (peer2.peer); | 293 | break; |
294 | break; | 294 | default: |
295 | default: | 295 | GNUNET_assert (0); |
296 | GNUNET_assert (0); | 296 | }; |
297 | }; | ||
298 | } | 297 | } |
299 | 298 | ||
300 | 299 | ||
@@ -308,8 +307,7 @@ controller_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
308 | * @param emsg NULL if peer is not NULL; else MAY contain the error description | 307 | * @param emsg NULL if peer is not NULL; else MAY contain the error description |
309 | */ | 308 | */ |
310 | static void | 309 | static void |
311 | peer_create_cb (void *cls, | 310 | peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg) |
312 | struct GNUNET_TESTBED_Peer *peer, const char *emsg) | ||
313 | { | 311 | { |
314 | struct PeerContext *pc = cls; | 312 | struct PeerContext *pc = cls; |
315 | 313 | ||
@@ -328,15 +326,17 @@ peer_create_cb (void *cls, | |||
328 | * @param cls the host which has been registered | 326 | * @param cls the host which has been registered |
329 | * @param emsg the error message; NULL if host registration is successful | 327 | * @param emsg the error message; NULL if host registration is successful |
330 | */ | 328 | */ |
331 | static void | 329 | static void |
332 | registration_comp (void *cls, const char *emsg) | 330 | registration_comp (void *cls, const char *emsg) |
333 | { | 331 | { |
334 | GNUNET_assert (cls == neighbour); | 332 | GNUNET_assert (cls == neighbour); |
335 | reg_handle = NULL; | 333 | reg_handle = NULL; |
336 | peer1.operation = GNUNET_TESTBED_peer_create (controller, host, cfg, | 334 | peer1.operation = |
337 | &peer_create_cb, &peer1); | 335 | GNUNET_TESTBED_peer_create (controller, host, cfg, &peer_create_cb, |
338 | peer2.operation = GNUNET_TESTBED_peer_create (controller, host, cfg, | 336 | &peer1); |
339 | &peer_create_cb, &peer2); | 337 | peer2.operation = |
338 | GNUNET_TESTBED_peer_create (controller, host, cfg, &peer_create_cb, | ||
339 | &peer2); | ||
340 | GNUNET_assert (NULL != peer1.operation); | 340 | GNUNET_assert (NULL != peer1.operation); |
341 | GNUNET_assert (NULL != peer2.operation); | 341 | GNUNET_assert (NULL != peer2.operation); |
342 | } | 342 | } |
@@ -351,9 +351,8 @@ registration_comp (void *cls, const char *emsg) | |||
351 | * @param status GNUNET_OK if the startup is successfull; GNUNET_SYSERR if not, | 351 | * @param status GNUNET_OK if the startup is successfull; GNUNET_SYSERR if not, |
352 | * GNUNET_TESTBED_controller_stop() shouldn't be called in this case | 352 | * GNUNET_TESTBED_controller_stop() shouldn't be called in this case |
353 | */ | 353 | */ |
354 | static void | 354 | static void |
355 | status_cb (void *cls, | 355 | status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, int status) |
356 | const struct GNUNET_CONFIGURATION_Handle *cfg, int status) | ||
357 | { | 356 | { |
358 | uint64_t event_mask; | 357 | uint64_t event_mask; |
359 | 358 | ||
@@ -363,21 +362,22 @@ status_cb (void *cls, | |||
363 | event_mask |= (1L << GNUNET_TESTBED_ET_PEER_STOP); | 362 | event_mask |= (1L << GNUNET_TESTBED_ET_PEER_STOP); |
364 | event_mask |= (1L << GNUNET_TESTBED_ET_CONNECT); | 363 | event_mask |= (1L << GNUNET_TESTBED_ET_CONNECT); |
365 | event_mask |= (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED); | 364 | event_mask |= (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED); |
366 | controller = GNUNET_TESTBED_controller_connect (cfg, host, event_mask, | 365 | controller = |
367 | &controller_cb, NULL); | 366 | GNUNET_TESTBED_controller_connect (cfg, host, event_mask, &controller_cb, |
367 | NULL); | ||
368 | GNUNET_assert (NULL != controller); | 368 | GNUNET_assert (NULL != controller); |
369 | neighbour = GNUNET_TESTBED_host_create ("localhost", NULL, 0); | 369 | neighbour = GNUNET_TESTBED_host_create ("localhost", NULL, 0); |
370 | GNUNET_assert (NULL != neighbour); | 370 | GNUNET_assert (NULL != neighbour); |
371 | reg_handle = | 371 | reg_handle = |
372 | GNUNET_TESTBED_register_host (controller, neighbour, ®istration_comp, | 372 | GNUNET_TESTBED_register_host (controller, neighbour, ®istration_comp, |
373 | neighbour); | 373 | neighbour); |
374 | GNUNET_assert (NULL != reg_handle); | 374 | GNUNET_assert (NULL != reg_handle); |
375 | } | 375 | } |
376 | 376 | ||
377 | 377 | ||
378 | 378 | ||
379 | /** | 379 | /** |
380 | * Main run function. | 380 | * Main run function. |
381 | * | 381 | * |
382 | * @param cls NULL | 382 | * @param cls NULL |
383 | * @param args arguments passed to GNUNET_PROGRAM_run | 383 | * @param args arguments passed to GNUNET_PROGRAM_run |
@@ -391,30 +391,35 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
391 | host = GNUNET_TESTBED_host_create (NULL, NULL, 0); | 391 | host = GNUNET_TESTBED_host_create (NULL, NULL, 0); |
392 | GNUNET_assert (NULL != host); | 392 | GNUNET_assert (NULL != host); |
393 | cfg = GNUNET_CONFIGURATION_dup (config); | 393 | cfg = GNUNET_CONFIGURATION_dup (config); |
394 | cp = GNUNET_TESTBED_controller_start ("127.0.0.1", host, cfg, status_cb, NULL); | 394 | cp = GNUNET_TESTBED_controller_start ("127.0.0.1", host, cfg, status_cb, |
395 | abort_task = GNUNET_SCHEDULER_add_delayed | 395 | NULL); |
396 | (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 30), &do_abort, NULL); | 396 | abort_task = |
397 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | ||
398 | (GNUNET_TIME_UNIT_MINUTES, 30), &do_abort, | ||
399 | NULL); | ||
397 | } | 400 | } |
398 | 401 | ||
399 | 402 | ||
400 | /** | 403 | /** |
401 | * Main function | 404 | * Main function |
402 | */ | 405 | */ |
403 | int main (int argc, char **argv) | 406 | int |
407 | main (int argc, char **argv) | ||
404 | { | 408 | { |
405 | int ret; | 409 | int ret; |
406 | 410 | ||
407 | char *const argv2[] = { "test_testbed_api_2peers", | 411 | char *const argv2[] = { "test_testbed_api_2peers", |
408 | "-c", "test_testbed_api.conf", | 412 | "-c", "test_testbed_api.conf", |
409 | NULL | 413 | NULL |
410 | }; | 414 | }; |
411 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 415 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
412 | GNUNET_GETOPT_OPTION_END | 416 | GNUNET_GETOPT_OPTION_END |
413 | }; | 417 | }; |
414 | result = INIT; | 418 | result = INIT; |
415 | ret = GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, | 419 | ret = |
416 | "test_testbed_api_2peers", "nohelp", options, &run, | 420 | GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, |
417 | NULL); | 421 | "test_testbed_api_2peers", "nohelp", options, &run, |
422 | NULL); | ||
418 | if ((GNUNET_OK != ret) || (SUCCESS != result)) | 423 | if ((GNUNET_OK != ret) || (SUCCESS != result)) |
419 | return 1; | 424 | return 1; |
420 | return 0; | 425 | return 0; |
diff --git a/src/testbed/test_testbed_api_controllerlink.c b/src/testbed/test_testbed_api_controllerlink.c index a5f84b6ce..b10e454de 100644 --- a/src/testbed/test_testbed_api_controllerlink.c +++ b/src/testbed/test_testbed_api_controllerlink.c | |||
@@ -21,7 +21,7 @@ | |||
21 | /** | 21 | /** |
22 | * @file testbed/test_testbed_api_controllerlink.c | 22 | * @file testbed/test_testbed_api_controllerlink.c |
23 | * @brief testcase for testing controller to subcontroller linking | 23 | * @brief testcase for testing controller to subcontroller linking |
24 | * @author Sree Harsha Totakura <sreeharsha@totakura.in> | 24 | * @author Sree Harsha Totakura <sreeharsha@totakura.in> |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "platform.h" | 27 | #include "platform.h" |
@@ -45,78 +45,78 @@ | |||
45 | * Different stages in testing | 45 | * Different stages in testing |
46 | */ | 46 | */ |
47 | enum Stage | 47 | enum Stage |
48 | { | 48 | { |
49 | 49 | ||
50 | /** | 50 | /** |
51 | * Initial stage | 51 | * Initial stage |
52 | */ | 52 | */ |
53 | INIT, | 53 | INIT, |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * Master controller has started | 56 | * Master controller has started |
57 | */ | 57 | */ |
58 | MASTER_STARTED, | 58 | MASTER_STARTED, |
59 | 59 | ||
60 | /** | 60 | /** |
61 | * The first slave has been registered at master controller | 61 | * The first slave has been registered at master controller |
62 | */ | 62 | */ |
63 | SLAVE1_REGISTERED, | 63 | SLAVE1_REGISTERED, |
64 | 64 | ||
65 | /** | 65 | /** |
66 | * The second slave has been registered at the master controller | 66 | * The second slave has been registered at the master controller |
67 | */ | 67 | */ |
68 | SLAVE2_REGISTERED, | 68 | SLAVE2_REGISTERED, |
69 | 69 | ||
70 | /** | 70 | /** |
71 | * Link from master to slave 1 has been successfully created | 71 | * Link from master to slave 1 has been successfully created |
72 | */ | 72 | */ |
73 | SLAVE1_LINK_SUCCESS, | 73 | SLAVE1_LINK_SUCCESS, |
74 | 74 | ||
75 | /** | 75 | /** |
76 | * Link from slave 1 to slave 2 has been successfully created. | 76 | * Link from slave 1 to slave 2 has been successfully created. |
77 | */ | 77 | */ |
78 | SLAVE2_LINK_SUCCESS, | 78 | SLAVE2_LINK_SUCCESS, |
79 | 79 | ||
80 | /** | 80 | /** |
81 | * Peer create on slave 1 successful | 81 | * Peer create on slave 1 successful |
82 | */ | 82 | */ |
83 | SLAVE1_PEER_CREATE_SUCCESS, | 83 | SLAVE1_PEER_CREATE_SUCCESS, |
84 | 84 | ||
85 | /** | 85 | /** |
86 | * Peer create on slave 2 successful | 86 | * Peer create on slave 2 successful |
87 | */ | 87 | */ |
88 | SLAVE2_PEER_CREATE_SUCCESS, | 88 | SLAVE2_PEER_CREATE_SUCCESS, |
89 | 89 | ||
90 | /** | 90 | /** |
91 | * Peer startup on slave 1 successful | 91 | * Peer startup on slave 1 successful |
92 | */ | 92 | */ |
93 | SLAVE1_PEER_START_SUCCESS, | 93 | SLAVE1_PEER_START_SUCCESS, |
94 | 94 | ||
95 | /** | 95 | /** |
96 | * Peer on slave 1 successfully stopped | 96 | * Peer on slave 1 successfully stopped |
97 | */ | 97 | */ |
98 | SLAVE1_PEER_STOP_SUCCESS, | 98 | SLAVE1_PEER_STOP_SUCCESS, |
99 | 99 | ||
100 | /** | 100 | /** |
101 | * Peer startup on slave 2 successful | 101 | * Peer startup on slave 2 successful |
102 | */ | 102 | */ |
103 | SLAVE2_PEER_START_SUCCESS, | 103 | SLAVE2_PEER_START_SUCCESS, |
104 | 104 | ||
105 | /** | 105 | /** |
106 | * Peer on slave 2 successfully stopped | 106 | * Peer on slave 2 successfully stopped |
107 | */ | 107 | */ |
108 | SLAVE2_PEER_STOP_SUCCESS, | 108 | SLAVE2_PEER_STOP_SUCCESS, |
109 | 109 | ||
110 | /** | 110 | /** |
111 | * Peer destroy on slave 1 successful | 111 | * Peer destroy on slave 1 successful |
112 | */ | 112 | */ |
113 | SLAVE1_PEER_DESTROY_SUCCESS, | 113 | SLAVE1_PEER_DESTROY_SUCCESS, |
114 | 114 | ||
115 | /** | 115 | /** |
116 | * Peer destory on slave 2 successful; Marks test as successful | 116 | * Peer destory on slave 2 successful; Marks test as successful |
117 | */ | 117 | */ |
118 | SUCCESS | 118 | SUCCESS |
119 | }; | 119 | }; |
120 | 120 | ||
121 | /** | 121 | /** |
122 | * Host for running master controller | 122 | * Host for running master controller |
@@ -197,7 +197,7 @@ do_shutdown (void *cls, const const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
197 | GNUNET_SCHEDULER_cancel (abort_task); | 197 | GNUNET_SCHEDULER_cancel (abort_task); |
198 | if (NULL != slave2) | 198 | if (NULL != slave2) |
199 | GNUNET_TESTBED_host_destroy (slave2); | 199 | GNUNET_TESTBED_host_destroy (slave2); |
200 | if (NULL != slave) | 200 | if (NULL != slave) |
201 | GNUNET_TESTBED_host_destroy (slave); | 201 | GNUNET_TESTBED_host_destroy (slave); |
202 | if (NULL != host) | 202 | if (NULL != host) |
203 | GNUNET_TESTBED_host_destroy (host); | 203 | GNUNET_TESTBED_host_destroy (host); |
@@ -209,7 +209,7 @@ do_shutdown (void *cls, const const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
209 | GNUNET_TESTBED_controller_stop (cp); | 209 | GNUNET_TESTBED_controller_stop (cp); |
210 | if (NULL != rh) | 210 | if (NULL != rh) |
211 | GNUNET_TESTBED_cancel_registration (rh); | 211 | GNUNET_TESTBED_cancel_registration (rh); |
212 | 212 | ||
213 | } | 213 | } |
214 | 214 | ||
215 | 215 | ||
@@ -231,8 +231,8 @@ do_abort (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
231 | /** | 231 | /** |
232 | * Task for inserting delay between tests | 232 | * Task for inserting delay between tests |
233 | * | 233 | * |
234 | * @param | 234 | * @param |
235 | * @return | 235 | * @return |
236 | */ | 236 | */ |
237 | static void | 237 | static void |
238 | delay_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 238 | delay_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
@@ -241,15 +241,15 @@ delay_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
241 | { | 241 | { |
242 | case SLAVE1_PEER_START_SUCCESS: | 242 | case SLAVE1_PEER_START_SUCCESS: |
243 | op = GNUNET_TESTBED_peer_stop (slave1_peer); | 243 | op = GNUNET_TESTBED_peer_stop (slave1_peer); |
244 | GNUNET_assert (NULL != op); | 244 | GNUNET_assert (NULL != op); |
245 | break; | 245 | break; |
246 | case SLAVE2_PEER_START_SUCCESS: | 246 | case SLAVE2_PEER_START_SUCCESS: |
247 | op = GNUNET_TESTBED_peer_stop (slave2_peer); | 247 | op = GNUNET_TESTBED_peer_stop (slave2_peer); |
248 | GNUNET_assert (NULL != op); | 248 | GNUNET_assert (NULL != op); |
249 | break; | 249 | break; |
250 | default: | 250 | default: |
251 | GNUNET_assert (0); | 251 | GNUNET_assert (0); |
252 | } | 252 | } |
253 | } | 253 | } |
254 | 254 | ||
255 | 255 | ||
@@ -262,7 +262,7 @@ delay_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
262 | * creation | 262 | * creation |
263 | * @param emsg NULL if peer is not NULL; else MAY contain the error description | 263 | * @param emsg NULL if peer is not NULL; else MAY contain the error description |
264 | */ | 264 | */ |
265 | static void | 265 | static void |
266 | peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg) | 266 | peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg) |
267 | { | 267 | { |
268 | switch (result) | 268 | switch (result) |
@@ -270,9 +270,9 @@ peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg) | |||
270 | case SLAVE2_LINK_SUCCESS: | 270 | case SLAVE2_LINK_SUCCESS: |
271 | GNUNET_assert (NULL != peer); | 271 | GNUNET_assert (NULL != peer); |
272 | GNUNET_assert (NULL == emsg); | 272 | GNUNET_assert (NULL == emsg); |
273 | result = SLAVE1_PEER_CREATE_SUCCESS; | 273 | result = SLAVE1_PEER_CREATE_SUCCESS; |
274 | slave1_peer = peer; | 274 | slave1_peer = peer; |
275 | GNUNET_TESTBED_operation_done (op); | 275 | GNUNET_TESTBED_operation_done (op); |
276 | op = GNUNET_TESTBED_peer_create (mc, slave2, cfg, peer_create_cb, NULL); | 276 | op = GNUNET_TESTBED_peer_create (mc, slave2, cfg, peer_create_cb, NULL); |
277 | GNUNET_assert (NULL != op); | 277 | GNUNET_assert (NULL != op); |
278 | break; | 278 | break; |
@@ -280,13 +280,13 @@ peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg) | |||
280 | GNUNET_assert (NULL != peer); | 280 | GNUNET_assert (NULL != peer); |
281 | GNUNET_assert (NULL == emsg); | 281 | GNUNET_assert (NULL == emsg); |
282 | result = SLAVE2_PEER_CREATE_SUCCESS; | 282 | result = SLAVE2_PEER_CREATE_SUCCESS; |
283 | slave2_peer = peer; | 283 | slave2_peer = peer; |
284 | GNUNET_TESTBED_operation_done (op); | 284 | GNUNET_TESTBED_operation_done (op); |
285 | op = GNUNET_TESTBED_peer_start (slave1_peer); | 285 | op = GNUNET_TESTBED_peer_start (slave1_peer); |
286 | GNUNET_assert (NULL != op); | 286 | GNUNET_assert (NULL != op); |
287 | break; | 287 | break; |
288 | default: | 288 | default: |
289 | GNUNET_assert (0); | 289 | GNUNET_assert (0); |
290 | } | 290 | } |
291 | } | 291 | } |
292 | 292 | ||
@@ -318,13 +318,13 @@ check_operation_success (const struct GNUNET_TESTBED_EventInformation *event) | |||
318 | * @param cls closure | 318 | * @param cls closure |
319 | * @param event information about the event | 319 | * @param event information about the event |
320 | */ | 320 | */ |
321 | static void | 321 | static void |
322 | controller_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event) | 322 | controller_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) |
323 | { | 323 | { |
324 | switch (result) | 324 | switch (result) |
325 | { | 325 | { |
326 | case SLAVE2_REGISTERED: | 326 | case SLAVE2_REGISTERED: |
327 | check_operation_success (event); | 327 | check_operation_success (event); |
328 | GNUNET_TESTBED_operation_done (op); | 328 | GNUNET_TESTBED_operation_done (op); |
329 | op = NULL; | 329 | op = NULL; |
330 | result = SLAVE1_LINK_SUCCESS; | 330 | result = SLAVE1_LINK_SUCCESS; |
@@ -347,9 +347,9 @@ controller_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
347 | GNUNET_assert (event->details.peer_start.peer == slave1_peer); | 347 | GNUNET_assert (event->details.peer_start.peer == slave1_peer); |
348 | GNUNET_TESTBED_operation_done (op); | 348 | GNUNET_TESTBED_operation_done (op); |
349 | result = SLAVE1_PEER_START_SUCCESS; | 349 | result = SLAVE1_PEER_START_SUCCESS; |
350 | GNUNET_SCHEDULER_add_delayed | 350 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
351 | (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), | 351 | (GNUNET_TIME_UNIT_SECONDS, 1), &delay_task, |
352 | &delay_task, NULL); | 352 | NULL); |
353 | break; | 353 | break; |
354 | case SLAVE1_PEER_START_SUCCESS: | 354 | case SLAVE1_PEER_START_SUCCESS: |
355 | GNUNET_assert (GNUNET_TESTBED_ET_PEER_STOP == event->type); | 355 | GNUNET_assert (GNUNET_TESTBED_ET_PEER_STOP == event->type); |
@@ -357,7 +357,7 @@ controller_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
357 | GNUNET_TESTBED_operation_done (op); | 357 | GNUNET_TESTBED_operation_done (op); |
358 | result = SLAVE1_PEER_STOP_SUCCESS; | 358 | result = SLAVE1_PEER_STOP_SUCCESS; |
359 | op = GNUNET_TESTBED_peer_start (slave2_peer); | 359 | op = GNUNET_TESTBED_peer_start (slave2_peer); |
360 | GNUNET_assert (NULL != op); | 360 | GNUNET_assert (NULL != op); |
361 | break; | 361 | break; |
362 | case SLAVE1_PEER_STOP_SUCCESS: | 362 | case SLAVE1_PEER_STOP_SUCCESS: |
363 | GNUNET_assert (GNUNET_TESTBED_ET_PEER_START == event->type); | 363 | GNUNET_assert (GNUNET_TESTBED_ET_PEER_START == event->type); |
@@ -365,9 +365,9 @@ controller_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
365 | GNUNET_assert (event->details.peer_start.peer == slave2_peer); | 365 | GNUNET_assert (event->details.peer_start.peer == slave2_peer); |
366 | GNUNET_TESTBED_operation_done (op); | 366 | GNUNET_TESTBED_operation_done (op); |
367 | result = SLAVE2_PEER_START_SUCCESS; | 367 | result = SLAVE2_PEER_START_SUCCESS; |
368 | GNUNET_SCHEDULER_add_delayed | 368 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
369 | (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1), | 369 | (GNUNET_TIME_UNIT_SECONDS, 1), &delay_task, |
370 | &delay_task, NULL); | 370 | NULL); |
371 | break; | 371 | break; |
372 | case SLAVE2_PEER_START_SUCCESS: | 372 | case SLAVE2_PEER_START_SUCCESS: |
373 | GNUNET_assert (GNUNET_TESTBED_ET_PEER_STOP == event->type); | 373 | GNUNET_assert (GNUNET_TESTBED_ET_PEER_STOP == event->type); |
@@ -389,7 +389,7 @@ controller_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
389 | GNUNET_TESTBED_operation_done (op); | 389 | GNUNET_TESTBED_operation_done (op); |
390 | result = SUCCESS; | 390 | result = SUCCESS; |
391 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); | 391 | GNUNET_SCHEDULER_add_now (&do_shutdown, NULL); |
392 | break; | 392 | break; |
393 | default: | 393 | default: |
394 | GNUNET_assert (0); | 394 | GNUNET_assert (0); |
395 | } | 395 | } |
@@ -402,7 +402,7 @@ controller_cb(void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
402 | * @param cls the host which has been registered | 402 | * @param cls the host which has been registered |
403 | * @param emsg the error message; NULL if host registration is successful | 403 | * @param emsg the error message; NULL if host registration is successful |
404 | */ | 404 | */ |
405 | static void | 405 | static void |
406 | registration_cont (void *cls, const char *emsg) | 406 | registration_cont (void *cls, const char *emsg) |
407 | { | 407 | { |
408 | rh = NULL; | 408 | rh = NULL; |
@@ -439,9 +439,9 @@ registration_cont (void *cls, const char *emsg) | |||
439 | * @param status GNUNET_OK if the startup is successfull; GNUNET_SYSERR if not, | 439 | * @param status GNUNET_OK if the startup is successfull; GNUNET_SYSERR if not, |
440 | * GNUNET_TESTBED_controller_stop() shouldn't be called in this case | 440 | * GNUNET_TESTBED_controller_stop() shouldn't be called in this case |
441 | */ | 441 | */ |
442 | static void | 442 | static void |
443 | status_cb (void *cls, | 443 | status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *config, |
444 | const struct GNUNET_CONFIGURATION_Handle *config, int status) | 444 | int status) |
445 | { | 445 | { |
446 | switch (result) | 446 | switch (result) |
447 | { | 447 | { |
@@ -453,7 +453,7 @@ status_cb (void *cls, | |||
453 | event_mask |= (1L << GNUNET_TESTBED_ET_CONNECT); | 453 | event_mask |= (1L << GNUNET_TESTBED_ET_CONNECT); |
454 | event_mask |= (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED); | 454 | event_mask |= (1L << GNUNET_TESTBED_ET_OPERATION_FINISHED); |
455 | mc = GNUNET_TESTBED_controller_connect (config, host, event_mask, | 455 | mc = GNUNET_TESTBED_controller_connect (config, host, event_mask, |
456 | &controller_cb, NULL); | 456 | &controller_cb, NULL); |
457 | GNUNET_assert (NULL != mc); | 457 | GNUNET_assert (NULL != mc); |
458 | result = MASTER_STARTED; | 458 | result = MASTER_STARTED; |
459 | slave = GNUNET_TESTBED_host_create_with_id (1, "127.0.0.1", NULL, 0); | 459 | slave = GNUNET_TESTBED_host_create_with_id (1, "127.0.0.1", NULL, 0); |
@@ -468,7 +468,7 @@ status_cb (void *cls, | |||
468 | 468 | ||
469 | 469 | ||
470 | /** | 470 | /** |
471 | * Main run function. | 471 | * Main run function. |
472 | * | 472 | * |
473 | * @param cls NULL | 473 | * @param cls NULL |
474 | * @param args arguments passed to GNUNET_PROGRAM_run | 474 | * @param args arguments passed to GNUNET_PROGRAM_run |
@@ -482,23 +482,26 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
482 | host = GNUNET_TESTBED_host_create (NULL, NULL, 0); | 482 | host = GNUNET_TESTBED_host_create (NULL, NULL, 0); |
483 | GNUNET_assert (NULL != host); | 483 | GNUNET_assert (NULL != host); |
484 | cfg = GNUNET_CONFIGURATION_dup (config); | 484 | cfg = GNUNET_CONFIGURATION_dup (config); |
485 | cp = | 485 | cp = GNUNET_TESTBED_controller_start ("127.0.0.1", host, cfg, status_cb, |
486 | GNUNET_TESTBED_controller_start ("127.0.0.1", host, cfg, status_cb, NULL); | 486 | NULL); |
487 | abort_task = GNUNET_SCHEDULER_add_delayed | 487 | abort_task = |
488 | (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5), | 488 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
489 | &do_abort, NULL); | 489 | (GNUNET_TIME_UNIT_MINUTES, 5), &do_abort, |
490 | NULL); | ||
490 | } | 491 | } |
491 | 492 | ||
492 | 493 | ||
493 | /** | 494 | /** |
494 | * Main function | 495 | * Main function |
495 | */ | 496 | */ |
496 | int main (int argc, char **argv) | 497 | int |
498 | main (int argc, char **argv) | ||
497 | { | 499 | { |
498 | int ret; | 500 | int ret; |
501 | |||
499 | char *const argv2[] = { "test_testbed_api_controllerlink", | 502 | char *const argv2[] = { "test_testbed_api_controllerlink", |
500 | "-c", "test_testbed_api.conf", | 503 | "-c", "test_testbed_api.conf", |
501 | NULL | 504 | NULL |
502 | }; | 505 | }; |
503 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 506 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
504 | GNUNET_GETOPT_OPTION_END | 507 | GNUNET_GETOPT_OPTION_END |
@@ -509,28 +512,31 @@ int main (int argc, char **argv) | |||
509 | struct GNUNET_OS_Process *auxp; | 512 | struct GNUNET_OS_Process *auxp; |
510 | enum GNUNET_OS_ProcessStatusType type; | 513 | enum GNUNET_OS_ProcessStatusType type; |
511 | unsigned long code; | 514 | unsigned long code; |
512 | 515 | ||
513 | auxp = GNUNET_OS_start_process_vap (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, | 516 | auxp = |
514 | NULL, NULL, "ssh", remote_args); | 517 | GNUNET_OS_start_process_vap (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, NULL, |
518 | NULL, "ssh", remote_args); | ||
515 | GNUNET_assert (NULL != auxp); | 519 | GNUNET_assert (NULL != auxp); |
516 | do | 520 | do |
517 | { | 521 | { |
518 | ret = GNUNET_OS_process_status (auxp, &type, &code); | 522 | ret = GNUNET_OS_process_status (auxp, &type, &code); |
519 | GNUNET_assert (GNUNET_SYSERR != ret); | 523 | GNUNET_assert (GNUNET_SYSERR != ret); |
520 | (void) usleep (300); | 524 | (void) usleep (300); |
521 | } while (GNUNET_NO == ret); | 525 | } |
522 | GNUNET_OS_process_destroy (auxp); | 526 | while (GNUNET_NO == ret); |
527 | GNUNET_OS_process_destroy (auxp); | ||
523 | if (0 != code) | 528 | if (0 != code) |
524 | { | 529 | { |
525 | (void) printf ("Unable to run the test as this system is not configured " | 530 | (void) printf ("Unable to run the test as this system is not configured " |
526 | "to use password less SSH logins to localhost.\n" | 531 | "to use password less SSH logins to localhost.\n" |
527 | "Marking test as successful\n"); | 532 | "Marking test as successful\n"); |
528 | return 0; | 533 | return 0; |
529 | } | 534 | } |
530 | result = INIT; | 535 | result = INIT; |
531 | ret = GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, | 536 | ret = |
532 | "test_testbed_api_controllerlink", "nohelp", options, &run, | 537 | GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, |
533 | NULL); | 538 | "test_testbed_api_controllerlink", "nohelp", options, |
539 | &run, NULL); | ||
534 | if ((GNUNET_OK != ret) || (SUCCESS != result)) | 540 | if ((GNUNET_OK != ret) || (SUCCESS != result)) |
535 | return 1; | 541 | return 1; |
536 | return 0; | 542 | return 0; |
diff --git a/src/testbed/test_testbed_api_hosts.c b/src/testbed/test_testbed_api_hosts.c index ae71abc54..d870ef4c4 100644 --- a/src/testbed/test_testbed_api_hosts.c +++ b/src/testbed/test_testbed_api_hosts.c | |||
@@ -62,7 +62,7 @@ do_shutdown (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
62 | 62 | ||
63 | 63 | ||
64 | /** | 64 | /** |
65 | * Main run function. | 65 | * Main run function. |
66 | * | 66 | * |
67 | * @param cls NULL | 67 | * @param cls NULL |
68 | * @param args arguments passed to GNUNET_PROGRAM_run | 68 | * @param args arguments passed to GNUNET_PROGRAM_run |
@@ -81,26 +81,27 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
81 | GNUNET_assert (NULL != host); | 81 | GNUNET_assert (NULL != host); |
82 | GNUNET_assert (0 == GNUNET_TESTBED_host_get_id_ (host)); | 82 | GNUNET_assert (0 == GNUNET_TESTBED_host_get_id_ (host)); |
83 | GNUNET_assert (host == GNUNET_TESTBED_host_lookup_by_id_ (0)); | 83 | GNUNET_assert (host == GNUNET_TESTBED_host_lookup_by_id_ (0)); |
84 | shutdown_id = | 84 | shutdown_id = |
85 | GNUNET_SCHEDULER_add_delayed (TIME_REL_SECS (2), &do_shutdown, NULL); | 85 | GNUNET_SCHEDULER_add_delayed (TIME_REL_SECS (2), &do_shutdown, NULL); |
86 | } | 86 | } |
87 | 87 | ||
88 | 88 | ||
89 | int main (int argc, char **argv) | 89 | int |
90 | main (int argc, char **argv) | ||
90 | { | 91 | { |
91 | char *const argv2[] = { "test_testbed_api_hosts", | 92 | char *const argv2[] = { "test_testbed_api_hosts", |
92 | "-c", "test_testbed_api.conf", | 93 | "-c", "test_testbed_api.conf", |
93 | NULL | 94 | NULL |
94 | }; | 95 | }; |
95 | struct GNUNET_GETOPT_CommandLineOption options[] = { | 96 | struct GNUNET_GETOPT_CommandLineOption options[] = { |
96 | GNUNET_GETOPT_OPTION_END | 97 | GNUNET_GETOPT_OPTION_END |
97 | }; | 98 | }; |
98 | 99 | ||
99 | status = GNUNET_YES; | 100 | status = GNUNET_YES; |
100 | if (GNUNET_OK != | 101 | if (GNUNET_OK != |
101 | GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, | 102 | GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, |
102 | "test_testbed_api_hosts", "nohelp", | 103 | "test_testbed_api_hosts", "nohelp", options, &run, |
103 | options, &run, NULL)) | 104 | NULL)) |
104 | return 1; | 105 | return 1; |
105 | return (GNUNET_OK == status) ? 0 : 1; | 106 | return (GNUNET_OK == status) ? 0 : 1; |
106 | } | 107 | } |
diff --git a/src/testbed/test_testbed_api_operations.c b/src/testbed/test_testbed_api_operations.c index f72b6f0e5..eea919705 100644 --- a/src/testbed/test_testbed_api_operations.c +++ b/src/testbed/test_testbed_api_operations.c | |||
@@ -59,33 +59,32 @@ struct GNUNET_TESTBED_Operation *op2; | |||
59 | * Enumeration of test stages | 59 | * Enumeration of test stages |
60 | */ | 60 | */ |
61 | enum Test | 61 | enum Test |
62 | { | 62 | { |
63 | /** | 63 | /** |
64 | * Initial stage | 64 | * Initial stage |
65 | */ | 65 | */ |
66 | TEST_INIT, | 66 | TEST_INIT, |
67 | 67 | ||
68 | /** | 68 | /** |
69 | * op1 has been started | 69 | * op1 has been started |
70 | */ | 70 | */ |
71 | TEST_OP1_STARTED, | 71 | TEST_OP1_STARTED, |
72 | 72 | ||
73 | /** | 73 | /** |
74 | * op1 has been released | 74 | * op1 has been released |
75 | */ | 75 | */ |
76 | TEST_OP1_RELEASED, | 76 | TEST_OP1_RELEASED, |
77 | 77 | ||
78 | /** | 78 | /** |
79 | * op2 has started | 79 | * op2 has started |
80 | */ | 80 | */ |
81 | TEST_OP2_STARTED, | 81 | TEST_OP2_STARTED, |
82 | 82 | ||
83 | /** | 83 | /** |
84 | * op2 released | 84 | * op2 released |
85 | */ | 85 | */ |
86 | TEST_OP2_RELEASED | 86 | TEST_OP2_RELEASED |
87 | 87 | }; | |
88 | }; | ||
89 | 88 | ||
90 | /** | 89 | /** |
91 | * The test result | 90 | * The test result |
@@ -151,7 +150,7 @@ start_cb (void *cls) | |||
151 | * a callback to the 'OperationStart' preceeds the call to | 150 | * a callback to the 'OperationStart' preceeds the call to |
152 | * 'OperationRelease'. Implementations of this function are expected | 151 | * 'OperationRelease'. Implementations of this function are expected |
153 | * to clean up whatever state is in 'cls' and release all resources | 152 | * to clean up whatever state is in 'cls' and release all resources |
154 | * associated with the operation. | 153 | * associated with the operation. |
155 | */ | 154 | */ |
156 | static void | 155 | static void |
157 | release_cb (void *cls) | 156 | release_cb (void *cls) |
@@ -175,7 +174,7 @@ release_cb (void *cls) | |||
175 | 174 | ||
176 | 175 | ||
177 | /** | 176 | /** |
178 | * Main run function. | 177 | * Main run function. |
179 | * | 178 | * |
180 | * @param cls NULL | 179 | * @param cls NULL |
181 | * @param args arguments passed to GNUNET_PROGRAM_run | 180 | * @param args arguments passed to GNUNET_PROGRAM_run |
@@ -190,7 +189,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
190 | GNUNET_assert (NULL != q1); | 189 | GNUNET_assert (NULL != q1); |
191 | q2 = GNUNET_TESTBED_operation_queue_create_ (2); | 190 | q2 = GNUNET_TESTBED_operation_queue_create_ (2); |
192 | GNUNET_assert (NULL != q2); | 191 | GNUNET_assert (NULL != q2); |
193 | op1 = GNUNET_TESTBED_operation_create_ (&op1, start_cb, release_cb); | 192 | op1 = GNUNET_TESTBED_operation_create_ (&op1, start_cb, release_cb); |
194 | GNUNET_assert (NULL != op1); | 193 | GNUNET_assert (NULL != op1); |
195 | op2 = GNUNET_TESTBED_operation_create_ (&op2, start_cb, release_cb); | 194 | op2 = GNUNET_TESTBED_operation_create_ (&op2, start_cb, release_cb); |
196 | GNUNET_TESTBED_operation_queue_insert_ (q1, op1); | 195 | GNUNET_TESTBED_operation_queue_insert_ (q1, op1); |
@@ -203,17 +202,19 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
203 | /** | 202 | /** |
204 | * Main function | 203 | * Main function |
205 | */ | 204 | */ |
206 | int main (int argc, char **argv) | 205 | int |
206 | main (int argc, char **argv) | ||
207 | { | 207 | { |
208 | int ret; | 208 | int ret; |
209 | char *const argv2[] = | 209 | char *const argv2[] = |
210 | {"test_testbed_api_operations", "-c", "test_testbed_api.conf", NULL}; | 210 | { "test_testbed_api_operations", "-c", "test_testbed_api.conf", NULL }; |
211 | struct GNUNET_GETOPT_CommandLineOption options[] = | 211 | struct GNUNET_GETOPT_CommandLineOption options[] = |
212 | {GNUNET_GETOPT_OPTION_END}; | 212 | { GNUNET_GETOPT_OPTION_END }; |
213 | 213 | ||
214 | ret = GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, | 214 | ret = |
215 | "test_testbed_api_operations", "nohelp", options, | 215 | GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, |
216 | &run, NULL); | 216 | "test_testbed_api_operations", "nohelp", options, |
217 | &run, NULL); | ||
217 | if ((GNUNET_OK != ret) || (TEST_OP2_RELEASED != result)) | 218 | if ((GNUNET_OK != ret) || (TEST_OP2_RELEASED != result)) |
218 | return 1; | 219 | return 1; |
219 | op1 = NULL; | 220 | op1 = NULL; |
diff --git a/src/testbed/test_testbed_api_testbed_run.c b/src/testbed/test_testbed_api_testbed_run.c index 31b633032..a9a2a8192 100644 --- a/src/testbed/test_testbed_api_testbed_run.c +++ b/src/testbed/test_testbed_api_testbed_run.c | |||
@@ -21,7 +21,7 @@ | |||
21 | /** | 21 | /** |
22 | * @file testbed/test_testbed_api_testbed_run.c | 22 | * @file testbed/test_testbed_api_testbed_run.c |
23 | * @brief Test cases for testing high-level testbed management | 23 | * @brief Test cases for testing high-level testbed management |
24 | * @author Sree Harsha Totakura <sreeharsha@totakura.in> | 24 | * @author Sree Harsha Totakura <sreeharsha@totakura.in> |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include "platform.h" | 27 | #include "platform.h" |
@@ -110,7 +110,7 @@ static void | |||
110 | controller_event_cb (void *cls, | 110 | controller_event_cb (void *cls, |
111 | const struct GNUNET_TESTBED_EventInformation *event) | 111 | const struct GNUNET_TESTBED_EventInformation *event) |
112 | { | 112 | { |
113 | 113 | ||
114 | switch (event->type) | 114 | switch (event->type) |
115 | { | 115 | { |
116 | case GNUNET_TESTBED_ET_PEER_START: | 116 | case GNUNET_TESTBED_ET_PEER_START: |
@@ -125,7 +125,7 @@ controller_event_cb (void *cls, | |||
125 | 125 | ||
126 | 126 | ||
127 | /** | 127 | /** |
128 | * Main run function. | 128 | * Main run function. |
129 | * | 129 | * |
130 | * @param cls NULL | 130 | * @param cls NULL |
131 | * @param args arguments passed to GNUNET_PROGRAM_run | 131 | * @param args arguments passed to GNUNET_PROGRAM_run |
@@ -137,7 +137,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
137 | const struct GNUNET_CONFIGURATION_Handle *config) | 137 | const struct GNUNET_CONFIGURATION_Handle *config) |
138 | { | 138 | { |
139 | uint64_t event_mask; | 139 | uint64_t event_mask; |
140 | 140 | ||
141 | event_mask = 0; | 141 | event_mask = 0; |
142 | event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START); | 142 | event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START); |
143 | event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_STOP); | 143 | event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_STOP); |
@@ -146,18 +146,22 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
146 | event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED); | 146 | event_mask |= (1LL << GNUNET_TESTBED_ET_OPERATION_FINISHED); |
147 | GNUNET_TESTBED_run (NULL, config, NUM_PEERS, event_mask, &controller_event_cb, | 147 | GNUNET_TESTBED_run (NULL, config, NUM_PEERS, event_mask, &controller_event_cb, |
148 | NULL, &master_task, NULL); | 148 | NULL, &master_task, NULL); |
149 | abort_task = GNUNET_SCHEDULER_add_delayed | 149 | abort_task = |
150 | (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5), &do_abort, NULL); | 150 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
151 | (GNUNET_TIME_UNIT_SECONDS, 5), &do_abort, | ||
152 | NULL); | ||
151 | } | 153 | } |
152 | 154 | ||
153 | 155 | ||
154 | /** | 156 | /** |
155 | * Main function | 157 | * Main function |
156 | */ | 158 | */ |
157 | int main (int argc, char **argv) | 159 | int |
160 | main (int argc, char **argv) | ||
158 | { | 161 | { |
159 | int ret; | 162 | int ret; |
160 | char *const argv2[] = { | 163 | |
164 | char *const argv2[] = { | ||
161 | "test_testbed_api_testbed_run", | 165 | "test_testbed_api_testbed_run", |
162 | "-c", "test_testbed_api.conf", | 166 | "-c", "test_testbed_api.conf", |
163 | NULL | 167 | NULL |
@@ -167,9 +171,10 @@ int main (int argc, char **argv) | |||
167 | }; | 171 | }; |
168 | 172 | ||
169 | result = GNUNET_SYSERR; | 173 | result = GNUNET_SYSERR; |
170 | ret = GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, | 174 | ret = |
171 | "test_testbed_api_testbed_run", "nohelp", options, | 175 | GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, |
172 | &run, NULL); | 176 | "test_testbed_api_testbed_run", "nohelp", options, |
177 | &run, NULL); | ||
173 | if ((GNUNET_OK != ret) || (GNUNET_OK != result)) | 178 | if ((GNUNET_OK != ret) || (GNUNET_OK != result)) |
174 | return 1; | 179 | return 1; |
175 | return 0; | 180 | return 0; |
diff --git a/src/testbed/testbed.h b/src/testbed/testbed.h index c7848135d..caeed6e08 100644 --- a/src/testbed/testbed.h +++ b/src/testbed/testbed.h | |||
@@ -44,7 +44,7 @@ struct GNUNET_TESTBED_InitMessage | |||
44 | /** | 44 | /** |
45 | * Host ID that the controller is either given (if this is the | 45 | * Host ID that the controller is either given (if this is the |
46 | * dominating client) or assumed to have (for peer-connections | 46 | * dominating client) or assumed to have (for peer-connections |
47 | * between controllers). A controller must check that all | 47 | * between controllers). A controller must check that all |
48 | * connections make consistent claims... | 48 | * connections make consistent claims... |
49 | */ | 49 | */ |
50 | uint32_t host_id GNUNET_PACKED; | 50 | uint32_t host_id GNUNET_PACKED; |
@@ -112,9 +112,9 @@ struct GNUNET_TESTBED_HostConfirmedMessage | |||
112 | */ | 112 | */ |
113 | uint32_t host_id GNUNET_PACKED; | 113 | uint32_t host_id GNUNET_PACKED; |
114 | 114 | ||
115 | /* followed by the 0-terminated error message (on failure) | 115 | /* followed by the 0-terminated error message (on failure) |
116 | (typical errors include failure to login and | 116 | * (typical errors include failure to login and |
117 | host-id already in use) */ | 117 | * host-id already in use) */ |
118 | 118 | ||
119 | }; | 119 | }; |
120 | 120 | ||
@@ -187,13 +187,13 @@ struct GNUNET_TESTBED_ControllerLinkMessage | |||
187 | uint8_t is_subordinate; | 187 | uint8_t is_subordinate; |
188 | 188 | ||
189 | /* followed by serialized slave configuration; | 189 | /* followed by serialized slave configuration; |
190 | gzip'ed configuration file in INI format */ | 190 | * gzip'ed configuration file in INI format */ |
191 | 191 | ||
192 | }; | 192 | }; |
193 | 193 | ||
194 | 194 | ||
195 | /** | 195 | /** |
196 | * Message sent from client to testing service to | 196 | * Message sent from client to testing service to |
197 | * create (configure, but not start) a peer. | 197 | * create (configure, but not start) a peer. |
198 | */ | 198 | */ |
199 | struct GNUNET_TESTBED_PeerCreateMessage | 199 | struct GNUNET_TESTBED_PeerCreateMessage |
@@ -225,13 +225,13 @@ struct GNUNET_TESTBED_PeerCreateMessage | |||
225 | uint32_t config_size GNUNET_PACKED; | 225 | uint32_t config_size GNUNET_PACKED; |
226 | 226 | ||
227 | /* followed by serialized peer configuration; | 227 | /* followed by serialized peer configuration; |
228 | gzip'ed configuration file in INI format */ | 228 | * gzip'ed configuration file in INI format */ |
229 | 229 | ||
230 | }; | 230 | }; |
231 | 231 | ||
232 | 232 | ||
233 | /** | 233 | /** |
234 | * Message sent from client to testing service to | 234 | * Message sent from client to testing service to |
235 | * reconfigure a (stopped) a peer. | 235 | * reconfigure a (stopped) a peer. |
236 | */ | 236 | */ |
237 | struct GNUNET_TESTBED_PeerReconfigureMessage | 237 | struct GNUNET_TESTBED_PeerReconfigureMessage |
@@ -253,8 +253,8 @@ struct GNUNET_TESTBED_PeerReconfigureMessage | |||
253 | uint64_t operation_id GNUNET_PACKED; | 253 | uint64_t operation_id GNUNET_PACKED; |
254 | 254 | ||
255 | /* followed by serialized peer configuration; | 255 | /* followed by serialized peer configuration; |
256 | gzip'ed configuration file in INI format */ | 256 | * gzip'ed configuration file in INI format */ |
257 | 257 | ||
258 | }; | 258 | }; |
259 | 259 | ||
260 | 260 | ||
@@ -416,7 +416,7 @@ struct GNUNET_TESTBED_PeerEventMessage | |||
416 | * either GNUNET_TESTBED_ET_PEER_START or GNUNET_TESTBED_ET_PEER_STOP. | 416 | * either GNUNET_TESTBED_ET_PEER_START or GNUNET_TESTBED_ET_PEER_STOP. |
417 | */ | 417 | */ |
418 | int32_t event_type GNUNET_PACKED; | 418 | int32_t event_type GNUNET_PACKED; |
419 | 419 | ||
420 | /** | 420 | /** |
421 | * Host where the peer is running. | 421 | * Host where the peer is running. |
422 | */ | 422 | */ |
@@ -451,7 +451,7 @@ struct GNUNET_TESTBED_ConnectionEventMessage | |||
451 | * either GNUNET_TESTBED_ET_CONNECT or GNUNET_TESTBED_ET_DISCONNECT. | 451 | * either GNUNET_TESTBED_ET_CONNECT or GNUNET_TESTBED_ET_DISCONNECT. |
452 | */ | 452 | */ |
453 | int32_t event_type GNUNET_PACKED; | 453 | int32_t event_type GNUNET_PACKED; |
454 | 454 | ||
455 | /** | 455 | /** |
456 | * First peer. | 456 | * First peer. |
457 | */ | 457 | */ |
@@ -486,7 +486,7 @@ struct GNUNET_TESTBED_OperationFailureEventMessage | |||
486 | * GNUNET_TESTBED_ET_OPERATION_FINISHED. | 486 | * GNUNET_TESTBED_ET_OPERATION_FINISHED. |
487 | */ | 487 | */ |
488 | int32_t event_type GNUNET_PACKED; | 488 | int32_t event_type GNUNET_PACKED; |
489 | 489 | ||
490 | /** | 490 | /** |
491 | * Operation ID of the operation that created this event. | 491 | * Operation ID of the operation that created this event. |
492 | */ | 492 | */ |
@@ -512,7 +512,7 @@ struct GNUNET_TESTBED_PeerCreateSuccessEventMessage | |||
512 | * Peer identity of the peer that was created. | 512 | * Peer identity of the peer that was created. |
513 | */ | 513 | */ |
514 | uint32_t peer_id GNUNET_PACKED; | 514 | uint32_t peer_id GNUNET_PACKED; |
515 | 515 | ||
516 | /** | 516 | /** |
517 | * Operation ID of the operation that created this event. | 517 | * Operation ID of the operation that created this event. |
518 | */ | 518 | */ |
@@ -539,7 +539,7 @@ struct GNUNET_TESTBED_GenericOperationSuccessEventMessage | |||
539 | * GNUNET_TESTBED_ET_OPERATION_FINISHED. | 539 | * GNUNET_TESTBED_ET_OPERATION_FINISHED. |
540 | */ | 540 | */ |
541 | int32_t event_type GNUNET_PACKED; | 541 | int32_t event_type GNUNET_PACKED; |
542 | 542 | ||
543 | /** | 543 | /** |
544 | * Operation ID of the operation that created this event. | 544 | * Operation ID of the operation that created this event. |
545 | */ | 545 | */ |
@@ -551,7 +551,7 @@ struct GNUNET_TESTBED_GenericOperationSuccessEventMessage | |||
551 | 551 | ||
552 | 552 | ||
553 | /** | 553 | /** |
554 | * Message sent from client to testing service to | 554 | * Message sent from client to testing service to |
555 | * obtain the configuration of a peer. | 555 | * obtain the configuration of a peer. |
556 | */ | 556 | */ |
557 | struct GNUNET_TESTBED_PeerGetConfigurationMessage | 557 | struct GNUNET_TESTBED_PeerGetConfigurationMessage |
@@ -591,7 +591,7 @@ struct GNUNET_TESTBED_PeerConfigurationInformationMessage | |||
591 | * The id of the peer relevant to this information | 591 | * The id of the peer relevant to this information |
592 | */ | 592 | */ |
593 | uint32_t peer_id GNUNET_PACKED; | 593 | uint32_t peer_id GNUNET_PACKED; |
594 | 594 | ||
595 | /** | 595 | /** |
596 | * Operation ID of the operation that created this event. | 596 | * Operation ID of the operation that created this event. |
597 | */ | 597 | */ |
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c index 87a6aa45f..ecc897205 100644 --- a/src/testbed/testbed_api.c +++ b/src/testbed/testbed_api.c | |||
@@ -81,7 +81,7 @@ struct MessageQueue | |||
81 | * next pointer for DLL | 81 | * next pointer for DLL |
82 | */ | 82 | */ |
83 | struct MessageQueue *next; | 83 | struct MessageQueue *next; |
84 | 84 | ||
85 | /** | 85 | /** |
86 | * prev pointer for DLL | 86 | * prev pointer for DLL |
87 | */ | 87 | */ |
@@ -160,17 +160,17 @@ struct GNUNET_TESTBED_HostRegistrationHandle | |||
160 | */ | 160 | */ |
161 | struct ForwardedOperationData | 161 | struct ForwardedOperationData |
162 | { | 162 | { |
163 | 163 | ||
164 | /** | 164 | /** |
165 | * The callback to call when reply is available | 165 | * The callback to call when reply is available |
166 | */ | 166 | */ |
167 | GNUNET_CLIENT_MessageHandler cc; | 167 | GNUNET_CLIENT_MessageHandler cc; |
168 | 168 | ||
169 | /** | 169 | /** |
170 | * The closure for the above callback | 170 | * The closure for the above callback |
171 | */ | 171 | */ |
172 | void *cc_cls; | 172 | void *cc_cls; |
173 | 173 | ||
174 | }; | 174 | }; |
175 | 175 | ||
176 | 176 | ||
@@ -215,8 +215,8 @@ handle_addhostconfirm (struct GNUNET_TESTBED_Controller *c, | |||
215 | 215 | ||
216 | rh = c->rh; | 216 | rh = c->rh; |
217 | if (NULL == rh) | 217 | if (NULL == rh) |
218 | { | 218 | { |
219 | return GNUNET_OK; | 219 | return GNUNET_OK; |
220 | } | 220 | } |
221 | if (GNUNET_TESTBED_host_get_id_ (rh->host) != ntohl (msg->host_id)) | 221 | if (GNUNET_TESTBED_host_get_id_ (rh->host) != ntohl (msg->host_id)) |
222 | { | 222 | { |
@@ -229,20 +229,20 @@ handle_addhostconfirm (struct GNUNET_TESTBED_Controller *c, | |||
229 | if (sizeof (struct GNUNET_TESTBED_HostConfirmedMessage) == msg_size) | 229 | if (sizeof (struct GNUNET_TESTBED_HostConfirmedMessage) == msg_size) |
230 | { | 230 | { |
231 | LOG_DEBUG ("Host %u successfully registered\n", ntohl (msg->host_id)); | 231 | LOG_DEBUG ("Host %u successfully registered\n", ntohl (msg->host_id)); |
232 | GNUNET_TESTBED_mark_host_registered_at_ (rh->host, c); | 232 | GNUNET_TESTBED_mark_host_registered_at_ (rh->host, c); |
233 | rh->cc (rh->cc_cls, NULL); | 233 | rh->cc (rh->cc_cls, NULL); |
234 | GNUNET_free (rh); | 234 | GNUNET_free (rh); |
235 | return GNUNET_OK; | 235 | return GNUNET_OK; |
236 | } | 236 | } |
237 | /* We have an error message */ | 237 | /* We have an error message */ |
238 | emsg = (char *) &msg[1]; | 238 | emsg = (char *) &msg[1]; |
239 | if ('\0' != emsg[msg_size - | 239 | if ('\0' != |
240 | sizeof (struct GNUNET_TESTBED_HostConfirmedMessage)]) | 240 | emsg[msg_size - sizeof (struct GNUNET_TESTBED_HostConfirmedMessage)]) |
241 | { | 241 | { |
242 | GNUNET_break (0); | 242 | GNUNET_break (0); |
243 | GNUNET_free (rh); | 243 | GNUNET_free (rh); |
244 | return GNUNET_NO; | 244 | return GNUNET_NO; |
245 | } | 245 | } |
246 | LOG (GNUNET_ERROR_TYPE_ERROR, _("Adding host %u failed with error: %s\n"), | 246 | LOG (GNUNET_ERROR_TYPE_ERROR, _("Adding host %u failed with error: %s\n"), |
247 | ntohl (msg->host_id), emsg); | 247 | ntohl (msg->host_id), emsg); |
248 | rh->cc (rh->cc_cls, emsg); | 248 | rh->cc (rh->cc_cls, emsg); |
@@ -268,7 +268,7 @@ handle_opsuccess (struct GNUNET_TESTBED_Controller *c, | |||
268 | struct OperationContext *opc; | 268 | struct OperationContext *opc; |
269 | struct GNUNET_TESTBED_EventInformation *event; | 269 | struct GNUNET_TESTBED_EventInformation *event; |
270 | uint64_t op_id; | 270 | uint64_t op_id; |
271 | 271 | ||
272 | op_id = GNUNET_ntohll (msg->operation_id); | 272 | op_id = GNUNET_ntohll (msg->operation_id); |
273 | LOG_DEBUG ("Operation %ul successful\n", op_id); | 273 | LOG_DEBUG ("Operation %ul successful\n", op_id); |
274 | if (NULL == (opc = find_opc (c, op_id))) | 274 | if (NULL == (opc = find_opc (c, op_id))) |
@@ -284,28 +284,29 @@ handle_opsuccess (struct GNUNET_TESTBED_Controller *c, | |||
284 | switch (opc->type) | 284 | switch (opc->type) |
285 | { | 285 | { |
286 | case OP_FORWARDED: | 286 | case OP_FORWARDED: |
287 | { | 287 | { |
288 | struct ForwardedOperationData *fo_data; | 288 | struct ForwardedOperationData *fo_data; |
289 | 289 | ||
290 | fo_data = opc->data; | 290 | fo_data = opc->data; |
291 | if (NULL != fo_data->cc) | 291 | if (NULL != fo_data->cc) |
292 | fo_data->cc (fo_data->cc_cls, (const struct GNUNET_MessageHeader *) msg); | 292 | fo_data->cc (fo_data->cc_cls, (const struct GNUNET_MessageHeader *) msg); |
293 | GNUNET_CONTAINER_DLL_remove (c->ocq_head, c->ocq_tail, opc); | 293 | GNUNET_CONTAINER_DLL_remove (c->ocq_head, c->ocq_tail, opc); |
294 | GNUNET_free (fo_data); | 294 | GNUNET_free (fo_data); |
295 | GNUNET_free (opc); | 295 | GNUNET_free (opc); |
296 | return GNUNET_YES; | 296 | return GNUNET_YES; |
297 | } | 297 | } |
298 | break; | 298 | break; |
299 | case OP_PEER_DESTROY: | 299 | case OP_PEER_DESTROY: |
300 | { | 300 | { |
301 | struct GNUNET_TESTBED_Peer *peer; | 301 | struct GNUNET_TESTBED_Peer *peer; |
302 | peer = opc->data; | 302 | |
303 | GNUNET_free (peer); | 303 | peer = opc->data; |
304 | opc->data = NULL; | 304 | GNUNET_free (peer); |
305 | //PEERDESTROYDATA | 305 | opc->data = NULL; |
306 | } | 306 | //PEERDESTROYDATA |
307 | } | ||
307 | break; | 308 | break; |
308 | case OP_LINK_CONTROLLERS: | 309 | case OP_LINK_CONTROLLERS: |
309 | break; | 310 | break; |
310 | default: | 311 | default: |
311 | GNUNET_assert (0); | 312 | GNUNET_assert (0); |
@@ -325,8 +326,8 @@ handle_opsuccess (struct GNUNET_TESTBED_Controller *c, | |||
325 | if (NULL != c->cc) | 326 | if (NULL != c->cc) |
326 | c->cc (c->cc_cls, event); | 327 | c->cc (c->cc_cls, event); |
327 | GNUNET_free (event); | 328 | GNUNET_free (event); |
328 | } | 329 | } |
329 | return GNUNET_YES; | 330 | return GNUNET_YES; |
330 | } | 331 | } |
331 | 332 | ||
332 | 333 | ||
@@ -341,8 +342,8 @@ handle_opsuccess (struct GNUNET_TESTBED_Controller *c, | |||
341 | */ | 342 | */ |
342 | static int | 343 | static int |
343 | handle_peer_create_success (struct GNUNET_TESTBED_Controller *c, | 344 | handle_peer_create_success (struct GNUNET_TESTBED_Controller *c, |
344 | const struct | 345 | const struct |
345 | GNUNET_TESTBED_PeerCreateSuccessEventMessage *msg) | 346 | GNUNET_TESTBED_PeerCreateSuccessEventMessage *msg) |
346 | { | 347 | { |
347 | struct OperationContext *opc; | 348 | struct OperationContext *opc; |
348 | struct PeerCreateData *data; | 349 | struct PeerCreateData *data; |
@@ -351,8 +352,8 @@ handle_peer_create_success (struct GNUNET_TESTBED_Controller *c, | |||
351 | void *cls; | 352 | void *cls; |
352 | uint64_t op_id; | 353 | uint64_t op_id; |
353 | 354 | ||
354 | GNUNET_assert (sizeof (struct GNUNET_TESTBED_PeerCreateSuccessEventMessage) | 355 | GNUNET_assert (sizeof (struct GNUNET_TESTBED_PeerCreateSuccessEventMessage) == |
355 | == ntohs (msg->header.size)); | 356 | ntohs (msg->header.size)); |
356 | op_id = GNUNET_ntohll (msg->operation_id); | 357 | op_id = GNUNET_ntohll (msg->operation_id); |
357 | if (NULL == (opc = find_opc (c, op_id))) | 358 | if (NULL == (opc = find_opc (c, op_id))) |
358 | { | 359 | { |
@@ -362,14 +363,14 @@ handle_peer_create_success (struct GNUNET_TESTBED_Controller *c, | |||
362 | if (OP_FORWARDED == opc->type) | 363 | if (OP_FORWARDED == opc->type) |
363 | { | 364 | { |
364 | struct ForwardedOperationData *fo_data; | 365 | struct ForwardedOperationData *fo_data; |
365 | 366 | ||
366 | fo_data = opc->data; | 367 | fo_data = opc->data; |
367 | if (NULL != fo_data->cc) | 368 | if (NULL != fo_data->cc) |
368 | fo_data->cc (fo_data->cc_cls, (const struct GNUNET_MessageHeader *) msg); | 369 | fo_data->cc (fo_data->cc_cls, (const struct GNUNET_MessageHeader *) msg); |
369 | GNUNET_CONTAINER_DLL_remove (c->ocq_head, c->ocq_tail, opc); | 370 | GNUNET_CONTAINER_DLL_remove (c->ocq_head, c->ocq_tail, opc); |
370 | GNUNET_free (fo_data); | 371 | GNUNET_free (fo_data); |
371 | GNUNET_free (opc); | 372 | GNUNET_free (opc); |
372 | return GNUNET_YES; | 373 | return GNUNET_YES; |
373 | } | 374 | } |
374 | GNUNET_assert (OP_PEER_CREATE == opc->type); | 375 | GNUNET_assert (OP_PEER_CREATE == opc->type); |
375 | GNUNET_assert (NULL != opc->data); | 376 | GNUNET_assert (NULL != opc->data); |
@@ -380,7 +381,7 @@ handle_peer_create_success (struct GNUNET_TESTBED_Controller *c, | |||
380 | peer->state = PS_CREATED; | 381 | peer->state = PS_CREATED; |
381 | cb = data->cb; | 382 | cb = data->cb; |
382 | cls = data->cls; | 383 | cls = data->cls; |
383 | GNUNET_free (opc->data); | 384 | GNUNET_free (opc->data); |
384 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); | 385 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); |
385 | opc->state = OPC_STATE_FINISHED; | 386 | opc->state = OPC_STATE_FINISHED; |
386 | if (NULL != cb) | 387 | if (NULL != cb) |
@@ -400,15 +401,15 @@ handle_peer_create_success (struct GNUNET_TESTBED_Controller *c, | |||
400 | */ | 401 | */ |
401 | static int | 402 | static int |
402 | handle_peer_event (struct GNUNET_TESTBED_Controller *c, | 403 | handle_peer_event (struct GNUNET_TESTBED_Controller *c, |
403 | const struct GNUNET_TESTBED_PeerEventMessage *msg) | 404 | const struct GNUNET_TESTBED_PeerEventMessage *msg) |
404 | { | 405 | { |
405 | struct OperationContext *opc; | 406 | struct OperationContext *opc; |
406 | struct GNUNET_TESTBED_Peer *peer; | 407 | struct GNUNET_TESTBED_Peer *peer; |
407 | struct GNUNET_TESTBED_EventInformation event; | 408 | struct GNUNET_TESTBED_EventInformation event; |
408 | uint64_t op_id; | 409 | uint64_t op_id; |
409 | 410 | ||
410 | GNUNET_assert (sizeof (struct GNUNET_TESTBED_PeerEventMessage) | 411 | GNUNET_assert (sizeof (struct GNUNET_TESTBED_PeerEventMessage) == |
411 | == ntohs (msg->header.size)); | 412 | ntohs (msg->header.size)); |
412 | op_id = GNUNET_ntohll (msg->operation_id); | 413 | op_id = GNUNET_ntohll (msg->operation_id); |
413 | if (NULL == (opc = find_opc (c, op_id))) | 414 | if (NULL == (opc = find_opc (c, op_id))) |
414 | { | 415 | { |
@@ -418,14 +419,14 @@ handle_peer_event (struct GNUNET_TESTBED_Controller *c, | |||
418 | if (OP_FORWARDED == opc->type) | 419 | if (OP_FORWARDED == opc->type) |
419 | { | 420 | { |
420 | struct ForwardedOperationData *fo_data; | 421 | struct ForwardedOperationData *fo_data; |
421 | 422 | ||
422 | fo_data = opc->data; | 423 | fo_data = opc->data; |
423 | if (NULL != fo_data->cc) | 424 | if (NULL != fo_data->cc) |
424 | fo_data->cc (fo_data->cc_cls, (const struct GNUNET_MessageHeader *) msg); | 425 | fo_data->cc (fo_data->cc_cls, (const struct GNUNET_MessageHeader *) msg); |
425 | GNUNET_CONTAINER_DLL_remove (c->ocq_head, c->ocq_tail, opc); | 426 | GNUNET_CONTAINER_DLL_remove (c->ocq_head, c->ocq_tail, opc); |
426 | GNUNET_free (fo_data); | 427 | GNUNET_free (fo_data); |
427 | GNUNET_free (opc); | 428 | GNUNET_free (opc); |
428 | return GNUNET_YES; | 429 | return GNUNET_YES; |
429 | } | 430 | } |
430 | GNUNET_assert ((OP_PEER_START == opc->type) || (OP_PEER_STOP == opc->type)); | 431 | GNUNET_assert ((OP_PEER_START == opc->type) || (OP_PEER_STOP == opc->type)); |
431 | peer = opc->data; | 432 | peer = opc->data; |
@@ -439,20 +440,21 @@ handle_peer_event (struct GNUNET_TESTBED_Controller *c, | |||
439 | event.details.peer_start.peer = peer; | 440 | event.details.peer_start.peer = peer; |
440 | break; | 441 | break; |
441 | case GNUNET_TESTBED_ET_PEER_STOP: | 442 | case GNUNET_TESTBED_ET_PEER_STOP: |
442 | peer->state = PS_STOPPED; | 443 | peer->state = PS_STOPPED; |
443 | event.details.peer_stop.peer = peer; | 444 | event.details.peer_stop.peer = peer; |
444 | break; | 445 | break; |
445 | default: | 446 | default: |
446 | GNUNET_assert (0); /* We should never reach this state */ | 447 | GNUNET_assert (0); /* We should never reach this state */ |
447 | } | 448 | } |
448 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); | 449 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); |
449 | opc->state = OPC_STATE_FINISHED; | 450 | opc->state = OPC_STATE_FINISHED; |
450 | if (0 != ((GNUNET_TESTBED_ET_PEER_START | GNUNET_TESTBED_ET_PEER_STOP) | 451 | if (0 != |
451 | & c->event_mask)) | 452 | ((GNUNET_TESTBED_ET_PEER_START | GNUNET_TESTBED_ET_PEER_STOP) & |
453 | c->event_mask)) | ||
452 | { | 454 | { |
453 | if (NULL != c->cc) | 455 | if (NULL != c->cc) |
454 | c->cc (c->cc_cls, &event); | 456 | c->cc (c->cc_cls, &event); |
455 | } | 457 | } |
456 | return GNUNET_YES; | 458 | return GNUNET_YES; |
457 | } | 459 | } |
458 | 460 | ||
@@ -483,8 +485,8 @@ handle_peer_conevent (struct GNUNET_TESTBED_Controller *c, | |||
483 | } | 485 | } |
484 | data = opc->data; | 486 | data = opc->data; |
485 | GNUNET_assert (NULL != data); | 487 | GNUNET_assert (NULL != data); |
486 | GNUNET_assert ((ntohl (msg->peer1) == data->p1->unique_id) | 488 | GNUNET_assert ((ntohl (msg->peer1) == data->p1->unique_id) && |
487 | && (ntohl (msg->peer2) == data->p2->unique_id)); | 489 | (ntohl (msg->peer2) == data->p2->unique_id)); |
488 | event.type = (enum GNUNET_TESTBED_EventType) ntohl (msg->event_type); | 490 | event.type = (enum GNUNET_TESTBED_EventType) ntohl (msg->event_type); |
489 | switch (event.type) | 491 | switch (event.type) |
490 | { | 492 | { |
@@ -502,8 +504,9 @@ handle_peer_conevent (struct GNUNET_TESTBED_Controller *c, | |||
502 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); | 504 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); |
503 | opc->state = OPC_STATE_FINISHED; | 505 | opc->state = OPC_STATE_FINISHED; |
504 | GNUNET_free (data); | 506 | GNUNET_free (data); |
505 | if (0 != ((GNUNET_TESTBED_ET_CONNECT | GNUNET_TESTBED_ET_DISCONNECT) | 507 | if (0 != |
506 | & c->event_mask)) | 508 | ((GNUNET_TESTBED_ET_CONNECT | GNUNET_TESTBED_ET_DISCONNECT) & |
509 | c->event_mask)) | ||
507 | { | 510 | { |
508 | if (NULL != c->cc) | 511 | if (NULL != c->cc) |
509 | c->cc (c->cc_cls, &event); | 512 | c->cc (c->cc_cls, &event); |
@@ -523,7 +526,8 @@ handle_peer_conevent (struct GNUNET_TESTBED_Controller *c, | |||
523 | */ | 526 | */ |
524 | static int | 527 | static int |
525 | handle_peer_config (struct GNUNET_TESTBED_Controller *c, | 528 | handle_peer_config (struct GNUNET_TESTBED_Controller *c, |
526 | const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *msg) | 529 | const struct |
530 | GNUNET_TESTBED_PeerConfigurationInformationMessage *msg) | ||
527 | { | 531 | { |
528 | struct OperationContext *opc; | 532 | struct OperationContext *opc; |
529 | struct GNUNET_TESTBED_Peer *peer; | 533 | struct GNUNET_TESTBED_Peer *peer; |
@@ -531,7 +535,7 @@ handle_peer_config (struct GNUNET_TESTBED_Controller *c, | |||
531 | struct PeerInfoData2 *response_data; | 535 | struct PeerInfoData2 *response_data; |
532 | struct GNUNET_TESTBED_EventInformation info; | 536 | struct GNUNET_TESTBED_EventInformation info; |
533 | uint64_t op_id; | 537 | uint64_t op_id; |
534 | 538 | ||
535 | op_id = GNUNET_ntohll (msg->operation_id); | 539 | op_id = GNUNET_ntohll (msg->operation_id); |
536 | if (NULL == (opc = find_opc (c, op_id))) | 540 | if (NULL == (opc = find_opc (c, op_id))) |
537 | { | 541 | { |
@@ -541,14 +545,14 @@ handle_peer_config (struct GNUNET_TESTBED_Controller *c, | |||
541 | if (OP_FORWARDED == opc->type) | 545 | if (OP_FORWARDED == opc->type) |
542 | { | 546 | { |
543 | struct ForwardedOperationData *fo_data; | 547 | struct ForwardedOperationData *fo_data; |
544 | 548 | ||
545 | fo_data = opc->data; | 549 | fo_data = opc->data; |
546 | if (NULL != fo_data->cc) | 550 | if (NULL != fo_data->cc) |
547 | fo_data->cc (fo_data->cc_cls, (const struct GNUNET_MessageHeader *) msg); | 551 | fo_data->cc (fo_data->cc_cls, (const struct GNUNET_MessageHeader *) msg); |
548 | GNUNET_CONTAINER_DLL_remove (c->ocq_head, c->ocq_tail, opc); | 552 | GNUNET_CONTAINER_DLL_remove (c->ocq_head, c->ocq_tail, opc); |
549 | GNUNET_free (fo_data); | 553 | GNUNET_free (fo_data); |
550 | GNUNET_free (opc); | 554 | GNUNET_free (opc); |
551 | return GNUNET_YES; | 555 | return GNUNET_YES; |
552 | } | 556 | } |
553 | data = opc->data; | 557 | data = opc->data; |
554 | GNUNET_assert (NULL != data); | 558 | GNUNET_assert (NULL != data); |
@@ -572,34 +576,35 @@ handle_peer_config (struct GNUNET_TESTBED_Controller *c, | |||
572 | switch (response_data->pit) | 576 | switch (response_data->pit) |
573 | { | 577 | { |
574 | case GNUNET_TESTBED_PIT_IDENTITY: | 578 | case GNUNET_TESTBED_PIT_IDENTITY: |
575 | { | 579 | { |
576 | struct GNUNET_PeerIdentity *peer_identity; | 580 | struct GNUNET_PeerIdentity *peer_identity; |
577 | 581 | ||
578 | peer_identity = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity)); | 582 | peer_identity = GNUNET_malloc (sizeof (struct GNUNET_PeerIdentity)); |
579 | (void) memcpy (peer_identity, &msg->peer_identity, | 583 | (void) memcpy (peer_identity, &msg->peer_identity, |
580 | sizeof (struct GNUNET_PeerIdentity)); | 584 | sizeof (struct GNUNET_PeerIdentity)); |
581 | response_data->details.peer_identity = peer_identity; | 585 | response_data->details.peer_identity = peer_identity; |
582 | info.details.operation_finished.op_result.pid = peer_identity; | 586 | info.details.operation_finished.op_result.pid = peer_identity; |
583 | } | 587 | } |
584 | break; | 588 | break; |
585 | case GNUNET_TESTBED_PIT_CONFIGURATION: | 589 | case GNUNET_TESTBED_PIT_CONFIGURATION: |
586 | response_data->details.cfg = /* Freed in oprelease_peer_getinfo */ | 590 | response_data->details.cfg = /* Freed in oprelease_peer_getinfo */ |
587 | GNUNET_TESTBED_get_config_from_peerinfo_msg_ (msg); | 591 | GNUNET_TESTBED_get_config_from_peerinfo_msg_ (msg); |
588 | info.details.operation_finished.op_result.cfg = response_data->details.cfg; | 592 | info.details.operation_finished.op_result.cfg = response_data->details.cfg; |
589 | break; | 593 | break; |
590 | case GNUNET_TESTBED_PIT_GENERIC: | 594 | case GNUNET_TESTBED_PIT_GENERIC: |
591 | GNUNET_assert (0); /* never reach here */ | 595 | GNUNET_assert (0); /* never reach here */ |
592 | break; | 596 | break; |
593 | } | 597 | } |
594 | opc->data = response_data; | 598 | opc->data = response_data; |
595 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); | 599 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); |
596 | opc->state = OPC_STATE_FINISHED; | 600 | opc->state = OPC_STATE_FINISHED; |
597 | if (0 != ((GNUNET_TESTBED_ET_CONNECT | GNUNET_TESTBED_ET_DISCONNECT) | 601 | if (0 != |
598 | & c->event_mask)) | 602 | ((GNUNET_TESTBED_ET_CONNECT | GNUNET_TESTBED_ET_DISCONNECT) & |
603 | c->event_mask)) | ||
599 | { | 604 | { |
600 | if (NULL != c->cc) | 605 | if (NULL != c->cc) |
601 | c->cc (c->cc_cls, &info); | 606 | c->cc (c->cc_cls, &info); |
602 | } | 607 | } |
603 | return GNUNET_YES; | 608 | return GNUNET_YES; |
604 | } | 609 | } |
605 | 610 | ||
@@ -615,15 +620,15 @@ handle_peer_config (struct GNUNET_TESTBED_Controller *c, | |||
615 | */ | 620 | */ |
616 | static int | 621 | static int |
617 | handle_op_fail_event (struct GNUNET_TESTBED_Controller *c, | 622 | handle_op_fail_event (struct GNUNET_TESTBED_Controller *c, |
618 | const struct | 623 | const struct GNUNET_TESTBED_OperationFailureEventMessage |
619 | GNUNET_TESTBED_OperationFailureEventMessage *msg) | 624 | *msg) |
620 | { | 625 | { |
621 | struct OperationContext *opc; | 626 | struct OperationContext *opc; |
622 | char *emsg; | 627 | char *emsg; |
623 | uint64_t op_id; | 628 | uint64_t op_id; |
624 | struct GNUNET_TESTBED_EventInformation event; | 629 | struct GNUNET_TESTBED_EventInformation event; |
625 | uint16_t msize; | 630 | uint16_t msize; |
626 | 631 | ||
627 | op_id = GNUNET_ntohll (msg->operation_id); | 632 | op_id = GNUNET_ntohll (msg->operation_id); |
628 | if (NULL == (opc = find_opc (c, op_id))) | 633 | if (NULL == (opc = find_opc (c, op_id))) |
629 | { | 634 | { |
@@ -633,14 +638,14 @@ handle_op_fail_event (struct GNUNET_TESTBED_Controller *c, | |||
633 | if (OP_FORWARDED == opc->type) | 638 | if (OP_FORWARDED == opc->type) |
634 | { | 639 | { |
635 | struct ForwardedOperationData *fo_data; | 640 | struct ForwardedOperationData *fo_data; |
636 | 641 | ||
637 | fo_data = opc->data; | 642 | fo_data = opc->data; |
638 | if (NULL != fo_data->cc) | 643 | if (NULL != fo_data->cc) |
639 | fo_data->cc (fo_data->cc_cls, (const struct GNUNET_MessageHeader *) msg); | 644 | fo_data->cc (fo_data->cc_cls, (const struct GNUNET_MessageHeader *) msg); |
640 | GNUNET_CONTAINER_DLL_remove (c->ocq_head, c->ocq_tail, opc); | 645 | GNUNET_CONTAINER_DLL_remove (c->ocq_head, c->ocq_tail, opc); |
641 | GNUNET_free (fo_data); | 646 | GNUNET_free (fo_data); |
642 | GNUNET_free (opc); | 647 | GNUNET_free (opc); |
643 | return GNUNET_YES; | 648 | return GNUNET_YES; |
644 | } | 649 | } |
645 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); | 650 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); |
646 | opc->state = OPC_STATE_FINISHED; | 651 | opc->state = OPC_STATE_FINISHED; |
@@ -658,8 +663,8 @@ handle_op_fail_event (struct GNUNET_TESTBED_Controller *c, | |||
658 | emsg = (char *) &msg[1]; | 663 | emsg = (char *) &msg[1]; |
659 | GNUNET_assert ('\0' == emsg[msize - 1]); | 664 | GNUNET_assert ('\0' == emsg[msize - 1]); |
660 | } | 665 | } |
661 | if ((0 != (GNUNET_TESTBED_ET_OPERATION_FINISHED & c->event_mask)) | 666 | if ((0 != (GNUNET_TESTBED_ET_OPERATION_FINISHED & c->event_mask)) && |
662 | && (NULL != c->cc)) | 667 | (NULL != c->cc)) |
663 | { | 668 | { |
664 | event.type = GNUNET_TESTBED_ET_OPERATION_FINISHED; | 669 | event.type = GNUNET_TESTBED_ET_OPERATION_FINISHED; |
665 | event.details.operation_finished.operation = opc->op; | 670 | event.details.operation_finished.operation = opc->op; |
@@ -668,7 +673,7 @@ handle_op_fail_event (struct GNUNET_TESTBED_Controller *c, | |||
668 | event.details.operation_finished.pit = GNUNET_TESTBED_PIT_GENERIC; | 673 | event.details.operation_finished.pit = GNUNET_TESTBED_PIT_GENERIC; |
669 | event.details.operation_finished.op_result.generic = NULL; | 674 | event.details.operation_finished.op_result.generic = NULL; |
670 | c->cc (c->cc_cls, &event); | 675 | c->cc (c->cc_cls, &event); |
671 | } | 676 | } |
672 | return GNUNET_YES; | 677 | return GNUNET_YES; |
673 | } | 678 | } |
674 | 679 | ||
@@ -679,7 +684,7 @@ handle_op_fail_event (struct GNUNET_TESTBED_Controller *c, | |||
679 | * @param cls the controller handler | 684 | * @param cls the controller handler |
680 | * @param msg message received, NULL on timeout or fatal error | 685 | * @param msg message received, NULL on timeout or fatal error |
681 | */ | 686 | */ |
682 | static void | 687 | static void |
683 | message_handler (void *cls, const struct GNUNET_MessageHeader *msg) | 688 | message_handler (void *cls, const struct GNUNET_MessageHeader *msg) |
684 | { | 689 | { |
685 | struct GNUNET_TESTBED_Controller *c = cls; | 690 | struct GNUNET_TESTBED_Controller *c = cls; |
@@ -698,54 +703,67 @@ message_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
698 | switch (ntohs (msg->type)) | 703 | switch (ntohs (msg->type)) |
699 | { | 704 | { |
700 | case GNUNET_MESSAGE_TYPE_TESTBED_ADDHOSTCONFIRM: | 705 | case GNUNET_MESSAGE_TYPE_TESTBED_ADDHOSTCONFIRM: |
701 | GNUNET_assert (msize >= sizeof (struct | 706 | GNUNET_assert (msize >= |
702 | GNUNET_TESTBED_HostConfirmedMessage)); | 707 | sizeof (struct GNUNET_TESTBED_HostConfirmedMessage)); |
703 | status = | 708 | status = |
704 | handle_addhostconfirm (c, (const struct GNUNET_TESTBED_HostConfirmedMessage *) msg); | 709 | handle_addhostconfirm (c, |
710 | (const struct GNUNET_TESTBED_HostConfirmedMessage | ||
711 | *) msg); | ||
705 | break; | 712 | break; |
706 | case GNUNET_MESSAGE_TYPE_TESTBED_GENERICOPSUCCESS: | 713 | case GNUNET_MESSAGE_TYPE_TESTBED_GENERICOPSUCCESS: |
707 | GNUNET_assert | 714 | GNUNET_assert (msize == |
708 | (msize == sizeof (struct GNUNET_TESTBED_GenericOperationSuccessEventMessage)); | 715 | sizeof (struct |
716 | GNUNET_TESTBED_GenericOperationSuccessEventMessage)); | ||
709 | status = | 717 | status = |
710 | handle_opsuccess (c, (const struct | 718 | handle_opsuccess (c, |
711 | GNUNET_TESTBED_GenericOperationSuccessEventMessage | 719 | (const struct |
712 | *) msg); | 720 | GNUNET_TESTBED_GenericOperationSuccessEventMessage *) |
721 | msg); | ||
713 | break; | 722 | break; |
714 | case GNUNET_MESSAGE_TYPE_TESTBED_PEERCREATESUCCESS: | 723 | case GNUNET_MESSAGE_TYPE_TESTBED_PEERCREATESUCCESS: |
715 | GNUNET_assert (msize == | 724 | GNUNET_assert (msize == |
716 | sizeof (struct GNUNET_TESTBED_PeerCreateSuccessEventMessage)); | 725 | sizeof (struct |
726 | GNUNET_TESTBED_PeerCreateSuccessEventMessage)); | ||
717 | status = | 727 | status = |
718 | handle_peer_create_success | 728 | handle_peer_create_success (c, |
719 | (c, (const struct GNUNET_TESTBED_PeerCreateSuccessEventMessage *)msg); | 729 | (const struct |
730 | GNUNET_TESTBED_PeerCreateSuccessEventMessage | ||
731 | *) msg); | ||
720 | break; | 732 | break; |
721 | case GNUNET_MESSAGE_TYPE_TESTBED_PEEREVENT: | 733 | case GNUNET_MESSAGE_TYPE_TESTBED_PEEREVENT: |
722 | GNUNET_assert (msize == sizeof (struct GNUNET_TESTBED_PeerEventMessage)); | 734 | GNUNET_assert (msize == sizeof (struct GNUNET_TESTBED_PeerEventMessage)); |
723 | status = | 735 | status = |
724 | handle_peer_event (c, (const struct GNUNET_TESTBED_PeerEventMessage *) msg); | 736 | handle_peer_event (c, |
725 | 737 | (const struct GNUNET_TESTBED_PeerEventMessage *) | |
738 | msg); | ||
739 | |||
726 | break; | 740 | break; |
727 | case GNUNET_MESSAGE_TYPE_TESTBED_PEERCONFIG: | 741 | case GNUNET_MESSAGE_TYPE_TESTBED_PEERCONFIG: |
728 | GNUNET_assert (msize >= | 742 | GNUNET_assert (msize >= |
729 | sizeof (struct GNUNET_TESTBED_PeerConfigurationInformationMessage)); | 743 | sizeof (struct |
730 | status = | 744 | GNUNET_TESTBED_PeerConfigurationInformationMessage)); |
731 | handle_peer_config | 745 | status = |
732 | (c, (const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *) | 746 | handle_peer_config (c, |
733 | msg); | 747 | (const struct |
748 | GNUNET_TESTBED_PeerConfigurationInformationMessage | ||
749 | *) msg); | ||
734 | break; | 750 | break; |
735 | case GNUNET_MESSAGE_TYPE_TESTBED_PEERCONEVENT: | 751 | case GNUNET_MESSAGE_TYPE_TESTBED_PEERCONEVENT: |
736 | GNUNET_assert (msize == | 752 | GNUNET_assert (msize == |
737 | sizeof (struct GNUNET_TESTBED_ConnectionEventMessage)); | 753 | sizeof (struct GNUNET_TESTBED_ConnectionEventMessage)); |
738 | status = | 754 | status = |
739 | handle_peer_conevent (c, (const struct | 755 | handle_peer_conevent (c, |
740 | GNUNET_TESTBED_ConnectionEventMessage *) msg); | 756 | (const struct |
757 | GNUNET_TESTBED_ConnectionEventMessage *) msg); | ||
741 | break; | 758 | break; |
742 | case GNUNET_MESSAGE_TYPE_TESTBED_OPERATIONEVENT: | 759 | case GNUNET_MESSAGE_TYPE_TESTBED_OPERATIONEVENT: |
743 | GNUNET_assert (msize >= | 760 | GNUNET_assert (msize >= |
744 | sizeof (struct GNUNET_TESTBED_OperationFailureEventMessage)); | 761 | sizeof (struct GNUNET_TESTBED_OperationFailureEventMessage)); |
745 | status = | 762 | status = |
746 | handle_op_fail_event (c, (const struct | 763 | handle_op_fail_event (c, |
747 | GNUNET_TESTBED_OperationFailureEventMessage *) | 764 | (const struct |
748 | msg); | 765 | GNUNET_TESTBED_OperationFailureEventMessage *) |
766 | msg); | ||
749 | break; | 767 | break; |
750 | default: | 768 | default: |
751 | GNUNET_assert (0); | 769 | GNUNET_assert (0); |
@@ -754,7 +772,7 @@ message_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
754 | { | 772 | { |
755 | c->in_receive = GNUNET_YES; | 773 | c->in_receive = GNUNET_YES; |
756 | GNUNET_CLIENT_receive (c->client, &message_handler, c, | 774 | GNUNET_CLIENT_receive (c->client, &message_handler, c, |
757 | GNUNET_TIME_UNIT_FOREVER_REL); | 775 | GNUNET_TIME_UNIT_FOREVER_REL); |
758 | } | 776 | } |
759 | } | 777 | } |
760 | 778 | ||
@@ -778,38 +796,36 @@ transmit_ready_notify (void *cls, size_t size, void *buf) | |||
778 | c->th = NULL; | 796 | c->th = NULL; |
779 | mq_entry = c->mq_head; | 797 | mq_entry = c->mq_head; |
780 | GNUNET_assert (NULL != mq_entry); | 798 | GNUNET_assert (NULL != mq_entry); |
781 | if ((0 == size) && (NULL == buf)) /* Timeout */ | 799 | if ((0 == size) && (NULL == buf)) /* Timeout */ |
782 | { | 800 | { |
783 | LOG_DEBUG ("Message sending timed out -- retrying\n"); | 801 | LOG_DEBUG ("Message sending timed out -- retrying\n"); |
784 | c->th = | 802 | c->th = |
785 | GNUNET_CLIENT_notify_transmit_ready (c->client, | 803 | GNUNET_CLIENT_notify_transmit_ready (c->client, |
786 | ntohs (mq_entry->msg->size), | 804 | ntohs (mq_entry->msg->size), |
787 | TIMEOUT_REL, | 805 | TIMEOUT_REL, GNUNET_YES, |
788 | GNUNET_YES, &transmit_ready_notify, | 806 | &transmit_ready_notify, c); |
789 | c); | ||
790 | return 0; | 807 | return 0; |
791 | } | 808 | } |
792 | GNUNET_assert (ntohs (mq_entry->msg->size) <= size); | 809 | GNUNET_assert (ntohs (mq_entry->msg->size) <= size); |
793 | size = ntohs (mq_entry->msg->size); | 810 | size = ntohs (mq_entry->msg->size); |
794 | memcpy (buf, mq_entry->msg, size); | 811 | memcpy (buf, mq_entry->msg, size); |
795 | LOG_DEBUG ("Message of type: %u and size: %u sent\n", | 812 | LOG_DEBUG ("Message of type: %u and size: %u sent\n", |
796 | ntohs (mq_entry->msg->type), size); | 813 | ntohs (mq_entry->msg->type), size); |
797 | GNUNET_free (mq_entry->msg); | 814 | GNUNET_free (mq_entry->msg); |
798 | GNUNET_CONTAINER_DLL_remove (c->mq_head, c->mq_tail, mq_entry); | 815 | GNUNET_CONTAINER_DLL_remove (c->mq_head, c->mq_tail, mq_entry); |
799 | GNUNET_free (mq_entry); | 816 | GNUNET_free (mq_entry); |
800 | mq_entry = c->mq_head; | 817 | mq_entry = c->mq_head; |
801 | if (NULL != mq_entry) | 818 | if (NULL != mq_entry) |
802 | c->th = | 819 | c->th = |
803 | GNUNET_CLIENT_notify_transmit_ready (c->client, | 820 | GNUNET_CLIENT_notify_transmit_ready (c->client, |
804 | ntohs (mq_entry->msg->size), | 821 | ntohs (mq_entry->msg->size), |
805 | TIMEOUT_REL, | 822 | TIMEOUT_REL, GNUNET_YES, |
806 | GNUNET_YES, &transmit_ready_notify, | 823 | &transmit_ready_notify, c); |
807 | c); | ||
808 | if (GNUNET_NO == c->in_receive) | 824 | if (GNUNET_NO == c->in_receive) |
809 | { | 825 | { |
810 | c->in_receive = GNUNET_YES; | 826 | c->in_receive = GNUNET_YES; |
811 | GNUNET_CLIENT_receive (c->client, &message_handler, c, | 827 | GNUNET_CLIENT_receive (c->client, &message_handler, c, |
812 | GNUNET_TIME_UNIT_FOREVER_REL); | 828 | GNUNET_TIME_UNIT_FOREVER_REL); |
813 | } | 829 | } |
814 | return size; | 830 | return size; |
815 | } | 831 | } |
@@ -823,7 +839,7 @@ transmit_ready_notify (void *cls, size_t size, void *buf) | |||
823 | */ | 839 | */ |
824 | void | 840 | void |
825 | GNUNET_TESTBED_queue_message_ (struct GNUNET_TESTBED_Controller *controller, | 841 | GNUNET_TESTBED_queue_message_ (struct GNUNET_TESTBED_Controller *controller, |
826 | struct GNUNET_MessageHeader *msg) | 842 | struct GNUNET_MessageHeader *msg) |
827 | { | 843 | { |
828 | struct MessageQueue *mq_entry; | 844 | struct MessageQueue *mq_entry; |
829 | uint16_t type; | 845 | uint16_t type; |
@@ -832,7 +848,7 @@ GNUNET_TESTBED_queue_message_ (struct GNUNET_TESTBED_Controller *controller, | |||
832 | type = ntohs (msg->type); | 848 | type = ntohs (msg->type); |
833 | size = ntohs (msg->size); | 849 | size = ntohs (msg->size); |
834 | GNUNET_assert ((GNUNET_MESSAGE_TYPE_TESTBED_INIT <= type) && | 850 | GNUNET_assert ((GNUNET_MESSAGE_TYPE_TESTBED_INIT <= type) && |
835 | (GNUNET_MESSAGE_TYPE_TESTBED_MAX > type)); | 851 | (GNUNET_MESSAGE_TYPE_TESTBED_MAX > type)); |
836 | mq_entry = GNUNET_malloc (sizeof (struct MessageQueue)); | 852 | mq_entry = GNUNET_malloc (sizeof (struct MessageQueue)); |
837 | mq_entry->msg = msg; | 853 | mq_entry->msg = msg; |
838 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 854 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
@@ -841,11 +857,11 @@ GNUNET_TESTBED_queue_message_ (struct GNUNET_TESTBED_Controller *controller, | |||
841 | GNUNET_CONTAINER_DLL_insert_tail (controller->mq_head, controller->mq_tail, | 857 | GNUNET_CONTAINER_DLL_insert_tail (controller->mq_head, controller->mq_tail, |
842 | mq_entry); | 858 | mq_entry); |
843 | if (NULL == controller->th) | 859 | if (NULL == controller->th) |
844 | controller->th = | 860 | controller->th = |
845 | GNUNET_CLIENT_notify_transmit_ready (controller->client, size, | 861 | GNUNET_CLIENT_notify_transmit_ready (controller->client, size, |
846 | TIMEOUT_REL, | 862 | TIMEOUT_REL, GNUNET_YES, |
847 | GNUNET_YES, &transmit_ready_notify, | 863 | &transmit_ready_notify, |
848 | controller); | 864 | controller); |
849 | } | 865 | } |
850 | 866 | ||
851 | 867 | ||
@@ -861,36 +877,35 @@ GNUNET_TESTBED_queue_message_ (struct GNUNET_TESTBED_Controller *controller, | |||
861 | * @param cc the callback to call when reply is available | 877 | * @param cc the callback to call when reply is available |
862 | * @param cc_cls the closure for the above callback | 878 | * @param cc_cls the closure for the above callback |
863 | * @return the operation context which can be used to cancel the forwarded | 879 | * @return the operation context which can be used to cancel the forwarded |
864 | * operation | 880 | * operation |
865 | */ | 881 | */ |
866 | struct OperationContext * | 882 | struct OperationContext * |
867 | GNUNET_TESTBED_forward_operation_msg_ (struct GNUNET_TESTBED_Controller | 883 | GNUNET_TESTBED_forward_operation_msg_ (struct GNUNET_TESTBED_Controller |
868 | * controller, | 884 | *controller, uint64_t operation_id, |
869 | uint64_t operation_id, | ||
870 | const struct GNUNET_MessageHeader *msg, | 885 | const struct GNUNET_MessageHeader *msg, |
871 | GNUNET_CLIENT_MessageHandler cc, | 886 | GNUNET_CLIENT_MessageHandler cc, |
872 | void *cc_cls) | 887 | void *cc_cls) |
873 | { | 888 | { |
874 | struct OperationContext *opc; | 889 | struct OperationContext *opc; |
875 | struct ForwardedOperationData *data; | 890 | struct ForwardedOperationData *data; |
876 | struct GNUNET_MessageHeader *dup_msg; | 891 | struct GNUNET_MessageHeader *dup_msg; |
877 | uint16_t msize; | 892 | uint16_t msize; |
878 | 893 | ||
879 | data = GNUNET_malloc (sizeof (struct ForwardedOperationData)); | 894 | data = GNUNET_malloc (sizeof (struct ForwardedOperationData)); |
880 | data->cc = cc; | 895 | data->cc = cc; |
881 | data->cc_cls = cc_cls; | 896 | data->cc_cls = cc_cls; |
882 | opc = GNUNET_malloc (sizeof (struct OperationContext)); | 897 | opc = GNUNET_malloc (sizeof (struct OperationContext)); |
883 | opc->c = controller; | 898 | opc->c = controller; |
884 | opc->type = OP_FORWARDED; | 899 | opc->type = OP_FORWARDED; |
885 | opc->data = data; | 900 | opc->data = data; |
886 | opc->id = operation_id; | 901 | opc->id = operation_id; |
887 | msize = ntohs (msg->size); | 902 | msize = ntohs (msg->size); |
888 | dup_msg = GNUNET_malloc (msize); | 903 | dup_msg = GNUNET_malloc (msize); |
889 | (void) memcpy (dup_msg, msg, msize); | 904 | (void) memcpy (dup_msg, msg, msize); |
890 | GNUNET_TESTBED_queue_message_ (opc->c, dup_msg); | 905 | GNUNET_TESTBED_queue_message_ (opc->c, dup_msg); |
891 | GNUNET_CONTAINER_DLL_insert_tail (controller->ocq_head, | 906 | GNUNET_CONTAINER_DLL_insert_tail (controller->ocq_head, controller->ocq_tail, |
892 | controller->ocq_tail, opc); | 907 | opc); |
893 | return opc; | 908 | return opc; |
894 | } | 909 | } |
895 | 910 | ||
896 | 911 | ||
@@ -905,7 +920,7 @@ GNUNET_TESTBED_forward_operation_msg_cancel_ (struct OperationContext *opc) | |||
905 | { | 920 | { |
906 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); | 921 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); |
907 | GNUNET_free (opc->data); | 922 | GNUNET_free (opc->data); |
908 | GNUNET_free (opc); | 923 | GNUNET_free (opc); |
909 | } | 924 | } |
910 | 925 | ||
911 | 926 | ||
@@ -974,9 +989,8 @@ struct GNUNET_TESTBED_ControllerProc | |||
974 | * | 989 | * |
975 | * @return GNUNET_OK on success, GNUNET_SYSERR to stop further processing | 990 | * @return GNUNET_OK on success, GNUNET_SYSERR to stop further processing |
976 | */ | 991 | */ |
977 | static int | 992 | static int |
978 | helper_mst (void *cls, void *client, | 993 | helper_mst (void *cls, void *client, const struct GNUNET_MessageHeader *message) |
979 | const struct GNUNET_MessageHeader *message) | ||
980 | { | 994 | { |
981 | struct GNUNET_TESTBED_ControllerProc *cp = cls; | 995 | struct GNUNET_TESTBED_ControllerProc *cp = cls; |
982 | const struct GNUNET_TESTBED_HelperReply *msg; | 996 | const struct GNUNET_TESTBED_HelperReply *msg; |
@@ -984,29 +998,31 @@ helper_mst (void *cls, void *client, | |||
984 | char *config; | 998 | char *config; |
985 | uLongf config_size; | 999 | uLongf config_size; |
986 | uLongf xconfig_size; | 1000 | uLongf xconfig_size; |
987 | 1001 | ||
988 | msg = (const struct GNUNET_TESTBED_HelperReply *) message; | 1002 | msg = (const struct GNUNET_TESTBED_HelperReply *) message; |
989 | GNUNET_assert (sizeof (struct GNUNET_TESTBED_HelperReply) | 1003 | GNUNET_assert (sizeof (struct GNUNET_TESTBED_HelperReply) < |
990 | < ntohs (msg->header.size)); | 1004 | ntohs (msg->header.size)); |
991 | GNUNET_assert (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_REPLY | 1005 | GNUNET_assert (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_REPLY == |
992 | == ntohs (msg->header.type)); | 1006 | ntohs (msg->header.type)); |
993 | config_size = (uLongf) ntohs (msg->config_size); | 1007 | config_size = (uLongf) ntohs (msg->config_size); |
994 | xconfig_size = (uLongf) (ntohs (msg->header.size) | 1008 | xconfig_size = |
995 | - sizeof (struct GNUNET_TESTBED_HelperReply)); | 1009 | (uLongf) (ntohs (msg->header.size) - |
1010 | sizeof (struct GNUNET_TESTBED_HelperReply)); | ||
996 | config = GNUNET_malloc (config_size); | 1011 | config = GNUNET_malloc (config_size); |
997 | GNUNET_assert (Z_OK == uncompress ((Bytef *) config, &config_size, | 1012 | GNUNET_assert (Z_OK == |
998 | (const Bytef *) &msg[1], xconfig_size)); | 1013 | uncompress ((Bytef *) config, &config_size, |
1014 | (const Bytef *) &msg[1], xconfig_size)); | ||
999 | GNUNET_assert (NULL == cp->cfg); | 1015 | GNUNET_assert (NULL == cp->cfg); |
1000 | cp->cfg = GNUNET_CONFIGURATION_create (); | 1016 | cp->cfg = GNUNET_CONFIGURATION_create (); |
1001 | GNUNET_assert (GNUNET_CONFIGURATION_deserialize (cp->cfg, config, | 1017 | GNUNET_assert (GNUNET_CONFIGURATION_deserialize |
1002 | config_size, GNUNET_NO)); | 1018 | (cp->cfg, config, config_size, GNUNET_NO)); |
1003 | GNUNET_free (config); | 1019 | GNUNET_free (config); |
1004 | if ((NULL == cp->host) || | 1020 | if ((NULL == cp->host) || |
1005 | (NULL == (hostname = GNUNET_TESTBED_host_get_hostname_ (cp->host)))) | 1021 | (NULL == (hostname = GNUNET_TESTBED_host_get_hostname_ (cp->host)))) |
1006 | hostname = "localhost"; | 1022 | hostname = "localhost"; |
1007 | /* Change the hostname so that we can connect to it */ | 1023 | /* Change the hostname so that we can connect to it */ |
1008 | GNUNET_CONFIGURATION_set_value_string (cp->cfg, "testbed", "hostname", | 1024 | GNUNET_CONFIGURATION_set_value_string (cp->cfg, "testbed", "hostname", |
1009 | hostname); | 1025 | hostname); |
1010 | cp->cb (cp->cls, cp->cfg, GNUNET_OK); | 1026 | cp->cb (cp->cls, cp->cfg, GNUNET_OK); |
1011 | return GNUNET_OK; | 1027 | return GNUNET_OK; |
1012 | } | 1028 | } |
@@ -1014,17 +1030,17 @@ helper_mst (void *cls, void *client, | |||
1014 | 1030 | ||
1015 | /** | 1031 | /** |
1016 | * Continuation function from GNUNET_HELPER_send() | 1032 | * Continuation function from GNUNET_HELPER_send() |
1017 | * | 1033 | * |
1018 | * @param cls closure | 1034 | * @param cls closure |
1019 | * @param result GNUNET_OK on success, | 1035 | * @param result GNUNET_OK on success, |
1020 | * GNUNET_NO if helper process died | 1036 | * GNUNET_NO if helper process died |
1021 | * GNUNET_SYSERR during GNUNET_HELPER_stop | 1037 | * GNUNET_SYSERR during GNUNET_HELPER_stop |
1022 | */ | 1038 | */ |
1023 | static void | 1039 | static void |
1024 | clear_msg (void *cls, int result) | 1040 | clear_msg (void *cls, int result) |
1025 | { | 1041 | { |
1026 | struct GNUNET_TESTBED_ControllerProc *cp = cls; | 1042 | struct GNUNET_TESTBED_ControllerProc *cp = cls; |
1027 | 1043 | ||
1028 | GNUNET_assert (NULL != cp->shandle); | 1044 | GNUNET_assert (NULL != cp->shandle); |
1029 | cp->shandle = NULL; | 1045 | cp->shandle = NULL; |
1030 | GNUNET_free (cp->msg); | 1046 | GNUNET_free (cp->msg); |
@@ -1037,7 +1053,7 @@ clear_msg (void *cls, int result) | |||
1037 | * | 1053 | * |
1038 | * @param cls the closure from GNUNET_HELPER_start() | 1054 | * @param cls the closure from GNUNET_HELPER_start() |
1039 | */ | 1055 | */ |
1040 | static void | 1056 | static void |
1041 | helper_exp_cb (void *cls) | 1057 | helper_exp_cb (void *cls) |
1042 | { | 1058 | { |
1043 | struct GNUNET_TESTBED_ControllerProc *cp = cls; | 1059 | struct GNUNET_TESTBED_ControllerProc *cp = cls; |
@@ -1059,7 +1075,7 @@ helper_exp_cb (void *cls) | |||
1059 | * | 1075 | * |
1060 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 1076 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
1061 | */ | 1077 | */ |
1062 | static void | 1078 | static void |
1063 | opstart_link_controllers (void *cls) | 1079 | opstart_link_controllers (void *cls) |
1064 | { | 1080 | { |
1065 | struct OperationContext *opc = cls; | 1081 | struct OperationContext *opc = cls; |
@@ -1079,7 +1095,7 @@ opstart_link_controllers (void *cls) | |||
1079 | * | 1095 | * |
1080 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 1096 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
1081 | */ | 1097 | */ |
1082 | static void | 1098 | static void |
1083 | oprelease_link_controllers (void *cls) | 1099 | oprelease_link_controllers (void *cls) |
1084 | { | 1100 | { |
1085 | struct OperationContext *opc = cls; | 1101 | struct OperationContext *opc = cls; |
@@ -1115,24 +1131,24 @@ oprelease_link_controllers (void *cls) | |||
1115 | */ | 1131 | */ |
1116 | struct GNUNET_TESTBED_ControllerProc * | 1132 | struct GNUNET_TESTBED_ControllerProc * |
1117 | GNUNET_TESTBED_controller_start (const char *controller_ip, | 1133 | GNUNET_TESTBED_controller_start (const char *controller_ip, |
1118 | struct GNUNET_TESTBED_Host *host, | 1134 | struct GNUNET_TESTBED_Host *host, |
1119 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 1135 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
1120 | GNUNET_TESTBED_ControllerStatusCallback cb, | 1136 | GNUNET_TESTBED_ControllerStatusCallback cb, |
1121 | void *cls) | 1137 | void *cls) |
1122 | { | 1138 | { |
1123 | struct GNUNET_TESTBED_ControllerProc *cp; | 1139 | struct GNUNET_TESTBED_ControllerProc *cp; |
1124 | struct GNUNET_TESTBED_HelperInit *msg; | 1140 | struct GNUNET_TESTBED_HelperInit *msg; |
1125 | 1141 | ||
1126 | cp = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_ControllerProc)); | 1142 | cp = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_ControllerProc)); |
1127 | if ((NULL == host) || (0 == GNUNET_TESTBED_host_get_id_ (host))) | 1143 | if ((NULL == host) || (0 == GNUNET_TESTBED_host_get_id_ (host))) |
1128 | { | 1144 | { |
1129 | char * const binary_argv[] = { | 1145 | char *const binary_argv[] = { |
1130 | "gnunet-testbed-helper", NULL | 1146 | "gnunet-testbed-helper", NULL |
1131 | }; | 1147 | }; |
1132 | 1148 | ||
1133 | cp->helper = GNUNET_HELPER_start (GNUNET_YES, | 1149 | cp->helper = |
1134 | "gnunet-testbed-helper", binary_argv, | 1150 | GNUNET_HELPER_start (GNUNET_YES, "gnunet-testbed-helper", binary_argv, |
1135 | &helper_mst, &helper_exp_cb, cp); | 1151 | &helper_mst, &helper_exp_cb, cp); |
1136 | } | 1152 | } |
1137 | else | 1153 | else |
1138 | { | 1154 | { |
@@ -1146,7 +1162,7 @@ GNUNET_TESTBED_controller_start (const char *controller_ip, | |||
1146 | GNUNET_asprintf (&cp->port, "%u", GNUNET_TESTBED_host_get_ssh_port_ (host)); | 1162 | GNUNET_asprintf (&cp->port, "%u", GNUNET_TESTBED_host_get_ssh_port_ (host)); |
1147 | if (NULL == username) | 1163 | if (NULL == username) |
1148 | GNUNET_asprintf (&cp->dst, "%s", hostname); | 1164 | GNUNET_asprintf (&cp->dst, "%s", hostname); |
1149 | else | 1165 | else |
1150 | GNUNET_asprintf (&cp->dst, "%s@%s", username, hostname); | 1166 | GNUNET_asprintf (&cp->dst, "%s@%s", username, hostname); |
1151 | LOG_DEBUG ("Starting SSH to destination %s\n", cp->dst); | 1167 | LOG_DEBUG ("Starting SSH to destination %s\n", cp->dst); |
1152 | argp = 0; | 1168 | argp = 0; |
@@ -1159,9 +1175,9 @@ GNUNET_TESTBED_controller_start (const char *controller_ip, | |||
1159 | remote_args[argp++] = "gnunet-testbed-helper"; | 1175 | remote_args[argp++] = "gnunet-testbed-helper"; |
1160 | remote_args[argp++] = NULL; | 1176 | remote_args[argp++] = NULL; |
1161 | GNUNET_assert (argp == 8); | 1177 | GNUNET_assert (argp == 8); |
1162 | cp->helper = GNUNET_HELPER_start (GNUNET_NO, | 1178 | cp->helper = |
1163 | "ssh", remote_args, | 1179 | GNUNET_HELPER_start (GNUNET_NO, "ssh", remote_args, &helper_mst, |
1164 | &helper_mst, &helper_exp_cb, cp); | 1180 | &helper_exp_cb, cp); |
1165 | } | 1181 | } |
1166 | if (NULL == cp->helper) | 1182 | if (NULL == cp->helper) |
1167 | { | 1183 | { |
@@ -1175,8 +1191,8 @@ GNUNET_TESTBED_controller_start (const char *controller_ip, | |||
1175 | cp->cls = cls; | 1191 | cp->cls = cls; |
1176 | msg = GNUNET_TESTBED_create_helper_init_msg_ (controller_ip, cfg); | 1192 | msg = GNUNET_TESTBED_create_helper_init_msg_ (controller_ip, cfg); |
1177 | cp->msg = &msg->header; | 1193 | cp->msg = &msg->header; |
1178 | cp->shandle = GNUNET_HELPER_send (cp->helper, &msg->header, GNUNET_NO, | 1194 | cp->shandle = |
1179 | &clear_msg, cp); | 1195 | GNUNET_HELPER_send (cp->helper, &msg->header, GNUNET_NO, &clear_msg, cp); |
1180 | if (NULL == cp->shandle) | 1196 | if (NULL == cp->shandle) |
1181 | { | 1197 | { |
1182 | GNUNET_free (msg); | 1198 | GNUNET_free (msg); |
@@ -1226,11 +1242,11 @@ GNUNET_TESTBED_controller_stop (struct GNUNET_TESTBED_ControllerProc *cproc) | |||
1226 | * @return handle to the controller | 1242 | * @return handle to the controller |
1227 | */ | 1243 | */ |
1228 | struct GNUNET_TESTBED_Controller * | 1244 | struct GNUNET_TESTBED_Controller * |
1229 | GNUNET_TESTBED_controller_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | 1245 | GNUNET_TESTBED_controller_connect (const struct GNUNET_CONFIGURATION_Handle |
1230 | struct GNUNET_TESTBED_Host *host, | 1246 | *cfg, struct GNUNET_TESTBED_Host *host, |
1231 | uint64_t event_mask, | 1247 | uint64_t event_mask, |
1232 | GNUNET_TESTBED_ControllerCallback cc, | 1248 | GNUNET_TESTBED_ControllerCallback cc, |
1233 | void *cc_cls) | 1249 | void *cc_cls) |
1234 | { | 1250 | { |
1235 | struct GNUNET_TESTBED_Controller *controller; | 1251 | struct GNUNET_TESTBED_Controller *controller; |
1236 | struct GNUNET_TESTBED_InitMessage *msg; | 1252 | struct GNUNET_TESTBED_InitMessage *msg; |
@@ -1259,7 +1275,7 @@ GNUNET_TESTBED_controller_connect (const struct GNUNET_CONFIGURATION_Handle *cfg | |||
1259 | controller->cc_cls = cc_cls; | 1275 | controller->cc_cls = cc_cls; |
1260 | controller->event_mask = event_mask; | 1276 | controller->event_mask = event_mask; |
1261 | controller->cfg = GNUNET_CONFIGURATION_dup (cfg); | 1277 | controller->cfg = GNUNET_CONFIGURATION_dup (cfg); |
1262 | controller->client = GNUNET_CLIENT_connect ("testbed", controller->cfg); | 1278 | controller->client = GNUNET_CLIENT_connect ("testbed", controller->cfg); |
1263 | if (NULL == controller->client) | 1279 | if (NULL == controller->client) |
1264 | { | 1280 | { |
1265 | GNUNET_TESTBED_controller_disconnect (controller); | 1281 | GNUNET_TESTBED_controller_disconnect (controller); |
@@ -1271,8 +1287,8 @@ GNUNET_TESTBED_controller_connect (const struct GNUNET_CONFIGURATION_Handle *cfg | |||
1271 | if (NULL == host) /* If the above host create fails */ | 1287 | if (NULL == host) /* If the above host create fails */ |
1272 | { | 1288 | { |
1273 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1289 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1274 | "Treating NULL host as localhost. Multiple references to localhost " | 1290 | "Treating NULL host as localhost. Multiple references to localhost " |
1275 | "may break when localhost freed before calling disconnect \n"); | 1291 | "may break when localhost freed before calling disconnect \n"); |
1276 | host = GNUNET_TESTBED_host_lookup_by_id_ (0); | 1292 | host = GNUNET_TESTBED_host_lookup_by_id_ (0); |
1277 | } | 1293 | } |
1278 | else | 1294 | else |
@@ -1284,24 +1300,26 @@ GNUNET_TESTBED_controller_connect (const struct GNUNET_CONFIGURATION_Handle *cfg | |||
1284 | GNUNET_TESTBED_mark_host_registered_at_ (host, controller); | 1300 | GNUNET_TESTBED_mark_host_registered_at_ (host, controller); |
1285 | controller->host = host; | 1301 | controller->host = host; |
1286 | controller->opq_parallel_operations = | 1302 | controller->opq_parallel_operations = |
1287 | GNUNET_TESTBED_operation_queue_create_ ((unsigned int) | 1303 | GNUNET_TESTBED_operation_queue_create_ ((unsigned int) |
1288 | max_parallel_operations); | 1304 | max_parallel_operations); |
1289 | controller->opq_parallel_service_connections = | 1305 | controller->opq_parallel_service_connections = |
1290 | GNUNET_TESTBED_operation_queue_create_ ((unsigned int) | 1306 | GNUNET_TESTBED_operation_queue_create_ ((unsigned int) |
1291 | max_parallel_service_connections); | 1307 | max_parallel_service_connections); |
1292 | controller_hostname = GNUNET_TESTBED_host_get_hostname_ (host); | 1308 | controller_hostname = GNUNET_TESTBED_host_get_hostname_ (host); |
1293 | if (NULL == controller_hostname) | 1309 | if (NULL == controller_hostname) |
1294 | controller_hostname = "127.0.0.1"; | 1310 | controller_hostname = "127.0.0.1"; |
1295 | msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_InitMessage) | 1311 | msg = |
1296 | + strlen (controller_hostname) + 1); | 1312 | GNUNET_malloc (sizeof (struct GNUNET_TESTBED_InitMessage) + |
1313 | strlen (controller_hostname) + 1); | ||
1297 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_INIT); | 1314 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_INIT); |
1298 | msg->header.size = htons (sizeof (struct GNUNET_TESTBED_InitMessage) | 1315 | msg->header.size = |
1299 | + strlen (controller_hostname) + 1); | 1316 | htons (sizeof (struct GNUNET_TESTBED_InitMessage) + |
1317 | strlen (controller_hostname) + 1); | ||
1300 | msg->host_id = htonl (GNUNET_TESTBED_host_get_id_ (host)); | 1318 | msg->host_id = htonl (GNUNET_TESTBED_host_get_id_ (host)); |
1301 | msg->event_mask = GNUNET_htonll (controller->event_mask); | 1319 | msg->event_mask = GNUNET_htonll (controller->event_mask); |
1302 | strcpy ((char *) &msg[1], controller_hostname); | 1320 | strcpy ((char *) &msg[1], controller_hostname); |
1303 | GNUNET_TESTBED_queue_message_ (controller, (struct GNUNET_MessageHeader *) | 1321 | GNUNET_TESTBED_queue_message_ (controller, |
1304 | msg); | 1322 | (struct GNUNET_MessageHeader *) msg); |
1305 | return controller; | 1323 | return controller; |
1306 | } | 1324 | } |
1307 | 1325 | ||
@@ -1312,7 +1330,7 @@ GNUNET_TESTBED_controller_connect (const struct GNUNET_CONFIGURATION_Handle *cfg | |||
1312 | * should not be run for each peer but instead be shared | 1330 | * should not be run for each peer but instead be shared |
1313 | * across N peers on the specified host. This function | 1331 | * across N peers on the specified host. This function |
1314 | * must be called before any peers are created at the host. | 1332 | * must be called before any peers are created at the host. |
1315 | * | 1333 | * |
1316 | * @param controller controller to configure | 1334 | * @param controller controller to configure |
1317 | * @param service_name name of the service to share | 1335 | * @param service_name name of the service to share |
1318 | * @param num_peers number of peers that should share one instance | 1336 | * @param num_peers number of peers that should share one instance |
@@ -1320,24 +1338,27 @@ GNUNET_TESTBED_controller_connect (const struct GNUNET_CONFIGURATION_Handle *cfg | |||
1320 | * use 0 to disable the service | 1338 | * use 0 to disable the service |
1321 | */ | 1339 | */ |
1322 | void | 1340 | void |
1323 | GNUNET_TESTBED_controller_configure_sharing (struct GNUNET_TESTBED_Controller *controller, | 1341 | GNUNET_TESTBED_controller_configure_sharing (struct GNUNET_TESTBED_Controller |
1324 | const char *service_name, | 1342 | *controller, |
1325 | uint32_t num_peers) | 1343 | const char *service_name, |
1344 | uint32_t num_peers) | ||
1326 | { | 1345 | { |
1327 | struct GNUNET_TESTBED_ConfigureSharedServiceMessage *msg; | 1346 | struct GNUNET_TESTBED_ConfigureSharedServiceMessage *msg; |
1328 | uint16_t service_name_size; | 1347 | uint16_t service_name_size; |
1329 | uint16_t msg_size; | 1348 | uint16_t msg_size; |
1330 | 1349 | ||
1331 | service_name_size = strlen (service_name) + 1; | 1350 | service_name_size = strlen (service_name) + 1; |
1332 | msg_size = sizeof (struct GNUNET_TESTBED_ConfigureSharedServiceMessage) | 1351 | msg_size = |
1333 | + service_name_size; | 1352 | sizeof (struct GNUNET_TESTBED_ConfigureSharedServiceMessage) + |
1353 | service_name_size; | ||
1334 | msg = GNUNET_malloc (msg_size); | 1354 | msg = GNUNET_malloc (msg_size); |
1335 | msg->header.size = htons (msg_size); | 1355 | msg->header.size = htons (msg_size); |
1336 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_SERVICESHARE); | 1356 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_SERVICESHARE); |
1337 | msg->host_id = htonl (GNUNET_TESTBED_host_get_id_ (controller->host)); | 1357 | msg->host_id = htonl (GNUNET_TESTBED_host_get_id_ (controller->host)); |
1338 | msg->num_peers = htonl (num_peers); | 1358 | msg->num_peers = htonl (num_peers); |
1339 | memcpy (&msg[1], service_name, service_name_size); | 1359 | memcpy (&msg[1], service_name, service_name_size); |
1340 | GNUNET_TESTBED_queue_message_ (controller, (struct GNUNET_MessageHeader *) msg); | 1360 | GNUNET_TESTBED_queue_message_ (controller, |
1361 | (struct GNUNET_MessageHeader *) msg); | ||
1341 | } | 1362 | } |
1342 | 1363 | ||
1343 | 1364 | ||
@@ -1347,18 +1368,18 @@ GNUNET_TESTBED_controller_configure_sharing (struct GNUNET_TESTBED_Controller *c | |||
1347 | * @param controller handle to controller to stop | 1368 | * @param controller handle to controller to stop |
1348 | */ | 1369 | */ |
1349 | void | 1370 | void |
1350 | GNUNET_TESTBED_controller_disconnect (struct GNUNET_TESTBED_Controller *controller) | 1371 | GNUNET_TESTBED_controller_disconnect (struct GNUNET_TESTBED_Controller |
1372 | *controller) | ||
1351 | { | 1373 | { |
1352 | struct MessageQueue *mq_entry; | 1374 | struct MessageQueue *mq_entry; |
1353 | 1375 | ||
1354 | if (NULL != controller->th) | 1376 | if (NULL != controller->th) |
1355 | GNUNET_CLIENT_notify_transmit_ready_cancel (controller->th); | 1377 | GNUNET_CLIENT_notify_transmit_ready_cancel (controller->th); |
1356 | /* Clear the message queue */ | 1378 | /* Clear the message queue */ |
1357 | while (NULL != (mq_entry = controller->mq_head)) | 1379 | while (NULL != (mq_entry = controller->mq_head)) |
1358 | { | 1380 | { |
1359 | GNUNET_CONTAINER_DLL_remove (controller->mq_head, | 1381 | GNUNET_CONTAINER_DLL_remove (controller->mq_head, controller->mq_tail, |
1360 | controller->mq_tail, | 1382 | mq_entry); |
1361 | mq_entry); | ||
1362 | GNUNET_free (mq_entry->msg); | 1383 | GNUNET_free (mq_entry->msg); |
1363 | GNUNET_free (mq_entry); | 1384 | GNUNET_free (mq_entry); |
1364 | } | 1385 | } |
@@ -1369,7 +1390,7 @@ GNUNET_TESTBED_controller_disconnect (struct GNUNET_TESTBED_Controller *controll | |||
1369 | GNUNET_TESTBED_host_destroy (controller->host); | 1390 | GNUNET_TESTBED_host_destroy (controller->host); |
1370 | GNUNET_TESTBED_operation_queue_destroy_ (controller->opq_parallel_operations); | 1391 | GNUNET_TESTBED_operation_queue_destroy_ (controller->opq_parallel_operations); |
1371 | GNUNET_TESTBED_operation_queue_destroy_ | 1392 | GNUNET_TESTBED_operation_queue_destroy_ |
1372 | (controller->opq_parallel_service_connections); | 1393 | (controller->opq_parallel_service_connections); |
1373 | GNUNET_free (controller); | 1394 | GNUNET_free (controller); |
1374 | } | 1395 | } |
1375 | 1396 | ||
@@ -1384,7 +1405,7 @@ GNUNET_TESTBED_controller_disconnect (struct GNUNET_TESTBED_Controller *controll | |||
1384 | * will be invalid. Cannot be NULL. | 1405 | * will be invalid. Cannot be NULL. |
1385 | * @param cc_cls the closure for the cc | 1406 | * @param cc_cls the closure for the cc |
1386 | * @return handle to the host registration which can be used to cancel the | 1407 | * @return handle to the host registration which can be used to cancel the |
1387 | * registration | 1408 | * registration |
1388 | */ | 1409 | */ |
1389 | struct GNUNET_TESTBED_HostRegistrationHandle * | 1410 | struct GNUNET_TESTBED_HostRegistrationHandle * |
1390 | GNUNET_TESTBED_register_host (struct GNUNET_TESTBED_Controller *controller, | 1411 | GNUNET_TESTBED_register_host (struct GNUNET_TESTBED_Controller *controller, |
@@ -1404,11 +1425,10 @@ GNUNET_TESTBED_register_host (struct GNUNET_TESTBED_Controller *controller, | |||
1404 | hostname = GNUNET_TESTBED_host_get_hostname_ (host); | 1425 | hostname = GNUNET_TESTBED_host_get_hostname_ (host); |
1405 | if (GNUNET_YES == GNUNET_TESTBED_is_host_registered_ (host, controller)) | 1426 | if (GNUNET_YES == GNUNET_TESTBED_is_host_registered_ (host, controller)) |
1406 | { | 1427 | { |
1407 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1428 | LOG (GNUNET_ERROR_TYPE_WARNING, "Host hostname: %s already registered\n", |
1408 | "Host hostname: %s already registered\n", | ||
1409 | (NULL == hostname) ? "localhost" : hostname); | 1429 | (NULL == hostname) ? "localhost" : hostname); |
1410 | return NULL; | 1430 | return NULL; |
1411 | } | 1431 | } |
1412 | rh = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_HostRegistrationHandle)); | 1432 | rh = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_HostRegistrationHandle)); |
1413 | rh->host = host; | 1433 | rh->host = host; |
1414 | rh->c = controller; | 1434 | rh->c = controller; |
@@ -1436,7 +1456,8 @@ GNUNET_TESTBED_register_host (struct GNUNET_TESTBED_Controller *controller, | |||
1436 | if (NULL != username) | 1456 | if (NULL != username) |
1437 | memcpy (&msg[1], username, user_name_length); | 1457 | memcpy (&msg[1], username, user_name_length); |
1438 | strcpy (((void *) &msg[1]) + user_name_length, hostname); | 1458 | strcpy (((void *) &msg[1]) + user_name_length, hostname); |
1439 | GNUNET_TESTBED_queue_message_ (controller, (struct GNUNET_MessageHeader *) msg); | 1459 | GNUNET_TESTBED_queue_message_ (controller, |
1460 | (struct GNUNET_MessageHeader *) msg); | ||
1440 | return rh; | 1461 | return rh; |
1441 | } | 1462 | } |
1442 | 1463 | ||
@@ -1458,7 +1479,7 @@ GNUNET_TESTBED_cancel_registration (struct GNUNET_TESTBED_HostRegistrationHandle | |||
1458 | return; | 1479 | return; |
1459 | } | 1480 | } |
1460 | handle->c->rh = NULL; | 1481 | handle->c->rh = NULL; |
1461 | GNUNET_free (handle); | 1482 | GNUNET_free (handle); |
1462 | } | 1483 | } |
1463 | 1484 | ||
1464 | 1485 | ||
@@ -1479,29 +1500,28 @@ GNUNET_TESTBED_cancel_registration (struct GNUNET_TESTBED_HostRegistrationHandle | |||
1479 | */ | 1500 | */ |
1480 | struct GNUNET_TESTBED_Operation * | 1501 | struct GNUNET_TESTBED_Operation * |
1481 | GNUNET_TESTBED_controller_link_2 (struct GNUNET_TESTBED_Controller *master, | 1502 | GNUNET_TESTBED_controller_link_2 (struct GNUNET_TESTBED_Controller *master, |
1482 | struct GNUNET_TESTBED_Host *delegated_host, | 1503 | struct GNUNET_TESTBED_Host *delegated_host, |
1483 | struct GNUNET_TESTBED_Host *slave_host, | 1504 | struct GNUNET_TESTBED_Host *slave_host, |
1484 | const char *sxcfg, | 1505 | const char *sxcfg, size_t sxcfg_size, |
1485 | size_t sxcfg_size, | 1506 | size_t scfg_size, int is_subordinate) |
1486 | size_t scfg_size, | ||
1487 | int is_subordinate) | ||
1488 | { | 1507 | { |
1489 | struct OperationContext *opc; | 1508 | struct OperationContext *opc; |
1490 | struct GNUNET_TESTBED_ControllerLinkMessage *msg; | 1509 | struct GNUNET_TESTBED_ControllerLinkMessage *msg; |
1491 | uint16_t msg_size; | 1510 | uint16_t msg_size; |
1492 | 1511 | ||
1493 | GNUNET_assert (GNUNET_YES == | 1512 | GNUNET_assert (GNUNET_YES == |
1494 | GNUNET_TESTBED_is_host_registered_ (delegated_host, master)); | 1513 | GNUNET_TESTBED_is_host_registered_ (delegated_host, master)); |
1495 | if ((NULL != slave_host) && (0 != GNUNET_TESTBED_host_get_id_ (slave_host))) | 1514 | if ((NULL != slave_host) && (0 != GNUNET_TESTBED_host_get_id_ (slave_host))) |
1496 | GNUNET_assert (GNUNET_YES == | 1515 | GNUNET_assert (GNUNET_YES == |
1497 | GNUNET_TESTBED_is_host_registered_ (slave_host, master)); | 1516 | GNUNET_TESTBED_is_host_registered_ (slave_host, master)); |
1498 | msg_size = sxcfg_size + sizeof (struct GNUNET_TESTBED_ControllerLinkMessage); | 1517 | msg_size = sxcfg_size + sizeof (struct GNUNET_TESTBED_ControllerLinkMessage); |
1499 | msg = GNUNET_malloc (msg_size); | 1518 | msg = GNUNET_malloc (msg_size); |
1500 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_LCONTROLLERS); | 1519 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_LCONTROLLERS); |
1501 | msg->header.size = htons (msg_size); | 1520 | msg->header.size = htons (msg_size); |
1502 | msg->delegated_host_id = htonl (GNUNET_TESTBED_host_get_id_ (delegated_host)); | 1521 | msg->delegated_host_id = htonl (GNUNET_TESTBED_host_get_id_ (delegated_host)); |
1503 | msg->slave_host_id = htonl (GNUNET_TESTBED_host_get_id_ | 1522 | msg->slave_host_id = |
1504 | ((NULL != slave_host) ? slave_host : master->host)); | 1523 | htonl (GNUNET_TESTBED_host_get_id_ |
1524 | ((NULL != slave_host) ? slave_host : master->host)); | ||
1505 | msg->config_size = htons ((uint16_t) scfg_size); | 1525 | msg->config_size = htons ((uint16_t) scfg_size); |
1506 | msg->is_subordinate = (GNUNET_YES == is_subordinate) ? 1 : 0; | 1526 | msg->is_subordinate = (GNUNET_YES == is_subordinate) ? 1 : 0; |
1507 | memcpy (&msg[1], sxcfg, sxcfg_size); | 1527 | memcpy (&msg[1], sxcfg, sxcfg_size); |
@@ -1512,8 +1532,9 @@ GNUNET_TESTBED_controller_link_2 (struct GNUNET_TESTBED_Controller *master, | |||
1512 | opc->id = master->operation_counter++; | 1532 | opc->id = master->operation_counter++; |
1513 | opc->state = OPC_STATE_INIT; | 1533 | opc->state = OPC_STATE_INIT; |
1514 | msg->operation_id = GNUNET_htonll (opc->id); | 1534 | msg->operation_id = GNUNET_htonll (opc->id); |
1515 | opc->op = GNUNET_TESTBED_operation_create_ (opc, &opstart_link_controllers, | 1535 | opc->op = |
1516 | &oprelease_link_controllers); | 1536 | GNUNET_TESTBED_operation_create_ (opc, &opstart_link_controllers, |
1537 | &oprelease_link_controllers); | ||
1517 | GNUNET_TESTBED_operation_queue_insert_ (master->opq_parallel_operations, | 1538 | GNUNET_TESTBED_operation_queue_insert_ (master->opq_parallel_operations, |
1518 | opc->op); | 1539 | opc->op); |
1519 | return opc->op; | 1540 | return opc->op; |
@@ -1526,24 +1547,24 @@ GNUNET_TESTBED_controller_link_2 (struct GNUNET_TESTBED_Controller *master, | |||
1526 | * @param config the serialized configuration | 1547 | * @param config the serialized configuration |
1527 | * @param size the size of config | 1548 | * @param size the size of config |
1528 | * @param xconfig will be set to the compressed configuration (memory is fresly | 1549 | * @param xconfig will be set to the compressed configuration (memory is fresly |
1529 | * allocated) | 1550 | * allocated) |
1530 | * @return the size of the xconfig | 1551 | * @return the size of the xconfig |
1531 | */ | 1552 | */ |
1532 | size_t | 1553 | size_t |
1533 | GNUNET_TESTBED_compress_config_ (const char *config, size_t size, | 1554 | GNUNET_TESTBED_compress_config_ (const char *config, size_t size, |
1534 | char **xconfig) | 1555 | char **xconfig) |
1535 | { | 1556 | { |
1536 | size_t xsize; | 1557 | size_t xsize; |
1537 | 1558 | ||
1538 | xsize = compressBound ((uLong) size); | 1559 | xsize = compressBound ((uLong) size); |
1539 | *xconfig = GNUNET_malloc (xsize); | 1560 | *xconfig = GNUNET_malloc (xsize); |
1540 | GNUNET_assert (Z_OK == | 1561 | GNUNET_assert (Z_OK == |
1541 | compress2 ((Bytef *)* xconfig, (uLongf *) &xsize, | 1562 | compress2 ((Bytef *) * xconfig, (uLongf *) & xsize, |
1542 | (const Bytef *) config, (uLongf) size, | 1563 | (const Bytef *) config, (uLongf) size, |
1543 | Z_BEST_SPEED)); | 1564 | Z_BEST_SPEED)); |
1544 | return xsize; | 1565 | return xsize; |
1545 | } | 1566 | } |
1546 | 1567 | ||
1547 | 1568 | ||
1548 | /** | 1569 | /** |
1549 | * Create a link from slave controller to delegated controller. Whenever the | 1570 | * Create a link from slave controller to delegated controller. Whenever the |
@@ -1559,7 +1580,7 @@ GNUNET_TESTBED_compress_config_ (const char *config, size_t size, | |||
1559 | * | 1580 | * |
1560 | * @param master handle to the master controller who creates the association | 1581 | * @param master handle to the master controller who creates the association |
1561 | * @param delegated_host requests to which host should be delegated | 1582 | * @param delegated_host requests to which host should be delegated |
1562 | * @param slave_host which host is used to run the slave controller | 1583 | * @param slave_host which host is used to run the slave controller |
1563 | * @param slave_cfg configuration to use for the slave controller | 1584 | * @param slave_cfg configuration to use for the slave controller |
1564 | * @param is_subordinate GNUNET_YES if the slave should be started (and stopped) | 1585 | * @param is_subordinate GNUNET_YES if the slave should be started (and stopped) |
1565 | * by the master controller; GNUNET_NO if we are just | 1586 | * by the master controller; GNUNET_NO if we are just |
@@ -1568,31 +1589,29 @@ GNUNET_TESTBED_compress_config_ (const char *config, size_t size, | |||
1568 | */ | 1589 | */ |
1569 | struct GNUNET_TESTBED_Operation * | 1590 | struct GNUNET_TESTBED_Operation * |
1570 | GNUNET_TESTBED_controller_link (struct GNUNET_TESTBED_Controller *master, | 1591 | GNUNET_TESTBED_controller_link (struct GNUNET_TESTBED_Controller *master, |
1571 | struct GNUNET_TESTBED_Host *delegated_host, | 1592 | struct GNUNET_TESTBED_Host *delegated_host, |
1572 | struct GNUNET_TESTBED_Host *slave_host, | 1593 | struct GNUNET_TESTBED_Host *slave_host, |
1573 | const struct GNUNET_CONFIGURATION_Handle *slave_cfg, | 1594 | const struct GNUNET_CONFIGURATION_Handle |
1574 | int is_subordinate) | 1595 | *slave_cfg, int is_subordinate) |
1575 | { | 1596 | { |
1576 | struct GNUNET_TESTBED_Operation *op; | 1597 | struct GNUNET_TESTBED_Operation *op; |
1577 | char *config; | 1598 | char *config; |
1578 | char *cconfig; | 1599 | char *cconfig; |
1579 | size_t cc_size; | 1600 | size_t cc_size; |
1580 | size_t config_size; | 1601 | size_t config_size; |
1581 | 1602 | ||
1582 | GNUNET_assert (GNUNET_YES == | 1603 | GNUNET_assert (GNUNET_YES == |
1583 | GNUNET_TESTBED_is_host_registered_ (delegated_host, master)); | 1604 | GNUNET_TESTBED_is_host_registered_ (delegated_host, master)); |
1584 | if ((NULL != slave_host) && (0 != GNUNET_TESTBED_host_get_id_ (slave_host))) | 1605 | if ((NULL != slave_host) && (0 != GNUNET_TESTBED_host_get_id_ (slave_host))) |
1585 | GNUNET_assert (GNUNET_YES == | 1606 | GNUNET_assert (GNUNET_YES == |
1586 | GNUNET_TESTBED_is_host_registered_ (slave_host, master)); | 1607 | GNUNET_TESTBED_is_host_registered_ (slave_host, master)); |
1587 | config = GNUNET_CONFIGURATION_serialize (slave_cfg, &config_size); | 1608 | config = GNUNET_CONFIGURATION_serialize (slave_cfg, &config_size); |
1588 | cc_size = GNUNET_TESTBED_compress_config_ (config, config_size, &cconfig); | 1609 | cc_size = GNUNET_TESTBED_compress_config_ (config, config_size, &cconfig); |
1589 | GNUNET_free (config); | 1610 | GNUNET_free (config); |
1590 | GNUNET_assert ((UINT16_MAX - | 1611 | GNUNET_assert ((UINT16_MAX - sizeof (struct GNUNET_TESTBED_ControllerLinkMessage)) >= cc_size); /* Configuration doesn't fit in 1 message */ |
1591 | sizeof (struct GNUNET_TESTBED_ControllerLinkMessage)) | ||
1592 | >= cc_size); /* Configuration doesn't fit in 1 message */ | ||
1593 | op = GNUNET_TESTBED_controller_link_2 (master, delegated_host, slave_host, | 1612 | op = GNUNET_TESTBED_controller_link_2 (master, delegated_host, slave_host, |
1594 | (const char *) cconfig, | 1613 | (const char *) cconfig, cc_size, |
1595 | cc_size, config_size, is_subordinate); | 1614 | config_size, is_subordinate); |
1596 | GNUNET_free (cconfig); | 1615 | GNUNET_free (cconfig); |
1597 | return op; | 1616 | return op; |
1598 | } | 1617 | } |
@@ -1608,8 +1627,9 @@ GNUNET_TESTBED_controller_link (struct GNUNET_TESTBED_Controller *master, | |||
1608 | * be written to. | 1627 | * be written to. |
1609 | */ | 1628 | */ |
1610 | void | 1629 | void |
1611 | GNUNET_TESTBED_overlay_write_topology_to_file (struct GNUNET_TESTBED_Controller *controller, | 1630 | GNUNET_TESTBED_overlay_write_topology_to_file (struct GNUNET_TESTBED_Controller |
1612 | const char *filename) | 1631 | *controller, |
1632 | const char *filename) | ||
1613 | { | 1633 | { |
1614 | GNUNET_break (0); | 1634 | GNUNET_break (0); |
1615 | } | 1635 | } |
@@ -1626,7 +1646,8 @@ GNUNET_TESTBED_overlay_write_topology_to_file (struct GNUNET_TESTBED_Controller | |||
1626 | */ | 1646 | */ |
1627 | struct GNUNET_TESTBED_HelperInit * | 1647 | struct GNUNET_TESTBED_HelperInit * |
1628 | GNUNET_TESTBED_create_helper_init_msg_ (const char *cname, | 1648 | GNUNET_TESTBED_create_helper_init_msg_ (const char *cname, |
1629 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 1649 | const struct GNUNET_CONFIGURATION_Handle |
1650 | *cfg) | ||
1630 | { | 1651 | { |
1631 | struct GNUNET_TESTBED_HelperInit *msg; | 1652 | struct GNUNET_TESTBED_HelperInit *msg; |
1632 | char *config; | 1653 | char *config; |
@@ -1639,13 +1660,13 @@ GNUNET_TESTBED_create_helper_init_msg_ (const char *cname, | |||
1639 | config = GNUNET_CONFIGURATION_serialize (cfg, &config_size); | 1660 | config = GNUNET_CONFIGURATION_serialize (cfg, &config_size); |
1640 | GNUNET_assert (NULL != config); | 1661 | GNUNET_assert (NULL != config); |
1641 | xconfig_size = | 1662 | xconfig_size = |
1642 | GNUNET_TESTBED_compress_config_ (config, config_size, &xconfig); | 1663 | GNUNET_TESTBED_compress_config_ (config, config_size, &xconfig); |
1643 | GNUNET_free (config); | 1664 | GNUNET_free (config); |
1644 | cname_len = strlen (cname); | 1665 | cname_len = strlen (cname); |
1645 | msg_size = xconfig_size + cname_len + 1 + | 1666 | msg_size = |
1646 | sizeof (struct GNUNET_TESTBED_HelperInit); | 1667 | xconfig_size + cname_len + 1 + sizeof (struct GNUNET_TESTBED_HelperInit); |
1647 | msg = GNUNET_realloc (xconfig, msg_size); | 1668 | msg = GNUNET_realloc (xconfig, msg_size); |
1648 | (void) memmove ( ((void *) &msg[1]) + cname_len + 1, msg, xconfig_size); | 1669 | (void) memmove (((void *) &msg[1]) + cname_len + 1, msg, xconfig_size); |
1649 | msg->header.size = htons (msg_size); | 1670 | msg->header.size = htons (msg_size); |
1650 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT); | 1671 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_HELPER_INIT); |
1651 | msg->cname_size = htons (cname_len); | 1672 | msg->cname_size = htons (cname_len); |
@@ -1660,8 +1681,8 @@ GNUNET_TESTBED_create_helper_init_msg_ (const char *cname, | |||
1660 | * of the operation and will ensure that no event | 1681 | * of the operation and will ensure that no event |
1661 | * is generated for the operation. Does NOT guarantee | 1682 | * is generated for the operation. Does NOT guarantee |
1662 | * that the operation will be fully undone (or that | 1683 | * that the operation will be fully undone (or that |
1663 | * nothing ever happened). | 1684 | * nothing ever happened). |
1664 | * | 1685 | * |
1665 | * @param operation operation to cancel | 1686 | * @param operation operation to cancel |
1666 | */ | 1687 | */ |
1667 | void | 1688 | void |
@@ -1677,7 +1698,7 @@ GNUNET_TESTBED_operation_cancel (struct GNUNET_TESTBED_Operation *operation) | |||
1677 | * of type 'operation_finished' to fully remove the operation | 1698 | * of type 'operation_finished' to fully remove the operation |
1678 | * from the operation queue. After calling this function, the | 1699 | * from the operation queue. After calling this function, the |
1679 | * 'op_result' becomes invalid (!). | 1700 | * 'op_result' becomes invalid (!). |
1680 | * | 1701 | * |
1681 | * @param operation operation to signal completion for | 1702 | * @param operation operation to signal completion for |
1682 | */ | 1703 | */ |
1683 | void | 1704 | void |
@@ -1717,18 +1738,20 @@ GNUNET_TESTBED_get_config_from_peerinfo_msg_ (const struct | |||
1717 | uLong config_size; | 1738 | uLong config_size; |
1718 | int ret; | 1739 | int ret; |
1719 | uint16_t msize; | 1740 | uint16_t msize; |
1720 | 1741 | ||
1721 | config_size = (uLong) ntohs (msg->config_size); | 1742 | config_size = (uLong) ntohs (msg->config_size); |
1722 | config = GNUNET_malloc (config_size); | 1743 | config = GNUNET_malloc (config_size); |
1723 | msize = ntohs (msg->header.size); | 1744 | msize = ntohs (msg->header.size); |
1724 | msize -= sizeof (struct GNUNET_TESTBED_PeerConfigurationInformationMessage); | 1745 | msize -= sizeof (struct GNUNET_TESTBED_PeerConfigurationInformationMessage); |
1725 | if (Z_OK != (ret = uncompress ((Bytef *) config, &config_size, | 1746 | if (Z_OK != |
1726 | (const Bytef *) &msg[1], (uLong) msize))) | 1747 | (ret = |
1748 | uncompress ((Bytef *) config, &config_size, (const Bytef *) &msg[1], | ||
1749 | (uLong) msize))) | ||
1727 | GNUNET_assert (0); | 1750 | GNUNET_assert (0); |
1728 | cfg = GNUNET_CONFIGURATION_create (); | 1751 | cfg = GNUNET_CONFIGURATION_create (); |
1729 | GNUNET_assert (GNUNET_OK == | 1752 | GNUNET_assert (GNUNET_OK == |
1730 | GNUNET_CONFIGURATION_deserialize (cfg, config, | 1753 | GNUNET_CONFIGURATION_deserialize (cfg, config, |
1731 | (size_t) config_size, | 1754 | (size_t) config_size, |
1732 | GNUNET_NO)); | 1755 | GNUNET_NO)); |
1733 | GNUNET_free (config); | 1756 | GNUNET_free (config); |
1734 | return cfg; | 1757 | return cfg; |
diff --git a/src/testbed/testbed_api.h b/src/testbed/testbed_api.h index 7f7ab6c94..06ab6d504 100644 --- a/src/testbed/testbed_api.h +++ b/src/testbed/testbed_api.h | |||
@@ -34,48 +34,48 @@ | |||
34 | * Enumeration of operations | 34 | * Enumeration of operations |
35 | */ | 35 | */ |
36 | enum OperationType | 36 | enum OperationType |
37 | { | 37 | { |
38 | /** | 38 | /** |
39 | * Peer create operation | 39 | * Peer create operation |
40 | */ | 40 | */ |
41 | OP_PEER_CREATE, | 41 | OP_PEER_CREATE, |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * Peer start operation | 44 | * Peer start operation |
45 | */ | 45 | */ |
46 | OP_PEER_START, | 46 | OP_PEER_START, |
47 | 47 | ||
48 | /** | 48 | /** |
49 | * Peer stop operation | 49 | * Peer stop operation |
50 | */ | 50 | */ |
51 | OP_PEER_STOP, | 51 | OP_PEER_STOP, |
52 | 52 | ||
53 | /** | 53 | /** |
54 | * Peer destroy operation | 54 | * Peer destroy operation |
55 | */ | 55 | */ |
56 | OP_PEER_DESTROY, | 56 | OP_PEER_DESTROY, |
57 | 57 | ||
58 | /** | 58 | /** |
59 | * Get peer information operation | 59 | * Get peer information operation |
60 | */ | 60 | */ |
61 | OP_PEER_INFO, | 61 | OP_PEER_INFO, |
62 | 62 | ||
63 | /** | 63 | /** |
64 | * Overlay connection operation | 64 | * Overlay connection operation |
65 | */ | 65 | */ |
66 | OP_OVERLAY_CONNECT, | 66 | OP_OVERLAY_CONNECT, |
67 | 67 | ||
68 | /** | 68 | /** |
69 | * Forwarded operation | 69 | * Forwarded operation |
70 | */ | 70 | */ |
71 | OP_FORWARDED, | 71 | OP_FORWARDED, |
72 | 72 | ||
73 | /** | 73 | /** |
74 | * Link controllers operation | 74 | * Link controllers operation |
75 | */ | 75 | */ |
76 | OP_LINK_CONTROLLERS, | 76 | OP_LINK_CONTROLLERS, |
77 | 77 | ||
78 | }; | 78 | }; |
79 | 79 | ||
80 | 80 | ||
81 | /** | 81 | /** |
@@ -130,25 +130,25 @@ struct ControllerLink; | |||
130 | * Enumeration of states of OperationContext | 130 | * Enumeration of states of OperationContext |
131 | */ | 131 | */ |
132 | enum OperationContextState | 132 | enum OperationContextState |
133 | { | 133 | { |
134 | /** | 134 | /** |
135 | * The initial state where the associated operation has just been created | 135 | * The initial state where the associated operation has just been created |
136 | * and is waiting in the operation queues to be started | 136 | * and is waiting in the operation queues to be started |
137 | */ | 137 | */ |
138 | OPC_STATE_INIT = 0, | 138 | OPC_STATE_INIT = 0, |
139 | 139 | ||
140 | /** | 140 | /** |
141 | * The operation has been started. It may occupy some resources which are to | 141 | * The operation has been started. It may occupy some resources which are to |
142 | * be freed if cancelled. | 142 | * be freed if cancelled. |
143 | */ | 143 | */ |
144 | OPC_STATE_STARTED, | 144 | OPC_STATE_STARTED, |
145 | 145 | ||
146 | /** | 146 | /** |
147 | * The operation has finished. The end results of this operation may occupy | 147 | * The operation has finished. The end results of this operation may occupy |
148 | * some resources which are to be freed by operation_done | 148 | * some resources which are to be freed by operation_done |
149 | */ | 149 | */ |
150 | OPC_STATE_FINISHED | 150 | OPC_STATE_FINISHED |
151 | }; | 151 | }; |
152 | 152 | ||
153 | 153 | ||
154 | /** | 154 | /** |
@@ -234,7 +234,7 @@ struct GNUNET_TESTBED_Controller | |||
234 | * The client connection handle to the controller service | 234 | * The client connection handle to the controller service |
235 | */ | 235 | */ |
236 | struct GNUNET_CLIENT_Connection *client; | 236 | struct GNUNET_CLIENT_Connection *client; |
237 | 237 | ||
238 | /** | 238 | /** |
239 | * The head of the message queue | 239 | * The head of the message queue |
240 | */ | 240 | */ |
@@ -262,7 +262,7 @@ struct GNUNET_TESTBED_Controller | |||
262 | 262 | ||
263 | /** | 263 | /** |
264 | * The host registration handle; NULL if no current registration requests are | 264 | * The host registration handle; NULL if no current registration requests are |
265 | * present | 265 | * present |
266 | */ | 266 | */ |
267 | struct GNUNET_TESTBED_HostRegistrationHandle *rh; | 267 | struct GNUNET_TESTBED_HostRegistrationHandle *rh; |
268 | 268 | ||
@@ -290,7 +290,7 @@ struct GNUNET_TESTBED_Controller | |||
290 | * The operation id counter. use current value and increment | 290 | * The operation id counter. use current value and increment |
291 | */ | 291 | */ |
292 | uint64_t operation_counter; | 292 | uint64_t operation_counter; |
293 | 293 | ||
294 | /** | 294 | /** |
295 | * The controller event mask | 295 | * The controller event mask |
296 | */ | 296 | */ |
@@ -316,7 +316,7 @@ struct GNUNET_TESTBED_Controller | |||
316 | */ | 316 | */ |
317 | void | 317 | void |
318 | GNUNET_TESTBED_queue_message_ (struct GNUNET_TESTBED_Controller *controller, | 318 | GNUNET_TESTBED_queue_message_ (struct GNUNET_TESTBED_Controller *controller, |
319 | struct GNUNET_MessageHeader *msg); | 319 | struct GNUNET_MessageHeader *msg); |
320 | 320 | ||
321 | 321 | ||
322 | /** | 322 | /** |
@@ -325,12 +325,12 @@ GNUNET_TESTBED_queue_message_ (struct GNUNET_TESTBED_Controller *controller, | |||
325 | * @param config the serialized configuration | 325 | * @param config the serialized configuration |
326 | * @param size the size of config | 326 | * @param size the size of config |
327 | * @param xconfig will be set to the compressed configuration (memory is fresly | 327 | * @param xconfig will be set to the compressed configuration (memory is fresly |
328 | * allocated) | 328 | * allocated) |
329 | * @return the size of the xconfig | 329 | * @return the size of the xconfig |
330 | */ | 330 | */ |
331 | size_t | 331 | size_t |
332 | GNUNET_TESTBED_compress_config_ (const char *config, size_t size, | 332 | GNUNET_TESTBED_compress_config_ (const char *config, size_t size, |
333 | char **xconfig); | 333 | char **xconfig); |
334 | 334 | ||
335 | 335 | ||
336 | /** | 336 | /** |
@@ -352,8 +352,8 @@ GNUNET_TESTBED_operation_add_ (struct GNUNET_TESTBED_Operation *op); | |||
352 | */ | 352 | */ |
353 | struct GNUNET_TESTBED_HelperInit * | 353 | struct GNUNET_TESTBED_HelperInit * |
354 | GNUNET_TESTBED_create_helper_init_msg_ (const char *cname, | 354 | GNUNET_TESTBED_create_helper_init_msg_ (const char *cname, |
355 | const struct | 355 | const struct GNUNET_CONFIGURATION_Handle |
356 | GNUNET_CONFIGURATION_Handle *cfg); | 356 | *cfg); |
357 | 357 | ||
358 | 358 | ||
359 | /** | 359 | /** |
@@ -368,12 +368,11 @@ GNUNET_TESTBED_create_helper_init_msg_ (const char *cname, | |||
368 | * @param cc the callback to call when reply is available | 368 | * @param cc the callback to call when reply is available |
369 | * @param cc_cls the closure for the above callback | 369 | * @param cc_cls the closure for the above callback |
370 | * @return the operation context which can be used to cancel the forwarded | 370 | * @return the operation context which can be used to cancel the forwarded |
371 | * operation | 371 | * operation |
372 | */ | 372 | */ |
373 | struct OperationContext * | 373 | struct OperationContext * |
374 | GNUNET_TESTBED_forward_operation_msg_ (struct GNUNET_TESTBED_Controller | 374 | GNUNET_TESTBED_forward_operation_msg_ (struct GNUNET_TESTBED_Controller |
375 | * controller, | 375 | *controller, uint64_t operation_id, |
376 | uint64_t operation_id, | ||
377 | const struct GNUNET_MessageHeader *msg, | 376 | const struct GNUNET_MessageHeader *msg, |
378 | GNUNET_CLIENT_MessageHandler cc, | 377 | GNUNET_CLIENT_MessageHandler cc, |
379 | void *cc_cls); | 378 | void *cc_cls); |
diff --git a/src/testbed/testbed_api_hosts.c b/src/testbed/testbed_api_hosts.c index 27731caf8..20e601265 100644 --- a/src/testbed/testbed_api_hosts.c +++ b/src/testbed/testbed_api_hosts.c | |||
@@ -57,7 +57,7 @@ struct RegisteredController | |||
57 | * The controller at which this host is registered | 57 | * The controller at which this host is registered |
58 | */ | 58 | */ |
59 | const struct GNUNET_TESTBED_Controller *controller; | 59 | const struct GNUNET_TESTBED_Controller *controller; |
60 | 60 | ||
61 | /** | 61 | /** |
62 | * The next ptr for DLL | 62 | * The next ptr for DLL |
63 | */ | 63 | */ |
@@ -134,7 +134,7 @@ static uint32_t host_list_size; | |||
134 | 134 | ||
135 | /** | 135 | /** |
136 | * Lookup a host by ID. | 136 | * Lookup a host by ID. |
137 | * | 137 | * |
138 | * @param id global host ID assigned to the host; 0 is | 138 | * @param id global host ID assigned to the host; 0 is |
139 | * reserved to always mean 'localhost' | 139 | * reserved to always mean 'localhost' |
140 | * @return handle to the host, NULL if host not found | 140 | * @return handle to the host, NULL if host not found |
@@ -152,7 +152,7 @@ GNUNET_TESTBED_host_lookup_by_id_ (uint32_t id) | |||
152 | * Create a host by ID; given this host handle, we could not | 152 | * Create a host by ID; given this host handle, we could not |
153 | * run peers at the host, but we can talk about the host | 153 | * run peers at the host, but we can talk about the host |
154 | * internally. | 154 | * internally. |
155 | * | 155 | * |
156 | * @param id global host ID assigned to the host; 0 is | 156 | * @param id global host ID assigned to the host; 0 is |
157 | * reserved to always mean 'localhost' | 157 | * reserved to always mean 'localhost' |
158 | * @return handle to the host, NULL on error | 158 | * @return handle to the host, NULL on error |
@@ -166,13 +166,13 @@ GNUNET_TESTBED_host_create_by_id_ (uint32_t id) | |||
166 | 166 | ||
167 | /** | 167 | /** |
168 | * Obtain the host's unique global ID. | 168 | * Obtain the host's unique global ID. |
169 | * | 169 | * |
170 | * @param host handle to the host, NULL means 'localhost' | 170 | * @param host handle to the host, NULL means 'localhost' |
171 | * @return id global host ID assigned to the host (0 is | 171 | * @return id global host ID assigned to the host (0 is |
172 | * 'localhost', but then obviously not globally unique) | 172 | * 'localhost', but then obviously not globally unique) |
173 | */ | 173 | */ |
174 | uint32_t | 174 | uint32_t |
175 | GNUNET_TESTBED_host_get_id_ (const struct GNUNET_TESTBED_Host *host) | 175 | GNUNET_TESTBED_host_get_id_ (const struct GNUNET_TESTBED_Host * host) |
176 | { | 176 | { |
177 | return host->id; | 177 | return host->id; |
178 | } | 178 | } |
@@ -180,7 +180,7 @@ GNUNET_TESTBED_host_get_id_ (const struct GNUNET_TESTBED_Host *host) | |||
180 | 180 | ||
181 | /** | 181 | /** |
182 | * Obtain the host's hostname. | 182 | * Obtain the host's hostname. |
183 | * | 183 | * |
184 | * @param host handle to the host, NULL means 'localhost' | 184 | * @param host handle to the host, NULL means 'localhost' |
185 | * @return hostname of the host | 185 | * @return hostname of the host |
186 | */ | 186 | */ |
@@ -193,7 +193,7 @@ GNUNET_TESTBED_host_get_hostname_ (const struct GNUNET_TESTBED_Host *host) | |||
193 | 193 | ||
194 | /** | 194 | /** |
195 | * Obtain the host's username | 195 | * Obtain the host's username |
196 | * | 196 | * |
197 | * @param host handle to the host, NULL means 'localhost' | 197 | * @param host handle to the host, NULL means 'localhost' |
198 | * @return username to login to the host | 198 | * @return username to login to the host |
199 | */ | 199 | */ |
@@ -206,12 +206,12 @@ GNUNET_TESTBED_host_get_username_ (const struct GNUNET_TESTBED_Host *host) | |||
206 | 206 | ||
207 | /** | 207 | /** |
208 | * Obtain the host's ssh port | 208 | * Obtain the host's ssh port |
209 | * | 209 | * |
210 | * @param host handle to the host, NULL means 'localhost' | 210 | * @param host handle to the host, NULL means 'localhost' |
211 | * @return username to login to the host | 211 | * @return username to login to the host |
212 | */ | 212 | */ |
213 | uint16_t | 213 | uint16_t |
214 | GNUNET_TESTBED_host_get_ssh_port_ (const struct GNUNET_TESTBED_Host *host) | 214 | GNUNET_TESTBED_host_get_ssh_port_ (const struct GNUNET_TESTBED_Host * host) |
215 | { | 215 | { |
216 | return host->port; | 216 | return host->port; |
217 | } | 217 | } |
@@ -219,7 +219,7 @@ GNUNET_TESTBED_host_get_ssh_port_ (const struct GNUNET_TESTBED_Host *host) | |||
219 | 219 | ||
220 | /** | 220 | /** |
221 | * Create a host to run peers and controllers on. | 221 | * Create a host to run peers and controllers on. |
222 | * | 222 | * |
223 | * @param id global host ID assigned to the host; 0 is | 223 | * @param id global host ID assigned to the host; 0 is |
224 | * reserved to always mean 'localhost' | 224 | * reserved to always mean 'localhost' |
225 | * @param hostname name of the host, use "NULL" for localhost | 225 | * @param hostname name of the host, use "NULL" for localhost |
@@ -228,10 +228,8 @@ GNUNET_TESTBED_host_get_ssh_port_ (const struct GNUNET_TESTBED_Host *host) | |||
228 | * @return handle to the host, NULL on error | 228 | * @return handle to the host, NULL on error |
229 | */ | 229 | */ |
230 | struct GNUNET_TESTBED_Host * | 230 | struct GNUNET_TESTBED_Host * |
231 | GNUNET_TESTBED_host_create_with_id (uint32_t id, | 231 | GNUNET_TESTBED_host_create_with_id (uint32_t id, const char *hostname, |
232 | const char *hostname, | 232 | const char *username, uint16_t port) |
233 | const char *username, | ||
234 | uint16_t port) | ||
235 | { | 233 | { |
236 | struct GNUNET_TESTBED_Host *host; | 234 | struct GNUNET_TESTBED_Host *host; |
237 | uint32_t new_size; | 235 | uint32_t new_size; |
@@ -251,15 +249,15 @@ GNUNET_TESTBED_host_create_with_id (uint32_t id, | |||
251 | new_size += HOST_LIST_GROW_STEP; | 249 | new_size += HOST_LIST_GROW_STEP; |
252 | if (new_size != host_list_size) | 250 | if (new_size != host_list_size) |
253 | { | 251 | { |
254 | host_list = GNUNET_realloc (host_list, sizeof (struct GNUNET_TESTBED_Host *) | 252 | host_list = |
255 | * new_size); | 253 | GNUNET_realloc (host_list, |
256 | (void) memset(&host_list[host_list_size], 0, | 254 | sizeof (struct GNUNET_TESTBED_Host *) * new_size); |
257 | sizeof (struct GNUNET_TESTBED_Host *) * | 255 | (void) memset (&host_list[host_list_size], 0, |
258 | (new_size - host_list_size)); | 256 | sizeof (struct GNUNET_TESTBED_Host *) * (new_size - |
257 | host_list_size)); | ||
259 | host_list_size = new_size; | 258 | host_list_size = new_size; |
260 | } | 259 | } |
261 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 260 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Adding host with id: %u\n", host->id); |
262 | "Adding host with id: %u\n", host->id); | ||
263 | host_list[id] = host; | 261 | host_list[id] = host; |
264 | return host; | 262 | return host; |
265 | } | 263 | } |
@@ -267,24 +265,22 @@ GNUNET_TESTBED_host_create_with_id (uint32_t id, | |||
267 | 265 | ||
268 | /** | 266 | /** |
269 | * Create a host to run peers and controllers on. | 267 | * Create a host to run peers and controllers on. |
270 | * | 268 | * |
271 | * @param hostname name of the host, use "NULL" for localhost | 269 | * @param hostname name of the host, use "NULL" for localhost |
272 | * @param username username to use for the login; may be NULL | 270 | * @param username username to use for the login; may be NULL |
273 | * @param port port number to use for ssh; use 0 to let ssh decide | 271 | * @param port port number to use for ssh; use 0 to let ssh decide |
274 | * @return handle to the host, NULL on error | 272 | * @return handle to the host, NULL on error |
275 | */ | 273 | */ |
276 | struct GNUNET_TESTBED_Host * | 274 | struct GNUNET_TESTBED_Host * |
277 | GNUNET_TESTBED_host_create (const char *hostname, | 275 | GNUNET_TESTBED_host_create (const char *hostname, const char *username, |
278 | const char *username, | 276 | uint16_t port) |
279 | uint16_t port) | ||
280 | { | 277 | { |
281 | static uint32_t uid_generator; | 278 | static uint32_t uid_generator; |
282 | 279 | ||
283 | if (NULL == hostname) | 280 | if (NULL == hostname) |
284 | return GNUNET_TESTBED_host_create_with_id (0, hostname, username, port); | 281 | return GNUNET_TESTBED_host_create_with_id (0, hostname, username, port); |
285 | return GNUNET_TESTBED_host_create_with_id (++uid_generator, | 282 | return GNUNET_TESTBED_host_create_with_id (++uid_generator, hostname, |
286 | hostname, username, | 283 | username, port); |
287 | port); | ||
288 | } | 284 | } |
289 | 285 | ||
290 | 286 | ||
@@ -297,7 +293,7 @@ GNUNET_TESTBED_host_create (const char *hostname, | |||
297 | */ | 293 | */ |
298 | unsigned int | 294 | unsigned int |
299 | GNUNET_TESTBED_hosts_load_from_file (const char *filename, | 295 | GNUNET_TESTBED_hosts_load_from_file (const char *filename, |
300 | struct GNUNET_TESTBED_Host **hosts) | 296 | struct GNUNET_TESTBED_Host **hosts) |
301 | { | 297 | { |
302 | // see testing_group.c, GNUNET_TESTING_hosts_load | 298 | // see testing_group.c, GNUNET_TESTING_hosts_load |
303 | GNUNET_break (0); | 299 | GNUNET_break (0); |
@@ -313,7 +309,7 @@ GNUNET_TESTBED_hosts_load_from_file (const char *filename, | |||
313 | */ | 309 | */ |
314 | void | 310 | void |
315 | GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host) | 311 | GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host) |
316 | { | 312 | { |
317 | struct RegisteredController *rc; | 313 | struct RegisteredController *rc; |
318 | uint32_t id; | 314 | uint32_t id; |
319 | 315 | ||
@@ -321,7 +317,7 @@ GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host) | |||
321 | GNUNET_assert (host_list[host->id] == host); | 317 | GNUNET_assert (host_list[host->id] == host); |
322 | host_list[host->id] = NULL; | 318 | host_list[host->id] = NULL; |
323 | /* clear registered controllers list */ | 319 | /* clear registered controllers list */ |
324 | for (rc=host->rc_head; NULL != rc; rc=host->rc_head) | 320 | for (rc = host->rc_head; NULL != rc; rc = host->rc_head) |
325 | { | 321 | { |
326 | GNUNET_CONTAINER_DLL_remove (host->rc_head, host->rc_tail, rc); | 322 | GNUNET_CONTAINER_DLL_remove (host->rc_head, host->rc_tail, rc); |
327 | GNUNET_free (rc); | 323 | GNUNET_free (rc); |
@@ -331,18 +327,19 @@ GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host) | |||
331 | GNUNET_free (host); | 327 | GNUNET_free (host); |
332 | while (host_list_size >= HOST_LIST_GROW_STEP) | 328 | while (host_list_size >= HOST_LIST_GROW_STEP) |
333 | { | 329 | { |
334 | for (id = host_list_size - 1; | 330 | for (id = host_list_size - 1; id > host_list_size - HOST_LIST_GROW_STEP; |
335 | id > host_list_size - HOST_LIST_GROW_STEP; id--) | 331 | id--) |
336 | if (NULL != host_list[id]) | 332 | if (NULL != host_list[id]) |
337 | break; | 333 | break; |
338 | if (id != host_list_size - HOST_LIST_GROW_STEP) | 334 | if (id != host_list_size - HOST_LIST_GROW_STEP) |
339 | break; | 335 | break; |
340 | if (NULL != host_list[id]) | 336 | if (NULL != host_list[id]) |
341 | break; | 337 | break; |
342 | host_list_size -= HOST_LIST_GROW_STEP; | 338 | host_list_size -= HOST_LIST_GROW_STEP; |
343 | } | 339 | } |
344 | host_list = GNUNET_realloc (host_list, sizeof (struct GNUNET_TESTBED_Host) * | 340 | host_list = |
345 | host_list_size); | 341 | GNUNET_realloc (host_list, |
342 | sizeof (struct GNUNET_TESTBED_Host) * host_list_size); | ||
346 | } | 343 | } |
347 | 344 | ||
348 | 345 | ||
@@ -354,14 +351,14 @@ GNUNET_TESTBED_host_destroy (struct GNUNET_TESTBED_Host *host) | |||
354 | */ | 351 | */ |
355 | void | 352 | void |
356 | GNUNET_TESTBED_mark_host_registered_at_ (struct GNUNET_TESTBED_Host *host, | 353 | GNUNET_TESTBED_mark_host_registered_at_ (struct GNUNET_TESTBED_Host *host, |
357 | const struct GNUNET_TESTBED_Controller | 354 | const struct GNUNET_TESTBED_Controller |
358 | * const controller) | 355 | *const controller) |
359 | { | 356 | { |
360 | struct RegisteredController *rc; | 357 | struct RegisteredController *rc; |
361 | 358 | ||
362 | for (rc=host->rc_head; NULL != rc; rc=rc->next) | 359 | for (rc = host->rc_head; NULL != rc; rc = rc->next) |
363 | { | 360 | { |
364 | if (controller == rc->controller) /* already registered at controller */ | 361 | if (controller == rc->controller) /* already registered at controller */ |
365 | { | 362 | { |
366 | GNUNET_break (0); | 363 | GNUNET_break (0); |
367 | return; | 364 | return; |
@@ -383,14 +380,14 @@ GNUNET_TESTBED_mark_host_registered_at_ (struct GNUNET_TESTBED_Host *host, | |||
383 | */ | 380 | */ |
384 | int | 381 | int |
385 | GNUNET_TESTBED_is_host_registered_ (const struct GNUNET_TESTBED_Host *host, | 382 | GNUNET_TESTBED_is_host_registered_ (const struct GNUNET_TESTBED_Host *host, |
386 | const struct GNUNET_TESTBED_Controller | 383 | const struct GNUNET_TESTBED_Controller |
387 | *const controller) | 384 | *const controller) |
388 | { | 385 | { |
389 | struct RegisteredController *rc; | 386 | struct RegisteredController *rc; |
390 | 387 | ||
391 | for (rc=host->rc_head; NULL != rc; rc=rc->next) | 388 | for (rc = host->rc_head; NULL != rc; rc = rc->next) |
392 | { | 389 | { |
393 | if (controller == rc->controller) /* already registered at controller */ | 390 | if (controller == rc->controller) /* already registered at controller */ |
394 | { | 391 | { |
395 | return GNUNET_YES; | 392 | return GNUNET_YES; |
396 | } | 393 | } |
diff --git a/src/testbed/testbed_api_hosts.h b/src/testbed/testbed_api_hosts.h index de62b376d..ea93579b0 100644 --- a/src/testbed/testbed_api_hosts.h +++ b/src/testbed/testbed_api_hosts.h | |||
@@ -33,7 +33,7 @@ | |||
33 | 33 | ||
34 | /** | 34 | /** |
35 | * Lookup a host by ID. | 35 | * Lookup a host by ID. |
36 | * | 36 | * |
37 | * @param id global host ID assigned to the host; 0 is | 37 | * @param id global host ID assigned to the host; 0 is |
38 | * reserved to always mean 'localhost' | 38 | * reserved to always mean 'localhost' |
39 | * @return handle to the host, NULL on error | 39 | * @return handle to the host, NULL on error |
@@ -46,7 +46,7 @@ GNUNET_TESTBED_host_lookup_by_id_ (uint32_t id); | |||
46 | * Create a host by ID; given this host handle, we could not | 46 | * Create a host by ID; given this host handle, we could not |
47 | * run peers at the host, but we can talk about the host | 47 | * run peers at the host, but we can talk about the host |
48 | * internally. | 48 | * internally. |
49 | * | 49 | * |
50 | * @param id global host ID assigned to the host; 0 is | 50 | * @param id global host ID assigned to the host; 0 is |
51 | * reserved to always mean 'localhost' | 51 | * reserved to always mean 'localhost' |
52 | * @return handle to the host, NULL on error | 52 | * @return handle to the host, NULL on error |
@@ -57,7 +57,7 @@ GNUNET_TESTBED_host_create_by_id_ (uint32_t id); | |||
57 | 57 | ||
58 | /** | 58 | /** |
59 | * Obtain a host's unique global ID. | 59 | * Obtain a host's unique global ID. |
60 | * | 60 | * |
61 | * @param host handle to the host, NULL means 'localhost' | 61 | * @param host handle to the host, NULL means 'localhost' |
62 | * @return id global host ID assigned to the host (0 is | 62 | * @return id global host ID assigned to the host (0 is |
63 | * 'localhost', but then obviously not globally unique) | 63 | * 'localhost', but then obviously not globally unique) |
@@ -68,7 +68,7 @@ GNUNET_TESTBED_host_get_id_ (const struct GNUNET_TESTBED_Host *host); | |||
68 | 68 | ||
69 | /** | 69 | /** |
70 | * Obtain the host's hostname. | 70 | * Obtain the host's hostname. |
71 | * | 71 | * |
72 | * @param host handle to the host, NULL means 'localhost' | 72 | * @param host handle to the host, NULL means 'localhost' |
73 | * @return hostname of the host | 73 | * @return hostname of the host |
74 | */ | 74 | */ |
@@ -78,7 +78,7 @@ GNUNET_TESTBED_host_get_hostname_ (const struct GNUNET_TESTBED_Host *host); | |||
78 | 78 | ||
79 | /** | 79 | /** |
80 | * Obtain the host's username | 80 | * Obtain the host's username |
81 | * | 81 | * |
82 | * @param host handle to the host, NULL means 'localhost' | 82 | * @param host handle to the host, NULL means 'localhost' |
83 | * @return username to login to the host | 83 | * @return username to login to the host |
84 | */ | 84 | */ |
@@ -88,7 +88,7 @@ GNUNET_TESTBED_host_get_username_ (const struct GNUNET_TESTBED_Host *host); | |||
88 | 88 | ||
89 | /** | 89 | /** |
90 | * Obtain the host's ssh port | 90 | * Obtain the host's ssh port |
91 | * | 91 | * |
92 | * @param host handle to the host, NULL means 'localhost' | 92 | * @param host handle to the host, NULL means 'localhost' |
93 | * @return username to login to the host | 93 | * @return username to login to the host |
94 | */ | 94 | */ |
@@ -147,8 +147,8 @@ struct GNUNET_TESTBED_HelperHandle; | |||
147 | */ | 147 | */ |
148 | void | 148 | void |
149 | GNUNET_TESTBED_mark_host_registered_at_ (struct GNUNET_TESTBED_Host *host, | 149 | GNUNET_TESTBED_mark_host_registered_at_ (struct GNUNET_TESTBED_Host *host, |
150 | const struct GNUNET_TESTBED_Controller | 150 | const struct GNUNET_TESTBED_Controller |
151 | *controller); | 151 | *controller); |
152 | 152 | ||
153 | 153 | ||
154 | /** | 154 | /** |
@@ -160,8 +160,8 @@ GNUNET_TESTBED_mark_host_registered_at_ (struct GNUNET_TESTBED_Host *host, | |||
160 | */ | 160 | */ |
161 | int | 161 | int |
162 | GNUNET_TESTBED_is_host_registered_ (const struct GNUNET_TESTBED_Host *host, | 162 | GNUNET_TESTBED_is_host_registered_ (const struct GNUNET_TESTBED_Host *host, |
163 | const struct GNUNET_TESTBED_Controller | 163 | const struct GNUNET_TESTBED_Controller |
164 | *controller); | 164 | *controller); |
165 | 165 | ||
166 | 166 | ||
167 | 167 | ||
diff --git a/src/testbed/testbed_api_operations.c b/src/testbed/testbed_api_operations.c index 2bd82949e..b3cd1c090 100644 --- a/src/testbed/testbed_api_operations.c +++ b/src/testbed/testbed_api_operations.c | |||
@@ -69,7 +69,7 @@ struct OperationQueue | |||
69 | * Number of operations that can be concurrently | 69 | * Number of operations that can be concurrently |
70 | * active in this queue. | 70 | * active in this queue. |
71 | */ | 71 | */ |
72 | unsigned int active; | 72 | unsigned int active; |
73 | }; | 73 | }; |
74 | 74 | ||
75 | 75 | ||
@@ -77,17 +77,17 @@ struct OperationQueue | |||
77 | * Operation state | 77 | * Operation state |
78 | */ | 78 | */ |
79 | enum OperationState | 79 | enum OperationState |
80 | { | 80 | { |
81 | /** | 81 | /** |
82 | * The operation is currently waiting for resources | 82 | * The operation is currently waiting for resources |
83 | */ | 83 | */ |
84 | OP_STATE_WAITING, | 84 | OP_STATE_WAITING, |
85 | 85 | ||
86 | /** | 86 | /** |
87 | * The operation has started | 87 | * The operation has started |
88 | */ | 88 | */ |
89 | OP_STATE_STARTED, | 89 | OP_STATE_STARTED, |
90 | }; | 90 | }; |
91 | 91 | ||
92 | 92 | ||
93 | /** | 93 | /** |
@@ -105,7 +105,7 @@ struct GNUNET_TESTBED_Operation | |||
105 | * not have been started yet). | 105 | * not have been started yet). |
106 | */ | 106 | */ |
107 | OperationRelease release; | 107 | OperationRelease release; |
108 | 108 | ||
109 | /** | 109 | /** |
110 | * Closure for callbacks. | 110 | * Closure for callbacks. |
111 | */ | 111 | */ |
@@ -129,8 +129,8 @@ struct GNUNET_TESTBED_Operation | |||
129 | /** | 129 | /** |
130 | * The state of the operation | 130 | * The state of the operation |
131 | */ | 131 | */ |
132 | enum OperationState state; | 132 | enum OperationState state; |
133 | 133 | ||
134 | }; | 134 | }; |
135 | 135 | ||
136 | 136 | ||
@@ -142,15 +142,15 @@ struct GNUNET_TESTBED_Operation | |||
142 | */ | 142 | */ |
143 | static void | 143 | static void |
144 | call_start (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 144 | call_start (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
145 | { | 145 | { |
146 | struct GNUNET_TESTBED_Operation *op = cls; | 146 | struct GNUNET_TESTBED_Operation *op = cls; |
147 | 147 | ||
148 | op->start_task_id = GNUNET_SCHEDULER_NO_TASK; | 148 | op->start_task_id = GNUNET_SCHEDULER_NO_TASK; |
149 | op->state = OP_STATE_STARTED; | 149 | op->state = OP_STATE_STARTED; |
150 | if (NULL != op->start) | 150 | if (NULL != op->start) |
151 | { | 151 | { |
152 | op->start (op->cb_cls); | 152 | op->start (op->cb_cls); |
153 | } | 153 | } |
154 | } | 154 | } |
155 | 155 | ||
156 | 156 | ||
@@ -161,11 +161,11 @@ call_start (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
161 | */ | 161 | */ |
162 | static void | 162 | static void |
163 | check_readiness (struct GNUNET_TESTBED_Operation *op) | 163 | check_readiness (struct GNUNET_TESTBED_Operation *op) |
164 | { | 164 | { |
165 | unsigned int i; | 165 | unsigned int i; |
166 | 166 | ||
167 | if (GNUNET_SCHEDULER_NO_TASK != op->start_task_id) | 167 | if (GNUNET_SCHEDULER_NO_TASK != op->start_task_id) |
168 | return; | 168 | return; |
169 | for (i = 0; i < op->nqueues; i++) | 169 | for (i = 0; i < op->nqueues; i++) |
170 | { | 170 | { |
171 | if (0 == op->queues[i]->active) | 171 | if (0 == op->queues[i]->active) |
@@ -188,9 +188,8 @@ check_readiness (struct GNUNET_TESTBED_Operation *op) | |||
188 | * @return handle to the operation | 188 | * @return handle to the operation |
189 | */ | 189 | */ |
190 | struct GNUNET_TESTBED_Operation * | 190 | struct GNUNET_TESTBED_Operation * |
191 | GNUNET_TESTBED_operation_create_ (void *cls, | 191 | GNUNET_TESTBED_operation_create_ (void *cls, OperationStart start, |
192 | OperationStart start, | 192 | OperationRelease release) |
193 | OperationRelease release) | ||
194 | { | 193 | { |
195 | struct GNUNET_TESTBED_Operation *op; | 194 | struct GNUNET_TESTBED_Operation *op; |
196 | 195 | ||
@@ -240,9 +239,9 @@ GNUNET_TESTBED_operation_queue_destroy_ (struct OperationQueue *queue) | |||
240 | * Add an operation to a queue. An operation can be in multiple | 239 | * Add an operation to a queue. An operation can be in multiple |
241 | * queues at once. Once all queues permit the operation to become | 240 | * queues at once. Once all queues permit the operation to become |
242 | * active, the operation will be activated. The actual activation | 241 | * active, the operation will be activated. The actual activation |
243 | * will occur in a separate task (thus allowing multiple queue | 242 | * will occur in a separate task (thus allowing multiple queue |
244 | * insertions to be made without having the first one instantly | 243 | * insertions to be made without having the first one instantly |
245 | * trigger the operation if the first queue has sufficient | 244 | * trigger the operation if the first queue has sufficient |
246 | * resources). | 245 | * resources). |
247 | * | 246 | * |
248 | * @param queue queue to add the operation to | 247 | * @param queue queue to add the operation to |
@@ -250,7 +249,8 @@ GNUNET_TESTBED_operation_queue_destroy_ (struct OperationQueue *queue) | |||
250 | */ | 249 | */ |
251 | void | 250 | void |
252 | GNUNET_TESTBED_operation_queue_insert_ (struct OperationQueue *queue, | 251 | GNUNET_TESTBED_operation_queue_insert_ (struct OperationQueue *queue, |
253 | struct GNUNET_TESTBED_Operation *operation) | 252 | struct GNUNET_TESTBED_Operation |
253 | *operation) | ||
254 | { | 254 | { |
255 | struct QueueEntry *entry; | 255 | struct QueueEntry *entry; |
256 | 256 | ||
@@ -258,8 +258,9 @@ GNUNET_TESTBED_operation_queue_insert_ (struct OperationQueue *queue, | |||
258 | entry->op = operation; | 258 | entry->op = operation; |
259 | GNUNET_CONTAINER_DLL_insert_tail (queue->head, queue->tail, entry); | 259 | GNUNET_CONTAINER_DLL_insert_tail (queue->head, queue->tail, entry); |
260 | operation->queues = | 260 | operation->queues = |
261 | GNUNET_realloc (operation->queues, | 261 | GNUNET_realloc (operation->queues, |
262 | sizeof (struct OperationQueue *) * (++operation->nqueues)); | 262 | sizeof (struct OperationQueue *) * |
263 | (++operation->nqueues)); | ||
263 | operation->queues[operation->nqueues - 1] = queue; | 264 | operation->queues[operation->nqueues - 1] = queue; |
264 | check_readiness (operation); | 265 | check_readiness (operation); |
265 | } | 266 | } |
@@ -276,11 +277,12 @@ GNUNET_TESTBED_operation_queue_insert_ (struct OperationQueue *queue, | |||
276 | */ | 277 | */ |
277 | void | 278 | void |
278 | GNUNET_TESTBED_operation_queue_remove_ (struct OperationQueue *queue, | 279 | GNUNET_TESTBED_operation_queue_remove_ (struct OperationQueue *queue, |
279 | struct GNUNET_TESTBED_Operation *operation) | 280 | struct GNUNET_TESTBED_Operation |
281 | *operation) | ||
280 | { | 282 | { |
281 | struct QueueEntry *entry; | 283 | struct QueueEntry *entry; |
282 | struct QueueEntry *entry2; | 284 | struct QueueEntry *entry2; |
283 | 285 | ||
284 | for (entry = queue->head; NULL != entry; entry = entry->next) | 286 | for (entry = queue->head; NULL != entry; entry = entry->next) |
285 | if (entry->op == operation) | 287 | if (entry->op == operation) |
286 | break; | 288 | break; |
@@ -309,7 +311,7 @@ void | |||
309 | GNUNET_TESTBED_operation_release_ (struct GNUNET_TESTBED_Operation *operation) | 311 | GNUNET_TESTBED_operation_release_ (struct GNUNET_TESTBED_Operation *operation) |
310 | { | 312 | { |
311 | unsigned int i; | 313 | unsigned int i; |
312 | 314 | ||
313 | if (GNUNET_SCHEDULER_NO_TASK != operation->start_task_id) | 315 | if (GNUNET_SCHEDULER_NO_TASK != operation->start_task_id) |
314 | { | 316 | { |
315 | GNUNET_SCHEDULER_cancel (operation->start_task_id); | 317 | GNUNET_SCHEDULER_cancel (operation->start_task_id); |
diff --git a/src/testbed/testbed_api_operations.h b/src/testbed/testbed_api_operations.h index 08d6df2c0..519c68139 100644 --- a/src/testbed/testbed_api_operations.h +++ b/src/testbed/testbed_api_operations.h | |||
@@ -62,9 +62,9 @@ GNUNET_TESTBED_operation_queue_destroy_ (struct OperationQueue *queue); | |||
62 | * Add an operation to a queue. An operation can be in multiple | 62 | * Add an operation to a queue. An operation can be in multiple |
63 | * queues at once. Once all queues permit the operation to become | 63 | * queues at once. Once all queues permit the operation to become |
64 | * active, the operation will be activated. The actual activation | 64 | * active, the operation will be activated. The actual activation |
65 | * will occur in a separate task (thus allowing multiple queue | 65 | * will occur in a separate task (thus allowing multiple queue |
66 | * insertions to be made without having the first one instantly | 66 | * insertions to be made without having the first one instantly |
67 | * trigger the operation if the first queue has sufficient | 67 | * trigger the operation if the first queue has sufficient |
68 | * resources). | 68 | * resources). |
69 | * | 69 | * |
70 | * @param queue queue to add the operation to | 70 | * @param queue queue to add the operation to |
@@ -72,7 +72,8 @@ GNUNET_TESTBED_operation_queue_destroy_ (struct OperationQueue *queue); | |||
72 | */ | 72 | */ |
73 | void | 73 | void |
74 | GNUNET_TESTBED_operation_queue_insert_ (struct OperationQueue *queue, | 74 | GNUNET_TESTBED_operation_queue_insert_ (struct OperationQueue *queue, |
75 | struct GNUNET_TESTBED_Operation *operation); | 75 | struct GNUNET_TESTBED_Operation |
76 | *operation); | ||
76 | 77 | ||
77 | 78 | ||
78 | /** | 79 | /** |
@@ -86,7 +87,8 @@ GNUNET_TESTBED_operation_queue_insert_ (struct OperationQueue *queue, | |||
86 | */ | 87 | */ |
87 | void | 88 | void |
88 | GNUNET_TESTBED_operation_queue_remove_ (struct OperationQueue *queue, | 89 | GNUNET_TESTBED_operation_queue_remove_ (struct OperationQueue *queue, |
89 | struct GNUNET_TESTBED_Operation *operation); | 90 | struct GNUNET_TESTBED_Operation |
91 | *operation); | ||
90 | 92 | ||
91 | 93 | ||
92 | 94 | ||
@@ -97,7 +99,7 @@ GNUNET_TESTBED_operation_queue_remove_ (struct OperationQueue *queue, | |||
97 | * | 99 | * |
98 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 100 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
99 | */ | 101 | */ |
100 | typedef void (*OperationStart)(void *cls); | 102 | typedef void (*OperationStart) (void *cls); |
101 | 103 | ||
102 | 104 | ||
103 | /** | 105 | /** |
@@ -113,7 +115,7 @@ typedef void (*OperationStart)(void *cls); | |||
113 | * | 115 | * |
114 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 116 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
115 | */ | 117 | */ |
116 | typedef void (*OperationRelease)(void *cls); | 118 | typedef void (*OperationRelease) (void *cls); |
117 | 119 | ||
118 | 120 | ||
119 | /** | 121 | /** |
@@ -125,9 +127,8 @@ typedef void (*OperationRelease)(void *cls); | |||
125 | * @return handle to the operation | 127 | * @return handle to the operation |
126 | */ | 128 | */ |
127 | struct GNUNET_TESTBED_Operation * | 129 | struct GNUNET_TESTBED_Operation * |
128 | GNUNET_TESTBED_operation_create_ (void *cls, | 130 | GNUNET_TESTBED_operation_create_ (void *cls, OperationStart start, |
129 | OperationStart start, | 131 | OperationRelease release); |
130 | OperationRelease release); | ||
131 | 132 | ||
132 | 133 | ||
133 | /** | 134 | /** |
diff --git a/src/testbed/testbed_api_peers.c b/src/testbed/testbed_api_peers.c index 28110d1f1..9ced75973 100644 --- a/src/testbed/testbed_api_peers.c +++ b/src/testbed/testbed_api_peers.c | |||
@@ -40,7 +40,7 @@ | |||
40 | * | 40 | * |
41 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 41 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
42 | */ | 42 | */ |
43 | static void | 43 | static void |
44 | opstart_peer_create (void *cls) | 44 | opstart_peer_create (void *cls) |
45 | { | 45 | { |
46 | struct OperationContext *opc = cls; | 46 | struct OperationContext *opc = cls; |
@@ -52,7 +52,7 @@ opstart_peer_create (void *cls) | |||
52 | size_t xc_size; | 52 | size_t xc_size; |
53 | uint16_t msize; | 53 | uint16_t msize; |
54 | 54 | ||
55 | GNUNET_assert (OP_PEER_CREATE == opc->type); | 55 | GNUNET_assert (OP_PEER_CREATE == opc->type); |
56 | data = opc->data; | 56 | data = opc->data; |
57 | GNUNET_assert (NULL != data); | 57 | GNUNET_assert (NULL != data); |
58 | GNUNET_assert (NULL != data->peer); | 58 | GNUNET_assert (NULL != data->peer); |
@@ -79,10 +79,10 @@ opstart_peer_create (void *cls) | |||
79 | * | 79 | * |
80 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 80 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
81 | */ | 81 | */ |
82 | static void | 82 | static void |
83 | oprelease_peer_create (void *cls) | 83 | oprelease_peer_create (void *cls) |
84 | { | 84 | { |
85 | struct OperationContext *opc = cls; | 85 | struct OperationContext *opc = cls; |
86 | 86 | ||
87 | if (OPC_STATE_FINISHED != opc->state) | 87 | if (OPC_STATE_FINISHED != opc->state) |
88 | { | 88 | { |
@@ -99,7 +99,7 @@ oprelease_peer_create (void *cls) | |||
99 | * | 99 | * |
100 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 100 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
101 | */ | 101 | */ |
102 | static void | 102 | static void |
103 | opstart_peer_destroy (void *cls) | 103 | opstart_peer_destroy (void *cls) |
104 | { | 104 | { |
105 | struct OperationContext *opc = cls; | 105 | struct OperationContext *opc = cls; |
@@ -115,8 +115,7 @@ opstart_peer_destroy (void *cls) | |||
115 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER); | 115 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_DESTROYPEER); |
116 | msg->peer_id = htonl (peer->unique_id); | 116 | msg->peer_id = htonl (peer->unique_id); |
117 | msg->operation_id = GNUNET_htonll (opc->id); | 117 | msg->operation_id = GNUNET_htonll (opc->id); |
118 | GNUNET_CONTAINER_DLL_insert_tail (opc->c->ocq_head, | 118 | GNUNET_CONTAINER_DLL_insert_tail (opc->c->ocq_head, opc->c->ocq_tail, opc); |
119 | opc->c->ocq_tail, opc); | ||
120 | GNUNET_TESTBED_queue_message_ (peer->controller, &msg->header); | 119 | GNUNET_TESTBED_queue_message_ (peer->controller, &msg->header); |
121 | } | 120 | } |
122 | 121 | ||
@@ -126,11 +125,11 @@ opstart_peer_destroy (void *cls) | |||
126 | * | 125 | * |
127 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 126 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
128 | */ | 127 | */ |
129 | static void | 128 | static void |
130 | oprelease_peer_destroy (void *cls) | 129 | oprelease_peer_destroy (void *cls) |
131 | { | 130 | { |
132 | struct OperationContext *opc = cls; | 131 | struct OperationContext *opc = cls; |
133 | 132 | ||
134 | if (OPC_STATE_FINISHED != opc->state) | 133 | if (OPC_STATE_FINISHED != opc->state) |
135 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); | 134 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); |
136 | GNUNET_free (opc); | 135 | GNUNET_free (opc); |
@@ -142,7 +141,7 @@ oprelease_peer_destroy (void *cls) | |||
142 | * | 141 | * |
143 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 142 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
144 | */ | 143 | */ |
145 | static void | 144 | static void |
146 | opstart_peer_start (void *cls) | 145 | opstart_peer_start (void *cls) |
147 | { | 146 | { |
148 | struct OperationContext *opc = cls; | 147 | struct OperationContext *opc = cls; |
@@ -169,11 +168,11 @@ opstart_peer_start (void *cls) | |||
169 | * | 168 | * |
170 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 169 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
171 | */ | 170 | */ |
172 | static void | 171 | static void |
173 | oprelease_peer_start (void *cls) | 172 | oprelease_peer_start (void *cls) |
174 | { | 173 | { |
175 | struct OperationContext *opc = cls; | 174 | struct OperationContext *opc = cls; |
176 | 175 | ||
177 | if (OPC_STATE_FINISHED != opc->state) | 176 | if (OPC_STATE_FINISHED != opc->state) |
178 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); | 177 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); |
179 | GNUNET_free (opc); | 178 | GNUNET_free (opc); |
@@ -185,7 +184,7 @@ oprelease_peer_start (void *cls) | |||
185 | * | 184 | * |
186 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 185 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
187 | */ | 186 | */ |
188 | static void | 187 | static void |
189 | opstart_peer_stop (void *cls) | 188 | opstart_peer_stop (void *cls) |
190 | { | 189 | { |
191 | struct OperationContext *opc = cls; | 190 | struct OperationContext *opc = cls; |
@@ -194,8 +193,8 @@ opstart_peer_stop (void *cls) | |||
194 | 193 | ||
195 | GNUNET_assert (NULL != opc->data); | 194 | GNUNET_assert (NULL != opc->data); |
196 | peer = opc->data; | 195 | peer = opc->data; |
197 | GNUNET_assert (PS_STARTED == peer->state); | 196 | GNUNET_assert (PS_STARTED == peer->state); |
198 | opc->state = OPC_STATE_STARTED; | 197 | opc->state = OPC_STATE_STARTED; |
199 | msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_PeerStopMessage)); | 198 | msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_PeerStopMessage)); |
200 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_STOPPEER); | 199 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_STOPPEER); |
201 | msg->header.size = htons (sizeof (struct GNUNET_TESTBED_PeerStopMessage)); | 200 | msg->header.size = htons (sizeof (struct GNUNET_TESTBED_PeerStopMessage)); |
@@ -211,11 +210,11 @@ opstart_peer_stop (void *cls) | |||
211 | * | 210 | * |
212 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 211 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
213 | */ | 212 | */ |
214 | static void | 213 | static void |
215 | oprelease_peer_stop (void *cls) | 214 | oprelease_peer_stop (void *cls) |
216 | { | 215 | { |
217 | struct OperationContext *opc = cls; | 216 | struct OperationContext *opc = cls; |
218 | 217 | ||
219 | if (OPC_STATE_FINISHED != opc->state) | 218 | if (OPC_STATE_FINISHED != opc->state) |
220 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); | 219 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); |
221 | GNUNET_free (opc); | 220 | GNUNET_free (opc); |
@@ -236,10 +235,11 @@ GNUNET_TESTBED_generate_peergetconfig_msg_ (uint32_t peer_id, | |||
236 | { | 235 | { |
237 | struct GNUNET_TESTBED_PeerGetConfigurationMessage *msg; | 236 | struct GNUNET_TESTBED_PeerGetConfigurationMessage *msg; |
238 | 237 | ||
239 | msg = GNUNET_malloc (sizeof (struct | 238 | msg = |
240 | GNUNET_TESTBED_PeerGetConfigurationMessage)); | 239 | GNUNET_malloc (sizeof |
241 | msg->header.size = htons | 240 | (struct GNUNET_TESTBED_PeerGetConfigurationMessage)); |
242 | (sizeof (struct GNUNET_TESTBED_PeerGetConfigurationMessage)); | 241 | msg->header.size = |
242 | htons (sizeof (struct GNUNET_TESTBED_PeerGetConfigurationMessage)); | ||
243 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_GETPEERCONFIG); | 243 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_GETPEERCONFIG); |
244 | msg->peer_id = htonl (peer_id); | 244 | msg->peer_id = htonl (peer_id); |
245 | msg->operation_id = GNUNET_htonll (operation_id); | 245 | msg->operation_id = GNUNET_htonll (operation_id); |
@@ -252,18 +252,19 @@ GNUNET_TESTBED_generate_peergetconfig_msg_ (uint32_t peer_id, | |||
252 | * | 252 | * |
253 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 253 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
254 | */ | 254 | */ |
255 | static void | 255 | static void |
256 | opstart_peer_getinfo (void *cls) | 256 | opstart_peer_getinfo (void *cls) |
257 | { | 257 | { |
258 | struct OperationContext *opc = cls; | 258 | struct OperationContext *opc = cls; |
259 | struct PeerInfoData *data; | 259 | struct PeerInfoData *data; |
260 | struct GNUNET_TESTBED_PeerGetConfigurationMessage *msg; | 260 | struct GNUNET_TESTBED_PeerGetConfigurationMessage *msg; |
261 | 261 | ||
262 | data = opc->data; | 262 | data = opc->data; |
263 | GNUNET_assert (NULL != data); | 263 | GNUNET_assert (NULL != data); |
264 | opc->state = OPC_STATE_STARTED; | 264 | opc->state = OPC_STATE_STARTED; |
265 | msg = GNUNET_TESTBED_generate_peergetconfig_msg_ (data->peer->unique_id, | 265 | msg = |
266 | opc->id); | 266 | GNUNET_TESTBED_generate_peergetconfig_msg_ (data->peer->unique_id, |
267 | opc->id); | ||
267 | GNUNET_CONTAINER_DLL_insert_tail (opc->c->ocq_head, opc->c->ocq_tail, opc); | 268 | GNUNET_CONTAINER_DLL_insert_tail (opc->c->ocq_head, opc->c->ocq_tail, opc); |
268 | GNUNET_TESTBED_queue_message_ (opc->c, &msg->header); | 269 | GNUNET_TESTBED_queue_message_ (opc->c, &msg->header); |
269 | } | 270 | } |
@@ -274,16 +275,16 @@ opstart_peer_getinfo (void *cls) | |||
274 | * | 275 | * |
275 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 276 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
276 | */ | 277 | */ |
277 | static void | 278 | static void |
278 | oprelease_peer_getinfo (void *cls) | 279 | oprelease_peer_getinfo (void *cls) |
279 | { | 280 | { |
280 | struct OperationContext *opc = cls; | 281 | struct OperationContext *opc = cls; |
281 | struct PeerInfoData2 *data; | 282 | struct PeerInfoData2 *data; |
282 | 283 | ||
283 | if (OPC_STATE_FINISHED != opc->state) | 284 | if (OPC_STATE_FINISHED != opc->state) |
284 | { | 285 | { |
285 | GNUNET_free_non_null (opc->data); | 286 | GNUNET_free_non_null (opc->data); |
286 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); | 287 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); |
287 | } | 288 | } |
288 | else | 289 | else |
289 | { | 290 | { |
@@ -311,19 +312,19 @@ oprelease_peer_getinfo (void *cls) | |||
311 | * | 312 | * |
312 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 313 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
313 | */ | 314 | */ |
314 | static void | 315 | static void |
315 | opstart_overlay_connect (void *cls) | 316 | opstart_overlay_connect (void *cls) |
316 | { | 317 | { |
317 | struct OperationContext *opc = cls; | 318 | struct OperationContext *opc = cls; |
318 | struct GNUNET_TESTBED_OverlayConnectMessage *msg; | 319 | struct GNUNET_TESTBED_OverlayConnectMessage *msg; |
319 | struct OverlayConnectData *data; | 320 | struct OverlayConnectData *data; |
320 | 321 | ||
321 | opc->state = OPC_STATE_STARTED; | 322 | opc->state = OPC_STATE_STARTED; |
322 | data = opc->data; | 323 | data = opc->data; |
323 | GNUNET_assert (NULL != data); | 324 | GNUNET_assert (NULL != data); |
324 | msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_OverlayConnectMessage)); | 325 | msg = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_OverlayConnectMessage)); |
325 | msg->header.size = htons (sizeof | 326 | msg->header.size = |
326 | (struct GNUNET_TESTBED_OverlayConnectMessage)); | 327 | htons (sizeof (struct GNUNET_TESTBED_OverlayConnectMessage)); |
327 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_OLCONNECT); | 328 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_OLCONNECT); |
328 | msg->peer1 = htonl (data->p1->unique_id); | 329 | msg->peer1 = htonl (data->p1->unique_id); |
329 | msg->peer2 = htonl (data->p2->unique_id); | 330 | msg->peer2 = htonl (data->p2->unique_id); |
@@ -338,23 +339,23 @@ opstart_overlay_connect (void *cls) | |||
338 | * | 339 | * |
339 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 340 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
340 | */ | 341 | */ |
341 | static void | 342 | static void |
342 | oprelease_overlay_connect (void *cls) | 343 | oprelease_overlay_connect (void *cls) |
343 | { | 344 | { |
344 | struct OperationContext *opc = cls; | 345 | struct OperationContext *opc = cls; |
345 | 346 | ||
346 | if (OPC_STATE_FINISHED != opc->state) | 347 | if (OPC_STATE_FINISHED != opc->state) |
347 | { | 348 | { |
348 | GNUNET_free (opc->data); | 349 | GNUNET_free (opc->data); |
349 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); | 350 | GNUNET_CONTAINER_DLL_remove (opc->c->ocq_head, opc->c->ocq_tail, opc); |
350 | } | 351 | } |
351 | GNUNET_free (opc); | 352 | GNUNET_free (opc); |
352 | } | 353 | } |
353 | 354 | ||
354 | 355 | ||
355 | /** | 356 | /** |
356 | * Lookup a peer by ID. | 357 | * Lookup a peer by ID. |
357 | * | 358 | * |
358 | * @param id global peer ID assigned to the peer | 359 | * @param id global peer ID assigned to the peer |
359 | * @return handle to the host, NULL on error | 360 | * @return handle to the host, NULL on error |
360 | */ | 361 | */ |
@@ -400,11 +401,12 @@ GNUNET_TESTBED_peer_lookup_by_id_ (uint32_t id) | |||
400 | */ | 401 | */ |
401 | struct GNUNET_TESTBED_Operation * | 402 | struct GNUNET_TESTBED_Operation * |
402 | GNUNET_TESTBED_peer_create_with_id_ (uint32_t unique_id, | 403 | GNUNET_TESTBED_peer_create_with_id_ (uint32_t unique_id, |
403 | struct GNUNET_TESTBED_Controller *controller, | 404 | struct GNUNET_TESTBED_Controller |
404 | struct GNUNET_TESTBED_Host *host, | 405 | *controller, |
405 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 406 | struct GNUNET_TESTBED_Host *host, |
406 | GNUNET_TESTBED_PeerCreateCallback cb, | 407 | const struct GNUNET_CONFIGURATION_Handle |
407 | void *cls) | 408 | *cfg, GNUNET_TESTBED_PeerCreateCallback cb, |
409 | void *cls) | ||
408 | { | 410 | { |
409 | struct GNUNET_TESTBED_Peer *peer; | 411 | struct GNUNET_TESTBED_Peer *peer; |
410 | struct PeerCreateData *data; | 412 | struct PeerCreateData *data; |
@@ -426,8 +428,9 @@ GNUNET_TESTBED_peer_create_with_id_ (uint32_t unique_id, | |||
426 | opc->data = data; | 428 | opc->data = data; |
427 | opc->id = controller->operation_counter++; | 429 | opc->id = controller->operation_counter++; |
428 | opc->type = OP_PEER_CREATE; | 430 | opc->type = OP_PEER_CREATE; |
429 | opc->op = GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_create, | 431 | opc->op = |
430 | &oprelease_peer_create); | 432 | GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_create, |
433 | &oprelease_peer_create); | ||
431 | GNUNET_TESTBED_operation_queue_insert_ (controller->opq_parallel_operations, | 434 | GNUNET_TESTBED_operation_queue_insert_ (controller->opq_parallel_operations, |
432 | opc->op); | 435 | opc->op); |
433 | return opc->op; | 436 | return opc->op; |
@@ -465,18 +468,14 @@ GNUNET_TESTBED_peer_create_with_id_ (uint32_t unique_id, | |||
465 | */ | 468 | */ |
466 | struct GNUNET_TESTBED_Operation * | 469 | struct GNUNET_TESTBED_Operation * |
467 | GNUNET_TESTBED_peer_create (struct GNUNET_TESTBED_Controller *controller, | 470 | GNUNET_TESTBED_peer_create (struct GNUNET_TESTBED_Controller *controller, |
468 | struct GNUNET_TESTBED_Host *host, | 471 | struct GNUNET_TESTBED_Host *host, |
469 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 472 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
470 | GNUNET_TESTBED_PeerCreateCallback cb, | 473 | GNUNET_TESTBED_PeerCreateCallback cb, void *cls) |
471 | void *cls) | ||
472 | { | 474 | { |
473 | static uint32_t id_gen; | 475 | static uint32_t id_gen; |
474 | 476 | ||
475 | return GNUNET_TESTBED_peer_create_with_id_ (id_gen++, | 477 | return GNUNET_TESTBED_peer_create_with_id_ (id_gen++, controller, host, cfg, |
476 | controller, | 478 | cb, cls); |
477 | host, | ||
478 | cfg, | ||
479 | cb, cls); | ||
480 | } | 479 | } |
481 | 480 | ||
482 | 481 | ||
@@ -496,17 +495,18 @@ GNUNET_TESTBED_peer_start (struct GNUNET_TESTBED_Peer *peer) | |||
496 | opc->data = peer; | 495 | opc->data = peer; |
497 | opc->id = opc->c->operation_counter++; | 496 | opc->id = opc->c->operation_counter++; |
498 | opc->type = OP_PEER_START; | 497 | opc->type = OP_PEER_START; |
499 | opc->op = GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_start, | 498 | opc->op = |
500 | &oprelease_peer_start); | 499 | GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_start, |
500 | &oprelease_peer_start); | ||
501 | GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations, | 501 | GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations, |
502 | opc->op); | 502 | opc->op); |
503 | return opc->op; | 503 | return opc->op; |
504 | } | 504 | } |
505 | 505 | ||
506 | 506 | ||
507 | /** | 507 | /** |
508 | * Stop the given peer. The handle remains valid (use | 508 | * Stop the given peer. The handle remains valid (use |
509 | * "GNUNET_TESTBED_peer_destroy" to fully clean up the | 509 | * "GNUNET_TESTBED_peer_destroy" to fully clean up the |
510 | * state of the peer). | 510 | * state of the peer). |
511 | * | 511 | * |
512 | * @param peer peer to stop | 512 | * @param peer peer to stop |
@@ -522,8 +522,9 @@ GNUNET_TESTBED_peer_stop (struct GNUNET_TESTBED_Peer *peer) | |||
522 | opc->data = peer; | 522 | opc->data = peer; |
523 | opc->id = opc->c->operation_counter++; | 523 | opc->id = opc->c->operation_counter++; |
524 | opc->type = OP_PEER_STOP; | 524 | opc->type = OP_PEER_STOP; |
525 | opc->op = GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_stop, | 525 | opc->op = |
526 | &oprelease_peer_stop); | 526 | GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_stop, |
527 | &oprelease_peer_stop); | ||
527 | GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations, | 528 | GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations, |
528 | opc->op); | 529 | opc->op); |
529 | return opc->op; | 530 | return opc->op; |
@@ -539,7 +540,8 @@ GNUNET_TESTBED_peer_stop (struct GNUNET_TESTBED_Peer *peer) | |||
539 | */ | 540 | */ |
540 | struct GNUNET_TESTBED_Operation * | 541 | struct GNUNET_TESTBED_Operation * |
541 | GNUNET_TESTBED_peer_get_information (struct GNUNET_TESTBED_Peer *peer, | 542 | GNUNET_TESTBED_peer_get_information (struct GNUNET_TESTBED_Peer *peer, |
542 | enum GNUNET_TESTBED_PeerInformationType pit) | 543 | enum GNUNET_TESTBED_PeerInformationType |
544 | pit) | ||
543 | { | 545 | { |
544 | struct OperationContext *opc; | 546 | struct OperationContext *opc; |
545 | struct PeerInfoData *data; | 547 | struct PeerInfoData *data; |
@@ -553,8 +555,9 @@ GNUNET_TESTBED_peer_get_information (struct GNUNET_TESTBED_Peer *peer, | |||
553 | opc->data = data; | 555 | opc->data = data; |
554 | opc->type = OP_PEER_INFO; | 556 | opc->type = OP_PEER_INFO; |
555 | opc->id = opc->c->operation_counter++; | 557 | opc->id = opc->c->operation_counter++; |
556 | opc->op = GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_getinfo, | 558 | opc->op = |
557 | &oprelease_peer_getinfo); | 559 | GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_getinfo, |
560 | &oprelease_peer_getinfo); | ||
558 | GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations, | 561 | GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations, |
559 | opc->op); | 562 | opc->op); |
560 | return opc->op; | 563 | return opc->op; |
@@ -573,7 +576,8 @@ GNUNET_TESTBED_peer_get_information (struct GNUNET_TESTBED_Peer *peer, | |||
573 | */ | 576 | */ |
574 | struct GNUNET_TESTBED_Operation * | 577 | struct GNUNET_TESTBED_Operation * |
575 | GNUNET_TESTBED_peer_update_configuration (struct GNUNET_TESTBED_Peer *peer, | 578 | GNUNET_TESTBED_peer_update_configuration (struct GNUNET_TESTBED_Peer *peer, |
576 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 579 | const struct |
580 | GNUNET_CONFIGURATION_Handle *cfg) | ||
577 | { | 581 | { |
578 | // FIXME: handle locally or delegate... | 582 | // FIXME: handle locally or delegate... |
579 | GNUNET_break (0); | 583 | GNUNET_break (0); |
@@ -598,8 +602,9 @@ GNUNET_TESTBED_peer_destroy (struct GNUNET_TESTBED_Peer *peer) | |||
598 | opc->c = peer->controller; | 602 | opc->c = peer->controller; |
599 | opc->id = peer->controller->operation_counter++; | 603 | opc->id = peer->controller->operation_counter++; |
600 | opc->type = OP_PEER_DESTROY; | 604 | opc->type = OP_PEER_DESTROY; |
601 | opc->op = GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_destroy, | 605 | opc->op = |
602 | &oprelease_peer_destroy); | 606 | GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_destroy, |
607 | &oprelease_peer_destroy); | ||
603 | GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations, | 608 | GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations, |
604 | opc->op); | 609 | opc->op); |
605 | return opc->op; | 610 | return opc->op; |
@@ -608,7 +613,7 @@ GNUNET_TESTBED_peer_destroy (struct GNUNET_TESTBED_Peer *peer) | |||
608 | 613 | ||
609 | /** | 614 | /** |
610 | * Manipulate the P2P underlay topology by configuring a link | 615 | * Manipulate the P2P underlay topology by configuring a link |
611 | * between two peers. | 616 | * between two peers. |
612 | * | 617 | * |
613 | * @param op_cls closure argument to give with the operation event | 618 | * @param op_cls closure argument to give with the operation event |
614 | * @param p1 first peer | 619 | * @param p1 first peer |
@@ -620,9 +625,10 @@ GNUNET_TESTBED_peer_destroy (struct GNUNET_TESTBED_Peer *peer) | |||
620 | */ | 625 | */ |
621 | struct GNUNET_TESTBED_Operation * | 626 | struct GNUNET_TESTBED_Operation * |
622 | GNUNET_TESTBED_underlay_configure_link (void *op_cls, | 627 | GNUNET_TESTBED_underlay_configure_link (void *op_cls, |
623 | struct GNUNET_TESTBED_Peer *p1, | 628 | struct GNUNET_TESTBED_Peer *p1, |
624 | struct GNUNET_TESTBED_Peer *p2, | 629 | struct GNUNET_TESTBED_Peer *p2, |
625 | enum GNUNET_TESTBED_ConnectOption co, ...) | 630 | enum GNUNET_TESTBED_ConnectOption co, |
631 | ...) | ||
626 | { | 632 | { |
627 | GNUNET_break (0); | 633 | GNUNET_break (0); |
628 | return NULL; | 634 | return NULL; |
@@ -643,9 +649,8 @@ GNUNET_TESTBED_underlay_configure_link (void *op_cls, | |||
643 | * not running or underlay disallows) | 649 | * not running or underlay disallows) |
644 | */ | 650 | */ |
645 | struct GNUNET_TESTBED_Operation * | 651 | struct GNUNET_TESTBED_Operation * |
646 | GNUNET_TESTBED_overlay_connect (void *op_cls, | 652 | GNUNET_TESTBED_overlay_connect (void *op_cls, struct GNUNET_TESTBED_Peer *p1, |
647 | struct GNUNET_TESTBED_Peer *p1, | 653 | struct GNUNET_TESTBED_Peer *p2) |
648 | struct GNUNET_TESTBED_Peer *p2) | ||
649 | { | 654 | { |
650 | struct OperationContext *opc; | 655 | struct OperationContext *opc; |
651 | struct OverlayConnectData *data; | 656 | struct OverlayConnectData *data; |
@@ -660,8 +665,9 @@ GNUNET_TESTBED_overlay_connect (void *op_cls, | |||
660 | opc->c = p1->controller; | 665 | opc->c = p1->controller; |
661 | opc->id = opc->c->operation_counter++; | 666 | opc->id = opc->c->operation_counter++; |
662 | opc->type = OP_OVERLAY_CONNECT; | 667 | opc->type = OP_OVERLAY_CONNECT; |
663 | opc->op = GNUNET_TESTBED_operation_create_ (opc, &opstart_overlay_connect, | 668 | opc->op = |
664 | &oprelease_overlay_connect); | 669 | GNUNET_TESTBED_operation_create_ (opc, &opstart_overlay_connect, |
670 | &oprelease_overlay_connect); | ||
665 | GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations, | 671 | GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations, |
666 | opc->op); | 672 | opc->op); |
667 | return opc->op; | 673 | return opc->op; |
diff --git a/src/testbed/testbed_api_peers.h b/src/testbed/testbed_api_peers.h index 9256bf54f..21cae976b 100644 --- a/src/testbed/testbed_api_peers.h +++ b/src/testbed/testbed_api_peers.h | |||
@@ -35,34 +35,34 @@ | |||
35 | /** | 35 | /** |
36 | * Enumeration of possible states a peer could be in | 36 | * Enumeration of possible states a peer could be in |
37 | */ | 37 | */ |
38 | enum PeerState | 38 | enum PeerState |
39 | { | 39 | { |
40 | /** | 40 | /** |
41 | * State to signify that this peer is invalid | 41 | * State to signify that this peer is invalid |
42 | */ | 42 | */ |
43 | PS_INVALID, | 43 | PS_INVALID, |
44 | 44 | ||
45 | /** | 45 | /** |
46 | * The peer has been created | 46 | * The peer has been created |
47 | */ | 47 | */ |
48 | PS_CREATED, | 48 | PS_CREATED, |
49 | 49 | ||
50 | /** | 50 | /** |
51 | * The peer is running | 51 | * The peer is running |
52 | */ | 52 | */ |
53 | PS_STARTED, | 53 | PS_STARTED, |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * The peer is stopped | 56 | * The peer is stopped |
57 | */ | 57 | */ |
58 | PS_STOPPED, | 58 | PS_STOPPED, |
59 | }; | 59 | }; |
60 | 60 | ||
61 | 61 | ||
62 | /** | 62 | /** |
63 | * A peer controlled by the testing framework. A peer runs | 63 | * A peer controlled by the testing framework. A peer runs |
64 | * at a particular host. | 64 | * at a particular host. |
65 | */ | 65 | */ |
66 | struct GNUNET_TESTBED_Peer | 66 | struct GNUNET_TESTBED_Peer |
67 | { | 67 | { |
68 | /** | 68 | /** |
@@ -70,7 +70,7 @@ struct GNUNET_TESTBED_Peer | |||
70 | * that is responsible for starting/running the peer!). | 70 | * that is responsible for starting/running the peer!). |
71 | */ | 71 | */ |
72 | struct GNUNET_TESTBED_Controller *controller; | 72 | struct GNUNET_TESTBED_Controller *controller; |
73 | 73 | ||
74 | /** | 74 | /** |
75 | * Which host does this peer run on? | 75 | * Which host does this peer run on? |
76 | */ | 76 | */ |
@@ -102,12 +102,12 @@ struct PeerCreateData | |||
102 | * The template configuration of the peer | 102 | * The template configuration of the peer |
103 | */ | 103 | */ |
104 | const struct GNUNET_CONFIGURATION_Handle *cfg; | 104 | const struct GNUNET_CONFIGURATION_Handle *cfg; |
105 | 105 | ||
106 | /** | 106 | /** |
107 | * The call back to call when we receive peer create success message | 107 | * The call back to call when we receive peer create success message |
108 | */ | 108 | */ |
109 | GNUNET_TESTBED_PeerCreateCallback cb; | 109 | GNUNET_TESTBED_PeerCreateCallback cb; |
110 | 110 | ||
111 | /** | 111 | /** |
112 | * The closure for the above callback | 112 | * The closure for the above callback |
113 | */ | 113 | */ |
@@ -144,7 +144,7 @@ struct PeerInfoData | |||
144 | * The peer whose information has been requested | 144 | * The peer whose information has been requested |
145 | */ | 145 | */ |
146 | struct GNUNET_TESTBED_Peer *peer; | 146 | struct GNUNET_TESTBED_Peer *peer; |
147 | 147 | ||
148 | /** | 148 | /** |
149 | * The type of peer information requested | 149 | * The type of peer information requested |
150 | */ | 150 | */ |
@@ -232,11 +232,12 @@ struct OverlayConnectData | |||
232 | */ | 232 | */ |
233 | struct GNUNET_TESTBED_Operation * | 233 | struct GNUNET_TESTBED_Operation * |
234 | GNUNET_TESTBED_peer_create_with_id_ (uint32_t unique_id, | 234 | GNUNET_TESTBED_peer_create_with_id_ (uint32_t unique_id, |
235 | struct GNUNET_TESTBED_Controller *controller, | 235 | struct GNUNET_TESTBED_Controller |
236 | struct GNUNET_TESTBED_Host *host, | 236 | *controller, |
237 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 237 | struct GNUNET_TESTBED_Host *host, |
238 | GNUNET_TESTBED_PeerCreateCallback cb, | 238 | const struct GNUNET_CONFIGURATION_Handle |
239 | void *cls); | 239 | *cfg, GNUNET_TESTBED_PeerCreateCallback cb, |
240 | void *cls); | ||
240 | 241 | ||
241 | 242 | ||
242 | /** | 243 | /** |
@@ -245,7 +246,7 @@ GNUNET_TESTBED_peer_create_with_id_ (uint32_t unique_id, | |||
245 | * @param peer_id the id of the peer whose information we have to get | 246 | * @param peer_id the id of the peer whose information we have to get |
246 | * @param operation_id the ip of the operation that should be represented in | 247 | * @param operation_id the ip of the operation that should be represented in |
247 | * the message | 248 | * the message |
248 | * @param | 249 | * @param |
249 | * @return the PeerGetConfigurationMessage | 250 | * @return the PeerGetConfigurationMessage |
250 | */ | 251 | */ |
251 | struct GNUNET_TESTBED_PeerGetConfigurationMessage * | 252 | struct GNUNET_TESTBED_PeerGetConfigurationMessage * |
diff --git a/src/testbed/testbed_api_services.c b/src/testbed/testbed_api_services.c index ea7b50def..f37ada310 100644 --- a/src/testbed/testbed_api_services.c +++ b/src/testbed/testbed_api_services.c | |||
@@ -33,26 +33,26 @@ | |||
33 | * States for Service connect operations | 33 | * States for Service connect operations |
34 | */ | 34 | */ |
35 | enum State | 35 | enum State |
36 | { | 36 | { |
37 | /** | 37 | /** |
38 | * Initial state | 38 | * Initial state |
39 | */ | 39 | */ |
40 | INIT, | 40 | INIT, |
41 | 41 | ||
42 | /** | 42 | /** |
43 | * The configuration request has been sent | 43 | * The configuration request has been sent |
44 | */ | 44 | */ |
45 | CFG_REQUEST_QUEUED, | 45 | CFG_REQUEST_QUEUED, |
46 | 46 | ||
47 | /** | 47 | /** |
48 | * connected to service | 48 | * connected to service |
49 | */ | 49 | */ |
50 | SERVICE_CONNECTED, | 50 | SERVICE_CONNECTED, |
51 | 51 | ||
52 | /** | 52 | /** |
53 | * | 53 | * |
54 | */ | 54 | */ |
55 | }; | 55 | }; |
56 | 56 | ||
57 | 57 | ||
58 | /** | 58 | /** |
@@ -79,7 +79,7 @@ struct ServiceConnectData | |||
79 | * Service name | 79 | * Service name |
80 | */ | 80 | */ |
81 | char *service_name; | 81 | char *service_name; |
82 | 82 | ||
83 | /** | 83 | /** |
84 | * Closure for operation event | 84 | * Closure for operation event |
85 | */ | 85 | */ |
@@ -114,7 +114,7 @@ struct ServiceConnectData | |||
114 | * State information | 114 | * State information |
115 | */ | 115 | */ |
116 | enum State state; | 116 | enum State state; |
117 | 117 | ||
118 | }; | 118 | }; |
119 | 119 | ||
120 | 120 | ||
@@ -125,17 +125,16 @@ struct ServiceConnectData | |||
125 | * @param cls ServiceConnectData | 125 | * @param cls ServiceConnectData |
126 | * @param msg message received, NULL on timeout or fatal error | 126 | * @param msg message received, NULL on timeout or fatal error |
127 | */ | 127 | */ |
128 | static void | 128 | static void |
129 | configuration_receiver (void *cls, | 129 | configuration_receiver (void *cls, const struct GNUNET_MessageHeader *msg) |
130 | const struct GNUNET_MessageHeader *msg) | ||
131 | { | 130 | { |
132 | struct ServiceConnectData *data = cls; | 131 | struct ServiceConnectData *data = cls; |
133 | const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *imsg; | 132 | const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *imsg; |
134 | struct GNUNET_TESTBED_Controller *c; | 133 | struct GNUNET_TESTBED_Controller *c; |
135 | struct GNUNET_TESTBED_EventInformation info; | 134 | struct GNUNET_TESTBED_EventInformation info; |
136 | 135 | ||
137 | imsg = (const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *) | 136 | imsg = |
138 | msg; | 137 | (const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *) msg; |
139 | data->cfg = GNUNET_TESTBED_get_config_from_peerinfo_msg_ (imsg); | 138 | data->cfg = GNUNET_TESTBED_get_config_from_peerinfo_msg_ (imsg); |
140 | data->op_result = data->ca (data->cada_cls, data->cfg); | 139 | data->op_result = data->ca (data->cada_cls, data->cfg); |
141 | info.type = GNUNET_TESTBED_ET_OPERATION_FINISHED; | 140 | info.type = GNUNET_TESTBED_ET_OPERATION_FINISHED; |
@@ -146,9 +145,9 @@ configuration_receiver (void *cls, | |||
146 | info.details.operation_finished.op_result.generic = data->op_result; | 145 | info.details.operation_finished.op_result.generic = data->op_result; |
147 | c = data->peer->controller; | 146 | c = data->peer->controller; |
148 | data->state = SERVICE_CONNECTED; | 147 | data->state = SERVICE_CONNECTED; |
149 | if ((0 != (GNUNET_TESTBED_ET_OPERATION_FINISHED & c->event_mask)) | 148 | if ((0 != (GNUNET_TESTBED_ET_OPERATION_FINISHED & c->event_mask)) && |
150 | && (NULL != c->cc)) | 149 | (NULL != c->cc)) |
151 | c->cc (c->cc_cls, &info); | 150 | c->cc (c->cc_cls, &info); |
152 | } | 151 | } |
153 | 152 | ||
154 | 153 | ||
@@ -157,23 +156,23 @@ configuration_receiver (void *cls, | |||
157 | * | 156 | * |
158 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 157 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
159 | */ | 158 | */ |
160 | static void | 159 | static void |
161 | opstart_service_connect (void *cls) | 160 | opstart_service_connect (void *cls) |
162 | { | 161 | { |
163 | struct ServiceConnectData *data = cls; | 162 | struct ServiceConnectData *data = cls; |
164 | struct GNUNET_TESTBED_PeerGetConfigurationMessage *msg; | 163 | struct GNUNET_TESTBED_PeerGetConfigurationMessage *msg; |
165 | struct GNUNET_TESTBED_Controller *c; | 164 | struct GNUNET_TESTBED_Controller *c; |
166 | uint64_t op_id; | 165 | uint64_t op_id; |
167 | 166 | ||
168 | GNUNET_assert (NULL != data); | 167 | GNUNET_assert (NULL != data); |
169 | GNUNET_assert (NULL != data->peer); | 168 | GNUNET_assert (NULL != data->peer); |
170 | c = data->peer->controller; | 169 | c = data->peer->controller; |
171 | op_id = c->operation_counter++; | 170 | op_id = c->operation_counter++; |
172 | msg = GNUNET_TESTBED_generate_peergetconfig_msg_ (data->peer->unique_id, | 171 | msg = |
173 | op_id); | 172 | GNUNET_TESTBED_generate_peergetconfig_msg_ (data->peer->unique_id, op_id); |
174 | data->opc = | 173 | data->opc = |
175 | GNUNET_TESTBED_forward_operation_msg_ (c, op_id, &msg->header, | 174 | GNUNET_TESTBED_forward_operation_msg_ (c, op_id, &msg->header, |
176 | &configuration_receiver, data); | 175 | &configuration_receiver, data); |
177 | GNUNET_free (msg); | 176 | GNUNET_free (msg); |
178 | data->state = CFG_REQUEST_QUEUED; | 177 | data->state = CFG_REQUEST_QUEUED; |
179 | } | 178 | } |
@@ -185,7 +184,7 @@ opstart_service_connect (void *cls) | |||
185 | * | 184 | * |
186 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 185 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
187 | */ | 186 | */ |
188 | static void | 187 | static void |
189 | oprelease_service_connect (void *cls) | 188 | oprelease_service_connect (void *cls) |
190 | { | 189 | { |
191 | struct ServiceConnectData *data = cls; | 190 | struct ServiceConnectData *data = cls; |
@@ -215,7 +214,7 @@ oprelease_service_connect (void *cls) | |||
215 | * maintain connections with other systems. The actual service | 214 | * maintain connections with other systems. The actual service |
216 | * handle is then returned via the 'op_result' member in the event | 215 | * handle is then returned via the 'op_result' member in the event |
217 | * callback. The 'ca' callback is used to create the connection | 216 | * callback. The 'ca' callback is used to create the connection |
218 | * when the time is right; the 'da' callback will be used to | 217 | * when the time is right; the 'da' callback will be used to |
219 | * destroy the connection (upon 'GNUNET_TESTBED_operation_done'). | 218 | * destroy the connection (upon 'GNUNET_TESTBED_operation_done'). |
220 | * 'GNUNET_TESTBED_operation_cancel' can be used to abort this | 219 | * 'GNUNET_TESTBED_operation_cancel' can be used to abort this |
221 | * operation until the event callback has been called. | 220 | * operation until the event callback has been called. |
@@ -229,12 +228,11 @@ oprelease_service_connect (void *cls) | |||
229 | * @return handle for the operation | 228 | * @return handle for the operation |
230 | */ | 229 | */ |
231 | struct GNUNET_TESTBED_Operation * | 230 | struct GNUNET_TESTBED_Operation * |
232 | GNUNET_TESTBED_service_connect (void *op_cls, | 231 | GNUNET_TESTBED_service_connect (void *op_cls, struct GNUNET_TESTBED_Peer *peer, |
233 | struct GNUNET_TESTBED_Peer *peer, | 232 | const char *service_name, |
234 | const char *service_name, | 233 | GNUNET_TESTBED_ConnectAdapter ca, |
235 | GNUNET_TESTBED_ConnectAdapter ca, | 234 | GNUNET_TESTBED_DisconnectAdapter da, |
236 | GNUNET_TESTBED_DisconnectAdapter da, | 235 | void *cada_cls) |
237 | void *cada_cls) | ||
238 | { | 236 | { |
239 | struct ServiceConnectData *data; | 237 | struct ServiceConnectData *data; |
240 | 238 | ||
@@ -245,14 +243,16 @@ GNUNET_TESTBED_service_connect (void *op_cls, | |||
245 | data->op_cls = op_cls; | 243 | data->op_cls = op_cls; |
246 | data->peer = peer; | 244 | data->peer = peer; |
247 | data->state = INIT; | 245 | data->state = INIT; |
248 | data->operation = | 246 | data->operation = |
249 | GNUNET_TESTBED_operation_create_ (data, &opstart_service_connect, | 247 | GNUNET_TESTBED_operation_create_ (data, &opstart_service_connect, |
250 | &oprelease_service_connect); | 248 | &oprelease_service_connect); |
251 | GNUNET_TESTBED_operation_queue_insert_ | 249 | GNUNET_TESTBED_operation_queue_insert_ (peer-> |
252 | (peer->controller->opq_parallel_service_connections, data->operation); | 250 | controller->opq_parallel_service_connections, |
253 | GNUNET_TESTBED_operation_queue_insert_ | 251 | data->operation); |
254 | (peer->controller->opq_parallel_operations, data->operation); | 252 | GNUNET_TESTBED_operation_queue_insert_ (peer-> |
255 | return data->operation; | 253 | controller->opq_parallel_operations, |
254 | data->operation); | ||
255 | return data->operation; | ||
256 | } | 256 | } |
257 | 257 | ||
258 | /* end of testbed_api_services.c */ | 258 | /* end of testbed_api_services.c */ |
diff --git a/src/testbed/testbed_api_test.c b/src/testbed/testbed_api_test.c index 38e189b18..b532cf64e 100644 --- a/src/testbed/testbed_api_test.c +++ b/src/testbed/testbed_api_test.c | |||
@@ -53,11 +53,10 @@ | |||
53 | * @param test_master_cls closure for 'task'. | 53 | * @param test_master_cls closure for 'task'. |
54 | */ | 54 | */ |
55 | void | 55 | void |
56 | GNUNET_TESTBED_test_run (const char *testname, | 56 | GNUNET_TESTBED_test_run (const char *testname, const char *cfg_filename, |
57 | const char *cfg_filename, | 57 | unsigned int num_peers, |
58 | unsigned int num_peers, | 58 | GNUNET_TESTBED_TestMaster test_master, |
59 | GNUNET_TESTBED_TestMaster test_master, | 59 | void *test_master_cls) |
60 | void *test_master_cls) | ||
61 | { | 60 | { |
62 | GNUNET_break (0); | 61 | GNUNET_break (0); |
63 | } | 62 | } |
diff --git a/src/testbed/testbed_api_testbed.c b/src/testbed/testbed_api_testbed.c index 914523780..fb9ed31b6 100644 --- a/src/testbed/testbed_api_testbed.c +++ b/src/testbed/testbed_api_testbed.c | |||
@@ -61,13 +61,13 @@ struct DLLOperation | |||
61 | /** | 61 | /** |
62 | * Closure | 62 | * Closure |
63 | */ | 63 | */ |
64 | void *cls; | 64 | void *cls; |
65 | 65 | ||
66 | /** | 66 | /** |
67 | * The next pointer for DLL | 67 | * The next pointer for DLL |
68 | */ | 68 | */ |
69 | struct DLLOperation *next; | 69 | struct DLLOperation *next; |
70 | 70 | ||
71 | /** | 71 | /** |
72 | * The prev pointer for DLL | 72 | * The prev pointer for DLL |
73 | */ | 73 | */ |
@@ -78,13 +78,13 @@ struct DLLOperation | |||
78 | /** | 78 | /** |
79 | * States of RunContext | 79 | * States of RunContext |
80 | */ | 80 | */ |
81 | enum State | 81 | enum State |
82 | { | 82 | { |
83 | /** | 83 | /** |
84 | * Initial state | 84 | * Initial state |
85 | */ | 85 | */ |
86 | RC_INIT = 0, | 86 | RC_INIT = 0, |
87 | 87 | ||
88 | /** | 88 | /** |
89 | * Peers have been started | 89 | * Peers have been started |
90 | */ | 90 | */ |
@@ -94,12 +94,11 @@ enum State | |||
94 | * Peers are stopped | 94 | * Peers are stopped |
95 | */ | 95 | */ |
96 | RC_PEERS_STOPPED, | 96 | RC_PEERS_STOPPED, |
97 | 97 | ||
98 | /** | 98 | /** |
99 | * Peers are destroyed | 99 | * Peers are destroyed |
100 | */ | 100 | */ |
101 | RC_PEERS_DESTROYED | 101 | RC_PEERS_DESTROYED |
102 | |||
103 | }; | 102 | }; |
104 | 103 | ||
105 | 104 | ||
@@ -127,17 +126,17 @@ struct RunContext | |||
127 | * The callback to use as controller callback | 126 | * The callback to use as controller callback |
128 | */ | 127 | */ |
129 | GNUNET_TESTBED_ControllerCallback cc; | 128 | GNUNET_TESTBED_ControllerCallback cc; |
130 | 129 | ||
131 | /** | 130 | /** |
132 | * The pointer to the controller callback | 131 | * The pointer to the controller callback |
133 | */ | 132 | */ |
134 | void *cc_cls; | 133 | void *cc_cls; |
135 | 134 | ||
136 | /** | 135 | /** |
137 | * Master task to call when testbed initialization is done | 136 | * Master task to call when testbed initialization is done |
138 | */ | 137 | */ |
139 | GNUNET_SCHEDULER_Task master; | 138 | GNUNET_SCHEDULER_Task master; |
140 | 139 | ||
141 | /** | 140 | /** |
142 | * The closure for the master task | 141 | * The closure for the master task |
143 | */ | 142 | */ |
@@ -147,7 +146,7 @@ struct RunContext | |||
147 | * The head element of DLL operations | 146 | * The head element of DLL operations |
148 | */ | 147 | */ |
149 | struct DLLOperation *dll_op_head; | 148 | struct DLLOperation *dll_op_head; |
150 | 149 | ||
151 | /** | 150 | /** |
152 | * The tail element of DLL operations | 151 | * The tail element of DLL operations |
153 | */ | 152 | */ |
@@ -157,7 +156,7 @@ struct RunContext | |||
157 | * Array of peers which we create | 156 | * Array of peers which we create |
158 | */ | 157 | */ |
159 | struct GNUNET_TESTBED_Peer **peers; | 158 | struct GNUNET_TESTBED_Peer **peers; |
160 | 159 | ||
161 | /** | 160 | /** |
162 | * The event mask for the controller | 161 | * The event mask for the controller |
163 | */ | 162 | */ |
@@ -173,7 +172,7 @@ struct RunContext | |||
173 | * successful operation on a peer | 172 | * successful operation on a peer |
174 | */ | 173 | */ |
175 | unsigned int peer_count; | 174 | unsigned int peer_count; |
176 | 175 | ||
177 | /** | 176 | /** |
178 | * number of peers to start | 177 | * number of peers to start |
179 | */ | 178 | */ |
@@ -203,12 +202,12 @@ struct RunContext | |||
203 | */ | 202 | */ |
204 | struct GNUNET_TESTBED_Testbed * | 203 | struct GNUNET_TESTBED_Testbed * |
205 | GNUNET_TESTBED_create_va (struct GNUNET_TESTBED_Controller *controller, | 204 | GNUNET_TESTBED_create_va (struct GNUNET_TESTBED_Controller *controller, |
206 | unsigned int num_hosts, | 205 | unsigned int num_hosts, |
207 | struct GNUNET_TESTBED_Host **hosts, | 206 | struct GNUNET_TESTBED_Host **hosts, |
208 | unsigned int num_peers, | 207 | unsigned int num_peers, |
209 | const struct GNUNET_CONFIGURATION_Handle *peer_cfg, | 208 | const struct GNUNET_CONFIGURATION_Handle *peer_cfg, |
210 | enum GNUNET_TESTBED_TopologyOption underlay_topology, | 209 | enum GNUNET_TESTBED_TopologyOption underlay_topology, |
211 | va_list va) | 210 | va_list va) |
212 | { | 211 | { |
213 | GNUNET_break (0); | 212 | GNUNET_break (0); |
214 | return NULL; | 213 | return NULL; |
@@ -233,12 +232,12 @@ GNUNET_TESTBED_create_va (struct GNUNET_TESTBED_Controller *controller, | |||
233 | */ | 232 | */ |
234 | struct GNUNET_TESTBED_Testbed * | 233 | struct GNUNET_TESTBED_Testbed * |
235 | GNUNET_TESTBED_create (struct GNUNET_TESTBED_Controller *controller, | 234 | GNUNET_TESTBED_create (struct GNUNET_TESTBED_Controller *controller, |
236 | unsigned int num_hosts, | 235 | unsigned int num_hosts, |
237 | struct GNUNET_TESTBED_Host **hosts, | 236 | struct GNUNET_TESTBED_Host **hosts, |
238 | unsigned int num_peers, | 237 | unsigned int num_peers, |
239 | const struct GNUNET_CONFIGURATION_Handle *peer_cfg, | 238 | const struct GNUNET_CONFIGURATION_Handle *peer_cfg, |
240 | enum GNUNET_TESTBED_TopologyOption underlay_topology, | 239 | enum GNUNET_TESTBED_TopologyOption underlay_topology, |
241 | ...) | 240 | ...) |
242 | { | 241 | { |
243 | GNUNET_break (0); | 242 | GNUNET_break (0); |
244 | return NULL; | 243 | return NULL; |
@@ -268,18 +267,18 @@ static void | |||
268 | start_peers_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 267 | start_peers_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
269 | { | 268 | { |
270 | struct RunContext *rc = cls; | 269 | struct RunContext *rc = cls; |
271 | struct DLLOperation *dll_op; | 270 | struct DLLOperation *dll_op; |
272 | unsigned int peer; | 271 | unsigned int peer; |
273 | 272 | ||
274 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Starting Peers\n"); | 273 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Starting Peers\n"); |
275 | for (peer = 0; peer < rc->num_peers; peer++) | 274 | for (peer = 0; peer < rc->num_peers; peer++) |
276 | { | 275 | { |
277 | dll_op = GNUNET_malloc (sizeof (struct DLLOperation)); | 276 | dll_op = GNUNET_malloc (sizeof (struct DLLOperation)); |
278 | dll_op->op = GNUNET_TESTBED_peer_start (rc->peers[peer]); | 277 | dll_op->op = GNUNET_TESTBED_peer_start (rc->peers[peer]); |
279 | dll_op->cls = rc->peers[peer]; | 278 | dll_op->cls = rc->peers[peer]; |
280 | GNUNET_CONTAINER_DLL_insert_tail (rc->dll_op_head, rc->dll_op_tail, dll_op); | 279 | GNUNET_CONTAINER_DLL_insert_tail (rc->dll_op_head, rc->dll_op_tail, dll_op); |
281 | } | 280 | } |
282 | rc->peer_count = 0; | 281 | rc->peer_count = 0; |
283 | } | 282 | } |
284 | 283 | ||
285 | 284 | ||
@@ -292,17 +291,17 @@ start_peers_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
292 | * creation | 291 | * creation |
293 | * @param emsg NULL if peer is not NULL; else MAY contain the error description | 292 | * @param emsg NULL if peer is not NULL; else MAY contain the error description |
294 | */ | 293 | */ |
295 | static void | 294 | static void |
296 | peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg) | 295 | peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg) |
297 | { | 296 | { |
298 | struct DLLOperation *dll_op = cls; | 297 | struct DLLOperation *dll_op = cls; |
299 | struct RunContext *rc; | 298 | struct RunContext *rc; |
300 | 299 | ||
301 | GNUNET_assert (NULL != dll_op); | 300 | GNUNET_assert (NULL != dll_op); |
302 | rc = dll_op->rc; | 301 | rc = dll_op->rc; |
303 | GNUNET_assert (NULL != rc); | 302 | GNUNET_assert (NULL != rc); |
304 | GNUNET_CONTAINER_DLL_remove (rc->dll_op_head, rc->dll_op_tail, dll_op); | 303 | GNUNET_CONTAINER_DLL_remove (rc->dll_op_head, rc->dll_op_tail, dll_op); |
305 | GNUNET_TESTBED_operation_done (dll_op->op); | 304 | GNUNET_TESTBED_operation_done (dll_op->op); |
306 | GNUNET_free (dll_op); | 305 | GNUNET_free (dll_op); |
307 | if (NULL == peer) | 306 | if (NULL == peer) |
308 | { | 307 | { |
@@ -316,7 +315,7 @@ peer_create_cb (void *cls, struct GNUNET_TESTBED_Peer *peer, const char *emsg) | |||
316 | rc->peer_count++; | 315 | rc->peer_count++; |
317 | if (rc->peer_count < rc->num_peers) | 316 | if (rc->peer_count < rc->num_peers) |
318 | return; | 317 | return; |
319 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Required peers created successfully\n"); | 318 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Required peers created successfully\n"); |
320 | GNUNET_SCHEDULER_add_now (&start_peers_task, rc); | 319 | GNUNET_SCHEDULER_add_now (&start_peers_task, rc); |
321 | } | 320 | } |
322 | 321 | ||
@@ -331,8 +330,8 @@ static void | |||
331 | cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 330 | cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
332 | { | 331 | { |
333 | struct RunContext *rc = cls; | 332 | struct RunContext *rc = cls; |
334 | struct DLLOperation *dll_op; | 333 | struct DLLOperation *dll_op; |
335 | 334 | ||
336 | GNUNET_assert (NULL == rc->peers); | 335 | GNUNET_assert (NULL == rc->peers); |
337 | GNUNET_assert (RC_PEERS_DESTROYED == rc->state); | 336 | GNUNET_assert (RC_PEERS_DESTROYED == rc->state); |
338 | if (NULL != rc->c) | 337 | if (NULL != rc->c) |
@@ -363,21 +362,21 @@ cleanup_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
363 | * @param cls closure | 362 | * @param cls closure |
364 | * @param event information about the event | 363 | * @param event information about the event |
365 | */ | 364 | */ |
366 | static void | 365 | static void |
367 | event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | 366 | event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) |
368 | { | 367 | { |
369 | struct RunContext *rc = cls; | 368 | struct RunContext *rc = cls; |
370 | struct DLLOperation *dll_op; | 369 | struct DLLOperation *dll_op; |
371 | unsigned int peer_id; | 370 | unsigned int peer_id; |
372 | |||
373 | 371 | ||
374 | if ((RC_INIT != rc->state) && | 372 | |
375 | ((GNUNET_TESTBED_ET_OPERATION_FINISHED == event->type)|| | 373 | if ((RC_INIT != rc->state) && |
374 | ((GNUNET_TESTBED_ET_OPERATION_FINISHED == event->type) || | ||
376 | (GNUNET_TESTBED_ET_PEER_STOP == event->type))) | 375 | (GNUNET_TESTBED_ET_PEER_STOP == event->type))) |
377 | { | 376 | { |
378 | for (dll_op = rc->dll_op_head; NULL != dll_op; dll_op = dll_op->next) | 377 | for (dll_op = rc->dll_op_head; NULL != dll_op; dll_op = dll_op->next) |
379 | { | 378 | { |
380 | if ((GNUNET_TESTBED_ET_OPERATION_FINISHED == event->type) && | 379 | if ((GNUNET_TESTBED_ET_OPERATION_FINISHED == event->type) && |
381 | (event->details.operation_finished.operation == dll_op->op)) | 380 | (event->details.operation_finished.operation == dll_op->op)) |
382 | break; | 381 | break; |
383 | if ((GNUNET_TESTBED_ET_PEER_STOP == event->type) && | 382 | if ((GNUNET_TESTBED_ET_PEER_STOP == event->type) && |
@@ -418,12 +417,12 @@ event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
418 | return; | 417 | return; |
419 | } | 418 | } |
420 | 419 | ||
421 | call_cc: | 420 | call_cc: |
422 | rc->cc (rc->cc_cls, event); | 421 | rc->cc (rc->cc_cls, event); |
423 | if (GNUNET_TESTBED_ET_PEER_START != event->type) | 422 | if (GNUNET_TESTBED_ET_PEER_START != event->type) |
424 | return; | 423 | return; |
425 | for (dll_op = rc->dll_op_head; NULL != dll_op; dll_op = dll_op->next) | 424 | for (dll_op = rc->dll_op_head; NULL != dll_op; dll_op = dll_op->next) |
426 | if ((NULL != dll_op->cls) && | 425 | if ((NULL != dll_op->cls) && |
427 | (event->details.peer_start.peer == dll_op->cls)) | 426 | (event->details.peer_start.peer == dll_op->cls)) |
428 | break; | 427 | break; |
429 | GNUNET_assert (NULL != dll_op); | 428 | GNUNET_assert (NULL != dll_op); |
@@ -436,7 +435,7 @@ event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
436 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers started successfully\n"); | 435 | LOG (GNUNET_ERROR_TYPE_DEBUG, "Peers started successfully\n"); |
437 | rc->state = RC_PEERS_STARTED; | 436 | rc->state = RC_PEERS_STARTED; |
438 | GNUNET_SCHEDULER_add_continuation (rc->master, rc->master_cls, | 437 | GNUNET_SCHEDULER_add_continuation (rc->master, rc->master_cls, |
439 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 438 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
440 | } | 439 | } |
441 | 440 | ||
442 | 441 | ||
@@ -450,32 +449,33 @@ event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event) | |||
450 | * @param status GNUNET_OK if the startup is successfull; GNUNET_SYSERR if not, | 449 | * @param status GNUNET_OK if the startup is successfull; GNUNET_SYSERR if not, |
451 | * GNUNET_TESTBED_controller_stop() shouldn't be called in this case | 450 | * GNUNET_TESTBED_controller_stop() shouldn't be called in this case |
452 | */ | 451 | */ |
453 | static void | 452 | static void |
454 | controller_status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, | 453 | controller_status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, |
455 | int status) | 454 | int status) |
456 | { | 455 | { |
457 | struct RunContext *rc = cls; | 456 | struct RunContext *rc = cls; |
458 | struct DLLOperation *dll_op; | 457 | struct DLLOperation *dll_op; |
459 | unsigned int peer; | 458 | unsigned int peer; |
460 | 459 | ||
461 | if (status != GNUNET_OK) | 460 | if (status != GNUNET_OK) |
462 | { | 461 | { |
463 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Testbed startup failed\n"); | 462 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Testbed startup failed\n"); |
464 | return; | 463 | return; |
465 | } | 464 | } |
466 | rc->c = GNUNET_TESTBED_controller_connect (cfg, rc->h, rc->event_mask, | 465 | rc->c = |
467 | &event_cb, rc); | 466 | GNUNET_TESTBED_controller_connect (cfg, rc->h, rc->event_mask, &event_cb, |
468 | rc->peers = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Peer *) | 467 | rc); |
469 | * rc->num_peers); | 468 | rc->peers = |
469 | GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Peer *) * rc->num_peers); | ||
470 | GNUNET_assert (NULL != rc->c); | 470 | GNUNET_assert (NULL != rc->c); |
471 | rc->peer_count = 0; | 471 | rc->peer_count = 0; |
472 | for (peer = 0; peer < rc->num_peers; peer++) | 472 | for (peer = 0; peer < rc->num_peers; peer++) |
473 | { | 473 | { |
474 | dll_op = GNUNET_malloc (sizeof (struct DLLOperation)); | 474 | dll_op = GNUNET_malloc (sizeof (struct DLLOperation)); |
475 | dll_op->rc = rc; | 475 | dll_op->rc = rc; |
476 | dll_op->op = GNUNET_TESTBED_peer_create (rc->c, rc->h, cfg, peer_create_cb, | 476 | dll_op->op = |
477 | dll_op); | 477 | GNUNET_TESTBED_peer_create (rc->c, rc->h, cfg, peer_create_cb, dll_op); |
478 | GNUNET_CONTAINER_DLL_insert_tail (rc->dll_op_head, rc->dll_op_tail, dll_op); | 478 | GNUNET_CONTAINER_DLL_insert_tail (rc->dll_op_head, rc->dll_op_tail, dll_op); |
479 | } | 479 | } |
480 | } | 480 | } |
481 | 481 | ||
@@ -488,11 +488,11 @@ controller_status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
488 | */ | 488 | */ |
489 | void | 489 | void |
490 | shutdown_run_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 490 | shutdown_run_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
491 | { | 491 | { |
492 | struct RunContext *rc = cls; | 492 | struct RunContext *rc = cls; |
493 | struct DLLOperation *dll_op; | 493 | struct DLLOperation *dll_op; |
494 | unsigned int peer; | 494 | unsigned int peer; |
495 | 495 | ||
496 | if (NULL != rc->c) | 496 | if (NULL != rc->c) |
497 | { | 497 | { |
498 | if (NULL != rc->peers) | 498 | if (NULL != rc->peers) |
@@ -509,8 +509,8 @@ shutdown_run_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
509 | return; | 509 | return; |
510 | } | 510 | } |
511 | } | 511 | } |
512 | rc->state = RC_PEERS_DESTROYED; /* No peers are present so we consider the | 512 | rc->state = RC_PEERS_DESTROYED; /* No peers are present so we consider the |
513 | state where all peers are destroyed */ | 513 | * state where all peers are destroyed */ |
514 | GNUNET_SCHEDULER_add_now (&cleanup_task, rc); | 514 | GNUNET_SCHEDULER_add_now (&cleanup_task, rc); |
515 | } | 515 | } |
516 | 516 | ||
@@ -540,25 +540,23 @@ shutdown_run_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
540 | */ | 540 | */ |
541 | void | 541 | void |
542 | GNUNET_TESTBED_run (const char *host_filename, | 542 | GNUNET_TESTBED_run (const char *host_filename, |
543 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 543 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
544 | unsigned int num_peers, | 544 | unsigned int num_peers, uint64_t event_mask, |
545 | uint64_t event_mask, | 545 | GNUNET_TESTBED_ControllerCallback cc, void *cc_cls, |
546 | GNUNET_TESTBED_ControllerCallback cc, | 546 | GNUNET_SCHEDULER_Task master, void *master_cls) |
547 | void *cc_cls, | ||
548 | GNUNET_SCHEDULER_Task master, | ||
549 | void *master_cls) | ||
550 | { | 547 | { |
551 | struct RunContext *rc; | 548 | struct RunContext *rc; |
552 | 549 | ||
553 | event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START); | 550 | event_mask |= (1LL << GNUNET_TESTBED_ET_PEER_START); |
554 | rc = GNUNET_malloc (sizeof (struct RunContext)); | 551 | rc = GNUNET_malloc (sizeof (struct RunContext)); |
555 | GNUNET_break (NULL == host_filename); /* Currently we do not support host | 552 | GNUNET_break (NULL == host_filename); /* Currently we do not support host |
556 | files */ | 553 | * files */ |
557 | host_filename = NULL; | 554 | host_filename = NULL; |
558 | rc->h = GNUNET_TESTBED_host_create (NULL, NULL, 0); | 555 | rc->h = GNUNET_TESTBED_host_create (NULL, NULL, 0); |
559 | GNUNET_assert (NULL != rc->h); | 556 | GNUNET_assert (NULL != rc->h); |
560 | rc->cproc = GNUNET_TESTBED_controller_start ("127.0.0.1", rc->h, cfg, | 557 | rc->cproc = |
561 | &controller_status_cb, rc); | 558 | GNUNET_TESTBED_controller_start ("127.0.0.1", rc->h, cfg, |
559 | &controller_status_cb, rc); | ||
562 | GNUNET_assert (NULL != rc->cproc); | 560 | GNUNET_assert (NULL != rc->cproc); |
563 | rc->num_peers = num_peers; | 561 | rc->num_peers = num_peers; |
564 | rc->event_mask = event_mask; | 562 | rc->event_mask = event_mask; |
diff --git a/src/testbed/testbed_api_topology.c b/src/testbed/testbed_api_topology.c index c0e9f7296..e21a2dbf2 100644 --- a/src/testbed/testbed_api_topology.c +++ b/src/testbed/testbed_api_topology.c | |||
@@ -40,10 +40,12 @@ | |||
40 | */ | 40 | */ |
41 | struct GNUNET_TESTBED_Operation * | 41 | struct GNUNET_TESTBED_Operation * |
42 | GNUNET_TESTBED_underlay_configure_topology_va (void *op_cls, | 42 | GNUNET_TESTBED_underlay_configure_topology_va (void *op_cls, |
43 | unsigned int num_peers, | 43 | unsigned int num_peers, |
44 | struct GNUNET_TESTBED_Peer **peers, | 44 | struct GNUNET_TESTBED_Peer |
45 | enum GNUNET_TESTBED_TopologyOption topo, | 45 | **peers, |
46 | va_list ap) | 46 | enum |
47 | GNUNET_TESTBED_TopologyOption | ||
48 | topo, va_list ap) | ||
47 | { | 49 | { |
48 | GNUNET_break (0); | 50 | GNUNET_break (0); |
49 | return NULL; | 51 | return NULL; |
@@ -63,10 +65,10 @@ GNUNET_TESTBED_underlay_configure_topology_va (void *op_cls, | |||
63 | */ | 65 | */ |
64 | struct GNUNET_TESTBED_Operation * | 66 | struct GNUNET_TESTBED_Operation * |
65 | GNUNET_TESTBED_underlay_configure_topology (void *op_cls, | 67 | GNUNET_TESTBED_underlay_configure_topology (void *op_cls, |
66 | unsigned int num_peers, | 68 | unsigned int num_peers, |
67 | struct GNUNET_TESTBED_Peer **peers, | 69 | struct GNUNET_TESTBED_Peer **peers, |
68 | enum GNUNET_TESTBED_TopologyOption topo, | 70 | enum GNUNET_TESTBED_TopologyOption |
69 | ...) | 71 | topo, ...) |
70 | { | 72 | { |
71 | GNUNET_break (0); | 73 | GNUNET_break (0); |
72 | return NULL; | 74 | return NULL; |
@@ -83,16 +85,16 @@ GNUNET_TESTBED_underlay_configure_topology (void *op_cls, | |||
83 | * @param peers array of 'num_peers' with the peers to configure | 85 | * @param peers array of 'num_peers' with the peers to configure |
84 | * @param topo desired underlay topology to use | 86 | * @param topo desired underlay topology to use |
85 | * @param va topology-specific options | 87 | * @param va topology-specific options |
86 | * @return handle to the operation, NULL if connecting these | 88 | * @return handle to the operation, NULL if connecting these |
87 | * peers is fundamentally not possible at this time (peers | 89 | * peers is fundamentally not possible at this time (peers |
88 | * not running or underlay disallows) | 90 | * not running or underlay disallows) |
89 | */ | 91 | */ |
90 | struct GNUNET_TESTBED_Operation * | 92 | struct GNUNET_TESTBED_Operation * |
91 | GNUNET_TESTBED_overlay_configure_topology_va (void *op_cls, | 93 | GNUNET_TESTBED_overlay_configure_topology_va (void *op_cls, |
92 | unsigned int num_peers, | 94 | unsigned int num_peers, |
93 | struct GNUNET_TESTBED_Peer *peers, | 95 | struct GNUNET_TESTBED_Peer *peers, |
94 | enum GNUNET_TESTBED_TopologyOption topo, | 96 | enum GNUNET_TESTBED_TopologyOption |
95 | va_list va) | 97 | topo, va_list va) |
96 | { | 98 | { |
97 | GNUNET_break (0); | 99 | GNUNET_break (0); |
98 | return NULL; | 100 | return NULL; |
@@ -109,16 +111,15 @@ GNUNET_TESTBED_overlay_configure_topology_va (void *op_cls, | |||
109 | * @param peers array of 'num_peers' with the peers to configure | 111 | * @param peers array of 'num_peers' with the peers to configure |
110 | * @param topo desired underlay topology to use | 112 | * @param topo desired underlay topology to use |
111 | * @param ... topology-specific options | 113 | * @param ... topology-specific options |
112 | * @return handle to the operation, NULL if connecting these | 114 | * @return handle to the operation, NULL if connecting these |
113 | * peers is fundamentally not possible at this time (peers | 115 | * peers is fundamentally not possible at this time (peers |
114 | * not running or underlay disallows) | 116 | * not running or underlay disallows) |
115 | */ | 117 | */ |
116 | struct GNUNET_TESTBED_Operation * | 118 | struct GNUNET_TESTBED_Operation * |
117 | GNUNET_TESTBED_overlay_configure_topology (void *op_cls, | 119 | GNUNET_TESTBED_overlay_configure_topology (void *op_cls, unsigned int num_peers, |
118 | unsigned int num_peers, | 120 | struct GNUNET_TESTBED_Peer *peers, |
119 | struct GNUNET_TESTBED_Peer *peers, | 121 | enum GNUNET_TESTBED_TopologyOption |
120 | enum GNUNET_TESTBED_TopologyOption topo, | 122 | topo, ...) |
121 | ...) | ||
122 | { | 123 | { |
123 | GNUNET_break (0); | 124 | GNUNET_break (0); |
124 | return NULL; | 125 | return NULL; |
diff --git a/src/testbed/testbed_helper.h b/src/testbed/testbed_helper.h index 6fa35f08b..1bc6bffc3 100644 --- a/src/testbed/testbed_helper.h +++ b/src/testbed/testbed_helper.h | |||
@@ -22,7 +22,7 @@ | |||
22 | * @file testbed/testbed_helper.h | 22 | * @file testbed/testbed_helper.h |
23 | * @brief Message formats for communication between testbed api and | 23 | * @brief Message formats for communication between testbed api and |
24 | * gnunet-testbed-helper process | 24 | * gnunet-testbed-helper process |
25 | * @author Sree Harsha Totakura <sreeharsha@totakura.in> | 25 | * @author Sree Harsha Totakura <sreeharsha@totakura.in> |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #ifndef TESTBED_HELPER_H | 28 | #ifndef TESTBED_HELPER_H |
@@ -40,7 +40,7 @@ struct GNUNET_TESTBED_HelperInit | |||
40 | 40 | ||
41 | /** | 41 | /** |
42 | * The controller hostname size excluding the NULL termination character - | 42 | * The controller hostname size excluding the NULL termination character - |
43 | * strlen (hostname); cannot be zero | 43 | * strlen (hostname); cannot be zero |
44 | */ | 44 | */ |
45 | uint16_t cname_size GNUNET_PACKED; | 45 | uint16_t cname_size GNUNET_PACKED; |
46 | 46 | ||
@@ -50,9 +50,9 @@ struct GNUNET_TESTBED_HelperInit | |||
50 | uint16_t config_size GNUNET_PACKED; | 50 | uint16_t config_size GNUNET_PACKED; |
51 | 51 | ||
52 | /* Followed by NULL terminated controller hostname */ | 52 | /* Followed by NULL terminated controller hostname */ |
53 | 53 | ||
54 | /* Followed by serialized and compressed configuration which should be | 54 | /* Followed by serialized and compressed configuration which should be |
55 | config_size long when un-compressed */ | 55 | * config_size long when un-compressed */ |
56 | }; | 56 | }; |
57 | 57 | ||
58 | /** | 58 | /** |
@@ -71,7 +71,7 @@ struct GNUNET_TESTBED_HelperReply | |||
71 | uint16_t config_size GNUNET_PACKED; | 71 | uint16_t config_size GNUNET_PACKED; |
72 | 72 | ||
73 | /* Followed by compressed configuration which should be config_size long when | 73 | /* Followed by compressed configuration which should be config_size long when |
74 | un-compressed */ | 74 | * un-compressed */ |
75 | }; | 75 | }; |
76 | 76 | ||
77 | #endif | 77 | #endif |