aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/testbed_api_testbed.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testbed/testbed_api_testbed.c')
-rw-r--r--src/testbed/testbed_api_testbed.c125
1 files changed, 80 insertions, 45 deletions
diff --git a/src/testbed/testbed_api_testbed.c b/src/testbed/testbed_api_testbed.c
index 5900a863e..c4cfe59b1 100644
--- a/src/testbed/testbed_api_testbed.c
+++ b/src/testbed/testbed_api_testbed.c
@@ -815,8 +815,17 @@ static void
815create_peers (struct RunContext *rc) 815create_peers (struct RunContext *rc)
816{ 816{
817 struct RunContextOperation *rcop; 817 struct RunContextOperation *rcop;
818 struct GNUNET_TESTBED_Host *host;
818 unsigned int peer; 819 unsigned int peer;
820#if ENABLE_LL
821 struct Island *island;
822 unsigned int icnt;
823 unsigned int hcnt;
819 824
825 island = NULL;
826 icnt = 0;
827 hcnt = 0;
828#endif
820 DEBUG ("Creating peers\n"); 829 DEBUG ("Creating peers\n");
821 rc->pstart_time = GNUNET_TIME_absolute_get (); 830 rc->pstart_time = GNUNET_TIME_absolute_get ();
822 rc->peers = 831 rc->peers =
@@ -827,12 +836,31 @@ create_peers (struct RunContext *rc)
827 { 836 {
828 rcop = GNUNET_malloc (sizeof (struct RunContextOperation)); 837 rcop = GNUNET_malloc (sizeof (struct RunContextOperation));
829 rcop->rc = rc; 838 rcop->rc = rc;
830 rcop->op = 839#if ENABLE_LL
831 GNUNET_TESTBED_peer_create (rc->c, 840 if (0 != rc->nislands)
832 (0 == 841 {
833 rc->num_hosts) ? rc->h : rc->hosts[peer % 842 island = rc->islands[icnt];
834 rc->num_hosts], 843 if (hcnt == island->nhosts)
835 rc->cfg, &peer_create_cb, rcop); 844 {
845 icnt++;
846 if (icnt == rc->nislands)
847 icnt = 0;
848 island = rc->islands[icnt];
849 hcnt = 0;
850 }
851 GNUNET_assert (icnt < rc->nislands);
852 GNUNET_assert (hcnt < island->nhosts);
853 GNUNET_assert (NULL != island->hosts[hcnt]);
854 host = island->hosts[hcnt];
855 hcnt++;
856 }
857 else
858 host = rc->h;
859#else
860 host = (0 == rc->num_hosts) ? rc->h : rc->hosts[peer % rc->num_hosts];
861#endif
862 rcop->op = GNUNET_TESTBED_peer_create (rc->c, host, rc->cfg,
863 &peer_create_cb, rcop);
836 GNUNET_assert (NULL != rcop->op); 864 GNUNET_assert (NULL != rcop->op);
837 insert_rcop (rc, rcop); 865 insert_rcop (rc, rcop);
838 } 866 }
@@ -900,7 +928,7 @@ event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
900 } 928 }
901 } 929 }
902 if (0 != rc->reg_hosts) 930 if (0 != rc->reg_hosts)
903 return; 931 return;
904 rc->state = RC_LINKED; 932 rc->state = RC_LINKED;
905 create_peers (rc); 933 create_peers (rc);
906#endif 934#endif
@@ -934,6 +962,7 @@ event_cb (void *cls, const struct GNUNET_TESTBED_EventInformation *event)
934 return; 962 return;
935 rc->state = RC_LINKED; 963 rc->state = RC_LINKED;
936 create_peers (rc); 964 create_peers (rc);
965 return;
937 default: 966 default:
938 GNUNET_break (0); 967 GNUNET_break (0);
939 shutdown_now (rc); 968 shutdown_now (rc);
@@ -1180,6 +1209,49 @@ controller_status_cb (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg,
1180} 1209}
1181 1210
1182 1211
1212#if ENABLE_LL
1213#define ISLANDNAME_SIZE 4
1214static void
1215parse_islands (struct RunContext *rc)
1216{
1217 char island_id[ISLANDNAME_SIZE];
1218 struct GNUNET_TESTBED_Host *host;
1219 struct Island *island;
1220 const char *hostname;
1221 unsigned int nhost;
1222
1223 DEBUG ("Parsing for islands\n");
1224 memset (island_id, 0, ISLANDNAME_SIZE);
1225 island = NULL;
1226 for (nhost = 0; nhost < rc->num_hosts; nhost++)
1227 {
1228 host = rc->hosts[nhost];
1229 hostname = GNUNET_TESTBED_host_get_hostname (host);
1230 GNUNET_assert (NULL != hostname);
1231 if (NULL == island)
1232 {
1233 strncpy (island_id, hostname, ISLANDNAME_SIZE - 1);
1234 island = GNUNET_malloc (sizeof (struct Island));
1235 }
1236 if (0 == strncmp (island_id, hostname, ISLANDNAME_SIZE - 1))
1237 {
1238 GNUNET_array_append (island->hosts, island->nhosts, host);
1239 continue;
1240 }
1241 DEBUG ("Adding island `%s' with %u hosts\n", island_id, island->nhosts);
1242 GNUNET_array_append (rc->islands, rc->nislands, island);
1243 island = NULL;
1244 }
1245 if (NULL != island)
1246 {
1247 DEBUG ("Adding island `%s' with %u hosts\n", island_id, island->nhosts);
1248 GNUNET_array_append (rc->islands, rc->nislands, island);
1249 }
1250 DEBUG ("Total islands parsed: %u\n", rc->nislands);
1251}
1252#endif
1253
1254
1183/** 1255/**
1184 * Callback function invoked for each interface found. 1256 * Callback function invoked for each interface found.
1185 * 1257 *
@@ -1274,6 +1346,7 @@ host_habitable_cb (void *cls, const struct GNUNET_TESTBED_Host *host,
1274 GNUNET_free (rc->hosts); 1346 GNUNET_free (rc->hosts);
1275 rc->hosts = NULL; 1347 rc->hosts = NULL;
1276 } 1348 }
1349 parse_islands (rc);
1277 GNUNET_OS_network_interfaces_list (netint_proc, rc); 1350 GNUNET_OS_network_interfaces_list (netint_proc, rc);
1278 if (NULL == rc->trusted_ip) 1351 if (NULL == rc->trusted_ip)
1279 rc->trusted_ip = GNUNET_strdup ("127.0.0.1"); 1352 rc->trusted_ip = GNUNET_strdup ("127.0.0.1");
@@ -1310,43 +1383,6 @@ timeout_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
1310} 1383}
1311 1384
1312 1385
1313#if ENABLE_LL
1314static void
1315parse_islands (struct RunContext *rc)
1316{
1317#define ISLANDNAME_SIZE 4
1318 char island_id[ISLANDNAME_SIZE];
1319 struct GNUNET_TESTBED_Host *host;
1320 struct Island *island;
1321 const char *hostname;
1322 unsigned int nhost;
1323
1324 memset (island_id, 0, ISLANDNAME_SIZE);
1325 island = NULL;
1326 for (nhost = 0; nhost < rc->num_hosts; nhost++)
1327 {
1328 host = rc->hosts[nhost];
1329 hostname = GNUNET_TESTBED_host_get_hostname (host);
1330 GNUNET_assert (NULL != hostname);
1331 if (NULL == island)
1332 {
1333 strncpy (island_id, hostname, ISLANDNAME_SIZE - 1);
1334 island = GNUNET_malloc (sizeof (struct Island));
1335 }
1336 if (0 == strncmp (island_id, hostname, ISLANDNAME_SIZE - 1))
1337 {
1338 GNUNET_array_append (island->hosts, island->nhosts, host);
1339 continue;
1340 }
1341 DEBUG ("Adding island `%s' with %u hosts\n", island_id, island->nhosts);
1342 GNUNET_array_append (rc->islands, rc->nislands, island);
1343 island = NULL;
1344 }
1345 if (NULL != island)
1346 GNUNET_array_append (rc->islands, rc->nislands, island);
1347}
1348#endif
1349
1350/** 1386/**
1351 * Convenience method for running a testbed with 1387 * Convenience method for running a testbed with
1352 * a single call. Underlay and overlay topology 1388 * a single call. Underlay and overlay topology
@@ -1402,7 +1438,6 @@ GNUNET_TESTBED_run (const char *host_filename,
1402 _("No hosts loaded from LoadLeveler. Need at least one host\n")); 1438 _("No hosts loaded from LoadLeveler. Need at least one host\n"));
1403 goto error_cleanup; 1439 goto error_cleanup;
1404 } 1440 }
1405 parse_islands (rc);
1406#else 1441#else
1407 if (NULL != host_filename) 1442 if (NULL != host_filename)
1408 { 1443 {