aboutsummaryrefslogtreecommitdiff
path: root/src/transport/transport-testing2.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/transport-testing2.c')
-rw-r--r--src/transport/transport-testing2.c67
1 files changed, 63 insertions, 4 deletions
diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c
index fc7ae2df6..ae5a65f2a 100644
--- a/src/transport/transport-testing2.c
+++ b/src/transport/transport-testing2.c
@@ -325,6 +325,63 @@ handle_add_address (void *cls,
325} 325}
326 326
327 327
328/**
329 * Incoming message. Test message is well-formed.
330 *
331 * @param cls the client
332 * @param msg the send message that was sent
333 * @return #GNUNET_OK if message is well-formed
334 */
335static int
336check_incoming_msg (void *cls,
337 const struct GNUNET_TRANSPORT_IncomingMessage *msg)
338{
339 //struct TransportClient *tc = cls;
340
341 //if (CT_COMMUNICATOR != tc->type)
342 //{
343 // GNUNET_break (0);
344 // return GNUNET_SYSERR;
345 //}
346 GNUNET_MQ_check_boxed_message (msg);
347 return GNUNET_OK;
348}
349
350
351/**
352 * @brief Receive an incoming message.
353 *
354 * Pass the message to the client.
355 *
356 * @param cls Closure - communicator handle
357 * @param msg Message
358 */
359static void
360handle_incoming_msg (void *cls,
361 const struct GNUNET_TRANSPORT_IncomingMessage *msg)
362{
363 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls;
364
365 if (NULL != tc_h->incoming_msg_cb) {
366 tc_h->incoming_msg_cb (tc_h->cb_cls,
367 tc_h,
368 (const struct GNUNET_MessageHeader *) msg);
369 }
370 else
371 {
372 LOG (GNUNET_ERROR_TYPE_WARNING,
373 "Incoming message from communicator but no handler!\n");
374 }
375 GNUNET_SERVICE_client_continue (tc_h->client);
376}
377
378
379/**
380 * @brief Communicator informs that it tries to establish requested queue
381 *
382 * @param cls Closure - communicator handle
383 * @param msg Message
384 */
328static void 385static void
329handle_queue_create_ok (void *cls, 386handle_queue_create_ok (void *cls,
330 const struct GNUNET_TRANSPORT_CreateQueueResponse *msg) 387 const struct GNUNET_TRANSPORT_CreateQueueResponse *msg)
@@ -509,10 +566,10 @@ transport_communicator_start (
509 // GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_ADDRESS, 566 // GNUNET_MESSAGE_TYPE_TRANSPORT_DEL_ADDRESS,
510 // struct GNUNET_TRANSPORT_DelAddressMessage, 567 // struct GNUNET_TRANSPORT_DelAddressMessage,
511 // NULL), 568 // NULL),
512 //GNUNET_MQ_hd_var_size (incoming_msg, 569 GNUNET_MQ_hd_var_size (incoming_msg,
513 // GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG, 570 GNUNET_MESSAGE_TYPE_TRANSPORT_INCOMING_MSG,
514 // struct GNUNET_TRANSPORT_IncomingMessage, 571 struct GNUNET_TRANSPORT_IncomingMessage,
515 // NULL), 572 NULL),
516 GNUNET_MQ_hd_fixed_size (queue_create_ok, 573 GNUNET_MQ_hd_fixed_size (queue_create_ok,
517 GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK, 574 GNUNET_MESSAGE_TYPE_TRANSPORT_QUEUE_CREATE_OK,
518 struct GNUNET_TRANSPORT_CreateQueueResponse, 575 struct GNUNET_TRANSPORT_CreateQueueResponse,
@@ -634,6 +691,7 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_service_start (
634 GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb, 691 GNUNET_TRANSPORT_TESTING_AddAddressCallback add_address_cb,
635 GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb, 692 GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb,
636 GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb, 693 GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb,
694 GNUNET_TRANSPORT_TESTING_IncomingMessageCallback incoming_message_cb,
637 void *cb_cls) 695 void *cb_cls)
638{ 696{
639 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h; 697 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h;
@@ -656,6 +714,7 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_service_start (
656 tc_h->add_address_cb = add_address_cb; 714 tc_h->add_address_cb = add_address_cb;
657 tc_h->queue_create_reply_cb = queue_create_reply_cb; 715 tc_h->queue_create_reply_cb = queue_create_reply_cb;
658 tc_h->add_queue_cb = add_queue_cb; 716 tc_h->add_queue_cb = add_queue_cb;
717 tc_h->incoming_msg_cb = incoming_message_cb;
659 tc_h->cb_cls = cb_cls; 718 tc_h->cb_cls = cb_cls;
660 719
661 /* Start communicator part of service */ 720 /* Start communicator part of service */