summaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authort3sserakt <t3ss@posteo.de>2021-07-30 14:47:59 +0200
committert3sserakt <t3ss@posteo.de>2021-07-30 14:47:59 +0200
commit4748af6e8e04347ceaeec09ccdfc04d740fa65f0 (patch)
tree1d0feeab3254c58b175e1376f72e7e2b92ec222d /src/transport
parent1a542d67de29d6ed40706ca70988f79bfd00fb38 (diff)
- there are two helper running, but only one is doing the work of both. Therefore connecting peers does not work atm.
Diffstat (limited to 'src/transport')
-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
8 files changed, 205 insertions, 86 deletions
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 = \
transport_api_cmd_start_peer.c \
transport_api_cmd_send_simple.c \
transport-testing2.c transport-testing2.h \
+ transport-testing-cmds.h \
transport-testing-filenames2.c \
transport-testing-loggers2.c \
transport-testing-main2.c \
@@ -409,8 +410,8 @@ libgnunet_plugin_cmd_simple_send_la_LIBADD = \
$(top_builddir)/src/testbed/libgnunettestbed.la \
libgnunettransporttesting2.la \
$(LTLIBINTL)
-#libgnunet_plugin_cmd_simple_send_la_LDFLAGS = \
-# $(GN_PLUGIN_LDFLAGS)
+libgnunet_plugin_cmd_simple_send_la_LDFLAGS = \
+ $(GN_PLUGIN_LDFLAGS)
if HAVE_EXPERIMENTAL
plugin_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)
BUF_SIZE - queue->cread_off);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received %lu bytes from TCP queue\n", rcvd);
+ GNUNET_log_from_nocheck (GNUNET_ERROR_TYPE_DEBUG,
+ "transport",
+ "Received %lu bytes from TCP queue\n", rcvd);
if (-1 == rcvd)
{
if ((EAGAIN != errno) && (EINTR != errno))
@@ -2675,6 +2678,9 @@ proto_read_kx (void *cls)
sizeof(pq->ibuf) - pq->ibuf_off);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received %lu bytes for KX\n", rcvd);
+ GNUNET_log_from_nocheck (GNUNET_ERROR_TYPE_DEBUG,
+ "transport",
+ "Received %lu bytes for KX\n", rcvd);
if (-1 == rcvd)
{
if ((EAGAIN != errno) && (EINTR != errno))
@@ -2824,6 +2830,10 @@ queue_read_kx (void *cls)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received %lu bytes for KX\n",
rcvd);
+ GNUNET_log_from_nocheck (GNUNET_ERROR_TYPE_DEBUG,
+ "transport",
+ "Received %lu bytes for KX\n",
+ rcvd);
if (-1 == rcvd)
{
if ((EAGAIN != errno) && (EINTR != errno))
@@ -2918,6 +2928,9 @@ mq_init (void *cls, const struct GNUNET_PeerIdentity *peer, const char *address)
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Connecting to %s\n", address);
+ GNUNET_log_from_nocheck (GNUNET_ERROR_TYPE_DEBUG,
+ "transport",
+ "Connecting to %s\n", address);
if (0 != strncmp (address,
COMMUNICATOR_ADDRESS_PREFIX "-",
strlen (COMMUNICATOR_ADDRESS_PREFIX "-")))
@@ -3238,7 +3251,7 @@ init_socket (struct sockaddr *addr,
return GNUNET_SYSERR;
}
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"address %s\n",
GNUNET_a2s (addr, in_len));
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 @@
// #include "gnunet_transport_service.h"
#include "gnunet_testbed_ng_service.h"
#include "transport-testing2.h"
+#include "transport-testing-cmds.h"
/**
* Generic logging shortcut
@@ -85,20 +86,25 @@ static void
start_testcase (TESTBED_CMD_HELPER_write_cb write_message, char *router_ip,
char *node_ip,
char *m,
- char *n)
+ char *n,
+ char *local_m)
{
char *testdir;
char *cfgname;
GNUNET_asprintf (&cfgname,
"%s%s.conf",
- "test_transport_api2_tcp_peer",
+ "test_transport_api2_tcp_node",
n);
LOG (GNUNET_ERROR_TYPE_ERROR,
"cfgname: %s\n",
cfgname);
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "node ip: %s\n",
+ node_ip);
+
testdir = GNUNET_malloc (strlen (BASE_DIR) + strlen (m) + strlen (n)
+ 1);
@@ -125,6 +131,7 @@ start_testcase (TESTBED_CMD_HELPER_write_cb write_message, char *router_ip,
"system-create-1",
m,
n,
+ local_m,
handlers,
cfgname),
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,
GNUNET_TRANSPORT_cmd_connect_peers ("connect-peers-1",
"start-peer-1",
"this is useless"),
- /*GNUNET_TESTING_cmd_send_simple ("send-simple-1",
- char *m,
- char *n,
- uint32_t num,
- const char *peer1_label,
- const char *peer2_label),*/
+ GNUNET_TRANSPORT_cmd_send_simple ("send-simple-1",
+ m,
+ n,
+ 0,
+ "start-peer-1",
+ "this is useless"),
GNUNET_TESTING_cmd_local_test_finished ("local-test-finished-1",
write_message)
};
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 @@
+/*
+ This file is part of GNUnet.
+ Copyright (C) 2006, 2009, 2015, 2016 GNUnet e.V.
+
+ GNUnet is free software: you can redistribute it and/or modify it
+ under the terms of the GNU Affero General Public License as published
+ by the Free Software Foundation, either version 3 of the License,
+ or (at your option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ SPDX-License-Identifier: AGPL3.0-or-later
+ */
+
+/**
+ * @file transport-testing.h
+ * @brief testing lib for transport service
+ * @author Matthias Wachs
+ * @author Christian Grothoff
+ */
+#ifndef TRANSPORT_TESTING_CMDS_H
+#define TRANSPORT_TESTING__CMDS_H
+#include "gnunet_testing_lib.h"
+
+struct GNUNET_TESTING_Command
+GNUNET_TRANSPORT_cmd_start_peer (const char *label,
+ const char *system_label,
+ char *m,
+ char *n,
+ char *local_m,
+ struct GNUNET_MQ_MessageHandler *handlers,
+ const char *cfgname);
+
+struct GNUNET_TESTING_Command
+GNUNET_TRANSPORT_cmd_connect_peers (const char *label,
+ const char *peer1_label,
+ const char *peer2_label);
+
+struct GNUNET_TESTING_Command
+GNUNET_TRANSPORT_cmd_send_simple (const char *label,
+ char *m,
+ char *n,
+ uint32_t num,
+ const char *peer1_label,
+ const char *peer2_label);
+
+int
+GNUNET_TRANSPORT_get_trait_peer_id (const struct
+ GNUNET_TESTING_Command *cmd,
+ struct GNUNET_PeerIdentity **id);
+
+int
+GNUNET_TRANSPORT_get_trait_connected_peers_map (const struct
+ GNUNET_TESTING_Command
+ *cmd,
+ struct
+ GNUNET_CONTAINER_MultiShortmap **
+ connected_peers_map);
+int
+GNUNET_TRANSPORT_get_trait_hello_size (const struct
+ GNUNET_TESTING_Command
+ *cmd,
+ size_t **hello_size);
+
+int
+GNUNET_TRANSPORT_get_trait_hello (const struct
+ GNUNET_TESTING_Command
+ *cmd,
+ char **hello);
+
+#endif
+/* 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,
char *
GNUNET_TRANSPORT_TESTING_get_test_source_name (const char *file);
-struct GNUNET_TESTING_Command
-GNUNET_TRANSPORT_cmd_start_peer (const char *label,
- const char *system_label,
- char *m,
- char *n,
- struct GNUNET_MQ_MessageHandler *handlers,
- const char *cfgname);
-
-struct GNUNET_TESTING_Command
-GNUNET_TRANSPORT_cmd_connect_peers (const char *label,
- const char *peer1_label,
- const char *peer2_label);
-
-int
-GNUNET_TRANSPORT_get_trait_peer_id (const struct
- GNUNET_TESTING_Command *cmd,
- struct GNUNET_PeerIdentity **id);
-
-int
-GNUNET_TRANSPORT_get_trait_connected_peers_map (const struct
- GNUNET_TESTING_Command
- *cmd,
- struct
- GNUNET_CONTAINER_MultiPeerMap **
- connected_peers_map);
-int
-GNUNET_TRANSPORT_get_trait_hello_size (const struct
- GNUNET_TESTING_Command
- *cmd,
- size_t **hello_size);
-
-int
-GNUNET_TRANSPORT_get_trait_hello (const struct
- GNUNET_TESTING_Command
- *cmd,
- char **hello);
-
#endif
/* 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 @@
#include "gnunet_transport_application_service.h"
#include "gnunet_hello_lib.h"
#include "gnunet_transport_service.h"
+#include "transport-testing-cmds.h"
/**
* Generic logging shortcut
@@ -40,6 +41,8 @@ struct ConnectPeersState
const char *peer1_label;
const char *peer2_label;
+
+ struct GNUNET_PeerIdentity *id;
};
@@ -52,12 +55,13 @@ connect_peers_run (void *cls,
const struct GNUNET_TESTING_Command *peer1_cmd;
const struct GNUNET_TESTING_Command *peer2_cmd;
struct GNUNET_TRANSPORT_ApplicationHandle *ah;
- struct GNUNET_PeerIdentity *id;
+ struct GNUNET_PeerIdentity *peer = GNUNET_new (struct GNUNET_PeerIdentity);
char *addr;
struct GNUNET_TIME_Absolute t;
char *hello;
size_t *hello_size;
enum GNUNET_NetworkType nt = 0;
+ char *peer_id;
peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer1_label);
GNUNET_TRANSPORT_get_trait_application_handle (peer1_cmd,
@@ -70,6 +74,31 @@ connect_peers_run (void *cls,
"hello: %s\n",
hello);
+ /*GNUNET_TRANSPORT_get_trait_peer_id (peer1_cmd,
+ &id);
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "pid %s\n",
+ GNUNET_i2s_full(id));*/
+
+ if(strstr(hello, "60002") != NULL)
+ {
+ addr = "tcp-192.168.15.2:60003";
+ peer_id = "4TTC9WBSVP9RJT6DVEZ7E0TDW7TQXC11NR1EMR2F8ARS87WZ2730";
+ }
+ else
+ {
+ addr = "tcp-192.168.15.1:60002";
+ peer_id = "F2F3X9G1YNCTXKK7A4J6M4ZM4BBSKC9DEXZVHCWQ475M0C7PNWCG";
+ }
+
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "get pub key\n");
+ GNUNET_CRYPTO_eddsa_public_key_from_string (peer_id,
+ strlen (peer_id),
+ &peer->public_key);
+
+ cps->id = peer;
+
// 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.
// ---------------------------------------------
/*peer2_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer2_label);
@@ -84,14 +113,16 @@ connect_peers_run (void *cls,
*hello_size,
id,
&nt,
- &t);
+ &t);*/
//----------------------------------------------
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "application validate\n");
GNUNET_TRANSPORT_application_validate (ah,
- id,
+ peer,
nt,
- addr);*/
+ addr);
}
@@ -100,34 +131,38 @@ connect_peers_finish (void *cls,
GNUNET_SCHEDULER_TaskCallback cont,
void *cont_cls)
{
- /*struct ConnectPeersState *cps = cls;
+ struct ConnectPeersState *cps = cls;
const struct GNUNET_TESTING_Command *peer1_cmd;
- const struct GNUNET_TESTING_Command *peer2_cmd;
- struct GNUNET_CONTAINER_MultiPeerMap *connected_peers_map;
+ struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
unsigned int ret;
- struct GNUNET_PeerIdentity *id;
+ struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode);
+ struct GNUNET_HashCode hc;
+ int node_number;
peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer1_label);
- GNUNET_TRANSPORT_get_trait_peer_id (peer1_cmd,
- &id);
-
- peer2_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer2_label);
- GNUNET_TRANSPORT_get_trait_connected_peers_map (peer2_cmd,
+ GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd,
&connected_peers_map);
- ret = GNUNET_CONTAINER_multipeermap_contains (connected_peers_map,
- id);
+ node_number = 1;
+ GNUNET_CRYPTO_hash (&node_number, sizeof(node_number), &hc);
+
+ // TODO we need to store with a key identifying the netns node in the future. For now we have only one connecting node.
+ memcpy (key,
+ &hc,
+ sizeof (*key));
+ ret = GNUNET_CONTAINER_multishortmap_contains (connected_peers_map,
+ key);
if (GNUNET_YES == ret)
{
cont (cont_cls);
- }
-
- return ret;*/
- cont (cont_cls);
LOG (GNUNET_ERROR_TYPE_ERROR,
"connect peer finish\n");
- return GNUNET_OK;
+ }
+
+ return ret;
+ /*cont (cont_cls);
+ return GNUNET_OK;*/
}
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 @@
#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testing_ng_lib.h"
-#include "transport-testing.h"
+#include "transport-testing2.h"
+#include "transport-testing-cmds.h"
struct SendSimpleState
{
@@ -70,21 +71,26 @@ send_simple_run (void *cls,
struct GNUNET_MQ_Envelope *env;
struct GNUNET_TRANSPORT_TESTING_TestMessage *test;
struct GNUNET_MQ_Handle *mq;
- struct GNUNET_CONTAINER_MultiPeerMap *connected_peers_map;
+ struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
struct GNUNET_PeerIdentity *id;
const struct GNUNET_TESTING_Command *peer1_cmd;
const struct GNUNET_TESTING_Command *peer2_cmd;
+ struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode);
+ struct GNUNET_HashCode hc;
+ int node_number;
peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (sss->peer1_label);
GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd,
&connected_peers_map);
- peer2_cmd = GNUNET_TESTING_interpreter_lookup_command (sss->peer2_label);
- GNUNET_TRANSPORT_get_trait_peer_id (peer2_cmd,
- &id);
-
- mq = GNUNET_CONTAINER_multipeermap_get (connected_peers_map,
- id);
+ node_number = 1;
+ GNUNET_CRYPTO_hash (&node_number, sizeof(node_number), &hc);
+ memcpy (key,
+ &hc,
+ sizeof (*key));
+
+ mq = GNUNET_CONTAINER_multishortmap_get (connected_peers_map,
+ key);
env = GNUNET_MQ_msg_extra (test,
2600 - sizeof(*test),
@@ -110,7 +116,7 @@ send_simple_run (void *cls,
* @return command.
*/
struct GNUNET_TESTING_Command
-GNUNET_TESTING_cmd_send_simple (const char *label,
+GNUNET_TRANSPORT_cmd_send_simple (const char *label,
char *m,
char *n,
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
char *n;
+ char *local_m;
+
unsigned int finished;
const char *system_label;
@@ -104,7 +106,7 @@ struct StartPeerState
*/
unsigned int no;
- struct GNUNET_CONTAINER_MultiPeerMap *connected_peers_map;
+ struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
struct GNUNET_TESTING_System *tl_system;
@@ -190,7 +192,9 @@ notify_connect (void *cls,
struct GNUNET_MQ_Handle *mq)
{
struct StartPeerState *sps = cls;
-
+ struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode);
+ struct GNUNET_HashCode hc;
+ int node_number;
void *ret;
@@ -201,8 +205,16 @@ notify_connect (void *cls,
sps->no,
GNUNET_i2s (&sps->id));
- GNUNET_CONTAINER_multipeermap_put (sps->connected_peers_map,
- peer,
+ // TODO we need to store with a key identifying the netns node in the future. For now we have only one connecting node.
+ node_number = 1;
+ GNUNET_CRYPTO_hash (&node_number, sizeof(node_number), &hc);
+
+
+ memcpy (key,
+ &hc,
+ sizeof (*key));
+ GNUNET_CONTAINER_multishortmap_put (sps->connected_peers_map,
+ key,
mq,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
@@ -428,7 +440,7 @@ start_peer_traits (void *cls,
struct StartPeerState *sps = cls;
struct GNUNET_TRANSPORT_ApplicationHandle *ah = sps->ah;
struct GNUNET_PeerIdentity *id = &sps->id;
- struct GNUNET_CONTAINER_MultiPeerMap *connected_peers_map =
+ struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map =
sps->connected_peers_map;
char *hello = sps->hello;
size_t hello_size = sps->hello_size;
@@ -498,7 +510,7 @@ GNUNET_TRANSPORT_get_trait_connected_peers_map (const struct
GNUNET_TESTING_Command
*cmd,
struct
- GNUNET_CONTAINER_MultiPeerMap **
+ GNUNET_CONTAINER_MultiShortmap **
connected_peers_map)
{
return cmd->traits (cmd->cls,
@@ -545,20 +557,24 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label,
const char *system_label,
char *m,
char *n,
+ char *local_m,
struct GNUNET_MQ_MessageHandler *handlers,
const char *cfgname)
{
struct StartPeerState *sps;
- struct GNUNET_CONTAINER_MultiPeerMap *connected_peers_map =
- GNUNET_CONTAINER_multipeermap_create (1,GNUNET_NO);
+ struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map =
+ GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO);
unsigned int i;
LOG (GNUNET_ERROR_TYPE_ERROR,
- "start peer 0.1\n");
+ "start peer 0.1 with cfg: %s\n",
+ cfgname);
sps = GNUNET_new (struct StartPeerState);
sps->m = m;
sps->n = n;
+ sps->local_m = local_m;
+ sps->no = (atoi (n) - 1) * atoi (sps->local_m) + atoi (m);
sps->system_label = system_label;
sps->connected_peers_map = connected_peers_map;
sps->cfgname = cfgname;