diff options
-rw-r--r-- | src/transport/Makefile.am | 6 | ||||
-rw-r--r-- | src/transport/test_communicator_unix.c | 25 | ||||
-rw-r--r-- | src/transport/transport-testing2.c | 49 | ||||
-rw-r--r-- | src/transport/transport-testing2.h | 1 |
4 files changed, 50 insertions, 31 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index 4fd54ac88..5c3721faa 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am | |||
@@ -249,7 +249,9 @@ libexec_PROGRAMS = \ | |||
249 | $(WLAN_BIN_DUMMY) \ | 249 | $(WLAN_BIN_DUMMY) \ |
250 | $(BT_BIN) \ | 250 | $(BT_BIN) \ |
251 | gnunet-service-transport \ | 251 | gnunet-service-transport \ |
252 | gnunet-communicator-unix | 252 | gnunet-communicator-unix \ |
253 | gnunet-communicator-udp \ | ||
254 | gnunet-communicator-tcp | ||
253 | 255 | ||
254 | 256 | ||
255 | 257 | ||
@@ -600,6 +602,8 @@ if HAVE_GETOPT_BINARY | |||
600 | check_PROGRAMS += \ | 602 | check_PROGRAMS += \ |
601 | test_transport_api_slow_ats | 603 | test_transport_api_slow_ats |
602 | endif | 604 | endif |
605 | check_PROGRAMS += \ | ||
606 | test_communicator_unix | ||
603 | endif | 607 | endif |
604 | 608 | ||
605 | if ENABLE_TEST_RUN | 609 | if ENABLE_TEST_RUN |
diff --git a/src/transport/test_communicator_unix.c b/src/transport/test_communicator_unix.c index e52391ef2..459af116a 100644 --- a/src/transport/test_communicator_unix.c +++ b/src/transport/test_communicator_unix.c | |||
@@ -32,18 +32,6 @@ | |||
32 | 32 | ||
33 | #include <inttypes.h> | 33 | #include <inttypes.h> |
34 | 34 | ||
35 | /** | ||
36 | * TODO | ||
37 | * - start two communicators | ||
38 | * - act like transport services | ||
39 | * - get_server_addresses (service.c) | ||
40 | * - open_listen_socket (service.c) | ||
41 | * - GNUNET_MQ_queue_for_callbacks (service.c) | ||
42 | * - let them communicate | ||
43 | * | ||
44 | */ | ||
45 | |||
46 | |||
47 | 35 | ||
48 | #define LOG(kind,...) GNUNET_log_from (kind, "test_transport_communicator_unix", __VA_ARGS__) | 36 | #define LOG(kind,...) GNUNET_log_from (kind, "test_transport_communicator_unix", __VA_ARGS__) |
49 | 37 | ||
@@ -55,6 +43,14 @@ static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_hs[NUM_PE | |||
55 | 43 | ||
56 | //static char *addresses[NUM_PEERS]; | 44 | //static char *addresses[NUM_PEERS]; |
57 | 45 | ||
46 | |||
47 | #define PAYLOAD_SIZE 256 | ||
48 | |||
49 | //static char payload[PAYLOAD_SIZE] = "TEST PAYLOAD"; | ||
50 | //static char payload[] = "TEST PAYLOAD"; | ||
51 | static uint32_t payload = 42; | ||
52 | |||
53 | |||
58 | static void | 54 | static void |
59 | communicator_available_cb (void *cls, | 55 | communicator_available_cb (void *cls, |
60 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, | 56 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, |
@@ -110,6 +106,9 @@ add_queue_cb (void *cls, | |||
110 | { | 106 | { |
111 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 107 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
112 | "Got Queue!\n"); | 108 | "Got Queue!\n"); |
109 | GNUNET_TRANSPORT_TESTING_transport_communicator_send (tc_queue, | ||
110 | &payload, | ||
111 | sizeof (payload)); | ||
113 | } | 112 | } |
114 | 113 | ||
115 | 114 | ||
@@ -120,6 +119,7 @@ run (void *cls) | |||
120 | 119 | ||
121 | tc_hs[0] = GNUNET_TRANSPORT_TESTING_transport_communicator_service_start ( | 120 | tc_hs[0] = GNUNET_TRANSPORT_TESTING_transport_communicator_service_start ( |
122 | "transport", | 121 | "transport", |
122 | "gnunet-communicator-unix", | ||
123 | "test_communicator_1.conf", | 123 | "test_communicator_1.conf", |
124 | &communicator_available_cb, | 124 | &communicator_available_cb, |
125 | NULL, | 125 | NULL, |
@@ -128,6 +128,7 @@ run (void *cls) | |||
128 | NULL); /* cls */ | 128 | NULL); /* cls */ |
129 | tc_hs[1] = GNUNET_TRANSPORT_TESTING_transport_communicator_service_start ( | 129 | tc_hs[1] = GNUNET_TRANSPORT_TESTING_transport_communicator_service_start ( |
130 | "transport", | 130 | "transport", |
131 | "gnunet-communicator-unix", | ||
131 | "test_communicator_2.conf", | 132 | "test_communicator_2.conf", |
132 | &communicator_available_cb, | 133 | &communicator_available_cb, |
133 | &add_address_cb, | 134 | &add_address_cb, |
diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c index 9bbd15983..ff8e15719 100644 --- a/src/transport/transport-testing2.c +++ b/src/transport/transport-testing2.c | |||
@@ -541,19 +541,20 @@ shutdown_communicator (void *cls) | |||
541 | */ | 541 | */ |
542 | static void | 542 | static void |
543 | communicator_start ( | 543 | communicator_start ( |
544 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h) | 544 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h, |
545 | const char *binary_name) | ||
545 | { | 546 | { |
546 | char *binary; | 547 | char *binary; |
547 | 548 | ||
548 | LOG (GNUNET_ERROR_TYPE_DEBUG, "communicator_start\n"); | 549 | LOG (GNUNET_ERROR_TYPE_DEBUG, "communicator_start\n"); |
549 | binary = GNUNET_OS_get_libexec_binary_path ("gnunet-communicator-unix"); | 550 | binary = GNUNET_OS_get_libexec_binary_path (binary_name); |
550 | tc_h->c_proc = GNUNET_OS_start_process (GNUNET_YES, | 551 | tc_h->c_proc = GNUNET_OS_start_process (GNUNET_YES, |
551 | GNUNET_OS_INHERIT_STD_OUT_AND_ERR, | 552 | GNUNET_OS_INHERIT_STD_OUT_AND_ERR, |
552 | NULL, | 553 | NULL, |
553 | NULL, | 554 | NULL, |
554 | NULL, | 555 | NULL, |
555 | binary, | 556 | binary, |
556 | "./gnunet-communicator-unix", | 557 | binary_name, |
557 | "-c", | 558 | "-c", |
558 | tc_h->cfg_filename, | 559 | tc_h->cfg_filename, |
559 | NULL); | 560 | NULL); |
@@ -583,14 +584,15 @@ communicator_start ( | |||
583 | */ | 584 | */ |
584 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * | 585 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * |
585 | GNUNET_TRANSPORT_TESTING_transport_communicator_service_start ( | 586 | GNUNET_TRANSPORT_TESTING_transport_communicator_service_start ( |
586 | const char *service_name, | 587 | const char *service_name, |
587 | const char *cfg_filename, | 588 | const char *binary_name, |
588 | GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback | 589 | const char *cfg_filename, |
589 | communicator_available_cb, | 590 | GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback |
590 | GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb, | 591 | communicator_available_cb, |
591 | GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb, | 592 | GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb, |
592 | GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb, | 593 | GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb, |
593 | void *cb_cls) | 594 | GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb, |
595 | void *cb_cls) | ||
594 | { | 596 | { |
595 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h; | 597 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h; |
596 | 598 | ||
@@ -618,7 +620,8 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_service_start ( | |||
618 | transport_communicator_start (tc_h); | 620 | transport_communicator_start (tc_h); |
619 | 621 | ||
620 | /* Schedule start communicator */ | 622 | /* Schedule start communicator */ |
621 | communicator_start (tc_h); | 623 | communicator_start (tc_h, |
624 | binary_name); | ||
622 | return tc_h; | 625 | return tc_h; |
623 | } | 626 | } |
624 | 627 | ||
@@ -638,6 +641,7 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue ( | |||
638 | 641 | ||
639 | tc_queue = | 642 | tc_queue = |
640 | GNUNET_new (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue); | 643 | GNUNET_new (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue); |
644 | tc_queue->tc_h = tc_h; | ||
641 | prefix = GNUNET_HELLO_address_to_prefix (address); | 645 | prefix = GNUNET_HELLO_address_to_prefix (address); |
642 | if (NULL == prefix) | 646 | if (NULL == prefix) |
643 | { | 647 | { |
@@ -674,18 +678,27 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_send | |||
674 | GNUNET_TRANSPORT_TESTING_SuccessStatus cb, | 678 | GNUNET_TRANSPORT_TESTING_SuccessStatus cb, |
675 | void *cb_cls*/) | 679 | void *cb_cls*/) |
676 | { | 680 | { |
677 | // struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission *tc_t; | 681 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission *tc_t; |
682 | struct GNUNET_MessageHeader *mh; | ||
678 | struct GNUNET_TRANSPORT_SendMessageTo *msg; | 683 | struct GNUNET_TRANSPORT_SendMessageTo *msg; |
679 | struct GNUNET_MQ_Envelope *env; | 684 | struct GNUNET_MQ_Envelope *env; |
680 | 685 | size_t inbox_size; | |
686 | |||
687 | inbox_size = sizeof (struct GNUNET_MessageHeader) + payload_size; | ||
688 | mh = GNUNET_malloc (inbox_size); | ||
689 | mh->size = htons (inbox_size); | ||
690 | mh->type = GNUNET_MESSAGE_TYPE_DUMMY; | ||
691 | memcpy (&mh[1], | ||
692 | payload, | ||
693 | payload_size); | ||
681 | env = GNUNET_MQ_msg_extra (msg, | 694 | env = GNUNET_MQ_msg_extra (msg, |
682 | payload_size, | 695 | inbox_size, |
683 | GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG); | 696 | GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG); |
684 | msg->qid = htonl (tc_queue->qid); | 697 | msg->qid = htonl (tc_queue->qid); |
685 | msg->mid = tc_queue->mid++; | 698 | msg->mid = tc_queue->mid++; |
686 | msg->receiver = tc_queue->peer_id; | 699 | msg->receiver = tc_queue->peer_id; |
687 | memcpy (&msg[1], payload, payload_size); | 700 | memcpy (&msg[1], mh, inbox_size); |
701 | GNUNET_free (mh); | ||
688 | GNUNET_MQ_send (tc_queue->tc_h->c_mq, env); | 702 | GNUNET_MQ_send (tc_queue->tc_h->c_mq, env); |
689 | GNUNET_break (0); /* fixme: return value? */ | 703 | return tc_t; |
690 | return NULL; // tc_t; | ||
691 | } | 704 | } |
diff --git a/src/transport/transport-testing2.h b/src/transport/transport-testing2.h index 4b9eb0f54..83d98baab 100644 --- a/src/transport/transport-testing2.h +++ b/src/transport/transport-testing2.h | |||
@@ -84,6 +84,7 @@ typedef void | |||
84 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * | 84 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * |
85 | GNUNET_TRANSPORT_TESTING_transport_communicator_service_start | 85 | GNUNET_TRANSPORT_TESTING_transport_communicator_service_start |
86 | (const char *service_name, | 86 | (const char *service_name, |
87 | const char *binary_name, | ||
87 | const char *cfg_filename, | 88 | const char *cfg_filename, |
88 | GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback communicator_available_cb, | 89 | GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback communicator_available_cb, |
89 | GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb, | 90 | GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb, |