aboutsummaryrefslogtreecommitdiff
path: root/src/transport/transport_api_cmd_start_peer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/transport/transport_api_cmd_start_peer.c')
-rw-r--r--src/transport/transport_api_cmd_start_peer.c78
1 files changed, 45 insertions, 33 deletions
diff --git a/src/transport/transport_api_cmd_start_peer.c b/src/transport/transport_api_cmd_start_peer.c
index 44fc68807..dc19f10eb 100644
--- a/src/transport/transport_api_cmd_start_peer.c
+++ b/src/transport/transport_api_cmd_start_peer.c
@@ -51,7 +51,6 @@ hello_iter_cb (void *cb_cls,
51 const char *emsg) 51 const char *emsg)
52{ 52{
53 struct StartPeerState *sps = cb_cls; 53 struct StartPeerState *sps = cb_cls;
54
55 if (NULL == record) 54 if (NULL == record)
56 { 55 {
57 sps->pic = NULL; 56 sps->pic = NULL;
@@ -66,7 +65,7 @@ hello_iter_cb (void *cb_cls,
66 65
67 GNUNET_PEERSTORE_iterate_cancel (sps->pic); 66 GNUNET_PEERSTORE_iterate_cancel (sps->pic);
68 sps->pic = NULL; 67 sps->pic = NULL;
69 sps->finished = GNUNET_YES; 68 GNUNET_TESTING_async_finish (&sps->ac);
70} 69}
71 70
72 71
@@ -122,7 +121,7 @@ notify_connect (void *cls,
122 struct StartPeerState *sps = cls; 121 struct StartPeerState *sps = cls;
123 struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode); 122 struct GNUNET_ShortHashCode *key = GNUNET_new (struct GNUNET_ShortHashCode);
124 struct GNUNET_HashCode hc; 123 struct GNUNET_HashCode hc;
125 int node_number; 124 struct GNUNET_CRYPTO_EddsaPublicKey public_key = peer->public_key;
126 125
127 void *ret = NULL; 126 void *ret = NULL;
128 127
@@ -133,9 +132,7 @@ notify_connect (void *cls,
133 sps->no, 132 sps->no,
134 GNUNET_i2s (&sps->id)); 133 GNUNET_i2s (&sps->id));
135 134
136 // TODO we need to store with a key identifying the netns node in the future. For now we have only one connecting node. 135 GNUNET_CRYPTO_hash (&public_key, sizeof(public_key), &hc);
137 node_number = 1;
138 GNUNET_CRYPTO_hash (&node_number, sizeof(node_number), &hc);
139 136
140 137
141 memcpy (key, 138 memcpy (key,
@@ -147,6 +144,11 @@ notify_connect (void *cls,
147 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 144 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
148 145
149 GNUNET_free (key); 146 GNUNET_free (key);
147
148 sps->notify_connect (cls,
149 peer,
150 mq);
151
150 // TODO what does the handler function need? 152 // TODO what does the handler function need?
151 return ret; 153 return ret;
152} 154}
@@ -167,7 +169,8 @@ start_peer_run (void *cls,
167 struct GNUNET_TESTING_System *tl_system; 169 struct GNUNET_TESTING_System *tl_system;
168 char *home; 170 char *home;
169 char *transport_unix_path; 171 char *transport_unix_path;
170 char *communicator_unix_path; 172 char *tcp_communicator_unix_path;
173 char *udp_communicator_unix_path;
171 char *bindto; 174 char *bindto;
172 175
173 if (GNUNET_NO == GNUNET_DISK_file_test (sps->cfgname)) 176 if (GNUNET_NO == GNUNET_DISK_file_test (sps->cfgname))
@@ -192,7 +195,11 @@ start_peer_run (void *cls,
192 "$GNUNET_RUNTIME_DIR/tng-p%u.sock", 195 "$GNUNET_RUNTIME_DIR/tng-p%u.sock",
193 sps->no); 196 sps->no);
194 197
195 GNUNET_asprintf (&communicator_unix_path, 198 GNUNET_asprintf (&tcp_communicator_unix_path,
199 "$GNUNET_RUNTIME_DIR/tcp-comm-p%u.sock",
200 sps->no);
201
202 GNUNET_asprintf (&udp_communicator_unix_path,
196 "$GNUNET_RUNTIME_DIR/tcp-comm-p%u.sock", 203 "$GNUNET_RUNTIME_DIR/tcp-comm-p%u.sock",
197 sps->no); 204 sps->no);
198 205
@@ -200,6 +207,9 @@ start_peer_run (void *cls,
200 "%s:60002", 207 "%s:60002",
201 sps->node_ip); 208 sps->node_ip);
202 209
210 LOG (GNUNET_ERROR_TYPE_ERROR,
211 "node_ip %s\n",
212 bindto);
203 213
204 GNUNET_CONFIGURATION_set_value_string (sps->cfg, "PATHS", "GNUNET_TEST_HOME", 214 GNUNET_CONFIGURATION_set_value_string (sps->cfg, "PATHS", "GNUNET_TEST_HOME",
205 home); 215 home);
@@ -208,9 +218,15 @@ start_peer_run (void *cls,
208 GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-tcp", 218 GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-tcp",
209 "BINDTO", 219 "BINDTO",
210 bindto); 220 bindto);
221 GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-udp",
222 "BINDTO",
223 bindto);
211 GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-tcp", 224 GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-tcp",
212 "UNIXPATH", 225 "UNIXPATH",
213 communicator_unix_path); 226 tcp_communicator_unix_path);
227 GNUNET_CONFIGURATION_set_value_string (sps->cfg, "communicator-udp",
228 "UNIXPATH",
229 udp_communicator_unix_path);
214 230
215 system_cmd = GNUNET_TESTING_interpreter_lookup_command (is, 231 system_cmd = GNUNET_TESTING_interpreter_lookup_command (is,
216 sps->system_label); 232 sps->system_label);
@@ -417,10 +433,9 @@ start_peer_traits (void *cls,
417 * 433 *
418 */ 434 */
419int 435int
420GNUNET_TRANSPORT_get_trait_state (const struct 436GNUNET_TRANSPORT_get_trait_state (
421 GNUNET_TESTING_Command 437 const struct GNUNET_TESTING_Command *cmd,
422 *cmd, 438 struct StartPeerState **sps)
423 struct StartPeerState **sps)
424{ 439{
425 return cmd->traits (cmd->cls, 440 return cmd->traits (cmd->cls,
426 (const void **) sps, 441 (const void **) sps,
@@ -481,7 +496,8 @@ GNUNET_TRANSPORT_get_trait_connected_peers_map (const struct
481 GNUNET_TESTING_Command 496 GNUNET_TESTING_Command
482 *cmd, 497 *cmd,
483 struct 498 struct
484 GNUNET_CONTAINER_MultiShortmap * 499 GNUNET_CONTAINER_MultiShortmap
500 *
485 * 501 *
486 connected_peers_map) 502 connected_peers_map)
487{ 503{
@@ -545,12 +561,11 @@ GNUNET_TRANSPORT_get_trait_peer_id (const struct
545struct GNUNET_TESTING_Command 561struct GNUNET_TESTING_Command
546GNUNET_TRANSPORT_cmd_start_peer (const char *label, 562GNUNET_TRANSPORT_cmd_start_peer (const char *label,
547 const char *system_label, 563 const char *system_label,
548 char *m, 564 uint32_t no,
549 char *n,
550 char *local_m,
551 char *node_ip, 565 char *node_ip,
552 struct GNUNET_MQ_MessageHandler *handlers, 566 struct GNUNET_MQ_MessageHandler *handlers,
553 const char *cfgname) 567 const char *cfgname,
568 GNUNET_TRANSPORT_NotifyConnect notify_connect)
554{ 569{
555 struct StartPeerState *sps; 570 struct StartPeerState *sps;
556 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map = 571 struct GNUNET_CONTAINER_MultiShortmap *connected_peers_map =
@@ -558,14 +573,12 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label,
558 unsigned int i; 573 unsigned int i;
559 574
560 sps = GNUNET_new (struct StartPeerState); 575 sps = GNUNET_new (struct StartPeerState);
561 sps->m = m; 576 sps->no = no;
562 sps->n = n;
563 sps->local_m = local_m;
564 sps->no = (atoi (n) - 1) * atoi (sps->local_m) + atoi (m);
565 sps->system_label = system_label; 577 sps->system_label = system_label;
566 sps->connected_peers_map = connected_peers_map; 578 sps->connected_peers_map = connected_peers_map;
567 sps->cfgname = cfgname; 579 sps->cfgname = cfgname;
568 sps->node_ip = node_ip; 580 sps->node_ip = node_ip;
581 sps->notify_connect = notify_connect;
569 582
570 if (NULL != handlers) 583 if (NULL != handlers)
571 { 584 {
@@ -578,15 +591,14 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label,
578 i * sizeof(struct GNUNET_MQ_MessageHandler)); 591 i * sizeof(struct GNUNET_MQ_MessageHandler));
579 } 592 }
580 593
581 { 594 struct GNUNET_TESTING_Command cmd = {
582 struct GNUNET_TESTING_Command cmd = { 595 .cls = sps,
583 .cls = sps, 596 .label = label,
584 .label = label, 597 .run = &start_peer_run,
585 .run = &start_peer_run, 598 .ac = &sps->ac,
586 .cleanup = &start_peer_cleanup, 599 .cleanup = &start_peer_cleanup,
587 .traits = &start_peer_traits 600 .traits = &start_peer_traits
588 }; 601 };
589 602
590 return cmd; 603 return cmd;
591 }
592} 604}