diff options
author | Julius Bünger <buenger@mytum.de> | 2019-06-06 12:34:30 +0200 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2019-06-06 12:34:30 +0200 |
commit | 1a0c0c0d17662b39b8c736d80edbf486a00348eb (patch) | |
tree | 7bb9237c8971d2aa3a22b924d4e3685ca76f4d12 /src/transport | |
parent | 2cc12edbeaaab5ad8181cf84f76035183114b492 (diff) | |
download | gnunet-1a0c0c0d17662b39b8c736d80edbf486a00348eb.tar.gz gnunet-1a0c0c0d17662b39b8c736d80edbf486a00348eb.zip |
TNG testing: Add callback stub for incoming messages
Diffstat (limited to 'src/transport')
-rw-r--r-- | src/transport/test_communicator_unix.c | 1 | ||||
-rw-r--r-- | src/transport/transport-testing2.c | 67 |
2 files changed, 64 insertions, 4 deletions
diff --git a/src/transport/test_communicator_unix.c b/src/transport/test_communicator_unix.c index 0fdbe4b99..fed15b236 100644 --- a/src/transport/test_communicator_unix.c +++ b/src/transport/test_communicator_unix.c | |||
@@ -179,6 +179,7 @@ run (void *cls) | |||
179 | &add_address_cb, | 179 | &add_address_cb, |
180 | NULL, | 180 | NULL, |
181 | &add_queue_cb, | 181 | &add_queue_cb, |
182 | NULL, | ||
182 | NULL); /* cls */ | 183 | NULL); /* cls */ |
183 | } | 184 | } |
184 | 185 | ||
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 | */ | ||
335 | static int | ||
336 | check_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 | */ | ||
359 | static void | ||
360 | handle_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 | */ | ||
328 | static void | 385 | static void |
329 | handle_queue_create_ok (void *cls, | 386 | handle_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 */ |