aboutsummaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/Makefile.am2
-rw-r--r--src/transport/gnunet-communicator-udp.c41
-rw-r--r--src/transport/gnunet-service-tng.c80
-rw-r--r--src/transport/test_transport_plugin_cmd_simple_send.c17
-rw-r--r--src/transport/test_transport_plugin_cmd_udp_backchannel.c13
-rwxr-xr-xsrc/transport/test_transport_simple_send_string.sh16
-rw-r--r--src/transport/test_transport_start_with_config.c76
-rw-r--r--src/transport/transport_api_cmd_backchannel_check.c1
-rw-r--r--src/transport/transport_api_cmd_connecting_peers.c5
-rw-r--r--src/transport/transport_api_cmd_send_simple.c1
-rw-r--r--src/transport/transport_api_cmd_send_simple_v3.c194
-rw-r--r--src/transport/transport_api_cmd_start_peer.c5
-rw-r--r--src/transport/transport_api_cmd_stop_peer.c1
13 files changed, 232 insertions, 220 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am
index d281c4ffb..5fe8229e7 100644
--- a/src/transport/Makefile.am
+++ b/src/transport/Makefile.am
@@ -738,7 +738,9 @@ endif
738endif 738endif
739 739
740check_SCRIPTS= \ 740check_SCRIPTS= \
741 test_transport_simple_send_string.sh \
741 test_transport_simple_send.sh \ 742 test_transport_simple_send.sh \
743 test_transport_simple_send_broadcast.sh \
742 test_transport_udp_backchannel.sh 744 test_transport_udp_backchannel.sh
743 745
744test_transport_start_with_config_SOURCES = \ 746test_transport_start_with_config_SOURCES = \
diff --git a/src/transport/gnunet-communicator-udp.c b/src/transport/gnunet-communicator-udp.c
index 659fd7d26..b7a3b4082 100644
--- a/src/transport/gnunet-communicator-udp.c
+++ b/src/transport/gnunet-communicator-udp.c
@@ -2262,6 +2262,7 @@ static void
2262sock_read (void *cls) 2262sock_read (void *cls)
2263{ 2263{
2264 struct sockaddr_storage sa; 2264 struct sockaddr_storage sa;
2265 struct sockaddr_in *addr_verify;
2265 socklen_t salen = sizeof(sa); 2266 socklen_t salen = sizeof(sa);
2266 char buf[UINT16_MAX]; 2267 char buf[UINT16_MAX];
2267 ssize_t rcvd; 2268 ssize_t rcvd;
@@ -2341,12 +2342,22 @@ sock_read (void *cls)
2341 { 2342 {
2342 const struct UDPBroadcast *ub; 2343 const struct UDPBroadcast *ub;
2343 struct UdpBroadcastSignature uhs; 2344 struct UdpBroadcastSignature uhs;
2345 struct GNUNET_PeerIdentity sender;
2344 2346
2347 addr_verify = GNUNET_memdup (&sa, salen);
2348 addr_verify->sin_port = 0;
2349 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2350 "received UDPBroadcast from %s\n",
2351 GNUNET_a2s ((const struct sockaddr *) addr_verify, salen));
2345 ub = (const struct UDPBroadcast *) buf; 2352 ub = (const struct UDPBroadcast *) buf;
2346 uhs.purpose.purpose = htonl (GNUNET_SIGNATURE_COMMUNICATOR_UDP_BROADCAST); 2353 uhs.purpose.purpose = htonl (GNUNET_SIGNATURE_COMMUNICATOR_UDP_BROADCAST);
2347 uhs.purpose.size = htonl (sizeof(uhs)); 2354 uhs.purpose.size = htonl (sizeof(uhs));
2348 uhs.sender = ub->sender; 2355 uhs.sender = ub->sender;
2349 GNUNET_CRYPTO_hash (&sa, salen, &uhs.h_address); 2356 sender = ub->sender;
2357 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2358 "checking UDPBroadcastSignature for %s\n",
2359 GNUNET_i2s (&sender));
2360 GNUNET_CRYPTO_hash ((struct sockaddr *) addr_verify, salen, &uhs.h_address);
2350 if (GNUNET_OK == 2361 if (GNUNET_OK ==
2351 GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_COMMUNICATOR_UDP_BROADCAST, 2362 GNUNET_CRYPTO_eddsa_verify (GNUNET_SIGNATURE_COMMUNICATOR_UDP_BROADCAST,
2352 &uhs, 2363 &uhs,
@@ -2362,10 +2373,23 @@ sock_read (void *cls)
2362 /* use our own mechanism to determine network type */ 2373 /* use our own mechanism to determine network type */
2363 nt = 2374 nt =
2364 GNUNET_NT_scanner_get_type (is, (const struct sockaddr *) &sa, salen); 2375 GNUNET_NT_scanner_get_type (is, (const struct sockaddr *) &sa, salen);
2365 GNUNET_TRANSPORT_application_validate (ah, &ub->sender, nt, addr_s); 2376 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2377 "validating address %s received from UDPBroadcast\n",
2378 GNUNET_i2s (&sender));
2379 GNUNET_TRANSPORT_application_validate (ah, &sender, nt, addr_s);
2366 GNUNET_free (addr_s); 2380 GNUNET_free (addr_s);
2367 return; 2381 return;
2368 } 2382 }
2383 else
2384 {
2385 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2386 "VerifyingPeer %s is verifying UDPBroadcast\n",
2387 GNUNET_i2s (&my_identity));
2388 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2389 "Verifying UDPBroadcast from %s failed\n",
2390 GNUNET_i2s (&ub->sender));
2391 }
2392 GNUNET_free (addr_verify);
2369 /* continue with KX, mostly for statistics... */ 2393 /* continue with KX, mostly for statistics... */
2370 } 2394 }
2371 2395
@@ -3477,7 +3501,7 @@ ifc_broadcast (void *cls)
3477 delay.rel_value_us = 3501 delay.rel_value_us =
3478 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, delay.rel_value_us); 3502 GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, delay.rel_value_us);
3479 bi->broadcast_task = 3503 bi->broadcast_task =
3480 GNUNET_SCHEDULER_add_delayed (INTERFACE_SCAN_FREQUENCY, &ifc_broadcast, bi); 3504 GNUNET_SCHEDULER_add_delayed (delay, &ifc_broadcast, bi);
3481 3505
3482 switch (bi->sa->sa_family) 3506 switch (bi->sa->sa_family)
3483 { 3507 {
@@ -3494,6 +3518,12 @@ ifc_broadcast (void *cls)
3494 sizeof(int))) 3518 sizeof(int)))
3495 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, 3519 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
3496 "setsockopt"); 3520 "setsockopt");
3521 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3522 "creating UDPBroadcast from %s\n",
3523 GNUNET_i2s (&(bi->bcm.sender)));
3524 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3525 "sending UDPBroadcast to add %s\n",
3526 GNUNET_a2s (bi->ba, bi->salen));
3497 sent = GNUNET_NETWORK_socket_sendto (udp_sock, 3527 sent = GNUNET_NETWORK_socket_sendto (udp_sock,
3498 &bi->bcm, 3528 &bi->bcm,
3499 sizeof(bi->bcm), 3529 sizeof(bi->bcm),
@@ -3521,6 +3551,8 @@ ifc_broadcast (void *cls)
3521 dst.sin6_addr = bi->mcreq.ipv6mr_multiaddr; 3551 dst.sin6_addr = bi->mcreq.ipv6mr_multiaddr;
3522 dst.sin6_scope_id = ((struct sockaddr_in6 *) bi->ba)->sin6_scope_id; 3552 dst.sin6_scope_id = ((struct sockaddr_in6 *) bi->ba)->sin6_scope_id;
3523 3553
3554 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3555 "sending UDPBroadcast\n");
3524 sent = GNUNET_NETWORK_socket_sendto (udp_sock, 3556 sent = GNUNET_NETWORK_socket_sendto (udp_sock,
3525 &bi->bcm, 3557 &bi->bcm,
3526 sizeof(bi->bcm), 3558 sizeof(bi->bcm),
@@ -3608,6 +3640,9 @@ iface_proc (void *cls,
3608 ubs.purpose.purpose = htonl (GNUNET_SIGNATURE_COMMUNICATOR_UDP_BROADCAST); 3640 ubs.purpose.purpose = htonl (GNUNET_SIGNATURE_COMMUNICATOR_UDP_BROADCAST);
3609 ubs.purpose.size = htonl (sizeof(ubs)); 3641 ubs.purpose.size = htonl (sizeof(ubs));
3610 ubs.sender = my_identity; 3642 ubs.sender = my_identity;
3643 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3644 "creating UDPBroadcastSignature for %s\n",
3645 GNUNET_a2s (addr, addrlen));
3611 GNUNET_CRYPTO_hash (addr, addrlen, &ubs.h_address); 3646 GNUNET_CRYPTO_hash (addr, addrlen, &ubs.h_address);
3612 GNUNET_CRYPTO_eddsa_sign (my_private_key, 3647 GNUNET_CRYPTO_eddsa_sign (my_private_key,
3613 &ubs, 3648 &ubs,
diff --git a/src/transport/gnunet-service-tng.c b/src/transport/gnunet-service-tng.c
index a90bef3b5..84199a75f 100644
--- a/src/transport/gnunet-service-tng.c
+++ b/src/transport/gnunet-service-tng.c
@@ -4738,15 +4738,17 @@ send_dv_to_neighbour (void *cls,
4738 * @return expected RTT for transmission, #GNUNET_TIME_UNIT_FOREVER_REL if sending failed 4738 * @return expected RTT for transmission, #GNUNET_TIME_UNIT_FOREVER_REL if sending failed
4739 */ 4739 */
4740static struct GNUNET_TIME_Relative 4740static struct GNUNET_TIME_Relative
4741route_control_message_without_fc (const struct GNUNET_PeerIdentity *target, 4741route_control_message_without_fc (struct VirtualLink *vl,
4742// route_control_message_without_fc (const struct GNUNET_PeerIdentity *target,
4742 const struct GNUNET_MessageHeader *hdr, 4743 const struct GNUNET_MessageHeader *hdr,
4743 enum RouteMessageOptions options) 4744 enum RouteMessageOptions options)
4744{ 4745{
4745 struct VirtualLink *vl; 4746 // struct VirtualLink *vl;
4746 struct Neighbour *n; 4747 struct Neighbour *n;
4747 struct DistanceVector *dv; 4748 struct DistanceVector *dv;
4748 struct GNUNET_TIME_Relative rtt1; 4749 struct GNUNET_TIME_Relative rtt1;
4749 struct GNUNET_TIME_Relative rtt2; 4750 struct GNUNET_TIME_Relative rtt2;
4751 const struct GNUNET_PeerIdentity *target = &vl->target;
4750 4752
4751 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 4753 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
4752 "Trying to route message of type %u to %s without fc\n", 4754 "Trying to route message of type %u to %s without fc\n",
@@ -4754,7 +4756,7 @@ route_control_message_without_fc (const struct GNUNET_PeerIdentity *target,
4754 GNUNET_i2s (target)); 4756 GNUNET_i2s (target));
4755 4757
4756 // TODO Do this elsewhere. vl should be given as parameter to method. 4758 // TODO Do this elsewhere. vl should be given as parameter to method.
4757 vl = lookup_virtual_link (target); 4759 // vl = lookup_virtual_link (target);
4758 GNUNET_assert (NULL != vl); 4760 GNUNET_assert (NULL != vl);
4759 if (NULL == vl) 4761 if (NULL == vl)
4760 return GNUNET_TIME_UNIT_FOREVER_REL; 4762 return GNUNET_TIME_UNIT_FOREVER_REL;
@@ -4892,7 +4894,7 @@ consider_sending_fc (void *cls)
4892 fc.outbound_sent = GNUNET_htonll (vl->outbound_fc_window_size_used); 4894 fc.outbound_sent = GNUNET_htonll (vl->outbound_fc_window_size_used);
4893 fc.outbound_window_size = GNUNET_htonll (vl->outbound_fc_window_size); 4895 fc.outbound_window_size = GNUNET_htonll (vl->outbound_fc_window_size);
4894 fc.sender_time = GNUNET_TIME_absolute_hton (monotime); 4896 fc.sender_time = GNUNET_TIME_absolute_hton (monotime);
4895 rtt = route_control_message_without_fc (&vl->target, &fc.header, RMO_NONE); 4897 rtt = route_control_message_without_fc (vl, &fc.header, RMO_NONE);
4896 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == rtt.rel_value_us) 4898 if (GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us == rtt.rel_value_us)
4897 { 4899 {
4898 rtt = GNUNET_TIME_UNIT_SECONDS; 4900 rtt = GNUNET_TIME_UNIT_SECONDS;
@@ -5086,6 +5088,8 @@ handle_communicator_backchannel (
5086 void *cls, 5088 void *cls,
5087 const struct GNUNET_TRANSPORT_CommunicatorBackchannel *cb) 5089 const struct GNUNET_TRANSPORT_CommunicatorBackchannel *cb)
5088{ 5090{
5091 struct Neighbour *n;
5092 struct VirtualLink *vl;
5089 struct TransportClient *tc = cls; 5093 struct TransportClient *tc = cls;
5090 const struct GNUNET_MessageHeader *inbox = 5094 const struct GNUNET_MessageHeader *inbox =
5091 (const struct GNUNET_MessageHeader *) &cb[1]; 5095 (const struct GNUNET_MessageHeader *) &cb[1];
@@ -5116,7 +5120,22 @@ handle_communicator_backchannel (
5116 + isize], 5120 + isize],
5117 is, 5121 is,
5118 strlen (is) + 1); 5122 strlen (is) + 1);
5119 route_control_message_without_fc (&cb->pid, &be->header, RMO_DV_ALLOWED); 5123 // route_control_message_without_fc (&cb->pid, &be->header, RMO_DV_ALLOWED);
5124 vl = lookup_virtual_link (&cb->pid);
5125 if (NULL != vl)
5126 {
5127 route_control_message_without_fc (vl, &be->header, RMO_DV_ALLOWED);
5128 }
5129 else
5130 {
5131 /* Use route via neighbour */
5132 n = lookup_neighbour (&cb->pid);
5133 if (NULL != n)
5134 route_via_neighbour (
5135 n,
5136 &be->header,
5137 RMO_NONE);
5138 }
5120 GNUNET_SERVICE_client_continue (tc->client); 5139 GNUNET_SERVICE_client_continue (tc->client);
5121} 5140}
5122 5141
@@ -5540,6 +5559,8 @@ destroy_ack_cummulator (void *cls)
5540static void 5559static void
5541transmit_cummulative_ack_cb (void *cls) 5560transmit_cummulative_ack_cb (void *cls)
5542{ 5561{
5562 struct Neighbour *n;
5563 struct VirtualLink *vl;
5543 struct AcknowledgementCummulator *ac = cls; 5564 struct AcknowledgementCummulator *ac = cls;
5544 char buf[sizeof(struct TransportReliabilityAckMessage) 5565 char buf[sizeof(struct TransportReliabilityAckMessage)
5545 + ac->ack_counter 5566 + ac->ack_counter
@@ -5566,7 +5587,28 @@ transmit_cummulative_ack_cb (void *cls)
5566 ap[i].ack_delay = GNUNET_TIME_relative_hton ( 5587 ap[i].ack_delay = GNUNET_TIME_relative_hton (
5567 GNUNET_TIME_absolute_get_duration (ac->ack_uuids[i].receive_time)); 5588 GNUNET_TIME_absolute_get_duration (ac->ack_uuids[i].receive_time));
5568 } 5589 }
5569 route_control_message_without_fc (&ac->target, &ack->header, RMO_DV_ALLOWED); 5590 /*route_control_message_without_fc (
5591 &ac->target,
5592 &ack->header,
5593 RMO_DV_ALLOWED);*/
5594 vl = lookup_virtual_link (&ac->target);
5595 if (NULL != vl)
5596 {
5597 route_control_message_without_fc (
5598 vl,
5599 &ack->header,
5600 RMO_DV_ALLOWED);
5601 }
5602 else
5603 {
5604 /* Use route via neighbour */
5605 n = lookup_neighbour (&ac->target);
5606 if (NULL != n)
5607 route_via_neighbour (
5608 n,
5609 &ack->header,
5610 RMO_NONE);
5611 }
5570 ac->num_acks = 0; 5612 ac->num_acks = 0;
5571 ac->task = GNUNET_SCHEDULER_add_delayed (ACK_CUMMULATOR_TIMEOUT, 5613 ac->task = GNUNET_SCHEDULER_add_delayed (ACK_CUMMULATOR_TIMEOUT,
5572 &destroy_ack_cummulator, 5614 &destroy_ack_cummulator,
@@ -6558,6 +6600,8 @@ forward_dv_learn (const struct GNUNET_PeerIdentity *next_hop,
6558 const struct DVPathEntryP *hops, 6600 const struct DVPathEntryP *hops,
6559 struct GNUNET_TIME_Absolute in_time) 6601 struct GNUNET_TIME_Absolute in_time)
6560{ 6602{
6603 struct Neighbour *n;
6604 struct VirtualLink *vl;
6561 struct DVPathEntryP *dhops; 6605 struct DVPathEntryP *dhops;
6562 char buf[sizeof(struct TransportDVLearnMessage) 6606 char buf[sizeof(struct TransportDVLearnMessage)
6563 + (nhops + 1) * sizeof(struct DVPathEntryP)] GNUNET_ALIGN; 6607 + (nhops + 1) * sizeof(struct DVPathEntryP)] GNUNET_ALIGN;
@@ -6598,9 +6642,26 @@ forward_dv_learn (const struct GNUNET_PeerIdentity *next_hop,
6598 &dhp, 6642 &dhp,
6599 &dhops[nhops].hop_sig); 6643 &dhops[nhops].hop_sig);
6600 } 6644 }
6601 route_control_message_without_fc (next_hop, 6645 /*route_control_message_without_fc (next_hop,
6602 &fwd->header, 6646 &fwd->header,
6603 RMO_UNCONFIRMED_ALLOWED); 6647 RMO_UNCONFIRMED_ALLOWED);*/
6648 vl = lookup_virtual_link (next_hop);
6649 if (NULL != vl)
6650 {
6651 route_control_message_without_fc (vl,
6652 &fwd->header,
6653 RMO_UNCONFIRMED_ALLOWED);
6654 }
6655 else
6656 {
6657 /* Use route via neighbour */
6658 n = lookup_neighbour (next_hop);
6659 if (NULL != n)
6660 route_via_neighbour (
6661 n,
6662 &fwd->header,
6663 RMO_UNCONFIRMED_ALLOWED);
6664 }
6604} 6665}
6605 6666
6606 6667
@@ -7937,7 +7998,8 @@ handle_validation_challenge (
7937 vl = lookup_virtual_link (&sender); 7998 vl = lookup_virtual_link (&sender);
7938 if (NULL != vl) 7999 if (NULL != vl)
7939 { 8000 {
7940 route_control_message_without_fc (&cmc->im.sender, 8001 // route_control_message_without_fc (&cmc->im.sender,
8002 route_control_message_without_fc (vl,
7941 &tvr.header, 8003 &tvr.header,
7942 RMO_ANYTHING_GOES | RMO_REDUNDANT); 8004 RMO_ANYTHING_GOES | RMO_REDUNDANT);
7943 } 8005 }
diff --git a/src/transport/test_transport_plugin_cmd_simple_send.c b/src/transport/test_transport_plugin_cmd_simple_send.c
index c374fc2d0..2c987e601 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send.c
@@ -25,6 +25,7 @@
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_testing_ng_lib.h" 27#include "gnunet_testing_ng_lib.h"
28#include "gnunet_testing_netjail_lib.h"
28#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
29#include "gnunet_transport_application_service.h" 30#include "gnunet_transport_application_service.h"
30#include "transport-testing2.h" 31#include "transport-testing2.h"
@@ -213,7 +214,9 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
213 char *node_ip, 214 char *node_ip,
214 char *m, 215 char *m,
215 char *n, 216 char *n,
216 char *local_m) 217 char *local_m,
218 char *topology_data,
219 unsigned int *read_file)
217{ 220{
218 221
219 unsigned int n_int; 222 unsigned int n_int;
@@ -221,8 +224,16 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
221 unsigned int local_m_int; 224 unsigned int local_m_int;
222 unsigned int num; 225 unsigned int num;
223 struct TestState *ts = GNUNET_new (struct TestState); 226 struct TestState *ts = GNUNET_new (struct TestState);
224 struct GNUNET_TESTING_NetjailTopology *topology = 227 struct GNUNET_TESTING_NetjailTopology *topology;
225 GNUNET_TESTING_get_topo_from_file (TOPOLOGY_CONFIG); 228
229 if (GNUNET_YES == *read_file)
230 {
231 LOG (GNUNET_ERROR_TYPE_DEBUG,
232 "read from file\n");
233 topology = GNUNET_TESTING_get_topo_from_file (topology_data);
234 }
235 else
236 topology = GNUNET_TESTING_get_topo_from_string (topology_data);
226 237
227 ts->topology = topology; 238 ts->topology = topology;
228 239
diff --git a/src/transport/test_transport_plugin_cmd_udp_backchannel.c b/src/transport/test_transport_plugin_cmd_udp_backchannel.c
index f3afbec48..db320844f 100644
--- a/src/transport/test_transport_plugin_cmd_udp_backchannel.c
+++ b/src/transport/test_transport_plugin_cmd_udp_backchannel.c
@@ -25,6 +25,7 @@
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_testing_ng_lib.h" 27#include "gnunet_testing_ng_lib.h"
28#include "gnunet_testing_netjail_lib.h"
28#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
29#include "gnunet_transport_application_service.h" 30#include "gnunet_transport_application_service.h"
30#include "transport-testing2.h" 31#include "transport-testing2.h"
@@ -207,7 +208,9 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
207 char *node_ip, 208 char *node_ip,
208 char *m, 209 char *m,
209 char *n, 210 char *n,
210 char *local_m) 211 char *local_m,
212 char *topology_data,
213 unsigned int *read_file)
211{ 214{
212 215
213 unsigned int n_int; 216 unsigned int n_int;
@@ -216,8 +219,12 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
216 unsigned int num; 219 unsigned int num;
217 struct TestState *ts = GNUNET_new (struct TestState); 220 struct TestState *ts = GNUNET_new (struct TestState);
218 221
219 struct GNUNET_TESTING_NetjailTopology *topology = 222 struct GNUNET_TESTING_NetjailTopology *topology;
220 GNUNET_TESTING_get_topo_from_file (TOPOLOGY_CONFIG); 223
224 if (GNUNET_YES == *read_file)
225 topology = GNUNET_TESTING_get_topo_from_file (topology_data);
226 else
227 topology = GNUNET_TESTING_get_topo_from_string (topology_data);
221 228
222 ts->topology = topology; 229 ts->topology = topology;
223 230
diff --git a/src/transport/test_transport_simple_send_string.sh b/src/transport/test_transport_simple_send_string.sh
new file mode 100755
index 000000000..018ea55e8
--- /dev/null
+++ b/src/transport/test_transport_simple_send_string.sh
@@ -0,0 +1,16 @@
1#!/bin/bash
2string=$(cat << EOF
3M:2
4N:1
5X:0
6T:libgnunet_test_transport_plugin_cmd_simple_send
7P:1:1|{connect:{P:1:2:tcp}}
8P:1:2|{connect:{P:1:1:tcp}}
9EOF
10)
11if [ "$(sysctl -n kernel.unprivileged_userns_clone)" == 1 ]; then
12 exec unshare -r -nmU bash -c "mount -t tmpfs --make-rshared tmpfs /run/netns; ./test_transport_start_with_config -s '$string'"
13else
14 echo -e "Error during test setup: The kernel parameter kernel.unprivileged_userns_clone has to be set to 1! One has to execute\n\n sysctl kernel.unprivileged_userns_clone=1\n"
15 exit 78
16fi
diff --git a/src/transport/test_transport_start_with_config.c b/src/transport/test_transport_start_with_config.c
index 932b0e583..7eb92d629 100644
--- a/src/transport/test_transport_start_with_config.c
+++ b/src/transport/test_transport_start_with_config.c
@@ -25,6 +25,7 @@
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_testing_ng_lib.h" 27#include "gnunet_testing_ng_lib.h"
28#include "gnunet_testing_netjail_lib.h"
28#include "gnunet_util_lib.h" 29#include "gnunet_util_lib.h"
29 30
30#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120) 31#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120)
@@ -34,27 +35,86 @@ int
34main (int argc, 35main (int argc,
35 char *const *argv) 36 char *const *argv)
36{ 37{
37 char *topology_config; 38 char *topology_data;
39 char *topology_data_script;
40 struct GNUNET_TESTING_NetjailTopology *topology;
41 unsigned int read_file = GNUNET_YES;
42 int ret;
43 char *rest = NULL;
44 char *token;
45 size_t single_line_len;
46 size_t data_len;
38 47
39 GNUNET_log_setup ("test-netjail", 48 GNUNET_log_setup ("test-netjail",
40 "DEBUG", 49 "DEBUG",
41 NULL); 50 NULL);
42 51
43 topology_config = argv[1]; 52 if (0 == strcmp ("-s", argv[1]))
53 {
54 data_len = strlen (argv[2]);
55 topology_data = GNUNET_malloc (data_len);
56 topology_data_script = GNUNET_malloc (data_len);
57 token = strtok_r (argv[2], "\n", &rest);
58 while (NULL != token)
59 {
60 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
61 "token1 %s\n",
62 token);
63 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
64 "token2 %s\n",
65 token);
66 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
67 "topology_data %s\n",
68 topology_data);
69 strcat (topology_data_script, token);
70 strcat (topology_data_script, " ");
71 strcat (topology_data, token);
72 strcat (topology_data, "\n");
73 token = strtok_r (NULL, "\n", &rest);
74 }
75 single_line_len = strlen (topology_data);
76 topology_data_script [single_line_len - 1] = '\0';
77 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
78 "read from string\n");
79 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
80 "topology_data %s\n",
81 topology_data);
82 read_file = GNUNET_NO;
83 topology = GNUNET_TESTING_get_topo_from_string (topology_data);
84 }
85 else
86 {
87 topology_data = argv[1];
88 topology_data_script = argv[1];
89 topology = GNUNET_TESTING_get_topo_from_file (topology_data);
90 }
44 91
45 struct GNUNET_TESTING_Command commands[] = { 92 struct GNUNET_TESTING_Command commands[] = {
46 GNUNET_TESTING_cmd_netjail_start ("netjail-start", 93 GNUNET_TESTING_cmd_netjail_start ("netjail-start",
47 topology_config), 94 topology_data_script,
95 &read_file),
48 GNUNET_TESTING_cmd_netjail_start_testing_system ("netjail-start-testbed", 96 GNUNET_TESTING_cmd_netjail_start_testing_system ("netjail-start-testbed",
49 topology_config), 97 topology,
98 &read_file,
99 topology_data_script),
50 GNUNET_TESTING_cmd_stop_testing_system ("stop-testbed", 100 GNUNET_TESTING_cmd_stop_testing_system ("stop-testbed",
51 "netjail-start-testbed", 101 "netjail-start-testbed",
52 topology_config), 102 topology),
53 GNUNET_TESTING_cmd_netjail_stop ("netjail-stop", 103 GNUNET_TESTING_cmd_netjail_stop ("netjail-stop",
54 topology_config), 104 topology_data_script,
105 &read_file),
55 GNUNET_TESTING_cmd_end () 106 GNUNET_TESTING_cmd_end ()
56 }; 107 };
57 108
58 return GNUNET_TESTING_main (commands, 109 ret = GNUNET_TESTING_main (commands,
59 TIMEOUT); 110 TIMEOUT);
111
112 if (0 == strcmp ("-s", argv[1]))
113 {
114 GNUNET_free (topology_data_script);
115 GNUNET_free (topology_data);
116 }
117 GNUNET_TESTING_free_topology (topology);
118
119 return ret;
60} 120}
diff --git a/src/transport/transport_api_cmd_backchannel_check.c b/src/transport/transport_api_cmd_backchannel_check.c
index 03b231347..529b4690b 100644
--- a/src/transport/transport_api_cmd_backchannel_check.c
+++ b/src/transport/transport_api_cmd_backchannel_check.c
@@ -27,6 +27,7 @@
27#include "gnunet_common.h" 27#include "gnunet_common.h"
28#include "gnunet_util_lib.h" 28#include "gnunet_util_lib.h"
29#include "gnunet_testing_ng_lib.h" 29#include "gnunet_testing_ng_lib.h"
30#include "gnunet_testing_netjail_lib.h"
30#include "gnunet_transport_application_service.h" 31#include "gnunet_transport_application_service.h"
31#include "gnunet_hello_lib.h" 32#include "gnunet_hello_lib.h"
32#include "gnunet_transport_service.h" 33#include "gnunet_transport_service.h"
diff --git a/src/transport/transport_api_cmd_connecting_peers.c b/src/transport/transport_api_cmd_connecting_peers.c
index 2eb1b0914..b50b63c62 100644
--- a/src/transport/transport_api_cmd_connecting_peers.c
+++ b/src/transport/transport_api_cmd_connecting_peers.c
@@ -26,6 +26,7 @@
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_testing_ng_lib.h" 28#include "gnunet_testing_ng_lib.h"
29#include "gnunet_testing_netjail_lib.h"
29#include "gnunet_transport_application_service.h" 30#include "gnunet_transport_application_service.h"
30#include "gnunet_hello_lib.h" 31#include "gnunet_hello_lib.h"
31#include "gnunet_transport_service.h" 32#include "gnunet_transport_service.h"
@@ -91,6 +92,10 @@ connect_peers_run (void *cls,
91 addr = GNUNET_TESTING_get_address (pos_connection, 92 addr = GNUNET_TESTING_get_address (pos_connection,
92 pos_prefix->address_prefix); 93 pos_prefix->address_prefix);
93 peer = GNUNET_TESTING_get_pub_key (num, tl_system); 94 peer = GNUNET_TESTING_get_pub_key (num, tl_system);
95 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
96 "validating peer number %u with identity %s\n",
97 num,
98 GNUNET_i2s (peer));
94 GNUNET_TRANSPORT_application_validate (ah, 99 GNUNET_TRANSPORT_application_validate (ah,
95 peer, 100 peer,
96 nt, 101 nt,
diff --git a/src/transport/transport_api_cmd_send_simple.c b/src/transport/transport_api_cmd_send_simple.c
index 9c34c50d7..790139cce 100644
--- a/src/transport/transport_api_cmd_send_simple.c
+++ b/src/transport/transport_api_cmd_send_simple.c
@@ -26,6 +26,7 @@
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_testing_ng_lib.h" 28#include "gnunet_testing_ng_lib.h"
29#include "gnunet_testing_netjail_lib.h"
29#include "transport-testing2.h" 30#include "transport-testing2.h"
30#include "transport-testing-cmds.h" 31#include "transport-testing-cmds.h"
31 32
diff --git a/src/transport/transport_api_cmd_send_simple_v3.c b/src/transport/transport_api_cmd_send_simple_v3.c
deleted file mode 100644
index a4ce2c4e9..000000000
--- a/src/transport/transport_api_cmd_send_simple_v3.c
+++ /dev/null
@@ -1,194 +0,0 @@
1/*
2 This file is part of GNUnet
3 Copyright (C) 2021 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20
21/**
22 * @file testing_api_cmd_start_peer.c
23 * @brief cmd to start a peer.
24 * @author t3sserakt
25 */
26#include "platform.h"
27#include "gnunet_util_lib.h"
28#include "gnunet_testing_ng_lib.h"
29#include "transport-testing2.h"
30#include "transport-testing-cmds.h"
31
32/**
33 * Struct to hold information for callbacks.
34 *
35 */
36struct SendSimpleState
37{
38 /**
39 * Number globally identifying the node.
40 *
41 */
42 uint32_t num;
43
44 /**
45 * Label of the cmd to start a peer.
46 *
47 */
48 const char *start_peer_label;
49
50 /**
51 * Label of the cmd which started the test system.
52 *
53 */
54 const char *create_label;
55
56 /**
57 * The topology we get the connected nodes from.
58 */
59 struct GNUNET_TESTING_NetjailTopology *topology;
60};
61
62
63/**
64 * Trait function of this cmd does nothing.
65 *
66 */
67static int
68send_simple_traits (void *cls,
69 const void **ret,
70 const char *trait,
71 unsigned int index)
72{
73 return GNUNET_OK;
74}
75
76
77/**
78 * The cleanup function of this cmd frees resources the cmd allocated.
79 *
80 */
81static void
82send_simple_cleanup (void *cls,
83 const struct GNUNET_TESTING_Command *cmd)
84{
85 struct SendSimpleState *sss = cls;
86
87 GNUNET_free (sss);
88}
89
90
91/**
92 * The run method of this cmd will send a simple message to the connected peers.
93 *
94 */
95static void
96send_simple_run (void *cls,
97 const struct GNUNET_TESTING_Command *cmd,
98 struct GNUNET_TESTING_Interpreter *is)
99{
100 struct SendSimpleState *sss = cls;
101 struct GNUNET_MQ_Envelope *env;
102 struct GNUNET_TRANSPORT_TESTING_TestMessage *test;
103 struct GNUNET_MQ_Handle *mq;
104 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
105 const struct GNUNET_TESTING_Command *peer1_cmd;
106 struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode);
107 struct GNUNET_HashCode hc;
108 struct GNUNET_TESTING_NodeConnection *node_connections_head;
109 struct GNUNET_PeerIdentity *peer;
110 struct GNUNET_CRYPTO_EddsaPublicKey public_key;
111 uint32_t num;
112 struct GNUNET_TESTING_NodeConnection *pos_connection;
113 const struct GNUNET_TESTING_Command *system_cmd;
114 struct GNUNET_TESTING_System *tl_system;
115
116 peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (sss->start_peer_label);
117 GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd,
118 &connected_peers_map);
119
120 system_cmd = GNUNET_TESTING_interpreter_lookup_command (sss->create_label);
121 GNUNET_TESTING_get_trait_test_system (system_cmd,
122 &tl_system);
123
124 node_connections_head = GNUNET_TESTING_get_connections (sss->num,
125 sss->topology);
126
127 for (int i = 0; i < 1; i++)
128 {
129 for (pos_connection = node_connections_head; NULL != pos_connection;
130 pos_connection = pos_connection->next)
131 {
132 num = GNUNET_TESTING_calculate_num (pos_connection, sss->topology);
133 peer = GNUNET_TESTING_get_pub_key (num, tl_system);
134 public_key = peer->public_key;
135 GNUNET_CRYPTO_hash (&public_key, sizeof(public_key), &hc);
136
137 memcpy (key,
138 &hc,
139 sizeof (*key));
140 mq = GNUNET_CONTAINER_multishortmap_get (connected_peers_map,
141 key);
142 env = GNUNET_MQ_msg_extra (test,
143 1000 - sizeof(*test),
144 GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE);
145 test->num = htonl (sss->num);
146 memset (&test[1],
147 sss->num,
148 1000 - sizeof(*test));
149 GNUNET_MQ_send (mq,
150 env);
151 }
152 }
153
154 GNUNET_free (key);
155
156}
157
158
159/**
160 * Create command.
161 *
162 * @param label name for command.
163 * @param start_peer_label Label of the cmd to start a peer.
164 * @param start_peer_label Label of the cmd which started the test system.
165 * @param num Number globally identifying the node.
166 * @param The topology for the test setup.
167 * @return command.
168 */
169struct GNUNET_TESTING_Command
170GNUNET_TRANSPORT_cmd_send_simple_v3 (const char *label,
171 const char *start_peer_label,
172 const char *create_label,
173 uint32_t num,
174 struct GNUNET_TESTING_NetjailTopology *
175 topology)
176{
177 struct SendSimpleState *sss;
178
179 sss = GNUNET_new (struct SendSimpleState);
180 sss->num = num;
181 sss->start_peer_label = start_peer_label;
182 sss->create_label = create_label;
183 sss->topology = topology;
184
185 struct GNUNET_TESTING_Command cmd = {
186 .cls = sss,
187 .label = label,
188 .run = &send_simple_run,
189 .cleanup = &send_simple_cleanup,
190 .traits = &send_simple_traits
191 };
192
193 return cmd;
194}
diff --git a/src/transport/transport_api_cmd_start_peer.c b/src/transport/transport_api_cmd_start_peer.c
index a026d48cc..60f416f85 100644
--- a/src/transport/transport_api_cmd_start_peer.c
+++ b/src/transport/transport_api_cmd_start_peer.c
@@ -26,6 +26,7 @@
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_testing_ng_lib.h" 28#include "gnunet_testing_ng_lib.h"
29#include "gnunet_testing_netjail_lib.h"
29#include "gnunet_peerstore_service.h" 30#include "gnunet_peerstore_service.h"
30#include "gnunet_transport_core_service.h" 31#include "gnunet_transport_core_service.h"
31#include "gnunet_transport_application_service.h" 32#include "gnunet_transport_application_service.h"
@@ -172,6 +173,7 @@ start_peer_run (void *cls,
172 char *tcp_communicator_unix_path; 173 char *tcp_communicator_unix_path;
173 char *udp_communicator_unix_path; 174 char *udp_communicator_unix_path;
174 char *bindto; 175 char *bindto;
176 char *bindto_udp;
175 177
176 if (GNUNET_NO == GNUNET_DISK_file_test (sps->cfgname)) 178 if (GNUNET_NO == GNUNET_DISK_file_test (sps->cfgname))
177 { 179 {
@@ -207,6 +209,9 @@ start_peer_run (void *cls,
207 "%s:60002", 209 "%s:60002",
208 sps->node_ip); 210 sps->node_ip);
209 211
212 GNUNET_asprintf (&bindto_udp,
213 "2086");
214
210 LOG (GNUNET_ERROR_TYPE_ERROR, 215 LOG (GNUNET_ERROR_TYPE_ERROR,
211 "node_ip %s\n", 216 "node_ip %s\n",
212 bindto); 217 bindto);
diff --git a/src/transport/transport_api_cmd_stop_peer.c b/src/transport/transport_api_cmd_stop_peer.c
index dcb982a65..97408b083 100644
--- a/src/transport/transport_api_cmd_stop_peer.c
+++ b/src/transport/transport_api_cmd_stop_peer.c
@@ -26,6 +26,7 @@
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_util_lib.h" 27#include "gnunet_util_lib.h"
28#include "gnunet_testing_ng_lib.h" 28#include "gnunet_testing_ng_lib.h"
29#include "gnunet_testing_netjail_lib.h"
29#include "gnunet_peerstore_service.h" 30#include "gnunet_peerstore_service.h"
30#include "gnunet_transport_core_service.h" 31#include "gnunet_transport_core_service.h"
31#include "gnunet_transport_application_service.h" 32#include "gnunet_transport_application_service.h"