aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-09-26 13:39:45 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-09-26 13:39:45 +0000
commitbb64dc55f0a281d1e95965cf27cb72a9897daf9e (patch)
treef49ad72946c1785e9473760ab7b430cd6621e1a8 /src
parent5a753cbdb8bcf30257ac96d3abb720671a2728fd (diff)
downloadgnunet-bb64dc55f0a281d1e95965cf27cb72a9897daf9e.tar.gz
gnunet-bb64dc55f0a281d1e95965cf27cb72a9897daf9e.zip
towards generic topology creation
Diffstat (limited to 'src')
-rw-r--r--src/testbed/testbed.conf.in1
-rw-r--r--src/testbed/testbed_api.c12
-rw-r--r--src/testbed/testbed_api.h5
-rw-r--r--src/testbed/testbed_api_topology.c106
4 files changed, 116 insertions, 8 deletions
diff --git a/src/testbed/testbed.conf.in b/src/testbed/testbed.conf.in
index 94a8b21a5..5f5585c04 100644
--- a/src/testbed/testbed.conf.in
+++ b/src/testbed/testbed.conf.in
@@ -12,3 +12,4 @@ UNIX_MATCH_UID = YES
12UNIX_MATCH_GID = YES 12UNIX_MATCH_GID = YES
13MAX_PARALLEL_OPERATIONS = 1000 13MAX_PARALLEL_OPERATIONS = 1000
14MAX_PARALLEL_SERVICE_CONNECTIONS = 1000 14MAX_PARALLEL_SERVICE_CONNECTIONS = 1000
15MAX_PARALLEL_TOPOLOGY_CONFIG_OPERATIONS = 5 \ No newline at end of file
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c
index f12c0cf4a..be8c68fce 100644
--- a/src/testbed/testbed_api.c
+++ b/src/testbed/testbed_api.c
@@ -1281,6 +1281,7 @@ GNUNET_TESTBED_controller_connect (const struct GNUNET_CONFIGURATION_Handle
1281 const char *controller_hostname; 1281 const char *controller_hostname;
1282 unsigned long long max_parallel_operations; 1282 unsigned long long max_parallel_operations;
1283 unsigned long long max_parallel_service_connections; 1283 unsigned long long max_parallel_service_connections;
1284 unsigned long long max_parallel_topology_config_operations;
1284 1285
1285 if (GNUNET_OK != 1286 if (GNUNET_OK !=
1286 GNUNET_CONFIGURATION_get_value_number (cfg, "testbed", 1287 GNUNET_CONFIGURATION_get_value_number (cfg, "testbed",
@@ -1298,6 +1299,14 @@ GNUNET_TESTBED_controller_connect (const struct GNUNET_CONFIGURATION_Handle
1298 GNUNET_break (0); 1299 GNUNET_break (0);
1299 return NULL; 1300 return NULL;
1300 } 1301 }
1302 if (GNUNET_OK !=
1303 GNUNET_CONFIGURATION_get_value_number (cfg, "testbed",
1304 "MAX_PARALLEL_TOPOLOGY_CONFIG_OPERATIONS",
1305 &max_parallel_topology_config_operations))
1306 {
1307 GNUNET_break (0);
1308 return NULL;
1309 }
1301 controller = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Controller)); 1310 controller = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Controller));
1302 controller->cc = cc; 1311 controller->cc = cc;
1303 controller->cc_cls = cc_cls; 1312 controller->cc_cls = cc_cls;
@@ -1333,6 +1342,9 @@ GNUNET_TESTBED_controller_connect (const struct GNUNET_CONFIGURATION_Handle
1333 controller->opq_parallel_service_connections = 1342 controller->opq_parallel_service_connections =
1334 GNUNET_TESTBED_operation_queue_create_ ((unsigned int) 1343 GNUNET_TESTBED_operation_queue_create_ ((unsigned int)
1335 max_parallel_service_connections); 1344 max_parallel_service_connections);
1345 controller->opq_parallel_topology_config_operations=
1346 GNUNET_TESTBED_operation_queue_create_ ((unsigned int)
1347 max_parallel_service_connections);
1336 controller_hostname = GNUNET_TESTBED_host_get_hostname_ (host); 1348 controller_hostname = GNUNET_TESTBED_host_get_hostname_ (host);
1337 if (NULL == controller_hostname) 1349 if (NULL == controller_hostname)
1338 controller_hostname = "127.0.0.1"; 1350 controller_hostname = "127.0.0.1";
diff --git a/src/testbed/testbed_api.h b/src/testbed/testbed_api.h
index a021e2130..9165c7c24 100644
--- a/src/testbed/testbed_api.h
+++ b/src/testbed/testbed_api.h
@@ -287,6 +287,11 @@ struct GNUNET_TESTBED_Controller
287 struct OperationQueue *opq_parallel_service_connections; 287 struct OperationQueue *opq_parallel_service_connections;
288 288
289 /** 289 /**
290 * Operation queue for simultaneous topology configuration operations
291 */
292 struct OperationQueue *opq_parallel_topology_config_operations;
293
294 /**
290 * The operation id counter. use current value and increment 295 * The operation id counter. use current value and increment
291 */ 296 */
292 uint64_t operation_counter; 297 uint64_t operation_counter;
diff --git a/src/testbed/testbed_api_topology.c b/src/testbed/testbed_api_topology.c
index e21a2dbf2..45209fb65 100644
--- a/src/testbed/testbed_api_topology.c
+++ b/src/testbed/testbed_api_topology.c
@@ -25,6 +25,64 @@
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "gnunet_testbed_service.h" 27#include "gnunet_testbed_service.h"
28#include "testbed_api.h"
29#include "testbed_api_peers.h"
30#include "testbed_api_operations.h"
31
32
33/**
34 * Representation of an overlay link
35 */
36struct OverlayLink
37{
38 /**
39 * Peer A
40 */
41 struct GNUNET_TESTBED_Peer *A;
42
43 /**
44 * Peer B
45 */
46 struct GNUNET_TESTBED_Peer *B;
47
48};
49
50
51/**
52 * Context information for topology operations
53 */
54struct TopologyContext
55{
56 /**
57 * An array of links
58 */
59 struct OverlayLink *link_array;
60
61};
62
63
64/**
65 * Function called when a overlay connect operation is ready
66 *
67 * @param cls the closure from GNUNET_TESTBED_operation_create_()
68 */
69static void
70opstart_overlay_configure_topology (void *cls)
71{
72 GNUNET_break (0);
73}
74
75
76/**
77 * Callback which will be called when overlay connect operation is released
78 *
79 * @param cls the closure from GNUNET_TESTBED_operation_create_()
80 */
81static void
82oprelease_overlay_configure_topology (void *cls)
83{
84 GNUNET_break (0);
85}
28 86
29 87
30/** 88/**
@@ -87,17 +145,43 @@ GNUNET_TESTBED_underlay_configure_topology (void *op_cls,
87 * @param va topology-specific options 145 * @param va topology-specific options
88 * @return handle to the operation, NULL if connecting these 146 * @return handle to the operation, NULL if connecting these
89 * peers is fundamentally not possible at this time (peers 147 * peers is fundamentally not possible at this time (peers
90 * not running or underlay disallows) 148 * not running or underlay disallows) or if num_peers is less than 2
91 */ 149 */
92struct GNUNET_TESTBED_Operation * 150struct GNUNET_TESTBED_Operation *
93GNUNET_TESTBED_overlay_configure_topology_va (void *op_cls, 151GNUNET_TESTBED_overlay_configure_topology_va (void *op_cls,
94 unsigned int num_peers, 152 unsigned int num_peers,
95 struct GNUNET_TESTBED_Peer *peers, 153 struct GNUNET_TESTBED_Peer **peers,
96 enum GNUNET_TESTBED_TopologyOption 154 enum GNUNET_TESTBED_TopologyOption
97 topo, va_list va) 155 topo, va_list va)
98{ 156{
99 GNUNET_break (0); 157 struct OverlayLink *link_array;
100 return NULL; 158 struct GNUNET_TESTBED_Operation *op;
159 struct GNUNET_TESTBED_Controller *c;
160 unsigned int p;
161
162 if (num_peers < 2)
163 return NULL;
164 c = peers[0]->controller;
165 switch (topo)
166 {
167 case GNUNET_TESTBED_TOPOLOGY_LINE:
168 link_array = GNUNET_malloc (sizeof (struct OverlayLink) * (num_peers - 1));
169 for (p=1; p < num_peers; p++)
170 {
171 link_array[p-1].A = peers[p-1];
172 link_array[p-1].B = peers[p];
173 }
174 break;
175 default:
176 GNUNET_break (0);
177 return NULL;
178 }
179 op = GNUNET_TESTBED_operation_create_ (link_array,
180 &opstart_overlay_configure_topology,
181 &oprelease_overlay_configure_topology);
182 GNUNET_TESTBED_operation_queue_insert_
183 (c->opq_parallel_topology_config_operations, op);
184 return op;
101} 185}
102 186
103 187
@@ -113,16 +197,22 @@ GNUNET_TESTBED_overlay_configure_topology_va (void *op_cls,
113 * @param ... topology-specific options 197 * @param ... topology-specific options
114 * @return handle to the operation, NULL if connecting these 198 * @return handle to the operation, NULL if connecting these
115 * peers is fundamentally not possible at this time (peers 199 * peers is fundamentally not possible at this time (peers
116 * not running or underlay disallows) 200 * not running or underlay disallows) or if num_peers is less than 2
117 */ 201 */
118struct GNUNET_TESTBED_Operation * 202struct GNUNET_TESTBED_Operation *
119GNUNET_TESTBED_overlay_configure_topology (void *op_cls, unsigned int num_peers, 203GNUNET_TESTBED_overlay_configure_topology (void *op_cls, unsigned int num_peers,
120 struct GNUNET_TESTBED_Peer *peers, 204 struct GNUNET_TESTBED_Peer **peers,
121 enum GNUNET_TESTBED_TopologyOption 205 enum GNUNET_TESTBED_TopologyOption
122 topo, ...) 206 topo, ...)
123{ 207{
124 GNUNET_break (0); 208 struct GNUNET_TESTBED_Operation *op;
125 return NULL; 209 va_list vargs;
210
211 va_start (vargs, topo);
212 op = GNUNET_TESTBED_overlay_configure_topology_va (op_cls, num_peers, peers,
213 topo, vargs);
214 va_end (vargs);
215 return op;
126} 216}
127 217
128/* end of testbed_api_topology.c */ 218/* end of testbed_api_topology.c */