aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2020-02-18 16:08:43 +0100
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2020-02-18 16:08:43 +0100
commit3b2afcd3b931d56bf028aaf397014d27ff91b2a2 (patch)
treede38b3ad48aa67ce0dee2909ec676a7825e992af /src
parentd2ae278b8dd5d2a93e6325c8f82e85cb13f51d6e (diff)
downloadgnunet-3b2afcd3b931d56bf028aaf397014d27ff91b2a2.tar.gz
gnunet-3b2afcd3b931d56bf028aaf397014d27ff91b2a2.zip
fix TNG test with NAT
Diffstat (limited to 'src')
-rw-r--r--src/transport/test_communicator_udp_basic_peer1.conf9
-rw-r--r--src/transport/test_communicator_udp_basic_peer2.conf11
-rw-r--r--src/transport/transport-testing2.c130
3 files changed, 99 insertions, 51 deletions
diff --git a/src/transport/test_communicator_udp_basic_peer1.conf b/src/transport/test_communicator_udp_basic_peer1.conf
index 1b35d8e8a..4cfb6f72f 100644
--- a/src/transport/test_communicator_udp_basic_peer1.conf
+++ b/src/transport/test_communicator_udp_basic_peer1.conf
@@ -13,20 +13,13 @@ PORT = 52400
13PORT = 52401 13PORT = 52401
14 14
15[transport] 15[transport]
16PORT = 60000 16#PORT = 60000
17UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-transport_test_1.sock 17UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-transport_test_1.sock
18 18
19[nat] 19[nat]
20UNIXPATH = $GNUNET_TMP/test-communicator-unix-1/nat.sock 20UNIXPATH = $GNUNET_TMP/test-communicator-unix-1/nat.sock
21ENABLE_IPSCAN = YES 21ENABLE_IPSCAN = YES
22 22
23[communicator-unix]
24UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_1.sock
25
26[communicator-tcp]
27BINDTO = 60002
28DISABLE_V6 = YES
29
30[communicator-udp] 23[communicator-udp]
31BINDTO = 60002 24BINDTO = 60002
32DISABLE_V6 = YES 25DISABLE_V6 = YES
diff --git a/src/transport/test_communicator_udp_basic_peer2.conf b/src/transport/test_communicator_udp_basic_peer2.conf
index 0472820aa..b9bed2756 100644
--- a/src/transport/test_communicator_udp_basic_peer2.conf
+++ b/src/transport/test_communicator_udp_basic_peer2.conf
@@ -11,22 +11,15 @@ PRIVATE_KEY = $GNUNET_TMP/test-communicator-unix-2/private.key
11PORT = 52400 11PORT = 52400
12 12
13[transport-udp] 13[transport-udp]
14PORT = 52401 14PORT = 52402
15 15
16[transport] 16[transport]
17PORT = 60001 17#PORT = 60001
18UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-transport_test_2.sock 18UNIXPATH = $GNUNET_RUNTIME_DIR/gnunet-service-transport_test_2.sock
19 19
20[nat] 20[nat]
21UNIXPATH = $GNUNET_TMP/test-communicator-unix-2/nat.sock 21UNIXPATH = $GNUNET_TMP/test-communicator-unix-2/nat.sock
22 22
23[communicator-unix]
24UNIXPATH = $GNUNET_RUNTIME_DIR/test_gnunet-communicator-unix_2.sock
25
26[communicator-tcp]
27BINDTO = 60003
28DISABLE_V6 = YES
29
30[communicator-udp] 23[communicator-udp]
31BINDTO = 60003 24BINDTO = 60003
32DISABLE_V6 = YES 25DISABLE_V6 = YES
diff --git a/src/transport/transport-testing2.c b/src/transport/transport-testing2.c
index b087f6976..fe2f28f54 100644
--- a/src/transport/transport-testing2.c
+++ b/src/transport/transport-testing2.c
@@ -37,6 +37,26 @@
37 37
38#define LOG(kind, ...) GNUNET_log_from (kind, "transport-testing2", __VA_ARGS__) 38#define LOG(kind, ...) GNUNET_log_from (kind, "transport-testing2", __VA_ARGS__)
39 39
40struct MyClient
41{
42 struct MyClient *prev;
43 struct MyClient *next;
44 /**
45 * @brief Handle to the client
46 */
47 struct GNUNET_SERVICE_Client *client;
48
49 /**
50 * @brief Handle to the client
51 */
52 struct GNUNET_MQ_Handle *c_mq;
53
54 /**
55 * The TCH
56 */
57 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc;
58
59};
40 60
41/** 61/**
42 * @brief Handle to a transport communicator 62 * @brief Handle to a transport communicator
@@ -44,8 +64,19 @@
44struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle 64struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
45{ 65{
46 /** 66 /**
47 * @brief Handle to the configuration 67 * Clients
48 */ 68 */
69 struct MyClient *client_head;
70 struct MyClient *client_tail;
71
72 /**
73 * @brief Handle to the client
74 */
75 struct GNUNET_MQ_Handle *c_mq;
76
77 /**
78 * @brief Handle to the configuration
79 */
49 struct GNUNET_CONFIGURATION_Handle *cfg; 80 struct GNUNET_CONFIGURATION_Handle *cfg;
50 81
51 /** 82 /**
@@ -64,15 +95,6 @@ struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle
64 */ 95 */
65 struct GNUNET_SCHEDULER_Task *ts_shutdown_task; 96 struct GNUNET_SCHEDULER_Task *ts_shutdown_task;
66 97
67 /**
68 * @brief Handle to the client
69 */
70 struct GNUNET_SERVICE_Client *client;
71
72 /**
73 * @brief Handle to the client
74 */
75 struct GNUNET_MQ_Handle *c_mq;
76 98
77 /** 99 /**
78 * @brief Process of the communicator 100 * @brief Process of the communicator
@@ -269,12 +291,18 @@ handle_communicator_available (
269 void *cls, 291 void *cls,
270 const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *msg) 292 const struct GNUNET_TRANSPORT_CommunicatorAvailableMessage *msg)
271{ 293{
272 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; 294 struct MyClient *client = cls;
295 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h =
296 client->tc;
273 uint16_t size; 297 uint16_t size;
298 tc_h->c_mq = client->c_mq;
274 299
275 size = ntohs (msg->header.size) - sizeof(*msg); 300 size = ntohs (msg->header.size) - sizeof(*msg);
276 if (0 == size) 301 if (0 == size)
302 {
303 GNUNET_SERVICE_client_continue (client->client);
277 return; /* receive-only communicator */ 304 return; /* receive-only communicator */
305 }
278 tc_h->c_characteristics = ntohl (msg->cc); 306 tc_h->c_characteristics = ntohl (msg->cc);
279 tc_h->c_addr_prefix = GNUNET_strdup ((const char *) &msg[1]); 307 tc_h->c_addr_prefix = GNUNET_strdup ((const char *) &msg[1]);
280 if (NULL != tc_h->communicator_available_cb) 308 if (NULL != tc_h->communicator_available_cb)
@@ -285,7 +313,9 @@ handle_communicator_available (
285 tc_h->c_characteristics, 313 tc_h->c_characteristics,
286 tc_h->c_addr_prefix); 314 tc_h->c_addr_prefix);
287 } 315 }
288 GNUNET_SERVICE_client_continue (tc_h->client); 316 GNUNET_SERVICE_client_continue (client->client);
317 LOG (GNUNET_ERROR_TYPE_DEBUG, "finished communicator_available_cb()\n");
318
289} 319}
290 320
291 321
@@ -327,7 +357,9 @@ handle_communicator_backchannel (void *cls,
327 GNUNET_TRANSPORT_CommunicatorBackchannel * 357 GNUNET_TRANSPORT_CommunicatorBackchannel *
328 bc_msg) 358 bc_msg)
329{ 359{
330 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; 360 struct MyClient *client = cls;
361 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h =
362 client->tc;
331 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *other_tc_h; 363 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *other_tc_h;
332 struct GNUNET_MessageHeader *msg; 364 struct GNUNET_MessageHeader *msg;
333 msg = (struct GNUNET_MessageHeader *) &bc_msg[1]; 365 msg = (struct GNUNET_MessageHeader *) &bc_msg[1];
@@ -339,7 +371,7 @@ handle_communicator_backchannel (void *cls,
339 371
340 if (tc_h->bc_enabled != GNUNET_YES) 372 if (tc_h->bc_enabled != GNUNET_YES)
341 { 373 {
342 GNUNET_SERVICE_client_continue (tc_h->client); 374 GNUNET_SERVICE_client_continue (client->client);
343 return; 375 return;
344 } 376 }
345 /* Find client providing this communicator */ 377 /* Find client providing this communicator */
@@ -359,7 +391,7 @@ handle_communicator_backchannel (void *cls,
359 391
360 392
361 GNUNET_MQ_send (other_tc_h->c_mq, env); 393 GNUNET_MQ_send (other_tc_h->c_mq, env);
362 GNUNET_SERVICE_client_continue (tc_h->client); 394 GNUNET_SERVICE_client_continue (client->client);
363} 395}
364 396
365 397
@@ -396,7 +428,9 @@ static void
396handle_add_address (void *cls, 428handle_add_address (void *cls,
397 const struct GNUNET_TRANSPORT_AddAddressMessage *msg) 429 const struct GNUNET_TRANSPORT_AddAddressMessage *msg)
398{ 430{
399 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; 431 struct MyClient *client = cls;
432 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h =
433 client->tc;
400 uint16_t size; 434 uint16_t size;
401 size = ntohs (msg->header.size) - sizeof(*msg); 435 size = ntohs (msg->header.size) - sizeof(*msg);
402 if (0 == size) 436 if (0 == size)
@@ -413,7 +447,7 @@ handle_add_address (void *cls,
413 msg->aid, 447 msg->aid,
414 ntohl (msg->nt)); 448 ntohl (msg->nt));
415 } 449 }
416 GNUNET_SERVICE_client_continue (tc_h->client); 450 GNUNET_SERVICE_client_continue (client->client);
417} 451}
418 452
419 453
@@ -452,7 +486,9 @@ static void
452handle_incoming_msg (void *cls, 486handle_incoming_msg (void *cls,
453 const struct GNUNET_TRANSPORT_IncomingMessage *inc_msg) 487 const struct GNUNET_TRANSPORT_IncomingMessage *inc_msg)
454{ 488{
455 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; 489 struct MyClient *client = cls;
490 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h =
491 client->tc;
456 struct GNUNET_MessageHeader *msg; 492 struct GNUNET_MessageHeader *msg;
457 msg = (struct GNUNET_MessageHeader *) &inc_msg[1]; 493 msg = (struct GNUNET_MessageHeader *) &inc_msg[1];
458 size_t payload_len = ntohs (msg->size) - sizeof (struct 494 size_t payload_len = ntohs (msg->size) - sizeof (struct
@@ -485,7 +521,7 @@ handle_incoming_msg (void *cls,
485 GNUNET_MQ_send (tc_h->c_mq, env); 521 GNUNET_MQ_send (tc_h->c_mq, env);
486 } 522 }
487 523
488 GNUNET_SERVICE_client_continue (tc_h->client); 524 GNUNET_SERVICE_client_continue (client->client);
489} 525}
490 526
491 527
@@ -499,13 +535,15 @@ static void
499handle_queue_create_ok (void *cls, 535handle_queue_create_ok (void *cls,
500 const struct GNUNET_TRANSPORT_CreateQueueResponse *msg) 536 const struct GNUNET_TRANSPORT_CreateQueueResponse *msg)
501{ 537{
502 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; 538 struct MyClient *client = cls;
539 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h =
540 client->tc;
503 541
504 if (NULL != tc_h->queue_create_reply_cb) 542 if (NULL != tc_h->queue_create_reply_cb)
505 { 543 {
506 tc_h->queue_create_reply_cb (tc_h->cb_cls, tc_h, GNUNET_YES); 544 tc_h->queue_create_reply_cb (tc_h->cb_cls, tc_h, GNUNET_YES);
507 } 545 }
508 GNUNET_SERVICE_client_continue (tc_h->client); 546 GNUNET_SERVICE_client_continue (client->client);
509} 547}
510 548
511 549
@@ -523,13 +561,15 @@ handle_queue_create_fail (
523 void *cls, 561 void *cls,
524 const struct GNUNET_TRANSPORT_CreateQueueResponse *msg) 562 const struct GNUNET_TRANSPORT_CreateQueueResponse *msg)
525{ 563{
526 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; 564 struct MyClient *client = cls;
565 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h =
566 client->tc;
527 567
528 if (NULL != tc_h->queue_create_reply_cb) 568 if (NULL != tc_h->queue_create_reply_cb)
529 { 569 {
530 tc_h->queue_create_reply_cb (tc_h->cb_cls, tc_h, GNUNET_NO); 570 tc_h->queue_create_reply_cb (tc_h->cb_cls, tc_h, GNUNET_NO);
531 } 571 }
532 GNUNET_SERVICE_client_continue (tc_h->client); 572 GNUNET_SERVICE_client_continue (client->client);
533} 573}
534 574
535 575
@@ -560,7 +600,9 @@ static void
560handle_add_queue_message (void *cls, 600handle_add_queue_message (void *cls,
561 const struct GNUNET_TRANSPORT_AddQueueMessage *msg) 601 const struct GNUNET_TRANSPORT_AddQueueMessage *msg)
562{ 602{
563 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; 603 struct MyClient *client = cls;
604 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h =
605 client->tc;
564 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue; 606 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue;
565 607
566 tc_queue = tc_h->queue_head; 608 tc_queue = tc_h->queue_head;
@@ -589,7 +631,7 @@ handle_add_queue_message (void *cls,
589 { 631 {
590 tc_h->add_queue_cb (tc_h->cb_cls, tc_h, tc_queue); 632 tc_h->add_queue_cb (tc_h->cb_cls, tc_h, tc_queue);
591 } 633 }
592 GNUNET_SERVICE_client_continue (tc_h->client); 634 GNUNET_SERVICE_client_continue (client->client);
593} 635}
594 636
595 637
@@ -622,13 +664,20 @@ connect_cb (void *cls,
622 struct GNUNET_MQ_Handle *mq) 664 struct GNUNET_MQ_Handle *mq)
623{ 665{
624 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; 666 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls;
625 667 struct MyClient *new_c;
626 LOG (GNUNET_ERROR_TYPE_DEBUG, "Client connected.\n"); 668
627 tc_h->client = client; 669 LOG (GNUNET_ERROR_TYPE_DEBUG, "Client %p connected to %p.\n",
628 tc_h->c_mq = mq; 670 client, tc_h);
671 new_c = GNUNET_new (struct MyClient);
672 new_c->client = client;
673 new_c->c_mq = mq;
674 new_c->tc = tc_h;
675 GNUNET_CONTAINER_DLL_insert (tc_h->client_head,
676 tc_h->client_tail,
677 new_c);
629 678
630 if (NULL == tc_h->queue_head) 679 if (NULL == tc_h->queue_head)
631 return tc_h; 680 return new_c;
632 /* Iterate over queues. They are yet to be opened. Request opening. */ 681 /* Iterate over queues. They are yet to be opened. Request opening. */
633 for (struct 682 for (struct
634 GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue_iter = 683 GNUNET_TRANSPORT_TESTING_TransportCommunicatorQueue *tc_queue_iter =
@@ -644,7 +693,7 @@ connect_cb (void *cls,
644 tc_queue_iter->open_queue_env); 693 tc_queue_iter->open_queue_env);
645 tc_queue_iter->open_queue_env = NULL; 694 tc_queue_iter->open_queue_env = NULL;
646 } 695 }
647 return tc_h; 696 return new_c;
648} 697}
649 698
650 699
@@ -660,10 +709,20 @@ disconnect_cb (void *cls,
660 struct GNUNET_SERVICE_Client *client, 709 struct GNUNET_SERVICE_Client *client,
661 void *internal_cls) 710 void *internal_cls)
662{ 711{
712 struct MyClient *cl = cls;
663 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; 713 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls;
664 714
715 for (cl = tc_h->client_head; NULL != cl; cl = cl->next)
716 {
717 if (cl->client != client)
718 continue;
719 GNUNET_CONTAINER_DLL_remove (tc_h->client_head,
720 tc_h->client_tail,
721 cl);
722 GNUNET_free (cl);
723 break;
724 }
665 LOG (GNUNET_ERROR_TYPE_DEBUG, "Client disconnected.\n"); 725 LOG (GNUNET_ERROR_TYPE_DEBUG, "Client disconnected.\n");
666 tc_h->client = NULL;
667} 726}
668 727
669 728
@@ -677,8 +736,8 @@ static void
677handle_send_message_ack (void *cls, 736handle_send_message_ack (void *cls,
678 const struct GNUNET_TRANSPORT_SendMessageToAck *sma) 737 const struct GNUNET_TRANSPORT_SendMessageToAck *sma)
679{ 738{
680 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h = cls; 739 struct MyClient *client = cls;
681 GNUNET_SERVICE_client_continue (tc_h->client); 740 GNUNET_SERVICE_client_continue (client->client);
682 // NOP 741 // NOP
683} 742}
684 743
@@ -886,6 +945,9 @@ GNUNET_TRANSPORT_TESTING_transport_communicator_service_start (
886{ 945{
887 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h; 946 struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle *tc_h;
888 947
948 LOG (GNUNET_ERROR_TYPE_DEBUG,
949 "Starting new transport/communicator combo with config %s\n",
950 cfg_filename);
889 tc_h = 951 tc_h =
890 GNUNET_new (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle); 952 GNUNET_new (struct GNUNET_TRANSPORT_TESTING_TransportCommunicatorHandle);
891 tc_h->cfg_filename = GNUNET_strdup (cfg_filename); 953 tc_h->cfg_filename = GNUNET_strdup (cfg_filename);