diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2020-02-15 14:46:13 +0100 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2020-02-15 14:46:13 +0100 |
commit | 7d5ac971847a289b5923fec845349c342a61ddf7 (patch) | |
tree | 100221acf4cbffb81b3e72bf8fc24bd32e973bf4 /src/transport/transport-testing2.c | |
parent | 61f7c7d61727a1da4be4b31721503c88d0c86425 (diff) | |
parent | b03978816ac35a1123456c2d872d4330bfcc3ae1 (diff) | |
download | gnunet-7d5ac971847a289b5923fec845349c342a61ddf7.tar.gz gnunet-7d5ac971847a289b5923fec845349c342a61ddf7.zip |
Merge branch 'master' of ssh://gnunet.org/gnunet
Diffstat (limited to 'src/transport/transport-testing2.c')
-rw-r--r-- | src/transport/transport-testing2.c | 59 |
1 files changed, 31 insertions, 28 deletions
diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c index 75864294b..b087f6976 100644 --- a/src/transport/transport-testing2.c +++ b/src/transport/transport-testing2.c | |||
@@ -858,16 +858,6 @@ nat_start ( | |||
858 | } | 858 | } |
859 | 859 | ||
860 | 860 | ||
861 | static void | ||
862 | do_shutdown (void *cls) | ||
863 | { | ||
864 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; | ||
865 | shutdown_communicator (tc_h->c_proc); | ||
866 | shutdown_service (tc_h->sh); | ||
867 | shutdown_nat (tc_h->nat_proc); | ||
868 | } | ||
869 | |||
870 | |||
871 | /** | 861 | /** |
872 | * @brief Start communicator part of transport service and communicator | 862 | * @brief Start communicator part of transport service and communicator |
873 | * | 863 | * |
@@ -928,11 +918,22 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_service_start ( | |||
928 | /* Schedule start communicator */ | 918 | /* Schedule start communicator */ |
929 | communicator_start (tc_h, | 919 | communicator_start (tc_h, |
930 | binary_name); | 920 | binary_name); |
931 | GNUNET_SCHEDULER_add_shutdown (&do_shutdown, tc_h); | ||
932 | return tc_h; | 921 | return tc_h; |
933 | } | 922 | } |
934 | 923 | ||
935 | 924 | ||
925 | void | ||
926 | GNUNET_TRANSPORT_TESTING_transport_communicator_service_stop ( | ||
927 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h) | ||
928 | { | ||
929 | shutdown_communicator (tc_h->c_proc); | ||
930 | shutdown_service (tc_h->sh); | ||
931 | shutdown_nat (tc_h->nat_proc); | ||
932 | GNUNET_CONFIGURATION_destroy (tc_h->cfg); | ||
933 | GNUNET_free (tc_h); | ||
934 | } | ||
935 | |||
936 | |||
936 | /** | 937 | /** |
937 | * @brief Instruct communicator to open a queue | 938 | * @brief Instruct communicator to open a queue |
938 | * | 939 | * |
@@ -988,39 +989,41 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue ( | |||
988 | * @brief Instruct communicator to send data | 989 | * @brief Instruct communicator to send data |
989 | * | 990 | * |
990 | * @param tc_queue The queue to use for sending | 991 | * @param tc_queue The queue to use for sending |
992 | * @param cont function to call when done sending | ||
993 | * @param cont_cls closure for @a cont | ||
991 | * @param payload Data to send | 994 | * @param payload Data to send |
992 | * @param payload_size Size of the payload | 995 | * @param payload_size Size of the @a payload |
993 | * | ||
994 | * @return Handle to the transmission | ||
995 | */ | 996 | */ |
996 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission * | 997 | void |
997 | GNUNET_TRANSPORT_TESTING_transport_communicator_send | 998 | GNUNET_TRANSPORT_TESTING_transport_communicator_send |
998 | (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue, | 999 | (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue, |
1000 | GNUNET_SCHEDULER_TaskCallback cont, | ||
1001 | void *cont_cls, | ||
999 | const void *payload, | 1002 | const void *payload, |
1000 | size_t payload_size) | 1003 | size_t payload_size) |
1001 | { | 1004 | { |
1002 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission *tc_t; | ||
1003 | struct GNUNET_MessageHeader *mh; | 1005 | struct GNUNET_MessageHeader *mh; |
1004 | struct GNUNET_TRANSPORT_SendMessageTo *msg; | 1006 | struct GNUNET_TRANSPORT_SendMessageTo *msg; |
1005 | struct GNUNET_MQ_Envelope *env; | 1007 | struct GNUNET_MQ_Envelope *env; |
1006 | size_t inbox_size; | 1008 | size_t inbox_size; |
1007 | 1009 | ||
1008 | inbox_size = sizeof(struct GNUNET_MessageHeader) + payload_size; | 1010 | inbox_size = sizeof (struct GNUNET_MessageHeader) + payload_size; |
1009 | mh = GNUNET_malloc (inbox_size); | ||
1010 | mh->size = htons (inbox_size); | ||
1011 | mh->type = GNUNET_MESSAGE_TYPE_DUMMY; | ||
1012 | memcpy (&mh[1], | ||
1013 | payload, | ||
1014 | payload_size); | ||
1015 | env = GNUNET_MQ_msg_extra (msg, | 1011 | env = GNUNET_MQ_msg_extra (msg, |
1016 | inbox_size, | 1012 | inbox_size, |
1017 | GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG); | 1013 | GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG); |
1018 | msg->qid = htonl (tc_queue->qid); | 1014 | msg->qid = htonl (tc_queue->qid); |
1019 | msg->mid = tc_queue->mid++; | 1015 | msg->mid = tc_queue->mid++; |
1020 | msg->receiver = tc_queue->peer_id; | 1016 | msg->receiver = tc_queue->peer_id; |
1021 | memcpy (&msg[1], mh, inbox_size); | 1017 | mh = (struct GNUNET_MessageHeader *) &msg[1]; |
1022 | GNUNET_free (mh); | 1018 | mh->size = htons (inbox_size); |
1023 | GNUNET_MQ_send (tc_queue->tc_h->c_mq, env); | 1019 | mh->type = GNUNET_MESSAGE_TYPE_DUMMY; |
1024 | // GNUNET_assert (0); // FIXME: not iplemented! | 1020 | memcpy (&mh[1], |
1025 | return tc_t; | 1021 | payload, |
1022 | payload_size); | ||
1023 | if (NULL != cont) | ||
1024 | GNUNET_MQ_notify_sent (env, | ||
1025 | cont, | ||
1026 | cont_cls); | ||
1027 | GNUNET_MQ_send (tc_queue->tc_h->c_mq, | ||
1028 | env); | ||
1026 | } | 1029 | } |