gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r23420 - gnunet/src/testbed


From: gnunet
Subject: [GNUnet-SVN] r23420 - gnunet/src/testbed
Date: Sat, 25 Aug 2012 13:50:39 +0200

Author: harsha
Date: 2012-08-25 13:50:39 +0200 (Sat, 25 Aug 2012)
New Revision: 23420

Modified:
   gnunet/src/testbed/testbed_api.c
   gnunet/src/testbed/testbed_api.h
   gnunet/src/testbed/testbed_api_peers.c
   gnunet/src/testbed/testbed_api_peers.h
   gnunet/src/testbed/testbed_api_services.c
Log:
towards implementing service_connect

Modified: gnunet/src/testbed/testbed_api.c
===================================================================
--- gnunet/src/testbed/testbed_api.c    2012-08-25 10:29:17 UTC (rev 23419)
+++ gnunet/src/testbed/testbed_api.c    2012-08-25 11:50:39 UTC (rev 23420)
@@ -1160,6 +1160,7 @@
   struct GNUNET_TESTBED_InitMessage *msg;
   const char *controller_hostname;
   unsigned long long max_parallel_operations;
+  unsigned long long max_parallel_service_connections;
 
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_number (cfg, "testbed",
@@ -1169,6 +1170,14 @@
     GNUNET_break (0);
     return NULL;
   }
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_get_value_number (cfg, "testbed",
+                                             
"MAX_PARALLEL_SERVICE_CONNECTIONS",
+                                             
&max_parallel_service_connections))
+  {
+    GNUNET_break (0);
+    return NULL;
+  }
   controller = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Controller));
   controller->cc = cc;
   controller->cc_cls = cc_cls;
@@ -1201,6 +1210,9 @@
   controller->opq_parallel_operations =
     GNUNET_TESTBED_operation_queue_create_ ((unsigned int)
                                             max_parallel_operations);
+  controller->opq_parallel_service_connections =
+    GNUNET_TESTBED_operation_queue_create_ ((unsigned int)
+                                            max_parallel_service_connections);
   controller_hostname = GNUNET_TESTBED_host_get_hostname_ (host);
   if (NULL == controller_hostname)
     controller_hostname = "127.0.0.1";

Modified: gnunet/src/testbed/testbed_api.h
===================================================================
--- gnunet/src/testbed/testbed_api.h    2012-08-25 10:29:17 UTC (rev 23419)
+++ gnunet/src/testbed/testbed_api.h    2012-08-25 11:50:39 UTC (rev 23420)
@@ -27,6 +27,7 @@
 #ifndef TESTBED_API_H
 #define TESTBED_API_H
 
+#include "gnunet_testbed_service.h"
 
 /**
  * Enumeration of operations
@@ -73,6 +74,11 @@
      */
     OP_LINK_CONTROLLERS,
 
+    /**
+     * Service connect operation
+     */
+    OP_SERVICE_CONNECT
+
   };
 
 
@@ -280,6 +286,11 @@
   struct OperationQueue *opq_parallel_operations;
 
   /**
+   * Operation queue for simultaneous service connections
+   */
+  struct OperationQueue *opq_parallel_service_connections;
+
+  /**
    * The operation id counter. use current value and increment
    */
   uint64_t operation_counter;

Modified: gnunet/src/testbed/testbed_api_peers.c
===================================================================
--- gnunet/src/testbed/testbed_api_peers.c      2012-08-25 10:29:17 UTC (rev 
23419)
+++ gnunet/src/testbed/testbed_api_peers.c      2012-08-25 11:50:39 UTC (rev 
23420)
@@ -223,6 +223,32 @@
 
 
 /**
+ * Generate PeerGetConfigurationMessage
+ *
+ * @param peer_id the id of the peer whose information we have to get
+ * @param operation_id the ip of the operation that should be represented in
+ *          the message
+ * @param 
+ * @return the PeerGetConfigurationMessage
+ */
+struct GNUNET_TESTBED_PeerGetConfigurationMessage *
+GNUNET_TESTBED_generate_peergetconfig_msg_ (uint32_t peer_id,
+                                            uint64_t operation_id)
+{
+  struct GNUNET_TESTBED_PeerGetConfigurationMessage *msg;
+
+  msg = GNUNET_malloc (sizeof (struct
+                               GNUNET_TESTBED_PeerGetConfigurationMessage));
+  msg->header.size = htons
+    (sizeof (struct GNUNET_TESTBED_PeerGetConfigurationMessage));
+  msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_GETPEERCONFIG);
+  msg->peer_id = htonl (peer_id);
+  msg->operation_id = GNUNET_htonll (operation_id);
+  return msg;
+}
+
+
+/**
  * Function called when a peer get information operation is ready
  *
  * @param cls the closure from GNUNET_TESTBED_operation_create_()
@@ -237,13 +263,8 @@
   data = opc->data;
   GNUNET_assert (NULL != data);
   opc->state = OPC_STATE_STARTED;
-  msg = GNUNET_malloc (sizeof (struct
-                               GNUNET_TESTBED_PeerGetConfigurationMessage));
-  msg->header.size = htons
-    (sizeof (struct GNUNET_TESTBED_PeerGetConfigurationMessage));
-  msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_GETPEERCONFIG);
-  msg->peer_id = htonl (data->peer->unique_id);
-  msg->operation_id = GNUNET_htonll (opc->id);
+  msg = GNUNET_TESTBED_generate_peergetconfig_msg_ (data->peer->unique_id,
+                                                    opc->id);  
   GNUNET_CONTAINER_DLL_insert_tail (opc->c->ocq_head, opc->c->ocq_tail, opc);
   GNUNET_TESTBED_queue_message_ (opc->c, &msg->header);
 }
@@ -534,7 +555,7 @@
   opc->type = OP_PEER_INFO;
   opc->id = opc->c->operation_counter++;
   opc->op = GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_getinfo,
-                                             &oprelease_peer_getinfo);
+                                              &oprelease_peer_getinfo);
   GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations,
                                           opc->op);
   return opc->op;

Modified: gnunet/src/testbed/testbed_api_peers.h
===================================================================
--- gnunet/src/testbed/testbed_api_peers.h      2012-08-25 10:29:17 UTC (rev 
23419)
+++ gnunet/src/testbed/testbed_api_peers.h      2012-08-25 11:50:39 UTC (rev 
23420)
@@ -239,6 +239,18 @@
                                     void *cls);
 
 
+/**
+ * Generate PeerGetConfigurationMessage
+ *
+ * @param peer_id the id of the peer whose information we have to get
+ * @param operation_id the ip of the operation that should be represented in
+ *          the message
+ * @param 
+ * @return the PeerGetConfigurationMessage
+ */
+struct GNUNET_TESTBED_PeerGetConfigurationMessage *
+GNUNET_TESTBED_generate_peergetconfig_msg_ (uint32_t peer_id,
+                                            uint64_t operation_id);
 
 #endif
 /* end of testbed_api_peers.h */

Modified: gnunet/src/testbed/testbed_api_services.c
===================================================================
--- gnunet/src/testbed/testbed_api_services.c   2012-08-25 10:29:17 UTC (rev 
23419)
+++ gnunet/src/testbed/testbed_api_services.c   2012-08-25 11:50:39 UTC (rev 
23420)
@@ -24,10 +24,76 @@
  * @author Christian Grothoff
  */
 #include "platform.h"
+#include "testbed_api.h"
 #include "testbed_api_peers.h"
+#include "testbed_api_operations.h"
 
+struct ServiceConnectData
+{
+  /**
+   * helper function callback to establish the connection
+   */
+  GNUNET_TESTBED_ConnectAdapter ca;
 
+  /**
+   * helper function callback to close the connection
+   */
+  GNUNET_TESTBED_DisconnectAdapter da;
+
+  /**
+   * Closure to the above callbacks
+   */
+  void *cada_cls;
+
+  /**
+   * Service name
+   */
+  char *service_name;
+  
+  /**
+   * Closure for operation event
+   */
+  void *op_cls;
+
+};
+
+
 /**
+ * Context information for forwarded operation used in service connect
+ */
+struct SCFOContext
+{
+  
+};
+
+
+
+/**
+ * Function called when a service connect operation is ready
+ *
+ * @param cls the closure from GNUNET_TESTBED_operation_create_()
+ */
+static void 
+opstart_service_connect (void *cls)
+{
+  GNUNET_break (0);
+}
+
+
+/**
+ * Callback which will be called when service connect type operation is
+ * released
+ *
+ * @param cls the closure from GNUNET_TESTBED_operation_create_()
+ */
+static void 
+oprelease_service_connect (void *cls)
+{
+  GNUNET_break (0); 
+}
+
+
+/**
  * Connect to a service offered by the given peer.  Will ensure that
  * the request is queued to not overwhelm our ability to create and
  * maintain connections with other systems.  The actual service
@@ -54,8 +120,26 @@
                                GNUNET_TESTBED_DisconnectAdapter da,
                                void *cada_cls)
 {
-  GNUNET_break (0);
-  return NULL;
+  struct OperationContext *opc;
+  struct ServiceConnectData *data;
+
+  data = GNUNET_malloc (sizeof (struct ServiceConnectData));
+  data->ca = ca;
+  data->da = da;
+  data->cada_cls = cada_cls;
+  data->op_cls = op_cls;  
+  opc = GNUNET_malloc (sizeof (struct OperationContext));
+  opc->data = data;
+  opc->c = peer->controller;
+  opc->id = peer->controller->operation_counter++;
+  opc->type = OP_SERVICE_CONNECT;
+  opc->op = GNUNET_TESTBED_operation_create_ (opc, &opstart_service_connect,
+                                              &oprelease_service_connect);
+  GNUNET_TESTBED_operation_queue_insert_
+    (opc->c->opq_parallel_service_connections, opc->op);
+  GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations,
+                                          opc->op);
+  return opc->op;
 }
 
 /* end of testbed_api_services.c */




reply via email to

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