diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-10-10 15:47:00 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-10-10 15:47:00 +0000 |
commit | 93085e8a2991fde229400b588a5930e9fcca0d75 (patch) | |
tree | 0384246adbd96fa0138a46ad5fecb777aa40e789 /src/testbed/gnunet-service-testbed_oc.c | |
parent | 2bf962c76bb82c1f38acea42c7bdfb241e2582e7 (diff) | |
download | gnunet-93085e8a2991fde229400b588a5930e9fcca0d75.tar.gz gnunet-93085e8a2991fde229400b588a5930e9fcca0d75.zip |
migrating testbed to new service API
Diffstat (limited to 'src/testbed/gnunet-service-testbed_oc.c')
-rw-r--r-- | src/testbed/gnunet-service-testbed_oc.c | 225 |
1 files changed, 134 insertions, 91 deletions
diff --git a/src/testbed/gnunet-service-testbed_oc.c b/src/testbed/gnunet-service-testbed_oc.c index c681c3810..b775f31bd 100644 --- a/src/testbed/gnunet-service-testbed_oc.c +++ b/src/testbed/gnunet-service-testbed_oc.c | |||
@@ -168,7 +168,7 @@ struct OverlayConnectContext | |||
168 | * The client which has requested for overlay connection. This is used to send | 168 | * The client which has requested for overlay connection. This is used to send |
169 | * either a success of failure message | 169 | * either a success of failure message |
170 | */ | 170 | */ |
171 | struct GNUNET_SERVER_Client *client; | 171 | struct GNUNET_SERVICE_Client *client; |
172 | 172 | ||
173 | /** | 173 | /** |
174 | * the first peer which is to expect an overlay connection from the second peer. | 174 | * the first peer which is to expect an overlay connection from the second peer. |
@@ -358,7 +358,11 @@ static struct RemoteOverlayConnectCtx *roccq_tail; | |||
358 | void | 358 | void |
359 | GST_cleanup_focc (struct ForwardedOverlayConnectContext *focc) | 359 | GST_cleanup_focc (struct ForwardedOverlayConnectContext *focc) |
360 | { | 360 | { |
361 | GNUNET_SERVER_client_drop (focc->client); | 361 | struct RegisteredHostContext *rhc = focc->rhc; |
362 | |||
363 | GNUNET_CONTAINER_DLL_remove (rhc->focc_dll_head, | ||
364 | rhc->focc_dll_tail, | ||
365 | focc); | ||
362 | GNUNET_free_non_null (focc->orig_msg); | 366 | GNUNET_free_non_null (focc->orig_msg); |
363 | GNUNET_free (focc); | 367 | GNUNET_free (focc); |
364 | } | 368 | } |
@@ -376,10 +380,11 @@ forwarded_overlay_connect_timeout (void *cls) | |||
376 | struct RegisteredHostContext *rhc; | 380 | struct RegisteredHostContext *rhc; |
377 | struct ForwardedOverlayConnectContext *focc; | 381 | struct ForwardedOverlayConnectContext *focc; |
378 | 382 | ||
383 | fopc->timeout_task = NULL; | ||
379 | rhc = fopc->cls; | 384 | rhc = fopc->cls; |
380 | focc = rhc->focc_dll_head; | 385 | focc = rhc->focc_dll_head; |
381 | GNUNET_CONTAINER_DLL_remove (rhc->focc_dll_head, rhc->focc_dll_tail, focc); | 386 | LOG_DEBUG ("Overlay linking between peers %u and %u failed\n", |
382 | LOG_DEBUG ("Overlay linking between peers %u and %u failed\n", focc->peer1, | 387 | focc->peer1, |
383 | focc->peer2); | 388 | focc->peer2); |
384 | GST_cleanup_focc (focc); | 389 | GST_cleanup_focc (focc); |
385 | GST_forwarded_operation_timeout (fopc); | 390 | GST_forwarded_operation_timeout (fopc); |
@@ -407,7 +412,6 @@ forwarded_overlay_connect_listener (void *cls, | |||
407 | rhc = fopc->cls; | 412 | rhc = fopc->cls; |
408 | GST_forwarded_operation_reply_relay (cls, msg); | 413 | GST_forwarded_operation_reply_relay (cls, msg); |
409 | focc = rhc->focc_dll_head; | 414 | focc = rhc->focc_dll_head; |
410 | GNUNET_CONTAINER_DLL_remove (rhc->focc_dll_head, rhc->focc_dll_tail, focc); | ||
411 | GST_cleanup_focc (focc); | 415 | GST_cleanup_focc (focc); |
412 | if (NULL != rhc->focc_dll_head) | 416 | if (NULL != rhc->focc_dll_head) |
413 | GST_process_next_focc (rhc); | 417 | GST_process_next_focc (rhc); |
@@ -435,22 +439,24 @@ GST_process_next_focc (struct RegisteredHostContext *rhc) | |||
435 | GNUNET_assert (GNUNET_YES == peer->is_remote); | 439 | GNUNET_assert (GNUNET_YES == peer->is_remote); |
436 | GNUNET_assert (NULL != (slave = peer->details.remote.slave)); | 440 | GNUNET_assert (NULL != (slave = peer->details.remote.slave)); |
437 | fopc = GNUNET_new (struct ForwardedOperationContext); | 441 | fopc = GNUNET_new (struct ForwardedOperationContext); |
438 | GNUNET_SERVER_client_keep (focc->client); | ||
439 | fopc->client = focc->client; | 442 | fopc->client = focc->client; |
440 | fopc->operation_id = focc->operation_id; | 443 | fopc->operation_id = focc->operation_id; |
441 | fopc->cls = rhc; | 444 | fopc->cls = rhc; |
442 | fopc->type = OP_OVERLAY_CONNECT; | 445 | fopc->type = OP_OVERLAY_CONNECT; |
443 | fopc->opc = | 446 | fopc->opc = |
444 | GNUNET_TESTBED_forward_operation_msg_ (slave->controller, | 447 | GNUNET_TESTBED_forward_operation_msg_ (slave->controller, |
445 | focc->operation_id, focc->orig_msg, | 448 | focc->operation_id, |
449 | focc->orig_msg, | ||
446 | &forwarded_overlay_connect_listener, | 450 | &forwarded_overlay_connect_listener, |
447 | fopc); | 451 | fopc); |
448 | GNUNET_free (focc->orig_msg); | 452 | GNUNET_free (focc->orig_msg); |
449 | focc->orig_msg = NULL; | 453 | focc->orig_msg = NULL; |
450 | fopc->timeout_task = | 454 | fopc->timeout_task = GNUNET_SCHEDULER_add_delayed (GST_timeout, |
451 | GNUNET_SCHEDULER_add_delayed (GST_timeout, &forwarded_overlay_connect_timeout, | 455 | &forwarded_overlay_connect_timeout, |
456 | fopc); | ||
457 | GNUNET_CONTAINER_DLL_insert_tail (fopcq_head, | ||
458 | fopcq_tail, | ||
452 | fopc); | 459 | fopc); |
453 | GNUNET_CONTAINER_DLL_insert_tail (fopcq_head, fopcq_tail, fopc); | ||
454 | } | 460 | } |
455 | 461 | ||
456 | 462 | ||
@@ -533,7 +539,6 @@ cleanup_occ (struct OverlayConnectContext *occ) | |||
533 | occ->op_id); | 539 | occ->op_id); |
534 | GNUNET_free_non_null (occ->emsg); | 540 | GNUNET_free_non_null (occ->emsg); |
535 | GNUNET_free_non_null (occ->hello); | 541 | GNUNET_free_non_null (occ->hello); |
536 | GNUNET_SERVER_client_drop (occ->client); | ||
537 | if (NULL != occ->send_hello_task) | 542 | if (NULL != occ->send_hello_task) |
538 | GNUNET_SCHEDULER_cancel (occ->send_hello_task); | 543 | GNUNET_SCHEDULER_cancel (occ->send_hello_task); |
539 | if (NULL != occ->cleanup_task) | 544 | if (NULL != occ->cleanup_task) |
@@ -610,24 +615,58 @@ timeout_overlay_connect (void *cls) | |||
610 | 615 | ||
611 | 616 | ||
612 | /** | 617 | /** |
618 | * Notify OC subsystem that @a client disconnected. | ||
619 | * | ||
620 | * @param client the client that disconnected | ||
621 | */ | ||
622 | void | ||
623 | GST_notify_client_disconnect_oc (struct GNUNET_SERVICE_Client *client) | ||
624 | { | ||
625 | struct ForwardedOperationContext *fopc; | ||
626 | struct ForwardedOperationContext *fopcn; | ||
627 | struct OverlayConnectContext *occ; | ||
628 | struct OverlayConnectContext *occn; | ||
629 | |||
630 | for (fopc = fopcq_head; NULL != fopc; fopc = fopcn) | ||
631 | { | ||
632 | fopcn = fopc->next; | ||
633 | if (fopc->client == client) | ||
634 | { | ||
635 | GNUNET_SCHEDULER_cancel (fopc->timeout_task); | ||
636 | GST_forwarded_operation_timeout (fopc); | ||
637 | } | ||
638 | } | ||
639 | for (occ = occq_head; NULL != occ; occ = occn) | ||
640 | { | ||
641 | occn = occ->next; | ||
642 | if (occ->client == client) | ||
643 | cleanup_occ (occ); | ||
644 | } | ||
645 | // FIXME: implement clean up for client_keep replacements! | ||
646 | } | ||
647 | |||
648 | |||
649 | |||
650 | |||
651 | /** | ||
613 | * FIXME. | 652 | * FIXME. |
614 | */ | 653 | */ |
615 | static void | 654 | static void |
616 | send_overlay_connect_success_msg (struct OverlayConnectContext *occ) | 655 | send_overlay_connect_success_msg (struct OverlayConnectContext *occ) |
617 | { | 656 | { |
657 | struct GNUNET_MQ_Envelope *env; | ||
618 | struct GNUNET_TESTBED_ConnectionEventMessage *msg; | 658 | struct GNUNET_TESTBED_ConnectionEventMessage *msg; |
619 | 659 | ||
620 | LOG_DEBUG ("0x%llx: Peers connected - Sending overlay connect success\n", | 660 | LOG_DEBUG ("0x%llx: Peers connected - Sending overlay connect success\n", |
621 | occ->op_id); | 661 | occ->op_id); |
622 | msg = GNUNET_new (struct GNUNET_TESTBED_ConnectionEventMessage); | 662 | env = GNUNET_MQ_msg (msg, |
623 | msg->header.size = | 663 | GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONNECT_EVENT); |
624 | htons (sizeof (struct GNUNET_TESTBED_ConnectionEventMessage)); | ||
625 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_TESTBED_PEER_CONNECT_EVENT); | ||
626 | msg->event_type = htonl (GNUNET_TESTBED_ET_CONNECT); | 664 | msg->event_type = htonl (GNUNET_TESTBED_ET_CONNECT); |
627 | msg->peer1 = htonl (occ->peer->id); | 665 | msg->peer1 = htonl (occ->peer->id); |
628 | msg->peer2 = htonl (occ->other_peer_id); | 666 | msg->peer2 = htonl (occ->other_peer_id); |
629 | msg->operation_id = GNUNET_htonll (occ->op_id); | 667 | msg->operation_id = GNUNET_htonll (occ->op_id); |
630 | GST_queue_message (occ->client, &msg->header); | 668 | GNUNET_MQ_send (GNUNET_SERVICE_client_get_mq (occ->client), |
669 | env); | ||
631 | } | 670 | } |
632 | 671 | ||
633 | 672 | ||
@@ -1314,7 +1353,8 @@ register_host (struct Slave *slave, | |||
1314 | rhc->state = RHC_INIT; | 1353 | rhc->state = RHC_INIT; |
1315 | hash = hash_hosts (rhc->reg_host, rhc->host); | 1354 | hash = hash_hosts (rhc->reg_host, rhc->host); |
1316 | if ((GNUNET_NO == | 1355 | if ((GNUNET_NO == |
1317 | GNUNET_CONTAINER_multihashmap_contains (slave->reghost_map, &hash)) || | 1356 | GNUNET_CONTAINER_multihashmap_contains (slave->reghost_map, |
1357 | &hash)) || | ||
1318 | (GNUNET_SYSERR != | 1358 | (GNUNET_SYSERR != |
1319 | GNUNET_CONTAINER_multihashmap_get_multiple (slave->reghost_map, | 1359 | GNUNET_CONTAINER_multihashmap_get_multiple (slave->reghost_map, |
1320 | &hash, | 1360 | &hash, |
@@ -1323,10 +1363,14 @@ register_host (struct Slave *slave, | |||
1323 | { | 1363 | { |
1324 | /* create and add a new registerd host context */ | 1364 | /* create and add a new registerd host context */ |
1325 | /* add the focc to its queue */ | 1365 | /* add the focc to its queue */ |
1326 | GNUNET_CONTAINER_multihashmap_put (slave->reghost_map, &hash, rhc, | 1366 | GNUNET_CONTAINER_multihashmap_put (slave->reghost_map, |
1367 | &hash, | ||
1368 | rhc, | ||
1327 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 1369 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
1328 | GST_queue_host_registration (slave, host_registration_comp, | 1370 | GST_queue_host_registration (slave, |
1329 | rhc, rhc->reg_host); | 1371 | host_registration_comp, |
1372 | rhc, | ||
1373 | rhc->reg_host); | ||
1330 | } | 1374 | } |
1331 | else | 1375 | else |
1332 | { | 1376 | { |
@@ -1352,7 +1396,7 @@ register_host (struct Slave *slave, | |||
1352 | */ | 1396 | */ |
1353 | static void | 1397 | static void |
1354 | forward_overlay_connect (const struct GNUNET_TESTBED_OverlayConnectMessage *msg, | 1398 | forward_overlay_connect (const struct GNUNET_TESTBED_OverlayConnectMessage *msg, |
1355 | struct GNUNET_SERVER_Client *client) | 1399 | struct GNUNET_SERVICE_Client *client) |
1356 | { | 1400 | { |
1357 | struct ForwardedOperationContext *fopc; | 1401 | struct ForwardedOperationContext *fopc; |
1358 | struct Route *route_to_peer2_host; | 1402 | struct Route *route_to_peer2_host; |
@@ -1388,14 +1432,15 @@ forward_overlay_connect (const struct GNUNET_TESTBED_OverlayConnectMessage *msg, | |||
1388 | { | 1432 | { |
1389 | LOG_DEBUG ("Queueing forwarding FOCC for connecting peers %u and %u\n", p1, p2); | 1433 | LOG_DEBUG ("Queueing forwarding FOCC for connecting peers %u and %u\n", p1, p2); |
1390 | focc = GNUNET_new (struct ForwardedOverlayConnectContext); | 1434 | focc = GNUNET_new (struct ForwardedOverlayConnectContext); |
1435 | focc->rhc = rhc; | ||
1391 | focc->peer1 = p1; | 1436 | focc->peer1 = p1; |
1392 | focc->peer2 = p2; | 1437 | focc->peer2 = p2; |
1393 | focc->peer2_host_id = peer2_host_id; | 1438 | focc->peer2_host_id = peer2_host_id; |
1394 | focc->orig_msg = GNUNET_copy_message (&msg->header); | 1439 | focc->orig_msg = GNUNET_copy_message (&msg->header); |
1395 | focc->operation_id = op_id; | 1440 | focc->operation_id = op_id; |
1396 | focc->client = client; | 1441 | focc->client = client; |
1397 | GNUNET_SERVER_client_keep (client); | 1442 | GNUNET_CONTAINER_DLL_insert_tail (rhc->focc_dll_head, |
1398 | GNUNET_CONTAINER_DLL_insert_tail (rhc->focc_dll_head, rhc->focc_dll_tail, | 1443 | rhc->focc_dll_tail, |
1399 | focc); | 1444 | focc); |
1400 | return; | 1445 | return; |
1401 | } | 1446 | } |
@@ -1403,7 +1448,6 @@ forward_overlay_connect (const struct GNUNET_TESTBED_OverlayConnectMessage *msg, | |||
1403 | forward: | 1448 | forward: |
1404 | LOG_DEBUG ("Forwarding without FOCC for connecting peers %u and %u\n", p1, p2); | 1449 | LOG_DEBUG ("Forwarding without FOCC for connecting peers %u and %u\n", p1, p2); |
1405 | fopc = GNUNET_new (struct ForwardedOperationContext); | 1450 | fopc = GNUNET_new (struct ForwardedOperationContext); |
1406 | GNUNET_SERVER_client_keep (client); | ||
1407 | fopc->client = client; | 1451 | fopc->client = client; |
1408 | fopc->operation_id = op_id; | 1452 | fopc->operation_id = op_id; |
1409 | fopc->type = OP_OVERLAY_CONNECT; | 1453 | fopc->type = OP_OVERLAY_CONNECT; |
@@ -1450,7 +1494,8 @@ p2_controller_connect_cb (void *cls, | |||
1450 | cmsg.operation_id = GNUNET_htonll (occ->op_id); | 1494 | cmsg.operation_id = GNUNET_htonll (occ->op_id); |
1451 | rp2c->opc = | 1495 | rp2c->opc = |
1452 | GNUNET_TESTBED_forward_operation_msg_ (rp2c->p2c, | 1496 | GNUNET_TESTBED_forward_operation_msg_ (rp2c->p2c, |
1453 | occ->op_id, &cmsg.header, | 1497 | occ->op_id, |
1498 | &cmsg.header, | ||
1454 | &overlay_connect_get_config, | 1499 | &overlay_connect_get_config, |
1455 | occ); | 1500 | occ); |
1456 | GNUNET_free_non_null (occ->emsg); | 1501 | GNUNET_free_non_null (occ->emsg); |
@@ -1463,18 +1508,16 @@ p2_controller_connect_cb (void *cls, | |||
1463 | 1508 | ||
1464 | 1509 | ||
1465 | /** | 1510 | /** |
1466 | * Handler for #GNUNET_MESSAGE_TYPE_TESTBED_OLCONNECT messages | 1511 | * Handler for #GNUNET_MESSAGE_TYPE_TESTBED_OVERLAY_CONNECT messages |
1467 | * | 1512 | * |
1468 | * @param cls NULL | 1513 | * @param cls identification of the client |
1469 | * @param client identification of the client | 1514 | * @param msg the actual message |
1470 | * @param message the actual message | ||
1471 | */ | 1515 | */ |
1472 | void | 1516 | void |
1473 | GST_handle_overlay_connect (void *cls, | 1517 | handle_overlay_connect (void *cls, |
1474 | struct GNUNET_SERVER_Client *client, | 1518 | const struct GNUNET_TESTBED_OverlayConnectMessage *msg) |
1475 | const struct GNUNET_MessageHeader *message) | ||
1476 | { | 1519 | { |
1477 | const struct GNUNET_TESTBED_OverlayConnectMessage *msg; | 1520 | struct GNUNET_SERVICE_Client *client = cls; |
1478 | struct Peer *peer; | 1521 | struct Peer *peer; |
1479 | struct Peer *peer2; | 1522 | struct Peer *peer2; |
1480 | struct OverlayConnectContext *occ; | 1523 | struct OverlayConnectContext *occ; |
@@ -1484,20 +1527,12 @@ GST_handle_overlay_connect (void *cls, | |||
1484 | uint32_t p2; | 1527 | uint32_t p2; |
1485 | uint32_t peer2_host_id; | 1528 | uint32_t peer2_host_id; |
1486 | 1529 | ||
1487 | if (sizeof (struct GNUNET_TESTBED_OverlayConnectMessage) != | ||
1488 | ntohs (message->size)) | ||
1489 | { | ||
1490 | GNUNET_break (0); | ||
1491 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
1492 | return; | ||
1493 | } | ||
1494 | msg = (const struct GNUNET_TESTBED_OverlayConnectMessage *) message; | ||
1495 | p1 = ntohl (msg->peer1); | 1530 | p1 = ntohl (msg->peer1); |
1496 | p2 = ntohl (msg->peer2); | 1531 | p2 = ntohl (msg->peer2); |
1497 | if (!VALID_PEER_ID (p1)) | 1532 | if (! VALID_PEER_ID (p1)) |
1498 | { | 1533 | { |
1499 | GNUNET_break (0); | 1534 | GNUNET_break (0); |
1500 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1535 | GNUNET_SERVICE_client_drop (client); |
1501 | return; | 1536 | return; |
1502 | } | 1537 | } |
1503 | peer = GST_peer_list[p1]; | 1538 | peer = GST_peer_list[p1]; |
@@ -1513,30 +1548,27 @@ GST_handle_overlay_connect (void *cls, | |||
1513 | if (! VALID_HOST_ID (peer2_host_id)) | 1548 | if (! VALID_HOST_ID (peer2_host_id)) |
1514 | { | 1549 | { |
1515 | GNUNET_break (0); | 1550 | GNUNET_break (0); |
1516 | GNUNET_SERVER_receive_done (client, | 1551 | GNUNET_SERVICE_client_drop (client); |
1517 | GNUNET_SYSERR); | ||
1518 | return; | 1552 | return; |
1519 | } | 1553 | } |
1520 | forward_overlay_connect (msg, client); | 1554 | forward_overlay_connect (msg, client); |
1521 | GNUNET_SERVER_receive_done (client, | 1555 | GNUNET_SERVICE_client_continue (client); |
1522 | GNUNET_OK); | ||
1523 | return; | 1556 | return; |
1524 | } | 1557 | } |
1525 | p2n = NULL; | 1558 | p2n = NULL; |
1526 | occ = GNUNET_new (struct OverlayConnectContext); | 1559 | occ = GNUNET_new (struct OverlayConnectContext); |
1527 | occ->type = OCC_TYPE_LOCAL; | 1560 | occ->type = OCC_TYPE_LOCAL; |
1528 | if (!VALID_PEER_ID (p2)) /* May be peer2 is on a another controller */ | 1561 | if (! VALID_PEER_ID (p2)) /* May be peer2 is on a another controller */ |
1529 | { | 1562 | { |
1530 | if (NULL == (p2n = GST_get_neighbour (peer2_host_id))) | 1563 | if (NULL == (p2n = GST_get_neighbour (peer2_host_id))) |
1531 | { | 1564 | { |
1532 | if (!VALID_HOST_ID (peer2_host_id)) | 1565 | if (! VALID_HOST_ID (peer2_host_id)) |
1533 | { | 1566 | { |
1534 | GNUNET_break (0); | 1567 | GNUNET_break (0); |
1535 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1568 | LOG (GNUNET_ERROR_TYPE_WARNING, |
1536 | "0x%llx: Peer %u's host not in our neighbours list\n", | 1569 | "0x%llx: Peer %u's host not in our neighbours list\n", |
1537 | operation_id, p2); | 1570 | operation_id, p2); |
1538 | GNUNET_SERVER_receive_done (client, | 1571 | GNUNET_SERVICE_client_drop (client); |
1539 | GNUNET_SYSERR); | ||
1540 | GNUNET_free (occ); | 1572 | GNUNET_free (occ); |
1541 | return; | 1573 | return; |
1542 | } | 1574 | } |
@@ -1553,7 +1585,6 @@ GST_handle_overlay_connect (void *cls, | |||
1553 | GNUNET_CONTAINER_DLL_insert_tail (occq_head, | 1585 | GNUNET_CONTAINER_DLL_insert_tail (occq_head, |
1554 | occq_tail, | 1586 | occq_tail, |
1555 | occ); | 1587 | occ); |
1556 | GNUNET_SERVER_client_keep (client); | ||
1557 | occ->client = client; | 1588 | occ->client = client; |
1558 | occ->other_peer_id = p2; | 1589 | occ->other_peer_id = p2; |
1559 | GST_peer_list[p1]->reference_cnt++; | 1590 | GST_peer_list[p1]->reference_cnt++; |
@@ -1573,11 +1604,14 @@ GST_handle_overlay_connect (void *cls, | |||
1573 | occ->op_id, | 1604 | occ->op_id, |
1574 | occ->other_peer_id, | 1605 | occ->other_peer_id, |
1575 | peer2_host_id); | 1606 | peer2_host_id); |
1576 | occ->p2ctx.remote.ncn = | 1607 | occ->p2ctx.remote.ncn |
1577 | GST_neighbour_get_connection (p2n, &p2_controller_connect_cb, occ); | 1608 | = GST_neighbour_get_connection (p2n, |
1609 | &p2_controller_connect_cb, | ||
1610 | occ); | ||
1578 | break; | 1611 | break; |
1579 | case OCC_TYPE_REMOTE_SLAVE: | 1612 | case OCC_TYPE_REMOTE_SLAVE: |
1580 | p2_controller_connect_cb (occ, occ->p2ctx.remote.p2c); | 1613 | p2_controller_connect_cb (occ, |
1614 | occ->p2ctx.remote.p2c); | ||
1581 | break; | 1615 | break; |
1582 | case OCC_TYPE_LOCAL: | 1616 | case OCC_TYPE_LOCAL: |
1583 | peer2 = GST_peer_list[occ->other_peer_id]; | 1617 | peer2 = GST_peer_list[occ->other_peer_id]; |
@@ -1598,7 +1632,7 @@ GST_handle_overlay_connect (void *cls, | |||
1598 | &overlay_connect_notify, occ); | 1632 | &overlay_connect_notify, occ); |
1599 | break; | 1633 | break; |
1600 | } | 1634 | } |
1601 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1635 | GNUNET_SERVICE_client_continue (client); |
1602 | } | 1636 | } |
1603 | 1637 | ||
1604 | 1638 | ||
@@ -1793,64 +1827,72 @@ rocc_cache_get_handle_transport_cb (void *cls, | |||
1793 | 1827 | ||
1794 | 1828 | ||
1795 | /** | 1829 | /** |
1796 | * Handler for #GNUNET_MESSAGE_TYPE_TESTBED_REQUEST_CONNECT messages | 1830 | * Check #GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT messages |
1797 | * | 1831 | * |
1798 | * @param cls NULL | 1832 | * @param cls identification of the client |
1799 | * @param client identification of the client | 1833 | * @param msg the actual message |
1800 | * @param message the actual message | 1834 | * @return #GNUNET_OK if @a msg is well-formed |
1801 | */ | 1835 | */ |
1802 | void | 1836 | int |
1803 | GST_handle_remote_overlay_connect (void *cls, | 1837 | check_remote_overlay_connect (void *cls, |
1804 | struct GNUNET_SERVER_Client *client, | 1838 | const struct GNUNET_TESTBED_RemoteOverlayConnectMessage *msg) |
1805 | const struct GNUNET_MessageHeader *message) | ||
1806 | { | 1839 | { |
1807 | const struct GNUNET_TESTBED_RemoteOverlayConnectMessage *msg; | ||
1808 | struct RemoteOverlayConnectCtx *rocc; | ||
1809 | struct Peer *peer; | ||
1810 | struct GNUNET_PeerIdentity pid; | ||
1811 | static char pid_str[16]; | ||
1812 | uint32_t peer_id; | 1840 | uint32_t peer_id; |
1813 | uint16_t msize; | 1841 | uint16_t msize; |
1814 | uint16_t hsize; | 1842 | uint16_t hsize; |
1815 | 1843 | ||
1816 | msize = ntohs (message->size); | 1844 | msize = ntohs (msg->header.size); |
1817 | if (sizeof (struct GNUNET_TESTBED_RemoteOverlayConnectMessage) >= msize) | ||
1818 | { | ||
1819 | GNUNET_break (0); | ||
1820 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
1821 | return; | ||
1822 | } | ||
1823 | msg = (const struct GNUNET_TESTBED_RemoteOverlayConnectMessage *) message; | ||
1824 | if (GNUNET_MESSAGE_TYPE_HELLO != ntohs (msg->hello->type)) | 1845 | if (GNUNET_MESSAGE_TYPE_HELLO != ntohs (msg->hello->type)) |
1825 | { | 1846 | { |
1826 | GNUNET_break (0); | 1847 | GNUNET_break (0); |
1827 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1848 | return GNUNET_SYSERR; |
1828 | return; | ||
1829 | } | 1849 | } |
1830 | hsize = ntohs (msg->hello->size); | 1850 | hsize = ntohs (msg->hello->size); |
1831 | if ((sizeof (struct GNUNET_TESTBED_RemoteOverlayConnectMessage) + hsize) != | 1851 | if ((sizeof (struct GNUNET_TESTBED_RemoteOverlayConnectMessage) + hsize) != msize) |
1832 | msize) | ||
1833 | { | 1852 | { |
1834 | GNUNET_break (0); | 1853 | GNUNET_break (0); |
1835 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1854 | return GNUNET_SYSERR; |
1836 | return; | ||
1837 | } | 1855 | } |
1838 | peer_id = ntohl (msg->peer); | 1856 | peer_id = ntohl (msg->peer); |
1839 | if ((peer_id >= GST_peer_list_size) || | 1857 | if ((peer_id >= GST_peer_list_size) || |
1840 | (NULL == (peer = GST_peer_list[peer_id]))) | 1858 | (NULL == GST_peer_list[peer_id])) |
1841 | { | 1859 | { |
1842 | GNUNET_break_op (0); | 1860 | GNUNET_break_op (0); |
1843 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1861 | return GNUNET_SYSERR; |
1844 | return; | ||
1845 | } | 1862 | } |
1863 | return GNUNET_OK; | ||
1864 | } | ||
1865 | |||
1866 | |||
1867 | /** | ||
1868 | * Handler for #GNUNET_MESSAGE_TYPE_TESTBED_REMOTE_OVERLAY_CONNECT messages | ||
1869 | * | ||
1870 | * @param cls identification of the client | ||
1871 | * @param msg the actual message | ||
1872 | */ | ||
1873 | void | ||
1874 | handle_remote_overlay_connect (void *cls, | ||
1875 | const struct GNUNET_TESTBED_RemoteOverlayConnectMessage *msg) | ||
1876 | { | ||
1877 | struct GNUNET_SERVICE_Client *client = cls; | ||
1878 | struct RemoteOverlayConnectCtx *rocc; | ||
1879 | struct Peer *peer; | ||
1880 | struct GNUNET_PeerIdentity pid; | ||
1881 | static char pid_str[16]; | ||
1882 | uint32_t peer_id; | ||
1883 | uint16_t hsize; | ||
1884 | |||
1885 | hsize = ntohs (msg->hello->size); | ||
1886 | peer_id = ntohl (msg->peer); | ||
1887 | peer = GST_peer_list[peer_id]; | ||
1846 | if (GNUNET_YES == peer->is_remote) | 1888 | if (GNUNET_YES == peer->is_remote) |
1847 | { | 1889 | { |
1848 | struct GNUNET_MessageHeader *msg2; | 1890 | struct GNUNET_MessageHeader *msg2; |
1849 | 1891 | ||
1850 | msg2 = GNUNET_copy_message (message); | 1892 | msg2 = GNUNET_copy_message (&msg->header); |
1851 | GNUNET_TESTBED_queue_message_ (peer->details.remote.slave->controller, | 1893 | GNUNET_TESTBED_queue_message_ (peer->details.remote.slave->controller, |
1852 | msg2); | 1894 | msg2); |
1853 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 1895 | GNUNET_SERVICE_client_continue (client); |
1854 | return; | 1896 | return; |
1855 | } | 1897 | } |
1856 | rocc = GNUNET_new (struct RemoteOverlayConnectCtx); | 1898 | rocc = GNUNET_new (struct RemoteOverlayConnectCtx); |
@@ -1872,7 +1914,9 @@ GST_handle_remote_overlay_connect (void *cls, | |||
1872 | rocc->peer = peer; | 1914 | rocc->peer = peer; |
1873 | rocc->peer->reference_cnt++; | 1915 | rocc->peer->reference_cnt++; |
1874 | rocc->hello = GNUNET_malloc (hsize); | 1916 | rocc->hello = GNUNET_malloc (hsize); |
1875 | GNUNET_memcpy (rocc->hello, msg->hello, hsize); | 1917 | GNUNET_memcpy (rocc->hello, |
1918 | msg->hello, | ||
1919 | hsize); | ||
1876 | rocc->tcc.cgh_p2_th = | 1920 | rocc->tcc.cgh_p2_th = |
1877 | GST_connection_pool_get_handle (peer_id, | 1921 | GST_connection_pool_get_handle (peer_id, |
1878 | rocc->peer->details.local.cfg, | 1922 | rocc->peer->details.local.cfg, |
@@ -1886,8 +1930,7 @@ GST_handle_remote_overlay_connect (void *cls, | |||
1886 | GNUNET_SCHEDULER_add_delayed (GST_timeout, | 1930 | GNUNET_SCHEDULER_add_delayed (GST_timeout, |
1887 | &timeout_rocc_task, | 1931 | &timeout_rocc_task, |
1888 | rocc); | 1932 | rocc); |
1889 | GNUNET_SERVER_receive_done (client, | 1933 | GNUNET_SERVICE_client_continue (client); |
1890 | GNUNET_OK); | ||
1891 | } | 1934 | } |
1892 | 1935 | ||
1893 | 1936 | ||