aboutsummaryrefslogtreecommitdiff
path: root/src/stream
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-09-05 13:32:43 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-09-05 13:32:43 +0000
commit59367a58d0a8b2882c396a681146589a53b5b96e (patch)
tree6b7eef0d09e28e02eb33e083453db8c64e69b6ca /src/stream
parent72019c4552826af52db08dbaffa4f7e366ab096e (diff)
downloadgnunet-59367a58d0a8b2882c396a681146589a53b5b96e.tar.gz
gnunet-59367a58d0a8b2882c396a681146589a53b5b96e.zip
fix
Diffstat (limited to 'src/stream')
-rw-r--r--src/stream/test_stream_2peers_new.c74
1 files changed, 51 insertions, 23 deletions
diff --git a/src/stream/test_stream_2peers_new.c b/src/stream/test_stream_2peers_new.c
index 937500d1f..d597ac5c3 100644
--- a/src/stream/test_stream_2peers_new.c
+++ b/src/stream/test_stream_2peers_new.c
@@ -515,12 +515,59 @@ stream_connect (void)
515{ 515{
516 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stream listen open successful\n"); 516 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stream listen open successful\n");
517 peer2.op = GNUNET_TESTBED_service_connect (&peer2, peer2.peer, "stream", 517 peer2.op = GNUNET_TESTBED_service_connect (&peer2, peer2.peer, "stream",
518 NULL, NULL,
518 stream_ca, stream_da, &peer2); 519 stream_ca, stream_da, &peer2);
519 setup_state = PEER2_STREAM_CONNECT; 520 setup_state = PEER2_STREAM_CONNECT;
520} 521}
521 522
522 523
523/** 524/**
525 * Callback to be called when the requested peer information is available
526 *
527 * @param cb_cls the closure from GNUNET_TETSBED_peer_get_information()
528 * @param op the operation this callback corresponds to
529 * @param pinfo the result; will be NULL if the operation has failed
530 * @param emsg error message if the operation has failed; will be NULL if the
531 * operation is successfull
532 */
533static void
534peerinfo_cb (void *cb_cls, struct GNUNET_TESTBED_Operation *op_,
535 const struct GNUNET_TESTBED_PeerInformation *pinfo,
536 const char *emsg)
537{
538 GNUNET_assert (NULL == emsg);
539 GNUNET_assert (op == op_);
540 switch (setup_state)
541 {
542 case PEER1_GET_IDENTITY:
543 memcpy (&peer1.our_id, pinfo->result.id,
544 sizeof (struct GNUNET_PeerIdentity));
545 GNUNET_TESTBED_operation_done (op);
546 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 1 id: %s\n", GNUNET_i2s
547 (&peer1.our_id));
548 op = GNUNET_TESTBED_peer_get_information (peer2.peer,
549 GNUNET_TESTBED_PIT_IDENTITY,
550 &peerinfo_cb, NULL);
551 setup_state = PEER2_GET_IDENTITY;
552 break;
553 case PEER2_GET_IDENTITY:
554 memcpy (&peer2.our_id, pinfo->result.id,
555 sizeof (struct GNUNET_PeerIdentity));
556 GNUNET_TESTBED_operation_done (op);
557 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 2 id: %s\n", GNUNET_i2s
558 (&peer2.our_id));
559 peer1.op = GNUNET_TESTBED_service_connect (&peer1, peer1.peer, "stream",
560 NULL, NULL, stream_ca,
561 stream_da, &peer1);
562 setup_state = PEER1_STREAM_CONNECT;
563 break;
564 default:
565 GNUNET_assert (0);
566 }
567}
568
569
570/**
524 * Controller event callback 571 * Controller event callback
525 * 572 *
526 * @param cls NULL 573 * @param cls NULL
@@ -537,32 +584,13 @@ controller_event_cb (void *cls,
537 GNUNET_TESTBED_operation_done (op); 584 GNUNET_TESTBED_operation_done (op);
538 /* Get the peer identity and configuration of peers */ 585 /* Get the peer identity and configuration of peers */
539 op = GNUNET_TESTBED_peer_get_information (peer1.peer, 586 op = GNUNET_TESTBED_peer_get_information (peer1.peer,
540 GNUNET_TESTBED_PIT_IDENTITY); 587 GNUNET_TESTBED_PIT_IDENTITY,
588 &peerinfo_cb, NULL);
541 setup_state = PEER1_GET_IDENTITY; 589 setup_state = PEER1_GET_IDENTITY;
542 break; 590 break;
543 case GNUNET_TESTBED_ET_OPERATION_FINISHED: 591 case GNUNET_TESTBED_ET_OPERATION_FINISHED:
544 switch (setup_state) 592 switch (setup_state)
545 { 593 {
546 case PEER1_GET_IDENTITY:
547 memcpy (&peer1.our_id, event->details.operation_finished.op_result.pid,
548 sizeof (struct GNUNET_PeerIdentity));
549 GNUNET_TESTBED_operation_done (op);
550 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 1 id: %s\n", GNUNET_i2s
551 (&peer1.our_id));
552 op = GNUNET_TESTBED_peer_get_information (peer2.peer,
553 GNUNET_TESTBED_PIT_IDENTITY);
554 setup_state = PEER2_GET_IDENTITY;
555 break;
556 case PEER2_GET_IDENTITY:
557 memcpy (&peer2.our_id, event->details.operation_finished.op_result.pid,
558 sizeof (struct GNUNET_PeerIdentity));
559 GNUNET_TESTBED_operation_done (op);
560 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 2 id: %s\n", GNUNET_i2s
561 (&peer2.our_id));
562 peer1.op = GNUNET_TESTBED_service_connect (&peer1, peer1.peer, "stream",
563 stream_ca, stream_da, &peer1);
564 setup_state = PEER1_STREAM_CONNECT;
565 break;
566 case PEER1_STREAM_CONNECT: 594 case PEER1_STREAM_CONNECT:
567 case PEER2_STREAM_CONNECT: 595 case PEER2_STREAM_CONNECT:
568 GNUNET_assert (NULL == event->details.operation_finished.emsg); 596 GNUNET_assert (NULL == event->details.operation_finished.emsg);
@@ -593,7 +621,7 @@ test_master (void *cls, unsigned int num_peers,
593 GNUNET_assert (NULL != peers[1]); 621 GNUNET_assert (NULL != peers[1]);
594 peer1.peer = peers[0]; 622 peer1.peer = peers[0];
595 peer2.peer = peers[1]; 623 peer2.peer = peers[1];
596 op = GNUNET_TESTBED_overlay_connect (NULL, peer2.peer, peer1.peer); 624 op = GNUNET_TESTBED_overlay_connect (NULL, NULL, NULL, peer2.peer, peer1.peer);
597 setup_state = INIT; 625 setup_state = INIT;
598 abort_task = 626 abort_task =
599 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply 627 GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply