diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-12-31 14:39:56 +0900 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-12-31 14:39:56 +0900 |
commit | 65b645e3c3910401d43d922d46096aa22c6de9e7 (patch) | |
tree | 1661af3f33c2087dd46937ed8d1d5219c7e082fe /src/transport/transport-testing2.c | |
parent | 658ba3f2b74a7b5e4ec92211cded45cdf6af8105 (diff) | |
download | gnunet-65b645e3c3910401d43d922d46096aa22c6de9e7.tar.gz gnunet-65b645e3c3910401d43d922d46096aa22c6de9e7.zip |
add backchannel test; fix udp basic
Diffstat (limited to 'src/transport/transport-testing2.c')
-rw-r--r-- | src/transport/transport-testing2.c | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c index 41d4ab937..893579bc5 100644 --- a/src/transport/transport-testing2.c +++ b/src/transport/transport-testing2.c | |||
@@ -150,6 +150,11 @@ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle | |||
150 | * @brief Closure to the callback | 150 | * @brief Closure to the callback |
151 | */ | 151 | */ |
152 | void *cb_cls; | 152 | void *cb_cls; |
153 | |||
154 | /** | ||
155 | * Backchannel supported | ||
156 | */ | ||
157 | int bc_enabled; | ||
153 | }; | 158 | }; |
154 | 159 | ||
155 | 160 | ||
@@ -320,9 +325,28 @@ handle_communicator_backchannel (void *cls, | |||
320 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; | 325 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; |
321 | struct GNUNET_MessageHeader *msg; | 326 | struct GNUNET_MessageHeader *msg; |
322 | msg = (struct GNUNET_MessageHeader *) &bc_msg[1]; | 327 | msg = (struct GNUNET_MessageHeader *) &bc_msg[1]; |
323 | size_t payload_len = ntohs (msg->size) - sizeof (struct | 328 | struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming *cbi; |
324 | GNUNET_MessageHeader); | 329 | struct GNUNET_MQ_Envelope *env; |
325 | 330 | uint16_t isize = ntohs (msg->size); | |
331 | const char *target_communicator = ((const char *) msg) + isize; | ||
332 | if (tc_h->bc_enabled != GNUNET_YES) | ||
333 | { | ||
334 | GNUNET_SERVICE_client_continue (tc_h->client); | ||
335 | return; | ||
336 | } | ||
337 | /* Find client providing this communicator */ | ||
338 | /* Finally, deliver backchannel message to communicator */ | ||
339 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
340 | "Delivering backchannel message of type %u to %s\n", | ||
341 | ntohs (msg->type), | ||
342 | target_communicator); | ||
343 | env = GNUNET_MQ_msg_extra ( | ||
344 | cbi, | ||
345 | isize, | ||
346 | GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING); | ||
347 | cbi->pid = bc_msg->pid; | ||
348 | memcpy (&cbi[1], msg, isize); | ||
349 | GNUNET_MQ_send (tc_h->c_mq, env); | ||
326 | GNUNET_SERVICE_client_continue (tc_h->client); | 350 | GNUNET_SERVICE_client_continue (tc_h->client); |
327 | } | 351 | } |
328 | 352 | ||
@@ -873,6 +897,9 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_service_start ( | |||
873 | GNUNET_free (tc_h); | 897 | GNUNET_free (tc_h); |
874 | return NULL; | 898 | return NULL; |
875 | } | 899 | } |
900 | tc_h->bc_enabled = GNUNET_CONFIGURATION_get_value_yesno (tc_h->cfg, | ||
901 | "communicator-test", | ||
902 | "BACKCHANNEL_ENABLED"); | ||
876 | tc_h->communicator_available_cb = communicator_available_cb; | 903 | tc_h->communicator_available_cb = communicator_available_cb; |
877 | tc_h->add_address_cb = add_address_cb; | 904 | tc_h->add_address_cb = add_address_cb; |
878 | tc_h->queue_create_reply_cb = queue_create_reply_cb; | 905 | tc_h->queue_create_reply_cb = queue_create_reply_cb; |