summaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/gnunet-communicator-tcp.c29
-rw-r--r--src/transport/test_transport_api_cmd_simple_send.c12
-rw-r--r--src/transport/test_transport_plugin_cmd_simple_send.c7
-rw-r--r--src/transport/transport-testing-cmds.h10
-rw-r--r--src/transport/transport_api_cmd_connecting_peers.c94
-rw-r--r--src/transport/transport_api_cmd_send_simple.c65
-rw-r--r--src/transport/transport_api_cmd_start_peer.c268
-rw-r--r--src/transport/transport_api_cmd_stop_peer.c2
8 files changed, 247 insertions, 240 deletions
diff --git a/src/transport/gnunet-communicator-tcp.c b/src/transport/gnunet-communicator-tcp.c
index 10e2f7d40..d8bf7c1a8 100644
--- a/src/transport/gnunet-communicator-tcp.c
+++ b/src/transport/gnunet-communicator-tcp.c
@@ -879,12 +879,15 @@ queue_destroy (struct Queue *queue)
struct GNUNET_HashCode h_sock;
int sockfd;
- sockfd = GNUNET_NETWORK_get_fd (queue->listen_sock);
- GNUNET_CRYPTO_hash (&sockfd,
- sizeof(int),
- &h_sock);
+ if (NULL != queue->listen_sock)
+ {
+ sockfd = GNUNET_NETWORK_get_fd (queue->listen_sock);
+ GNUNET_CRYPTO_hash (&sockfd,
+ sizeof(int),
+ &h_sock);
- lt = GNUNET_CONTAINER_multihashmap_get (lt_map, &h_sock);
+ lt = GNUNET_CONTAINER_multihashmap_get (lt_map, &h_sock);
+ }
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Disconnecting queue for peer `%s'\n",
@@ -1900,9 +1903,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,
+ GNUNET_log_from_nocheck (GNUNET_ERROR_TYPE_DEBUG,
"transport",
- "Received %lu bytes from TCP queue\n", rcvd);
+ "Received %lu bytes from TCP queue\n", rcvd);
if (-1 == rcvd)
{
if ((EAGAIN != errno) && (EINTR != errno))
@@ -2678,9 +2681,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,
+ GNUNET_log_from_nocheck (GNUNET_ERROR_TYPE_DEBUG,
"transport",
- "Received %lu bytes for KX\n", rcvd);
+ "Received %lu bytes for KX\n", rcvd);
if (-1 == rcvd)
{
if ((EAGAIN != errno) && (EINTR != errno))
@@ -2830,10 +2833,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,
+ GNUNET_log_from_nocheck (GNUNET_ERROR_TYPE_DEBUG,
"transport",
- "Received %lu bytes for KX\n",
- rcvd);
+ "Received %lu bytes for KX\n",
+ rcvd);
if (-1 == rcvd)
{
if ((EAGAIN != errno) && (EINTR != errno))
@@ -3082,9 +3085,9 @@ do_shutdown (void *cls)
GNUNET_CONTAINER_multihashmap_iterate (lt_map, &get_lt_delete_it, NULL);
GNUNET_CONTAINER_multipeermap_iterate (queue_map, &get_queue_delete_it, NULL);
GNUNET_CONTAINER_multipeermap_destroy (queue_map);
- GNUNET_TRANSPORT_communicator_address_remove_all (ch);
if (NULL != ch)
{
+ GNUNET_TRANSPORT_communicator_address_remove_all (ch);
GNUNET_TRANSPORT_communicator_disconnect (ch);
ch = NULL;
}
diff --git a/src/transport/test_transport_api_cmd_simple_send.c b/src/transport/test_transport_api_cmd_simple_send.c
index 13497366e..27b9f95de 100644
--- a/src/transport/test_transport_api_cmd_simple_send.c
+++ b/src/transport/test_transport_api_cmd_simple_send.c
@@ -29,6 +29,10 @@
#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 120)
+/**
+ * Return value of the test.
+ *
+ */
static unsigned int rv = 0;
@@ -42,19 +46,19 @@ static void
run (void *cls)
{
struct GNUNET_TESTING_Command commands[] = {
- GNUNET_TESTING_cmd_netjail_start ("netjail-start-1",
+ GNUNET_TESTING_cmd_netjail_start ("netjail-start",
"2",
"1"),
- GNUNET_TESTING_cmd_netjail_start_testing_system ("netjail-start-testbed-1",
+ GNUNET_TESTING_cmd_netjail_start_testing_system ("netjail-start-testbed ",
"2",
"1",
"libgnunet_test_transport_plugin_cmd_simple_send",
&rv),
GNUNET_TESTING_cmd_stop_testing_system ("stop-testbed",
- "netjail-start-testbed-1",
+ "netjail-start-testbed ",
"2",
"1"),
- GNUNET_TESTING_cmd_netjail_stop ("netjail-stop-1",
+ GNUNET_TESTING_cmd_netjail_stop ("netjail-stop ",
"2",
"1"),
GNUNET_TESTING_cmd_end ()
diff --git a/src/transport/test_transport_plugin_cmd_simple_send.c b/src/transport/test_transport_plugin_cmd_simple_send.c
index ac5c01075..4b5018b60 100644
--- a/src/transport/test_transport_plugin_cmd_simple_send.c
+++ b/src/transport/test_transport_plugin_cmd_simple_send.c
@@ -160,13 +160,6 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, char *router_ip,
m,
n);
- /*testdir = GNUNET_malloc (strlen (BASE_DIR) + strlen (m) + strlen (n)
- + 1);
-
- strcpy (testdir, BASE_DIR);
- strcat (testdir, m);
- strcat (testdir, n);*/
-
struct GNUNET_MQ_MessageHandler handlers[] = {
GNUNET_MQ_hd_var_size (test,
GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE,
diff --git a/src/transport/transport-testing-cmds.h b/src/transport/transport-testing-cmds.h
index ece3b09a2..1461a3d4d 100644
--- a/src/transport/transport-testing-cmds.h
+++ b/src/transport/transport-testing-cmds.h
@@ -38,17 +38,19 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label,
const char *cfgname);
struct GNUNET_TESTING_Command
+GNUNET_TRANSPORT_cmd_stop_peer (const char *label,
+ const char *start_label);
+
+struct GNUNET_TESTING_Command
GNUNET_TRANSPORT_cmd_connect_peers (const char *label,
- const char *peer1_label,
- const char *peer2_label);
+ const char *start_peer_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);
+ const char *start_peer_label);
int
GNUNET_TRANSPORT_get_trait_peer_id (const struct
diff --git a/src/transport/transport_api_cmd_connecting_peers.c b/src/transport/transport_api_cmd_connecting_peers.c
index d5c4a5d48..34b3d5925 100644
--- a/src/transport/transport_api_cmd_connecting_peers.c
+++ b/src/transport/transport_api_cmd_connecting_peers.c
@@ -36,16 +36,30 @@
*/
#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
+/**
+ * Struct to store information needed in callbacks.
+ *
+ */
struct ConnectPeersState
{
- const char *peer1_label;
-
- const char *peer2_label;
-
+ /**
+ * Label of the cmd to start a peer.
+ *
+ */
+ const char *start_peer_label;
+
+ /**
+ * The peer identity of this peer.
+ *
+ */
struct GNUNET_PeerIdentity *id;
};
+/**
+ * The run method of this cmd will connect to peers.
+ *
+ */
static void
connect_peers_run (void *cls,
const struct GNUNET_TESTING_Command *cmd,
@@ -53,47 +67,38 @@ connect_peers_run (void *cls,
{
struct ConnectPeersState *cps = cls;
const struct GNUNET_TESTING_Command *peer1_cmd;
- //const struct GNUNET_TESTING_Command *peer2_cmd;
+ // const struct GNUNET_TESTING_Command *peer2_cmd;
struct GNUNET_TRANSPORT_ApplicationHandle *ah;
struct GNUNET_PeerIdentity *peer = GNUNET_new (struct GNUNET_PeerIdentity);
char *addr;
- //struct GNUNET_TIME_Absolute t;
+ // struct GNUNET_TIME_Absolute t;
char *hello;
- //size_t *hello_size;
+ // size_t *hello_size;
enum GNUNET_NetworkType nt = 0;
char *peer_id;
struct GNUNET_PeerIdentity *id;
- peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer1_label);
+ peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->start_peer_label);
GNUNET_TRANSPORT_get_trait_application_handle (peer1_cmd,
&ah);
GNUNET_TRANSPORT_get_trait_hello (peer1_cmd,
&hello);
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "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));
+ &id);
- if(strstr(hello, "60002") != NULL)
- {
+ if (strstr (hello, "60002") != NULL)
+ {
addr = "tcp-192.168.15.2:60003";
peer_id = "F2F3X9G1YNCTXKK7A4J6M4ZM4BBSKC9DEXZVHCWQ475M0C7PNWCG";
- }
+ }
else
- {
+ {
addr = "tcp-192.168.15.1:60002";
peer_id = "4TTC9WBSVP9RJT6DVEZ7E0TDW7TQXC11NR1EMR2F8ARS87WZ2730";
- }
+ }
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "get pub key\n");
GNUNET_CRYPTO_eddsa_public_key_from_string (peer_id,
strlen (peer_id),
&peer->public_key);
@@ -116,10 +121,9 @@ connect_peers_run (void *cls,
&nt,
&t);*/
- //----------------------------------------------
+ // ----------------------------------------------
+
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "application validate\n");
GNUNET_TRANSPORT_application_validate (ah,
peer,
nt,
@@ -127,6 +131,10 @@ connect_peers_run (void *cls,
}
+/**
+ * The finish function of this cmd will check if the peer we are trying to connect to is in the connected peers map of the start peer cmd for this peer.
+ *
+ */
static int
connect_peers_finish (void *cls,
GNUNET_SCHEDULER_TaskCallback cont,
@@ -140,36 +148,34 @@ connect_peers_finish (void *cls,
struct GNUNET_HashCode hc;
int node_number;
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "Connect finished?\n");
-
- peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer1_label);
+ peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->start_peer_label);
GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd,
- &connected_peers_map);
+ &connected_peers_map);
node_number = 1;
- GNUNET_CRYPTO_hash (&node_number, sizeof(node_number), &hc);
-
+ 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);
+ key);
if (GNUNET_YES == ret)
{
cont (cont_cls);
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "connect peer finish\n");
}
+ GNUNET_free (key);
return ret;
- /*cont (cont_cls);
- return GNUNET_OK;*/
}
+/**
+ * Trait function of this cmd does nothing.
+ *
+ */
static int
connect_peers_traits (void *cls,
const void **ret,
@@ -180,12 +186,17 @@ connect_peers_traits (void *cls,
}
+/**
+ * The cleanup function of this cmd frees resources the cmd allocated.
+ *
+ */
static void
connect_peers_cleanup (void *cls,
const struct GNUNET_TESTING_Command *cmd)
{
struct ConnectPeersState *cps = cls;
+ GNUNET_free (cps->id);
GNUNET_free (cps);
}
@@ -194,18 +205,17 @@ connect_peers_cleanup (void *cls,
* Create command.
*
* @param label name for command.
+ * @param start_peer_label Label of the cmd to start a peer.
* @return command.
*/
struct GNUNET_TESTING_Command
GNUNET_TRANSPORT_cmd_connect_peers (const char *label,
- const char *peer1_label,
- const char *peer2_label)
+ const char *start_peer_label)
{
struct ConnectPeersState *cps;
cps = GNUNET_new (struct ConnectPeersState);
- cps->peer1_label = peer1_label;
- cps->peer2_label = peer2_label;
+ cps->start_peer_label = start_peer_label;
struct GNUNET_TESTING_Command cmd = {
diff --git a/src/transport/transport_api_cmd_send_simple.c b/src/transport/transport_api_cmd_send_simple.c
index 6c4b76f48..f9e515c0f 100644
--- a/src/transport/transport_api_cmd_send_simple.c
+++ b/src/transport/transport_api_cmd_send_simple.c
@@ -29,19 +29,42 @@
#include "transport-testing2.h"
#include "transport-testing-cmds.h"
+/**
+ * Struct to hold information for callbacks.
+ *
+ */
struct SendSimpleState
{
+ /**
+ * The number of the local node of the actual network namespace.
+ *
+ */
char *m;
+ /**
+ * The number of the actual namespace.
+ *
+ */
char *n;
+ /**
+ * Number globally identifying the node.
+ *
+ */
uint32_t num;
- const char *peer1_label;
-
- const char *peer2_label;
+ /**
+ * Label of the cmd to start a peer.
+ *
+ */
+ const char *start_peer_label;
};
+
+/**
+ * Trait function of this cmd does nothing.
+ *
+ */
static int
send_simple_traits (void *cls,
const void **ret,
@@ -52,6 +75,10 @@ send_simple_traits (void *cls,
}
+/**
+ * The cleanup function of this cmd frees resources the cmd allocated.
+ *
+ */
static void
send_simple_cleanup (void *cls,
const struct GNUNET_TESTING_Command *cmd)
@@ -62,6 +89,10 @@ send_simple_cleanup (void *cls,
}
+/**
+ * The run method of this cmd will send a simple message to the connected peer.
+ *
+ */
static void
send_simple_run (void *cls,
const struct GNUNET_TESTING_Command *cmd,
@@ -72,14 +103,12 @@ send_simple_run (void *cls,
struct GNUNET_TRANSPORT_TESTING_TestMessage *test;
struct GNUNET_MQ_Handle *mq;
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);
+ peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (sss->start_peer_label);
GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd,
&connected_peers_map);
@@ -88,9 +117,9 @@ send_simple_run (void *cls,
memcpy (key,
&hc,
sizeof (*key));
-
+
mq = GNUNET_CONTAINER_multishortmap_get (connected_peers_map,
- key);
+ key);
env = GNUNET_MQ_msg_extra (test,
2600 - sizeof(*test),
@@ -99,12 +128,9 @@ send_simple_run (void *cls,
memset (&test[1],
sss->num,
2600 - sizeof(*test));
- /*GNUNET_MQ_notify_sent (env,
- cont,
- cont_cls);*/
GNUNET_MQ_send (mq,
env);
-
+ GNUNET_free (key);
}
@@ -113,15 +139,18 @@ send_simple_run (void *cls,
* Create command.
*
* @param label name for command.
+ * @param m The number of the local node of the actual network namespace.
+ * @param n The number of the actual namespace.
+ * @param num Number globally identifying the node.
+ * @param start_peer_label Label of the cmd to start a peer.
* @return command.
*/
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)
+ char *m,
+ char *n,
+ uint32_t num,
+ const char *start_peer_label)
{
struct SendSimpleState *sss;
@@ -129,7 +158,7 @@ GNUNET_TRANSPORT_cmd_send_simple (const char *label,
sss->m = m;
sss->n = n;
sss->num = num;
- sss->peer1_label = peer1_label;
+ sss->start_peer_label = start_peer_label;
struct GNUNET_TESTING_Command cmd = {
.cls = sss,
diff --git a/src/transport/transport_api_cmd_start_peer.c b/src/transport/transport_api_cmd_start_peer.c
index 8696a99dc..9277bc346 100644
--- a/src/transport/transport_api_cmd_start_peer.c
+++ b/src/transport/transport_api_cmd_start_peer.c
@@ -29,93 +29,22 @@
#include "gnunet_peerstore_service.h"
#include "gnunet_transport_core_service.h"
#include "gnunet_transport_application_service.h"
+#include "transport-testing-ng.h"
/**
* Generic logging shortcut
*/
#define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__)
-struct StartPeerState
-{
- /**
- * Receive callback
- */
- struct GNUNET_MQ_MessageHandler *handlers;
-
- const char *cfgname;
-
- /**
- * Peer's configuration
- */
- struct GNUNET_CONFIGURATION_Handle *cfg;
-
- struct GNUNET_TESTING_Peer *peer;
-
- /**
- * Peer identity
- */
- struct GNUNET_PeerIdentity id;
-
- /**
- * Peer's transport service handle
- */
- struct GNUNET_TRANSPORT_CoreHandle *th;
-
- /**
- * Application handle
- */
- struct GNUNET_TRANSPORT_ApplicationHandle *ah;
-
- /**
- * Peer's PEERSTORE Handle
- */
- struct GNUNET_PEERSTORE_Handle *ph;
-
- /**
- * Hello get task
- */
- struct GNUNET_SCHEDULER_Task *rh_task;
-
- /**
- * Peer's transport get hello handle to retrieve peer's HELLO message
- */
- struct GNUNET_PEERSTORE_IterateContext *pic;
-
- /**
- * Hello
- */
- char *hello;
-
- /**
- * Hello size
- */
- size_t hello_size;
-
- char *m;
-
- char *n;
-
- char *local_m;
-
- unsigned int finished;
-
- const char *system_label;
-
- /**
- * An unique number to identify the peer
- */
- unsigned int no;
-
- struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
-
- struct GNUNET_TESTING_System *tl_system;
-
-};
-
static void
retrieve_hello (void *cls);
+
+/**
+ * Callback delivering the hello of this peer from peerstore.
+ *
+ */
static void
hello_iter_cb (void *cb_cls,
const struct GNUNET_PEERSTORE_Record *record,
@@ -140,6 +69,11 @@ hello_iter_cb (void *cb_cls,
}
+
+/**
+ * Function to start the retrival task to retrieve the hello of this peer from the peerstore.
+ *
+ */
static void
retrieve_hello (void *cls)
{
@@ -154,6 +88,11 @@ retrieve_hello (void *cls)
}
+
+/**
+ * This function checks StartPeerState#finished, which is set when the hello was retrieved.
+ *
+ */
static int
start_peer_finish (void *cls,
GNUNET_SCHEDULER_TaskCallback cont,
@@ -170,6 +109,10 @@ start_peer_finish (void *cls,
}
+/**
+ * Disconnect callback for the connection to the core service.
+ *
+ */
static void
notify_disconnect (void *cls,
const struct GNUNET_PeerIdentity *peer,
@@ -186,6 +129,10 @@ notify_disconnect (void *cls,
}
+/**
+ * Connect callback for the connection to the core service.
+ *
+ */
static void *
notify_connect (void *cls,
const struct GNUNET_PeerIdentity *peer,
@@ -206,23 +153,27 @@ notify_connect (void *cls,
GNUNET_i2s (&sps->id));
// 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);
-
+ 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);
+ key,
+ mq,
+ GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
+ GNUNET_free (key);
// TODO what does the handler function need?
return ret;
}
-
+/**
+ * The run method of this cmd will start all services of a peer to test the transport service.
+ *
+ */
static void
start_peer_run (void *cls,
const struct GNUNET_TESTING_Command *cmd,
@@ -234,9 +185,6 @@ start_peer_run (void *cls,
const struct GNUNET_TESTING_Command *system_cmd;
struct GNUNET_TESTING_System *tl_system;
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "start peer 1\n");
-
if (GNUNET_NO == GNUNET_DISK_file_test (sps->cfgname))
{
LOG (GNUNET_ERROR_TYPE_ERROR,
@@ -269,8 +217,6 @@ start_peer_run (void *cls,
return;
}
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "start peer 2\n");
sps->peer = GNUNET_TESTING_peer_configure (sps->tl_system,
sps->cfg,
sps->no,
@@ -287,8 +233,6 @@ start_peer_run (void *cls,
return;
}
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "start peer 3\n");
if (GNUNET_OK != GNUNET_TESTING_peer_start (sps->peer))
{
LOG (GNUNET_ERROR_TYPE_ERROR,
@@ -298,17 +242,14 @@ start_peer_run (void *cls,
GNUNET_TESTING_interpreter_fail ();
return;
}
-LOG (GNUNET_ERROR_TYPE_ERROR,
- "start peer 4\n");
+
memset (&dummy,
'\0',
sizeof(dummy));
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "start peer 4.1\n");
+
GNUNET_TESTING_peer_get_identity (sps->peer,
&sps->id);
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "start peer 4.2\n");
+
if (0 == memcmp (&dummy,
&sps->id,
sizeof(struct GNUNET_PeerIdentity)))
@@ -324,8 +265,7 @@ LOG (GNUNET_ERROR_TYPE_ERROR,
"Peer %u configured with identity `%s'\n",
sps->no,
GNUNET_i2s_full (&sps->id));
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "start peer 4.3\n");
+
sps->th = GNUNET_TRANSPORT_core_connect (sps->cfg,
NULL,
sps->handlers,
@@ -342,8 +282,7 @@ LOG (GNUNET_ERROR_TYPE_ERROR,
GNUNET_TESTING_interpreter_fail ();
return;
}
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "start peer 5\n");
+
sps->ph = GNUNET_PEERSTORE_connect (sps->cfg);
if (NULL == sps->th)
{
@@ -355,8 +294,7 @@ LOG (GNUNET_ERROR_TYPE_ERROR,
GNUNET_TESTING_interpreter_fail ();
return;
}
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "start peer 6\n");
+
sps->ah = GNUNET_TRANSPORT_application_init (sps->cfg);
if (NULL == sps->ah)
{
@@ -371,28 +309,16 @@ LOG (GNUNET_ERROR_TYPE_ERROR,
sps->rh_task = GNUNET_SCHEDULER_add_now (retrieve_hello, sps);
}
-
+/**
+ * The cleanup function of this cmd frees resources the cmd allocated.
+ *
+ */
static void
start_peer_cleanup (void *cls,
const struct GNUNET_TESTING_Command *cmd)
{
struct StartPeerState *sps = cls;
- if (NULL != sps->rh_task)
- GNUNET_SCHEDULER_cancel (sps->rh_task);
- sps->rh_task = NULL;
- if (NULL != sps->ah)
- {
- GNUNET_TRANSPORT_application_done (sps->ah);
- sps->ah = NULL;
- }
- if (NULL != sps->ph)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Disconnecting from PEERSTORE service\n");
- GNUNET_PEERSTORE_disconnect (sps->ph, GNUNET_NO);
- sps->ph = NULL;
- }
if (NULL != sps->handlers)
{
GNUNET_free (sps->handlers);
@@ -403,34 +329,16 @@ start_peer_cleanup (void *cls,
GNUNET_CONFIGURATION_destroy (sps->cfg);
sps->cfg = NULL;
}
- if (NULL != sps->peer)
- {
- if (GNUNET_OK !=
- GNUNET_TESTING_peer_stop (sps->peer))
- {
- LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Testing lib failed to stop peer %u (`%s')\n",
- sps->no,
- GNUNET_i2s (&sps->id));
- }
- GNUNET_TESTING_peer_destroy (sps->peer);
- sps->peer = NULL;
- }
- if (NULL != sps->th)
- {
- GNUNET_TRANSPORT_core_disconnect (sps->th);
- sps->th = NULL;
- }
- if (NULL != sps->tl_system)
- {
- GNUNET_free (sps->tl_system);
- }
GNUNET_free (sps->hello);
GNUNET_free (sps->connected_peers_map);
GNUNET_free (sps);
}
+/**
+ * This function prepares an array with traits.
+ *
+ */
static int
start_peer_traits (void *cls,
const void **ret,
@@ -472,6 +380,11 @@ start_peer_traits (void *cls,
.trait_name = "hello_size",
.ptr = (const void *) hello_size,
},
+ {
+ .index = 5,
+ .trait_name = "state",
+ .ptr = (const void *) sps,
+ },
GNUNET_TESTING_trait_end ()
};
@@ -481,6 +394,34 @@ start_peer_traits (void *cls,
index);
}
+
+/**
+ * Function to get the trait with the struct StartPeerState.
+ *
+ * @param[out] sps struct StartPeerState.
+ * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
+ *
+ */
+int
+GNUNET_TRANSPORT_get_trait_state (const struct
+ GNUNET_TESTING_Command
+ *cmd,
+ struct StartPeerState **sps)
+{
+ return cmd->traits (cmd->cls,
+ (const void **) sps,
+ "state",
+ (unsigned int) 5);
+}
+
+
+/**
+ * Function to get the trait with the size of the hello.
+ *
+ * @param[out] hello_size size of hello.
+ * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
+ *
+ */
int
GNUNET_TRANSPORT_get_trait_hello_size (const struct
GNUNET_TESTING_Command
@@ -493,6 +434,13 @@ GNUNET_TRANSPORT_get_trait_hello_size (const struct
(unsigned int) 4);
}
+/**
+ * Function to get the trait with the hello.
+ *
+ * @param[out] hello The hello for the peer.
+ * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
+ *
+ */
int
GNUNET_TRANSPORT_get_trait_hello (const struct
GNUNET_TESTING_Command
@@ -505,12 +453,21 @@ GNUNET_TRANSPORT_get_trait_hello (const struct
(unsigned int) 3);
}
+
+/**
+ * Function to get the trait with the map of connected peers.
+ *
+ * @param[out] connected_peers_map The map with connected peers.
+ * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
+ *
+ */
int
GNUNET_TRANSPORT_get_trait_connected_peers_map (const struct
GNUNET_TESTING_Command
*cmd,
struct
- GNUNET_CONTAINER_MultiShortmap **
+ GNUNET_CONTAINER_MultiShortmap *
+ *
connected_peers_map)
{
return cmd->traits (cmd->cls,
@@ -520,6 +477,12 @@ GNUNET_TRANSPORT_get_trait_connected_peers_map (const struct
}
+/**
+ * Function to get the trait with the transport application handle.
+ *
+ * @param[out] ah The application handle.
+ * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
+ */
int
GNUNET_TRANSPORT_get_trait_application_handle (const struct
GNUNET_TESTING_Command *cmd,
@@ -534,6 +497,12 @@ GNUNET_TRANSPORT_get_trait_application_handle (const struct
}
+/**
+ * Function to get the trait with the peer id.
+ *
+ * @param[out] id The peer id.
+ * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise.
+ */
int
GNUNET_TRANSPORT_get_trait_peer_id (const struct
GNUNET_TESTING_Command *cmd,
@@ -550,6 +519,12 @@ GNUNET_TRANSPORT_get_trait_peer_id (const struct
* Create command.
*
* @param label name for command.
+ * @param system_label Label of the cmd to setup a test environment.
+ * @param m The number of the local node of the actual network namespace.
+ * @param n The number of the actual namespace.
+ * @param local_m Number of local nodes in each namespace.
+ * @param handlers Handler for messages received by this peer.
+ * @param cfgname Configuration file name for this peer.
* @return command.
*/
struct GNUNET_TESTING_Command
@@ -566,10 +541,6 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label,
GNUNET_CONTAINER_multishortmap_create (1,GNUNET_NO);
unsigned int i;
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "start peer 0.1 with cfg: %s\n",
- cfgname);
-
sps = GNUNET_new (struct StartPeerState);
sps->m = m;
sps->n = n;
@@ -579,9 +550,6 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label,
sps->connected_peers_map = connected_peers_map;
sps->cfgname = cfgname;
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "start peer 0.2\n");
-
if (NULL != handlers)
{
for (i = 0; NULL != handlers[i].cb; i++)
@@ -593,8 +561,6 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label,
i * sizeof(struct GNUNET_MQ_MessageHandler));
}
- LOG (GNUNET_ERROR_TYPE_ERROR,
- "start peer 0.3\n");
struct GNUNET_TESTING_Command cmd = {
.cls = sps,
.label = label,
diff --git a/src/transport/transport_api_cmd_stop_peer.c b/src/transport/transport_api_cmd_stop_peer.c
index 2277520ec..7a0050a63 100644
--- a/src/transport/transport_api_cmd_stop_peer.c
+++ b/src/transport/transport_api_cmd_stop_peer.c
@@ -92,7 +92,7 @@ stop_peer_run (void *cls,
if (GNUNET_OK !=
GNUNET_TESTING_peer_stop (sps->peer))
{
- LOG (GNUNET_ERROR_TYPE_DEBUG,
+ LOG (GNUNET_ERROR_TYPE_ERROR,
"Testing lib failed to stop peer %u (`%s')\n",
sps->no,
GNUNET_i2s (&sps->id));