summaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authort3sserakt <t3ss@posteo.de>2021-07-23 22:17:29 +0200
committert3sserakt <t3ss@posteo.de>2021-07-23 22:17:29 +0200
commit63a7eb6a3a94d43368b348c0a677bc77653cbe51 (patch)
tree2d9608a54ab9b13afb080335e092ad452e54fdc5 /src/transport
parent6140d64e1c55e76de3ff520143b10290fa1ba197 (diff)
- smaller bug fixes
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/Makefile.am28
-rw-r--r--src/transport/plugin_cmd_simple_send.c74
-rw-r--r--src/transport/test_transport_api_cmd_simple_send.c8
-rw-r--r--src/transport/transport-testing2.h37
-rw-r--r--src/transport/transport_api_cmd_connecting_peers.c14
-rw-r--r--src/transport/transport_api_cmd_send_simple.c8
-rw-r--r--src/transport/transport_api_cmd_start_peer.c34
7 files changed, 146 insertions, 57 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am
index 255a7973f..b59bfd0d4 100644
--- a/src/transport/Makefile.am
+++ b/src/transport/Makefile.am
@@ -397,20 +397,20 @@ plugin_LTLIBRARIES = \
$(HTTP_SERVER_PLUGIN_LA) \
$(HTTPS_SERVER_PLUGIN_LA) \
$(WLAN_PLUGIN_LA) \
- $(BT_PLUGIN_LA)
-# libgnunet_plugin_cmd_simple_send.la
-
-# libgnunet_plugin_cmd_simple_send_la_SOURCES = \
-# plugin_cmd_simple_send.c
-# libgnunet_plugin_cmd_simple_send_la_LIBADD = \
-# $(top_builddir)/src/util/libgnunetutil.la \
-# $(top_builddir)/src/testing/libgnunettesting.la \
-# $(top_builddir)/src/statistics/libgnunetstatistics.la \
-# $(top_builddir)/src/testbed/libgnunettestbed.la \
-# libgnunettransport.la \
-# $(LTLIBINTL)
-# libgnunet_plugin_cmd_simple_send_la_LDFLAGS = \
-# $(GN_PLUGIN_LDFLAGS)
+ $(BT_PLUGIN_LA) \
+ libgnunet_plugin_cmd_simple_send.la
+
+libgnunet_plugin_cmd_simple_send_la_SOURCES = \
+ plugin_cmd_simple_send.c
+libgnunet_plugin_cmd_simple_send_la_LIBADD = \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/testing/libgnunettesting.la \
+ $(top_builddir)/src/statistics/libgnunetstatistics.la \
+ $(top_builddir)/src/testbed/libgnunettestbed.la \
+ libgnunettransporttesting2.la \
+ $(LTLIBINTL)
+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/plugin_cmd_simple_send.c b/src/transport/plugin_cmd_simple_send.c
index 1fa2f1f03..62bb7544b 100644
--- a/src/transport/plugin_cmd_simple_send.c
+++ b/src/transport/plugin_cmd_simple_send.c
@@ -19,7 +19,7 @@
*/
/**
- * @file testbed/plugin_testcmd.c
+ * @file testbed/plugin_cmd_simple_send.c
* @brief a plugin to provide the API for running test cases.
* @author t3sserakt
*/
@@ -27,8 +27,10 @@
#include "gnunet_testing_ng_lib.h"
#include "gnunet_util_lib.h"
#include "gnunet_transport_application_service.h"
-#include "gnunet_transport_service.h"
+// #include "gnunet_transport_service.h"
#include "gnunet_testbed_ng_service.h"
+#include "transport-testing2.h"
+
/**
* Generic logging shortcut
*/
@@ -38,10 +40,38 @@
struct GNUNET_MQ_MessageHandler *handlers;
-const char *cfgname;
-
unsigned int are_all_peers_started;
+static int
+check_test (void *cls,
+ const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
+{
+ return GNUNET_OK;
+}
+
+static void
+handle_test (void *cls,
+ const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
+{
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "message received\n");
+}
+
+static int
+check_test2 (void *cls,
+ const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
+{
+ return GNUNET_OK;
+}
+
+static void
+handle_test2 (void *cls,
+ const struct GNUNET_TRANSPORT_TESTING_TestMessage *message)
+{
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "message received\n");
+}
+
static void
all_peers_started ()
{
@@ -58,6 +88,16 @@ start_testcase (TESTBED_CMD_HELPER_write_cb write_message, char *router_ip,
char *n)
{
char *testdir;
+ char *cfgname;
+
+ GNUNET_asprintf (&cfgname,
+ "%s%s.conf",
+ "test_transport_api2_tcp_peer",
+ n);
+
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "cfgname: %s\n",
+ cfgname);
testdir = GNUNET_malloc (strlen (BASE_DIR) + strlen (m) + strlen (n)
+ 1);
@@ -66,22 +106,34 @@ start_testcase (TESTBED_CMD_HELPER_write_cb write_message, char *router_ip,
strcat (testdir, m);
strcat (testdir, n);
+ struct GNUNET_MQ_MessageHandler handlers[] = {
+ GNUNET_MQ_hd_var_size (test,
+ GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE,
+ struct GNUNET_TRANSPORT_TESTING_TestMessage,
+ NULL),
+ GNUNET_MQ_hd_var_size (test2,
+ GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE2,
+ struct GNUNET_TRANSPORT_TESTING_TestMessage,
+ NULL),
+ GNUNET_MQ_handler_end ()
+ };
+
struct GNUNET_TESTING_Command commands[] = {
GNUNET_TESTING_cmd_system_create ("system-create-1",
testdir),
- /*GNUNET_TRANSPORT_cmd_start_peer ("start-peer-1",
+ GNUNET_TRANSPORT_cmd_start_peer ("start-peer-1",
"system-create-1",
m,
n,
handlers,
- cfgname),*/
+ cfgname),
GNUNET_TESTING_cmd_send_peer_ready ("send-peer-ready-1",
write_message),
GNUNET_TESTING_cmd_block_until_all_peers_started ("block-1",
&are_all_peers_started),
- /*GNUNET_TRANSPORT_cmd_connect_peers ("connect-peers-1",
+ GNUNET_TRANSPORT_cmd_connect_peers ("connect-peers-1",
"start-peer-1",
- "this is useless"),*/
+ "this is useless"),
/*GNUNET_TESTING_cmd_send_simple ("send-simple-1",
char *m,
char *n,
@@ -106,7 +158,7 @@ start_testcase (TESTBED_CMD_HELPER_write_cb write_message, char *router_ip,
* @return the exported block API
*/
void *
-libgnunet_plugin_testcmd_init (void *cls)
+libgnunet_plugin_cmd_simple_send_init (void *cls)
{
struct GNUNET_TESTING_PluginFunctions *api;
@@ -124,7 +176,7 @@ libgnunet_plugin_testcmd_init (void *cls)
* @return NULL
*/
void *
-libgnunet_plugin_testcmd_done (void *cls)
+libgnunet_plugin_cmd_simple_send_done (void *cls)
{
struct GNUNET_TESTING_PluginFunctions *api = cls;
@@ -133,4 +185,4 @@ libgnunet_plugin_testcmd_done (void *cls)
}
-/* end of plugin_testcmd.c */
+/* end of plugin_cmd_simple_send.c */
diff --git a/src/transport/test_transport_api_cmd_simple_send.c b/src/transport/test_transport_api_cmd_simple_send.c
index 36c7d23b2..9ae8fcc2b 100644
--- a/src/transport/test_transport_api_cmd_simple_send.c
+++ b/src/transport/test_transport_api_cmd_simple_send.c
@@ -41,18 +41,18 @@ run (void *cls)
struct GNUNET_TESTING_Command commands[] = {
GNUNET_TESTBED_cmd_netjail_start ("netjail-start-1",
"2",
- "2"),
+ "1"),
GNUNET_TESTBED_cmd_netjail_start_testbed ("netjail-start-testbed-1",
"2",
- "2",
+ "1",
"libgnunet_plugin_cmd_simple_send"),
GNUNET_TESTBED_cmd_stop_testbed ("stop-testbed",
"netjail-start-testbed-1",
"2",
- "2"),
+ "1"),
GNUNET_TESTBED_cmd_netjail_stop ("netjail-stop-1",
"2",
- "2"),
+ "1"),
GNUNET_TESTING_cmd_end ()
};
diff --git a/src/transport/transport-testing2.h b/src/transport/transport-testing2.h
index e2167ca7e..a6732e308 100644
--- a/src/transport/transport-testing2.h
+++ b/src/transport/transport-testing2.h
@@ -920,5 +920,42 @@ 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 06e2b8d61..0f2154c46 100644
--- a/src/transport/transport_api_cmd_connecting_peers.c
+++ b/src/transport/transport_api_cmd_connecting_peers.c
@@ -63,8 +63,8 @@ connect_peers_run (void *cls,
GNUNET_TRANSPORT_get_trait_application_handle (peer1_cmd,
&ah);
- GNUNET_TESTING_get_trait_hello (peer1_cmd,
- &hello);
+ GNUNET_TRANSPORT_get_trait_hello (peer1_cmd,
+ &hello);
LOG (GNUNET_ERROR_TYPE_ERROR,
"hello: %s\n",
@@ -73,11 +73,11 @@ connect_peers_run (void *cls,
// 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);
- GNUNET_TESTING_get_trait_peer_id (peer2_cmd,
+ GNUNET_TRANSPORT_get_trait_peer_id (peer2_cmd,
&id);
- GNUNET_TESTING_get_trait_hello (peer2_cmd,
+ GNUNET_TRANSPORT_get_trait_hello (peer2_cmd,
&hello);
- GNUNET_TESTING_get_trait_hello_size (peer2_cmd,
+ GNUNET_TRANSPORT_get_trait_hello_size (peer2_cmd,
&hello_size);
addr = GNUNET_HELLO_extract_address (hello,
@@ -108,11 +108,11 @@ connect_peers_finish (void *cls,
struct GNUNET_PeerIdentity *id;
peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer1_label);
- GNUNET_TESTING_get_trait_peer_id (peer1_cmd,
+ GNUNET_TRANSPORT_get_trait_peer_id (peer1_cmd,
&id);
peer2_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer2_label);
- GNUNET_TESTING_get_trait_connected_peers_map (peer2_cmd,
+ GNUNET_TRANSPORT_get_trait_connected_peers_map (peer2_cmd,
&connected_peers_map);
ret = GNUNET_CONTAINER_multipeermap_contains (connected_peers_map,
diff --git a/src/transport/transport_api_cmd_send_simple.c b/src/transport/transport_api_cmd_send_simple.c
index e4ac199d1..4a60f1a12 100644
--- a/src/transport/transport_api_cmd_send_simple.c
+++ b/src/transport/transport_api_cmd_send_simple.c
@@ -76,12 +76,12 @@ send_simple_run (void *cls,
const struct GNUNET_TESTING_Command *peer2_cmd;
peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (sss->peer1_label);
- GNUNET_TESTING_get_trait_connected_peers_map (peer1_cmd,
- &connected_peers_map);
+ GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd,
+ &connected_peers_map);
peer2_cmd = GNUNET_TESTING_interpreter_lookup_command (sss->peer2_label);
- GNUNET_TESTING_get_trait_peer_id (peer2_cmd,
- &id);
+ GNUNET_TRANSPORT_get_trait_peer_id (peer2_cmd,
+ &id);
mq = GNUNET_CONTAINER_multipeermap_get (connected_peers_map,
id);
diff --git a/src/transport/transport_api_cmd_start_peer.c b/src/transport/transport_api_cmd_start_peer.c
index 0ad9f99af..c9af497ae 100644
--- a/src/transport/transport_api_cmd_start_peer.c
+++ b/src/transport/transport_api_cmd_start_peer.c
@@ -445,10 +445,10 @@ start_peer_traits (void *cls,
}
int
-GNUNET_TESTING_get_trait_hello_size (const struct
- GNUNET_TESTING_Command
- *cmd,
- size_t **hello_size)
+GNUNET_TRANSPORT_get_trait_hello_size (const struct
+ GNUNET_TESTING_Command
+ *cmd,
+ size_t **hello_size)
{
return cmd->traits (cmd->cls,
(const void **) hello_size,
@@ -457,10 +457,10 @@ GNUNET_TESTING_get_trait_hello_size (const struct
}
int
-GNUNET_TESTING_get_trait_hello (const struct
- GNUNET_TESTING_Command
- *cmd,
- char **hello)
+GNUNET_TRANSPORT_get_trait_hello (const struct
+ GNUNET_TESTING_Command
+ *cmd,
+ char **hello)
{
return cmd->traits (cmd->cls,
(const void **) hello,
@@ -469,12 +469,12 @@ GNUNET_TESTING_get_trait_hello (const struct
}
int
-GNUNET_TESTING_get_trait_connected_peers_map (const struct
- GNUNET_TESTING_Command
- *cmd,
- struct
- GNUNET_CONTAINER_MultiPeerMap **
- connected_peers_map)
+GNUNET_TRANSPORT_get_trait_connected_peers_map (const struct
+ GNUNET_TESTING_Command
+ *cmd,
+ struct
+ GNUNET_CONTAINER_MultiPeerMap **
+ connected_peers_map)
{
return cmd->traits (cmd->cls,
(const void **) connected_peers_map,
@@ -498,9 +498,9 @@ GNUNET_TRANSPORT_get_trait_application_handle (const struct
int
-GNUNET_TESTING_get_trait_peer_id (const struct
- GNUNET_TESTING_Command *cmd,
- struct GNUNET_PeerIdentity **id)
+GNUNET_TRANSPORT_get_trait_peer_id (const struct
+ GNUNET_TESTING_Command *cmd,
+ struct GNUNET_PeerIdentity **id)
{
return cmd->traits (cmd->cls,
(const void **) id,