aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/include/gnunet_testing_plugin.h3
-rw-r--r--src/testbed/gnunet-cmd.c2
-rw-r--r--src/testbed/gnunet-cmds-helper.c2
-rw-r--r--src/testbed/plugin_testcmd.c3
-rw-r--r--src/testbed/testbed_api_cmd_netjail_start_testbed.c11
-rw-r--r--src/transport/Makefile.am5
-rw-r--r--src/transport/gnunet-communicator-tcp.c15
-rw-r--r--src/transport/plugin_cmd_simple_send.c23
-rw-r--r--src/transport/transport-testing-cmds.h78
-rw-r--r--src/transport/transport-testing2.h37
-rw-r--r--src/transport/transport_api_cmd_connecting_peers.c75
-rw-r--r--src/transport/transport_api_cmd_send_simple.c24
-rw-r--r--src/transport/transport_api_cmd_start_peer.c34
13 files changed, 220 insertions, 92 deletions
diff --git a/src/include/gnunet_testing_plugin.h b/src/include/gnunet_testing_plugin.h
index 8395e2a49..103eb23be 100644
--- a/src/include/gnunet_testing_plugin.h
+++ b/src/include/gnunet_testing_plugin.h
@@ -45,7 +45,8 @@ typedef void
45 write_message, char *router_ip, 45 write_message, char *router_ip,
46 char *node_ip, 46 char *node_ip,
47 char *n, 47 char *n,
48 char *m); 48 char *m,
49 char *local_m);
49 50
50typedef void 51typedef void
51(*GNUNET_TESTING_PLUGIN_ALL_PEERS_STARTED) (); 52(*GNUNET_TESTING_PLUGIN_ALL_PEERS_STARTED) ();
diff --git a/src/testbed/gnunet-cmd.c b/src/testbed/gnunet-cmd.c
index f232bd805..0ba94fdd9 100644
--- a/src/testbed/gnunet-cmd.c
+++ b/src/testbed/gnunet-cmd.c
@@ -90,7 +90,7 @@ run (void *cls)
90 strcat (node_ip, NODE_BASE_IP); 90 strcat (node_ip, NODE_BASE_IP);
91 strcat (node_ip, plugin->n); 91 strcat (node_ip, plugin->n);
92 92
93 plugin->api->start_testcase (NULL, router_ip, node_ip, NULL, NULL); 93 plugin->api->start_testcase (NULL, router_ip, node_ip, NULL, NULL, NULL);
94 94
95} 95}
96 96
diff --git a/src/testbed/gnunet-cmds-helper.c b/src/testbed/gnunet-cmds-helper.c
index c4a3e98d9..7cb753c23 100644
--- a/src/testbed/gnunet-cmds-helper.c
+++ b/src/testbed/gnunet-cmds-helper.c
@@ -428,7 +428,7 @@ tokenizer_cb (void *cls, const struct GNUNET_MessageHeader *message)
428 strcat (node_ip, plugin->n); 428 strcat (node_ip, plugin->n);
429 429
430 plugin->api->start_testcase (&write_message, router_ip, node_ip, plugin->m, 430 plugin->api->start_testcase (&write_message, router_ip, node_ip, plugin->m,
431 plugin->n); 431 plugin->n, plugin->local_m);
432 432
433 LOG (GNUNET_ERROR_TYPE_ERROR, 433 LOG (GNUNET_ERROR_TYPE_ERROR,
434 "We got here!\n"); 434 "We got here!\n");
diff --git a/src/testbed/plugin_testcmd.c b/src/testbed/plugin_testcmd.c
index 797826781..e08ec067d 100644
--- a/src/testbed/plugin_testcmd.c
+++ b/src/testbed/plugin_testcmd.c
@@ -48,7 +48,8 @@ static void
48start_testcase (TESTBED_CMD_HELPER_write_cb write_message, char *router_ip, 48start_testcase (TESTBED_CMD_HELPER_write_cb write_message, char *router_ip,
49 char *node_ip, 49 char *node_ip,
50 char *n, 50 char *n,
51 char *m) 51 char *m,
52 char *local_m)
52{ 53{
53 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get (); 54 struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
54 55
diff --git a/src/testbed/testbed_api_cmd_netjail_start_testbed.c b/src/testbed/testbed_api_cmd_netjail_start_testbed.c
index de3926696..fa0084a0a 100644
--- a/src/testbed/testbed_api_cmd_netjail_start_testbed.c
+++ b/src/testbed/testbed_api_cmd_netjail_start_testbed.c
@@ -373,10 +373,17 @@ start_testbed (struct NetJailState *ns, struct
373 tbc)); 373 tbc));
374 374
375 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 375 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
376 "First using helper %d\n", 376 "First using helper %d %d\n",
377 tbc->count - 1); 377 tbc->count - 1,
378 ns->n_helper);
378 struct GNUNET_HELPER_Handle *helper = ns->helper[tbc->count - 1]; 379 struct GNUNET_HELPER_Handle *helper = ns->helper[tbc->count - 1];
379 380
381 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
382 "First using helper %d %d %p\n",
383 tbc->count - 1,
384 ns->n_helper,
385 helper);
386
380 msg = create_helper_init_msg_ (m_char, 387 msg = create_helper_init_msg_ (m_char,
381 n_char, 388 n_char,
382 ns->plugin_name); 389 ns->plugin_name);
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am
index 2d3615e6a..e19ebd8e9 100644
--- a/src/transport/Makefile.am
+++ b/src/transport/Makefile.am
@@ -171,6 +171,7 @@ libgnunettransporttesting2_la_SOURCES = \
171 transport_api_cmd_start_peer.c \ 171 transport_api_cmd_start_peer.c \
172 transport_api_cmd_send_simple.c \ 172 transport_api_cmd_send_simple.c \
173 transport-testing2.c transport-testing2.h \ 173 transport-testing2.c transport-testing2.h \
174 transport-testing-cmds.h \
174 transport-testing-filenames2.c \ 175 transport-testing-filenames2.c \
175 transport-testing-loggers2.c \ 176 transport-testing-loggers2.c \
176 transport-testing-main2.c \ 177 transport-testing-main2.c \
@@ -409,8 +410,8 @@ libgnunet_plugin_cmd_simple_send_la_LIBADD = \
409 $(top_builddir)/src/testbed/libgnunettestbed.la \ 410 $(top_builddir)/src/testbed/libgnunettestbed.la \
410 libgnunettransporttesting2.la \ 411 libgnunettransporttesting2.la \
411 $(LTLIBINTL) 412 $(LTLIBINTL)
412#libgnunet_plugin_cmd_simple_send_la_LDFLAGS = \ 413libgnunet_plugin_cmd_simple_send_la_LDFLAGS = \
413# $(GN_PLUGIN_LDFLAGS) 414 $(GN_PLUGIN_LDFLAGS)
414 415
415if HAVE_EXPERIMENTAL 416if HAVE_EXPERIMENTAL
416plugin_LTLIBRARIES += libgnunet_plugin_transport_udp.la 417plugin_LTLIBRARIES += libgnunet_plugin_transport_udp.la
diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c
index 1b838bf9c..fde85923b 100644
--- a/src/transport/gnunet-communicator-tcp.c
+++ b/src/transport/gnunet-communicator-tcp.c
@@ -1900,6 +1900,9 @@ queue_read (void *cls)
1900 BUF_SIZE - queue->cread_off); 1900 BUF_SIZE - queue->cread_off);
1901 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1901 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1902 "Received %lu bytes from TCP queue\n", rcvd); 1902 "Received %lu bytes from TCP queue\n", rcvd);
1903 GNUNET_log_from_nocheck (GNUNET_ERROR_TYPE_DEBUG,
1904 "transport",
1905 "Received %lu bytes from TCP queue\n", rcvd);
1903 if (-1 == rcvd) 1906 if (-1 == rcvd)
1904 { 1907 {
1905 if ((EAGAIN != errno) && (EINTR != errno)) 1908 if ((EAGAIN != errno) && (EINTR != errno))
@@ -2675,6 +2678,9 @@ proto_read_kx (void *cls)
2675 sizeof(pq->ibuf) - pq->ibuf_off); 2678 sizeof(pq->ibuf) - pq->ibuf_off);
2676 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2679 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2677 "Received %lu bytes for KX\n", rcvd); 2680 "Received %lu bytes for KX\n", rcvd);
2681 GNUNET_log_from_nocheck (GNUNET_ERROR_TYPE_DEBUG,
2682 "transport",
2683 "Received %lu bytes for KX\n", rcvd);
2678 if (-1 == rcvd) 2684 if (-1 == rcvd)
2679 { 2685 {
2680 if ((EAGAIN != errno) && (EINTR != errno)) 2686 if ((EAGAIN != errno) && (EINTR != errno))
@@ -2824,6 +2830,10 @@ queue_read_kx (void *cls)
2824 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2830 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2825 "Received %lu bytes for KX\n", 2831 "Received %lu bytes for KX\n",
2826 rcvd); 2832 rcvd);
2833 GNUNET_log_from_nocheck (GNUNET_ERROR_TYPE_DEBUG,
2834 "transport",
2835 "Received %lu bytes for KX\n",
2836 rcvd);
2827 if (-1 == rcvd) 2837 if (-1 == rcvd)
2828 { 2838 {
2829 if ((EAGAIN != errno) && (EINTR != errno)) 2839 if ((EAGAIN != errno) && (EINTR != errno))
@@ -2918,6 +2928,9 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address)
2918 2928
2919 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2929 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2920 "Connecting to %s\n", address); 2930 "Connecting to %s\n", address);
2931 GNUNET_log_from_nocheck (GNUNET_ERROR_TYPE_DEBUG,
2932 "transport",
2933 "Connecting to %s\n", address);
2921 if (0 != strncmp (address, 2934 if (0 != strncmp (address,
2922 COMMUNICATOR_ADDRESS_PREFIX "-", 2935 COMMUNICATOR_ADDRESS_PREFIX "-",
2923 strlen (COMMUNICATOR_ADDRESS_PREFIX "-"))) 2936 strlen (COMMUNICATOR_ADDRESS_PREFIX "-")))
@@ -3238,7 +3251,7 @@ init_socket (struct sockaddr *addr,
3238 return GNUNET_SYSERR; 3251 return GNUNET_SYSERR;
3239 } 3252 }
3240 3253
3241 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3254 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
3242 "address %s\n", 3255 "address %s\n",
3243 GNUNET_a2s (addr, in_len)); 3256 GNUNET_a2s (addr, in_len));
3244 3257
diff --git a/src/transport/plugin_cmd_simple_send.c b/src/transport/plugin_cmd_simple_send.c
index 62bb7544b..e2407c8c0 100644
--- a/src/transport/plugin_cmd_simple_send.c
+++ b/src/transport/plugin_cmd_simple_send.c
@@ -30,6 +30,7 @@
30// #include "gnunet_transport_service.h" 30// #include "gnunet_transport_service.h"
31#include "gnunet_testbed_ng_service.h" 31#include "gnunet_testbed_ng_service.h"
32#include "transport-testing2.h" 32#include "transport-testing2.h"
33#include "transport-testing-cmds.h"
33 34
34/** 35/**
35 * Generic logging shortcut 36 * Generic logging shortcut
@@ -85,20 +86,25 @@ static void
85start_testcase (TESTBED_CMD_HELPER_write_cb write_message, char *router_ip, 86start_testcase (TESTBED_CMD_HELPER_write_cb write_message, char *router_ip,
86 char *node_ip, 87 char *node_ip,
87 char *m, 88 char *m,
88 char *n) 89 char *n,
90 char *local_m)
89{ 91{
90 char *testdir; 92 char *testdir;
91 char *cfgname; 93 char *cfgname;
92 94
93 GNUNET_asprintf (&cfgname, 95 GNUNET_asprintf (&cfgname,
94 "%s%s.conf", 96 "%s%s.conf",
95 "test_transport_api2_tcp_peer", 97 "test_transport_api2_tcp_node",
96 n); 98 n);
97 99
98 LOG (GNUNET_ERROR_TYPE_ERROR, 100 LOG (GNUNET_ERROR_TYPE_ERROR,
99 "cfgname: %s\n", 101 "cfgname: %s\n",
100 cfgname); 102 cfgname);
101 103
104 LOG (GNUNET_ERROR_TYPE_ERROR,
105 "node ip: %s\n",
106 node_ip);
107
102 testdir = GNUNET_malloc (strlen (BASE_DIR) + strlen (m) + strlen (n) 108 testdir = GNUNET_malloc (strlen (BASE_DIR) + strlen (m) + strlen (n)
103 + 1); 109 + 1);
104 110
@@ -125,6 +131,7 @@ start_testcase (TESTBED_CMD_HELPER_write_cb write_message, char *router_ip,
125 "system-create-1", 131 "system-create-1",
126 m, 132 m,
127 n, 133 n,
134 local_m,
128 handlers, 135 handlers,
129 cfgname), 136 cfgname),
130 GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready-1", 137 GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready-1",
@@ -134,12 +141,12 @@ start_testcase (TESTBED_CMD_HELPER_write_cb write_message, char *router_ip,
134 GNUNET_TRANSPORT_cmd_connect_peers ("connect-peers-1", 141 GNUNET_TRANSPORT_cmd_connect_peers ("connect-peers-1",
135 "start-peer-1", 142 "start-peer-1",
136 "this is useless"), 143 "this is useless"),
137 /*GNUNET_TESTING_cmd_send_simple ("send-simple-1", 144 GNUNET_TRANSPORT_cmd_send_simple ("send-simple-1",
138 char *m, 145 m,
139 char *n, 146 n,
140 uint32_t num, 147 0,
141 const char *peer1_label, 148 "start-peer-1",
142 const char *peer2_label),*/ 149 "this is useless"),
143 GNUNET_TESTING_cmd_local_test_finished ("local-test-finished-1", 150 GNUNET_TESTING_cmd_local_test_finished ("local-test-finished-1",
144 write_message) 151 write_message)
145 }; 152 };
diff --git a/src/transport/transport-testing-cmds.h b/src/transport/transport-testing-cmds.h
new file mode 100644
index 000000000..4edd334f0
--- /dev/null
+++ b/src/transport/transport-testing-cmds.h
@@ -0,0 +1,78 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2006, 2009, 2015, 2016 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 transport-testing.h
23 * @brief testing lib for transport service
24 * @author Matthias Wachs
25 * @author Christian Grothoff
26 */
27#ifndef TRANSPORT_TESTING_CMDS_H
28#define TRANSPORT_TESTING__CMDS_H
29#include "gnunet_testing_lib.h"
30
31struct GNUNET_TESTING_Command
32GNUNET_TRANSPORT_cmd_start_peer (const char *label,
33 const char *system_label,
34 char *m,
35 char *n,
36 char *local_m,
37 struct GNUNET_MQ_MessageHandler *handlers,
38 const char *cfgname);
39
40struct GNUNET_TESTING_Command
41GNUNET_TRANSPORT_cmd_connect_peers (const char *label,
42 const char *peer1_label,
43 const char *peer2_label);
44
45struct GNUNET_TESTING_Command
46GNUNET_TRANSPORT_cmd_send_simple (const char *label,
47 char *m,
48 char *n,
49 uint32_t num,
50 const char *peer1_label,
51 const char *peer2_label);
52
53int
54GNUNET_TRANSPORT_get_trait_peer_id (const struct
55 GNUNET_TESTING_Command *cmd,
56 struct GNUNET_PeerIdentity **id);
57
58int
59GNUNET_TRANSPORT_get_trait_connected_peers_map (const struct
60 GNUNET_TESTING_Command
61 *cmd,
62 struct
63 GNUNET_CONTAINER_MultiShortmap **
64 connected_peers_map);
65int
66GNUNET_TRANSPORT_get_trait_hello_size (const struct
67 GNUNET_TESTING_Command
68 *cmd,
69 size_t **hello_size);
70
71int
72GNUNET_TRANSPORT_get_trait_hello (const struct
73 GNUNET_TESTING_Command
74 *cmd,
75 char **hello);
76
77#endif
78/* end of transport_testing.h */
diff --git a/src/transport/transport-testing2.h b/src/transport/transport-testing2.h
index a6732e308..e2167ca7e 100644
--- a/src/transport/transport-testing2.h
+++ b/src/transport/transport-testing2.h
@@ -920,42 +920,5 @@ GNUNET_TRANSPORT_TESTING_get_test_plugin_name (const char *executable,
920char * 920char *
921GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file); 921GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file);
922 922
923struct GNUNET_TESTING_Command
924GNUNET_TRANSPORT_cmd_start_peer (const char *label,
925 const char *system_label,
926 char *m,
927 char *n,
928 struct GNUNET_MQ_MessageHandler *handlers,
929 const char *cfgname);
930
931struct GNUNET_TESTING_Command
932GNUNET_TRANSPORT_cmd_connect_peers (const char *label,
933 const char *peer1_label,
934 const char *peer2_label);
935
936int
937GNUNET_TRANSPORT_get_trait_peer_id (const struct
938 GNUNET_TESTING_Command *cmd,
939 struct GNUNET_PeerIdentity **id);
940
941int
942GNUNET_TRANSPORT_get_trait_connected_peers_map (const struct
943 GNUNET_TESTING_Command
944 *cmd,
945 struct
946 GNUNET_CONTAINER_MultiPeerMap **
947 connected_peers_map);
948int
949GNUNET_TRANSPORT_get_trait_hello_size (const struct
950 GNUNET_TESTING_Command
951 *cmd,
952 size_t **hello_size);
953
954int
955GNUNET_TRANSPORT_get_trait_hello (const struct
956 GNUNET_TESTING_Command
957 *cmd,
958 char **hello);
959
960#endif 923#endif
961/* end of transport_testing.h */ 924/* end of transport_testing.h */
diff --git a/src/transport/transport_api_cmd_connecting_peers.c b/src/transport/transport_api_cmd_connecting_peers.c
index d9253b6d4..f4b2e935f 100644
--- a/src/transport/transport_api_cmd_connecting_peers.c
+++ b/src/transport/transport_api_cmd_connecting_peers.c
@@ -29,6 +29,7 @@
29#include "gnunet_transport_application_service.h" 29#include "gnunet_transport_application_service.h"
30#include "gnunet_hello_lib.h" 30#include "gnunet_hello_lib.h"
31#include "gnunet_transport_service.h" 31#include "gnunet_transport_service.h"
32#include "transport-testing-cmds.h"
32 33
33/** 34/**
34 * Generic logging shortcut 35 * Generic logging shortcut
@@ -40,6 +41,8 @@ struct ConnectPeersState
40 const char *peer1_label; 41 const char *peer1_label;
41 42
42 const char *peer2_label; 43 const char *peer2_label;
44
45 struct GNUNET_PeerIdentity *id;
43}; 46};
44 47
45 48
@@ -52,12 +55,13 @@ connect_peers_run (void *cls,
52 const struct GNUNET_TESTING_Command *peer1_cmd; 55 const struct GNUNET_TESTING_Command *peer1_cmd;
53 const struct GNUNET_TESTING_Command *peer2_cmd; 56 const struct GNUNET_TESTING_Command *peer2_cmd;
54 struct GNUNET_TRANSPORT_ApplicationHandle *ah; 57 struct GNUNET_TRANSPORT_ApplicationHandle *ah;
55 struct GNUNET_PeerIdentity *id; 58 struct GNUNET_PeerIdentity *peer = GNUNET_new (struct GNUNET_PeerIdentity);
56 char *addr; 59 char *addr;
57 struct GNUNET_TIME_Absolute t; 60 struct GNUNET_TIME_Absolute t;
58 char *hello; 61 char *hello;
59 size_t *hello_size; 62 size_t *hello_size;
60 enum GNUNET_NetworkType nt = 0; 63 enum GNUNET_NetworkType nt = 0;
64 char *peer_id;
61 65
62 peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer1_label); 66 peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer1_label);
63 GNUNET_TRANSPORT_get_trait_application_handle (peer1_cmd, 67 GNUNET_TRANSPORT_get_trait_application_handle (peer1_cmd,
@@ -70,6 +74,31 @@ connect_peers_run (void *cls,
70 "hello: %s\n", 74 "hello: %s\n",
71 hello); 75 hello);
72 76
77 /*GNUNET_TRANSPORT_get_trait_peer_id (peer1_cmd,
78 &id);
79 LOG (GNUNET_ERROR_TYPE_ERROR,
80 "pid %s\n",
81 GNUNET_i2s_full(id));*/
82
83 if(strstr(hello, "60002") != NULL)
84 {
85 addr = "tcp-192.168.15.2:60003";
86 peer_id = "4TTC9WBSVP9RJT6DVEZ7E0TDW7TQXC11NR1EMR2F8ARS87WZ2730";
87 }
88 else
89 {
90 addr = "tcp-192.168.15.1:60002";
91 peer_id = "F2F3X9G1YNCTXKK7A4J6M4ZM4BBSKC9DEXZVHCWQ475M0C7PNWCG";
92 }
93
94 LOG (GNUNET_ERROR_TYPE_ERROR,
95 "get pub key\n");
96 GNUNET_CRYPTO_eddsa_public_key_from_string (peer_id,
97 strlen (peer_id),
98 &peer->public_key);
99
100 cps->id = peer;
101
73 // TODO This does not work, because the other peer is running in another local loop. We need to message between different local loops. For now we will create the hello manually with the known information about the other local peers. 102 // TODO This does not work, because the other peer is running in another local loop. We need to message between different local loops. For now we will create the hello manually with the known information about the other local peers.
74 // --------------------------------------------- 103 // ---------------------------------------------
75 /*peer2_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer2_label); 104 /*peer2_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer2_label);
@@ -84,14 +113,16 @@ connect_peers_run (void *cls,
84 *hello_size, 113 *hello_size,
85 id, 114 id,
86 &nt, 115 &nt,
87 &t); 116 &t);*/
88 117
89 //---------------------------------------------- 118 //----------------------------------------------
90 119
120 LOG (GNUNET_ERROR_TYPE_ERROR,
121 "application validate\n");
91 GNUNET_TRANSPORT_application_validate (ah, 122 GNUNET_TRANSPORT_application_validate (ah,
92 id, 123 peer,
93 nt, 124 nt,
94 addr);*/ 125 addr);
95} 126}
96 127
97 128
@@ -100,34 +131,38 @@ connect_peers_finish (void *cls,
100 GNUNET_SCHEDULER_TaskCallback cont, 131 GNUNET_SCHEDULER_TaskCallback cont,
101 void *cont_cls) 132 void *cont_cls)
102{ 133{
103 /*struct ConnectPeersState *cps = cls; 134 struct ConnectPeersState *cps = cls;
104 const struct GNUNET_TESTING_Command *peer1_cmd; 135 const struct GNUNET_TESTING_Command *peer1_cmd;
105 const struct GNUNET_TESTING_Command *peer2_cmd; 136 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
106 struct GNUNET_CONTAINER_MultiPeerMap *connected_peers_map;
107 unsigned int ret; 137 unsigned int ret;
108 struct GNUNET_PeerIdentity *id; 138 struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode);
139 struct GNUNET_HashCode hc;
140 int node_number;
109 141
110 peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer1_label); 142 peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer1_label);
111 GNUNET_TRANSPORT_get_trait_peer_id (peer1_cmd, 143 GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd,
112 &id);
113
114 peer2_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer2_label);
115 GNUNET_TRANSPORT_get_trait_connected_peers_map (peer2_cmd,
116 &connected_peers_map); 144 &connected_peers_map);
117 145
118 ret = GNUNET_CONTAINER_multipeermap_contains (connected_peers_map, 146 node_number = 1;
119 id); 147 GNUNET_CRYPTO_hash (&node_number, sizeof(node_number), &hc);
148
149 // TODO we need to store with a key identifying the netns node in the future. For now we have only one connecting node.
150 memcpy (key,
151 &hc,
152 sizeof (*key));
153 ret = GNUNET_CONTAINER_multishortmap_contains (connected_peers_map,
154 key);
120 155
121 if (GNUNET_YES == ret) 156 if (GNUNET_YES == ret)
122 { 157 {
123 cont (cont_cls); 158 cont (cont_cls);
124 }
125
126 return ret;*/
127 cont (cont_cls);
128 LOG (GNUNET_ERROR_TYPE_ERROR, 159 LOG (GNUNET_ERROR_TYPE_ERROR,
129 "connect peer finish\n"); 160 "connect peer finish\n");
130 return GNUNET_OK; 161 }
162
163 return ret;
164 /*cont (cont_cls);
165 return GNUNET_OK;*/
131} 166}
132 167
133 168
diff --git a/src/transport/transport_api_cmd_send_simple.c b/src/transport/transport_api_cmd_send_simple.c
index 4a60f1a12..6e7b89497 100644
--- a/src/transport/transport_api_cmd_send_simple.c
+++ b/src/transport/transport_api_cmd_send_simple.c
@@ -26,7 +26,8 @@
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 "transport-testing.h" 29#include "transport-testing2.h"
30#include "transport-testing-cmds.h"
30 31
31struct SendSimpleState 32struct SendSimpleState
32{ 33{
@@ -70,21 +71,26 @@ send_simple_run (void *cls,
70 struct GNUNET_MQ_Envelope *env; 71 struct GNUNET_MQ_Envelope *env;
71 struct GNUNET_TRANSPORT_TESTING_TestMessage *test; 72 struct GNUNET_TRANSPORT_TESTING_TestMessage *test;
72 struct GNUNET_MQ_Handle *mq; 73 struct GNUNET_MQ_Handle *mq;
73 struct GNUNET_CONTAINER_MultiPeerMap *connected_peers_map; 74 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
74 struct GNUNET_PeerIdentity *id; 75 struct GNUNET_PeerIdentity *id;
75 const struct GNUNET_TESTING_Command *peer1_cmd; 76 const struct GNUNET_TESTING_Command *peer1_cmd;
76 const struct GNUNET_TESTING_Command *peer2_cmd; 77 const struct GNUNET_TESTING_Command *peer2_cmd;
78 struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode);
79 struct GNUNET_HashCode hc;
80 int node_number;
77 81
78 peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (sss->peer1_label); 82 peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (sss->peer1_label);
79 GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd, 83 GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd,
80 &connected_peers_map); 84 &connected_peers_map);
81 85
82 peer2_cmd = GNUNET_TESTING_interpreter_lookup_command (sss->peer2_label); 86 node_number = 1;
83 GNUNET_TRANSPORT_get_trait_peer_id (peer2_cmd, 87 GNUNET_CRYPTO_hash (&node_number, sizeof(node_number), &hc);
84 &id); 88 memcpy (key,
85 89 &hc,
86 mq = GNUNET_CONTAINER_multipeermap_get (connected_peers_map, 90 sizeof (*key));
87 id); 91
92 mq = GNUNET_CONTAINER_multishortmap_get (connected_peers_map,
93 key);
88 94
89 env = GNUNET_MQ_msg_extra (test, 95 env = GNUNET_MQ_msg_extra (test,
90 2600 - sizeof(*test), 96 2600 - sizeof(*test),
@@ -110,7 +116,7 @@ send_simple_run (void *cls,
110 * @return command. 116 * @return command.
111 */ 117 */
112struct GNUNET_TESTING_Command 118struct GNUNET_TESTING_Command
113GNUNET_TESTING_cmd_send_simple (const char *label, 119GNUNET_TRANSPORT_cmd_send_simple (const char *label,
114 char *m, 120 char *m,
115 char *n, 121 char *n,
116 uint32_t num, 122 uint32_t num,
diff --git a/src/transport/transport_api_cmd_start_peer.c b/src/transport/transport_api_cmd_start_peer.c
index c2cc20a2a..b2b26194a 100644
--- a/src/transport/transport_api_cmd_start_peer.c
+++ b/src/transport/transport_api_cmd_start_peer.c
@@ -95,6 +95,8 @@ struct StartPeerState
95 95
96 char *n; 96 char *n;
97 97
98 char *local_m;
99
98 unsigned int finished; 100 unsigned int finished;
99 101
100 const char *system_label; 102 const char *system_label;
@@ -104,7 +106,7 @@ struct StartPeerState
104 */ 106 */
105 unsigned int no; 107 unsigned int no;
106 108
107 struct GNUNET_CONTAINER_MultiPeerMap *connected_peers_map; 109 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
108 110
109 struct GNUNET_TESTING_System *tl_system; 111 struct GNUNET_TESTING_System *tl_system;
110 112
@@ -190,7 +192,9 @@ notify_connect (void *cls,
190 struct GNUNET_MQ_Handle *mq) 192 struct GNUNET_MQ_Handle *mq)
191{ 193{
192 struct StartPeerState *sps = cls; 194 struct StartPeerState *sps = cls;
193 195 struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode);
196 struct GNUNET_HashCode hc;
197 int node_number;
194 198
195 void *ret; 199 void *ret;
196 200
@@ -201,8 +205,16 @@ notify_connect (void *cls,
201 sps->no, 205 sps->no,
202 GNUNET_i2s (&sps->id)); 206 GNUNET_i2s (&sps->id));
203 207
204 GNUNET_CONTAINER_multipeermap_put (sps->connected_peers_map, 208 // TODO we need to store with a key identifying the netns node in the future. For now we have only one connecting node.
205 peer, 209 node_number = 1;
210 GNUNET_CRYPTO_hash (&node_number, sizeof(node_number), &hc);
211
212
213 memcpy (key,
214 &hc,
215 sizeof (*key));
216 GNUNET_CONTAINER_multishortmap_put (sps->connected_peers_map,
217 key,
206 mq, 218 mq,
207 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 219 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
208 220
@@ -428,7 +440,7 @@ start_peer_traits (void *cls,
428 struct StartPeerState *sps = cls; 440 struct StartPeerState *sps = cls;
429 struct GNUNET_TRANSPORT_ApplicationHandle *ah = sps->ah; 441 struct GNUNET_TRANSPORT_ApplicationHandle *ah = sps->ah;
430 struct GNUNET_PeerIdentity *id = &sps->id; 442 struct GNUNET_PeerIdentity *id = &sps->id;
431 struct GNUNET_CONTAINER_MultiPeerMap *connected_peers_map = 443 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map =
432 sps->connected_peers_map; 444 sps->connected_peers_map;
433 char *hello = sps->hello; 445 char *hello = sps->hello;
434 size_t hello_size = sps->hello_size; 446 size_t hello_size = sps->hello_size;
@@ -498,7 +510,7 @@ GNUNET_TRANSPORT_get_trait_connected_peers_map (const struct
498 GNUNET_TESTING_Command 510 GNUNET_TESTING_Command
499 *cmd, 511 *cmd,
500 struct 512 struct
501 GNUNET_CONTAINER_MultiPeerMap ** 513 GNUNET_CONTAINER_MultiShortmap **
502 connected_peers_map) 514 connected_peers_map)
503{ 515{
504 return cmd->traits (cmd->cls, 516 return cmd->traits (cmd->cls,
@@ -545,20 +557,24 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label,
545 const char *system_label, 557 const char *system_label,
546 char *m, 558 char *m,
547 char *n, 559 char *n,
560 char *local_m,
548 struct GNUNET_MQ_MessageHandler *handlers, 561 struct GNUNET_MQ_MessageHandler *handlers,
549 const char *cfgname) 562 const char *cfgname)
550{ 563{
551 struct StartPeerState *sps; 564 struct StartPeerState *sps;
552 struct GNUNET_CONTAINER_MultiPeerMap *connected_peers_map = 565 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map =
553 GNUNET_CONTAINER_multipeermap_create (1,GNUNET_NO); 566 GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO);
554 unsigned int i; 567 unsigned int i;
555 568
556 LOG (GNUNET_ERROR_TYPE_ERROR, 569 LOG (GNUNET_ERROR_TYPE_ERROR,
557 "start peer 0.1\n"); 570 "start peer 0.1 with cfg: %s\n",
571 cfgname);
558 572
559 sps = GNUNET_new (struct StartPeerState); 573 sps = GNUNET_new (struct StartPeerState);
560 sps->m = m; 574 sps->m = m;
561 sps->n = n; 575 sps->n = n;
576 sps->local_m = local_m;
577 sps->no = (atoi (n) - 1) * atoi (sps->local_m) + atoi (m);
562 sps->system_label = system_label; 578 sps->system_label = system_label;
563 sps->connected_peers_map = connected_peers_map; 579 sps->connected_peers_map = connected_peers_map;
564 sps->cfgname = cfgname; 580 sps->cfgname = cfgname;