aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/testbed/testbed_api.c12
-rw-r--r--src/testbed/testbed_api.h11
-rw-r--r--src/testbed/testbed_api_peers.c37
-rw-r--r--src/testbed/testbed_api_peers.h12
-rw-r--r--src/testbed/testbed_api_services.c88
5 files changed, 150 insertions, 10 deletions
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c
index 42167a5cb..1a779c3c1 100644
--- a/src/testbed/testbed_api.c
+++ b/src/testbed/testbed_api.c
@@ -1160,6 +1160,7 @@ GNUNET_TESTBED_controller_connect (const struct GNUNET_CONFIGURATION_Handle *cfg
1160 struct GNUNET_TESTBED_InitMessage *msg; 1160 struct GNUNET_TESTBED_InitMessage *msg;
1161 const char *controller_hostname; 1161 const char *controller_hostname;
1162 unsigned long long max_parallel_operations; 1162 unsigned long long max_parallel_operations;
1163 unsigned long long max_parallel_service_connections;
1163 1164
1164 if (GNUNET_OK != 1165 if (GNUNET_OK !=
1165 GNUNET_CONFIGURATION_get_value_number (cfg, "testbed", 1166 GNUNET_CONFIGURATION_get_value_number (cfg, "testbed",
@@ -1169,6 +1170,14 @@ GNUNET_TESTBED_controller_connect (const struct GNUNET_CONFIGURATION_Handle *cfg
1169 GNUNET_break (0); 1170 GNUNET_break (0);
1170 return NULL; 1171 return NULL;
1171 } 1172 }
1173 if (GNUNET_OK !=
1174 GNUNET_CONFIGURATION_get_value_number (cfg, "testbed",
1175 "MAX_PARALLEL_SERVICE_CONNECTIONS",
1176 &max_parallel_service_connections))
1177 {
1178 GNUNET_break (0);
1179 return NULL;
1180 }
1172 controller = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Controller)); 1181 controller = GNUNET_malloc (sizeof (struct GNUNET_TESTBED_Controller));
1173 controller->cc = cc; 1182 controller->cc = cc;
1174 controller->cc_cls = cc_cls; 1183 controller->cc_cls = cc_cls;
@@ -1201,6 +1210,9 @@ GNUNET_TESTBED_controller_connect (const struct GNUNET_CONFIGURATION_Handle *cfg
1201 controller->opq_parallel_operations = 1210 controller->opq_parallel_operations =
1202 GNUNET_TESTBED_operation_queue_create_ ((unsigned int) 1211 GNUNET_TESTBED_operation_queue_create_ ((unsigned int)
1203 max_parallel_operations); 1212 max_parallel_operations);
1213 controller->opq_parallel_service_connections =
1214 GNUNET_TESTBED_operation_queue_create_ ((unsigned int)
1215 max_parallel_service_connections);
1204 controller_hostname = GNUNET_TESTBED_host_get_hostname_ (host); 1216 controller_hostname = GNUNET_TESTBED_host_get_hostname_ (host);
1205 if (NULL == controller_hostname) 1217 if (NULL == controller_hostname)
1206 controller_hostname = "127.0.0.1"; 1218 controller_hostname = "127.0.0.1";
diff --git a/src/testbed/testbed_api.h b/src/testbed/testbed_api.h
index 89e6800d7..09fb52569 100644
--- a/src/testbed/testbed_api.h
+++ b/src/testbed/testbed_api.h
@@ -27,6 +27,7 @@
27#ifndef TESTBED_API_H 27#ifndef TESTBED_API_H
28#define TESTBED_API_H 28#define TESTBED_API_H
29 29
30#include "gnunet_testbed_service.h"
30 31
31/** 32/**
32 * Enumeration of operations 33 * Enumeration of operations
@@ -73,6 +74,11 @@ enum OperationType
73 */ 74 */
74 OP_LINK_CONTROLLERS, 75 OP_LINK_CONTROLLERS,
75 76
77 /**
78 * Service connect operation
79 */
80 OP_SERVICE_CONNECT
81
76 }; 82 };
77 83
78 84
@@ -280,6 +286,11 @@ struct GNUNET_TESTBED_Controller
280 struct OperationQueue *opq_parallel_operations; 286 struct OperationQueue *opq_parallel_operations;
281 287
282 /** 288 /**
289 * Operation queue for simultaneous service connections
290 */
291 struct OperationQueue *opq_parallel_service_connections;
292
293 /**
283 * The operation id counter. use current value and increment 294 * The operation id counter. use current value and increment
284 */ 295 */
285 uint64_t operation_counter; 296 uint64_t operation_counter;
diff --git a/src/testbed/testbed_api_peers.c b/src/testbed/testbed_api_peers.c
index 25362df0d..9ef1829a7 100644
--- a/src/testbed/testbed_api_peers.c
+++ b/src/testbed/testbed_api_peers.c
@@ -223,6 +223,32 @@ oprelease_peer_stop (void *cls)
223 223
224 224
225/** 225/**
226 * Generate PeerGetConfigurationMessage
227 *
228 * @param peer_id the id of the peer whose information we have to get
229 * @param operation_id the ip of the operation that should be represented in
230 * the message
231 * @param
232 * @return the PeerGetConfigurationMessage
233 */
234struct GNUNET_TESTBED_PeerGetConfigurationMessage *
235GNUNET_TESTBED_generate_peergetconfig_msg_ (uint32_t peer_id,
236 uint64_t operation_id)
237{
238 struct GNUNET_TESTBED_PeerGetConfigurationMessage *msg;
239
240 msg = GNUNET_malloc (sizeof (struct
241 GNUNET_TESTBED_PeerGetConfigurationMessage));
242 msg->header.size = htons
243 (sizeof (struct GNUNET_TESTBED_PeerGetConfigurationMessage));
244 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_GETPEERCONFIG);
245 msg->peer_id = htonl (peer_id);
246 msg->operation_id = GNUNET_htonll (operation_id);
247 return msg;
248}
249
250
251/**
226 * Function called when a peer get information operation is ready 252 * Function called when a peer get information operation is ready
227 * 253 *
228 * @param cls the closure from GNUNET_TESTBED_operation_create_() 254 * @param cls the closure from GNUNET_TESTBED_operation_create_()
@@ -237,13 +263,8 @@ opstart_peer_getinfo (void *cls)
237 data = opc->data; 263 data = opc->data;
238 GNUNET_assert (NULL != data); 264 GNUNET_assert (NULL != data);
239 opc->state = OPC_STATE_STARTED; 265 opc->state = OPC_STATE_STARTED;
240 msg = GNUNET_malloc (sizeof (struct 266 msg = GNUNET_TESTBED_generate_peergetconfig_msg_ (data->peer->unique_id,
241 GNUNET_TESTBED_PeerGetConfigurationMessage)); 267 opc->id);
242 msg->header.size = htons
243 (sizeof (struct GNUNET_TESTBED_PeerGetConfigurationMessage));
244 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_GETPEERCONFIG);
245 msg->peer_id = htonl (data->peer->unique_id);
246 msg->operation_id = GNUNET_htonll (opc->id);
247 GNUNET_CONTAINER_DLL_insert_tail (opc->c->ocq_head, opc->c->ocq_tail, opc); 268 GNUNET_CONTAINER_DLL_insert_tail (opc->c->ocq_head, opc->c->ocq_tail, opc);
248 GNUNET_TESTBED_queue_message_ (opc->c, &msg->header); 269 GNUNET_TESTBED_queue_message_ (opc->c, &msg->header);
249} 270}
@@ -534,7 +555,7 @@ GNUNET_TESTBED_peer_get_information (struct GNUNET_TESTBED_Peer *peer,
534 opc->type = OP_PEER_INFO; 555 opc->type = OP_PEER_INFO;
535 opc->id = opc->c->operation_counter++; 556 opc->id = opc->c->operation_counter++;
536 opc->op = GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_getinfo, 557 opc->op = GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_getinfo,
537 &oprelease_peer_getinfo); 558 &oprelease_peer_getinfo);
538 GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations, 559 GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations,
539 opc->op); 560 opc->op);
540 return opc->op; 561 return opc->op;
diff --git a/src/testbed/testbed_api_peers.h b/src/testbed/testbed_api_peers.h
index 17db0d3b4..9256bf54f 100644
--- a/src/testbed/testbed_api_peers.h
+++ b/src/testbed/testbed_api_peers.h
@@ -239,6 +239,18 @@ GNUNET_TESTBED_peer_create_with_id_ (uint32_t unique_id,
239 void *cls); 239 void *cls);
240 240
241 241
242/**
243 * Generate PeerGetConfigurationMessage
244 *
245 * @param peer_id the id of the peer whose information we have to get
246 * @param operation_id the ip of the operation that should be represented in
247 * the message
248 * @param
249 * @return the PeerGetConfigurationMessage
250 */
251struct GNUNET_TESTBED_PeerGetConfigurationMessage *
252GNUNET_TESTBED_generate_peergetconfig_msg_ (uint32_t peer_id,
253 uint64_t operation_id);
242 254
243#endif 255#endif
244/* end of testbed_api_peers.h */ 256/* end of testbed_api_peers.h */
diff --git a/src/testbed/testbed_api_services.c b/src/testbed/testbed_api_services.c
index 34de0fd84..9fbb92797 100644
--- a/src/testbed/testbed_api_services.c
+++ b/src/testbed/testbed_api_services.c
@@ -24,7 +24,73 @@
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26#include "platform.h" 26#include "platform.h"
27#include "testbed_api.h"
27#include "testbed_api_peers.h" 28#include "testbed_api_peers.h"
29#include "testbed_api_operations.h"
30
31struct ServiceConnectData
32{
33 /**
34 * helper function callback to establish the connection
35 */
36 GNUNET_TESTBED_ConnectAdapter ca;
37
38 /**
39 * helper function callback to close the connection
40 */
41 GNUNET_TESTBED_DisconnectAdapter da;
42
43 /**
44 * Closure to the above callbacks
45 */
46 void *cada_cls;
47
48 /**
49 * Service name
50 */
51 char *service_name;
52
53 /**
54 * Closure for operation event
55 */
56 void *op_cls;
57
58};
59
60
61/**
62 * Context information for forwarded operation used in service connect
63 */
64struct SCFOContext
65{
66
67};
68
69
70
71/**
72 * Function called when a service connect operation is ready
73 *
74 * @param cls the closure from GNUNET_TESTBED_operation_create_()
75 */
76static void
77opstart_service_connect (void *cls)
78{
79 GNUNET_break (0);
80}
81
82
83/**
84 * Callback which will be called when service connect type operation is
85 * released
86 *
87 * @param cls the closure from GNUNET_TESTBED_operation_create_()
88 */
89static void
90oprelease_service_connect (void *cls)
91{
92 GNUNET_break (0);
93}
28 94
29 95
30/** 96/**
@@ -54,8 +120,26 @@ GNUNET_TESTBED_service_connect (void *op_cls,
54 GNUNET_TESTBED_DisconnectAdapter da, 120 GNUNET_TESTBED_DisconnectAdapter da,
55 void *cada_cls) 121 void *cada_cls)
56{ 122{
57 GNUNET_break (0); 123 struct OperationContext *opc;
58 return NULL; 124 struct ServiceConnectData *data;
125
126 data = GNUNET_malloc (sizeof (struct ServiceConnectData));
127 data->ca = ca;
128 data->da = da;
129 data->cada_cls = cada_cls;
130 data->op_cls = op_cls;
131 opc = GNUNET_malloc (sizeof (struct OperationContext));
132 opc->data = data;
133 opc->c = peer->controller;
134 opc->id = peer->controller->operation_counter++;
135 opc->type = OP_SERVICE_CONNECT;
136 opc->op = GNUNET_TESTBED_operation_create_ (opc, &opstart_service_connect,
137 &oprelease_service_connect);
138 GNUNET_TESTBED_operation_queue_insert_
139 (opc->c->opq_parallel_service_connections, opc->op);
140 GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations,
141 opc->op);
142 return opc->op;
59} 143}
60 144
61/* end of testbed_api_services.c */ 145/* end of testbed_api_services.c */