diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-12-31 12:39:14 +0900 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-12-31 12:39:14 +0900 |
commit | 9aa5f80626ef47b1c5f027308abc5dcef0adbb89 (patch) | |
tree | d96d229f87dc11d73daf3b38bce1e740b874f031 | |
parent | b82fedab2505eccef3161d225473a5c75dd012cd (diff) | |
download | gnunet-9aa5f80626ef47b1c5f027308abc5dcef0adbb89.tar.gz gnunet-9aa5f80626ef47b1c5f027308abc5dcef0adbb89.zip |
update udp communicator
-rw-r--r-- | src/transport/gnunet-communicator-udp.c | 13 | ||||
-rw-r--r-- | src/transport/test_communicator_udp_peer1.conf | 1 | ||||
-rw-r--r-- | src/transport/test_communicator_udp_peer2.conf | 1 | ||||
-rw-r--r-- | src/transport/transport-testing2.c | 60 | ||||
-rw-r--r-- | src/transport/transport_api2_communication.c | 1 |
5 files changed, 68 insertions, 8 deletions
diff --git a/src/transport/gnunet-communicator-udp.c b/src/transport/gnunet-communicator-udp.c index 6a4fea315..5abf42588 100644 --- a/src/transport/gnunet-communicator-udp.c +++ b/src/transport/gnunet-communicator-udp.c | |||
@@ -1083,6 +1083,7 @@ pass_plaintext_to_core (struct SenderAddress *sender, | |||
1083 | size_t plaintext_len) | 1083 | size_t plaintext_len) |
1084 | { | 1084 | { |
1085 | const struct GNUNET_MessageHeader *hdr = plaintext; | 1085 | const struct GNUNET_MessageHeader *hdr = plaintext; |
1086 | const char *pos = plaintext; | ||
1086 | 1087 | ||
1087 | while (ntohs (hdr->size) < plaintext_len) | 1088 | while (ntohs (hdr->size) < plaintext_len) |
1088 | { | 1089 | { |
@@ -1090,19 +1091,25 @@ pass_plaintext_to_core (struct SenderAddress *sender, | |||
1090 | "# bytes given to core", | 1091 | "# bytes given to core", |
1091 | ntohs (hdr->size), | 1092 | ntohs (hdr->size), |
1092 | GNUNET_NO); | 1093 | GNUNET_NO); |
1093 | (void) | 1094 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1095 | "Giving %u bytes to TNG\n", ntohs (hdr->size)); | ||
1096 | GNUNET_assert (GNUNET_SYSERR != | ||
1094 | GNUNET_TRANSPORT_communicator_receive (ch, | 1097 | GNUNET_TRANSPORT_communicator_receive (ch, |
1095 | &sender->target, | 1098 | &sender->target, |
1096 | hdr, | 1099 | hdr, |
1097 | ADDRESS_VALIDITY_PERIOD, | 1100 | ADDRESS_VALIDITY_PERIOD, |
1098 | NULL /* no flow control possible */ | 1101 | NULL /* no flow control possible */ |
1099 | , | 1102 | , |
1100 | NULL); | 1103 | NULL)); |
1101 | /* move on to next message, if any */ | 1104 | /* move on to next message, if any */ |
1102 | plaintext_len -= ntohs (hdr->size); | 1105 | plaintext_len -= ntohs (hdr->size); |
1103 | if (plaintext_len < sizeof(*hdr)) | 1106 | if (plaintext_len < sizeof(*hdr)) |
1104 | break; | 1107 | break; |
1105 | hdr = plaintext + ntohs (hdr->size); | 1108 | pos += ntohs (hdr->size); |
1109 | hdr = (const struct GNUNET_MessageHeader *)pos; | ||
1110 | //TODO for now..., we do not actually sen >1msg or have a way of telling | ||
1111 | //if we are done | ||
1112 | break; | ||
1106 | } | 1113 | } |
1107 | GNUNET_STATISTICS_update (stats, | 1114 | GNUNET_STATISTICS_update (stats, |
1108 | "# bytes padding discarded", | 1115 | "# bytes padding discarded", |
diff --git a/src/transport/test_communicator_udp_peer1.conf b/src/transport/test_communicator_udp_peer1.conf index 417e92ab5..1b35d8e8a 100644 --- a/src/transport/test_communicator_udp_peer1.conf +++ b/src/transport/test_communicator_udp_peer1.conf | |||
@@ -30,3 +30,4 @@ DISABLE_V6 = YES | |||
30 | [communicator-udp] | 30 | [communicator-udp] |
31 | BINDTO = 60002 | 31 | BINDTO = 60002 |
32 | DISABLE_V6 = YES | 32 | DISABLE_V6 = YES |
33 | MAX_QUEUE_LENGTH=5000 | ||
diff --git a/src/transport/test_communicator_udp_peer2.conf b/src/transport/test_communicator_udp_peer2.conf index a063a545a..0472820aa 100644 --- a/src/transport/test_communicator_udp_peer2.conf +++ b/src/transport/test_communicator_udp_peer2.conf | |||
@@ -30,3 +30,4 @@ DISABLE_V6 = YES | |||
30 | [communicator-udp] | 30 | [communicator-udp] |
31 | BINDTO = 60003 | 31 | BINDTO = 60003 |
32 | DISABLE_V6 = YES | 32 | DISABLE_V6 = YES |
33 | MAX_QUEUE_LENGTH=5000 | ||
diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c index 22a767fce..41d4ab937 100644 --- a/src/transport/transport-testing2.c +++ b/src/transport/transport-testing2.c | |||
@@ -280,6 +280,54 @@ handle_communicator_available ( | |||
280 | 280 | ||
281 | 281 | ||
282 | /** | 282 | /** |
283 | * Incoming message. Test message is well-formed. | ||
284 | * | ||
285 | * @param cls the client | ||
286 | * @param msg the send message that was sent | ||
287 | * @return #GNUNET_OK if message is well-formed | ||
288 | */ | ||
289 | static int | ||
290 | check_communicator_backchannel (void *cls, | ||
291 | const struct | ||
292 | GNUNET_TRANSPORT_CommunicatorBackchannel *msg) | ||
293 | { | ||
294 | // struct TransportClient *tc = cls; | ||
295 | |||
296 | // if (CT_COMMUNICATOR != tc->type) | ||
297 | // { | ||
298 | // GNUNET_break (0); | ||
299 | // return GNUNET_SYSERR; | ||
300 | // } | ||
301 | // GNUNET_MQ_check_boxed_message (msg); | ||
302 | return GNUNET_OK; | ||
303 | } | ||
304 | |||
305 | |||
306 | /** | ||
307 | * @brief Receive an incoming message. | ||
308 | * | ||
309 | * Pass the message to the client. | ||
310 | * | ||
311 | * @param cls Closure - communicator handle | ||
312 | * @param msg Message | ||
313 | */ | ||
314 | static void | ||
315 | handle_communicator_backchannel (void *cls, | ||
316 | const struct | ||
317 | GNUNET_TRANSPORT_CommunicatorBackchannel * | ||
318 | bc_msg) | ||
319 | { | ||
320 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; | ||
321 | struct GNUNET_MessageHeader *msg; | ||
322 | msg = (struct GNUNET_MessageHeader *) &bc_msg[1]; | ||
323 | size_t payload_len = ntohs (msg->size) - sizeof (struct | ||
324 | GNUNET_MessageHeader); | ||
325 | |||
326 | GNUNET_SERVICE_client_continue (tc_h->client); | ||
327 | } | ||
328 | |||
329 | |||
330 | /** | ||
283 | * Address of our peer added. Test message is well-formed. | 331 | * Address of our peer added. Test message is well-formed. |
284 | * | 332 | * |
285 | * @param cls the client | 333 | * @param cls the client |
@@ -373,6 +421,8 @@ handle_incoming_msg (void *cls, | |||
373 | msg = (struct GNUNET_MessageHeader *) &inc_msg[1]; | 421 | msg = (struct GNUNET_MessageHeader *) &inc_msg[1]; |
374 | size_t payload_len = ntohs (msg->size) - sizeof (struct | 422 | size_t payload_len = ntohs (msg->size) - sizeof (struct |
375 | GNUNET_MessageHeader); | 423 | GNUNET_MessageHeader); |
424 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
425 | "Incoming message from communicator!\n"); | ||
376 | 426 | ||
377 | if (NULL != tc_h->incoming_msg_cb) | 427 | if (NULL != tc_h->incoming_msg_cb) |
378 | { | 428 | { |
@@ -386,7 +436,7 @@ handle_incoming_msg (void *cls, | |||
386 | LOG (GNUNET_ERROR_TYPE_WARNING, | 436 | LOG (GNUNET_ERROR_TYPE_WARNING, |
387 | "Incoming message from communicator but no handler!\n"); | 437 | "Incoming message from communicator but no handler!\n"); |
388 | } | 438 | } |
389 | if (0 != ntohl (inc_msg->fc_on)) | 439 | if (GNUNET_YES == ntohl (inc_msg->fc_on)) |
390 | { | 440 | { |
391 | /* send ACK when done to communicator for flow control! */ | 441 | /* send ACK when done to communicator for flow control! */ |
392 | struct GNUNET_MQ_Envelope *env; | 442 | struct GNUNET_MQ_Envelope *env; |
@@ -613,10 +663,10 @@ transport_communicator_start ( | |||
613 | GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR, | 663 | GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR, |
614 | struct GNUNET_TRANSPORT_CommunicatorAvailableMessage, | 664 | struct GNUNET_TRANSPORT_CommunicatorAvailableMessage, |
615 | tc_h), | 665 | tc_h), |
616 | // GNUNET_MQ_hd_var_size (communicator_backchannel, | 666 | GNUNET_MQ_hd_var_size (communicator_backchannel, |
617 | // GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL, | 667 | GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL, |
618 | // struct GNUNET_TRANSPORT_CommunicatorBackchannel, | 668 | struct GNUNET_TRANSPORT_CommunicatorBackchannel, |
619 | // NULL), | 669 | tc_h), |
620 | GNUNET_MQ_hd_var_size (add_address, | 670 | GNUNET_MQ_hd_var_size (add_address, |
621 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS, | 671 | GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS, |
622 | struct GNUNET_TRANSPORT_AddAddressMessage, | 672 | struct GNUNET_TRANSPORT_AddAddressMessage, |
diff --git a/src/transport/transport_api2_communication.c b/src/transport/transport_api2_communication.c index 9df9424da..01a2447fa 100644 --- a/src/transport/transport_api2_communication.c +++ b/src/transport/transport_api2_communication.c | |||
@@ -893,6 +893,7 @@ GNUNET_TRANSPORT_communicator_receive ( | |||
893 | // and then have the application fill in the body so we do | 893 | // and then have the application fill in the body so we do |
894 | // not have to memcpy() | 894 | // not have to memcpy() |
895 | memcpy (&im[1], msg, msize); | 895 | memcpy (&im[1], msg, msize); |
896 | im->fc_on = htonl (GNUNET_NO); | ||
896 | if (NULL != cb) | 897 | if (NULL != cb) |
897 | { | 898 | { |
898 | struct FlowControl *fc; | 899 | struct FlowControl *fc; |