update udp communicator
authorSchanzenbach, Martin <mschanzenbach@posteo.de>
Tue, 31 Dec 2019 03:39:14 +0000 (12:39 +0900)
committerSchanzenbach, Martin <mschanzenbach@posteo.de>
Tue, 31 Dec 2019 03:39:14 +0000 (12:39 +0900)
src/transport/gnunet-communicator-udp.c
src/transport/test_communicator_udp_peer1.conf
src/transport/test_communicator_udp_peer2.conf
src/transport/transport-testing2.c
src/transport/transport_api2_communication.c

index 6a4fea315fe22058e877a84f62cf10181588a79b..5abf4258849a573c84552ca146d18ac5127f6203 100644 (file)
@@ -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",
index 417e92ab5aabc6ea9b26a776aa001660957679a2..1b35d8e8a4fad88810b32fa22f05a19ca9f0cef7 100644 (file)
@@ -30,3 +30,4 @@ DISABLE_V6 = YES
 [communicator-udp]
 BINDTO = 60002
 DISABLE_V6 = YES
+MAX_QUEUE_LENGTH=5000
index a063a545a963f14bc86fc1db69320eea30c423e8..0472820aa74fbc7ec2ef4d41a59285e404b345e8 100644 (file)
@@ -30,3 +30,4 @@ DISABLE_V6 = YES
 [communicator-udp]
 BINDTO = 60003
 DISABLE_V6 = YES
+MAX_QUEUE_LENGTH=5000
index 22a767fce6525c3f2728073d65375995d996766c..41d4ab9371e525395f34fb99d316e9e80240f212 100644 (file)
@@ -279,6 +279,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.
  *
@@ -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,
index 9df9424daa3d39fbc4ca7f161dd0b66e0f3c2dfc..01a2447fa29ec67b65f303b9eddafcc622c62373 100644 (file)
@@ -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;