aboutsummaryrefslogtreecommitdiff
path: root/src/testbed
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-08-10 20:03:22 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-08-10 20:03:22 +0000
commit2b53a7542cd3c26defc24464efba7377fa0c5c89 (patch)
tree351125fe95c7c12cddc910d15145a2db88234a4e /src/testbed
parent4693fb2d1f0c831dfc1621ab76e85e0ba233e3d7 (diff)
downloadgnunet-2b53a7542cd3c26defc24464efba7377fa0c5c89.tar.gz
gnunet-2b53a7542cd3c26defc24464efba7377fa0c5c89.zip
towards peer create forwarding
Diffstat (limited to 'src/testbed')
-rw-r--r--src/testbed/gnunet-service-testbed.c75
-rw-r--r--src/testbed/testbed_api.h4
2 files changed, 67 insertions, 12 deletions
diff --git a/src/testbed/gnunet-service-testbed.c b/src/testbed/gnunet-service-testbed.c
index c9781ba4e..017e8cea2 100644
--- a/src/testbed/gnunet-service-testbed.c
+++ b/src/testbed/gnunet-service-testbed.c
@@ -406,6 +406,29 @@ struct OverlayConnectContext
406 406
407 407
408/** 408/**
409 * Context data to be used when forwarding peer create messages
410 */
411struct PeerCreateContext
412{
413 /**
414 * The operation handle to peer create
415 */
416 struct GNUNET_TESTBED_operation *operation;
417
418 /**
419 * The ID of the operation which created this context
420 */
421 uint64_t operation_id;
422
423 /**
424 * The peer create timeout task id
425 */
426 GNUNET_SCHEDULER_TaskIdentifier timeout_task;
427
428};
429
430
431/**
409 * The master context; generated with the first INIT message 432 * The master context; generated with the first INIT message
410 */ 433 */
411static struct Context *master_context; 434static struct Context *master_context;
@@ -713,6 +736,29 @@ peer_list_remove (struct Peer *peer)
713 736
714 737
715/** 738/**
739 * Finds the route with directly connected host as destination through which
740 * the destination host can be reached
741 *
742 * @param host_id the id of the destination host
743 * @return the route with directly connected destination host; NULL if no route
744 * is found
745 */
746static struct Route *
747find_dest_route (uint32_t host_id)
748{
749 struct Route *route;
750
751 while(NULL != (route = route_list[host_id]))
752 {
753 if (route->thru == master_context->host_id)
754 break;
755 host_id = route->thru;
756 }
757 return route;
758}
759
760
761/**
716 * Routes message to a host given its host_id 762 * Routes message to a host given its host_id
717 * 763 *
718 * @param host_id the id of the destination host 764 * @param host_id the id of the destination host
@@ -1287,12 +1333,7 @@ handle_link_controllers (void *cls,
1287 lcfq->lcf = GNUNET_malloc (sizeof (struct LCFContext)); 1333 lcfq->lcf = GNUNET_malloc (sizeof (struct LCFContext));
1288 lcfq->lcf->delegated_host_id = delegated_host_id; 1334 lcfq->lcf->delegated_host_id = delegated_host_id;
1289 lcfq->lcf->slave_host_id = slave_host_id; 1335 lcfq->lcf->slave_host_id = slave_host_id;
1290 while (NULL != (route = route_list[slave_host_id])) 1336 route = find_dest_route (slave_host_id);
1291 {
1292 if (route->thru == master_context->host_id)
1293 break;
1294 slave_host_id = route->thru;
1295 }
1296 GNUNET_assert (NULL != route); /* because we add routes carefully */ 1337 GNUNET_assert (NULL != route); /* because we add routes carefully */
1297 GNUNET_assert (route->dest < slave_list_size); 1338 GNUNET_assert (route->dest < slave_list_size);
1298 GNUNET_assert (NULL != slave_list[route->dest]); 1339 GNUNET_assert (NULL != slave_list[route->dest]);
@@ -1335,10 +1376,13 @@ handle_peer_create (void *cls,
1335 const struct GNUNET_TESTBED_PeerCreateMessage *msg; 1376 const struct GNUNET_TESTBED_PeerCreateMessage *msg;
1336 struct GNUNET_TESTBED_PeerCreateSuccessEventMessage *reply; 1377 struct GNUNET_TESTBED_PeerCreateSuccessEventMessage *reply;
1337 struct GNUNET_CONFIGURATION_Handle *cfg; 1378 struct GNUNET_CONFIGURATION_Handle *cfg;
1379 struct PeerCreateContext *pc_ctxt;
1380 struct Route *route;
1338 char *config; 1381 char *config;
1339 size_t dest_size; 1382 size_t dest_size;
1340 int ret; 1383 int ret;
1341 uint32_t config_size; 1384 uint32_t config_size;
1385 uint32_t host_id;
1342 uint16_t msize; 1386 uint16_t msize;
1343 1387
1344 1388
@@ -1350,7 +1394,8 @@ handle_peer_create (void *cls,
1350 return; 1394 return;
1351 } 1395 }
1352 msg = (const struct GNUNET_TESTBED_PeerCreateMessage *) message; 1396 msg = (const struct GNUNET_TESTBED_PeerCreateMessage *) message;
1353 if (ntohl (msg->host_id) == master_context->host_id) 1397 host_id = ntohl (msg->host_id);
1398 if (host_id == master_context->host_id)
1354 { 1399 {
1355 struct Peer *peer; 1400 struct Peer *peer;
1356 char *emsg; 1401 char *emsg;
@@ -1411,10 +1456,18 @@ handle_peer_create (void *cls,
1411 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1456 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1412 return; 1457 return;
1413 } 1458 }
1414 1459
1415 /* FIXME: Forward the peer to other host */ 1460 /* Forward peer create request */
1416 GNUNET_break (0); 1461 route = find_dest_route (host_id);
1417 GNUNET_SERVER_receive_done (client, GNUNET_OK); 1462 if (NULL == route)
1463 {
1464 GNUNET_break (0);
1465 GNUNET_SERVER_receive_done (client, GNUNET_OK);
1466 return;
1467 }
1468 pc_ctxt = GNUNET_malloc (sizeof (struct PeerCreateContext));
1469 pc_ctxt->operation_id = GNUNET_ntohll (msg->operation_id);
1470 /* To be continued .. :) */
1418} 1471}
1419 1472
1420 1473
diff --git a/src/testbed/testbed_api.h b/src/testbed/testbed_api.h
index 4e73c63af..c5520a8c1 100644
--- a/src/testbed/testbed_api.h
+++ b/src/testbed/testbed_api.h
@@ -345,6 +345,8 @@ GNUNET_TESTBED_operation_add_ (struct GNUNET_TESTBED_Operation *op);
345 */ 345 */
346struct GNUNET_TESTBED_HelperInit * 346struct GNUNET_TESTBED_HelperInit *
347GNUNET_TESTBED_create_helper_init_msg_ (const char *cname, 347GNUNET_TESTBED_create_helper_init_msg_ (const char *cname,
348 const struct GNUNET_CONFIGURATION_Handle *cfg); 348 const struct
349 GNUNET_CONFIGURATION_Handle *cfg);
350
349 351
350#endif 352#endif