aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/testbed_api_services.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2019-10-05 15:09:28 +0200
committerChristian Grothoff <christian@grothoff.org>2019-10-05 15:09:28 +0200
commitc4e9ba925ffd758aaa3feee2ccfc0b76f26fe207 (patch)
treecac3ce030d77b4cbe7c7dc62ed58cfe6d24f73e1 /src/testbed/testbed_api_services.c
parentfbb71d527c7d6babf269a8fefce1db291b9f7068 (diff)
downloadgnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.tar.gz
gnunet-c4e9ba925ffd758aaa3feee2ccfc0b76f26fe207.zip
global reindent, now with uncrustify hook enabled
Diffstat (limited to 'src/testbed/testbed_api_services.c')
-rw-r--r--src/testbed/testbed_api_services.c129
1 files changed, 66 insertions, 63 deletions
diff --git a/src/testbed/testbed_api_services.c b/src/testbed/testbed_api_services.c
index ee4a65817..692fe505f 100644
--- a/src/testbed/testbed_api_services.c
+++ b/src/testbed/testbed_api_services.c
@@ -32,7 +32,8 @@
32/** 32/**
33 * States for Service connect operations 33 * States for Service connect operations
34 */ 34 */
35enum State { 35enum State
36{
36 /** 37 /**
37 * Initial state 38 * Initial state
38 */ 39 */
@@ -53,7 +54,8 @@ enum State {
53/** 54/**
54 * Data accessed during service connections 55 * Data accessed during service connections
55 */ 56 */
56struct ServiceConnectData { 57struct ServiceConnectData
58{
57 /** 59 /**
58 * helper function callback to establish the connection 60 * helper function callback to establish the connection
59 */ 61 */
@@ -129,7 +131,7 @@ struct ServiceConnectData {
129 * @param msg message received, NULL on timeout or fatal error 131 * @param msg message received, NULL on timeout or fatal error
130 */ 132 */
131static void 133static void
132configuration_receiver(void *cls, const struct GNUNET_MessageHeader *msg) 134configuration_receiver (void *cls, const struct GNUNET_MessageHeader *msg)
133{ 135{
134 struct ServiceConnectData *data = cls; 136 struct ServiceConnectData *data = cls;
135 struct GNUNET_TESTBED_Controller *c; 137 struct GNUNET_TESTBED_Controller *c;
@@ -138,26 +140,26 @@ configuration_receiver(void *cls, const struct GNUNET_MessageHeader *msg)
138 uint16_t mtype; 140 uint16_t mtype;
139 141
140 c = data->peer->controller; 142 c = data->peer->controller;
141 mtype = ntohs(msg->type); 143 mtype = ntohs (msg->type);
142 emsg = NULL; 144 emsg = NULL;
143 info.type = GNUNET_TESTBED_ET_OPERATION_FINISHED; 145 info.type = GNUNET_TESTBED_ET_OPERATION_FINISHED;
144 info.op = data->operation; 146 info.op = data->operation;
145 info.op_cls = data->op_cls; 147 info.op_cls = data->op_cls;
146 if (GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT == mtype) 148 if (GNUNET_MESSAGE_TYPE_TESTBED_OPERATION_FAIL_EVENT == mtype)
147 { 149 {
148 emsg = 150 emsg =
149 GNUNET_TESTBED_parse_error_string_((const struct 151 GNUNET_TESTBED_parse_error_string_ ((const struct
150 GNUNET_TESTBED_OperationFailureEventMessage 152 GNUNET_TESTBED_OperationFailureEventMessage
151 *)msg); 153 *) msg);
152 if (NULL == emsg) 154 if (NULL == emsg)
153 emsg = "Unknown error"; 155 emsg = "Unknown error";
154 info.details.operation_finished.emsg = emsg; 156 info.details.operation_finished.emsg = emsg;
155 info.details.operation_finished.generic = NULL; 157 info.details.operation_finished.generic = NULL;
156 goto call_cb; 158 goto call_cb;
157 } 159 }
158 data->cfg = GNUNET_TESTBED_extract_config_(msg); 160 data->cfg = GNUNET_TESTBED_extract_config_ (msg);
159 GNUNET_assert(NULL == data->op_result); 161 GNUNET_assert (NULL == data->op_result);
160 data->op_result = data->ca(data->cada_cls, data->cfg); 162 data->op_result = data->ca (data->cada_cls, data->cfg);
161 info.details.operation_finished.emsg = NULL; 163 info.details.operation_finished.emsg = NULL;
162 info.details.operation_finished.generic = data->op_result; 164 info.details.operation_finished.generic = data->op_result;
163 data->state = SERVICE_CONNECTED; 165 data->state = SERVICE_CONNECTED;
@@ -165,9 +167,9 @@ configuration_receiver(void *cls, const struct GNUNET_MessageHeader *msg)
165call_cb: 167call_cb:
166 if ((0 != (GNUNET_TESTBED_ET_OPERATION_FINISHED & c->event_mask)) && 168 if ((0 != (GNUNET_TESTBED_ET_OPERATION_FINISHED & c->event_mask)) &&
167 (NULL != c->cc)) 169 (NULL != c->cc))
168 c->cc(c->cc_cls, &info); 170 c->cc (c->cc_cls, &info);
169 if (NULL != data->cb) 171 if (NULL != data->cb)
170 data->cb(data->cb_cls, data->operation, data->op_result, emsg); 172 data->cb (data->cb_cls, data->operation, data->op_result, emsg);
171} 173}
172 174
173 175
@@ -177,23 +179,23 @@ call_cb:
177 * @param cls the closure from GNUNET_TESTBED_operation_create_() 179 * @param cls the closure from GNUNET_TESTBED_operation_create_()
178 */ 180 */
179static void 181static void
180opstart_service_connect(void *cls) 182opstart_service_connect (void *cls)
181{ 183{
182 struct ServiceConnectData *data = cls; 184 struct ServiceConnectData *data = cls;
183 struct GNUNET_TESTBED_PeerGetConfigurationMessage *msg; 185 struct GNUNET_TESTBED_PeerGetConfigurationMessage *msg;
184 struct GNUNET_TESTBED_Controller *c; 186 struct GNUNET_TESTBED_Controller *c;
185 uint64_t op_id; 187 uint64_t op_id;
186 188
187 GNUNET_assert(NULL != data); 189 GNUNET_assert (NULL != data);
188 GNUNET_assert(NULL != data->peer); 190 GNUNET_assert (NULL != data->peer);
189 c = data->peer->controller; 191 c = data->peer->controller;
190 op_id = GNUNET_TESTBED_get_next_op_id(c); 192 op_id = GNUNET_TESTBED_get_next_op_id (c);
191 msg = 193 msg =
192 GNUNET_TESTBED_generate_peergetconfig_msg_(data->peer->unique_id, op_id); 194 GNUNET_TESTBED_generate_peergetconfig_msg_ (data->peer->unique_id, op_id);
193 data->opc = 195 data->opc =
194 GNUNET_TESTBED_forward_operation_msg_(c, op_id, &msg->header, 196 GNUNET_TESTBED_forward_operation_msg_ (c, op_id, &msg->header,
195 &configuration_receiver, data); 197 &configuration_receiver, data);
196 GNUNET_free(msg); 198 GNUNET_free (msg);
197 data->state = CFG_REQUEST_QUEUED; 199 data->state = CFG_REQUEST_QUEUED;
198} 200}
199 201
@@ -205,28 +207,28 @@ opstart_service_connect(void *cls)
205 * @param cls the closure from GNUNET_TESTBED_operation_create_() 207 * @param cls the closure from GNUNET_TESTBED_operation_create_()
206 */ 208 */
207static void 209static void
208oprelease_service_connect(void *cls) 210oprelease_service_connect (void *cls)
209{ 211{
210 struct ServiceConnectData *data = cls; 212 struct ServiceConnectData *data = cls;
211 213
212 switch (data->state) 214 switch (data->state)
213 { 215 {
214 case INIT: 216 case INIT:
215 break; 217 break;
216 218
217 case CFG_REQUEST_QUEUED: 219 case CFG_REQUEST_QUEUED:
218 GNUNET_assert(NULL != data->opc); 220 GNUNET_assert (NULL != data->opc);
219 GNUNET_TESTBED_forward_operation_msg_cancel_(data->opc); 221 GNUNET_TESTBED_forward_operation_msg_cancel_ (data->opc);
220 break; 222 break;
221 223
222 case SERVICE_CONNECTED: 224 case SERVICE_CONNECTED:
223 GNUNET_assert(NULL != data->cfg); 225 GNUNET_assert (NULL != data->cfg);
224 GNUNET_CONFIGURATION_destroy(data->cfg); 226 GNUNET_CONFIGURATION_destroy (data->cfg);
225 if (NULL != data->da) 227 if (NULL != data->da)
226 data->da(data->cada_cls, data->op_result); 228 data->da (data->cada_cls, data->op_result);
227 break; 229 break;
228 } 230 }
229 GNUNET_free(data); 231 GNUNET_free (data);
230} 232}
231 233
232 234
@@ -252,17 +254,17 @@ oprelease_service_connect(void *cls)
252 * @return handle for the operation 254 * @return handle for the operation
253 */ 255 */
254struct GNUNET_TESTBED_Operation * 256struct GNUNET_TESTBED_Operation *
255GNUNET_TESTBED_service_connect(void *op_cls, struct GNUNET_TESTBED_Peer *peer, 257GNUNET_TESTBED_service_connect (void *op_cls, struct GNUNET_TESTBED_Peer *peer,
256 const char *service_name, 258 const char *service_name,
257 GNUNET_TESTBED_ServiceConnectCompletionCallback 259 GNUNET_TESTBED_ServiceConnectCompletionCallback
258 cb, void *cb_cls, 260 cb, void *cb_cls,
259 GNUNET_TESTBED_ConnectAdapter ca, 261 GNUNET_TESTBED_ConnectAdapter ca,
260 GNUNET_TESTBED_DisconnectAdapter da, 262 GNUNET_TESTBED_DisconnectAdapter da,
261 void *cada_cls) 263 void *cada_cls)
262{ 264{
263 struct ServiceConnectData *data; 265 struct ServiceConnectData *data;
264 266
265 data = GNUNET_new(struct ServiceConnectData); 267 data = GNUNET_new (struct ServiceConnectData);
266 data->ca = ca; 268 data->ca = ca;
267 data->da = da; 269 data->da = da;
268 data->cada_cls = cada_cls; 270 data->cada_cls = cada_cls;
@@ -272,15 +274,16 @@ GNUNET_TESTBED_service_connect(void *op_cls, struct GNUNET_TESTBED_Peer *peer,
272 data->cb = cb; 274 data->cb = cb;
273 data->cb_cls = cb_cls; 275 data->cb_cls = cb_cls;
274 data->operation = 276 data->operation =
275 GNUNET_TESTBED_operation_create_(data, &opstart_service_connect, 277 GNUNET_TESTBED_operation_create_ (data, &opstart_service_connect,
276 &oprelease_service_connect); 278 &oprelease_service_connect);
277 GNUNET_TESTBED_operation_queue_insert_(peer-> 279 GNUNET_TESTBED_operation_queue_insert_ (peer->
278 controller->opq_parallel_service_connections, 280 controller->
279 data->operation); 281 opq_parallel_service_connections,
280 GNUNET_TESTBED_operation_queue_insert_(peer-> 282 data->operation);
281 controller->opq_parallel_operations, 283 GNUNET_TESTBED_operation_queue_insert_ (peer->
282 data->operation); 284 controller->opq_parallel_operations,
283 GNUNET_TESTBED_operation_begin_wait_(data->operation); 285 data->operation);
286 GNUNET_TESTBED_operation_begin_wait_ (data->operation);
284 return data->operation; 287 return data->operation;
285} 288}
286 289