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.c119
1 files changed, 71 insertions, 48 deletions
diff --git a/src/transport/transport_api_cmd_send_simple.c b/src/transport/transport_api_cmd_send_simple.c
index 0631f7051..9c34c50d7 100644
--- a/src/transport/transport_api_cmd_send_simple.c
+++ b/src/transport/transport_api_cmd_send_simple.c
@@ -46,21 +46,18 @@ struct SendSimpleState
46 * 46 *
47 */ 47 */
48 const char *start_peer_label; 48 const char *start_peer_label;
49};
50 49
50 /**
51 * Label of the cmd which started the test system.
52 *
53 */
54 const char *create_label;
51 55
52/** 56 /**
53 * Trait function of this cmd does nothing. 57 * The topology we get the connected nodes from.
54 * 58 */
55 */ 59 struct GNUNET_TESTING_NetjailTopology *topology;
56static int 60};
57send_simple_traits (void *cls,
58 const void **ret,
59 const char *trait,
60 unsigned int index)
61{
62 return GNUNET_OK;
63}
64 61
65 62
66/** 63/**
@@ -77,7 +74,7 @@ send_simple_cleanup (void *cls)
77 74
78 75
79/** 76/**
80 * The run method of this cmd will send a simple message to the connected peer. 77 * The run method of this cmd will send a simple message to the connected peers.
81 * 78 *
82 */ 79 */
83static void 80static void
@@ -92,31 +89,54 @@ send_simple_run (void *cls,
92 const struct GNUNET_TESTING_Command *peer1_cmd; 89 const struct GNUNET_TESTING_Command *peer1_cmd;
93 struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode); 90 struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode);
94 struct GNUNET_HashCode hc; 91 struct GNUNET_HashCode hc;
95 int node_number; 92 struct GNUNET_TESTING_NodeConnection *node_connections_head;
93 struct GNUNET_PeerIdentity *peer;
94 struct GNUNET_CRYPTO_EddsaPublicKey public_key;
95 uint32_t num;
96 struct GNUNET_TESTING_NodeConnection *pos_connection;
97 const struct GNUNET_TESTING_Command *system_cmd;
98 struct GNUNET_TESTING_System *tl_system;
96 99
97 peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (is, 100 peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
98 sss->start_peer_label); 101 sss->start_peer_label);
99 GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd, 102 GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd,
100 &connected_peers_map); 103 &connected_peers_map);
101 104
102 node_number = 1; 105 system_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
103 GNUNET_CRYPTO_hash (&node_number, sizeof(node_number), &hc); 106 sss->create_label);
104 memcpy (key, 107 GNUNET_TESTING_get_trait_test_system (system_cmd,
105 &hc, 108 &tl_system);
106 sizeof (*key)); 109
107 110 node_connections_head = GNUNET_TESTING_get_connections (sss->num,
108 mq = GNUNET_CONTAINER_multishortmap_get (connected_peers_map, 111 sss->topology);
109 key); 112
110 113 for (int i = 0; i < 1; i++)
111 env = GNUNET_MQ_msg_extra (test, 114 {
112 2600 - sizeof(*test), 115 for (pos_connection = node_connections_head; NULL != pos_connection;
113 GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE); 116 pos_connection = pos_connection->next)
114 test->num = htonl (sss->num); 117 {
115 memset (&test[1], 118 num = GNUNET_TESTING_calculate_num (pos_connection, sss->topology);
116 sss->num, 119 peer = GNUNET_TESTING_get_pub_key (num, tl_system);
117 2600 - sizeof(*test)); 120 public_key = peer->public_key;
118 GNUNET_MQ_send (mq, 121 GNUNET_CRYPTO_hash (&public_key, sizeof(public_key), &hc);
119 env); 122
123 memcpy (key,
124 &hc,
125 sizeof (*key));
126 mq = GNUNET_CONTAINER_multishortmap_get (connected_peers_map,
127 key);
128 env = GNUNET_MQ_msg_extra (test,
129 1000 - sizeof(*test),
130 GNUNET_TRANSPORT_TESTING_SIMPLE_MTYPE);
131 test->num = htonl (sss->num);
132 memset (&test[1],
133 sss->num,
134 1000 - sizeof(*test));
135 GNUNET_MQ_send (mq,
136 env);
137 }
138 }
139
120 GNUNET_free (key); 140 GNUNET_free (key);
121 141
122} 142}
@@ -126,31 +146,34 @@ send_simple_run (void *cls,
126 * Create command. 146 * Create command.
127 * 147 *
128 * @param label name for command. 148 * @param label name for command.
129 * @param m The number of the local node of the actual network namespace.
130 * @param n The number of the actual namespace.
131 * @param num Number globally identifying the node.
132 * @param start_peer_label Label of the cmd to start a peer. 149 * @param start_peer_label Label of the cmd to start a peer.
150 * @param start_peer_label Label of the cmd which started the test system.
151 * @param num Number globally identifying the node.
152 * @param The topology for the test setup.
133 * @return command. 153 * @return command.
134 */ 154 */
135struct GNUNET_TESTING_Command 155struct GNUNET_TESTING_Command
136GNUNET_TRANSPORT_cmd_send_simple (const char *label, 156GNUNET_TRANSPORT_cmd_send_simple (const char *label,
137 const char *start_peer_label, 157 const char *start_peer_label,
138 uint32_t num) 158 const char *create_label,
159 uint32_t num,
160 struct GNUNET_TESTING_NetjailTopology *
161 topology)
139{ 162{
140 struct SendSimpleState *sss; 163 struct SendSimpleState *sss;
141 164
142 sss = GNUNET_new (struct SendSimpleState); 165 sss = GNUNET_new (struct SendSimpleState);
143 sss->num = num; 166 sss->num = num;
144 sss->start_peer_label = start_peer_label; 167 sss->start_peer_label = start_peer_label;
145 { 168 sss->create_label = create_label;
146 struct GNUNET_TESTING_Command cmd = { 169 sss->topology = topology;
147 .cls = sss, 170
148 .label = label, 171 struct GNUNET_TESTING_Command cmd = {
149 .run = &send_simple_run, 172 .cls = sss,
150 .cleanup = &send_simple_cleanup, 173 .label = label,
151 .traits = &send_simple_traits 174 .run = &send_simple_run,
152 }; 175 .cleanup = &send_simple_cleanup
153 176 };
154 return cmd; 177
155 } 178 return cmd;
156} 179}