diff options
author | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-12-31 14:39:56 +0900 |
---|---|---|
committer | Schanzenbach, Martin <mschanzenbach@posteo.de> | 2019-12-31 14:39:56 +0900 |
commit | 65b645e3c3910401d43d922d46096aa22c6de9e7 (patch) | |
tree | 1661af3f33c2087dd46937ed8d1d5219c7e082fe /src | |
parent | 658ba3f2b74a7b5e4ec92211cded45cdf6af8105 (diff) | |
download | gnunet-65b645e3c3910401d43d922d46096aa22c6de9e7.tar.gz gnunet-65b645e3c3910401d43d922d46096aa22c6de9e7.zip |
add backchannel test; fix udp basic
Diffstat (limited to 'src')
-rw-r--r-- | src/transport/Makefile.am | 23 | ||||
-rw-r--r-- | src/transport/test_communicator_udp_backchannel_peer1.conf | 36 | ||||
-rw-r--r-- | src/transport/test_communicator_udp_backchannel_peer2.conf | 36 | ||||
-rw-r--r-- | src/transport/test_communicator_udp_basic_peer1.conf (renamed from src/transport/test_communicator_udp_peer1.conf) | 0 | ||||
-rw-r--r-- | src/transport/transport-testing2.c | 33 |
5 files changed, 123 insertions, 5 deletions
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 += \ | |||
599 | test_communicator_basic-unix \ | 599 | test_communicator_basic-unix \ |
600 | test_communicator_basic-tcp \ | 600 | test_communicator_basic-tcp \ |
601 | test_communicator_basic-udp \ | 601 | test_communicator_basic-udp \ |
602 | test_communicator_rekey-tcp | 602 | test_communicator_rekey-tcp \ |
603 | test_communicator_rekey-udp \ | ||
604 | test_communicator_backchannel-udp | ||
603 | endif | 605 | endif |
604 | endif | 606 | endif |
605 | 607 | ||
@@ -813,6 +815,19 @@ test_communicator_rekey_tcp_LDADD = \ | |||
813 | $(top_builddir)/src/testing/libgnunettesting.la \ | 815 | $(top_builddir)/src/testing/libgnunettesting.la \ |
814 | $(top_builddir)/src/util/libgnunetutil.la | 816 | $(top_builddir)/src/util/libgnunetutil.la |
815 | 817 | ||
818 | test_communicator_rekey_udp_SOURCES = \ | ||
819 | test_communicator_basic.c | ||
820 | test_communicator_rekey_udp_LDADD = \ | ||
821 | libgnunettransporttesting2.la \ | ||
822 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
823 | $(top_builddir)/src/util/libgnunetutil.la | ||
824 | |||
825 | test_communicator_backchannel_udp_SOURCES = \ | ||
826 | test_communicator_basic.c | ||
827 | test_communicator_backchannel_udp_LDADD = \ | ||
828 | libgnunettransporttesting2.la \ | ||
829 | $(top_builddir)/src/testing/libgnunettesting.la \ | ||
830 | $(top_builddir)/src/util/libgnunetutil.la | ||
816 | endif | 831 | endif |
817 | 832 | ||
818 | test_plugin_unix_SOURCES = \ | 833 | test_plugin_unix_SOURCES = \ |
@@ -1519,4 +1534,8 @@ test_communicator_basic_tcp_peer2.conf \ | |||
1519 | test_communicator_basic_udp_peer1.conf \ | 1534 | test_communicator_basic_udp_peer1.conf \ |
1520 | test_communicator_basic_udp_peer2.conf \ | 1535 | test_communicator_basic_udp_peer2.conf \ |
1521 | test_communicator_rekey_tcp_peer1.conf \ | 1536 | test_communicator_rekey_tcp_peer1.conf \ |
1522 | test_communicator_rekey_tcp_peer2.conf | 1537 | test_communicator_rekey_tcp_peer2.conf \ |
1538 | test_communicator_rekey_udp_peer1.conf \ | ||
1539 | test_communicator_rekey_udp_peer2.conf \ | ||
1540 | test_communicator_backchannel_udp_peer1.conf \ | ||
1541 | 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 @@ | |||
1 | @INLINE@ test_transport_defaults.conf | ||
2 | |||
3 | [PATHS] | ||
4 | GNUNET_TEST_HOME = $GNUNET_TMP/test-communicator-unix-1/ | ||
5 | |||
6 | [PEER] | ||
7 | PRIVATE_KEY = $GNUNET_TMP/test-communicator-unix-1/private.key | ||
8 | |||
9 | [transport-tcp] | ||
10 | PORT = 52400 | ||
11 | |||
12 | [transport-udp] | ||
13 | PORT = 52401 | ||
14 | |||
15 | [transport] | ||
16 | PORT = 60000 | ||
17 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-transport_test_1.sock | ||
18 | |||
19 | [nat] | ||
20 | UNIXPATH = $GNUNET_TMP/test-communicator-unix-1/nat.sock | ||
21 | ENABLE_IPSCAN = YES | ||
22 | |||
23 | [communicator-unix] | ||
24 | UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_1.sock | ||
25 | |||
26 | [communicator-tcp] | ||
27 | BINDTO = 60002 | ||
28 | DISABLE_V6 = YES | ||
29 | |||
30 | [communicator-udp] | ||
31 | BINDTO = 60002 | ||
32 | DISABLE_V6 = YES | ||
33 | MAX_QUEUE_LENGTH=5000 | ||
34 | |||
35 | [communicator-test] | ||
36 | 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 @@ | |||
1 | @INLINE@ test_transport_defaults.conf | ||
2 | |||
3 | [PATHS] | ||
4 | GNUNET_TEST_HOME = $GNUNET_TMP/test-gnunetd-plugin-transport/ | ||
5 | |||
6 | [PEER] | ||
7 | PRIVATE_KEY = $GNUNET_TMP/test-communicator-unix-2/private.key | ||
8 | |||
9 | |||
10 | [transport-tcp] | ||
11 | PORT = 52400 | ||
12 | |||
13 | [transport-udp] | ||
14 | PORT = 52401 | ||
15 | |||
16 | [transport] | ||
17 | PORT = 60001 | ||
18 | UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-transport_test_2.sock | ||
19 | |||
20 | [nat] | ||
21 | UNIXPATH = $GNUNET_TMP/test-communicator-unix-2/nat.sock | ||
22 | |||
23 | [communicator-unix] | ||
24 | UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_2.sock | ||
25 | |||
26 | [communicator-tcp] | ||
27 | BINDTO = 60003 | ||
28 | DISABLE_V6 = YES | ||
29 | |||
30 | [communicator-udp] | ||
31 | BINDTO = 60003 | ||
32 | DISABLE_V6 = YES | ||
33 | MAX_QUEUE_LENGTH=5000 | ||
34 | |||
35 | [communicator-test] | ||
36 | BACKCHANNEL_ENABLED = YES | ||
diff --git a/src/transport/test_communicator_udp_peer1.conf b/src/transport/test_communicator_udp_basic_peer1.conf index 1b35d8e8a..1b35d8e8a 100644 --- a/src/transport/test_communicator_udp_peer1.conf +++ b/src/transport/test_communicator_udp_basic_peer1.conf | |||
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 | |||
150 | * @brief Closure to the callback | 150 | * @brief Closure to the callback |
151 | */ | 151 | */ |
152 | void *cb_cls; | 152 | void *cb_cls; |
153 | |||
154 | /** | ||
155 | * Backchannel supported | ||
156 | */ | ||
157 | int bc_enabled; | ||
153 | }; | 158 | }; |
154 | 159 | ||
155 | 160 | ||
@@ -320,9 +325,28 @@ handle_communicator_backchannel (void *cls, | |||
320 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; | 325 | struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; |
321 | struct GNUNET_MessageHeader *msg; | 326 | struct GNUNET_MessageHeader *msg; |
322 | msg = (struct GNUNET_MessageHeader *) &bc_msg[1]; | 327 | msg = (struct GNUNET_MessageHeader *) &bc_msg[1]; |
323 | size_t payload_len = ntohs (msg->size) - sizeof (struct | 328 | struct GNUNET_TRANSPORT_CommunicatorBackchannelIncoming *cbi; |
324 | GNUNET_MessageHeader); | 329 | struct GNUNET_MQ_Envelope *env; |
325 | 330 | uint16_t isize = ntohs (msg->size); | |
331 | const char *target_communicator = ((const char *) msg) + isize; | ||
332 | if (tc_h->bc_enabled != GNUNET_YES) | ||
333 | { | ||
334 | GNUNET_SERVICE_client_continue (tc_h->client); | ||
335 | return; | ||
336 | } | ||
337 | /* Find client providing this communicator */ | ||
338 | /* Finally, deliver backchannel message to communicator */ | ||
339 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
340 | "Delivering backchannel message of type %u to %s\n", | ||
341 | ntohs (msg->type), | ||
342 | target_communicator); | ||
343 | env = GNUNET_MQ_msg_extra ( | ||
344 | cbi, | ||
345 | isize, | ||
346 | GNUNET_MESSAGE_TYPE_TRANSPORT_COMMUNICATOR_BACKCHANNEL_INCOMING); | ||
347 | cbi->pid = bc_msg->pid; | ||
348 | memcpy (&cbi[1], msg, isize); | ||
349 | GNUNET_MQ_send (tc_h->c_mq, env); | ||
326 | GNUNET_SERVICE_client_continue (tc_h->client); | 350 | GNUNET_SERVICE_client_continue (tc_h->client); |
327 | } | 351 | } |
328 | 352 | ||
@@ -873,6 +897,9 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_service_start ( | |||
873 | GNUNET_free (tc_h); | 897 | GNUNET_free (tc_h); |
874 | return NULL; | 898 | return NULL; |
875 | } | 899 | } |
900 | tc_h->bc_enabled = GNUNET_CONFIGURATION_get_value_yesno (tc_h->cfg, | ||
901 | "communicator-test", | ||
902 | "BACKCHANNEL_ENABLED"); | ||
876 | tc_h->communicator_available_cb = communicator_available_cb; | 903 | tc_h->communicator_available_cb = communicator_available_cb; |
877 | tc_h->add_address_cb = add_address_cb; | 904 | tc_h->add_address_cb = add_address_cb; |
878 | tc_h->queue_create_reply_cb = queue_create_reply_cb; | 905 | tc_h->queue_create_reply_cb = queue_create_reply_cb; |