2 This file is part of GNUnet.
3 Copyright (C) 2019 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
22 * @file transport/transport-testing2.c
23 * @brief functions related to testing-tng
24 * @author Christian Grothoff
25 * @author Julius Bünger
28 #include "gnunet_util_lib.h"
29 #include "gnunet_protocols.h"
30 #include "gnunet_constants.h"
31 #include "transport-testing2.h"
32 #include "gnunet_ats_transport_service.h"
33 #include "gnunet_hello_lib.h"
34 #include "gnunet_signatures.h"
35 #include "transport.h"
38 #define LOG(kind, ...) GNUNET_log_from (kind, "transport-testing2", __VA_ARGS__)
42 * @brief Handle to a transport communicator
44 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
47 * @brief Handle to the configuration
49 struct GNUNET_CONFIGURATION_Handle *cfg;
52 * @brief File name of configuration file
57 * @brief Handle to the transport service
59 struct GNUNET_SERVICE_Handle *tsh;
62 * @brief Task that will be run on shutdown to stop and clean transport
65 struct GNUNET_SCHEDULER_Task *ts_shutdown_task;
68 * @brief Handle to the client
70 struct GNUNET_SERVICE_Client *client;
73 * @brief Handle to the client
75 struct GNUNET_MQ_Handle *c_mq;
78 * @brief Process of the communicator
80 struct GNUNET_OS_Process *c_proc;
85 struct GNUNET_OS_Process *nat_proc;
88 * @brief Task that will be run on shutdown to stop and clean communicator
90 struct GNUNET_SCHEDULER_Task *c_shutdown_task;
93 * @brief Characteristics of the communicator
95 enum GNUNET_TRANSPORT_CommunicatorCharacteristics c_characteristics;
98 * @brief Specifies supported addresses
103 * @brief Specifies supported addresses
108 * @brief Head of the DLL of queues associated with this communicator
110 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *queue_head;
113 * @brief Tail of the DLL of queues associated with this communicator
115 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *queue_tail;
117 /* Callbacks + Closures */
119 * @brief Callback called when a new communicator connects
121 GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback
122 communicator_available_cb;
125 * @brief Callback called when a new communicator connects
127 GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb;
130 * @brief Callback called when a new communicator connects
132 GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb;
135 * @brief Callback called when a new communicator connects
137 GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb;
140 * @brief Callback called when a new communicator connects
142 GNUNET_TRANSPORT_TESTING_IncomingMessageCallback incoming_msg_cb;
147 struct GNUNET_SERVICE_Handle *sh;
150 * @brief Closure to the callback
157 * @brief Queue of a communicator and some context
159 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue
162 * @brief Handle to the TransportCommunicator
164 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h;
167 * @brief Envelope to a message that requests the opening of the queue.
169 * If the client already requests queue(s), but the communicator is not yet
170 * connected, we cannot send the request to open the queue. Save it until the
171 * communicator becomes available and send it then.
173 struct GNUNET_MQ_Envelope *open_queue_env;
176 * @brief Peer ID of the peer on the other side of the queue
178 struct GNUNET_PeerIdentity peer_id;
186 * @brief Current message id
191 * An `enum GNUNET_NetworkType` in NBO.
196 * Maximum transmission unit, in NBO. UINT32_MAX for unlimited.
201 * An `enum GNUNET_TRANSPORT_ConnectionStatus` in NBO.
206 * @brief Next element inside a DLL
208 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *next;
211 * @brief Previous element inside a DLL
213 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *prev;
218 * @brief Handle/Context to a single transmission
220 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission
226 * @brief Check whether incoming msg indicating available communicator is
230 * @param msg Message struct
232 * @return GNUNET_YES in case message is correct
235 check_communicator_available (
237 const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *msg)
241 size = ntohs (msg->header.size) - sizeof(*msg);
243 return GNUNET_OK; /* receive-only communicator */
244 GNUNET_MQ_check_zero_termination (msg);
250 * @brief Handle new communicator
252 * Store characteristics of communicator, call respective client callback.
254 * @param cls Closure - communicator handle
255 * @param msg Message struct
258 handle_communicator_available (
260 const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *msg)
262 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls;
265 size = ntohs (msg->header.size) - sizeof(*msg);
267 return; /* receive-only communicator */
268 tc_h->c_characteristics = ntohl (msg->cc);
269 tc_h->c_addr_prefix = GNUNET_strdup ((const char *) &msg[1]);
270 if (NULL != tc_h->communicator_available_cb)
272 LOG (GNUNET_ERROR_TYPE_DEBUG, "calling communicator_available_cb()\n");
273 tc_h->communicator_available_cb (tc_h->cb_cls,
275 tc_h->c_characteristics,
276 tc_h->c_addr_prefix);
278 GNUNET_SERVICE_client_continue (tc_h->client);
283 * Address of our peer added. Test message is well-formed.
285 * @param cls the client
286 * @param aam the send message that was sent
287 * @return #GNUNET_OK if message is well-formed
290 check_add_address (void *cls,
291 const struct GNUNET_TRANSPORT_AddAddressMessage *msg)
293 // if (CT_COMMUNICATOR != tc->type)
296 // return GNUNET_SYSERR;
298 GNUNET_MQ_check_zero_termination (msg);
304 * @brief The communicator informs about an address.
306 * Store address and call client callback.
308 * @param cls Closure - communicator handle
312 handle_add_address (void *cls,
313 const struct GNUNET_TRANSPORT_AddAddressMessage *msg)
315 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls;
317 size = ntohs (msg->header.size) - sizeof(*msg);
319 return; /* receive-only communicator */
320 LOG (GNUNET_ERROR_TYPE_DEBUG, "received add address cb %u\n", size);
321 tc_h->c_address = GNUNET_strdup ((const char *) &msg[1]);
322 if (NULL != tc_h->add_address_cb)
324 LOG (GNUNET_ERROR_TYPE_DEBUG, "calling add_address_cb()\n");
325 tc_h->add_address_cb (tc_h->cb_cls,
328 GNUNET_TIME_relative_ntoh (msg->expiration),
332 GNUNET_SERVICE_client_continue (tc_h->client);
337 * Incoming message. Test message is well-formed.
339 * @param cls the client
340 * @param msg the send message that was sent
341 * @return #GNUNET_OK if message is well-formed
344 check_incoming_msg (void *cls,
345 const struct GNUNET_TRANSPORT_IncomingMessage *msg)
347 // struct TransportClient *tc = cls;
349 // if (CT_COMMUNICATOR != tc->type)
352 // return GNUNET_SYSERR;
354 GNUNET_MQ_check_boxed_message (msg);
360 * @brief Receive an incoming message.
362 * Pass the message to the client.
364 * @param cls Closure - communicator handle
368 handle_incoming_msg (void *cls,
369 const struct GNUNET_TRANSPORT_IncomingMessage *inc_msg)
371 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls;
372 struct GNUNET_MessageHeader *msg;
373 msg = (struct GNUNET_MessageHeader *) &inc_msg[1];
374 size_t payload_len = ntohs (msg->size) - sizeof (struct
375 GNUNET_MessageHeader);
377 if (NULL != tc_h->incoming_msg_cb)
379 tc_h->incoming_msg_cb (tc_h->cb_cls,
386 LOG (GNUNET_ERROR_TYPE_WARNING,
387 "Incoming message from communicator but no handler!\n");
389 if (0 != ntohl (inc_msg->fc_on))
391 /* send ACK when done to communicator for flow control! */
392 struct GNUNET_MQ_Envelope *env;
393 struct GNUNET_TRANSPORT_IncomingMessageAck *ack;
395 env = GNUNET_MQ_msg (ack, GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG_ACK);
396 ack->reserved = htonl (0);
397 ack->fc_id = inc_msg->fc_id;
398 ack->sender = inc_msg->sender;
399 GNUNET_MQ_send (tc_h->c_mq, env);
402 GNUNET_SERVICE_client_continue (tc_h->client);
407 * @brief Communicator informs that it tries to establish requested queue
409 * @param cls Closure - communicator handle
413 handle_queue_create_ok (void *cls,
414 const struct GNUNET_TRANSPORT_CreateQueueResponse *msg)
416 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls;
418 if (NULL != tc_h->queue_create_reply_cb)
420 tc_h->queue_create_reply_cb (tc_h->cb_cls, tc_h, GNUNET_YES);
422 GNUNET_SERVICE_client_continue (tc_h->client);
427 * @brief Communicator informs that it wont try establishing requested queue.
429 * It will not do so probably because the address is bougus (see comment to
430 * #GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL)
432 * @param cls Closure - communicator handle
436 handle_queue_create_fail (
438 const struct GNUNET_TRANSPORT_CreateQueueResponse *msg)
440 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls;
442 if (NULL != tc_h->queue_create_reply_cb)
444 tc_h->queue_create_reply_cb (tc_h->cb_cls, tc_h, GNUNET_NO);
446 GNUNET_SERVICE_client_continue (tc_h->client);
451 * New queue became available. Check message.
453 * @param cls the client
454 * @param aqm the send message that was sent
457 check_add_queue_message (void *cls,
458 const struct GNUNET_TRANSPORT_AddQueueMessage *aqm)
460 GNUNET_MQ_check_zero_termination (aqm);
466 * @brief Handle new queue
468 * Store context and call client callback.
470 * @param cls Closure - communicator handle
471 * @param msg Message struct
474 handle_add_queue_message (void *cls,
475 const struct GNUNET_TRANSPORT_AddQueueMessage *msg)
477 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls;
478 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue;
480 tc_queue = tc_h->queue_head;
481 if (NULL != tc_queue)
483 while (tc_queue->qid != msg->qid)
485 tc_queue = tc_queue->next;
491 GNUNET_new (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue);
492 tc_queue->tc_h = tc_h;
493 tc_queue->qid = msg->qid;
494 tc_queue->peer_id = msg->receiver;
495 GNUNET_CONTAINER_DLL_insert (tc_h->queue_head, tc_h->queue_tail, tc_queue);
497 GNUNET_assert (tc_queue->qid == msg->qid);
498 GNUNET_assert (0 == GNUNET_memcmp (&tc_queue->peer_id, &msg->receiver));
499 tc_queue->nt = msg->nt;
500 tc_queue->mtu = msg->mtu;
501 tc_queue->cs = msg->cs;
502 if (NULL != tc_h->add_queue_cb)
504 tc_h->add_queue_cb (tc_h->cb_cls, tc_h, tc_queue);
506 GNUNET_SERVICE_client_continue (tc_h->client);
511 * @brief Shut down the service
513 * @param cls Closure - Handle to the service
516 shutdown_service (void *cls)
518 struct GNUNET_SERVICE_Handle *h = cls;
520 GNUNET_SERVICE_stop (h);
525 * @brief Callback called when new Client (Communicator) connects
527 * @param cls Closure - TransporCommmunicator Handle
528 * @param client Client
529 * @param mq Messagequeue
531 * @return TransportCommunicator Handle
534 connect_cb (void *cls,
535 struct GNUNET_SERVICE_Client *client,
536 struct GNUNET_MQ_Handle *mq)
538 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls;
540 LOG (GNUNET_ERROR_TYPE_DEBUG, "Client connected.\n");
541 tc_h->client = client;
544 if (NULL == tc_h->queue_head)
546 /* Iterate over queues. They are yet to be opened. Request opening. */
548 GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue_iter =
550 NULL != tc_queue_iter;
551 tc_queue_iter = tc_queue_iter->next)
553 if (NULL == tc_queue_iter->open_queue_env)
555 /* Send the previously created mq envelope to request the creation of the
557 GNUNET_MQ_send (tc_h->c_mq,
558 tc_queue_iter->open_queue_env);
559 tc_queue_iter->open_queue_env = NULL;
566 * @brief Callback called when Client disconnects
568 * @param cls Closure - TransportCommunicator Handle
569 * @param client Client
570 * @param internal_cls TransporCommmunicator Handle
573 disconnect_cb (void *cls,
574 struct GNUNET_SERVICE_Client *client,
577 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls;
579 LOG (GNUNET_ERROR_TYPE_DEBUG, "Client disconnected.\n");
585 * Message was transmitted. Process the request.
587 * @param cls the client
588 * @param sma the send message that was sent
591 handle_send_message_ack (void *cls,
592 const struct GNUNET_TRANSPORT_SendMessageToAck *sma)
594 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls;
595 GNUNET_SERVICE_client_continue (tc_h->client);
601 * @brief Start the communicator part of the transport service
603 * @param communicator_available Callback to be called when a new communicator
605 * @param cfg Configuration
608 transport_communicator_start (
609 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
611 struct GNUNET_MQ_MessageHandler mh[] = {
612 GNUNET_MQ_hd_var_size (communicator_available,
613 GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR,
614 struct GNUNET_TRANSPORT_CommunicatorAvailableMessage,
616 // GNUNET_MQ_hd_var_size (communicator_backchannel,
617 // GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL,
618 // struct GNUNET_TRANSPORT_CommunicatorBackchannel,
620 GNUNET_MQ_hd_var_size (add_address,
621 GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS,
622 struct GNUNET_TRANSPORT_AddAddressMessage,
624 // GNUNET_MQ_hd_fixed_size (del_address,
625 // GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_ADDRESS,
626 // struct GNUNET_TRANSPORT_DelAddressMessage,
628 GNUNET_MQ_hd_var_size (incoming_msg,
629 GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG,
630 struct GNUNET_TRANSPORT_IncomingMessage,
632 GNUNET_MQ_hd_fixed_size (queue_create_ok,
633 GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK,
634 struct GNUNET_TRANSPORT_CreateQueueResponse,
636 GNUNET_MQ_hd_fixed_size (queue_create_fail,
637 GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_FAIL,
638 struct GNUNET_TRANSPORT_CreateQueueResponse,
640 GNUNET_MQ_hd_var_size (add_queue_message,
641 GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_SETUP,
642 struct GNUNET_TRANSPORT_AddQueueMessage,
644 // GNUNET_MQ_hd_fixed_size (del_queue_message,
645 // GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_TEARDOWN,
646 // struct GNUNET_TRANSPORT_DelQueueMessage,
648 GNUNET_MQ_hd_fixed_size (send_message_ack,
649 GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG_ACK,
650 struct GNUNET_TRANSPORT_SendMessageToAck,
652 GNUNET_MQ_handler_end ()
656 tc_h->sh = GNUNET_SERVICE_start ("transport",
662 GNUNET_assert (NULL != tc_h->sh);
667 * @brief Task run at shutdown to kill communicator and clean up
669 * @param cls Closure - Process of communicator
672 shutdown_process (struct GNUNET_OS_Process *proc)
674 if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
676 LOG (GNUNET_ERROR_TYPE_WARNING,
677 "Error shutting down communicator with SIGERM, trying SIGKILL\n");
678 if (0 != GNUNET_OS_process_kill (proc, SIGKILL))
680 LOG (GNUNET_ERROR_TYPE_ERROR,
681 "Error shutting down communicator with SIGERM and SIGKILL\n");
684 GNUNET_OS_process_destroy (proc);
689 shutdown_communicator (void *cls)
691 struct GNUNET_OS_Process *proc = cls;
692 shutdown_process (proc);
697 * @brief Start the communicator
699 * @param cfgname Name of the communicator
703 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h,
704 const char *binary_name)
708 LOG (GNUNET_ERROR_TYPE_DEBUG, "communicator_start\n");
709 binary = GNUNET_OS_get_libexec_binary_path (binary_name);
710 tc_h->c_proc = GNUNET_OS_start_process (GNUNET_YES,
711 GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
720 if (NULL == tc_h->c_proc)
722 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start communicator!");
725 LOG (GNUNET_ERROR_TYPE_INFO, "started communicator\n");
726 GNUNET_free (binary);
731 * @brief Task run at shutdown to kill communicator and clean up
733 * @param cls Closure - Process of communicator
736 shutdown_nat (void *cls)
738 struct GNUNET_OS_Process *proc = cls;
739 shutdown_process (proc);
749 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h)
753 LOG (GNUNET_ERROR_TYPE_DEBUG, "nat_start\n");
754 binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-nat");
755 tc_h->nat_proc = GNUNET_OS_start_process (GNUNET_YES,
756 GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
761 "gnunet-service-nat",
765 if (NULL == tc_h->nat_proc)
767 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to start NAT!");
770 LOG (GNUNET_ERROR_TYPE_INFO, "started NAT\n");
771 GNUNET_free (binary);
776 do_shutdown (void *cls)
778 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls;
779 shutdown_communicator (tc_h->c_proc);
780 shutdown_service (tc_h->sh);
781 shutdown_nat (tc_h->nat_proc);
786 * @brief Start communicator part of transport service and communicator
788 * @param service_name Name of the service
789 * @param cfg Configuration handle
790 * @param communicator_available_cb Callback that is called when a new
791 * @param add_address_cb Callback that is called when a new
792 * communicator becomes available
793 * @param cb_cls Closure to @a communicator_available_cb and @a
795 * @return Handle to the communicator duo
797 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *
798 GNUNET_TRANSPORT_TESTING_transport_communicator_service_start (
799 const char *service_name,
800 const char *binary_name,
801 const char *cfg_filename,
802 GNUNET_TRANSPORT_TESTING_CommunicatorAvailableCallback
803 communicator_available_cb,
804 GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb,
805 GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb,
806 GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb,
807 GNUNET_TRANSPORT_TESTING_IncomingMessageCallback incoming_message_cb,
810 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h;
813 GNUNET_new (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle);
814 tc_h->cfg_filename = GNUNET_strdup (cfg_filename);
815 tc_h->cfg = GNUNET_CONFIGURATION_create ();
816 if ((GNUNET_SYSERR == GNUNET_CONFIGURATION_load (tc_h->cfg, cfg_filename)))
818 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
819 _ ("Malformed configuration file `%s', exit ...\n"),
821 GNUNET_free (tc_h->cfg_filename);
822 GNUNET_CONFIGURATION_destroy (tc_h->cfg);
826 tc_h->communicator_available_cb = communicator_available_cb;
827 tc_h->add_address_cb = add_address_cb;
828 tc_h->queue_create_reply_cb = queue_create_reply_cb;
829 tc_h->add_queue_cb = add_queue_cb;
830 tc_h->incoming_msg_cb = incoming_message_cb;
831 tc_h->cb_cls = cb_cls;
833 /* Start communicator part of service */
834 transport_communicator_start (tc_h);
837 /* Schedule start communicator */
838 communicator_start (tc_h,
840 GNUNET_SCHEDULER_add_shutdown (&do_shutdown, tc_h);
846 * @brief Instruct communicator to open a queue
848 * @param tc_h Handle to communicator which shall open queue
849 * @param peer_id Towards which peer
850 * @param address For which address
853 GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue (
854 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h,
855 const struct GNUNET_PeerIdentity *peer_id,
858 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue;
859 static uint32_t idgen;
861 struct GNUNET_TRANSPORT_CreateQueue *msg;
862 struct GNUNET_MQ_Envelope *env;
866 GNUNET_new (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue);
867 tc_queue->tc_h = tc_h;
868 prefix = GNUNET_HELLO_address_to_prefix (address);
871 GNUNET_break (0); /* We got an invalid address!? */
872 GNUNET_free (tc_queue);
875 GNUNET_free (prefix);
876 alen = strlen (address) + 1;
878 GNUNET_MQ_msg_extra (msg, alen, GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE);
879 msg->request_id = htonl (idgen++);
880 tc_queue->qid = msg->request_id;
881 msg->receiver = *peer_id;
882 tc_queue->peer_id = *peer_id;
883 memcpy (&msg[1], address, alen);
884 if (NULL != tc_h->c_mq)
886 GNUNET_MQ_send (tc_h->c_mq, env);
890 tc_queue->open_queue_env = env;
892 GNUNET_CONTAINER_DLL_insert (tc_h->queue_head, tc_h->queue_tail, tc_queue);
897 * @brief Instruct communicator to send data
899 * @param tc_queue The queue to use for sending
900 * @param payload Data to send
901 * @param payload_size Size of the payload
903 * @return Handle to the transmission
905 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission *
906 GNUNET_TRANSPORT_TESTING_transport_communicator_send
907 (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue,
911 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission *tc_t;
912 struct GNUNET_MessageHeader *mh;
913 struct GNUNET_TRANSPORT_SendMessageTo *msg;
914 struct GNUNET_MQ_Envelope *env;
917 inbox_size = sizeof(struct GNUNET_MessageHeader) + payload_size;
918 mh = GNUNET_malloc (inbox_size);
919 mh->size = htons (inbox_size);
920 mh->type = GNUNET_MESSAGE_TYPE_DUMMY;
924 env = GNUNET_MQ_msg_extra (msg,
926 GNUNET_MESSAGE_TYPE_TRANSPORT_SEND_MSG);
927 msg->qid = htonl (tc_queue->qid);
928 msg->mid = tc_queue->mid++;
929 msg->receiver = tc_queue->peer_id;
930 memcpy (&msg[1], mh, inbox_size);
932 GNUNET_MQ_send (tc_queue->tc_h->c_mq, env);
933 // GNUNET_assert (0); // FIXME: not iplemented!