diff options
author | Sree Harsha Totakura <totakura@in.tum.de> | 2013-05-06 16:06:08 +0000 |
---|---|---|
committer | Sree Harsha Totakura <totakura@in.tum.de> | 2013-05-06 16:06:08 +0000 |
commit | ad25eef39dc8c15b85bd70c6585af95d7e687fd5 (patch) | |
tree | 152df39da268b913fd5a93467556ca9249e20416 /src/testbed/gnunet-service-testbed_oc.c | |
parent | e2bb863887e78b5847fd86ef5a399a5d13d856d3 (diff) | |
download | gnunet-ad25eef39dc8c15b85bd70c6585af95d7e687fd5.tar.gz gnunet-ad25eef39dc8c15b85bd70c6585af95d7e687fd5.zip |
- doc
Diffstat (limited to 'src/testbed/gnunet-service-testbed_oc.c')
-rw-r--r-- | src/testbed/gnunet-service-testbed_oc.c | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/src/testbed/gnunet-service-testbed_oc.c b/src/testbed/gnunet-service-testbed_oc.c index 744ae3d34..418defb25 100644 --- a/src/testbed/gnunet-service-testbed_oc.c +++ b/src/testbed/gnunet-service-testbed_oc.c | |||
@@ -439,7 +439,7 @@ GST_process_next_focc (struct RegisteredHostContext *rhc) | |||
439 | focc = rhc->focc_dll_head; | 439 | focc = rhc->focc_dll_head; |
440 | GNUNET_assert (NULL != focc); | 440 | GNUNET_assert (NULL != focc); |
441 | GNUNET_assert (RHC_DONE == rhc->state); | 441 | GNUNET_assert (RHC_DONE == rhc->state); |
442 | GNUNET_assert (!INVALID_PEER_ID (focc->peer1)); | 442 | GNUNET_assert (VALID_PEER_ID (focc->peer1)); |
443 | peer = GST_peer_list[focc->peer1]; | 443 | peer = GST_peer_list[focc->peer1]; |
444 | GNUNET_assert (GNUNET_YES == peer->is_remote); | 444 | GNUNET_assert (GNUNET_YES == peer->is_remote); |
445 | GNUNET_assert (NULL != (slave = peer->details.remote.slave)); | 445 | GNUNET_assert (NULL != (slave = peer->details.remote.slave)); |
@@ -1199,14 +1199,27 @@ hash_hosts (struct GNUNET_TESTBED_Host *reg_host, | |||
1199 | } | 1199 | } |
1200 | 1200 | ||
1201 | 1201 | ||
1202 | /** | ||
1203 | * Checks if the given host is registered at the given slave. | ||
1204 | * | ||
1205 | * @param slave the slave where registration has to be checked. The check is | ||
1206 | * actually done through a locally maintained hashmap. No | ||
1207 | * communication with the slave is involved. | ||
1208 | * @param host the host to register | ||
1209 | * @return If the given host is not registered already or the registration is | ||
1210 | * pending, it returns the registration context. Any overlay connects | ||
1211 | * to be forwarded should be queued in the context so that they can be | ||
1212 | * executed when the registration is completed. If the given host is | ||
1213 | * already registered, NULL is returned. | ||
1214 | */ | ||
1202 | static struct RegisteredHostContext * | 1215 | static struct RegisteredHostContext * |
1203 | register_p2_host (struct Slave *slave, uint32_t peer2_host_id) | 1216 | register_host (struct Slave *slave, struct GNUNET_TESTBED_Host *host) |
1204 | { | 1217 | { |
1205 | struct GNUNET_HashCode hash; | 1218 | struct GNUNET_HashCode hash; |
1206 | struct RegisteredHostContext *rhc; | 1219 | struct RegisteredHostContext *rhc; |
1207 | 1220 | ||
1208 | rhc = GNUNET_malloc (sizeof (struct RegisteredHostContext)); | 1221 | rhc = GNUNET_malloc (sizeof (struct RegisteredHostContext)); |
1209 | rhc->reg_host = GST_host_list[peer2_host_id]; | 1222 | rhc->reg_host = host; |
1210 | rhc->host = GST_host_list[slave->host_id]; | 1223 | rhc->host = GST_host_list[slave->host_id]; |
1211 | GNUNET_assert (NULL != rhc->reg_host); | 1224 | GNUNET_assert (NULL != rhc->reg_host); |
1212 | GNUNET_assert (NULL != rhc->host); | 1225 | GNUNET_assert (NULL != rhc->host); |
@@ -1268,8 +1281,8 @@ forward_overlay_connect (const struct GNUNET_TESTBED_OverlayConnectMessage *msg, | |||
1268 | p2 = ntohl (msg->peer2); | 1281 | p2 = ntohl (msg->peer2); |
1269 | op_id = GNUNET_ntohll (msg->operation_id); | 1282 | op_id = GNUNET_ntohll (msg->operation_id); |
1270 | peer2_host_id = ntohl (msg->peer2_host_id); | 1283 | peer2_host_id = ntohl (msg->peer2_host_id); |
1271 | GNUNET_assert (! INVALID_PEER_ID (p1)); | 1284 | GNUNET_assert (VALID_PEER_ID (p1)); |
1272 | GNUNET_assert (! INVALID_HOST_ID (peer2_host_id)); | 1285 | GNUNET_assert (VALID_HOST_ID (peer2_host_id)); |
1273 | peer = GST_peer_list[p1]; | 1286 | peer = GST_peer_list[p1]; |
1274 | GNUNET_assert (GNUNET_YES == peer->is_remote); | 1287 | GNUNET_assert (GNUNET_YES == peer->is_remote); |
1275 | LOG_DEBUG ("0x%llx: Forwarding overlay connect\n", op_id); | 1288 | LOG_DEBUG ("0x%llx: Forwarding overlay connect\n", op_id); |
@@ -1282,10 +1295,10 @@ forward_overlay_connect (const struct GNUNET_TESTBED_OverlayConnectMessage *msg, | |||
1282 | goto forward; | 1295 | goto forward; |
1283 | /* Peer2 is either with us OR peer1 and peer2 can be reached through | 1296 | /* Peer2 is either with us OR peer1 and peer2 can be reached through |
1284 | different subtrees OR peer2 is on a subtree unknown to us */ | 1297 | different subtrees OR peer2 is on a subtree unknown to us */ |
1285 | if (NULL != (rhc = register_p2_host (peer->details.remote.slave, | 1298 | if (NULL != (rhc = register_host (peer->details.remote.slave, |
1286 | peer2_host_id))) | 1299 | GST_host_list[peer2_host_id]))) |
1287 | { | 1300 | { |
1288 | LOG_DEBUG ("Forwarding with FOCC for connecting peers %u and %u\n", p1, p2); | 1301 | LOG_DEBUG ("Queueing forwarding FOCC for connecting peers %u and %u\n", p1, p2); |
1289 | focc = GNUNET_malloc (sizeof (struct ForwardedOverlayConnectContext)); | 1302 | focc = GNUNET_malloc (sizeof (struct ForwardedOverlayConnectContext)); |
1290 | focc->peer1 = p1; | 1303 | focc->peer1 = p1; |
1291 | focc->peer2 = p2; | 1304 | focc->peer2 = p2; |
@@ -1386,7 +1399,7 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client, | |||
1386 | msg = (const struct GNUNET_TESTBED_OverlayConnectMessage *) message; | 1399 | msg = (const struct GNUNET_TESTBED_OverlayConnectMessage *) message; |
1387 | p1 = ntohl (msg->peer1); | 1400 | p1 = ntohl (msg->peer1); |
1388 | p2 = ntohl (msg->peer2); | 1401 | p2 = ntohl (msg->peer2); |
1389 | if INVALID_PEER_ID (p1) | 1402 | if (!VALID_PEER_ID (p1)) |
1390 | { | 1403 | { |
1391 | GNUNET_break (0); | 1404 | GNUNET_break (0); |
1392 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1405 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
@@ -1400,7 +1413,7 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client, | |||
1400 | peer2_host_id = ntohl (msg->peer2_host_id); | 1413 | peer2_host_id = ntohl (msg->peer2_host_id); |
1401 | if (GNUNET_YES == peer->is_remote) | 1414 | if (GNUNET_YES == peer->is_remote) |
1402 | { | 1415 | { |
1403 | if INVALID_HOST_ID (peer2_host_id) | 1416 | if (!VALID_HOST_ID (peer2_host_id)) |
1404 | { | 1417 | { |
1405 | GNUNET_break (0); | 1418 | GNUNET_break (0); |
1406 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 1419 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
@@ -1413,11 +1426,11 @@ GST_handle_overlay_connect (void *cls, struct GNUNET_SERVER_Client *client, | |||
1413 | p2n = NULL; | 1426 | p2n = NULL; |
1414 | occ = GNUNET_malloc (sizeof (struct OverlayConnectContext)); | 1427 | occ = GNUNET_malloc (sizeof (struct OverlayConnectContext)); |
1415 | occ->type = OCC_TYPE_LOCAL; | 1428 | occ->type = OCC_TYPE_LOCAL; |
1416 | if INVALID_PEER_ID (p2) /* May be peer2 is on a another controller */ | 1429 | if (!VALID_PEER_ID (p2)) /* May be peer2 is on a another controller */ |
1417 | { | 1430 | { |
1418 | if (NULL == (p2n = GST_get_neighbour (peer2_host_id))) | 1431 | if (NULL == (p2n = GST_get_neighbour (peer2_host_id))) |
1419 | { | 1432 | { |
1420 | if (INVALID_HOST_ID (peer2_host_id)) | 1433 | if (!VALID_HOST_ID (peer2_host_id)) |
1421 | { | 1434 | { |
1422 | GNUNET_break (0); | 1435 | GNUNET_break (0); |
1423 | LOG (GNUNET_ERROR_TYPE_WARNING, | 1436 | LOG (GNUNET_ERROR_TYPE_WARNING, |