diff options
Diffstat (limited to 'src/testbed/testbed_api_peers.c')
-rw-r--r-- | src/testbed/testbed_api_peers.c | 747 |
1 files changed, 375 insertions, 372 deletions
diff --git a/src/testbed/testbed_api_peers.c b/src/testbed/testbed_api_peers.c index 78ed71a42..8d74d956f 100644 --- a/src/testbed/testbed_api_peers.c +++ b/src/testbed/testbed_api_peers.c | |||
@@ -51,9 +51,9 @@ static struct GNUNET_TESTBED_Peer *peer_list_tail; | |||
51 | * @param peer the peer to add to the peer list | 51 | * @param peer the peer to add to the peer list |
52 | */ | 52 | */ |
53 | void | 53 | void |
54 | GNUNET_TESTBED_peer_register_(struct GNUNET_TESTBED_Peer *peer) | 54 | GNUNET_TESTBED_peer_register_ (struct GNUNET_TESTBED_Peer *peer) |
55 | { | 55 | { |
56 | GNUNET_CONTAINER_DLL_insert_tail(peer_list_head, peer_list_tail, peer); | 56 | GNUNET_CONTAINER_DLL_insert_tail (peer_list_head, peer_list_tail, peer); |
57 | } | 57 | } |
58 | 58 | ||
59 | 59 | ||
@@ -63,9 +63,9 @@ GNUNET_TESTBED_peer_register_(struct GNUNET_TESTBED_Peer *peer) | |||
63 | * @param peer the peer to remove | 63 | * @param peer the peer to remove |
64 | */ | 64 | */ |
65 | void | 65 | void |
66 | GNUNET_TESTBED_peer_deregister_(struct GNUNET_TESTBED_Peer *peer) | 66 | GNUNET_TESTBED_peer_deregister_ (struct GNUNET_TESTBED_Peer *peer) |
67 | { | 67 | { |
68 | GNUNET_CONTAINER_DLL_remove(peer_list_head, peer_list_tail, peer); | 68 | GNUNET_CONTAINER_DLL_remove (peer_list_head, peer_list_tail, peer); |
69 | } | 69 | } |
70 | 70 | ||
71 | 71 | ||
@@ -73,15 +73,15 @@ GNUNET_TESTBED_peer_deregister_(struct GNUNET_TESTBED_Peer *peer) | |||
73 | * Frees all peers | 73 | * Frees all peers |
74 | */ | 74 | */ |
75 | void | 75 | void |
76 | GNUNET_TESTBED_cleanup_peers_(void) | 76 | GNUNET_TESTBED_cleanup_peers_ (void) |
77 | { | 77 | { |
78 | struct GNUNET_TESTBED_Peer *peer; | 78 | struct GNUNET_TESTBED_Peer *peer; |
79 | 79 | ||
80 | while (NULL != (peer = peer_list_head)) | 80 | while (NULL != (peer = peer_list_head)) |
81 | { | 81 | { |
82 | GNUNET_TESTBED_peer_deregister_(peer); | 82 | GNUNET_TESTBED_peer_deregister_ (peer); |
83 | GNUNET_free(peer); | 83 | GNUNET_free (peer); |
84 | } | 84 | } |
85 | } | 85 | } |
86 | 86 | ||
87 | 87 | ||
@@ -94,7 +94,7 @@ GNUNET_TESTBED_cleanup_peers_(void) | |||
94 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 94 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
95 | */ | 95 | */ |
96 | static void | 96 | static void |
97 | opstart_peer_create(void *cls) | 97 | opstart_peer_create (void *cls) |
98 | { | 98 | { |
99 | struct OperationContext *opc = cls; | 99 | struct OperationContext *opc = cls; |
100 | struct PeerCreateData *data = opc->data; | 100 | struct PeerCreateData *data = opc->data; |
@@ -105,30 +105,30 @@ opstart_peer_create(void *cls) | |||
105 | size_t c_size; | 105 | size_t c_size; |
106 | size_t xc_size; | 106 | size_t xc_size; |
107 | 107 | ||
108 | GNUNET_assert(OP_PEER_CREATE == opc->type); | 108 | GNUNET_assert (OP_PEER_CREATE == opc->type); |
109 | GNUNET_assert(NULL != data); | 109 | GNUNET_assert (NULL != data); |
110 | GNUNET_assert(NULL != data->peer); | 110 | GNUNET_assert (NULL != data->peer); |
111 | opc->state = OPC_STATE_STARTED; | 111 | opc->state = OPC_STATE_STARTED; |
112 | config = GNUNET_CONFIGURATION_serialize(data->cfg, | 112 | config = GNUNET_CONFIGURATION_serialize (data->cfg, |
113 | &c_size); | 113 | &c_size); |
114 | xc_size = GNUNET_TESTBED_compress_config_(config, | 114 | xc_size = GNUNET_TESTBED_compress_config_ (config, |
115 | c_size, | 115 | c_size, |
116 | &xconfig); | 116 | &xconfig); |
117 | GNUNET_free(config); | 117 | GNUNET_free (config); |
118 | env = GNUNET_MQ_msg_extra(msg, | 118 | env = GNUNET_MQ_msg_extra (msg, |
119 | xc_size, | 119 | xc_size, |
120 | GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER); | 120 | GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER); |
121 | msg->operation_id = GNUNET_htonll(opc->id); | 121 | msg->operation_id = GNUNET_htonll (opc->id); |
122 | msg->host_id = htonl(GNUNET_TESTBED_host_get_id_(data->peer->host)); | 122 | msg->host_id = htonl (GNUNET_TESTBED_host_get_id_ (data->peer->host)); |
123 | msg->peer_id = htonl(data->peer->unique_id); | 123 | msg->peer_id = htonl (data->peer->unique_id); |
124 | msg->config_size = htons((uint16_t)c_size); | 124 | msg->config_size = htons ((uint16_t) c_size); |
125 | GNUNET_memcpy(&msg[1], | 125 | GNUNET_memcpy (&msg[1], |
126 | xconfig, | 126 | xconfig, |
127 | xc_size); | 127 | xc_size); |
128 | GNUNET_MQ_send(opc->c->mq, | 128 | GNUNET_MQ_send (opc->c->mq, |
129 | env); | 129 | env); |
130 | GNUNET_free(xconfig); | 130 | GNUNET_free (xconfig); |
131 | GNUNET_TESTBED_insert_opc_(opc->c, opc); | 131 | GNUNET_TESTBED_insert_opc_ (opc->c, opc); |
132 | } | 132 | } |
133 | 133 | ||
134 | 134 | ||
@@ -138,25 +138,25 @@ opstart_peer_create(void *cls) | |||
138 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 138 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
139 | */ | 139 | */ |
140 | static void | 140 | static void |
141 | oprelease_peer_create(void *cls) | 141 | oprelease_peer_create (void *cls) |
142 | { | 142 | { |
143 | struct OperationContext *opc = cls; | 143 | struct OperationContext *opc = cls; |
144 | 144 | ||
145 | switch (opc->state) | 145 | switch (opc->state) |
146 | { | 146 | { |
147 | case OPC_STATE_STARTED: | 147 | case OPC_STATE_STARTED: |
148 | GNUNET_TESTBED_remove_opc_(opc->c, opc); | 148 | GNUNET_TESTBED_remove_opc_ (opc->c, opc); |
149 | 149 | ||
150 | /* No break we continue flow */ | 150 | /* No break we continue flow */ |
151 | case OPC_STATE_INIT: | 151 | case OPC_STATE_INIT: |
152 | GNUNET_free(((struct PeerCreateData *)opc->data)->peer); | 152 | GNUNET_free (((struct PeerCreateData *) opc->data)->peer); |
153 | GNUNET_free(opc->data); | 153 | GNUNET_free (opc->data); |
154 | break; | 154 | break; |
155 | 155 | ||
156 | case OPC_STATE_FINISHED: | 156 | case OPC_STATE_FINISHED: |
157 | break; | 157 | break; |
158 | } | 158 | } |
159 | GNUNET_free(opc); | 159 | GNUNET_free (opc); |
160 | } | 160 | } |
161 | 161 | ||
162 | 162 | ||
@@ -166,23 +166,23 @@ oprelease_peer_create(void *cls) | |||
166 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 166 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
167 | */ | 167 | */ |
168 | static void | 168 | static void |
169 | opstart_peer_destroy(void *cls) | 169 | opstart_peer_destroy (void *cls) |
170 | { | 170 | { |
171 | struct OperationContext *opc = cls; | 171 | struct OperationContext *opc = cls; |
172 | struct GNUNET_TESTBED_Peer *peer = opc->data; | 172 | struct GNUNET_TESTBED_Peer *peer = opc->data; |
173 | struct GNUNET_TESTBED_PeerDestroyMessage *msg; | 173 | struct GNUNET_TESTBED_PeerDestroyMessage *msg; |
174 | struct GNUNET_MQ_Envelope *env; | 174 | struct GNUNET_MQ_Envelope *env; |
175 | 175 | ||
176 | GNUNET_assert(OP_PEER_DESTROY == opc->type); | 176 | GNUNET_assert (OP_PEER_DESTROY == opc->type); |
177 | GNUNET_assert(NULL != peer); | 177 | GNUNET_assert (NULL != peer); |
178 | opc->state = OPC_STATE_STARTED; | 178 | opc->state = OPC_STATE_STARTED; |
179 | env = GNUNET_MQ_msg(msg, | 179 | env = GNUNET_MQ_msg (msg, |
180 | GNUNET_MESSAGE_TYPE_TESTBED_DESTROY_PEER); | 180 | GNUNET_MESSAGE_TYPE_TESTBED_DESTROY_PEER); |
181 | msg->peer_id = htonl(peer->unique_id); | 181 | msg->peer_id = htonl (peer->unique_id); |
182 | msg->operation_id = GNUNET_htonll(opc->id); | 182 | msg->operation_id = GNUNET_htonll (opc->id); |
183 | GNUNET_TESTBED_insert_opc_(opc->c, opc); | 183 | GNUNET_TESTBED_insert_opc_ (opc->c, opc); |
184 | GNUNET_MQ_send(peer->controller->mq, | 184 | GNUNET_MQ_send (peer->controller->mq, |
185 | env); | 185 | env); |
186 | } | 186 | } |
187 | 187 | ||
188 | 188 | ||
@@ -192,23 +192,23 @@ opstart_peer_destroy(void *cls) | |||
192 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 192 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
193 | */ | 193 | */ |
194 | static void | 194 | static void |
195 | oprelease_peer_destroy(void *cls) | 195 | oprelease_peer_destroy (void *cls) |
196 | { | 196 | { |
197 | struct OperationContext *opc = cls; | 197 | struct OperationContext *opc = cls; |
198 | 198 | ||
199 | switch (opc->state) | 199 | switch (opc->state) |
200 | { | 200 | { |
201 | case OPC_STATE_STARTED: | 201 | case OPC_STATE_STARTED: |
202 | GNUNET_TESTBED_remove_opc_(opc->c, opc); | 202 | GNUNET_TESTBED_remove_opc_ (opc->c, opc); |
203 | 203 | ||
204 | /* no break; continue */ | 204 | /* no break; continue */ |
205 | case OPC_STATE_INIT: | 205 | case OPC_STATE_INIT: |
206 | break; | 206 | break; |
207 | 207 | ||
208 | case OPC_STATE_FINISHED: | 208 | case OPC_STATE_FINISHED: |
209 | break; | 209 | break; |
210 | } | 210 | } |
211 | GNUNET_free(opc); | 211 | GNUNET_free (opc); |
212 | } | 212 | } |
213 | 213 | ||
214 | 214 | ||
@@ -218,7 +218,7 @@ oprelease_peer_destroy(void *cls) | |||
218 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 218 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
219 | */ | 219 | */ |
220 | static void | 220 | static void |
221 | opstart_peer_start(void *cls) | 221 | opstart_peer_start (void *cls) |
222 | { | 222 | { |
223 | struct OperationContext *opc = cls; | 223 | struct OperationContext *opc = cls; |
224 | struct GNUNET_TESTBED_PeerStartMessage *msg; | 224 | struct GNUNET_TESTBED_PeerStartMessage *msg; |
@@ -226,18 +226,19 @@ opstart_peer_start(void *cls) | |||
226 | struct PeerEventData *data; | 226 | struct PeerEventData *data; |
227 | struct GNUNET_TESTBED_Peer *peer; | 227 | struct GNUNET_TESTBED_Peer *peer; |
228 | 228 | ||
229 | GNUNET_assert(OP_PEER_START == opc->type); | 229 | GNUNET_assert (OP_PEER_START == opc->type); |
230 | GNUNET_assert(NULL != (data = opc->data)); | 230 | GNUNET_assert (NULL != (data = opc->data)); |
231 | GNUNET_assert(NULL != (peer = data->peer)); | 231 | GNUNET_assert (NULL != (peer = data->peer)); |
232 | GNUNET_assert((TESTBED_PS_CREATED == peer->state) || (TESTBED_PS_STOPPED == peer->state)); | 232 | GNUNET_assert ((TESTBED_PS_CREATED == peer->state) || (TESTBED_PS_STOPPED == |
233 | peer->state)); | ||
233 | opc->state = OPC_STATE_STARTED; | 234 | opc->state = OPC_STATE_STARTED; |
234 | env = GNUNET_MQ_msg(msg, | 235 | env = GNUNET_MQ_msg (msg, |
235 | GNUNET_MESSAGE_TYPE_TESTBED_START_PEER); | 236 | GNUNET_MESSAGE_TYPE_TESTBED_START_PEER); |
236 | msg->peer_id = htonl(peer->unique_id); | 237 | msg->peer_id = htonl (peer->unique_id); |
237 | msg->operation_id = GNUNET_htonll(opc->id); | 238 | msg->operation_id = GNUNET_htonll (opc->id); |
238 | GNUNET_TESTBED_insert_opc_(opc->c, opc); | 239 | GNUNET_TESTBED_insert_opc_ (opc->c, opc); |
239 | GNUNET_MQ_send(peer->controller->mq, | 240 | GNUNET_MQ_send (peer->controller->mq, |
240 | env); | 241 | env); |
241 | } | 242 | } |
242 | 243 | ||
243 | 244 | ||
@@ -247,24 +248,24 @@ opstart_peer_start(void *cls) | |||
247 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 248 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
248 | */ | 249 | */ |
249 | static void | 250 | static void |
250 | oprelease_peer_start(void *cls) | 251 | oprelease_peer_start (void *cls) |
251 | { | 252 | { |
252 | struct OperationContext *opc = cls; | 253 | struct OperationContext *opc = cls; |
253 | 254 | ||
254 | switch (opc->state) | 255 | switch (opc->state) |
255 | { | 256 | { |
256 | case OPC_STATE_STARTED: | 257 | case OPC_STATE_STARTED: |
257 | GNUNET_TESTBED_remove_opc_(opc->c, opc); | 258 | GNUNET_TESTBED_remove_opc_ (opc->c, opc); |
258 | 259 | ||
259 | /* no break; continue */ | 260 | /* no break; continue */ |
260 | case OPC_STATE_INIT: | 261 | case OPC_STATE_INIT: |
261 | GNUNET_free(opc->data); | 262 | GNUNET_free (opc->data); |
262 | break; | 263 | break; |
263 | 264 | ||
264 | case OPC_STATE_FINISHED: | 265 | case OPC_STATE_FINISHED: |
265 | break; | 266 | break; |
266 | } | 267 | } |
267 | GNUNET_free(opc); | 268 | GNUNET_free (opc); |
268 | } | 269 | } |
269 | 270 | ||
270 | 271 | ||
@@ -274,7 +275,7 @@ oprelease_peer_start(void *cls) | |||
274 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 275 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
275 | */ | 276 | */ |
276 | static void | 277 | static void |
277 | opstart_peer_stop(void *cls) | 278 | opstart_peer_stop (void *cls) |
278 | { | 279 | { |
279 | struct OperationContext *opc = cls; | 280 | struct OperationContext *opc = cls; |
280 | struct GNUNET_TESTBED_PeerStopMessage *msg; | 281 | struct GNUNET_TESTBED_PeerStopMessage *msg; |
@@ -282,17 +283,17 @@ opstart_peer_stop(void *cls) | |||
282 | struct GNUNET_TESTBED_Peer *peer; | 283 | struct GNUNET_TESTBED_Peer *peer; |
283 | struct GNUNET_MQ_Envelope *env; | 284 | struct GNUNET_MQ_Envelope *env; |
284 | 285 | ||
285 | GNUNET_assert(NULL != (data = opc->data)); | 286 | GNUNET_assert (NULL != (data = opc->data)); |
286 | GNUNET_assert(NULL != (peer = data->peer)); | 287 | GNUNET_assert (NULL != (peer = data->peer)); |
287 | GNUNET_assert(TESTBED_PS_STARTED == peer->state); | 288 | GNUNET_assert (TESTBED_PS_STARTED == peer->state); |
288 | opc->state = OPC_STATE_STARTED; | 289 | opc->state = OPC_STATE_STARTED; |
289 | env = GNUNET_MQ_msg(msg, | 290 | env = GNUNET_MQ_msg (msg, |
290 | GNUNET_MESSAGE_TYPE_TESTBED_STOP_PEER); | 291 | GNUNET_MESSAGE_TYPE_TESTBED_STOP_PEER); |
291 | msg->peer_id = htonl(peer->unique_id); | 292 | msg->peer_id = htonl (peer->unique_id); |
292 | msg->operation_id = GNUNET_htonll(opc->id); | 293 | msg->operation_id = GNUNET_htonll (opc->id); |
293 | GNUNET_TESTBED_insert_opc_(opc->c, opc); | 294 | GNUNET_TESTBED_insert_opc_ (opc->c, opc); |
294 | GNUNET_MQ_send(peer->controller->mq, | 295 | GNUNET_MQ_send (peer->controller->mq, |
295 | env); | 296 | env); |
296 | } | 297 | } |
297 | 298 | ||
298 | 299 | ||
@@ -302,24 +303,24 @@ opstart_peer_stop(void *cls) | |||
302 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 303 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
303 | */ | 304 | */ |
304 | static void | 305 | static void |
305 | oprelease_peer_stop(void *cls) | 306 | oprelease_peer_stop (void *cls) |
306 | { | 307 | { |
307 | struct OperationContext *opc = cls; | 308 | struct OperationContext *opc = cls; |
308 | 309 | ||
309 | switch (opc->state) | 310 | switch (opc->state) |
310 | { | 311 | { |
311 | case OPC_STATE_STARTED: | 312 | case OPC_STATE_STARTED: |
312 | GNUNET_TESTBED_remove_opc_(opc->c, opc); | 313 | GNUNET_TESTBED_remove_opc_ (opc->c, opc); |
313 | 314 | ||
314 | /* no break; continue */ | 315 | /* no break; continue */ |
315 | case OPC_STATE_INIT: | 316 | case OPC_STATE_INIT: |
316 | GNUNET_free(opc->data); | 317 | GNUNET_free (opc->data); |
317 | break; | 318 | break; |
318 | 319 | ||
319 | case OPC_STATE_FINISHED: | 320 | case OPC_STATE_FINISHED: |
320 | break; | 321 | break; |
321 | } | 322 | } |
322 | GNUNET_free(opc); | 323 | GNUNET_free (opc); |
323 | } | 324 | } |
324 | 325 | ||
325 | 326 | ||
@@ -332,19 +333,19 @@ oprelease_peer_stop(void *cls) | |||
332 | * @return the PeerGetConfigurationMessage | 333 | * @return the PeerGetConfigurationMessage |
333 | */ | 334 | */ |
334 | struct GNUNET_TESTBED_PeerGetConfigurationMessage * | 335 | struct GNUNET_TESTBED_PeerGetConfigurationMessage * |
335 | GNUNET_TESTBED_generate_peergetconfig_msg_(uint32_t peer_id, | 336 | GNUNET_TESTBED_generate_peergetconfig_msg_ (uint32_t peer_id, |
336 | uint64_t operation_id) | 337 | uint64_t operation_id) |
337 | { | 338 | { |
338 | struct GNUNET_TESTBED_PeerGetConfigurationMessage *msg; | 339 | struct GNUNET_TESTBED_PeerGetConfigurationMessage *msg; |
339 | 340 | ||
340 | msg = | 341 | msg = |
341 | GNUNET_malloc(sizeof | 342 | GNUNET_malloc (sizeof |
342 | (struct GNUNET_TESTBED_PeerGetConfigurationMessage)); | 343 | (struct GNUNET_TESTBED_PeerGetConfigurationMessage)); |
343 | msg->header.size = | 344 | msg->header.size = |
344 | htons(sizeof(struct GNUNET_TESTBED_PeerGetConfigurationMessage)); | 345 | htons (sizeof(struct GNUNET_TESTBED_PeerGetConfigurationMessage)); |
345 | msg->header.type = htons(GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION); | 346 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_GET_PEER_INFORMATION); |
346 | msg->peer_id = htonl(peer_id); | 347 | msg->peer_id = htonl (peer_id); |
347 | msg->operation_id = GNUNET_htonll(operation_id); | 348 | msg->operation_id = GNUNET_htonll (operation_id); |
348 | return msg; | 349 | return msg; |
349 | } | 350 | } |
350 | 351 | ||
@@ -355,19 +356,19 @@ GNUNET_TESTBED_generate_peergetconfig_msg_(uint32_t peer_id, | |||
355 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 356 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
356 | */ | 357 | */ |
357 | static void | 358 | static void |
358 | opstart_peer_getinfo(void *cls) | 359 | opstart_peer_getinfo (void *cls) |
359 | { | 360 | { |
360 | struct OperationContext *opc = cls; | 361 | struct OperationContext *opc = cls; |
361 | struct PeerInfoData *data = opc->data; | 362 | struct PeerInfoData *data = opc->data; |
362 | struct GNUNET_TESTBED_PeerGetConfigurationMessage *msg; | 363 | struct GNUNET_TESTBED_PeerGetConfigurationMessage *msg; |
363 | 364 | ||
364 | GNUNET_assert(NULL != data); | 365 | GNUNET_assert (NULL != data); |
365 | opc->state = OPC_STATE_STARTED; | 366 | opc->state = OPC_STATE_STARTED; |
366 | msg = | 367 | msg = |
367 | GNUNET_TESTBED_generate_peergetconfig_msg_(data->peer->unique_id, | 368 | GNUNET_TESTBED_generate_peergetconfig_msg_ (data->peer->unique_id, |
368 | opc->id); | 369 | opc->id); |
369 | GNUNET_TESTBED_insert_opc_(opc->c, opc); | 370 | GNUNET_TESTBED_insert_opc_ (opc->c, opc); |
370 | GNUNET_TESTBED_queue_message_(opc->c, &msg->header); | 371 | GNUNET_TESTBED_queue_message_ (opc->c, &msg->header); |
371 | } | 372 | } |
372 | 373 | ||
373 | 374 | ||
@@ -377,42 +378,42 @@ opstart_peer_getinfo(void *cls) | |||
377 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 378 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
378 | */ | 379 | */ |
379 | static void | 380 | static void |
380 | oprelease_peer_getinfo(void *cls) | 381 | oprelease_peer_getinfo (void *cls) |
381 | { | 382 | { |
382 | struct OperationContext *opc = cls; | 383 | struct OperationContext *opc = cls; |
383 | struct GNUNET_TESTBED_PeerInformation *data; | 384 | struct GNUNET_TESTBED_PeerInformation *data; |
384 | 385 | ||
385 | switch (opc->state) | 386 | switch (opc->state) |
387 | { | ||
388 | case OPC_STATE_STARTED: | ||
389 | GNUNET_TESTBED_remove_opc_ (opc->c, opc); | ||
390 | |||
391 | /* no break; continue */ | ||
392 | case OPC_STATE_INIT: | ||
393 | GNUNET_free (opc->data); | ||
394 | break; | ||
395 | |||
396 | case OPC_STATE_FINISHED: | ||
397 | data = opc->data; | ||
398 | GNUNET_assert (NULL != data); | ||
399 | switch (data->pit) | ||
386 | { | 400 | { |
387 | case OPC_STATE_STARTED: | 401 | case GNUNET_TESTBED_PIT_CONFIGURATION: |
388 | GNUNET_TESTBED_remove_opc_(opc->c, opc); | 402 | if (NULL != data->result.cfg) |
389 | 403 | GNUNET_CONFIGURATION_destroy (data->result.cfg); | |
390 | /* no break; continue */ | ||
391 | case OPC_STATE_INIT: | ||
392 | GNUNET_free(opc->data); | ||
393 | break; | 404 | break; |
394 | 405 | ||
395 | case OPC_STATE_FINISHED: | 406 | case GNUNET_TESTBED_PIT_IDENTITY: |
396 | data = opc->data; | 407 | GNUNET_free (data->result.id); |
397 | GNUNET_assert(NULL != data); | ||
398 | switch (data->pit) | ||
399 | { | ||
400 | case GNUNET_TESTBED_PIT_CONFIGURATION: | ||
401 | if (NULL != data->result.cfg) | ||
402 | GNUNET_CONFIGURATION_destroy(data->result.cfg); | ||
403 | break; | ||
404 | |||
405 | case GNUNET_TESTBED_PIT_IDENTITY: | ||
406 | GNUNET_free(data->result.id); | ||
407 | break; | ||
408 | |||
409 | default: | ||
410 | GNUNET_assert(0); /* We should never reach here */ | ||
411 | } | ||
412 | GNUNET_free(data); | ||
413 | break; | 408 | break; |
409 | |||
410 | default: | ||
411 | GNUNET_assert (0); /* We should never reach here */ | ||
414 | } | 412 | } |
415 | GNUNET_free(opc); | 413 | GNUNET_free (data); |
414 | break; | ||
415 | } | ||
416 | GNUNET_free (opc); | ||
416 | } | 417 | } |
417 | 418 | ||
418 | 419 | ||
@@ -422,7 +423,7 @@ oprelease_peer_getinfo(void *cls) | |||
422 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 423 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
423 | */ | 424 | */ |
424 | static void | 425 | static void |
425 | opstart_overlay_connect(void *cls) | 426 | opstart_overlay_connect (void *cls) |
426 | { | 427 | { |
427 | struct OperationContext *opc = cls; | 428 | struct OperationContext *opc = cls; |
428 | struct GNUNET_MQ_Envelope *env; | 429 | struct GNUNET_MQ_Envelope *env; |
@@ -431,17 +432,17 @@ opstart_overlay_connect(void *cls) | |||
431 | 432 | ||
432 | opc->state = OPC_STATE_STARTED; | 433 | opc->state = OPC_STATE_STARTED; |
433 | data = opc->data; | 434 | data = opc->data; |
434 | GNUNET_assert(NULL != data); | 435 | GNUNET_assert (NULL != data); |
435 | env = GNUNET_MQ_msg(msg, | 436 | env = GNUNET_MQ_msg (msg, |
436 | GNUNET_MESSAGE_TYPE_TESTBED_OVERLAY_CONNECT); | 437 | GNUNET_MESSAGE_TYPE_TESTBED_OVERLAY_CONNECT); |
437 | msg->peer1 = htonl(data->p1->unique_id); | 438 | msg->peer1 = htonl (data->p1->unique_id); |
438 | msg->peer2 = htonl(data->p2->unique_id); | 439 | msg->peer2 = htonl (data->p2->unique_id); |
439 | msg->operation_id = GNUNET_htonll(opc->id); | 440 | msg->operation_id = GNUNET_htonll (opc->id); |
440 | msg->peer2_host_id = htonl(GNUNET_TESTBED_host_get_id_(data->p2->host)); | 441 | msg->peer2_host_id = htonl (GNUNET_TESTBED_host_get_id_ (data->p2->host)); |
441 | GNUNET_TESTBED_insert_opc_(opc->c, | 442 | GNUNET_TESTBED_insert_opc_ (opc->c, |
442 | opc); | 443 | opc); |
443 | GNUNET_MQ_send(opc->c->mq, | 444 | GNUNET_MQ_send (opc->c->mq, |
444 | env); | 445 | env); |
445 | } | 446 | } |
446 | 447 | ||
447 | 448 | ||
@@ -451,26 +452,26 @@ opstart_overlay_connect(void *cls) | |||
451 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 452 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
452 | */ | 453 | */ |
453 | static void | 454 | static void |
454 | oprelease_overlay_connect(void *cls) | 455 | oprelease_overlay_connect (void *cls) |
455 | { | 456 | { |
456 | struct OperationContext *opc = cls; | 457 | struct OperationContext *opc = cls; |
457 | struct OverlayConnectData *data; | 458 | struct OverlayConnectData *data; |
458 | 459 | ||
459 | data = opc->data; | 460 | data = opc->data; |
460 | switch (opc->state) | 461 | switch (opc->state) |
461 | { | 462 | { |
462 | case OPC_STATE_INIT: | 463 | case OPC_STATE_INIT: |
463 | break; | 464 | break; |
464 | 465 | ||
465 | case OPC_STATE_STARTED: | 466 | case OPC_STATE_STARTED: |
466 | GNUNET_TESTBED_remove_opc_(opc->c, opc); | 467 | GNUNET_TESTBED_remove_opc_ (opc->c, opc); |
467 | break; | 468 | break; |
468 | 469 | ||
469 | case OPC_STATE_FINISHED: | 470 | case OPC_STATE_FINISHED: |
470 | break; | 471 | break; |
471 | } | 472 | } |
472 | GNUNET_free(data); | 473 | GNUNET_free (data); |
473 | GNUNET_free(opc); | 474 | GNUNET_free (opc); |
474 | } | 475 | } |
475 | 476 | ||
476 | 477 | ||
@@ -480,7 +481,7 @@ oprelease_overlay_connect(void *cls) | |||
480 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 481 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
481 | */ | 482 | */ |
482 | static void | 483 | static void |
483 | opstart_peer_reconfigure(void *cls) | 484 | opstart_peer_reconfigure (void *cls) |
484 | { | 485 | { |
485 | struct OperationContext *opc = cls; | 486 | struct OperationContext *opc = cls; |
486 | struct PeerReconfigureData *data = opc->data; | 487 | struct PeerReconfigureData *data = opc->data; |
@@ -490,28 +491,28 @@ opstart_peer_reconfigure(void *cls) | |||
490 | size_t xc_size; | 491 | size_t xc_size; |
491 | 492 | ||
492 | opc->state = OPC_STATE_STARTED; | 493 | opc->state = OPC_STATE_STARTED; |
493 | GNUNET_assert(NULL != data); | 494 | GNUNET_assert (NULL != data); |
494 | xc_size = GNUNET_TESTBED_compress_config_(data->config, | 495 | xc_size = GNUNET_TESTBED_compress_config_ (data->config, |
495 | data->cfg_size, | 496 | data->cfg_size, |
496 | &xconfig); | 497 | &xconfig); |
497 | GNUNET_free(data->config); | 498 | GNUNET_free (data->config); |
498 | data->config = NULL; | 499 | data->config = NULL; |
499 | GNUNET_assert(xc_size < UINT16_MAX - sizeof(*msg)); | 500 | GNUNET_assert (xc_size < UINT16_MAX - sizeof(*msg)); |
500 | env = GNUNET_MQ_msg_extra(msg, | 501 | env = GNUNET_MQ_msg_extra (msg, |
501 | xc_size, | 502 | xc_size, |
502 | GNUNET_MESSAGE_TYPE_TESTBED_RECONFIGURE_PEER); | 503 | GNUNET_MESSAGE_TYPE_TESTBED_RECONFIGURE_PEER); |
503 | msg->peer_id = htonl(data->peer->unique_id); | 504 | msg->peer_id = htonl (data->peer->unique_id); |
504 | msg->operation_id = GNUNET_htonll(opc->id); | 505 | msg->operation_id = GNUNET_htonll (opc->id); |
505 | msg->config_size = htons(data->cfg_size); | 506 | msg->config_size = htons (data->cfg_size); |
506 | GNUNET_memcpy(&msg[1], | 507 | GNUNET_memcpy (&msg[1], |
507 | xconfig, | 508 | xconfig, |
508 | xc_size); | 509 | xc_size); |
509 | GNUNET_free(xconfig); | 510 | GNUNET_free (xconfig); |
510 | GNUNET_free(data); | 511 | GNUNET_free (data); |
511 | opc->data = NULL; | 512 | opc->data = NULL; |
512 | GNUNET_TESTBED_insert_opc_(opc->c, opc); | 513 | GNUNET_TESTBED_insert_opc_ (opc->c, opc); |
513 | GNUNET_MQ_send(opc->c->mq, | 514 | GNUNET_MQ_send (opc->c->mq, |
514 | env); | 515 | env); |
515 | } | 516 | } |
516 | 517 | ||
517 | 518 | ||
@@ -521,26 +522,26 @@ opstart_peer_reconfigure(void *cls) | |||
521 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 522 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
522 | */ | 523 | */ |
523 | static void | 524 | static void |
524 | oprelease_peer_reconfigure(void *cls) | 525 | oprelease_peer_reconfigure (void *cls) |
525 | { | 526 | { |
526 | struct OperationContext *opc = cls; | 527 | struct OperationContext *opc = cls; |
527 | struct PeerReconfigureData *data = opc->data; | 528 | struct PeerReconfigureData *data = opc->data; |
528 | 529 | ||
529 | switch (opc->state) | 530 | switch (opc->state) |
530 | { | 531 | { |
531 | case OPC_STATE_INIT: | 532 | case OPC_STATE_INIT: |
532 | GNUNET_free(data->config); | 533 | GNUNET_free (data->config); |
533 | GNUNET_free(data); | 534 | GNUNET_free (data); |
534 | break; | 535 | break; |
535 | 536 | ||
536 | case OPC_STATE_STARTED: | 537 | case OPC_STATE_STARTED: |
537 | GNUNET_TESTBED_remove_opc_(opc->c, opc); | 538 | GNUNET_TESTBED_remove_opc_ (opc->c, opc); |
538 | break; | 539 | break; |
539 | 540 | ||
540 | case OPC_STATE_FINISHED: | 541 | case OPC_STATE_FINISHED: |
541 | break; | 542 | break; |
542 | } | 543 | } |
543 | GNUNET_free(opc); | 544 | GNUNET_free (opc); |
544 | } | 545 | } |
545 | 546 | ||
546 | 547 | ||
@@ -551,9 +552,9 @@ oprelease_peer_reconfigure(void *cls) | |||
551 | * @return handle to the host, NULL on error | 552 | * @return handle to the host, NULL on error |
552 | */ | 553 | */ |
553 | struct GNUNET_TESTBED_Peer * | 554 | struct GNUNET_TESTBED_Peer * |
554 | GNUNET_TESTBED_peer_lookup_by_id_(uint32_t id) | 555 | GNUNET_TESTBED_peer_lookup_by_id_ (uint32_t id) |
555 | { | 556 | { |
556 | GNUNET_break(0); | 557 | GNUNET_break (0); |
557 | return NULL; | 558 | return NULL; |
558 | } | 559 | } |
559 | 560 | ||
@@ -588,38 +589,38 @@ GNUNET_TESTBED_peer_lookup_by_id_(uint32_t id) | |||
588 | * @return the operation handle | 589 | * @return the operation handle |
589 | */ | 590 | */ |
590 | struct GNUNET_TESTBED_Operation * | 591 | struct GNUNET_TESTBED_Operation * |
591 | GNUNET_TESTBED_peer_create(struct GNUNET_TESTBED_Controller *controller, | 592 | GNUNET_TESTBED_peer_create (struct GNUNET_TESTBED_Controller *controller, |
592 | struct GNUNET_TESTBED_Host *host, | 593 | struct GNUNET_TESTBED_Host *host, |
593 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 594 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
594 | GNUNET_TESTBED_PeerCreateCallback cb, void *cls) | 595 | GNUNET_TESTBED_PeerCreateCallback cb, void *cls) |
595 | { | 596 | { |
596 | struct GNUNET_TESTBED_Peer *peer; | 597 | struct GNUNET_TESTBED_Peer *peer; |
597 | struct PeerCreateData *data; | 598 | struct PeerCreateData *data; |
598 | struct OperationContext *opc; | 599 | struct OperationContext *opc; |
599 | static uint32_t id_gen; | 600 | static uint32_t id_gen; |
600 | 601 | ||
601 | peer = GNUNET_new(struct GNUNET_TESTBED_Peer); | 602 | peer = GNUNET_new (struct GNUNET_TESTBED_Peer); |
602 | peer->controller = controller; | 603 | peer->controller = controller; |
603 | peer->host = host; | 604 | peer->host = host; |
604 | peer->unique_id = id_gen++; | 605 | peer->unique_id = id_gen++; |
605 | peer->state = TESTBED_PS_INVALID; | 606 | peer->state = TESTBED_PS_INVALID; |
606 | data = GNUNET_new(struct PeerCreateData); | 607 | data = GNUNET_new (struct PeerCreateData); |
607 | data->host = host; | 608 | data->host = host; |
608 | data->cfg = cfg; | 609 | data->cfg = cfg; |
609 | data->cb = cb; | 610 | data->cb = cb; |
610 | data->cls = cls; | 611 | data->cls = cls; |
611 | data->peer = peer; | 612 | data->peer = peer; |
612 | opc = GNUNET_new(struct OperationContext); | 613 | opc = GNUNET_new (struct OperationContext); |
613 | opc->c = controller; | 614 | opc->c = controller; |
614 | opc->data = data; | 615 | opc->data = data; |
615 | opc->id = GNUNET_TESTBED_get_next_op_id(controller); | 616 | opc->id = GNUNET_TESTBED_get_next_op_id (controller); |
616 | opc->type = OP_PEER_CREATE; | 617 | opc->type = OP_PEER_CREATE; |
617 | opc->op = | 618 | opc->op = |
618 | GNUNET_TESTBED_operation_create_(opc, &opstart_peer_create, | 619 | GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_create, |
619 | &oprelease_peer_create); | 620 | &oprelease_peer_create); |
620 | GNUNET_TESTBED_operation_queue_insert_(controller->opq_parallel_operations, | 621 | GNUNET_TESTBED_operation_queue_insert_ (controller->opq_parallel_operations, |
621 | opc->op); | 622 | opc->op); |
622 | GNUNET_TESTBED_operation_begin_wait_(opc->op); | 623 | GNUNET_TESTBED_operation_begin_wait_ (opc->op); |
623 | return opc->op; | 624 | return opc->op; |
624 | } | 625 | } |
625 | 626 | ||
@@ -635,28 +636,28 @@ GNUNET_TESTBED_peer_create(struct GNUNET_TESTBED_Controller *controller, | |||
635 | * @return handle to the operation | 636 | * @return handle to the operation |
636 | */ | 637 | */ |
637 | struct GNUNET_TESTBED_Operation * | 638 | struct GNUNET_TESTBED_Operation * |
638 | GNUNET_TESTBED_peer_start(void *op_cls, struct GNUNET_TESTBED_Peer *peer, | 639 | GNUNET_TESTBED_peer_start (void *op_cls, struct GNUNET_TESTBED_Peer *peer, |
639 | GNUNET_TESTBED_PeerChurnCallback pcc, void *pcc_cls) | 640 | GNUNET_TESTBED_PeerChurnCallback pcc, void *pcc_cls) |
640 | { | 641 | { |
641 | struct OperationContext *opc; | 642 | struct OperationContext *opc; |
642 | struct PeerEventData *data; | 643 | struct PeerEventData *data; |
643 | 644 | ||
644 | data = GNUNET_new(struct PeerEventData); | 645 | data = GNUNET_new (struct PeerEventData); |
645 | data->peer = peer; | 646 | data->peer = peer; |
646 | data->pcc = pcc; | 647 | data->pcc = pcc; |
647 | data->pcc_cls = pcc_cls; | 648 | data->pcc_cls = pcc_cls; |
648 | opc = GNUNET_new(struct OperationContext); | 649 | opc = GNUNET_new (struct OperationContext); |
649 | opc->c = peer->controller; | 650 | opc->c = peer->controller; |
650 | opc->data = data; | 651 | opc->data = data; |
651 | opc->op_cls = op_cls; | 652 | opc->op_cls = op_cls; |
652 | opc->id = GNUNET_TESTBED_get_next_op_id(opc->c); | 653 | opc->id = GNUNET_TESTBED_get_next_op_id (opc->c); |
653 | opc->type = OP_PEER_START; | 654 | opc->type = OP_PEER_START; |
654 | opc->op = | 655 | opc->op = |
655 | GNUNET_TESTBED_operation_create_(opc, &opstart_peer_start, | 656 | GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_start, |
656 | &oprelease_peer_start); | 657 | &oprelease_peer_start); |
657 | GNUNET_TESTBED_operation_queue_insert_(opc->c->opq_parallel_operations, | 658 | GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations, |
658 | opc->op); | 659 | opc->op); |
659 | GNUNET_TESTBED_operation_begin_wait_(opc->op); | 660 | GNUNET_TESTBED_operation_begin_wait_ (opc->op); |
660 | return opc->op; | 661 | return opc->op; |
661 | } | 662 | } |
662 | 663 | ||
@@ -674,29 +675,29 @@ GNUNET_TESTBED_peer_start(void *op_cls, struct GNUNET_TESTBED_Peer *peer, | |||
674 | * @return handle to the operation | 675 | * @return handle to the operation |
675 | */ | 676 | */ |
676 | struct GNUNET_TESTBED_Operation * | 677 | struct GNUNET_TESTBED_Operation * |
677 | GNUNET_TESTBED_peer_stop(void *op_cls, | 678 | GNUNET_TESTBED_peer_stop (void *op_cls, |
678 | struct GNUNET_TESTBED_Peer *peer, | 679 | struct GNUNET_TESTBED_Peer *peer, |
679 | GNUNET_TESTBED_PeerChurnCallback pcc, void *pcc_cls) | 680 | GNUNET_TESTBED_PeerChurnCallback pcc, void *pcc_cls) |
680 | { | 681 | { |
681 | struct OperationContext *opc; | 682 | struct OperationContext *opc; |
682 | struct PeerEventData *data; | 683 | struct PeerEventData *data; |
683 | 684 | ||
684 | data = GNUNET_new(struct PeerEventData); | 685 | data = GNUNET_new (struct PeerEventData); |
685 | data->peer = peer; | 686 | data->peer = peer; |
686 | data->pcc = pcc; | 687 | data->pcc = pcc; |
687 | data->pcc_cls = pcc_cls; | 688 | data->pcc_cls = pcc_cls; |
688 | opc = GNUNET_new(struct OperationContext); | 689 | opc = GNUNET_new (struct OperationContext); |
689 | opc->c = peer->controller; | 690 | opc->c = peer->controller; |
690 | opc->data = data; | 691 | opc->data = data; |
691 | opc->op_cls = op_cls; | 692 | opc->op_cls = op_cls; |
692 | opc->id = GNUNET_TESTBED_get_next_op_id(opc->c); | 693 | opc->id = GNUNET_TESTBED_get_next_op_id (opc->c); |
693 | opc->type = OP_PEER_STOP; | 694 | opc->type = OP_PEER_STOP; |
694 | opc->op = | 695 | opc->op = |
695 | GNUNET_TESTBED_operation_create_(opc, &opstart_peer_stop, | 696 | GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_stop, |
696 | &oprelease_peer_stop); | 697 | &oprelease_peer_stop); |
697 | GNUNET_TESTBED_operation_queue_insert_(opc->c->opq_parallel_operations, | 698 | GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations, |
698 | opc->op); | 699 | opc->op); |
699 | GNUNET_TESTBED_operation_begin_wait_(opc->op); | 700 | GNUNET_TESTBED_operation_begin_wait_ (opc->op); |
700 | return opc->op; | 701 | return opc->op; |
701 | } | 702 | } |
702 | 703 | ||
@@ -716,32 +717,32 @@ GNUNET_TESTBED_peer_stop(void *op_cls, | |||
716 | * @return handle to the operation | 717 | * @return handle to the operation |
717 | */ | 718 | */ |
718 | struct GNUNET_TESTBED_Operation * | 719 | struct GNUNET_TESTBED_Operation * |
719 | GNUNET_TESTBED_peer_get_information(struct GNUNET_TESTBED_Peer *peer, | 720 | GNUNET_TESTBED_peer_get_information (struct GNUNET_TESTBED_Peer *peer, |
720 | enum GNUNET_TESTBED_PeerInformationType | 721 | enum GNUNET_TESTBED_PeerInformationType |
721 | pit, GNUNET_TESTBED_PeerInfoCallback cb, | 722 | pit, GNUNET_TESTBED_PeerInfoCallback cb, |
722 | void *cb_cls) | 723 | void *cb_cls) |
723 | { | 724 | { |
724 | struct OperationContext *opc; | 725 | struct OperationContext *opc; |
725 | struct PeerInfoData *data; | 726 | struct PeerInfoData *data; |
726 | 727 | ||
727 | GNUNET_assert(GNUNET_TESTBED_PIT_GENERIC != pit); | 728 | GNUNET_assert (GNUNET_TESTBED_PIT_GENERIC != pit); |
728 | GNUNET_assert(NULL != cb); | 729 | GNUNET_assert (NULL != cb); |
729 | data = GNUNET_new(struct PeerInfoData); | 730 | data = GNUNET_new (struct PeerInfoData); |
730 | data->peer = peer; | 731 | data->peer = peer; |
731 | data->pit = pit; | 732 | data->pit = pit; |
732 | data->cb = cb; | 733 | data->cb = cb; |
733 | data->cb_cls = cb_cls; | 734 | data->cb_cls = cb_cls; |
734 | opc = GNUNET_new(struct OperationContext); | 735 | opc = GNUNET_new (struct OperationContext); |
735 | opc->c = peer->controller; | 736 | opc->c = peer->controller; |
736 | opc->data = data; | 737 | opc->data = data; |
737 | opc->type = OP_PEER_INFO; | 738 | opc->type = OP_PEER_INFO; |
738 | opc->id = GNUNET_TESTBED_get_next_op_id(opc->c); | 739 | opc->id = GNUNET_TESTBED_get_next_op_id (opc->c); |
739 | opc->op = | 740 | opc->op = |
740 | GNUNET_TESTBED_operation_create_(opc, &opstart_peer_getinfo, | 741 | GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_getinfo, |
741 | &oprelease_peer_getinfo); | 742 | &oprelease_peer_getinfo); |
742 | GNUNET_TESTBED_operation_queue_insert_(opc->c->opq_parallel_operations, | 743 | GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations, |
743 | opc->op); | 744 | opc->op); |
744 | GNUNET_TESTBED_operation_begin_wait_(opc->op); | 745 | GNUNET_TESTBED_operation_begin_wait_ (opc->op); |
745 | return opc->op; | 746 | return opc->op; |
746 | } | 747 | } |
747 | 748 | ||
@@ -757,41 +758,41 @@ GNUNET_TESTBED_peer_get_information(struct GNUNET_TESTBED_Peer *peer, | |||
757 | * @return handle to the operation | 758 | * @return handle to the operation |
758 | */ | 759 | */ |
759 | struct GNUNET_TESTBED_Operation * | 760 | struct GNUNET_TESTBED_Operation * |
760 | GNUNET_TESTBED_peer_update_configuration(struct GNUNET_TESTBED_Peer *peer, | 761 | GNUNET_TESTBED_peer_update_configuration (struct GNUNET_TESTBED_Peer *peer, |
761 | const struct | 762 | const struct |
762 | GNUNET_CONFIGURATION_Handle *cfg) | 763 | GNUNET_CONFIGURATION_Handle *cfg) |
763 | { | 764 | { |
764 | struct OperationContext *opc; | 765 | struct OperationContext *opc; |
765 | struct PeerReconfigureData *data; | 766 | struct PeerReconfigureData *data; |
766 | size_t csize; | 767 | size_t csize; |
767 | 768 | ||
768 | data = GNUNET_new(struct PeerReconfigureData); | 769 | data = GNUNET_new (struct PeerReconfigureData); |
769 | data->peer = peer; | 770 | data->peer = peer; |
770 | data->config = GNUNET_CONFIGURATION_serialize(cfg, &csize); | 771 | data->config = GNUNET_CONFIGURATION_serialize (cfg, &csize); |
771 | if (NULL == data->config) | 772 | if (NULL == data->config) |
772 | { | 773 | { |
773 | GNUNET_free(data); | 774 | GNUNET_free (data); |
774 | return NULL; | 775 | return NULL; |
775 | } | 776 | } |
776 | if (csize > UINT16_MAX) | 777 | if (csize > UINT16_MAX) |
777 | { | 778 | { |
778 | GNUNET_break(0); | 779 | GNUNET_break (0); |
779 | GNUNET_free(data->config); | 780 | GNUNET_free (data->config); |
780 | GNUNET_free(data); | 781 | GNUNET_free (data); |
781 | return NULL; | 782 | return NULL; |
782 | } | 783 | } |
783 | data->cfg_size = (uint16_t)csize; | 784 | data->cfg_size = (uint16_t) csize; |
784 | opc = GNUNET_new(struct OperationContext); | 785 | opc = GNUNET_new (struct OperationContext); |
785 | opc->c = peer->controller; | 786 | opc->c = peer->controller; |
786 | opc->data = data; | 787 | opc->data = data; |
787 | opc->type = OP_PEER_RECONFIGURE; | 788 | opc->type = OP_PEER_RECONFIGURE; |
788 | opc->id = GNUNET_TESTBED_get_next_op_id(opc->c); | 789 | opc->id = GNUNET_TESTBED_get_next_op_id (opc->c); |
789 | opc->op = | 790 | opc->op = |
790 | GNUNET_TESTBED_operation_create_(opc, &opstart_peer_reconfigure, | 791 | GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_reconfigure, |
791 | &oprelease_peer_reconfigure); | 792 | &oprelease_peer_reconfigure); |
792 | GNUNET_TESTBED_operation_queue_insert_(opc->c->opq_parallel_operations, | 793 | GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations, |
793 | opc->op); | 794 | opc->op); |
794 | GNUNET_TESTBED_operation_begin_wait_(opc->op); | 795 | GNUNET_TESTBED_operation_begin_wait_ (opc->op); |
795 | return opc->op; | 796 | return opc->op; |
796 | } | 797 | } |
797 | 798 | ||
@@ -804,21 +805,21 @@ GNUNET_TESTBED_peer_update_configuration(struct GNUNET_TESTBED_Peer *peer, | |||
804 | * @return handle to the operation | 805 | * @return handle to the operation |
805 | */ | 806 | */ |
806 | struct GNUNET_TESTBED_Operation * | 807 | struct GNUNET_TESTBED_Operation * |
807 | GNUNET_TESTBED_peer_destroy(struct GNUNET_TESTBED_Peer *peer) | 808 | GNUNET_TESTBED_peer_destroy (struct GNUNET_TESTBED_Peer *peer) |
808 | { | 809 | { |
809 | struct OperationContext *opc; | 810 | struct OperationContext *opc; |
810 | 811 | ||
811 | opc = GNUNET_new(struct OperationContext); | 812 | opc = GNUNET_new (struct OperationContext); |
812 | opc->data = peer; | 813 | opc->data = peer; |
813 | opc->c = peer->controller; | 814 | opc->c = peer->controller; |
814 | opc->id = GNUNET_TESTBED_get_next_op_id(peer->controller); | 815 | opc->id = GNUNET_TESTBED_get_next_op_id (peer->controller); |
815 | opc->type = OP_PEER_DESTROY; | 816 | opc->type = OP_PEER_DESTROY; |
816 | opc->op = | 817 | opc->op = |
817 | GNUNET_TESTBED_operation_create_(opc, &opstart_peer_destroy, | 818 | GNUNET_TESTBED_operation_create_ (opc, &opstart_peer_destroy, |
818 | &oprelease_peer_destroy); | 819 | &oprelease_peer_destroy); |
819 | GNUNET_TESTBED_operation_queue_insert_(opc->c->opq_parallel_operations, | 820 | GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations, |
820 | opc->op); | 821 | opc->op); |
821 | GNUNET_TESTBED_operation_begin_wait_(opc->op); | 822 | GNUNET_TESTBED_operation_begin_wait_ (opc->op); |
822 | return opc->op; | 823 | return opc->op; |
823 | } | 824 | } |
824 | 825 | ||
@@ -836,13 +837,13 @@ GNUNET_TESTBED_peer_destroy(struct GNUNET_TESTBED_Peer *peer) | |||
836 | * time is not allowed | 837 | * time is not allowed |
837 | */ | 838 | */ |
838 | struct GNUNET_TESTBED_Operation * | 839 | struct GNUNET_TESTBED_Operation * |
839 | GNUNET_TESTBED_underlay_configure_link(void *op_cls, | 840 | GNUNET_TESTBED_underlay_configure_link (void *op_cls, |
840 | struct GNUNET_TESTBED_Peer *p1, | 841 | struct GNUNET_TESTBED_Peer *p1, |
841 | struct GNUNET_TESTBED_Peer *p2, | 842 | struct GNUNET_TESTBED_Peer *p2, |
842 | enum GNUNET_TESTBED_ConnectOption co, | 843 | enum GNUNET_TESTBED_ConnectOption co, |
843 | ...) | 844 | ...) |
844 | { | 845 | { |
845 | GNUNET_break(0); | 846 | GNUNET_break (0); |
846 | return NULL; | 847 | return NULL; |
847 | } | 848 | } |
848 | 849 | ||
@@ -862,31 +863,32 @@ GNUNET_TESTBED_underlay_configure_link(void *op_cls, | |||
862 | * not running or underlay disallows) | 863 | * not running or underlay disallows) |
863 | */ | 864 | */ |
864 | struct GNUNET_TESTBED_Operation * | 865 | struct GNUNET_TESTBED_Operation * |
865 | GNUNET_TESTBED_overlay_connect(void *op_cls, | 866 | GNUNET_TESTBED_overlay_connect (void *op_cls, |
866 | GNUNET_TESTBED_OperationCompletionCallback cb, | 867 | GNUNET_TESTBED_OperationCompletionCallback cb, |
867 | void *cb_cls, struct GNUNET_TESTBED_Peer *p1, | 868 | void *cb_cls, struct GNUNET_TESTBED_Peer *p1, |
868 | struct GNUNET_TESTBED_Peer *p2) | 869 | struct GNUNET_TESTBED_Peer *p2) |
869 | { | 870 | { |
870 | struct OperationContext *opc; | 871 | struct OperationContext *opc; |
871 | struct OverlayConnectData *data; | 872 | struct OverlayConnectData *data; |
872 | 873 | ||
873 | GNUNET_assert((TESTBED_PS_STARTED == p1->state) && (TESTBED_PS_STARTED == p2->state)); | 874 | GNUNET_assert ((TESTBED_PS_STARTED == p1->state) && (TESTBED_PS_STARTED == |
874 | data = GNUNET_new(struct OverlayConnectData); | 875 | p2->state)); |
876 | data = GNUNET_new (struct OverlayConnectData); | ||
875 | data->p1 = p1; | 877 | data->p1 = p1; |
876 | data->p2 = p2; | 878 | data->p2 = p2; |
877 | data->cb = cb; | 879 | data->cb = cb; |
878 | data->cb_cls = cb_cls; | 880 | data->cb_cls = cb_cls; |
879 | opc = GNUNET_new(struct OperationContext); | 881 | opc = GNUNET_new (struct OperationContext); |
880 | opc->data = data; | 882 | opc->data = data; |
881 | opc->c = p1->controller; | 883 | opc->c = p1->controller; |
882 | opc->id = GNUNET_TESTBED_get_next_op_id(opc->c); | 884 | opc->id = GNUNET_TESTBED_get_next_op_id (opc->c); |
883 | opc->type = OP_OVERLAY_CONNECT; | 885 | opc->type = OP_OVERLAY_CONNECT; |
884 | opc->op_cls = op_cls; | 886 | opc->op_cls = op_cls; |
885 | opc->op = | 887 | opc->op = |
886 | GNUNET_TESTBED_operation_create_(opc, &opstart_overlay_connect, | 888 | GNUNET_TESTBED_operation_create_ (opc, &opstart_overlay_connect, |
887 | &oprelease_overlay_connect); | 889 | &oprelease_overlay_connect); |
888 | GNUNET_TESTBED_host_queue_oc_(p1->host, opc->op); | 890 | GNUNET_TESTBED_host_queue_oc_ (p1->host, opc->op); |
889 | GNUNET_TESTBED_operation_begin_wait_(opc->op); | 891 | GNUNET_TESTBED_operation_begin_wait_ (opc->op); |
890 | return opc->op; | 892 | return opc->op; |
891 | } | 893 | } |
892 | 894 | ||
@@ -897,7 +899,7 @@ GNUNET_TESTBED_overlay_connect(void *op_cls, | |||
897 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 899 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
898 | */ | 900 | */ |
899 | static void | 901 | static void |
900 | opstart_manage_service(void *cls) | 902 | opstart_manage_service (void *cls) |
901 | { | 903 | { |
902 | struct OperationContext *opc = cls; | 904 | struct OperationContext *opc = cls; |
903 | struct ManageServiceData *data = opc->data; | 905 | struct ManageServiceData *data = opc->data; |
@@ -905,23 +907,23 @@ opstart_manage_service(void *cls) | |||
905 | struct GNUNET_TESTBED_ManagePeerServiceMessage *msg; | 907 | struct GNUNET_TESTBED_ManagePeerServiceMessage *msg; |
906 | size_t xlen; | 908 | size_t xlen; |
907 | 909 | ||
908 | GNUNET_assert(NULL != data); | 910 | GNUNET_assert (NULL != data); |
909 | xlen = data->msize - sizeof(struct GNUNET_TESTBED_ManagePeerServiceMessage); | 911 | xlen = data->msize - sizeof(struct GNUNET_TESTBED_ManagePeerServiceMessage); |
910 | env = GNUNET_MQ_msg_extra(msg, | 912 | env = GNUNET_MQ_msg_extra (msg, |
911 | xlen, | 913 | xlen, |
912 | GNUNET_MESSAGE_TYPE_TESTBED_MANAGE_PEER_SERVICE); | 914 | GNUNET_MESSAGE_TYPE_TESTBED_MANAGE_PEER_SERVICE); |
913 | msg->peer_id = htonl(data->peer->unique_id); | 915 | msg->peer_id = htonl (data->peer->unique_id); |
914 | msg->operation_id = GNUNET_htonll(opc->id); | 916 | msg->operation_id = GNUNET_htonll (opc->id); |
915 | msg->start = (uint8_t)data->start; | 917 | msg->start = (uint8_t) data->start; |
916 | GNUNET_memcpy(&msg[1], | 918 | GNUNET_memcpy (&msg[1], |
917 | data->service_name, | 919 | data->service_name, |
918 | xlen); | 920 | xlen); |
919 | GNUNET_free(data->service_name); | 921 | GNUNET_free (data->service_name); |
920 | data->service_name = NULL; | 922 | data->service_name = NULL; |
921 | opc->state = OPC_STATE_STARTED; | 923 | opc->state = OPC_STATE_STARTED; |
922 | GNUNET_TESTBED_insert_opc_(opc->c, opc); | 924 | GNUNET_TESTBED_insert_opc_ (opc->c, opc); |
923 | GNUNET_MQ_send(opc->c->mq, | 925 | GNUNET_MQ_send (opc->c->mq, |
924 | env); | 926 | env); |
925 | } | 927 | } |
926 | 928 | ||
927 | 929 | ||
@@ -931,28 +933,28 @@ opstart_manage_service(void *cls) | |||
931 | * @param cls the closure from GNUNET_TESTBED_operation_create_() | 933 | * @param cls the closure from GNUNET_TESTBED_operation_create_() |
932 | */ | 934 | */ |
933 | static void | 935 | static void |
934 | oprelease_manage_service(void *cls) | 936 | oprelease_manage_service (void *cls) |
935 | { | 937 | { |
936 | struct OperationContext *opc = cls; | 938 | struct OperationContext *opc = cls; |
937 | struct ManageServiceData *data; | 939 | struct ManageServiceData *data; |
938 | 940 | ||
939 | data = opc->data; | 941 | data = opc->data; |
940 | switch (opc->state) | 942 | switch (opc->state) |
941 | { | 943 | { |
942 | case OPC_STATE_STARTED: | 944 | case OPC_STATE_STARTED: |
943 | GNUNET_TESTBED_remove_opc_(opc->c, opc); | 945 | GNUNET_TESTBED_remove_opc_ (opc->c, opc); |
944 | break; | 946 | break; |
945 | 947 | ||
946 | case OPC_STATE_INIT: | 948 | case OPC_STATE_INIT: |
947 | GNUNET_assert(NULL != data); | 949 | GNUNET_assert (NULL != data); |
948 | GNUNET_free(data->service_name); | 950 | GNUNET_free (data->service_name); |
949 | break; | 951 | break; |
950 | 952 | ||
951 | case OPC_STATE_FINISHED: | 953 | case OPC_STATE_FINISHED: |
952 | break; | 954 | break; |
953 | } | 955 | } |
954 | GNUNET_free_non_null(data); | 956 | GNUNET_free_non_null (data); |
955 | GNUNET_free(opc); | 957 | GNUNET_free (opc); |
956 | } | 958 | } |
957 | 959 | ||
958 | 960 | ||
@@ -972,41 +974,42 @@ oprelease_manage_service(void *cls) | |||
972 | * @return an operation handle; NULL upon error (peer not running) | 974 | * @return an operation handle; NULL upon error (peer not running) |
973 | */ | 975 | */ |
974 | struct GNUNET_TESTBED_Operation * | 976 | struct GNUNET_TESTBED_Operation * |
975 | GNUNET_TESTBED_peer_manage_service(void *op_cls, | 977 | GNUNET_TESTBED_peer_manage_service (void *op_cls, |
976 | struct GNUNET_TESTBED_Peer *peer, | 978 | struct GNUNET_TESTBED_Peer *peer, |
977 | const char *service_name, | 979 | const char *service_name, |
978 | GNUNET_TESTBED_OperationCompletionCallback cb, | 980 | GNUNET_TESTBED_OperationCompletionCallback |
979 | void *cb_cls, | 981 | cb, |
980 | unsigned int start) | 982 | void *cb_cls, |
983 | unsigned int start) | ||
981 | { | 984 | { |
982 | struct ManageServiceData *data; | 985 | struct ManageServiceData *data; |
983 | struct OperationContext *opc; | 986 | struct OperationContext *opc; |
984 | size_t msize; | 987 | size_t msize; |
985 | 988 | ||
986 | GNUNET_assert(TESTBED_PS_STARTED == peer->state); /* peer is not running? */ | 989 | GNUNET_assert (TESTBED_PS_STARTED == peer->state); /* peer is not running? */ |
987 | msize = strlen(service_name) + 1; | 990 | msize = strlen (service_name) + 1; |
988 | msize += sizeof(struct GNUNET_TESTBED_ManagePeerServiceMessage); | 991 | msize += sizeof(struct GNUNET_TESTBED_ManagePeerServiceMessage); |
989 | if (GNUNET_MAX_MESSAGE_SIZE < msize) | 992 | if (GNUNET_MAX_MESSAGE_SIZE < msize) |
990 | return NULL; | 993 | return NULL; |
991 | data = GNUNET_new(struct ManageServiceData); | 994 | data = GNUNET_new (struct ManageServiceData); |
992 | data->cb = cb; | 995 | data->cb = cb; |
993 | data->cb_cls = cb_cls; | 996 | data->cb_cls = cb_cls; |
994 | data->peer = peer; | 997 | data->peer = peer; |
995 | data->service_name = GNUNET_strdup(service_name); | 998 | data->service_name = GNUNET_strdup (service_name); |
996 | data->start = start; | 999 | data->start = start; |
997 | data->msize = (uint16_t)msize; | 1000 | data->msize = (uint16_t) msize; |
998 | opc = GNUNET_new(struct OperationContext); | 1001 | opc = GNUNET_new (struct OperationContext); |
999 | opc->data = data; | 1002 | opc->data = data; |
1000 | opc->c = peer->controller; | 1003 | opc->c = peer->controller; |
1001 | opc->id = GNUNET_TESTBED_get_next_op_id(opc->c); | 1004 | opc->id = GNUNET_TESTBED_get_next_op_id (opc->c); |
1002 | opc->type = OP_MANAGE_SERVICE; | 1005 | opc->type = OP_MANAGE_SERVICE; |
1003 | opc->op_cls = op_cls; | 1006 | opc->op_cls = op_cls; |
1004 | opc->op = | 1007 | opc->op = |
1005 | GNUNET_TESTBED_operation_create_(opc, &opstart_manage_service, | 1008 | GNUNET_TESTBED_operation_create_ (opc, &opstart_manage_service, |
1006 | &oprelease_manage_service); | 1009 | &oprelease_manage_service); |
1007 | GNUNET_TESTBED_operation_queue_insert_(opc->c->opq_parallel_operations, | 1010 | GNUNET_TESTBED_operation_queue_insert_ (opc->c->opq_parallel_operations, |
1008 | opc->op); | 1011 | opc->op); |
1009 | GNUNET_TESTBED_operation_begin_wait_(opc->op); | 1012 | GNUNET_TESTBED_operation_begin_wait_ (opc->op); |
1010 | return opc->op; | 1013 | return opc->op; |
1011 | } | 1014 | } |
1012 | 1015 | ||