aboutsummaryrefslogtreecommitdiff
path: root/src/transport/transport-testing2.c
diff options
context:
space:
mode:
authorJulius Bünger <buenger@mytum.de>2019-06-06 03:29:37 +0200
committerJulius Bünger <buenger@mytum.de>2019-06-06 03:29:37 +0200
commit17cee253b6820e1c7aa18e51344a2fd5a14b809d (patch)
tree7f9a29ebf337bc60eeed6c657ac83238b43454db /src/transport/transport-testing2.c
parentc2eeb2f69ab1f0aa248781bebf04617cf9908e4b (diff)
downloadgnunet-17cee253b6820e1c7aa18e51344a2fd5a14b809d.tar.gz
gnunet-17cee253b6820e1c7aa18e51344a2fd5a14b809d.zip
TNG testing: Make executable name variable, try sending test data
Diffstat (limited to 'src/transport/transport-testing2.c')
-rw-r--r--src/transport/transport-testing2.c49
1 files changed, 31 insertions, 18 deletions
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 */
542static void 542static void
543communicator_start ( 543communicator_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 */
584struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle * 585struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *
585GNUNET_TRANSPORT_TESTING_transport_communicator_service_start ( 586GNUNET_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}