gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r23659 - gnunet/src/stream


From: gnunet
Subject: [GNUnet-SVN] r23659 - gnunet/src/stream
Date: Wed, 5 Sep 2012 15:32:43 +0200

Author: harsha
Date: 2012-09-05 15:32:43 +0200 (Wed, 05 Sep 2012)
New Revision: 23659

Modified:
   gnunet/src/stream/test_stream_2peers_new.c
Log:
fix

Modified: gnunet/src/stream/test_stream_2peers_new.c
===================================================================
--- gnunet/src/stream/test_stream_2peers_new.c  2012-09-05 13:20:47 UTC (rev 
23658)
+++ gnunet/src/stream/test_stream_2peers_new.c  2012-09-05 13:32:43 UTC (rev 
23659)
@@ -515,12 +515,59 @@
 { 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Stream listen open successful\n");
   peer2.op = GNUNET_TESTBED_service_connect (&peer2, peer2.peer, "stream",
+                                            NULL, NULL,
                                              stream_ca, stream_da, &peer2);
   setup_state = PEER2_STREAM_CONNECT;
 }
 
 
 /**
+ * Callback to be called when the requested peer information is available
+ *
+ * @param cb_cls the closure from GNUNET_TETSBED_peer_get_information()
+ * @param op the operation this callback corresponds to
+ * @param pinfo the result; will be NULL if the operation has failed
+ * @param emsg error message if the operation has failed; will be NULL if the
+ *          operation is successfull
+ */
+static void 
+peerinfo_cb (void *cb_cls, struct GNUNET_TESTBED_Operation *op_,
+            const struct GNUNET_TESTBED_PeerInformation *pinfo,
+            const char *emsg)
+{
+  GNUNET_assert (NULL == emsg);
+  GNUNET_assert (op == op_);
+  switch (setup_state)
+    {
+    case PEER1_GET_IDENTITY:
+      memcpy (&peer1.our_id, pinfo->result.id, 
+             sizeof (struct GNUNET_PeerIdentity));
+      GNUNET_TESTBED_operation_done (op);
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 1 id: %s\n", GNUNET_i2s
+                  (&peer1.our_id));
+      op = GNUNET_TESTBED_peer_get_information (peer2.peer,
+                                                GNUNET_TESTBED_PIT_IDENTITY,
+                                               &peerinfo_cb, NULL);
+      setup_state = PEER2_GET_IDENTITY;
+      break;
+    case PEER2_GET_IDENTITY:
+      memcpy (&peer2.our_id, pinfo->result.id,
+              sizeof (struct GNUNET_PeerIdentity));
+      GNUNET_TESTBED_operation_done (op);
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 2 id: %s\n", GNUNET_i2s
+                  (&peer2.our_id));
+      peer1.op = GNUNET_TESTBED_service_connect (&peer1, peer1.peer, "stream",
+                                                NULL, NULL, stream_ca,
+                                                stream_da, &peer1);
+      setup_state = PEER1_STREAM_CONNECT;
+      break;
+    default:
+      GNUNET_assert (0);
+    }
+}
+
+
+/**
  * Controller event callback
  *
  * @param cls NULL
@@ -537,32 +584,13 @@
     GNUNET_TESTBED_operation_done (op);
     /* Get the peer identity and configuration of peers */
     op = GNUNET_TESTBED_peer_get_information (peer1.peer,
-                                              GNUNET_TESTBED_PIT_IDENTITY);
+                                              GNUNET_TESTBED_PIT_IDENTITY,
+                                             &peerinfo_cb, NULL);
     setup_state = PEER1_GET_IDENTITY;
     break;
   case GNUNET_TESTBED_ET_OPERATION_FINISHED:
     switch (setup_state)
-    {
-    case PEER1_GET_IDENTITY:
-      memcpy (&peer1.our_id, event->details.operation_finished.op_result.pid,
-              sizeof (struct GNUNET_PeerIdentity));
-      GNUNET_TESTBED_operation_done (op);
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 1 id: %s\n", GNUNET_i2s
-                  (&peer1.our_id));
-      op = GNUNET_TESTBED_peer_get_information (peer2.peer,
-                                                GNUNET_TESTBED_PIT_IDENTITY);
-      setup_state = PEER2_GET_IDENTITY;
-      break;
-    case PEER2_GET_IDENTITY:
-      memcpy (&peer2.our_id, event->details.operation_finished.op_result.pid,
-              sizeof (struct GNUNET_PeerIdentity));
-      GNUNET_TESTBED_operation_done (op);
-      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer 2 id: %s\n", GNUNET_i2s
-                  (&peer2.our_id));
-      peer1.op = GNUNET_TESTBED_service_connect (&peer1, peer1.peer, "stream",
-                                                 stream_ca, stream_da, &peer1);
-      setup_state = PEER1_STREAM_CONNECT;
-      break;
+    {    
     case PEER1_STREAM_CONNECT:
     case PEER2_STREAM_CONNECT:
       GNUNET_assert (NULL == event->details.operation_finished.emsg);
@@ -593,7 +621,7 @@
   GNUNET_assert (NULL != peers[1]);
   peer1.peer = peers[0];
   peer2.peer = peers[1];
-  op = GNUNET_TESTBED_overlay_connect (NULL, peer2.peer, peer1.peer);
+  op = GNUNET_TESTBED_overlay_connect (NULL, NULL, NULL, peer2.peer, 
peer1.peer);
   setup_state = INIT;
   abort_task =
     GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply




reply via email to

[Prev in Thread] Current Thread [Next in Thread]