gnunet-svn
[Top][All Lists]
Advanced

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

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


From: gnunet
Subject: [GNUnet-SVN] r24016 - gnunet/src/testbed
Date: Wed, 26 Sep 2012 15:39:45 +0200

Author: harsha
Date: 2012-09-26 15:39:45 +0200 (Wed, 26 Sep 2012)
New Revision: 24016

Modified:
   gnunet/src/testbed/testbed.conf.in
   gnunet/src/testbed/testbed_api.c
   gnunet/src/testbed/testbed_api.h
   gnunet/src/testbed/testbed_api_topology.c
Log:
towards generic topology creation

Modified: gnunet/src/testbed/testbed.conf.in
===================================================================
--- gnunet/src/testbed/testbed.conf.in  2012-09-26 13:34:09 UTC (rev 24015)
+++ gnunet/src/testbed/testbed.conf.in  2012-09-26 13:39:45 UTC (rev 24016)
@@ -12,3 +12,4 @@
 UNIX_MATCH_GID = YES
 MAX_PARALLEL_OPERATIONS = 1000
 MAX_PARALLEL_SERVICE_CONNECTIONS = 1000
+MAX_PARALLEL_TOPOLOGY_CONFIG_OPERATIONS = 5
\ No newline at end of file

Modified: gnunet/src/testbed/testbed_api.c
===================================================================
--- gnunet/src/testbed/testbed_api.c    2012-09-26 13:34:09 UTC (rev 24015)
+++ gnunet/src/testbed/testbed_api.c    2012-09-26 13:39:45 UTC (rev 24016)
@@ -1281,6 +1281,7 @@
   const char *controller_hostname;
   unsigned long long max_parallel_operations;
   unsigned long long max_parallel_service_connections;
+  unsigned long long max_parallel_topology_config_operations;
 
   if (GNUNET_OK !=
       GNUNET_CONFIGURATION_get_value_number (cfg, "testbed",
@@ -1298,6 +1299,14 @@
     GNUNET_break (0);
     return NULL;
   }
+  if (GNUNET_OK !=
+      GNUNET_CONFIGURATION_get_value_number (cfg, "testbed",
+                                             
"MAX_PARALLEL_TOPOLOGY_CONFIG_OPERATIONS",
+                                             
&max_parallel_topology_config_operations))
+  {
+    GNUNET_break (0);
+    return NULL;
+  }
   controller = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Controller));
   controller->cc = cc;
   controller->cc_cls = cc_cls;
@@ -1333,6 +1342,9 @@
   controller->opq_parallel_service_connections =
       GNUNET_TESTBED_operation_queue_create_ ((unsigned int)
                                               
max_parallel_service_connections);
+  controller->opq_parallel_topology_config_operations=
+      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-09-26 13:34:09 UTC (rev 24015)
+++ gnunet/src/testbed/testbed_api.h    2012-09-26 13:39:45 UTC (rev 24016)
@@ -287,6 +287,11 @@
   struct OperationQueue *opq_parallel_service_connections;
 
   /**
+   * Operation queue for simultaneous topology configuration operations
+   */
+  struct OperationQueue *opq_parallel_topology_config_operations;
+
+  /**
    * The operation id counter. use current value and increment
    */
   uint64_t operation_counter;

Modified: gnunet/src/testbed/testbed_api_topology.c
===================================================================
--- gnunet/src/testbed/testbed_api_topology.c   2012-09-26 13:34:09 UTC (rev 
24015)
+++ gnunet/src/testbed/testbed_api_topology.c   2012-09-26 13:39:45 UTC (rev 
24016)
@@ -25,9 +25,67 @@
  */
 #include "platform.h"
 #include "gnunet_testbed_service.h"
+#include "testbed_api.h"
+#include "testbed_api_peers.h"
+#include "testbed_api_operations.h"
 
 
 /**
+ * Representation of an overlay link
+ */
+struct OverlayLink
+{
+  /**
+   * Peer A
+   */
+  struct GNUNET_TESTBED_Peer *A;
+
+  /**
+   * Peer B
+   */
+  struct GNUNET_TESTBED_Peer *B;
+
+};
+
+
+/**
+ * Context information for topology operations
+ */
+struct TopologyContext
+{
+  /**
+   * An array of links
+   */
+  struct OverlayLink *link_array;
+  
+};
+
+
+/**
+ * Function called when a overlay connect operation is ready
+ *
+ * @param cls the closure from GNUNET_TESTBED_operation_create_()
+ */
+static void
+opstart_overlay_configure_topology (void *cls)
+{
+  GNUNET_break (0);
+}
+
+
+/**
+ * Callback which will be called when overlay connect operation is released
+ *
+ * @param cls the closure from GNUNET_TESTBED_operation_create_()
+ */
+static void
+oprelease_overlay_configure_topology (void *cls)
+{
+  GNUNET_break (0);
+}
+
+
+/**
  * Configure overall network topology to have a particular shape.
  *
  * @param op_cls closure argument to give with the operation event
@@ -87,17 +145,43 @@
  * @param va topology-specific options
  * @return handle to the operation, NULL if connecting these
  *         peers is fundamentally not possible at this time (peers
- *         not running or underlay disallows)
+ *         not running or underlay disallows) or if num_peers is less than 2
  */
 struct GNUNET_TESTBED_Operation *
 GNUNET_TESTBED_overlay_configure_topology_va (void *op_cls,
                                               unsigned int num_peers,
-                                              struct GNUNET_TESTBED_Peer 
*peers,
+                                              struct GNUNET_TESTBED_Peer 
**peers,
                                               enum 
GNUNET_TESTBED_TopologyOption
                                               topo, va_list va)
 {
-  GNUNET_break (0);
-  return NULL;
+  struct OverlayLink *link_array;
+  struct GNUNET_TESTBED_Operation *op;
+  struct GNUNET_TESTBED_Controller *c;
+  unsigned int p;
+
+  if (num_peers < 2)
+    return NULL;
+  c = peers[0]->controller;
+  switch (topo)
+  {
+  case GNUNET_TESTBED_TOPOLOGY_LINE:
+    link_array = GNUNET_malloc (sizeof (struct OverlayLink) * (num_peers - 1));
+    for (p=1; p < num_peers; p++)
+    {
+      link_array[p-1].A = peers[p-1];
+      link_array[p-1].B = peers[p];
+    }
+    break;
+  default:
+    GNUNET_break (0);
+    return NULL;
+  }
+  op = GNUNET_TESTBED_operation_create_ (link_array,
+                                        &opstart_overlay_configure_topology,
+                                        &oprelease_overlay_configure_topology);
+  GNUNET_TESTBED_operation_queue_insert_
+      (c->opq_parallel_topology_config_operations, op);
+  return op;
 }
 
 
@@ -113,16 +197,22 @@
  * @param ... topology-specific options
  * @return handle to the operation, NULL if connecting these
  *         peers is fundamentally not possible at this time (peers
- *         not running or underlay disallows)
+ *         not running or underlay disallows) or if num_peers is less than 2
  */
 struct GNUNET_TESTBED_Operation *
 GNUNET_TESTBED_overlay_configure_topology (void *op_cls, unsigned int 
num_peers,
-                                           struct GNUNET_TESTBED_Peer *peers,
+                                           struct GNUNET_TESTBED_Peer **peers,
                                            enum GNUNET_TESTBED_TopologyOption
                                            topo, ...)
 {
-  GNUNET_break (0);
-  return NULL;
+  struct GNUNET_TESTBED_Operation *op;
+  va_list vargs;
+
+  va_start (vargs, topo);
+  op = GNUNET_TESTBED_overlay_configure_topology_va (op_cls, num_peers, peers,
+                                                    topo, vargs);
+  va_end (vargs);
+  return op;
 }
 
 /* end of testbed_api_topology.c */




reply via email to

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