summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2019-12-31 12:39:14 +0900
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2019-12-31 12:39:14 +0900
commit9aa5f80626ef47b1c5f027308abc5dcef0adbb89 (patch)
treed96d229f87dc11d73daf3b38bce1e740b874f031
parentb82fedab2505eccef3161d225473a5c75dd012cd (diff)
update udp communicator
-rw-r--r--src/transport/gnunet-communicator-udp.c13
-rw-r--r--src/transport/test_communicator_udp_peer1.conf1
-rw-r--r--src/transport/test_communicator_udp_peer2.conf1
-rw-r--r--src/transport/transport-testing2.c60
-rw-r--r--src/transport/transport_api2_communication.c1
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,
size_t plaintext_len)
{
const struct GNUNET_MessageHeader *hdr = plaintext;
+ const char *pos = plaintext;
while (ntohs (hdr->size) < plaintext_len)
{
@@ -1090,19 +1091,25 @@ pass_plaintext_to_core (struct SenderAddress *sender,
"# bytes given to core",
ntohs (hdr->size),
GNUNET_NO);
- (void)
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Giving %u bytes to TNG\n", ntohs (hdr->size));
+ GNUNET_assert (GNUNET_SYSERR !=
GNUNET_TRANSPORT_communicator_receive (ch,
&sender->target,
hdr,
ADDRESS_VALIDITY_PERIOD,
NULL /* no flow control possible */
,
- NULL);
+ NULL));
/* move on to next message, if any */
plaintext_len -= ntohs (hdr->size);
if (plaintext_len < sizeof(*hdr))
break;
- hdr = plaintext + ntohs (hdr->size);
+ pos += ntohs (hdr->size);
+ hdr = (const struct GNUNET_MessageHeader *)pos;
+ //TODO for now..., we do not actually sen >1msg or have a way of telling
+ //if we are done
+ break;
}
GNUNET_STATISTICS_update (stats,
"# 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
[communicator-udp]
BINDTO = 60002
DISABLE_V6 = YES
+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
[communicator-udp]
BINDTO = 60003
DISABLE_V6 = YES
+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 (
/**
+ * Incoming message. Test message is well-formed.
+ *
+ * @param cls the client
+ * @param msg the send message that was sent
+ * @return #GNUNET_OK if message is well-formed
+ */
+static int
+check_communicator_backchannel (void *cls,
+ const struct
+ GNUNET_TRANSPORT_CommunicatorBackchannel *msg)
+{
+ // struct TransportClient *tc = cls;
+
+ // if (CT_COMMUNICATOR != tc->type)
+ // {
+ // GNUNET_break (0);
+ // return GNUNET_SYSERR;
+ // }
+ // GNUNET_MQ_check_boxed_message (msg);
+ return GNUNET_OK;
+}
+
+
+/**
+ * @brief Receive an incoming message.
+ *
+ * Pass the message to the client.
+ *
+ * @param cls Closure - communicator handle
+ * @param msg Message
+ */
+static void
+handle_communicator_backchannel (void *cls,
+ const struct
+ GNUNET_TRANSPORT_CommunicatorBackchannel *
+ bc_msg)
+{
+ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls;
+ struct GNUNET_MessageHeader *msg;
+ msg = (struct GNUNET_MessageHeader *) &bc_msg[1];
+ size_t payload_len = ntohs (msg->size) - sizeof (struct
+ GNUNET_MessageHeader);
+
+ GNUNET_SERVICE_client_continue (tc_h->client);
+}
+
+
+/**
* Address of our peer added. Test message is well-formed.
*
* @param cls the client
@@ -373,6 +421,8 @@ handle_incoming_msg (void *cls,
msg = (struct GNUNET_MessageHeader *) &inc_msg[1];
size_t payload_len = ntohs (msg->size) - sizeof (struct
GNUNET_MessageHeader);
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Incoming message from communicator!\n");
if (NULL != tc_h->incoming_msg_cb)
{
@@ -386,7 +436,7 @@ handle_incoming_msg (void *cls,
LOG (GNUNET_ERROR_TYPE_WARNING,
"Incoming message from communicator but no handler!\n");
}
- if (0 != ntohl (inc_msg->fc_on))
+ if (GNUNET_YES == ntohl (inc_msg->fc_on))
{
/* send ACK when done to communicator for flow control! */
struct GNUNET_MQ_Envelope *env;
@@ -613,10 +663,10 @@ transport_communicator_start (
GNUNET_MESSAGE_TYPE_TRANSPORT_NEW_COMMUNICATOR,
struct GNUNET_TRANSPORT_CommunicatorAvailableMessage,
tc_h),
- // GNUNET_MQ_hd_var_size (communicator_backchannel,
- // GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL,
- // struct GNUNET_TRANSPORT_CommunicatorBackchannel,
- // NULL),
+ GNUNET_MQ_hd_var_size (communicator_backchannel,
+ GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL,
+ struct GNUNET_TRANSPORT_CommunicatorBackchannel,
+ tc_h),
GNUNET_MQ_hd_var_size (add_address,
GNUNET_MESSAGE_TYPE_TRANSPORT_ADD_ADDRESS,
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 (
// and then have the application fill in the body so we do
// not have to memcpy()
memcpy (&im[1], msg, msize);
+ im->fc_on = htonl (GNUNET_NO);
if (NULL != cb)
{
struct FlowControl *fc;