aboutsummaryrefslogtreecommitdiff
path: root/src/transport/transport_api_cmd_send_simple.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/transport_api_cmd_send_simple.c')
-rw-r--r--src/transport/transport_api_cmd_send_simple.c65
1 files changed, 47 insertions, 18 deletions
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 @@
29#include "transport-testing2.h" 29#include "transport-testing2.h"
30#include "transport-testing-cmds.h" 30#include "transport-testing-cmds.h"
31 31
32/**
33 * Struct to hold information for callbacks.
34 *
35 */
32struct SendSimpleState 36struct SendSimpleState
33{ 37{
38 /**
39 * The number of the local node of the actual network namespace.
40 *
41 */
34 char *m; 42 char *m;
35 43
44 /**
45 * The number of the actual namespace.
46 *
47 */
36 char *n; 48 char *n;
37 49
50 /**
51 * Number globally identifying the node.
52 *
53 */
38 uint32_t num; 54 uint32_t num;
39 55
40 const char *peer1_label; 56 /**
41 57 * Label of the cmd to start a peer.
42 const char *peer2_label; 58 *
59 */
60 const char *start_peer_label;
43}; 61};
44 62
63
64/**
65 * Trait function of this cmd does nothing.
66 *
67 */
45static int 68static int
46send_simple_traits (void *cls, 69send_simple_traits (void *cls,
47 const void **ret, 70 const void **ret,
@@ -52,6 +75,10 @@ send_simple_traits (void *cls,
52} 75}
53 76
54 77
78/**
79 * The cleanup function of this cmd frees resources the cmd allocated.
80 *
81 */
55static void 82static void
56send_simple_cleanup (void *cls, 83send_simple_cleanup (void *cls,
57 const struct GNUNET_TESTING_Command *cmd) 84 const struct GNUNET_TESTING_Command *cmd)
@@ -62,6 +89,10 @@ send_simple_cleanup (void *cls,
62} 89}
63 90
64 91
92/**
93 * The run method of this cmd will send a simple message to the connected peer.
94 *
95 */
65static void 96static void
66send_simple_run (void *cls, 97send_simple_run (void *cls,
67 const struct GNUNET_TESTING_Command *cmd, 98 const struct GNUNET_TESTING_Command *cmd,
@@ -72,14 +103,12 @@ send_simple_run (void *cls,
72 struct GNUNET_TRANSPORT_TESTING_TestMessage *test; 103 struct GNUNET_TRANSPORT_TESTING_TestMessage *test;
73 struct GNUNET_MQ_Handle *mq; 104 struct GNUNET_MQ_Handle *mq;
74 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map; 105 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map;
75 //struct GNUNET_PeerIdentity *id;
76 const struct GNUNET_TESTING_Command *peer1_cmd; 106 const struct GNUNET_TESTING_Command *peer1_cmd;
77 //const struct GNUNET_TESTING_Command *peer2_cmd;
78 struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode); 107 struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode);
79 struct GNUNET_HashCode hc; 108 struct GNUNET_HashCode hc;
80 int node_number; 109 int node_number;
81 110
82 peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (sss->peer1_label); 111 peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (sss->start_peer_label);
83 GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd, 112 GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd,
84 &connected_peers_map); 113 &connected_peers_map);
85 114
@@ -88,9 +117,9 @@ send_simple_run (void *cls,
88 memcpy (key, 117 memcpy (key,
89 &hc, 118 &hc,
90 sizeof (*key)); 119 sizeof (*key));
91 120
92 mq = GNUNET_CONTAINER_multishortmap_get (connected_peers_map, 121 mq = GNUNET_CONTAINER_multishortmap_get (connected_peers_map,
93 key); 122 key);
94 123
95 env = GNUNET_MQ_msg_extra (test, 124 env = GNUNET_MQ_msg_extra (test,
96 2600 - sizeof(*test), 125 2600 - sizeof(*test),
@@ -99,12 +128,9 @@ send_simple_run (void *cls,
99 memset (&test[1], 128 memset (&test[1],
100 sss->num, 129 sss->num,
101 2600 - sizeof(*test)); 130 2600 - sizeof(*test));
102 /*GNUNET_MQ_notify_sent (env,
103 cont,
104 cont_cls);*/
105 GNUNET_MQ_send (mq, 131 GNUNET_MQ_send (mq,
106 env); 132 env);
107 133 GNUNET_free (key);
108 134
109} 135}
110 136
@@ -113,15 +139,18 @@ send_simple_run (void *cls,
113 * Create command. 139 * Create command.
114 * 140 *
115 * @param label name for command. 141 * @param label name for command.
142 * @param m The number of the local node of the actual network namespace.
143 * @param n The number of the actual namespace.
144 * @param num Number globally identifying the node.
145 * @param start_peer_label Label of the cmd to start a peer.
116 * @return command. 146 * @return command.
117 */ 147 */
118struct GNUNET_TESTING_Command 148struct GNUNET_TESTING_Command
119GNUNET_TRANSPORT_cmd_send_simple (const char *label, 149GNUNET_TRANSPORT_cmd_send_simple (const char *label,
120 char *m, 150 char *m,
121 char *n, 151 char *n,
122 uint32_t num, 152 uint32_t num,
123 const char *peer1_label, 153 const char *start_peer_label)
124 const char *peer2_label)
125{ 154{
126 struct SendSimpleState *sss; 155 struct SendSimpleState *sss;
127 156
@@ -129,7 +158,7 @@ GNUNET_TRANSPORT_cmd_send_simple (const char *label,
129 sss->m = m; 158 sss->m = m;
130 sss->n = n; 159 sss->n = n;
131 sss->num = num; 160 sss->num = num;
132 sss->peer1_label = peer1_label; 161 sss->start_peer_label = start_peer_label;
133 162
134 struct GNUNET_TESTING_Command cmd = { 163 struct GNUNET_TESTING_Command cmd = {
135 .cls = sss, 164 .cls = sss,