aboutsummaryrefslogtreecommitdiff
path: root/src/transport/transport-testing2.c
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2020-01-01 13:35:28 +0900
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2020-01-01 13:35:28 +0900
commit0c5090e7d76fd7c85b92f0c4f918cf5420bd68f8 (patch)
tree1c2d5d10f4a3d288c42198b7989cd70ac9537f05 /src/transport/transport-testing2.c
parent65b645e3c3910401d43d922d46096aa22c6de9e7 (diff)
downloadgnunet-0c5090e7d76fd7c85b92f0c4f918cf5420bd68f8.tar.gz
gnunet-0c5090e7d76fd7c85b92f0c4f918cf5420bd68f8.zip
fix backchannel
Diffstat (limited to 'src/transport/transport-testing2.c')
-rw-r--r--src/transport/transport-testing2.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c
index 893579bc5..75864294b 100644
--- a/src/transport/transport-testing2.c
+++ b/src/transport/transport-testing2.c
@@ -142,6 +142,11 @@ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
142 GNUNET_TRANSPORT_TESTING_IncomingMessageCallback incoming_msg_cb; 142 GNUNET_TRANSPORT_TESTING_IncomingMessageCallback incoming_msg_cb;
143 143
144 /** 144 /**
145 * @brief Backchannel callback
146 */
147 GNUNET_TRANSPORT_TESTING_BackchannelCallback bc_cb;
148
149 /**
145 * Our service handle 150 * Our service handle
146 */ 151 */
147 struct GNUNET_SERVICE_Handle *sh; 152 struct GNUNET_SERVICE_Handle *sh;
@@ -323,12 +328,15 @@ handle_communicator_backchannel (void *cls,
323 bc_msg) 328 bc_msg)
324{ 329{
325 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; 330 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls;
331 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *other_tc_h;
326 struct GNUNET_MessageHeader *msg; 332 struct GNUNET_MessageHeader *msg;
327 msg = (struct GNUNET_MessageHeader *) &bc_msg[1]; 333 msg = (struct GNUNET_MessageHeader *) &bc_msg[1];
328 struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming *cbi;
329 struct GNUNET_MQ_Envelope *env;
330 uint16_t isize = ntohs (msg->size); 334 uint16_t isize = ntohs (msg->size);
331 const char *target_communicator = ((const char *) msg) + isize; 335 const char *target_communicator = ((const char *) msg) + isize;
336 struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming *cbi;
337 struct GNUNET_MQ_Envelope *env;
338
339
332 if (tc_h->bc_enabled != GNUNET_YES) 340 if (tc_h->bc_enabled != GNUNET_YES)
333 { 341 {
334 GNUNET_SERVICE_client_continue (tc_h->client); 342 GNUNET_SERVICE_client_continue (tc_h->client);
@@ -340,13 +348,17 @@ handle_communicator_backchannel (void *cls,
340 "Delivering backchannel message of type %u to %s\n", 348 "Delivering backchannel message of type %u to %s\n",
341 ntohs (msg->type), 349 ntohs (msg->type),
342 target_communicator); 350 target_communicator);
351 other_tc_h = tc_h->bc_cb (tc_h, msg, (struct
352 GNUNET_PeerIdentity*) &bc_msg->pid);
343 env = GNUNET_MQ_msg_extra ( 353 env = GNUNET_MQ_msg_extra (
344 cbi, 354 cbi,
345 isize, 355 isize,
346 GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING); 356 GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING);
347 cbi->pid = bc_msg->pid; 357 cbi->pid = bc_msg->pid;
348 memcpy (&cbi[1], msg, isize); 358 memcpy (&cbi[1], msg, isize);
349 GNUNET_MQ_send (tc_h->c_mq, env); 359
360
361 GNUNET_MQ_send (other_tc_h->c_mq, env);
350 GNUNET_SERVICE_client_continue (tc_h->client); 362 GNUNET_SERVICE_client_continue (tc_h->client);
351} 363}
352 364
@@ -879,6 +891,7 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_service_start (
879 GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb, 891 GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb,
880 GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb, 892 GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb,
881 GNUNET_TRANSPORT_TESTING_IncomingMessageCallback incoming_message_cb, 893 GNUNET_TRANSPORT_TESTING_IncomingMessageCallback incoming_message_cb,
894 GNUNET_TRANSPORT_TESTING_BackchannelCallback bc_cb,
882 void *cb_cls) 895 void *cb_cls)
883{ 896{
884 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h; 897 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h;
@@ -905,6 +918,7 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_service_start (
905 tc_h->queue_create_reply_cb = queue_create_reply_cb; 918 tc_h->queue_create_reply_cb = queue_create_reply_cb;
906 tc_h->add_queue_cb = add_queue_cb; 919 tc_h->add_queue_cb = add_queue_cb;
907 tc_h->incoming_msg_cb = incoming_message_cb; 920 tc_h->incoming_msg_cb = incoming_message_cb;
921 tc_h->bc_cb = bc_cb;
908 tc_h->cb_cls = cb_cls; 922 tc_h->cb_cls = cb_cls;
909 923
910 /* Start communicator part of service */ 924 /* Start communicator part of service */