aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/testbed_api_services.c
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-08-31 10:36:28 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-08-31 10:36:28 +0000
commita94a1861d123fe850d2ab5ae74cbb59b132a15ea (patch)
treea16d2518067d13f2463e83cd9dc66bdd6b733621 /src/testbed/testbed_api_services.c
parentd0c55c3ee57913977b1497ea0e6f20573820b206 (diff)
downloadgnunet-a94a1861d123fe850d2ab5ae74cbb59b132a15ea.tar.gz
gnunet-a94a1861d123fe850d2ab5ae74cbb59b132a15ea.zip
adhering to indentation standard
Diffstat (limited to 'src/testbed/testbed_api_services.c')
-rw-r--r--src/testbed/testbed_api_services.c90
1 files changed, 45 insertions, 45 deletions
diff --git a/src/testbed/testbed_api_services.c b/src/testbed/testbed_api_services.c
index ea7b50def..f37ada310 100644
--- a/src/testbed/testbed_api_services.c
+++ b/src/testbed/testbed_api_services.c
@@ -33,26 +33,26 @@
33 * States for Service connect operations 33 * States for Service connect operations
34 */ 34 */
35enum State 35enum State
36 { 36{
37 /** 37 /**
38 * Initial state 38 * Initial state
39 */ 39 */
40 INIT, 40 INIT,
41 41
42 /** 42 /**
43 * The configuration request has been sent 43 * The configuration request has been sent
44 */ 44 */
45 CFG_REQUEST_QUEUED, 45 CFG_REQUEST_QUEUED,
46 46
47 /** 47 /**
48 * connected to service 48 * connected to service
49 */ 49 */
50 SERVICE_CONNECTED, 50 SERVICE_CONNECTED,
51 51
52 /** 52 /**
53 * 53 *
54 */ 54 */
55 }; 55};
56 56
57 57
58/** 58/**
@@ -79,7 +79,7 @@ struct ServiceConnectData
79 * Service name 79 * Service name
80 */ 80 */
81 char *service_name; 81 char *service_name;
82 82
83 /** 83 /**
84 * Closure for operation event 84 * Closure for operation event
85 */ 85 */
@@ -114,7 +114,7 @@ struct ServiceConnectData
114 * State information 114 * State information
115 */ 115 */
116 enum State state; 116 enum State state;
117 117
118}; 118};
119 119
120 120
@@ -125,17 +125,16 @@ struct ServiceConnectData
125 * @param cls ServiceConnectData 125 * @param cls ServiceConnectData
126 * @param msg message received, NULL on timeout or fatal error 126 * @param msg message received, NULL on timeout or fatal error
127 */ 127 */
128static void 128static void
129configuration_receiver (void *cls, 129configuration_receiver (void *cls, const struct GNUNET_MessageHeader *msg)
130 const struct GNUNET_MessageHeader *msg)
131{ 130{
132 struct ServiceConnectData *data = cls; 131 struct ServiceConnectData *data = cls;
133 const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *imsg; 132 const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *imsg;
134 struct GNUNET_TESTBED_Controller *c; 133 struct GNUNET_TESTBED_Controller *c;
135 struct GNUNET_TESTBED_EventInformation info; 134 struct GNUNET_TESTBED_EventInformation info;
136 135
137 imsg = (const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *) 136 imsg =
138 msg; 137 (const struct GNUNET_TESTBED_PeerConfigurationInformationMessage *) msg;
139 data->cfg = GNUNET_TESTBED_get_config_from_peerinfo_msg_ (imsg); 138 data->cfg = GNUNET_TESTBED_get_config_from_peerinfo_msg_ (imsg);
140 data->op_result = data->ca (data->cada_cls, data->cfg); 139 data->op_result = data->ca (data->cada_cls, data->cfg);
141 info.type = GNUNET_TESTBED_ET_OPERATION_FINISHED; 140 info.type = GNUNET_TESTBED_ET_OPERATION_FINISHED;
@@ -146,9 +145,9 @@ configuration_receiver (void *cls,
146 info.details.operation_finished.op_result.generic = data->op_result; 145 info.details.operation_finished.op_result.generic = data->op_result;
147 c = data->peer->controller; 146 c = data->peer->controller;
148 data->state = SERVICE_CONNECTED; 147 data->state = SERVICE_CONNECTED;
149 if ((0 != (GNUNET_TESTBED_ET_OPERATION_FINISHED & c->event_mask)) 148 if ((0 != (GNUNET_TESTBED_ET_OPERATION_FINISHED & c->event_mask)) &&
150 && (NULL != c->cc)) 149 (NULL != c->cc))
151 c->cc (c->cc_cls, &info); 150 c->cc (c->cc_cls, &info);
152} 151}
153 152
154 153
@@ -157,23 +156,23 @@ configuration_receiver (void *cls,
157 * 156 *
158 * @param cls the closure from GNUNET_TESTBED_operation_create_() 157 * @param cls the closure from GNUNET_TESTBED_operation_create_()
159 */ 158 */
160static void 159static void
161opstart_service_connect (void *cls) 160opstart_service_connect (void *cls)
162{ 161{
163 struct ServiceConnectData *data = cls; 162 struct ServiceConnectData *data = cls;
164 struct GNUNET_TESTBED_PeerGetConfigurationMessage *msg; 163 struct GNUNET_TESTBED_PeerGetConfigurationMessage *msg;
165 struct GNUNET_TESTBED_Controller *c; 164 struct GNUNET_TESTBED_Controller *c;
166 uint64_t op_id; 165 uint64_t op_id;
167 166
168 GNUNET_assert (NULL != data); 167 GNUNET_assert (NULL != data);
169 GNUNET_assert (NULL != data->peer); 168 GNUNET_assert (NULL != data->peer);
170 c = data->peer->controller; 169 c = data->peer->controller;
171 op_id = c->operation_counter++; 170 op_id = c->operation_counter++;
172 msg = GNUNET_TESTBED_generate_peergetconfig_msg_ (data->peer->unique_id, 171 msg =
173 op_id); 172 GNUNET_TESTBED_generate_peergetconfig_msg_ (data->peer->unique_id, op_id);
174 data->opc = 173 data->opc =
175 GNUNET_TESTBED_forward_operation_msg_ (c, op_id, &msg->header, 174 GNUNET_TESTBED_forward_operation_msg_ (c, op_id, &msg->header,
176 &configuration_receiver, data); 175 &configuration_receiver, data);
177 GNUNET_free (msg); 176 GNUNET_free (msg);
178 data->state = CFG_REQUEST_QUEUED; 177 data->state = CFG_REQUEST_QUEUED;
179} 178}
@@ -185,7 +184,7 @@ opstart_service_connect (void *cls)
185 * 184 *
186 * @param cls the closure from GNUNET_TESTBED_operation_create_() 185 * @param cls the closure from GNUNET_TESTBED_operation_create_()
187 */ 186 */
188static void 187static void
189oprelease_service_connect (void *cls) 188oprelease_service_connect (void *cls)
190{ 189{
191 struct ServiceConnectData *data = cls; 190 struct ServiceConnectData *data = cls;
@@ -215,7 +214,7 @@ oprelease_service_connect (void *cls)
215 * maintain connections with other systems. The actual service 214 * maintain connections with other systems. The actual service
216 * handle is then returned via the 'op_result' member in the event 215 * handle is then returned via the 'op_result' member in the event
217 * callback. The 'ca' callback is used to create the connection 216 * callback. The 'ca' callback is used to create the connection
218 * when the time is right; the 'da' callback will be used to 217 * when the time is right; the 'da' callback will be used to
219 * destroy the connection (upon 'GNUNET_TESTBED_operation_done'). 218 * destroy the connection (upon 'GNUNET_TESTBED_operation_done').
220 * 'GNUNET_TESTBED_operation_cancel' can be used to abort this 219 * 'GNUNET_TESTBED_operation_cancel' can be used to abort this
221 * operation until the event callback has been called. 220 * operation until the event callback has been called.
@@ -229,12 +228,11 @@ oprelease_service_connect (void *cls)
229 * @return handle for the operation 228 * @return handle for the operation
230 */ 229 */
231struct GNUNET_TESTBED_Operation * 230struct GNUNET_TESTBED_Operation *
232GNUNET_TESTBED_service_connect (void *op_cls, 231GNUNET_TESTBED_service_connect (void *op_cls, struct GNUNET_TESTBED_Peer *peer,
233 struct GNUNET_TESTBED_Peer *peer, 232 const char *service_name,
234 const char *service_name, 233 GNUNET_TESTBED_ConnectAdapter ca,
235 GNUNET_TESTBED_ConnectAdapter ca, 234 GNUNET_TESTBED_DisconnectAdapter da,
236 GNUNET_TESTBED_DisconnectAdapter da, 235 void *cada_cls)
237 void *cada_cls)
238{ 236{
239 struct ServiceConnectData *data; 237 struct ServiceConnectData *data;
240 238
@@ -245,14 +243,16 @@ GNUNET_TESTBED_service_connect (void *op_cls,
245 data->op_cls = op_cls; 243 data->op_cls = op_cls;
246 data->peer = peer; 244 data->peer = peer;
247 data->state = INIT; 245 data->state = INIT;
248 data->operation = 246 data->operation =
249 GNUNET_TESTBED_operation_create_ (data, &opstart_service_connect, 247 GNUNET_TESTBED_operation_create_ (data, &opstart_service_connect,
250 &oprelease_service_connect); 248 &oprelease_service_connect);
251 GNUNET_TESTBED_operation_queue_insert_ 249 GNUNET_TESTBED_operation_queue_insert_ (peer->
252 (peer->controller->opq_parallel_service_connections, data->operation); 250 controller->opq_parallel_service_connections,
253 GNUNET_TESTBED_operation_queue_insert_ 251 data->operation);
254 (peer->controller->opq_parallel_operations, data->operation); 252 GNUNET_TESTBED_operation_queue_insert_ (peer->
255 return data->operation; 253 controller->opq_parallel_operations,
254 data->operation);
255 return data->operation;
256} 256}
257 257
258/* end of testbed_api_services.c */ 258/* end of testbed_api_services.c */