aboutsummaryrefslogtreecommitdiff
path: root/src/transport
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
parent65b645e3c3910401d43d922d46096aa22c6de9e7 (diff)
downloadgnunet-0c5090e7d76fd7c85b92f0c4f918cf5420bd68f8.tar.gz
gnunet-0c5090e7d76fd7c85b92f0c4f918cf5420bd68f8.zip
fix backchannel
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-communicator-udp.c27
-rw-r--r--src/transport/test_communicator_basic.c37
-rw-r--r--src/transport/transport-testing2.c20
-rw-r--r--src/transport/transport-testing2.h16
-rw-r--r--src/transport/transport_api2_communication.c1
5 files changed, 75 insertions, 26 deletions
diff --git a/src/transport/gnunet-communicator-udp.c b/src/transport/gnunet-communicator-udp.c
index 5abf42588..e931bd2e7 100644
--- a/src/transport/gnunet-communicator-udp.c
+++ b/src/transport/gnunet-communicator-udp.c
@@ -1094,21 +1094,21 @@ pass_plaintext_to_core (struct SenderAddress *sender,
1094 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1094 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1095 "Giving %u bytes to TNG\n", ntohs (hdr->size)); 1095 "Giving %u bytes to TNG\n", ntohs (hdr->size));
1096 GNUNET_assert (GNUNET_SYSERR != 1096 GNUNET_assert (GNUNET_SYSERR !=
1097 GNUNET_TRANSPORT_communicator_receive (ch, 1097 GNUNET_TRANSPORT_communicator_receive (ch,
1098 &sender->target, 1098 &sender->target,
1099 hdr, 1099 hdr,
1100 ADDRESS_VALIDITY_PERIOD, 1100 ADDRESS_VALIDITY_PERIOD,
1101 NULL /* no flow control possible */ 1101 NULL /* no flow control possible */
1102 , 1102 ,
1103 NULL)); 1103 NULL));
1104 /* move on to next message, if any */ 1104 /* move on to next message, if any */
1105 plaintext_len -= ntohs (hdr->size); 1105 plaintext_len -= ntohs (hdr->size);
1106 if (plaintext_len < sizeof(*hdr)) 1106 if (plaintext_len < sizeof(*hdr))
1107 break; 1107 break;
1108 pos += ntohs (hdr->size); 1108 pos += ntohs (hdr->size);
1109 hdr = (const struct GNUNET_MessageHeader *)pos; 1109 hdr = (const struct GNUNET_MessageHeader *) pos;
1110 //TODO for now..., we do not actually sen >1msg or have a way of telling 1110 // TODO for now..., we do not actually sen >1msg or have a way of telling
1111 //if we are done 1111 // if we are done
1112 break; 1112 break;
1113 } 1113 }
1114 GNUNET_STATISTICS_update (stats, 1114 GNUNET_STATISTICS_update (stats,
@@ -1958,7 +1958,8 @@ mq_send (struct GNUNET_MQ_Handle *mq,
1958 receiver->address_len)) 1958 receiver->address_len))
1959 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "send"); 1959 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "send");
1960 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1960 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1961 "Sending KX to %s\n", GNUNET_a2s (receiver->address, receiver->address_len)); 1961 "Sending KX to %s\n", GNUNET_a2s (receiver->address,
1962 receiver->address_len));
1962 GNUNET_MQ_impl_send_continue (mq); 1963 GNUNET_MQ_impl_send_continue (mq);
1963 return; 1964 return;
1964 } /* End of KX encryption method */ 1965 } /* End of KX encryption method */
@@ -1966,6 +1967,8 @@ mq_send (struct GNUNET_MQ_Handle *mq,
1966 /* begin "BOX" encryption method, scan for ACKs from tail! */ 1967 /* begin "BOX" encryption method, scan for ACKs from tail! */
1967 for (struct SharedSecret *ss = receiver->ss_tail; NULL != ss; ss = ss->prev) 1968 for (struct SharedSecret *ss = receiver->ss_tail; NULL != ss; ss = ss->prev)
1968 { 1969 {
1970 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1971 "In non-kx mode...\n");
1969 if (ss->sequence_used < ss->sequence_allowed) 1972 if (ss->sequence_used < ss->sequence_allowed)
1970 { 1973 {
1971 char dgram[sizeof(struct UDPBox) + receiver->mtu]; 1974 char dgram[sizeof(struct UDPBox) + receiver->mtu];
@@ -1994,7 +1997,7 @@ mq_send (struct GNUNET_MQ_Handle *mq,
1994 receiver->address_len)) 1997 receiver->address_len))
1995 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "send"); 1998 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "send");
1996 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1999 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1997 "Sending data\n"); 2000 "Sending data\n");
1998 2001
1999 GNUNET_MQ_impl_send_continue (mq); 2002 GNUNET_MQ_impl_send_continue (mq);
2000 receiver->acks_available--; 2003 receiver->acks_available--;
diff --git a/src/transport/test_communicator_basic.c b/src/transport/test_communicator_basic.c
index 4699b8dd1..c469a55a1 100644
--- a/src/transport/test_communicator_basic.c
+++ b/src/transport/test_communicator_basic.c
@@ -76,6 +76,10 @@ static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *my_tc;
76 76
77#define TOTAL_ITERATIONS 5 77#define TOTAL_ITERATIONS 5
78 78
79#define PEER_A 0
80
81#define PEER_B 1
82
79static unsigned int iterations_left = TOTAL_ITERATIONS; 83static unsigned int iterations_left = TOTAL_ITERATIONS;
80 84
81#define SHORT_BURST_WINDOW \ 85#define SHORT_BURST_WINDOW \
@@ -136,14 +140,12 @@ add_address_cb (void *cls,
136 aid, 140 aid,
137 nt); 141 nt);
138 // addresses[1] = GNUNET_strdup (address); 142 // addresses[1] = GNUNET_strdup (address);
139 if ((0 == strcmp ((char*) cls, cfg_peers_name[NUM_PEERS - 1])) && 143 if ((0 == strcmp ((char*) cls, cfg_peers_name[PEER_B])) &&
140 (GNUNET_NO == queue_est)) 144 (GNUNET_NO == queue_est))
141 { 145 {
142 queue_est = GNUNET_YES; 146 queue_est = GNUNET_YES;
143 GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue (tc_hs[0], 147 GNUNET_TRANSPORT_TESTING_transport_communicator_open_queue (tc_hs[PEER_A],
144 &peer_id[ 148 &peer_id[PEER_B],
145 NUM_PEERS
146 - 1],
147 address); 149 address);
148 } 150 }
149} 151}
@@ -176,6 +178,20 @@ queue_create_reply_cb (void *cls,
176} 178}
177 179
178 180
181static struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *
182handle_backchannel_cb (void *cls,
183 struct GNUNET_MessageHeader *msg,
184 struct GNUNET_PeerIdentity *pid)
185{
186 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls;
187 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Handling BC message...\n");
188 if (0 == memcmp (&peer_id[PEER_A], pid, sizeof (*pid)))
189 return tc_hs[PEER_A];
190 else
191 return tc_hs[PEER_B];
192}
193
194
179static char* 195static char*
180make_payload (size_t payload_size) 196make_payload (size_t payload_size)
181{ 197{
@@ -366,8 +382,9 @@ incoming_message_cb (void *cls,
366 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, 382 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
367 "Short size packet test done.\n"); 383 "Short size packet test done.\n");
368 char *goodput = GNUNET_STRINGS_byte_size_fancy ((SHORT_MESSAGE_SIZE 384 char *goodput = GNUNET_STRINGS_byte_size_fancy ((SHORT_MESSAGE_SIZE
369 * num_received * 1000 * 1000) 385 * num_received * 1000
370 / duration.rel_value_us); 386 * 1000)
387 / duration.rel_value_us);
371 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, 388 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
372 "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n", 389 "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n",
373 (unsigned long) num_received, 390 (unsigned long) num_received,
@@ -402,8 +419,9 @@ incoming_message_cb (void *cls,
402 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, 419 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
403 "Long size packet test done.\n"); 420 "Long size packet test done.\n");
404 char *goodput = GNUNET_STRINGS_byte_size_fancy ((LONG_MESSAGE_SIZE 421 char *goodput = GNUNET_STRINGS_byte_size_fancy ((LONG_MESSAGE_SIZE
405 * num_received * 1000 * 1000) 422 * num_received * 1000
406 / duration.rel_value_us); 423 * 1000)
424 / duration.rel_value_us);
407 425
408 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE, 426 GNUNET_log (GNUNET_ERROR_TYPE_MESSAGE,
409 "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n", 427 "%lu/%lu packets in %llu us (%s/s) -- avg latency: %llu us\n",
@@ -496,6 +514,7 @@ run (void *cls)
496 &queue_create_reply_cb, 514 &queue_create_reply_cb,
497 &add_queue_cb, 515 &add_queue_cb,
498 &incoming_message_cb, 516 &incoming_message_cb,
517 &handle_backchannel_cb,
499 cfg_peers_name[i]); /* cls */ 518 cfg_peers_name[i]); /* cls */
500 } 519 }
501 GNUNET_SCHEDULER_add_shutdown (&do_shutdown, 520 GNUNET_SCHEDULER_add_shutdown (&do_shutdown,
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 */
diff --git a/src/transport/transport-testing2.h b/src/transport/transport-testing2.h
index 4e047828e..e7602e3e2 100644
--- a/src/transport/transport-testing2.h
+++ b/src/transport/transport-testing2.h
@@ -47,6 +47,19 @@ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue;
47 */ 47 */
48struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission; 48struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorTransmission;
49 49
50/**
51 * @brief Function signature for callbacks that are called when new
52 * backchannel message arrived
53 *
54 * @param cls Closure
55 * @param msg Backchannel message
56 * @param pid Target peer
57 */
58typedef struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *
59(*GNUNET_TRANSPORT_TESTING_BackchannelCallback)(void *cls,
60 struct GNUNET_MessageHeader *msg,
61 struct GNUNET_PeerIdentity *pid);
62
50 63
51/** 64/**
52 * @brief Function signature for callbacks that are called when new 65 * @brief Function signature for callbacks that are called when new
@@ -134,7 +147,7 @@ typedef void
134 struct 147 struct
135 GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle 148 GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
136 *tc_h, 149 *tc_h,
137 const char* payload, 150 const char*payload,
138 size_t payload_len); 151 size_t payload_len);
139 152
140 153
@@ -164,6 +177,7 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_service_start (
164 GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb, 177 GNUNET_TRANSPORT_TESTING_QueueCreateReplyCallback queue_create_reply_cb,
165 GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb, 178 GNUNET_TRANSPORT_TESTING_AddQueueCallback add_queue_cb,
166 GNUNET_TRANSPORT_TESTING_IncomingMessageCallback incoming_message_cb, 179 GNUNET_TRANSPORT_TESTING_IncomingMessageCallback incoming_message_cb,
180 GNUNET_TRANSPORT_TESTING_BackchannelCallback bc_cb,
167 void *cb_cls); 181 void *cb_cls);
168 182
169 183
diff --git a/src/transport/transport_api2_communication.c b/src/transport/transport_api2_communication.c
index 01a2447fa..e80cd5c03 100644
--- a/src/transport/transport_api2_communication.c
+++ b/src/transport/transport_api2_communication.c
@@ -694,7 +694,6 @@ handle_backchannel_incoming (
694 const struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming *bi) 694 const struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming *bi)
695{ 695{
696 struct GNUNET_TRANSPORT_CommunicatorHandle *ch = cls; 696 struct GNUNET_TRANSPORT_CommunicatorHandle *ch = cls;
697
698 if (NULL != ch->notify_cb) 697 if (NULL != ch->notify_cb)
699 ch->notify_cb (ch->notify_cb_cls, 698 ch->notify_cb (ch->notify_cb_cls,
700 &bi->pid, 699 &bi->pid,