diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2012-10-11 11:03:50 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2012-10-11 11:03:50 +0000 |
commit | ccd83827be97d2de6a592e7bb65c3487e14d7fbc (patch) | |
tree | 4a099d8da488f79c30d5d9876de41a6488d39f43 /src/testbed/gnunet-service-testbed.c | |
parent | 60e33ab01ef51657fc668266002a7e123828d852 (diff) | |
download | gnunet-ccd83827be97d2de6a592e7bb65c3487e14d7fbc.tar.gz gnunet-ccd83827be97d2de6a592e7bb65c3487e14d7fbc.zip |
overlay connect suboperations
Diffstat (limited to 'src/testbed/gnunet-service-testbed.c')
-rw-r--r-- | src/testbed/gnunet-service-testbed.c | 120 |
1 files changed, 105 insertions, 15 deletions
diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c index da0d8b982..b26bd9d97 100644 --- a/src/testbed/gnunet-service-testbed.c +++ b/src/testbed/gnunet-service-testbed.c | |||
@@ -559,6 +559,21 @@ struct ForwardedOverlayConnectContext | |||
559 | struct GNUNET_TESTBED_Operation *sub_op; | 559 | struct GNUNET_TESTBED_Operation *sub_op; |
560 | 560 | ||
561 | /** | 561 | /** |
562 | * The client which initiated the link controller operation | ||
563 | */ | ||
564 | struct GNUNET_SERVER_Client *client; | ||
565 | |||
566 | /** | ||
567 | * A copy of the original overlay connect message | ||
568 | */ | ||
569 | struct GNUNET_MessageHeader *orig_msg; | ||
570 | |||
571 | /** | ||
572 | * The id of the operation which created this context information | ||
573 | */ | ||
574 | uint64_t operation_id; | ||
575 | |||
576 | /** | ||
562 | * Enumeration of states for this context | 577 | * Enumeration of states for this context |
563 | */ | 578 | */ |
564 | enum FOCCState { | 579 | enum FOCCState { |
@@ -1199,6 +1214,34 @@ lcf_proc_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1199 | 1214 | ||
1200 | 1215 | ||
1201 | /** | 1216 | /** |
1217 | * Callback to be called when forwarded overlay connection operation has a reply | ||
1218 | * from the sub-controller successfull. We have to relay the reply msg back to | ||
1219 | * the client | ||
1220 | * | ||
1221 | * @param cls ForwardedOperationContext | ||
1222 | * @param msg the peer create success message | ||
1223 | */ | ||
1224 | static void | ||
1225 | forwarded_overlay_connect_listener (void *cls, | ||
1226 | const struct GNUNET_MessageHeader *msg); | ||
1227 | |||
1228 | |||
1229 | /** | ||
1230 | * Cleans up ForwardedOverlayConnectContext | ||
1231 | * | ||
1232 | * @param focc the ForwardedOverlayConnectContext to cleanup | ||
1233 | */ | ||
1234 | static void | ||
1235 | cleanup_focc (struct ForwardedOverlayConnectContext *focc) | ||
1236 | { | ||
1237 | if (NULL != focc->sub_op) | ||
1238 | GNUNET_TESTBED_operation_done (focc->sub_op); | ||
1239 | GNUNET_SERVER_client_drop (focc->client); | ||
1240 | GNUNET_free_non_null (focc->orig_msg); | ||
1241 | GNUNET_free (focc); | ||
1242 | } | ||
1243 | |||
1244 | /** | ||
1202 | * Callback for event from slave controllers | 1245 | * Callback for event from slave controllers |
1203 | * | 1246 | * |
1204 | * @param cls struct Slave * | 1247 | * @param cls struct Slave * |
@@ -1209,22 +1252,64 @@ slave_event_callback (void *cls, | |||
1209 | const struct GNUNET_TESTBED_EventInformation *event) | 1252 | const struct GNUNET_TESTBED_EventInformation *event) |
1210 | { | 1253 | { |
1211 | struct ForwardedOverlayConnectContext *focc; | 1254 | struct ForwardedOverlayConnectContext *focc; |
1255 | struct ForwardedOperationContext *fopc; | ||
1212 | struct GNUNET_CONFIGURATION_Handle *slave_cfg; | 1256 | struct GNUNET_CONFIGURATION_Handle *slave_cfg; |
1257 | struct GNUNET_TESTBED_Operation *old_op; | ||
1258 | char *emsg; | ||
1213 | 1259 | ||
1214 | /* We currently only get here when doing overlay connect operations and that | 1260 | /* We currently only get here when doing overlay connect operations and that |
1215 | too while trying out sub operations */ | 1261 | too while trying out sub operations */ |
1216 | if (GNUNET_TESTBED_ET_OPERATION_FINISHED != event->type) | 1262 | GNUNET_assert (GNUNET_TESTBED_ET_OPERATION_FINISHED != event->type); |
1217 | return; | ||
1218 | focc = event->details.operation_finished.op_cls; | 1263 | focc = event->details.operation_finished.op_cls; |
1264 | if (NULL != event->details.operation_finished.emsg) | ||
1265 | { | ||
1266 | GNUNET_asprintf (&emsg, "Failure executing suboperation: %s", | ||
1267 | event->details.operation_finished.emsg); | ||
1268 | send_operation_fail_msg (focc->client, focc->operation_id, | ||
1269 | emsg); | ||
1270 | GNUNET_free (emsg); | ||
1271 | cleanup_focc (focc); | ||
1272 | return; | ||
1273 | } | ||
1219 | switch (focc->state) | 1274 | switch (focc->state) |
1220 | { | 1275 | { |
1221 | case FOCC_GET_CFG: | 1276 | case FOCC_GET_CFG: |
1222 | slave_cfg = event->details.operation_finished.generic; | 1277 | slave_cfg = event->details.operation_finished.generic; |
1223 | GNUNET_break (0); /* FIXME */ | 1278 | old_op = focc->sub_op; |
1224 | GNUNET_CONFIGURATION_destroy (slave_cfg); | 1279 | focc->state = FOCC_LINK; |
1225 | default: | 1280 | focc->sub_op = GNUNET_TESTBED_controller_link_ (focc, |
1281 | focc->gateway, | ||
1282 | focc->peer2_host_id, | ||
1283 | peer_list[focc->peer1]->details.remote.remote_host_id, | ||
1284 | slave_cfg, | ||
1285 | GNUNET_NO); | ||
1286 | GNUNET_TESTBED_operation_done (old_op); | ||
1287 | break; | ||
1288 | case FOCC_LINK: | ||
1289 | GNUNET_TESTBED_operation_done (focc->sub_op); | ||
1290 | focc->sub_op = NULL; | ||
1291 | focc->state = FOCC_OL_CONNECT; | ||
1292 | fopc = GNUNET_malloc (sizeof (struct ForwardedOperationContext)); | ||
1293 | fopc->client = focc->client; | ||
1294 | focc->client = NULL; | ||
1295 | fopc->operation_id = focc->operation_id; | ||
1296 | fopc->cls = NULL; | ||
1297 | fopc->opc = | ||
1298 | GNUNET_TESTBED_forward_operation_msg_ (focc->gateway, | ||
1299 | focc->operation_id, focc->orig_msg, | ||
1300 | &forwarded_operation_reply_relay, | ||
1301 | fopc); | ||
1302 | GNUNET_free (focc->orig_msg); | ||
1303 | focc->orig_msg = NULL; | ||
1304 | fopc->timeout_task = | ||
1305 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &forwarded_operation_timeout, | ||
1306 | fopc); | ||
1307 | cleanup_focc (focc); | ||
1308 | break; | ||
1309 | default: | ||
1226 | GNUNET_assert (0); | 1310 | GNUNET_assert (0); |
1227 | } | 1311 | } |
1312 | return; | ||
1228 | } | 1313 | } |
1229 | 1314 | ||
1230 | 1315 | ||
@@ -2528,7 +2613,9 @@ forwarded_overlay_connect_listener (void *cls, | |||
2528 | case FOCC_INIT: | 2613 | case FOCC_INIT: |
2529 | if (GNUNET_MESSAGE_TYPE_TESTBED_NEEDCONTROLLERCONFIG != ntohs (msg->type)) | 2614 | if (GNUNET_MESSAGE_TYPE_TESTBED_NEEDCONTROLLERCONFIG != ntohs (msg->type)) |
2530 | { | 2615 | { |
2531 | GNUNET_break (0); /* Something failed; you may check output of sub-controllers */ | 2616 | GNUNET_break (0); /* Something failed; you may check output of |
2617 | sub-controllers */ | ||
2618 | cleanup_focc (focc); | ||
2532 | forwarded_operation_reply_relay (cls, msg); | 2619 | forwarded_operation_reply_relay (cls, msg); |
2533 | return; | 2620 | return; |
2534 | } | 2621 | } |
@@ -2536,18 +2623,14 @@ forwarded_overlay_connect_listener (void *cls, | |||
2536 | focc->state = FOCC_GET_CFG; | 2623 | focc->state = FOCC_GET_CFG; |
2537 | focc->sub_op = GNUNET_TESTBED_get_slave_config_ (focc, focc->gateway2, | 2624 | focc->sub_op = GNUNET_TESTBED_get_slave_config_ (focc, focc->gateway2, |
2538 | focc->peer2_host_id); | 2625 | focc->peer2_host_id); |
2539 | /* FIXME */ | ||
2540 | GNUNET_break (0); | ||
2541 | break; | 2626 | break; |
2542 | /* focc->op = GNUNET_TESTBED_controller_link (focc, */ | ||
2543 | /* focc->gateway, */ | ||
2544 | /* slave_list[peer2_host_id], */ | ||
2545 | /* slave_list[peer_list[focc->peer1]->remote_host_id], */ | ||
2546 | /* slave_list */ | ||
2547 | |||
2548 | default: | 2627 | default: |
2549 | GNUNET_assert (0); | 2628 | GNUNET_assert (0); |
2550 | } | 2629 | } |
2630 | GNUNET_SERVER_client_drop (fopc->client); | ||
2631 | GNUNET_SCHEDULER_cancel (fopc->timeout_task); | ||
2632 | fopc->timeout_task = GNUNET_SCHEDULER_NO_TASK; | ||
2633 | GNUNET_free (fopc); | ||
2551 | } | 2634 | } |
2552 | 2635 | ||
2553 | 2636 | ||
@@ -2604,7 +2687,9 @@ handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client, | |||
2604 | if (route_to_peer2_host->dest != route_to_peer1_host->dest) | 2687 | if (route_to_peer2_host->dest != route_to_peer1_host->dest) |
2605 | { | 2688 | { |
2606 | struct ForwardedOverlayConnectContext *focc; | 2689 | struct ForwardedOverlayConnectContext *focc; |
2607 | 2690 | uint16_t msize; | |
2691 | |||
2692 | msize = sizeof (struct GNUNET_TESTBED_OverlayConnectMessage); | ||
2608 | focc = GNUNET_malloc (sizeof (struct ForwardedOverlayConnectContext)); | 2693 | focc = GNUNET_malloc (sizeof (struct ForwardedOverlayConnectContext)); |
2609 | focc->gateway = peer->details.remote.controller; | 2694 | focc->gateway = peer->details.remote.controller; |
2610 | focc->gateway2 = slave_list[route_to_peer2_host->dest]->controller; | 2695 | focc->gateway2 = slave_list[route_to_peer2_host->dest]->controller; |
@@ -2612,6 +2697,11 @@ handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client, | |||
2612 | focc->peer2 = p2; | 2697 | focc->peer2 = p2; |
2613 | focc->peer2_host_id = peer2_host_id; | 2698 | focc->peer2_host_id = peer2_host_id; |
2614 | focc->state = FOCC_INIT; | 2699 | focc->state = FOCC_INIT; |
2700 | focc->orig_msg = GNUNET_malloc (msize); | ||
2701 | (void) memcpy (focc->orig_msg, message, msize); | ||
2702 | GNUNET_SERVER_client_keep (client); | ||
2703 | focc->client = client; | ||
2704 | focc->operation_id = operation_id; | ||
2615 | fopc->cls = focc; | 2705 | fopc->cls = focc; |
2616 | } | 2706 | } |
2617 | } | 2707 | } |