diff options
Diffstat (limited to 'src/transport/transport_api_cmd_connecting_peers.c')
-rw-r--r-- | src/transport/transport_api_cmd_connecting_peers.c | 515 |
1 files changed, 353 insertions, 162 deletions
diff --git a/src/transport/transport_api_cmd_connecting_peers.c b/src/transport/transport_api_cmd_connecting_peers.c index 39c7db450..2e51363f6 100644 --- a/src/transport/transport_api_cmd_connecting_peers.c +++ b/src/transport/transport_api_cmd_connecting_peers.c | |||
@@ -36,199 +36,348 @@ | |||
36 | */ | 36 | */ |
37 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) | 37 | #define LOG(kind, ...) GNUNET_log (kind, __VA_ARGS__) |
38 | 38 | ||
39 | /** | 39 | #define CONNECT_ADDRESS_TEMPLATE_TCP "tcp-192.168.15.%u:60002" |
40 | * Struct to store information needed in callbacks. | ||
41 | * | ||
42 | */ | ||
43 | struct ConnectPeersState | ||
44 | { | ||
45 | // Label of the cmd which started the test system. | ||
46 | const char *create_label; | ||
47 | 40 | ||
48 | /** | 41 | #define CONNECT_ADDRESS_TEMPLATE_UDP "udp-192.168.15.%u:60002" |
49 | * Number globally identifying the node. | ||
50 | * | ||
51 | */ | ||
52 | uint32_t num; | ||
53 | 42 | ||
54 | /** | 43 | #define ROUTER_CONNECT_ADDRESS_TEMPLATE_TCP "tcp-92.68.150.%u:60002" |
55 | * Label of the cmd to start a peer. | ||
56 | * | ||
57 | */ | ||
58 | const char *start_peer_label; | ||
59 | 44 | ||
60 | /** | 45 | #define ROUTER_CONNECT_ADDRESS_TEMPLATE_UDP "udp-92.68.150.%u:60002" |
61 | * The peer identity of this peer. | ||
62 | * | ||
63 | */ | ||
64 | struct GNUNET_PeerIdentity *id; | ||
65 | }; | ||
66 | 46 | ||
47 | #define GLOBAL_CONNECT_ADDRESS_TEMPLATE_TCP "tcp-92.68.151.%u:60002" | ||
67 | 48 | ||
68 | /** | 49 | #define GLOBAL_CONNECT_ADDRESS_TEMPLATE_UDP "udp-92.68.151.%u:60002" |
69 | * The run method of this cmd will connect to peers. | 50 | |
70 | * | 51 | #define PREFIX_TCP "tcp" |
71 | */ | 52 | |
72 | static void | 53 | #define PREFIX_UDP "udp" |
73 | connect_peers_run (void *cls, | 54 | |
74 | const struct GNUNET_TESTING_Command *cmd, | 55 | |
75 | struct GNUNET_TESTING_Interpreter *is) | 56 | |
57 | |||
58 | static struct GNUNET_PeerIdentity * | ||
59 | get_pub_key (unsigned int num, struct GNUNET_TESTING_System *tl_system) | ||
76 | { | 60 | { |
77 | struct ConnectPeersState *cps = cls; | 61 | struct GNUNET_PeerIdentity *peer = GNUNET_new (struct GNUNET_PeerIdentity); |
78 | const struct GNUNET_TESTING_Command *system_cmd; | ||
79 | struct GNUNET_TESTING_System *tl_system; | ||
80 | struct GNUNET_CRYPTO_EddsaPrivateKey *priv_key = GNUNET_new (struct | ||
81 | GNUNET_CRYPTO_EddsaPrivateKey); | ||
82 | struct GNUNET_CRYPTO_EddsaPublicKey *pub_key = GNUNET_new (struct | 62 | struct GNUNET_CRYPTO_EddsaPublicKey *pub_key = GNUNET_new (struct |
83 | GNUNET_CRYPTO_EddsaPublicKey); | 63 | GNUNET_CRYPTO_EddsaPublicKey); |
84 | ; | 64 | struct GNUNET_CRYPTO_EddsaPrivateKey *priv_key = GNUNET_new (struct |
85 | const struct GNUNET_TESTING_Command *peer1_cmd; | 65 | GNUNET_CRYPTO_EddsaPrivateKey); |
86 | // const struct GNUNET_TESTING_Command *peer2_cmd; | ||
87 | struct GNUNET_TRANSPORT_ApplicationHandle *ah; | ||
88 | struct GNUNET_PeerIdentity *peer = GNUNET_new (struct GNUNET_PeerIdentity); | ||
89 | char *addr; | ||
90 | // struct GNUNET_TIME_Absolute t; | ||
91 | char *hello; | ||
92 | // size_t *hello_size; | ||
93 | enum GNUNET_NetworkType nt = 0; | ||
94 | // char *peer_id; | ||
95 | struct GNUNET_PeerIdentity *id; | ||
96 | struct GNUNET_PeerIdentity *other = GNUNET_new (struct GNUNET_PeerIdentity); | ||
97 | uint32_t num; | ||
98 | 66 | ||
99 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->start_peer_label); | 67 | priv_key = GNUNET_TESTING_hostkey_get (tl_system, |
100 | GNUNET_TRANSPORT_get_trait_application_handle (peer1_cmd, | 68 | num, |
101 | &ah); | 69 | peer); |
102 | 70 | ||
103 | GNUNET_TRANSPORT_get_trait_hello (peer1_cmd, | 71 | GNUNET_CRYPTO_eddsa_key_get_public (priv_key, |
104 | &hello); | 72 | pub_key); |
73 | peer->public_key = *pub_key; | ||
74 | return peer; | ||
75 | } | ||
105 | 76 | ||
106 | GNUNET_TRANSPORT_get_trait_peer_id (peer1_cmd, | ||
107 | &id); | ||
108 | 77 | ||
109 | system_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->create_label); | 78 | static int |
110 | GNUNET_TESTING_get_trait_test_system (system_cmd, | 79 | log_nodes (void *cls, const struct GNUNET_ShortHashCode *id, void *value) |
111 | &tl_system); | 80 | { |
81 | struct GNUNET_TESTING_NetjailNode *node = value; | ||
82 | struct GNUNET_TESTING_NodeConnection *pos_connection; | ||
83 | struct GNUNET_TESTING_ADDRESS_PREFIX *pos_prefix; | ||
112 | 84 | ||
113 | if (2 == cps->num) | 85 | LOG (GNUNET_ERROR_TYPE_ERROR, |
114 | num = 1; | 86 | "plugin: %s space: %u node: %u global: %u\n", |
115 | else | 87 | node->plugin, |
116 | num = 2; | 88 | node->namespace_n, |
89 | node->node_n, | ||
90 | node->is_global); | ||
91 | |||
92 | for (pos_connection = node->node_connections_head; NULL != pos_connection; | ||
93 | pos_connection = pos_connection->next) | ||
94 | { | ||
95 | |||
96 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
97 | "namespace_n: %u node_n: %u node_type: %u\n", | ||
98 | pos_connection->namespace_n, | ||
99 | pos_connection->node_n, | ||
100 | pos_connection->node_type); | ||
101 | |||
102 | for (pos_prefix = pos_connection->address_prefixes_head; NULL != pos_prefix; | ||
103 | pos_prefix = | ||
104 | pos_prefix->next) | ||
105 | { | ||
106 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
107 | "prefix: %s\n", | ||
108 | pos_prefix->address_prefix); | ||
109 | } | ||
110 | } | ||
111 | return GNUNET_YES; | ||
112 | } | ||
113 | |||
114 | |||
115 | static int | ||
116 | log_namespaces (void *cls, const struct GNUNET_ShortHashCode *id, void *value) | ||
117 | { | ||
118 | struct GNUNET_TESTING_NetjailNamespace *namespace = value; | ||
119 | struct GNUNET_TESTING_NetjailRouter *router = namespace->router; | ||
120 | |||
121 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
122 | "router_tcp: %u router_udp: %u spaces: %u\n", | ||
123 | router->tcp_port, | ||
124 | router->udp_port, | ||
125 | namespace->namespace_n); | ||
126 | GNUNET_CONTAINER_multishortmap_iterate (namespace->nodes, &log_nodes, NULL); | ||
127 | return GNUNET_YES; | ||
128 | } | ||
117 | 129 | ||
118 | 130 | ||
131 | static int | ||
132 | log_topo (struct GNUNET_TESTING_NetjailTopology *topology) | ||
133 | { | ||
134 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
135 | "plugin: %s spaces: %u nodes: %u known: %u\n", | ||
136 | topology->plugin, | ||
137 | topology->namespaces_n, | ||
138 | topology->nodes_m, | ||
139 | topology->nodes_x); | ||
140 | |||
141 | GNUNET_CONTAINER_multishortmap_iterate (topology->map_namespaces, | ||
142 | log_namespaces, NULL); | ||
143 | GNUNET_CONTAINER_multishortmap_iterate (topology->map_globals, &log_nodes, | ||
144 | NULL); | ||
145 | return GNUNET_YES; | ||
146 | } | ||
147 | |||
148 | |||
149 | static struct GNUNET_TESTING_NodeConnection * | ||
150 | get_connections (unsigned int num, struct | ||
151 | GNUNET_TESTING_NetjailTopology *topology) | ||
152 | { | ||
153 | struct GNUNET_TESTING_NetjailNode *node; | ||
154 | struct GNUNET_ShortHashCode *hkey; | ||
155 | struct GNUNET_HashCode hc; | ||
156 | struct GNUNET_TESTING_NetjailNamespace *namespace; | ||
157 | unsigned int namespace_n, node_m; | ||
119 | 158 | ||
159 | log_topo (topology); | ||
120 | 160 | ||
121 | // if (strstr (hello, "60002") != NULL) | 161 | hkey = GNUNET_new (struct GNUNET_ShortHashCode); |
122 | if (2 == num) | 162 | if (topology->nodes_x >= num) |
123 | { | 163 | { |
124 | addr = "tcp-192.168.15.2:60002"; | 164 | |
125 | // peer_id = "F2F3X9G1YNCTXKK7A4J6M4ZM4BBSKC9DEXZVHCWQ475M0C7PNWCG"; | 165 | GNUNET_CRYPTO_hash (&num, sizeof(num), &hc); |
166 | memcpy (hkey, | ||
167 | &hc, | ||
168 | sizeof (*hkey)); | ||
169 | node = GNUNET_CONTAINER_multishortmap_get (topology->map_globals, | ||
170 | hkey); | ||
126 | } | 171 | } |
127 | else | 172 | else |
128 | { | 173 | { |
129 | addr = "tcp-192.168.15.1:60002"; | 174 | namespace_n = (unsigned int) floor ((num - topology->nodes_x) |
130 | // peer_id = "4TTC9WBSVP9RJT6DVEZ7E0TDW7TQXC11NR1EMR2F8ARS87WZ2730"; | 175 | / topology->nodes_m); |
176 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
177 | "num: %u nodes_x: %u nodes_m: %u namespace_n: %u\n", | ||
178 | num, | ||
179 | topology->nodes_x, | ||
180 | topology->nodes_m, | ||
181 | namespace_n); | ||
182 | hkey = GNUNET_new (struct GNUNET_ShortHashCode); | ||
183 | GNUNET_CRYPTO_hash (&namespace_n, sizeof(namespace_n), &hc); | ||
184 | memcpy (hkey, | ||
185 | &hc, | ||
186 | sizeof (*hkey)); | ||
187 | namespace = GNUNET_CONTAINER_multishortmap_get (topology->map_namespaces, | ||
188 | hkey); | ||
189 | node_m = num - topology->nodes_x - topology->nodes_m * (namespace_n - 1); | ||
190 | hkey = GNUNET_new (struct GNUNET_ShortHashCode); | ||
191 | GNUNET_CRYPTO_hash (&node_m, sizeof(node_m), &hc); | ||
192 | memcpy (hkey, | ||
193 | &hc, | ||
194 | sizeof (*hkey)); | ||
195 | node = GNUNET_CONTAINER_multishortmap_get (namespace->nodes, | ||
196 | hkey); | ||
131 | } | 197 | } |
132 | 198 | ||
133 | priv_key = GNUNET_TESTING_hostkey_get (tl_system, | ||
134 | num, | ||
135 | other); | ||
136 | 199 | ||
137 | GNUNET_CRYPTO_eddsa_key_get_public (priv_key, | 200 | return node->node_connections_head; |
138 | pub_key); | 201 | } |
139 | 202 | ||
140 | /*GNUNET_CRYPTO_eddsa_public_key_from_string (peer_id, | ||
141 | strlen (peer_id), | ||
142 | &peer->public_key);*/ | ||
143 | 203 | ||
144 | peer->public_key = *pub_key; | 204 | static unsigned int |
205 | calculate_num (struct GNUNET_TESTING_NodeConnection *node_connection, | ||
206 | struct GNUNET_TESTING_NetjailTopology *topology) | ||
207 | { | ||
208 | unsigned int n, m, num; | ||
145 | 209 | ||
146 | LOG (GNUNET_ERROR_TYPE_ERROR, | 210 | n = node_connection->namespace_n; |
147 | "num: %u id: %s pub_key %s\n", | 211 | m = node_connection->node_n; |
148 | num, | 212 | |
149 | GNUNET_i2s_full (id), | 213 | if (0 == n) |
150 | GNUNET_CRYPTO_eddsa_public_key_to_string (pub_key)); | 214 | num = m; |
151 | 215 | else | |
152 | cps->id = peer; | 216 | num = (n - 1) * topology->nodes_m + m + topology->nodes_x; |
153 | 217 | ||
154 | // 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. | 218 | return num; |
155 | // --------------------------------------------- | 219 | } |
156 | /*peer2_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->peer2_label); | 220 | |
157 | GNUNET_TRANSPORT_get_trait_peer_id (peer2_cmd, | 221 | |
158 | &id); | 222 | static char * |
159 | GNUNET_TRANSPORT_get_trait_hello (peer2_cmd, | 223 | get_address (struct GNUNET_TESTING_NodeConnection *connection, |
160 | &hello); | 224 | char *prefix) |
161 | GNUNET_TRANSPORT_get_trait_hello_size (peer2_cmd, | 225 | { |
162 | &hello_size); | 226 | struct GNUNET_TESTING_NetjailNode *node; |
163 | 227 | char *addr; | |
164 | addr = GNUNET_HELLO_extract_address (hello, | 228 | |
165 | *hello_size, | 229 | node = connection->node; |
166 | id, | 230 | if (connection->namespace_n == node->namespace_n) |
167 | &nt, | 231 | { |
168 | &t);*/ | 232 | if (0 == strcmp (PREFIX_TCP, prefix)) |
169 | 233 | { | |
170 | // ---------------------------------------------- | 234 | |
171 | 235 | GNUNET_asprintf (&addr, | |
172 | 236 | CONNECT_ADDRESS_TEMPLATE_TCP, | |
173 | GNUNET_TRANSPORT_application_validate (ah, | 237 | connection->node_n); |
174 | peer, | 238 | } |
175 | nt, | 239 | else if (0 == strcmp (PREFIX_UDP, prefix)) |
176 | addr); | 240 | { |
241 | GNUNET_asprintf (&addr, | ||
242 | CONNECT_ADDRESS_TEMPLATE_UDP, | ||
243 | connection->node_n); | ||
244 | } | ||
245 | else | ||
246 | { | ||
247 | GNUNET_break (0); | ||
248 | } | ||
249 | } | ||
250 | else | ||
251 | { | ||
252 | if (0 == strcmp (PREFIX_TCP, prefix)) | ||
253 | { | ||
254 | |||
255 | GNUNET_asprintf (&addr, | ||
256 | ROUTER_CONNECT_ADDRESS_TEMPLATE_TCP, | ||
257 | connection->namespace_n); | ||
258 | } | ||
259 | else if (0 == strcmp (PREFIX_UDP, prefix)) | ||
260 | { | ||
261 | GNUNET_asprintf (&addr, | ||
262 | ROUTER_CONNECT_ADDRESS_TEMPLATE_UDP, | ||
263 | connection->namespace_n); | ||
264 | } | ||
265 | else | ||
266 | { | ||
267 | GNUNET_break (0); | ||
268 | } | ||
269 | } | ||
270 | |||
271 | return addr; | ||
177 | } | 272 | } |
178 | 273 | ||
179 | 274 | ||
180 | /** | 275 | /** |
181 | * 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. | 276 | * The run method of this cmd will connect to peers. |
182 | * | 277 | * |
183 | */ | 278 | */ |
184 | static int | 279 | static void |
185 | connect_peers_finish (void *cls, | 280 | connect_peers_run (void *cls, |
186 | GNUNET_SCHEDULER_TaskCallback cont, | 281 | struct GNUNET_TESTING_Interpreter *is) |
187 | void *cont_cls) | ||
188 | { | 282 | { |
189 | struct ConnectPeersState *cps = cls; | 283 | struct ConnectPeersState *cps = cls; |
284 | const struct GNUNET_TESTING_Command *system_cmd; | ||
285 | struct GNUNET_TESTING_System *tl_system; | ||
286 | |||
287 | |||
190 | const struct GNUNET_TESTING_Command *peer1_cmd; | 288 | const struct GNUNET_TESTING_Command *peer1_cmd; |
191 | struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map; | 289 | struct GNUNET_TRANSPORT_ApplicationHandle *ah; |
192 | unsigned int ret; | 290 | struct GNUNET_PeerIdentity *peer; |
193 | struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode); | 291 | char *addr; |
194 | struct GNUNET_HashCode hc; | 292 | enum GNUNET_NetworkType nt = 0; |
195 | int node_number; | 293 | uint32_t num; |
294 | struct GNUNET_TESTING_NodeConnection *pos_connection; | ||
295 | struct GNUNET_TESTING_ADDRESS_PREFIX *pos_prefix; | ||
296 | unsigned int con_num = 0; | ||
196 | 297 | ||
197 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (cps->start_peer_label); | 298 | cps->is = is; |
198 | GNUNET_TRANSPORT_get_trait_connected_peers_map (peer1_cmd, | 299 | peer1_cmd = GNUNET_TESTING_interpreter_lookup_command (is, |
199 | &connected_peers_map); | 300 | cps->start_peer_label); |
301 | GNUNET_TRANSPORT_get_trait_application_handle (peer1_cmd, | ||
302 | &ah); | ||
200 | 303 | ||
201 | node_number = 1; | 304 | system_cmd = GNUNET_TESTING_interpreter_lookup_command (is, |
202 | GNUNET_CRYPTO_hash (&node_number, sizeof(node_number), &hc); | 305 | cps->create_label); |
306 | GNUNET_TESTING_get_trait_test_system (system_cmd, | ||
307 | &tl_system); | ||
308 | |||
309 | cps->tl_system = tl_system; | ||
203 | 310 | ||
204 | // TODO we need to store with a key identifying the netns node in the future. For now we have only one connecting node. | 311 | cps->node_connections_head = get_connections (cps->num, cps->topology); |
205 | memcpy (key, | ||
206 | &hc, | ||
207 | sizeof (*key)); | ||
208 | ret = GNUNET_CONTAINER_multishortmap_contains (connected_peers_map, | ||
209 | key); | ||
210 | 312 | ||
211 | if (GNUNET_YES == ret) | 313 | for (pos_connection = cps->node_connections_head; NULL != pos_connection; |
314 | pos_connection = pos_connection->next) | ||
212 | { | 315 | { |
213 | cont (cont_cls); | 316 | con_num++; |
317 | num = calculate_num (pos_connection, cps->topology); | ||
318 | for (pos_prefix = pos_connection->address_prefixes_head; NULL != pos_prefix; | ||
319 | pos_prefix = | ||
320 | pos_prefix->next) | ||
321 | { | ||
322 | |||
323 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
324 | "prefix: %s\n", | ||
325 | pos_prefix->address_prefix); | ||
326 | |||
327 | addr = get_address (pos_connection, pos_prefix->address_prefix); | ||
328 | |||
329 | peer = get_pub_key (num, tl_system); | ||
330 | |||
331 | LOG (GNUNET_ERROR_TYPE_ERROR, | ||
332 | "num: %u pub_key %s addr: %s\n", | ||
333 | num, | ||
334 | GNUNET_CRYPTO_eddsa_public_key_to_string (&(peer->public_key)), | ||
335 | addr); | ||
336 | |||
337 | cps->id = peer; | ||
338 | |||
339 | GNUNET_TRANSPORT_application_validate (ah, | ||
340 | peer, | ||
341 | nt, | ||
342 | addr); | ||
343 | } | ||
214 | } | 344 | } |
215 | 345 | cps->con_num = con_num; | |
216 | GNUNET_free (key); | ||
217 | return ret; | ||
218 | } | 346 | } |
219 | 347 | ||
220 | 348 | ||
221 | /** | 349 | /** |
222 | * Trait function of this cmd does nothing. | 350 | * Callback from start peer cmd for signaling a peer got connected. |
223 | * | 351 | * |
224 | */ | 352 | */ |
225 | static int | 353 | static void * |
226 | connect_peers_traits (void *cls, | 354 | notify_connect (void *cls, |
227 | const void **ret, | 355 | const struct GNUNET_PeerIdentity *peer, |
228 | const char *trait, | 356 | struct GNUNET_MQ_Handle *mq) |
229 | unsigned int index) | ||
230 | { | 357 | { |
231 | return GNUNET_OK; | 358 | struct ConnectPeersState *cps = cls; |
359 | struct GNUNET_PeerIdentity *peer_connection; | ||
360 | unsigned int con_num = 0; | ||
361 | struct GNUNET_TESTING_NodeConnection *pos_connection; | ||
362 | unsigned int num; | ||
363 | void *ret = NULL; | ||
364 | |||
365 | for (pos_connection = cps->node_connections_head; NULL != pos_connection; | ||
366 | pos_connection = pos_connection->next) | ||
367 | { | ||
368 | num = calculate_num (pos_connection, cps->topology); | ||
369 | peer_connection = get_pub_key (num, cps->tl_system); | ||
370 | if (0 == GNUNET_memcmp (peer, | ||
371 | peer_connection)) | ||
372 | con_num++; | ||
373 | } | ||
374 | |||
375 | |||
376 | if (cps->con_num == con_num) | ||
377 | { | ||
378 | GNUNET_TESTING_async_finish (&cps->ac); | ||
379 | } | ||
380 | return ret; | ||
232 | } | 381 | } |
233 | 382 | ||
234 | 383 | ||
@@ -237,8 +386,7 @@ connect_peers_traits (void *cls, | |||
237 | * | 386 | * |
238 | */ | 387 | */ |
239 | static void | 388 | static void |
240 | connect_peers_cleanup (void *cls, | 389 | connect_peers_cleanup (void *cls) |
241 | const struct GNUNET_TESTING_Command *cmd) | ||
242 | { | 390 | { |
243 | struct ConnectPeersState *cps = cls; | 391 | struct ConnectPeersState *cps = cls; |
244 | 392 | ||
@@ -248,17 +396,57 @@ connect_peers_cleanup (void *cls, | |||
248 | 396 | ||
249 | 397 | ||
250 | /** | 398 | /** |
251 | * Create command. | 399 | * This function prepares an array with traits. |
400 | * | ||
401 | */ | ||
402 | static int | ||
403 | connect_peers_traits (void *cls, | ||
404 | const void **ret, | ||
405 | const char *trait, | ||
406 | unsigned int index) | ||
407 | { | ||
408 | struct StartPeerState *cps = cls; | ||
409 | struct GNUNET_TESTING_Trait traits[] = { | ||
410 | { | ||
411 | .index = 0, | ||
412 | .trait_name = "state", | ||
413 | .ptr = (const void *) cps, | ||
414 | }, | ||
415 | GNUNET_TESTING_trait_end () | ||
416 | }; | ||
417 | return GNUNET_TESTING_get_trait (traits, | ||
418 | ret, | ||
419 | trait, | ||
420 | index); | ||
421 | } | ||
422 | |||
423 | |||
424 | /** | ||
425 | * Function to get the trait with the struct ConnectPeersState. | ||
426 | * | ||
427 | * @param[out] sps struct ConnectPeersState. | ||
428 | * @return #GNUNET_OK if no error occurred, #GNUNET_SYSERR otherwise. | ||
252 | * | 429 | * |
253 | * @param label name for command. | ||
254 | * @param start_peer_label Label of the cmd to start a peer. | ||
255 | * @return command. | ||
256 | */ | 430 | */ |
431 | int | ||
432 | GNUNET_TESTING_get_trait_connect_peer_state ( | ||
433 | const struct GNUNET_TESTING_Command *cmd, | ||
434 | struct ConnectPeersState **cps) | ||
435 | { | ||
436 | return cmd->traits (cmd->cls, | ||
437 | (const void **) cps, | ||
438 | "state", | ||
439 | (unsigned int) 0); | ||
440 | } | ||
441 | |||
442 | |||
257 | struct GNUNET_TESTING_Command | 443 | struct GNUNET_TESTING_Command |
258 | GNUNET_TRANSPORT_cmd_connect_peers (const char *label, | 444 | GNUNET_TRANSPORT_cmd_connect_peers (const char *label, |
259 | const char *start_peer_label, | 445 | const char *start_peer_label, |
260 | const char *create_label, | 446 | const char *create_label, |
261 | uint32_t num) | 447 | uint32_t num, |
448 | struct GNUNET_TESTING_NetjailTopology * | ||
449 | topology) | ||
262 | { | 450 | { |
263 | struct ConnectPeersState *cps; | 451 | struct ConnectPeersState *cps; |
264 | 452 | ||
@@ -266,16 +454,19 @@ GNUNET_TRANSPORT_cmd_connect_peers (const char *label, | |||
266 | cps->start_peer_label = start_peer_label; | 454 | cps->start_peer_label = start_peer_label; |
267 | cps->num = num; | 455 | cps->num = num; |
268 | cps->create_label = create_label; | 456 | cps->create_label = create_label; |
457 | cps->topology = topology; | ||
458 | cps->notify_connect = ¬ify_connect; | ||
269 | 459 | ||
270 | 460 | { | |
271 | struct GNUNET_TESTING_Command cmd = { | 461 | struct GNUNET_TESTING_Command cmd = { |
272 | .cls = cps, | 462 | .cls = cps, |
273 | .label = label, | 463 | .label = label, |
274 | .run = &connect_peers_run, | 464 | .run = &connect_peers_run, |
275 | .finish = &connect_peers_finish, | 465 | .ac = &cps->ac, |
276 | .cleanup = &connect_peers_cleanup, | 466 | .cleanup = &connect_peers_cleanup, |
277 | .traits = &connect_peers_traits | 467 | .traits = &connect_peers_traits |
278 | }; | 468 | }; |
279 | 469 | ||
280 | return cmd; | 470 | return cmd; |
471 | } | ||
281 | } | 472 | } |