From: Schanzenbach, Martin Date: Tue, 31 Dec 2019 05:39:56 +0000 (+0900) Subject: add backchannel test; fix udp basic X-Git-Tag: v0.12.2~37 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=65b645e3c3910401d43d922d46096aa22c6de9e7;p=oweals%2Fgnunet.git add backchannel test; fix udp basic --- diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index 7dbff2d44..c37a34ab7 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am @@ -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 index 000000000..0c595b77b --- /dev/null +++ b/src/transport/test_communicator_udp_backchannel_peer1.conf @@ -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 index 000000000..d29f37ec9 --- /dev/null +++ b/src/transport/test_communicator_udp_backchannel_peer2.conf @@ -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 index 000000000..1b35d8e8a --- /dev/null +++ b/src/transport/test_communicator_udp_basic_peer1.conf @@ -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 index 1b35d8e8a..000000000 --- a/src/transport/test_communicator_udp_peer1.conf +++ /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 diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c index 41d4ab937..893579bc5 100644 --- a/src/transport/transport-testing2.c +++ b/src/transport/transport-testing2.c @@ -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;