add backchannel test; fix udp basic
authorSchanzenbach, Martin <mschanzenbach@posteo.de>
Tue, 31 Dec 2019 05:39:56 +0000 (14:39 +0900)
committerSchanzenbach, Martin <mschanzenbach@posteo.de>
Tue, 31 Dec 2019 05:39:56 +0000 (14:39 +0900)
src/transport/Makefile.am
src/transport/test_communicator_udp_backchannel_peer1.conf [new file with mode: 0644]
src/transport/test_communicator_udp_backchannel_peer2.conf [new file with mode: 0644]
src/transport/test_communicator_udp_basic_peer1.conf [new file with mode: 0644]
src/transport/test_communicator_udp_peer1.conf [deleted file]
src/transport/transport-testing2.c

index 7dbff2d445608a008f2fb1ca6ab6c7d8ce4e433c..c37a34ab795ed7e1f8129ac8236d389fc06006e3 100644 (file)
@@ -599,7 +599,9 @@ check_PROGRAMS += \
   test_communicator_basic-unix \
   test_communicator_basic-tcp \
   test_communicator_basic-udp \
-  test_communicator_rekey-tcp
+  test_communicator_rekey-tcp \
+  test_communicator_rekey-udp \
+  test_communicator_backchannel-udp
 endif
 endif
 
@@ -813,6 +815,19 @@ test_communicator_rekey_tcp_LDADD = \
  $(top_builddir)/src/testing/libgnunettesting.la \
  $(top_builddir)/src/util/libgnunetutil.la
 
+test_communicator_rekey_udp_SOURCES = \
+ test_communicator_basic.c
+test_communicator_rekey_udp_LDADD = \
+ libgnunettransporttesting2.la \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ $(top_builddir)/src/util/libgnunetutil.la
+
+test_communicator_backchannel_udp_SOURCES = \
+ test_communicator_basic.c
+test_communicator_backchannel_udp_LDADD = \
+ libgnunettransporttesting2.la \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ $(top_builddir)/src/util/libgnunetutil.la
 endif
 
 test_plugin_unix_SOURCES = \
@@ -1519,4 +1534,8 @@ test_communicator_basic_tcp_peer2.conf \
 test_communicator_basic_udp_peer1.conf \
 test_communicator_basic_udp_peer2.conf \
 test_communicator_rekey_tcp_peer1.conf \
-test_communicator_rekey_tcp_peer2.conf
+test_communicator_rekey_tcp_peer2.conf \
+test_communicator_rekey_udp_peer1.conf \
+test_communicator_rekey_udp_peer2.conf \
+test_communicator_backchannel_udp_peer1.conf \
+test_communicator_backchannel_udp_peer2.conf
diff --git a/src/transport/test_communicator_udp_backchannel_peer1.conf b/src/transport/test_communicator_udp_backchannel_peer1.conf
new file mode 100644 (file)
index 0000000..0c595b7
--- /dev/null
@@ -0,0 +1,36 @@
+@INLINE@ test_transport_defaults.conf
+
+[PATHS]
+GNUNET_TEST_HOME = $GNUNET_TMP/test-communicator-unix-1/
+
+[PEER]
+PRIVATE_KEY = $GNUNET_TMP/test-communicator-unix-1/private.key
+
+[transport-tcp]
+PORT = 52400
+
+[transport-udp]
+PORT = 52401
+
+[transport]
+PORT = 60000
+UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-transport_test_1.sock
+
+[nat]
+UNIXPATH = $GNUNET_TMP/test-communicator-unix-1/nat.sock
+ENABLE_IPSCAN = YES
+
+[communicator-unix]
+UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_1.sock
+
+[communicator-tcp]
+BINDTO = 60002
+DISABLE_V6 = YES
+
+[communicator-udp]
+BINDTO = 60002
+DISABLE_V6 = YES
+MAX_QUEUE_LENGTH=5000
+
+[communicator-test]
+BACKCHANNEL_ENABLED = YES
diff --git a/src/transport/test_communicator_udp_backchannel_peer2.conf b/src/transport/test_communicator_udp_backchannel_peer2.conf
new file mode 100644 (file)
index 0000000..d29f37e
--- /dev/null
@@ -0,0 +1,36 @@
+@INLINE@ test_transport_defaults.conf
+
+[PATHS]
+GNUNET_TEST_HOME = $GNUNET_TMP/test-gnunetd-plugin-transport/
+
+[PEER]
+PRIVATE_KEY = $GNUNET_TMP/test-communicator-unix-2/private.key
+
+
+[transport-tcp]
+PORT = 52400
+
+[transport-udp]
+PORT = 52401
+
+[transport]
+PORT = 60001
+UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-transport_test_2.sock
+
+[nat]
+UNIXPATH = $GNUNET_TMP/test-communicator-unix-2/nat.sock
+
+[communicator-unix]
+UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_2.sock
+
+[communicator-tcp]
+BINDTO = 60003
+DISABLE_V6 = YES
+
+[communicator-udp]
+BINDTO = 60003
+DISABLE_V6 = YES
+MAX_QUEUE_LENGTH=5000
+
+[communicator-test]
+BACKCHANNEL_ENABLED = YES
diff --git a/src/transport/test_communicator_udp_basic_peer1.conf b/src/transport/test_communicator_udp_basic_peer1.conf
new file mode 100644 (file)
index 0000000..1b35d8e
--- /dev/null
@@ -0,0 +1,33 @@
+@INLINE@ test_transport_defaults.conf
+
+[PATHS]
+GNUNET_TEST_HOME = $GNUNET_TMP/test-communicator-unix-1/
+
+[PEER]
+PRIVATE_KEY = $GNUNET_TMP/test-communicator-unix-1/private.key
+
+[transport-tcp]
+PORT = 52400
+
+[transport-udp]
+PORT = 52401
+
+[transport]
+PORT = 60000
+UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-transport_test_1.sock
+
+[nat]
+UNIXPATH = $GNUNET_TMP/test-communicator-unix-1/nat.sock
+ENABLE_IPSCAN = YES
+
+[communicator-unix]
+UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_1.sock
+
+[communicator-tcp]
+BINDTO = 60002
+DISABLE_V6 = YES
+
+[communicator-udp]
+BINDTO = 60002
+DISABLE_V6 = YES
+MAX_QUEUE_LENGTH=5000
diff --git a/src/transport/test_communicator_udp_peer1.conf b/src/transport/test_communicator_udp_peer1.conf
deleted file mode 100644 (file)
index 1b35d8e..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-@INLINE@ test_transport_defaults.conf
-
-[PATHS]
-GNUNET_TEST_HOME = $GNUNET_TMP/test-communicator-unix-1/
-
-[PEER]
-PRIVATE_KEY = $GNUNET_TMP/test-communicator-unix-1/private.key
-
-[transport-tcp]
-PORT = 52400
-
-[transport-udp]
-PORT = 52401
-
-[transport]
-PORT = 60000
-UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-transport_test_1.sock
-
-[nat]
-UNIXPATH = $GNUNET_TMP/test-communicator-unix-1/nat.sock
-ENABLE_IPSCAN = YES
-
-[communicator-unix]
-UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_1.sock
-
-[communicator-tcp]
-BINDTO = 60002
-DISABLE_V6 = YES
-
-[communicator-udp]
-BINDTO = 60002
-DISABLE_V6 = YES
-MAX_QUEUE_LENGTH=5000
index 41d4ab9371e525395f34fb99d316e9e80240f212..893579bc55dd37fbbc5b554f37e730afcbe67139 100644 (file)
@@ -150,6 +150,11 @@ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
    * @brief Closure to the callback
    */
   void *cb_cls;
+
+  /**
+   * Backchannel supported
+   */
+  int bc_enabled;
 };
 
 
@@ -320,9 +325,28 @@ handle_communicator_backchannel (void *cls,
   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);
-
+  struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming *cbi;
+  struct GNUNET_MQ_Envelope *env;
+  uint16_t isize = ntohs (msg->size);
+  const char *target_communicator = ((const char *) msg) + isize;
+  if (tc_h->bc_enabled != GNUNET_YES)
+  {
+    GNUNET_SERVICE_client_continue (tc_h->client);
+    return;
+  }
+  /* Find client providing this communicator */
+  /* Finally, deliver backchannel message to communicator */
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Delivering backchannel message of type %u to %s\n",
+              ntohs (msg->type),
+              target_communicator);
+  env = GNUNET_MQ_msg_extra (
+    cbi,
+    isize,
+    GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING);
+  cbi->pid = bc_msg->pid;
+  memcpy (&cbi[1], msg, isize);
+  GNUNET_MQ_send (tc_h->c_mq, env);
   GNUNET_SERVICE_client_continue (tc_h->client);
 }
 
@@ -873,6 +897,9 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_service_start (
     GNUNET_free (tc_h);
     return NULL;
   }
+  tc_h->bc_enabled = GNUNET_CONFIGURATION_get_value_yesno (tc_h->cfg,
+                                                           "communicator-test",
+                                                           "BACKCHANNEL_ENABLED");
   tc_h->communicator_available_cb = communicator_available_cb;
   tc_h->add_address_cb = add_address_cb;
   tc_h->queue_create_reply_cb = queue_create_reply_cb;