aboutsummaryrefslogtreecommitdiff
path: root/src/testbed
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-06-27 16:52:08 +0000
committerChristian Grothoff <christian@grothoff.org>2016-06-27 16:52:08 +0000
commit9335b7094d8a11449c322b2ca3f5a6cb7a257dad (patch)
tree9b0c7369111ab6e0ded80329a65a0c51e37e2b7f /src/testbed
parentf27f46409ec33cef42379006d561d33a2ae44682 (diff)
downloadgnunet-9335b7094d8a11449c322b2ca3f5a6cb7a257dad.tar.gz
gnunet-9335b7094d8a11449c322b2ca3f5a6cb7a257dad.zip
-use more of MQ API
Diffstat (limited to 'src/testbed')
-rw-r--r--src/testbed/gnunet-service-testbed_oc.c1
-rw-r--r--src/testbed/testbed_api.c100
-rw-r--r--src/testbed/testbed_api_peers.c104
3 files changed, 119 insertions, 86 deletions
diff --git a/src/testbed/gnunet-service-testbed_oc.c b/src/testbed/gnunet-service-testbed_oc.c
index 44f408764..de462da7a 100644
--- a/src/testbed/gnunet-service-testbed_oc.c
+++ b/src/testbed/gnunet-service-testbed_oc.c
@@ -1722,7 +1722,6 @@ rocc_hello_sent_cb (void *cls)
1722 GST_CONNECTIONPOOL_SERVICE_ATS_CONNECTIVITY, 1722 GST_CONNECTIONPOOL_SERVICE_ATS_CONNECTIVITY,
1723 &occ_cache_get_handle_ats_rocc_cb, 1723 &occ_cache_get_handle_ats_rocc_cb,
1724 rocc, NULL, NULL, NULL); 1724 rocc, NULL, NULL, NULL);
1725
1726} 1725}
1727 1726
1728 1727
diff --git a/src/testbed/testbed_api.c b/src/testbed/testbed_api.c
index aad5055ef..b74b48b69 100644
--- a/src/testbed/testbed_api.c
+++ b/src/testbed/testbed_api.c
@@ -1288,7 +1288,6 @@ handle_barrier_status (void *cls,
1288 * 1288 *
1289 * @param controller the handle to the controller 1289 * @param controller the handle to the controller
1290 * @param msg the message to queue 1290 * @param msg the message to queue
1291 * @deprecated
1292 */ 1291 */
1293void 1292void
1294GNUNET_TESTBED_queue_message_ (struct GNUNET_TESTBED_Controller *controller, 1293GNUNET_TESTBED_queue_message_ (struct GNUNET_TESTBED_Controller *controller,
@@ -1328,17 +1327,27 @@ GNUNET_TESTBED_queue_message_ (struct GNUNET_TESTBED_Controller *controller,
1328 * operation 1327 * operation
1329 */ 1328 */
1330struct OperationContext * 1329struct OperationContext *
1331GNUNET_TESTBED_forward_operation_msg_ (struct GNUNET_TESTBED_Controller 1330GNUNET_TESTBED_forward_operation_msg_ (struct GNUNET_TESTBED_Controller *controller,
1332 *controller, uint64_t operation_id, 1331 uint64_t operation_id,
1333 const struct GNUNET_MessageHeader *msg, 1332 const struct GNUNET_MessageHeader *msg,
1334 GNUNET_CLIENT_MessageHandler cc, 1333 GNUNET_CLIENT_MessageHandler cc,
1335 void *cc_cls) 1334 void *cc_cls)
1336{ 1335{
1337 struct OperationContext *opc; 1336 struct OperationContext *opc;
1338 struct ForwardedOperationData *data; 1337 struct ForwardedOperationData *data;
1339 struct GNUNET_MessageHeader *dup_msg; 1338 struct GNUNET_MQ_Envelope *env;
1340 uint16_t msize; 1339 struct GNUNET_MessageHeader *m2;
1340 uint16_t type = ntohs (msg->type);
1341 uint16_t size = ntohs (msg->size);
1341 1342
1343 env = GNUNET_MQ_msg_extra (m2,
1344 size - sizeof (*m2),
1345 type);
1346 memcpy (m2,
1347 msg,
1348 size);
1349 GNUNET_MQ_send (controller->mq,
1350 env);
1342 data = GNUNET_new (struct ForwardedOperationData); 1351 data = GNUNET_new (struct ForwardedOperationData);
1343 data->cc = cc; 1352 data->cc = cc;
1344 data->cc_cls = cc_cls; 1353 data->cc_cls = cc_cls;
@@ -1347,11 +1356,8 @@ GNUNET_TESTBED_forward_operation_msg_ (struct GNUNET_TESTBED_Controller
1347 opc->type = OP_FORWARDED; 1356 opc->type = OP_FORWARDED;
1348 opc->data = data; 1357 opc->data = data;
1349 opc->id = operation_id; 1358 opc->id = operation_id;
1350 msize = ntohs (msg->size); 1359 GNUNET_TESTBED_insert_opc_ (controller,
1351 dup_msg = GNUNET_malloc (msize); 1360 opc);
1352 (void) memcpy (dup_msg, msg, msize);
1353 GNUNET_TESTBED_queue_message_ (opc->c, dup_msg);
1354 GNUNET_TESTBED_insert_opc_ (controller, opc);
1355 return opc; 1361 return opc;
1356} 1362}
1357 1363
@@ -1365,7 +1371,8 @@ GNUNET_TESTBED_forward_operation_msg_ (struct GNUNET_TESTBED_Controller
1365void 1371void
1366GNUNET_TESTBED_forward_operation_msg_cancel_ (struct OperationContext *opc) 1372GNUNET_TESTBED_forward_operation_msg_cancel_ (struct OperationContext *opc)
1367{ 1373{
1368 GNUNET_TESTBED_remove_opc_ (opc->c, opc); 1374 GNUNET_TESTBED_remove_opc_ (opc->c,
1375 opc);
1369 GNUNET_free (opc->data); 1376 GNUNET_free (opc->data);
1370 GNUNET_free (opc); 1377 GNUNET_free (opc);
1371} 1378}
@@ -1561,11 +1568,13 @@ GNUNET_TESTBED_controller_connect (struct GNUNET_TESTBED_Host *host,
1561 GNUNET_MQ_handler_end () 1568 GNUNET_MQ_handler_end ()
1562 }; 1569 };
1563 struct GNUNET_TESTBED_InitMessage *msg; 1570 struct GNUNET_TESTBED_InitMessage *msg;
1571 struct GNUNET_MQ_Envelope *env;
1564 const struct GNUNET_CONFIGURATION_Handle *cfg; 1572 const struct GNUNET_CONFIGURATION_Handle *cfg;
1565 const char *controller_hostname; 1573 const char *controller_hostname;
1566 unsigned long long max_parallel_operations; 1574 unsigned long long max_parallel_operations;
1567 unsigned long long max_parallel_service_connections; 1575 unsigned long long max_parallel_service_connections;
1568 unsigned long long max_parallel_topology_config_operations; 1576 unsigned long long max_parallel_topology_config_operations;
1577 size_t slen;
1569 1578
1570 GNUNET_assert (NULL != (cfg = GNUNET_TESTBED_host_get_cfg_ (host))); 1579 GNUNET_assert (NULL != (cfg = GNUNET_TESTBED_host_get_cfg_ (host)));
1571 if (GNUNET_OK != 1580 if (GNUNET_OK !=
@@ -1626,18 +1635,17 @@ GNUNET_TESTBED_controller_connect (struct GNUNET_TESTBED_Host *host,
1626 controller_hostname = GNUNET_TESTBED_host_get_hostname (host); 1635 controller_hostname = GNUNET_TESTBED_host_get_hostname (host);
1627 if (NULL == controller_hostname) 1636 if (NULL == controller_hostname)
1628 controller_hostname = "127.0.0.1"; 1637 controller_hostname = "127.0.0.1";
1629 msg = 1638 slen = strlen (controller_hostname) + 1;
1630 GNUNET_malloc (sizeof (struct GNUNET_TESTBED_InitMessage) + 1639 env = GNUNET_MQ_msg_extra (msg,
1631 strlen (controller_hostname) + 1); 1640 slen,
1632 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_INIT); 1641 GNUNET_MESSAGE_TYPE_TESTBED_INIT);
1633 msg->header.size =
1634 htons (sizeof (struct GNUNET_TESTBED_InitMessage) +
1635 strlen (controller_hostname) + 1);
1636 msg->host_id = htonl (GNUNET_TESTBED_host_get_id_ (host)); 1642 msg->host_id = htonl (GNUNET_TESTBED_host_get_id_ (host));
1637 msg->event_mask = GNUNET_htonll (controller->event_mask); 1643 msg->event_mask = GNUNET_htonll (controller->event_mask);
1638 strcpy ((char *) &msg[1], controller_hostname); 1644 memcpy (&msg[1],
1639 GNUNET_TESTBED_queue_message_ (controller, 1645 controller_hostname,
1640 (struct GNUNET_MessageHeader *) msg); 1646 slen);
1647 GNUNET_MQ_send (controller->mq,
1648 env);
1641 return controller; 1649 return controller;
1642} 1650}
1643 1651
@@ -2182,16 +2190,17 @@ static void
2182opstart_shutdown_peers (void *cls) 2190opstart_shutdown_peers (void *cls)
2183{ 2191{
2184 struct OperationContext *opc = cls; 2192 struct OperationContext *opc = cls;
2193 struct GNUNET_MQ_Envelope *env;
2185 struct GNUNET_TESTBED_ShutdownPeersMessage *msg; 2194 struct GNUNET_TESTBED_ShutdownPeersMessage *msg;
2186 2195
2187 opc->state = OPC_STATE_STARTED; 2196 opc->state = OPC_STATE_STARTED;
2188 msg = GNUNET_new (struct GNUNET_TESTBED_ShutdownPeersMessage); 2197 env = GNUNET_MQ_msg (msg,
2189 msg->header.size = 2198 GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS);
2190 htons (sizeof (struct GNUNET_TESTBED_ShutdownPeersMessage));
2191 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_SHUTDOWN_PEERS);
2192 msg->operation_id = GNUNET_htonll (opc->id); 2199 msg->operation_id = GNUNET_htonll (opc->id);
2193 GNUNET_TESTBED_insert_opc_ (opc->c, opc); 2200 GNUNET_TESTBED_insert_opc_ (opc->c,
2194 GNUNET_TESTBED_queue_message_ (opc->c, &msg->header); 2201 opc);
2202 GNUNET_MQ_send (opc->c->mq,
2203 env);
2195} 2204}
2196 2205
2197 2206
@@ -2330,10 +2339,10 @@ GNUNET_TESTBED_barrier_init_ (struct GNUNET_TESTBED_Controller *controller,
2330 int echo) 2339 int echo)
2331{ 2340{
2332 struct GNUNET_TESTBED_BarrierInit *msg; 2341 struct GNUNET_TESTBED_BarrierInit *msg;
2342 struct GNUNET_MQ_Envelope *env;
2333 struct GNUNET_TESTBED_Barrier *barrier; 2343 struct GNUNET_TESTBED_Barrier *barrier;
2334 struct GNUNET_HashCode key; 2344 struct GNUNET_HashCode key;
2335 size_t name_len; 2345 size_t name_len;
2336 uint16_t msize;
2337 2346
2338 GNUNET_assert (quorum <= 100); 2347 GNUNET_assert (quorum <= 100);
2339 GNUNET_assert (NULL != cb); 2348 GNUNET_assert (NULL != cb);
@@ -2362,13 +2371,16 @@ GNUNET_TESTBED_barrier_init_ (struct GNUNET_TESTBED_Controller *controller,
2362 &barrier->key, 2371 &barrier->key,
2363 barrier, 2372 barrier,
2364 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)); 2373 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST));
2365 msize = name_len + sizeof (struct GNUNET_TESTBED_BarrierInit); 2374
2366 msg = GNUNET_malloc (msize); 2375 env = GNUNET_MQ_msg_extra (msg,
2367 msg->header.size = htons (msize); 2376 name_len,
2368 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT); 2377 GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_INIT);
2369 msg->quorum = (uint8_t) quorum; 2378 msg->quorum = (uint8_t) quorum;
2370 (void) memcpy (msg->name, barrier->name, name_len); 2379 memcpy (msg->name,
2371 GNUNET_TESTBED_queue_message_ (barrier->c, &msg->header); 2380 barrier->name,
2381 name_len);
2382 GNUNET_MQ_send (barrier->c->mq,
2383 env);
2372 return barrier; 2384 return barrier;
2373} 2385}
2374 2386
@@ -2406,15 +2418,19 @@ GNUNET_TESTBED_barrier_init (struct GNUNET_TESTBED_Controller *controller,
2406void 2418void
2407GNUNET_TESTBED_barrier_cancel (struct GNUNET_TESTBED_Barrier *barrier) 2419GNUNET_TESTBED_barrier_cancel (struct GNUNET_TESTBED_Barrier *barrier)
2408{ 2420{
2421 struct GNUNET_MQ_Envelope *env;
2409 struct GNUNET_TESTBED_BarrierCancel *msg; 2422 struct GNUNET_TESTBED_BarrierCancel *msg;
2410 uint16_t msize; 2423 size_t slen;
2411 2424
2412 msize = sizeof (struct GNUNET_TESTBED_BarrierCancel) + strlen (barrier->name); 2425 slen = strlen (barrier->name);
2413 msg = GNUNET_malloc (msize); 2426 env = GNUNET_MQ_msg_extra (msg,
2414 msg->header.size = htons (msize); 2427 slen,
2415 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_CANCEL); 2428 GNUNET_MESSAGE_TYPE_TESTBED_BARRIER_CANCEL);
2416 (void) memcpy (msg->name, barrier->name, strlen (barrier->name)); 2429 memcpy (msg->name,
2417 GNUNET_TESTBED_queue_message_ (barrier->c, &msg->header); 2430 barrier->name,
2431 slen);
2432 GNUNET_MQ_send (barrier->c->mq,
2433 env);
2418 GNUNET_TESTBED_barrier_remove_ (barrier); 2434 GNUNET_TESTBED_barrier_remove_ (barrier);
2419} 2435}
2420 2436
diff --git a/src/testbed/testbed_api_peers.c b/src/testbed/testbed_api_peers.c
index 884d4ffca..c30f960c8 100644
--- a/src/testbed/testbed_api_peers.c
+++ b/src/testbed/testbed_api_peers.c
@@ -99,30 +99,36 @@ opstart_peer_create (void *cls)
99 struct OperationContext *opc = cls; 99 struct OperationContext *opc = cls;
100 struct PeerCreateData *data = opc->data; 100 struct PeerCreateData *data = opc->data;
101 struct GNUNET_TESTBED_PeerCreateMessage *msg; 101 struct GNUNET_TESTBED_PeerCreateMessage *msg;
102 struct GNUNET_MQ_Envelope *env;
102 char *config; 103 char *config;
103 char *xconfig; 104 char *xconfig;
104 size_t c_size; 105 size_t c_size;
105 size_t xc_size; 106 size_t xc_size;
106 uint16_t msize;
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, &c_size); 112 config = GNUNET_CONFIGURATION_serialize (data->cfg,
113 xc_size = GNUNET_TESTBED_compress_config_ (config, c_size, &xconfig); 113 &c_size);
114 xc_size = GNUNET_TESTBED_compress_config_ (config,
115 c_size,
116 &xconfig);
114 GNUNET_free (config); 117 GNUNET_free (config);
115 msize = xc_size + sizeof (struct GNUNET_TESTBED_PeerCreateMessage); 118 env = GNUNET_MQ_msg_extra (msg,
116 msg = GNUNET_realloc (xconfig, msize); 119 xc_size,
117 memmove (&msg[1], msg, xc_size); 120 GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER);
118 msg->header.size = htons (msize);
119 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_CREATE_PEER);
120 msg->operation_id = GNUNET_htonll (opc->id); 121 msg->operation_id = GNUNET_htonll (opc->id);
121 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));
122 msg->peer_id = htonl (data->peer->unique_id); 123 msg->peer_id = htonl (data->peer->unique_id);
123 msg->config_size = htons ((uint16_t) c_size); 124 msg->config_size = htons ((uint16_t) c_size);
125 memcpy (&msg[1],
126 xconfig,
127 xc_size);
128 GNUNET_MQ_send (opc->c->mq,
129 env);
130 GNUNET_free (xconfig);
124 GNUNET_TESTBED_insert_opc_ (opc->c, opc); 131 GNUNET_TESTBED_insert_opc_ (opc->c, opc);
125 GNUNET_TESTBED_queue_message_ (opc->c, &msg->header);
126} 132}
127 133
128 134
@@ -163,17 +169,18 @@ opstart_peer_destroy (void *cls)
163 struct OperationContext *opc = cls; 169 struct OperationContext *opc = cls;
164 struct GNUNET_TESTBED_Peer *peer = opc->data; 170 struct GNUNET_TESTBED_Peer *peer = opc->data;
165 struct GNUNET_TESTBED_PeerDestroyMessage *msg; 171 struct GNUNET_TESTBED_PeerDestroyMessage *msg;
172 struct GNUNET_MQ_Envelope *env;
166 173
167 GNUNET_assert (OP_PEER_DESTROY == opc->type); 174 GNUNET_assert (OP_PEER_DESTROY == opc->type);
168 GNUNET_assert (NULL != peer); 175 GNUNET_assert (NULL != peer);
169 opc->state = OPC_STATE_STARTED; 176 opc->state = OPC_STATE_STARTED;
170 msg = GNUNET_new (struct GNUNET_TESTBED_PeerDestroyMessage); 177 env = GNUNET_MQ_msg (msg,
171 msg->header.size = htons (sizeof (struct GNUNET_TESTBED_PeerDestroyMessage)); 178 GNUNET_MESSAGE_TYPE_TESTBED_DESTROY_PEER);
172 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_DESTROY_PEER);
173 msg->peer_id = htonl (peer->unique_id); 179 msg->peer_id = htonl (peer->unique_id);
174 msg->operation_id = GNUNET_htonll (opc->id); 180 msg->operation_id = GNUNET_htonll (opc->id);
175 GNUNET_TESTBED_insert_opc_ (opc->c, opc); 181 GNUNET_TESTBED_insert_opc_ (opc->c, opc);
176 GNUNET_TESTBED_queue_message_ (peer->controller, &msg->header); 182 GNUNET_MQ_send (peer->controller->mq,
183 env);
177} 184}
178 185
179 186
@@ -211,6 +218,7 @@ opstart_peer_start (void *cls)
211{ 218{
212 struct OperationContext *opc = cls; 219 struct OperationContext *opc = cls;
213 struct GNUNET_TESTBED_PeerStartMessage *msg; 220 struct GNUNET_TESTBED_PeerStartMessage *msg;
221 struct GNUNET_MQ_Envelope *env;
214 struct PeerEventData *data; 222 struct PeerEventData *data;
215 struct GNUNET_TESTBED_Peer *peer; 223 struct GNUNET_TESTBED_Peer *peer;
216 224
@@ -219,13 +227,13 @@ opstart_peer_start (void *cls)
219 GNUNET_assert (NULL != (peer = data->peer)); 227 GNUNET_assert (NULL != (peer = data->peer));
220 GNUNET_assert ((TESTBED_PS_CREATED == peer->state) || (TESTBED_PS_STOPPED == peer->state)); 228 GNUNET_assert ((TESTBED_PS_CREATED == peer->state) || (TESTBED_PS_STOPPED == peer->state));
221 opc->state = OPC_STATE_STARTED; 229 opc->state = OPC_STATE_STARTED;
222 msg = GNUNET_new (struct GNUNET_TESTBED_PeerStartMessage); 230 env = GNUNET_MQ_msg (msg,
223 msg->header.size = htons (sizeof (struct GNUNET_TESTBED_PeerStartMessage)); 231 GNUNET_MESSAGE_TYPE_TESTBED_START_PEER);
224 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_START_PEER);
225 msg->peer_id = htonl (peer->unique_id); 232 msg->peer_id = htonl (peer->unique_id);
226 msg->operation_id = GNUNET_htonll (opc->id); 233 msg->operation_id = GNUNET_htonll (opc->id);
227 GNUNET_TESTBED_insert_opc_ (opc->c, opc); 234 GNUNET_TESTBED_insert_opc_ (opc->c, opc);
228 GNUNET_TESTBED_queue_message_ (peer->controller, &msg->header); 235 GNUNET_MQ_send (peer->controller->mq,
236 env);
229} 237}
230 238
231 239
@@ -266,18 +274,19 @@ opstart_peer_stop (void *cls)
266 struct GNUNET_TESTBED_PeerStopMessage *msg; 274 struct GNUNET_TESTBED_PeerStopMessage *msg;
267 struct PeerEventData *data; 275 struct PeerEventData *data;
268 struct GNUNET_TESTBED_Peer *peer; 276 struct GNUNET_TESTBED_Peer *peer;
277 struct GNUNET_MQ_Envelope *env;
269 278
270 GNUNET_assert (NULL != (data = opc->data)); 279 GNUNET_assert (NULL != (data = opc->data));
271 GNUNET_assert (NULL != (peer = data->peer)); 280 GNUNET_assert (NULL != (peer = data->peer));
272 GNUNET_assert (TESTBED_PS_STARTED == peer->state); 281 GNUNET_assert (TESTBED_PS_STARTED == peer->state);
273 opc->state = OPC_STATE_STARTED; 282 opc->state = OPC_STATE_STARTED;
274 msg = GNUNET_new (struct GNUNET_TESTBED_PeerStopMessage); 283 env = GNUNET_MQ_msg (msg,
275 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_STOP_PEER); 284 GNUNET_MESSAGE_TYPE_TESTBED_STOP_PEER);
276 msg->header.size = htons (sizeof (struct GNUNET_TESTBED_PeerStopMessage));
277 msg->peer_id = htonl (peer->unique_id); 285 msg->peer_id = htonl (peer->unique_id);
278 msg->operation_id = GNUNET_htonll (opc->id); 286 msg->operation_id = GNUNET_htonll (opc->id);
279 GNUNET_TESTBED_insert_opc_ (opc->c, opc); 287 GNUNET_TESTBED_insert_opc_ (opc->c, opc);
280 GNUNET_TESTBED_queue_message_ (peer->controller, &msg->header); 288 GNUNET_MQ_send (peer->controller->mq,
289 env);
281} 290}
282 291
283 292
@@ -404,22 +413,23 @@ static void
404opstart_overlay_connect (void *cls) 413opstart_overlay_connect (void *cls)
405{ 414{
406 struct OperationContext *opc = cls; 415 struct OperationContext *opc = cls;
416 struct GNUNET_MQ_Envelope *env;
407 struct GNUNET_TESTBED_OverlayConnectMessage *msg; 417 struct GNUNET_TESTBED_OverlayConnectMessage *msg;
408 struct OverlayConnectData *data; 418 struct OverlayConnectData *data;
409 419
410 opc->state = OPC_STATE_STARTED; 420 opc->state = OPC_STATE_STARTED;
411 data = opc->data; 421 data = opc->data;
412 GNUNET_assert (NULL != data); 422 GNUNET_assert (NULL != data);
413 msg = GNUNET_new (struct GNUNET_TESTBED_OverlayConnectMessage); 423 env = GNUNET_MQ_msg (msg,
414 msg->header.size = 424 GNUNET_MESSAGE_TYPE_TESTBED_OVERLAY_CONNECT);
415 htons (sizeof (struct GNUNET_TESTBED_OverlayConnectMessage));
416 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_OVERLAY_CONNECT);
417 msg->peer1 = htonl (data->p1->unique_id); 425 msg->peer1 = htonl (data->p1->unique_id);
418 msg->peer2 = htonl (data->p2->unique_id); 426 msg->peer2 = htonl (data->p2->unique_id);
419 msg->operation_id = GNUNET_htonll (opc->id); 427 msg->operation_id = GNUNET_htonll (opc->id);
420 msg->peer2_host_id = htonl (GNUNET_TESTBED_host_get_id_ (data->p2->host)); 428 msg->peer2_host_id = htonl (GNUNET_TESTBED_host_get_id_ (data->p2->host));
421 GNUNET_TESTBED_insert_opc_ (opc->c, opc); 429 GNUNET_TESTBED_insert_opc_ (opc->c,
422 GNUNET_TESTBED_queue_message_ (opc->c, &msg->header); 430 opc);
431 GNUNET_MQ_send (opc->c->mq,
432 env);
423} 433}
424 434
425 435
@@ -460,31 +470,34 @@ opstart_peer_reconfigure (void *cls)
460{ 470{
461 struct OperationContext *opc = cls; 471 struct OperationContext *opc = cls;
462 struct PeerReconfigureData *data = opc->data; 472 struct PeerReconfigureData *data = opc->data;
473 struct GNUNET_MQ_Envelope *env;
463 struct GNUNET_TESTBED_PeerReconfigureMessage *msg; 474 struct GNUNET_TESTBED_PeerReconfigureMessage *msg;
464 char *xconfig; 475 char *xconfig;
465 size_t xc_size; 476 size_t xc_size;
466 uint16_t msize;
467 477
468 opc->state = OPC_STATE_STARTED; 478 opc->state = OPC_STATE_STARTED;
469 GNUNET_assert (NULL != data); 479 GNUNET_assert (NULL != data);
470 xc_size = GNUNET_TESTBED_compress_config_ (data->config, data->cfg_size, 480 xc_size = GNUNET_TESTBED_compress_config_ (data->config,
481 data->cfg_size,
471 &xconfig); 482 &xconfig);
472 GNUNET_free (data->config); 483 GNUNET_free (data->config);
473 data->config = NULL; 484 data->config = NULL;
474 GNUNET_assert (xc_size <= UINT16_MAX); 485 GNUNET_assert (xc_size < UINT16_MAX - sizeof (*msg));
475 msize = (uint16_t) xc_size + 486 env = GNUNET_MQ_msg_extra (msg,
476 sizeof (struct GNUNET_TESTBED_PeerReconfigureMessage); 487 xc_size,
477 msg = GNUNET_realloc (xconfig, msize); 488 GNUNET_MESSAGE_TYPE_TESTBED_RECONFIGURE_PEER);
478 (void) memmove (&msg[1], msg, xc_size);
479 msg->header.size = htons (msize);
480 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_RECONFIGURE_PEER);
481 msg->peer_id = htonl (data->peer->unique_id); 489 msg->peer_id = htonl (data->peer->unique_id);
482 msg->operation_id = GNUNET_htonll (opc->id); 490 msg->operation_id = GNUNET_htonll (opc->id);
483 msg->config_size = htons (data->cfg_size); 491 msg->config_size = htons (data->cfg_size);
492 memcpy (&msg[1],
493 xconfig,
494 xc_size);
495 GNUNET_free (xconfig);
484 GNUNET_free (data); 496 GNUNET_free (data);
485 opc->data = NULL; 497 opc->data = NULL;
486 GNUNET_TESTBED_insert_opc_ (opc->c, opc); 498 GNUNET_TESTBED_insert_opc_ (opc->c, opc);
487 GNUNET_TESTBED_queue_message_ (opc->c, &msg->header); 499 GNUNET_MQ_send (opc->c->mq,
500 env);
488} 501}
489 502
490 503
@@ -873,22 +886,27 @@ opstart_manage_service (void *cls)
873{ 886{
874 struct OperationContext *opc = cls; 887 struct OperationContext *opc = cls;
875 struct ManageServiceData *data = opc->data; 888 struct ManageServiceData *data = opc->data;
889 struct GNUNET_MQ_Envelope *env;
876 struct GNUNET_TESTBED_ManagePeerServiceMessage *msg; 890 struct GNUNET_TESTBED_ManagePeerServiceMessage *msg;
891 size_t xlen;
877 892
878 GNUNET_assert (NULL != data); 893 GNUNET_assert (NULL != data);
879 msg = GNUNET_malloc (data->msize); 894 xlen = data->msize - sizeof (struct GNUNET_TESTBED_ManagePeerServiceMessage);
880 msg->header.size = htons (data->msize); 895 env = GNUNET_MQ_msg_extra (msg,
881 msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_MANAGE_PEER_SERVICE); 896 xlen,
897 GNUNET_MESSAGE_TYPE_TESTBED_MANAGE_PEER_SERVICE);
882 msg->peer_id = htonl (data->peer->unique_id); 898 msg->peer_id = htonl (data->peer->unique_id);
883 msg->operation_id = GNUNET_htonll (opc->id); 899 msg->operation_id = GNUNET_htonll (opc->id);
884 msg->start = (uint8_t) data->start; 900 msg->start = (uint8_t) data->start;
885 (void) memcpy (&msg[1], data->service_name, data->msize 901 memcpy (&msg[1],
886 - sizeof (struct GNUNET_TESTBED_ManagePeerServiceMessage)); 902 data->service_name,
903 xlen);
887 GNUNET_free (data->service_name); 904 GNUNET_free (data->service_name);
888 data->service_name = NULL; 905 data->service_name = NULL;
889 opc->state = OPC_STATE_STARTED; 906 opc->state = OPC_STATE_STARTED;
890 GNUNET_TESTBED_insert_opc_ (opc->c, opc); 907 GNUNET_TESTBED_insert_opc_ (opc->c, opc);
891 GNUNET_TESTBED_queue_message_ (opc->c, &msg->header); 908 GNUNET_MQ_send (opc->c->mq,
909 env);
892} 910}
893 911
894 912