diff options
Diffstat (limited to 'src/mesh')
-rw-r--r-- | src/mesh/gnunet-service-mesh.c | 307 | ||||
-rw-r--r-- | src/mesh/mesh_api.c | 77 | ||||
-rw-r--r-- | src/mesh/mesh_api_new.c | 67 | ||||
-rw-r--r-- | src/mesh/test_mesh_api.c | 28 | ||||
-rw-r--r-- | src/mesh/test_mesh_small.c | 169 |
5 files changed, 280 insertions, 368 deletions
diff --git a/src/mesh/gnunet-service-mesh.c b/src/mesh/gnunet-service-mesh.c index de1daecb0..338def09a 100644 --- a/src/mesh/gnunet-service-mesh.c +++ b/src/mesh/gnunet-service-mesh.c | |||
@@ -480,11 +480,9 @@ get_peer_info (const struct GNUNET_PeerIdentity *peer) | |||
480 | peer_info = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey); | 480 | peer_info = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey); |
481 | if (NULL == peer_info) | 481 | if (NULL == peer_info) |
482 | { | 482 | { |
483 | peer_info = (struct MeshPeerInfo *) | 483 | peer_info = |
484 | GNUNET_malloc (sizeof (struct MeshPeerInfo)); | 484 | (struct MeshPeerInfo *) GNUNET_malloc (sizeof (struct MeshPeerInfo)); |
485 | GNUNET_CONTAINER_multihashmap_put (peers, | 485 | GNUNET_CONTAINER_multihashmap_put (peers, &peer->hashPubKey, peer_info, |
486 | &peer->hashPubKey, | ||
487 | peer_info, | ||
488 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 486 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
489 | peer_info->id = GNUNET_PEER_intern (peer); | 487 | peer_info->id = GNUNET_PEER_intern (peer); |
490 | peer_info->state = MESH_PEER_SEARCHING; | 488 | peer_info->state = MESH_PEER_SEARCHING; |
@@ -591,8 +589,8 @@ add_path_to_peer (struct MeshPeerInfo *peer_info, struct MeshPath *path) | |||
591 | if (best_cost < new_cost) | 589 | if (best_cost < new_cost) |
592 | { | 590 | { |
593 | path->in_use = 0; | 591 | path->in_use = 0; |
594 | GNUNET_CONTAINER_DLL_insert_tail (peer_info->path, | 592 | GNUNET_CONTAINER_DLL_insert_tail (peer_info->path, peer_info->path_tail, |
595 | peer_info->path_tail, path); | 593 | path); |
596 | } | 594 | } |
597 | else | 595 | else |
598 | { | 596 | { |
@@ -820,16 +818,12 @@ announce_applications (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
820 | GNUNET_PEER_resolve (myid, &id); | 818 | GNUNET_PEER_resolve (myid, &id); |
821 | for (i = 0; i < n_applications; i++) | 819 | for (i = 0; i < n_applications; i++) |
822 | { | 820 | { |
823 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 821 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting PUT for app %d\n", |
824 | "Starting PUT for app %d\n", applications[i]); | 822 | applications[i]); |
825 | *p = htonl (applications[i]); | 823 | *p = htonl (applications[i]); |
826 | GNUNET_CRYPTO_hash (buffer, 12, &hash); | 824 | GNUNET_CRYPTO_hash (buffer, 12, &hash); |
827 | GNUNET_DHT_put (dht_handle, | 825 | GNUNET_DHT_put (dht_handle, &hash, 10U, GNUNET_DHT_RO_RECORD_ROUTE, |
828 | &hash, | 826 | GNUNET_BLOCK_TYPE_ANY, sizeof (struct GNUNET_PeerIdentity), |
829 | 10U, | ||
830 | GNUNET_DHT_RO_RECORD_ROUTE, | ||
831 | GNUNET_BLOCK_TYPE_ANY, | ||
832 | sizeof (struct GNUNET_PeerIdentity), | ||
833 | (const char *) &id, | 827 | (const char *) &id, |
834 | GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), | 828 | GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (), |
835 | APP_ANNOUNCE_TIME), | 829 | APP_ANNOUNCE_TIME), |
@@ -840,9 +834,9 @@ announce_applications (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
840 | NULL, NULL); | 834 | NULL, NULL); |
841 | #endif | 835 | #endif |
842 | } | 836 | } |
843 | announce_applications_task = GNUNET_SCHEDULER_add_delayed (APP_ANNOUNCE_TIME, | 837 | announce_applications_task = |
844 | &announce_applications, | 838 | GNUNET_SCHEDULER_add_delayed (APP_ANNOUNCE_TIME, &announce_applications, |
845 | cls); | 839 | cls); |
846 | return; | 840 | return; |
847 | } | 841 | } |
848 | 842 | ||
@@ -883,8 +877,8 @@ announce_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
883 | NULL, /* Continuation */ | 877 | NULL, /* Continuation */ |
884 | NULL); /* Continuation closure */ | 878 | NULL); /* Continuation closure */ |
885 | #endif | 879 | #endif |
886 | announce_id_task = GNUNET_SCHEDULER_add_delayed (ID_ANNOUNCE_TIME, | 880 | announce_id_task = |
887 | &announce_id, cls); | 881 | GNUNET_SCHEDULER_add_delayed (ID_ANNOUNCE_TIME, &announce_id, cls); |
888 | } | 882 | } |
889 | 883 | ||
890 | /******************************************************************************/ | 884 | /******************************************************************************/ |
@@ -917,11 +911,8 @@ send_core_create_path_for_peer (void *cls, size_t size, void *buf) | |||
917 | { | 911 | { |
918 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Retransmitting create path\n"); | 912 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Retransmitting create path\n"); |
919 | GNUNET_PEER_resolve (get_first_hop (peer_info->path), &id); | 913 | GNUNET_PEER_resolve (get_first_hop (peer_info->path), &id); |
920 | GNUNET_CORE_notify_transmit_ready (core_handle, | 914 | GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, |
921 | 0, | 915 | GNUNET_TIME_UNIT_FOREVER_REL, &id, |
922 | 0, | ||
923 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
924 | &id, | ||
925 | sizeof (struct | 916 | sizeof (struct |
926 | GNUNET_MESH_ManipulatePath) + | 917 | GNUNET_MESH_ManipulatePath) + |
927 | (peer_info->path->length * | 918 | (peer_info->path->length * |
@@ -942,8 +933,9 @@ send_core_create_path_for_peer (void *cls, size_t size, void *buf) | |||
942 | if (p == NULL) | 933 | if (p == NULL) |
943 | return 0; // TODO Notify ERROR Path not found | 934 | return 0; // TODO Notify ERROR Path not found |
944 | 935 | ||
945 | size_needed = sizeof (struct GNUNET_MESH_ManipulatePath) | 936 | size_needed = |
946 | + p->length * sizeof (struct GNUNET_PeerIdentity); | 937 | sizeof (struct GNUNET_MESH_ManipulatePath) + |
938 | p->length * sizeof (struct GNUNET_PeerIdentity); | ||
947 | if (size < size_needed) | 939 | if (size < size_needed) |
948 | { | 940 | { |
949 | // TODO retry? cancel? | 941 | // TODO retry? cancel? |
@@ -1194,8 +1186,8 @@ send_p2p_tunnel_destroy (void *cls, size_t size, void *buf) | |||
1194 | c = t->client; | 1186 | c = t->client; |
1195 | msg = buf; | 1187 | msg = buf; |
1196 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROY); | 1188 | msg->header.type = htons (GNUNET_MESSAGE_TYPE_MESH_LOCAL_TUNNEL_DESTROY); |
1197 | /*FIXME*/ | 1189 | /*FIXME*/ msg->header.size = |
1198 | msg->header.size = htons (sizeof (struct GNUNET_MESH_TunnelMessage)); | 1190 | htons (sizeof (struct GNUNET_MESH_TunnelMessage)); |
1199 | msg->tunnel_id = htonl (t->id.tid); | 1191 | msg->tunnel_id = htonl (t->id.tid); |
1200 | 1192 | ||
1201 | destroy_tunnel (c, t); | 1193 | destroy_tunnel (c, t); |
@@ -1223,8 +1215,8 @@ send_subscribed_clients (struct GNUNET_MessageHeader *msg) | |||
1223 | if (is_client_subscribed (type, c)) | 1215 | if (is_client_subscribed (type, c)) |
1224 | { | 1216 | { |
1225 | count++; | 1217 | count++; |
1226 | GNUNET_SERVER_notification_context_unicast (nc, | 1218 | GNUNET_SERVER_notification_context_unicast (nc, c->handle, msg, |
1227 | c->handle, msg, GNUNET_YES); | 1219 | GNUNET_YES); |
1228 | } | 1220 | } |
1229 | } | 1221 | } |
1230 | return count; | 1222 | return count; |
@@ -1284,8 +1276,7 @@ iterate_collect_neighbors (void *cls, const GNUNET_HashCode * key, void *value) | |||
1284 | * | 1276 | * |
1285 | */ | 1277 | */ |
1286 | static int | 1278 | static int |
1287 | handle_mesh_path_create (void *cls, | 1279 | handle_mesh_path_create (void *cls, const struct GNUNET_PeerIdentity *peer, |
1288 | const struct GNUNET_PeerIdentity *peer, | ||
1289 | const struct GNUNET_MessageHeader *message, | 1280 | const struct GNUNET_MessageHeader *message, |
1290 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 1281 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
1291 | { | 1282 | { |
@@ -1341,9 +1332,7 @@ handle_mesh_path_create (void *cls, | |||
1341 | 1332 | ||
1342 | GNUNET_CRYPTO_hash (&t->id, sizeof (struct MESH_TunnelID), &hash); | 1333 | GNUNET_CRYPTO_hash (&t->id, sizeof (struct MESH_TunnelID), &hash); |
1343 | if (GNUNET_OK != | 1334 | if (GNUNET_OK != |
1344 | GNUNET_CONTAINER_multihashmap_put (tunnels, | 1335 | GNUNET_CONTAINER_multihashmap_put (tunnels, &hash, t, |
1345 | &hash, | ||
1346 | t, | ||
1347 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) | 1336 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) |
1348 | { | 1337 | { |
1349 | GNUNET_break (0); | 1338 | GNUNET_break (0); |
@@ -1351,15 +1340,14 @@ handle_mesh_path_create (void *cls, | |||
1351 | } | 1340 | } |
1352 | 1341 | ||
1353 | } | 1342 | } |
1354 | dest_peer_info = GNUNET_CONTAINER_multihashmap_get (peers, | 1343 | dest_peer_info = |
1355 | &pi[size - 1].hashPubKey); | 1344 | GNUNET_CONTAINER_multihashmap_get (peers, &pi[size - 1].hashPubKey); |
1356 | if (NULL == dest_peer_info) | 1345 | if (NULL == dest_peer_info) |
1357 | { | 1346 | { |
1358 | dest_peer_info = GNUNET_malloc (sizeof (struct MeshPeerInfo)); | 1347 | dest_peer_info = GNUNET_malloc (sizeof (struct MeshPeerInfo)); |
1359 | dest_peer_info->id = GNUNET_PEER_intern (&pi[size - 1]); | 1348 | dest_peer_info->id = GNUNET_PEER_intern (&pi[size - 1]); |
1360 | dest_peer_info->state = MESH_PEER_WAITING; | 1349 | dest_peer_info->state = MESH_PEER_WAITING; |
1361 | GNUNET_CONTAINER_multihashmap_put (peers, | 1350 | GNUNET_CONTAINER_multihashmap_put (peers, &pi[size - 1].hashPubKey, |
1362 | &pi[size - 1].hashPubKey, | ||
1363 | dest_peer_info, | 1351 | dest_peer_info, |
1364 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 1352 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
1365 | } | 1353 | } |
@@ -1369,9 +1357,7 @@ handle_mesh_path_create (void *cls, | |||
1369 | orig_peer_info = GNUNET_malloc (sizeof (struct MeshPeerInfo)); | 1357 | orig_peer_info = GNUNET_malloc (sizeof (struct MeshPeerInfo)); |
1370 | orig_peer_info->id = GNUNET_PEER_intern (pi); | 1358 | orig_peer_info->id = GNUNET_PEER_intern (pi); |
1371 | orig_peer_info->state = MESH_PEER_WAITING; | 1359 | orig_peer_info->state = MESH_PEER_WAITING; |
1372 | GNUNET_CONTAINER_multihashmap_put (peers, | 1360 | GNUNET_CONTAINER_multihashmap_put (peers, &pi->hashPubKey, orig_peer_info, |
1373 | &pi->hashPubKey, | ||
1374 | orig_peer_info, | ||
1375 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 1361 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
1376 | } | 1362 | } |
1377 | 1363 | ||
@@ -1424,11 +1410,8 @@ handle_mesh_path_create (void *cls, | |||
1424 | { | 1410 | { |
1425 | add_path_to_peer (dest_peer_info, path); | 1411 | add_path_to_peer (dest_peer_info, path); |
1426 | GNUNET_PEER_resolve (get_first_hop (path), &id); | 1412 | GNUNET_PEER_resolve (get_first_hop (path), &id); |
1427 | GNUNET_CORE_notify_transmit_ready (core_handle, | 1413 | GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, |
1428 | 0, | 1414 | GNUNET_TIME_UNIT_FOREVER_REL, &id, |
1429 | 0, | ||
1430 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
1431 | &id, | ||
1432 | sizeof (struct GNUNET_MessageHeader), | 1415 | sizeof (struct GNUNET_MessageHeader), |
1433 | &send_core_create_path_for_peer, | 1416 | &send_core_create_path_for_peer, |
1434 | dest_peer_info); | 1417 | dest_peer_info); |
@@ -1448,8 +1431,7 @@ handle_mesh_path_create (void *cls, | |||
1448 | * GNUNET_SYSERR to close it (signal serious error) | 1431 | * GNUNET_SYSERR to close it (signal serious error) |
1449 | */ | 1432 | */ |
1450 | static int | 1433 | static int |
1451 | handle_mesh_data_unicast (void *cls, | 1434 | handle_mesh_data_unicast (void *cls, const struct GNUNET_PeerIdentity *peer, |
1452 | const struct GNUNET_PeerIdentity *peer, | ||
1453 | const struct GNUNET_MessageHeader *message, | 1435 | const struct GNUNET_MessageHeader *message, |
1454 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 1436 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
1455 | { | 1437 | { |
@@ -1460,8 +1442,9 @@ handle_mesh_data_unicast (void *cls, | |||
1460 | size_t size; | 1442 | size_t size; |
1461 | 1443 | ||
1462 | size = ntohs (message->size); | 1444 | size = ntohs (message->size); |
1463 | if (size < sizeof (struct GNUNET_MESH_Unicast) | 1445 | if (size < |
1464 | + sizeof (struct GNUNET_MessageHeader)) | 1446 | sizeof (struct GNUNET_MESH_Unicast) + |
1447 | sizeof (struct GNUNET_MessageHeader)) | ||
1465 | { | 1448 | { |
1466 | GNUNET_break (0); | 1449 | GNUNET_break (0); |
1467 | return GNUNET_OK; | 1450 | return GNUNET_OK; |
@@ -1488,11 +1471,9 @@ handle_mesh_data_unicast (void *cls, | |||
1488 | GNUNET_PEER_resolve (get_first_hop (pi->path), &id); | 1471 | GNUNET_PEER_resolve (get_first_hop (pi->path), &id); |
1489 | msg = GNUNET_malloc (size); | 1472 | msg = GNUNET_malloc (size); |
1490 | memcpy (msg, message, size); | 1473 | memcpy (msg, message, size); |
1491 | GNUNET_CORE_notify_transmit_ready (core_handle, | 1474 | GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, |
1492 | 0, | 1475 | GNUNET_TIME_UNIT_FOREVER_REL, &id, size, |
1493 | 0, | 1476 | &send_core_data_raw, msg); |
1494 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
1495 | &id, size, &send_core_data_raw, msg); | ||
1496 | return GNUNET_OK; | 1477 | return GNUNET_OK; |
1497 | } | 1478 | } |
1498 | 1479 | ||
@@ -1508,8 +1489,7 @@ handle_mesh_data_unicast (void *cls, | |||
1508 | * GNUNET_SYSERR to close it (signal serious error) | 1489 | * GNUNET_SYSERR to close it (signal serious error) |
1509 | */ | 1490 | */ |
1510 | static int | 1491 | static int |
1511 | handle_mesh_data_multicast (void *cls, | 1492 | handle_mesh_data_multicast (void *cls, const struct GNUNET_PeerIdentity *peer, |
1512 | const struct GNUNET_PeerIdentity *peer, | ||
1513 | const struct GNUNET_MessageHeader *message, | 1493 | const struct GNUNET_MessageHeader *message, |
1514 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 1494 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
1515 | { | 1495 | { |
@@ -1524,8 +1504,9 @@ handle_mesh_data_multicast (void *cls, | |||
1524 | 1504 | ||
1525 | 1505 | ||
1526 | size = ntohs (message->size); | 1506 | size = ntohs (message->size); |
1527 | if (size < sizeof (struct GNUNET_MESH_Multicast) | 1507 | if (size < |
1528 | + sizeof (struct GNUNET_MessageHeader)) | 1508 | sizeof (struct GNUNET_MESH_Multicast) + |
1509 | sizeof (struct GNUNET_MessageHeader)) | ||
1529 | { | 1510 | { |
1530 | GNUNET_break_op (0); | 1511 | GNUNET_break_op (0); |
1531 | return GNUNET_OK; | 1512 | return GNUNET_OK; |
@@ -1549,8 +1530,7 @@ handle_mesh_data_multicast (void *cls, | |||
1549 | /* Retransmit to other peers */ | 1530 | /* Retransmit to other peers */ |
1550 | neighbors = GNUNET_malloc (sizeof (GNUNET_PEER_Id)); | 1531 | neighbors = GNUNET_malloc (sizeof (GNUNET_PEER_Id)); |
1551 | neighbors[0] = 0; | 1532 | neighbors[0] = 0; |
1552 | GNUNET_CONTAINER_multihashmap_iterate (t->peers, | 1533 | GNUNET_CONTAINER_multihashmap_iterate (t->peers, &iterate_collect_neighbors, |
1553 | &iterate_collect_neighbors, | ||
1554 | &neighbors); | 1534 | &neighbors); |
1555 | if (!neighbors[0]) | 1535 | if (!neighbors[0]) |
1556 | { | 1536 | { |
@@ -1598,8 +1578,7 @@ handle_mesh_data_multicast (void *cls, | |||
1598 | * GNUNET_SYSERR to close it (signal serious error) | 1578 | * GNUNET_SYSERR to close it (signal serious error) |
1599 | */ | 1579 | */ |
1600 | static int | 1580 | static int |
1601 | handle_mesh_data_to_orig (void *cls, | 1581 | handle_mesh_data_to_orig (void *cls, const struct GNUNET_PeerIdentity *peer, |
1602 | const struct GNUNET_PeerIdentity *peer, | ||
1603 | const struct GNUNET_MessageHeader *message, | 1582 | const struct GNUNET_MessageHeader *message, |
1604 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 1583 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
1605 | { | 1584 | { |
@@ -1610,8 +1589,9 @@ handle_mesh_data_to_orig (void *cls, | |||
1610 | size_t size; | 1589 | size_t size; |
1611 | 1590 | ||
1612 | size = ntohs (message->size); | 1591 | size = ntohs (message->size); |
1613 | if (size < sizeof (struct GNUNET_MESH_ToOrigin) | 1592 | if (size < |
1614 | + sizeof (struct GNUNET_MessageHeader)) | 1593 | sizeof (struct GNUNET_MESH_ToOrigin) + |
1594 | sizeof (struct GNUNET_MessageHeader)) | ||
1615 | { | 1595 | { |
1616 | GNUNET_break_op (0); | 1596 | GNUNET_break_op (0); |
1617 | return GNUNET_OK; | 1597 | return GNUNET_OK; |
@@ -1633,9 +1613,8 @@ handle_mesh_data_to_orig (void *cls, | |||
1633 | GNUNET_break_op (0); | 1613 | GNUNET_break_op (0); |
1634 | return GNUNET_OK; | 1614 | return GNUNET_OK; |
1635 | } | 1615 | } |
1636 | GNUNET_SERVER_notification_context_unicast (nc, | 1616 | GNUNET_SERVER_notification_context_unicast (nc, t->client->handle, message, |
1637 | t->client->handle, | 1617 | GNUNET_YES); |
1638 | message, GNUNET_YES); | ||
1639 | return GNUNET_OK; | 1618 | return GNUNET_OK; |
1640 | } | 1619 | } |
1641 | peer_info = get_peer_info (&msg->oid); | 1620 | peer_info = get_peer_info (&msg->oid); |
@@ -1648,11 +1627,9 @@ handle_mesh_data_to_orig (void *cls, | |||
1648 | GNUNET_PEER_resolve (get_first_hop (peer_info->path), &id); | 1627 | GNUNET_PEER_resolve (get_first_hop (peer_info->path), &id); |
1649 | msg = GNUNET_malloc (size); | 1628 | msg = GNUNET_malloc (size); |
1650 | memcpy (msg, message, size); | 1629 | memcpy (msg, message, size); |
1651 | GNUNET_CORE_notify_transmit_ready (core_handle, | 1630 | GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, |
1652 | 0, | 1631 | GNUNET_TIME_UNIT_FOREVER_REL, &id, size, |
1653 | 0, | 1632 | &send_core_data_raw, msg); |
1654 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
1655 | &id, size, &send_core_data_raw, msg); | ||
1656 | 1633 | ||
1657 | return GNUNET_OK; | 1634 | return GNUNET_OK; |
1658 | } | 1635 | } |
@@ -1669,8 +1646,7 @@ handle_mesh_data_to_orig (void *cls, | |||
1669 | * GNUNET_SYSERR to close it (signal serious error) | 1646 | * GNUNET_SYSERR to close it (signal serious error) |
1670 | */ | 1647 | */ |
1671 | static int | 1648 | static int |
1672 | handle_mesh_path_ack (void *cls, | 1649 | handle_mesh_path_ack (void *cls, const struct GNUNET_PeerIdentity *peer, |
1673 | const struct GNUNET_PeerIdentity *peer, | ||
1674 | const struct GNUNET_MessageHeader *message, | 1650 | const struct GNUNET_MessageHeader *message, |
1675 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 1651 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
1676 | { | 1652 | { |
@@ -1708,8 +1684,7 @@ handle_mesh_path_ack (void *cls, | |||
1708 | pc.header.size = htons (sizeof (struct GNUNET_MESH_PeerControl)); | 1684 | pc.header.size = htons (sizeof (struct GNUNET_MESH_PeerControl)); |
1709 | pc.tunnel_id = htonl (t->local_tid); | 1685 | pc.tunnel_id = htonl (t->local_tid); |
1710 | GNUNET_PEER_resolve (peer_info->id, &pc.peer); | 1686 | GNUNET_PEER_resolve (peer_info->id, &pc.peer); |
1711 | GNUNET_SERVER_notification_context_unicast (nc, | 1687 | GNUNET_SERVER_notification_context_unicast (nc, t->client->handle, |
1712 | t->client->handle, | ||
1713 | &pc.header, GNUNET_NO); | 1688 | &pc.header, GNUNET_NO); |
1714 | return GNUNET_OK; | 1689 | return GNUNET_OK; |
1715 | } | 1690 | } |
@@ -1724,11 +1699,8 @@ handle_mesh_path_ack (void *cls, | |||
1724 | GNUNET_PEER_resolve (get_first_hop (peer_info->path), &id); | 1699 | GNUNET_PEER_resolve (get_first_hop (peer_info->path), &id); |
1725 | msg = GNUNET_malloc (sizeof (struct GNUNET_MESH_PathACK)); | 1700 | msg = GNUNET_malloc (sizeof (struct GNUNET_MESH_PathACK)); |
1726 | memcpy (msg, message, sizeof (struct GNUNET_MESH_PathACK)); | 1701 | memcpy (msg, message, sizeof (struct GNUNET_MESH_PathACK)); |
1727 | GNUNET_CORE_notify_transmit_ready (core_handle, | 1702 | GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, |
1728 | 0, | 1703 | GNUNET_TIME_UNIT_FOREVER_REL, &id, |
1729 | 0, | ||
1730 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
1731 | &id, | ||
1732 | sizeof (struct GNUNET_MESH_PathACK), | 1704 | sizeof (struct GNUNET_MESH_PathACK), |
1733 | &send_core_data_raw, msg); | 1705 | &send_core_data_raw, msg); |
1734 | return GNUNET_OK; | 1706 | return GNUNET_OK; |
@@ -1826,14 +1798,12 @@ path_refresh (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1826 | if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) | 1798 | if (tc->reason == GNUNET_SCHEDULER_REASON_SHUTDOWN) |
1827 | return; | 1799 | return; |
1828 | GNUNET_PEER_resolve (get_first_hop (peer_info->path), &id); | 1800 | GNUNET_PEER_resolve (get_first_hop (peer_info->path), &id); |
1829 | GNUNET_CORE_notify_transmit_ready (core_handle, | 1801 | GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, |
1830 | 0, | 1802 | GNUNET_TIME_UNIT_FOREVER_REL, &id, |
1831 | 0, | ||
1832 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
1833 | &id, | ||
1834 | sizeof (struct GNUNET_MESH_ManipulatePath) | 1803 | sizeof (struct GNUNET_MESH_ManipulatePath) |
1835 | + (peer_info->path->length | 1804 | + |
1836 | * sizeof (struct GNUNET_PeerIdentity)), | 1805 | (peer_info->path->length * |
1806 | sizeof (struct GNUNET_PeerIdentity)), | ||
1837 | &send_core_create_path_for_peer, | 1807 | &send_core_create_path_for_peer, |
1838 | peer_info); | 1808 | peer_info); |
1839 | peer_info->path_refresh_task = | 1809 | peer_info->path_refresh_task = |
@@ -1860,8 +1830,7 @@ path_refresh (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
1860 | * @param data pointer to the result data | 1830 | * @param data pointer to the result data |
1861 | */ | 1831 | */ |
1862 | static void | 1832 | static void |
1863 | dht_get_id_handler (void *cls, | 1833 | dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp, |
1864 | struct GNUNET_TIME_Absolute exp, | ||
1865 | const GNUNET_HashCode * key, | 1834 | const GNUNET_HashCode * key, |
1866 | const struct GNUNET_PeerIdentity *const *get_path, | 1835 | const struct GNUNET_PeerIdentity *const *get_path, |
1867 | const struct GNUNET_PeerIdentity *const *put_path, | 1836 | const struct GNUNET_PeerIdentity *const *put_path, |
@@ -1890,28 +1859,26 @@ dht_get_id_handler (void *cls, | |||
1890 | for (i = 0; get_path[i] != NULL; i++) ; | 1859 | for (i = 0; get_path[i] != NULL; i++) ; |
1891 | for (i--; i >= 0; i--) | 1860 | for (i--; i >= 0; i--) |
1892 | { | 1861 | { |
1893 | p->peers = GNUNET_realloc (p->peers, | 1862 | p->peers = |
1894 | sizeof (GNUNET_PEER_Id) * (p->length + 1)); | 1863 | GNUNET_realloc (p->peers, sizeof (GNUNET_PEER_Id) * (p->length + 1)); |
1895 | p->peers[p->length] = GNUNET_PEER_intern (get_path[i]); | 1864 | p->peers[p->length] = GNUNET_PEER_intern (get_path[i]); |
1896 | p->length++; | 1865 | p->length++; |
1897 | } | 1866 | } |
1898 | for (i = 0; put_path[i] != NULL; i++) ; | 1867 | for (i = 0; put_path[i] != NULL; i++) ; |
1899 | for (i--; i >= 0; i--) | 1868 | for (i--; i >= 0; i--) |
1900 | { | 1869 | { |
1901 | p->peers = GNUNET_realloc (p->peers, | 1870 | p->peers = |
1902 | sizeof (GNUNET_PEER_Id) * (p->length + 1)); | 1871 | GNUNET_realloc (p->peers, sizeof (GNUNET_PEER_Id) * (p->length + 1)); |
1903 | p->peers[p->length] = GNUNET_PEER_intern (put_path[i]); | 1872 | p->peers[p->length] = GNUNET_PEER_intern (put_path[i]); |
1904 | p->length++; | 1873 | p->length++; |
1905 | } | 1874 | } |
1906 | add_path_to_peer (peer_info, p); | 1875 | add_path_to_peer (peer_info, p); |
1907 | GNUNET_CORE_notify_transmit_ready (core_handle, | 1876 | GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, |
1908 | 0, | 1877 | GNUNET_TIME_UNIT_FOREVER_REL, get_path[1], |
1909 | 0, | ||
1910 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
1911 | get_path[1], | ||
1912 | sizeof (struct GNUNET_MESH_ManipulatePath) | 1878 | sizeof (struct GNUNET_MESH_ManipulatePath) |
1913 | + (p->length | 1879 | + |
1914 | * sizeof (struct GNUNET_PeerIdentity)), | 1880 | (p->length * |
1881 | sizeof (struct GNUNET_PeerIdentity)), | ||
1915 | &send_core_create_path_for_peer, | 1882 | &send_core_create_path_for_peer, |
1916 | peer_info); | 1883 | peer_info); |
1917 | if (0 == peer_info->path_refresh_task) | 1884 | if (0 == peer_info->path_refresh_task) |
@@ -1941,13 +1908,12 @@ dht_get_id_handler (void *cls, | |||
1941 | * @param data pointer to the result data | 1908 | * @param data pointer to the result data |
1942 | */ | 1909 | */ |
1943 | static void | 1910 | static void |
1944 | dht_get_type_handler (void *cls, | 1911 | dht_get_type_handler (void *cls, struct GNUNET_TIME_Absolute exp, |
1945 | struct GNUNET_TIME_Absolute exp, | ||
1946 | const GNUNET_HashCode * key, | 1912 | const GNUNET_HashCode * key, |
1947 | const struct GNUNET_PeerIdentity *const *get_path, | 1913 | const struct GNUNET_PeerIdentity *const *get_path, |
1948 | const struct GNUNET_PeerIdentity *const *put_path, | 1914 | const struct GNUNET_PeerIdentity *const *put_path, |
1949 | enum GNUNET_BLOCK_Type type, | 1915 | enum GNUNET_BLOCK_Type type, size_t size, |
1950 | size_t size, const void *data) | 1916 | const void *data) |
1951 | { | 1917 | { |
1952 | const struct GNUNET_PeerIdentity *pi = data; | 1918 | const struct GNUNET_PeerIdentity *pi = data; |
1953 | struct MeshTunnel *t = cls; | 1919 | struct MeshTunnel *t = cls; |
@@ -1962,9 +1928,7 @@ dht_get_type_handler (void *cls, | |||
1962 | return; | 1928 | return; |
1963 | } | 1929 | } |
1964 | peer_info = get_peer_info (pi); | 1930 | peer_info = get_peer_info (pi); |
1965 | GNUNET_CONTAINER_multihashmap_put (t->peers, | 1931 | GNUNET_CONTAINER_multihashmap_put (t->peers, &pi->hashPubKey, peer_info, |
1966 | &pi->hashPubKey, | ||
1967 | peer_info, | ||
1968 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 1932 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
1969 | if ((NULL == get_path || NULL == put_path) && NULL == peer_info->path) | 1933 | if ((NULL == get_path || NULL == put_path) && NULL == peer_info->path) |
1970 | { | 1934 | { |
@@ -1984,28 +1948,26 @@ dht_get_type_handler (void *cls, | |||
1984 | for (i = 0; get_path[i] != NULL; i++) ; | 1948 | for (i = 0; get_path[i] != NULL; i++) ; |
1985 | for (i--; i >= 0; i--) | 1949 | for (i--; i >= 0; i--) |
1986 | { | 1950 | { |
1987 | p->peers = GNUNET_realloc (p->peers, | 1951 | p->peers = |
1988 | sizeof (GNUNET_PEER_Id) * (p->length + 1)); | 1952 | GNUNET_realloc (p->peers, sizeof (GNUNET_PEER_Id) * (p->length + 1)); |
1989 | p->peers[p->length] = GNUNET_PEER_intern (get_path[i]); | 1953 | p->peers[p->length] = GNUNET_PEER_intern (get_path[i]); |
1990 | p->length++; | 1954 | p->length++; |
1991 | } | 1955 | } |
1992 | for (i = 0; put_path[i] != NULL; i++) ; | 1956 | for (i = 0; put_path[i] != NULL; i++) ; |
1993 | for (i--; i >= 0; i--) | 1957 | for (i--; i >= 0; i--) |
1994 | { | 1958 | { |
1995 | p->peers = GNUNET_realloc (p->peers, | 1959 | p->peers = |
1996 | sizeof (GNUNET_PEER_Id) * (p->length + 1)); | 1960 | GNUNET_realloc (p->peers, sizeof (GNUNET_PEER_Id) * (p->length + 1)); |
1997 | p->peers[p->length] = GNUNET_PEER_intern (put_path[i]); | 1961 | p->peers[p->length] = GNUNET_PEER_intern (put_path[i]); |
1998 | p->length++; | 1962 | p->length++; |
1999 | } | 1963 | } |
2000 | add_path_to_peer (peer_info, p); | 1964 | add_path_to_peer (peer_info, p); |
2001 | GNUNET_CORE_notify_transmit_ready (core_handle, | 1965 | GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, |
2002 | 0, | 1966 | GNUNET_TIME_UNIT_FOREVER_REL, get_path[1], |
2003 | 0, | ||
2004 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
2005 | get_path[1], | ||
2006 | sizeof (struct GNUNET_MESH_ManipulatePath) | 1967 | sizeof (struct GNUNET_MESH_ManipulatePath) |
2007 | + (p->length | 1968 | + |
2008 | * sizeof (struct GNUNET_PeerIdentity)), | 1969 | (p->length * |
1970 | sizeof (struct GNUNET_PeerIdentity)), | ||
2009 | &send_core_create_path_for_peer, | 1971 | &send_core_create_path_for_peer, |
2010 | peer_info); | 1972 | peer_info); |
2011 | 1973 | ||
@@ -2039,8 +2001,8 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | |||
2039 | { | 2001 | { |
2040 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2002 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2041 | " matching client found, cleaning\n"); | 2003 | " matching client found, cleaning\n"); |
2042 | GNUNET_CONTAINER_multihashmap_iterate (c->tunnels, | 2004 | GNUNET_CONTAINER_multihashmap_iterate (c->tunnels, &delete_tunnel_entry, |
2043 | &delete_tunnel_entry, c); | 2005 | c); |
2044 | GNUNET_CONTAINER_multihashmap_destroy (c->tunnels); | 2006 | GNUNET_CONTAINER_multihashmap_destroy (c->tunnels); |
2045 | if (0 != c->app_counter) | 2007 | if (0 != c->app_counter) |
2046 | { /* deregister clients applications */ | 2008 | { /* deregister clients applications */ |
@@ -2055,10 +2017,10 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | |||
2055 | applications[j] = applications[n_applications - 1]; | 2017 | applications[j] = applications[n_applications - 1]; |
2056 | applications_rc[j] = applications_rc[n_applications - 1]; | 2018 | applications_rc[j] = applications_rc[n_applications - 1]; |
2057 | n_applications--; | 2019 | n_applications--; |
2058 | applications = GNUNET_realloc (applications, | 2020 | applications = |
2059 | n_applications * | 2021 | GNUNET_realloc (applications, |
2060 | sizeof | 2022 | n_applications * |
2061 | (GNUNET_MESH_ApplicationType)); | 2023 | sizeof (GNUNET_MESH_ApplicationType)); |
2062 | applications_rc = | 2024 | applications_rc = |
2063 | GNUNET_realloc (applications_rc, | 2025 | GNUNET_realloc (applications_rc, |
2064 | n_applications * sizeof (unsigned int)); | 2026 | n_applications * sizeof (unsigned int)); |
@@ -2100,8 +2062,7 @@ handle_client_disconnect (void *cls, struct GNUNET_SERVER_Client *client) | |||
2100 | * @param message the actual message, which includes messages the client wants | 2062 | * @param message the actual message, which includes messages the client wants |
2101 | */ | 2063 | */ |
2102 | static void | 2064 | static void |
2103 | handle_local_new_client (void *cls, | 2065 | handle_local_new_client (void *cls, struct GNUNET_SERVER_Client *client, |
2104 | struct GNUNET_SERVER_Client *client, | ||
2105 | const struct GNUNET_MessageHeader *message) | 2066 | const struct GNUNET_MessageHeader *message) |
2106 | { | 2067 | { |
2107 | struct GNUNET_MESH_ClientConnect *cc_msg; | 2068 | struct GNUNET_MESH_ClientConnect *cc_msg; |
@@ -2140,8 +2101,7 @@ handle_local_new_client (void *cls, | |||
2140 | { | 2101 | { |
2141 | c->app_counter = apps; | 2102 | c->app_counter = apps; |
2142 | c->apps = GNUNET_malloc (apps * sizeof (GNUNET_MESH_ApplicationType)); | 2103 | c->apps = GNUNET_malloc (apps * sizeof (GNUNET_MESH_ApplicationType)); |
2143 | memcpy (c->apps, | 2104 | memcpy (c->apps, &message[1] + types * sizeof (uint16_t), |
2144 | &message[1] + types * sizeof (uint16_t), | ||
2145 | apps * sizeof (GNUNET_MESH_ApplicationType)); | 2105 | apps * sizeof (GNUNET_MESH_ApplicationType)); |
2146 | } | 2106 | } |
2147 | for (i = 0; i < apps; i++) | 2107 | for (i = 0; i < apps; i++) |
@@ -2159,11 +2119,13 @@ handle_local_new_client (void *cls, | |||
2159 | if (!known) | 2119 | if (!known) |
2160 | { /* Register previously unknown application */ | 2120 | { /* Register previously unknown application */ |
2161 | n_applications++; | 2121 | n_applications++; |
2162 | applications = GNUNET_realloc (applications, | 2122 | applications = |
2163 | n_applications * | 2123 | GNUNET_realloc (applications, |
2164 | sizeof (GNUNET_MESH_ApplicationType)); | 2124 | n_applications * |
2165 | applications_rc = GNUNET_realloc (applications_rc, | 2125 | sizeof (GNUNET_MESH_ApplicationType)); |
2166 | n_applications * sizeof (unsigned int)); | 2126 | applications_rc = |
2127 | GNUNET_realloc (applications_rc, | ||
2128 | n_applications * sizeof (unsigned int)); | ||
2167 | applications[n_applications - 1] = c->apps[i]; | 2129 | applications[n_applications - 1] = c->apps[i]; |
2168 | applications_rc[n_applications - 1] = 1; | 2130 | applications_rc[n_applications - 1] = 1; |
2169 | if (0 == announce_applications_task) | 2131 | if (0 == announce_applications_task) |
@@ -2174,8 +2136,7 @@ handle_local_new_client (void *cls, | |||
2174 | } | 2136 | } |
2175 | } | 2137 | } |
2176 | } | 2138 | } |
2177 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 2139 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " client has %u+%u subscriptions\n", |
2178 | " client has %u+%u subscriptions\n", | ||
2179 | c->type_counter, c->app_counter); | 2140 | c->type_counter, c->app_counter); |
2180 | 2141 | ||
2181 | GNUNET_CONTAINER_DLL_insert (clients, clients_tail, c); | 2142 | GNUNET_CONTAINER_DLL_insert (clients, clients_tail, c); |
@@ -2195,8 +2156,7 @@ handle_local_new_client (void *cls, | |||
2195 | * @param message the actual message | 2156 | * @param message the actual message |
2196 | */ | 2157 | */ |
2197 | static void | 2158 | static void |
2198 | handle_local_tunnel_create (void *cls, | 2159 | handle_local_tunnel_create (void *cls, struct GNUNET_SERVER_Client *client, |
2199 | struct GNUNET_SERVER_Client *client, | ||
2200 | const struct GNUNET_MessageHeader *message) | 2160 | const struct GNUNET_MessageHeader *message) |
2201 | { | 2161 | { |
2202 | struct GNUNET_MESH_TunnelMessage *t_msg; | 2162 | struct GNUNET_MESH_TunnelMessage *t_msg; |
@@ -2278,8 +2238,7 @@ handle_local_tunnel_create (void *cls, | |||
2278 | * @param message the actual message | 2238 | * @param message the actual message |
2279 | */ | 2239 | */ |
2280 | static void | 2240 | static void |
2281 | handle_local_tunnel_destroy (void *cls, | 2241 | handle_local_tunnel_destroy (void *cls, struct GNUNET_SERVER_Client *client, |
2282 | struct GNUNET_SERVER_Client *client, | ||
2283 | const struct GNUNET_MessageHeader *message) | 2242 | const struct GNUNET_MessageHeader *message) |
2284 | { | 2243 | { |
2285 | struct GNUNET_MESH_TunnelMessage *tunnel_msg; | 2244 | struct GNUNET_MESH_TunnelMessage *tunnel_msg; |
@@ -2332,8 +2291,7 @@ handle_local_tunnel_destroy (void *cls, | |||
2332 | * @param message the actual message (PeerControl) | 2291 | * @param message the actual message (PeerControl) |
2333 | */ | 2292 | */ |
2334 | static void | 2293 | static void |
2335 | handle_local_connect_add (void *cls, | 2294 | handle_local_connect_add (void *cls, struct GNUNET_SERVER_Client *client, |
2336 | struct GNUNET_SERVER_Client *client, | ||
2337 | const struct GNUNET_MessageHeader *message) | 2295 | const struct GNUNET_MessageHeader *message) |
2338 | { | 2296 | { |
2339 | struct GNUNET_MESH_PeerControl *peer_msg; | 2297 | struct GNUNET_MESH_PeerControl *peer_msg; |
@@ -2406,8 +2364,7 @@ handle_local_connect_add (void *cls, | |||
2406 | * @param message the actual message (PeerControl) | 2364 | * @param message the actual message (PeerControl) |
2407 | */ | 2365 | */ |
2408 | static void | 2366 | static void |
2409 | handle_local_connect_del (void *cls, | 2367 | handle_local_connect_del (void *cls, struct GNUNET_SERVER_Client *client, |
2410 | struct GNUNET_SERVER_Client *client, | ||
2411 | const struct GNUNET_MessageHeader *message) | 2368 | const struct GNUNET_MessageHeader *message) |
2412 | { | 2369 | { |
2413 | struct GNUNET_MESH_PeerControl *peer_msg; | 2370 | struct GNUNET_MESH_PeerControl *peer_msg; |
@@ -2466,8 +2423,7 @@ handle_local_connect_del (void *cls, | |||
2466 | * @param message the actual message (ConnectPeerByType) | 2423 | * @param message the actual message (ConnectPeerByType) |
2467 | */ | 2424 | */ |
2468 | static void | 2425 | static void |
2469 | handle_local_connect_by_type (void *cls, | 2426 | handle_local_connect_by_type (void *cls, struct GNUNET_SERVER_Client *client, |
2470 | struct GNUNET_SERVER_Client *client, | ||
2471 | const struct GNUNET_MessageHeader *message) | 2427 | const struct GNUNET_MessageHeader *message) |
2472 | { | 2428 | { |
2473 | struct GNUNET_MESH_ConnectPeerByType *connect_msg; | 2429 | struct GNUNET_MESH_ConnectPeerByType *connect_msg; |
@@ -2528,8 +2484,7 @@ handle_local_connect_by_type (void *cls, | |||
2528 | struct GNUNET_MESH_PeerControl pc; | 2484 | struct GNUNET_MESH_PeerControl pc; |
2529 | 2485 | ||
2530 | GNUNET_PEER_resolve (myid, &pc.peer); | 2486 | GNUNET_PEER_resolve (myid, &pc.peer); |
2531 | GNUNET_CONTAINER_multihashmap_put (t->peers, | 2487 | GNUNET_CONTAINER_multihashmap_put (t->peers, &pc.peer.hashPubKey, |
2532 | &pc.peer.hashPubKey, | ||
2533 | get_peer_info (&pc.peer), | 2488 | get_peer_info (&pc.peer), |
2534 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); | 2489 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY); |
2535 | pc.header.size = htons (sizeof (struct GNUNET_MESH_PeerControl)); | 2490 | pc.header.size = htons (sizeof (struct GNUNET_MESH_PeerControl)); |
@@ -2546,14 +2501,11 @@ handle_local_connect_by_type (void *cls, | |||
2546 | { | 2501 | { |
2547 | GNUNET_DHT_get_stop (c->dht_get_type); | 2502 | GNUNET_DHT_get_stop (c->dht_get_type); |
2548 | } | 2503 | } |
2549 | c->dht_get_type = GNUNET_DHT_get_start (dht_handle, | 2504 | c->dht_get_type = |
2550 | GNUNET_TIME_UNIT_FOREVER_REL, | 2505 | GNUNET_DHT_get_start (dht_handle, GNUNET_TIME_UNIT_FOREVER_REL, |
2551 | GNUNET_BLOCK_TYPE_ANY, | 2506 | GNUNET_BLOCK_TYPE_ANY, &hash, 10U, |
2552 | &hash, | 2507 | GNUNET_DHT_RO_RECORD_ROUTE, NULL, 0, NULL, 0, |
2553 | 10U, | 2508 | &dht_get_type_handler, t); |
2554 | GNUNET_DHT_RO_RECORD_ROUTE, | ||
2555 | NULL, | ||
2556 | 0, NULL, 0, &dht_get_type_handler, t); | ||
2557 | 2509 | ||
2558 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 2510 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
2559 | return; | 2511 | return; |
@@ -2568,8 +2520,7 @@ handle_local_connect_by_type (void *cls, | |||
2568 | * @param message the actual message | 2520 | * @param message the actual message |
2569 | */ | 2521 | */ |
2570 | static void | 2522 | static void |
2571 | handle_local_unicast (void *cls, | 2523 | handle_local_unicast (void *cls, struct GNUNET_SERVER_Client *client, |
2572 | struct GNUNET_SERVER_Client *client, | ||
2573 | const struct GNUNET_MessageHeader *message) | 2524 | const struct GNUNET_MessageHeader *message) |
2574 | { | 2525 | { |
2575 | struct MeshClient *c; | 2526 | struct MeshClient *c; |
@@ -2590,8 +2541,8 @@ handle_local_unicast (void *cls, | |||
2590 | } | 2541 | } |
2591 | data_msg = (struct GNUNET_MESH_Unicast *) message; | 2542 | data_msg = (struct GNUNET_MESH_Unicast *) message; |
2592 | /* Sanity check for message size */ | 2543 | /* Sanity check for message size */ |
2593 | if (sizeof (struct GNUNET_MESH_Unicast) + sizeof (struct GNUNET_MessageHeader) | 2544 | if (sizeof (struct GNUNET_MESH_Unicast) + |
2594 | > ntohs (data_msg->header.size)) | 2545 | sizeof (struct GNUNET_MessageHeader) > ntohs (data_msg->header.size)) |
2595 | { | 2546 | { |
2596 | GNUNET_break (0); | 2547 | GNUNET_break (0); |
2597 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | 2548 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); |
@@ -2645,9 +2596,8 @@ handle_local_unicast (void *cls, | |||
2645 | info->origin = &t->id; | 2596 | info->origin = &t->id; |
2646 | info->size = data_size; | 2597 | info->size = data_size; |
2647 | info->client = client; | 2598 | info->client = client; |
2648 | GNUNET_CORE_notify_transmit_ready (core_handle, | 2599 | GNUNET_CORE_notify_transmit_ready (core_handle, 0, 0, |
2649 | 0, | 2600 | GNUNET_TIME_UNIT_FOREVER_REL, &next_hop, |
2650 | 0, GNUNET_TIME_UNIT_FOREVER_REL, &next_hop, | ||
2651 | /* FIXME re-check types */ | 2601 | /* FIXME re-check types */ |
2652 | data_size + | 2602 | data_size + |
2653 | sizeof (struct GNUNET_MESH_Unicast), | 2603 | sizeof (struct GNUNET_MESH_Unicast), |
@@ -2663,8 +2613,7 @@ handle_local_unicast (void *cls, | |||
2663 | * @param message the actual message | 2613 | * @param message the actual message |
2664 | */ | 2614 | */ |
2665 | static void | 2615 | static void |
2666 | handle_local_multicast (void *cls, | 2616 | handle_local_multicast (void *cls, struct GNUNET_SERVER_Client *client, |
2667 | struct GNUNET_SERVER_Client *client, | ||
2668 | const struct GNUNET_MessageHeader *message) | 2617 | const struct GNUNET_MessageHeader *message) |
2669 | { | 2618 | { |
2670 | struct MeshClient *c; | 2619 | struct MeshClient *c; |
@@ -2751,8 +2700,7 @@ static struct GNUNET_SERVER_MessageHandler plugin_handlers[] = { | |||
2751 | * @param publicKey the public key of this peer | 2700 | * @param publicKey the public key of this peer |
2752 | */ | 2701 | */ |
2753 | static void | 2702 | static void |
2754 | core_init (void *cls, | 2703 | core_init (void *cls, struct GNUNET_CORE_Handle *server, |
2755 | struct GNUNET_CORE_Handle *server, | ||
2756 | const struct GNUNET_PeerIdentity *identity, | 2704 | const struct GNUNET_PeerIdentity *identity, |
2757 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) | 2705 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey) |
2758 | { | 2706 | { |
@@ -2771,8 +2719,7 @@ core_init (void *cls, | |||
2771 | * @param atsi performance data for the connection | 2719 | * @param atsi performance data for the connection |
2772 | */ | 2720 | */ |
2773 | static void | 2721 | static void |
2774 | core_connect (void *cls, | 2722 | core_connect (void *cls, const struct GNUNET_PeerIdentity *peer, |
2775 | const struct GNUNET_PeerIdentity *peer, | ||
2776 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 2723 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
2777 | { | 2724 | { |
2778 | // GNUNET_PEER_Id pid; | 2725 | // GNUNET_PEER_Id pid; |
@@ -2870,8 +2817,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
2870 | * @param c configuration to use | 2817 | * @param c configuration to use |
2871 | */ | 2818 | */ |
2872 | static void | 2819 | static void |
2873 | run (void *cls, | 2820 | run (void *cls, struct GNUNET_SERVER_Handle *server, |
2874 | struct GNUNET_SERVER_Handle *server, | ||
2875 | const struct GNUNET_CONFIGURATION_Handle *c) | 2821 | const struct GNUNET_CONFIGURATION_Handle *c) |
2876 | { | 2822 | { |
2877 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "starting to run\n"); | 2823 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "starting to run\n"); |
@@ -2919,8 +2865,8 @@ run (void *cls, | |||
2919 | announce_applications_task = 0; | 2865 | announce_applications_task = 0; |
2920 | 2866 | ||
2921 | /* Scheduled the task to clean up when shutdown is called */ | 2867 | /* Scheduled the task to clean up when shutdown is called */ |
2922 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 2868 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, |
2923 | &shutdown_task, NULL); | 2869 | NULL); |
2924 | 2870 | ||
2925 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "end of run()\n"); | 2871 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "end of run()\n"); |
2926 | } | 2872 | } |
@@ -2937,11 +2883,10 @@ main (int argc, char *const *argv) | |||
2937 | { | 2883 | { |
2938 | int ret; | 2884 | int ret; |
2939 | 2885 | ||
2940 | ret = (GNUNET_OK == | 2886 | ret = |
2941 | GNUNET_SERVICE_run (argc, | 2887 | (GNUNET_OK == |
2942 | argv, | 2888 | GNUNET_SERVICE_run (argc, argv, "mesh", GNUNET_SERVICE_OPTION_NONE, &run, |
2943 | "mesh", | 2889 | NULL)) ? 0 : 1; |
2944 | GNUNET_SERVICE_OPTION_NONE, &run, NULL)) ? 0 : 1; | ||
2945 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "end of main()\n"); | 2890 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "end of main()\n"); |
2946 | return ret; | 2891 | return ret; |
2947 | } | 2892 | } |
diff --git a/src/mesh/mesh_api.c b/src/mesh/mesh_api.c index 1ccd31dfe..3a50e44ee 100644 --- a/src/mesh/mesh_api.c +++ b/src/mesh/mesh_api.c | |||
@@ -171,8 +171,8 @@ call_connect_handler (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
171 | } | 171 | } |
172 | 172 | ||
173 | static void | 173 | static void |
174 | core_startup (void *cls, | 174 | core_startup (void *cls, struct GNUNET_CORE_Handle *core |
175 | struct GNUNET_CORE_Handle *core __attribute__ ((unused)), | 175 | __attribute__ ((unused)), |
176 | const struct GNUNET_PeerIdentity *my_identity, | 176 | const struct GNUNET_PeerIdentity *my_identity, |
177 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey | 177 | const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *publicKey |
178 | __attribute__ ((unused))) | 178 | __attribute__ ((unused))) |
@@ -215,8 +215,7 @@ send_hello_message (void *cls, size_t size, void *buf) | |||
215 | * | 215 | * |
216 | */ | 216 | */ |
217 | static void | 217 | static void |
218 | core_connect (void *cls, | 218 | core_connect (void *cls, const struct GNUNET_PeerIdentity *peer, |
219 | const struct GNUNET_PeerIdentity *peer, | ||
220 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 219 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
221 | { | 220 | { |
222 | struct GNUNET_MESH_Handle *handle = cls; | 221 | struct GNUNET_MESH_Handle *handle = cls; |
@@ -225,11 +224,8 @@ core_connect (void *cls, | |||
225 | "Core tells us we are connected to peer %s\n", GNUNET_i2s (peer)); | 224 | "Core tells us we are connected to peer %s\n", GNUNET_i2s (peer)); |
226 | 225 | ||
227 | /* Send a hello to this peer */ | 226 | /* Send a hello to this peer */ |
228 | GNUNET_CORE_notify_transmit_ready (handle->core, | 227 | GNUNET_CORE_notify_transmit_ready (handle->core, GNUNET_NO, 42, |
229 | GNUNET_NO, | 228 | GNUNET_TIME_UNIT_SECONDS, peer, |
230 | 42, | ||
231 | GNUNET_TIME_UNIT_SECONDS, | ||
232 | peer, | ||
233 | sizeof (struct GNUNET_MessageHeader) + | 229 | sizeof (struct GNUNET_MessageHeader) + |
234 | handle->hello_message_size, | 230 | handle->hello_message_size, |
235 | &send_hello_message, cls); | 231 | &send_hello_message, cls); |
@@ -347,8 +343,7 @@ core_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer) | |||
347 | * This is a hello-message, containing the application-types the other peer can receive | 343 | * This is a hello-message, containing the application-types the other peer can receive |
348 | */ | 344 | */ |
349 | static int | 345 | static int |
350 | receive_hello (void *cls, | 346 | receive_hello (void *cls, const struct GNUNET_PeerIdentity *other, |
351 | const struct GNUNET_PeerIdentity *other, | ||
352 | const struct GNUNET_MessageHeader *message, | 347 | const struct GNUNET_MessageHeader *message, |
353 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 348 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
354 | { | 349 | { |
@@ -434,8 +429,7 @@ receive_hello (void *cls, | |||
434 | * Receive a message from core. | 429 | * Receive a message from core. |
435 | */ | 430 | */ |
436 | static int | 431 | static int |
437 | core_receive (void *cls, | 432 | core_receive (void *cls, const struct GNUNET_PeerIdentity *other, |
438 | const struct GNUNET_PeerIdentity *other, | ||
439 | const struct GNUNET_MessageHeader *message, | 433 | const struct GNUNET_MessageHeader *message, |
440 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 434 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
441 | { | 435 | { |
@@ -448,9 +442,9 @@ core_receive (void *cls, | |||
448 | 442 | ||
449 | for (handler = handle->handlers; handler->callback != NULL; handler++) | 443 | for (handler = handle->handlers; handler->callback != NULL; handler++) |
450 | { | 444 | { |
451 | if ((ntohs (rmessage->type) == handler->type) | 445 | if ((ntohs (rmessage->type) == handler->type) && |
452 | && ((handler->expected_size == 0) | 446 | ((handler->expected_size == 0) || |
453 | || (handler->expected_size == ntohs (rmessage->size)))) | 447 | (handler->expected_size == ntohs (rmessage->size)))) |
454 | { | 448 | { |
455 | break; | 449 | break; |
456 | } | 450 | } |
@@ -474,10 +468,10 @@ core_receive (void *cls, | |||
474 | if (tunnel->tunnel.id.id == tmessage->id.id && | 468 | if (tunnel->tunnel.id.id == tmessage->id.id && |
475 | (0 == | 469 | (0 == |
476 | memcmp (&tmessage->id.initiator, &tunnel->tunnel.id.initiator, | 470 | memcmp (&tmessage->id.initiator, &tunnel->tunnel.id.initiator, |
477 | sizeof (struct GNUNET_PeerIdentity))) | 471 | sizeof (struct GNUNET_PeerIdentity))) && |
478 | && (0 == | 472 | (0 == |
479 | memcmp (&tmessage->id.target, &tunnel->tunnel.id.target, | 473 | memcmp (&tmessage->id.target, &tunnel->tunnel.id.target, |
480 | sizeof (struct GNUNET_PeerIdentity)))) | 474 | sizeof (struct GNUNET_PeerIdentity)))) |
481 | break; | 475 | break; |
482 | tunnel = tunnel->next; | 476 | tunnel = tunnel->next; |
483 | } | 477 | } |
@@ -507,8 +501,8 @@ core_receive (void *cls, | |||
507 | "Inbound message from peer %s; type %d.\n", GNUNET_i2s (other), | 501 | "Inbound message from peer %s; type %d.\n", GNUNET_i2s (other), |
508 | ntohs (rmessage->type)); | 502 | ntohs (rmessage->type)); |
509 | 503 | ||
510 | return handler->callback (handle->cls, &tunnel->tunnel, | 504 | return handler->callback (handle->cls, &tunnel->tunnel, &tunnel->tunnel.ctx, |
511 | &tunnel->tunnel.ctx, other, rmessage, atsi); | 505 | other, rmessage, atsi); |
512 | } | 506 | } |
513 | 507 | ||
514 | struct GNUNET_MESH_Tunnel * | 508 | struct GNUNET_MESH_Tunnel * |
@@ -691,19 +685,13 @@ core_notify (void *cls, size_t size, void *buf) | |||
691 | * memory); if NULL is returned, "notify" will NOT be called. | 685 | * memory); if NULL is returned, "notify" will NOT be called. |
692 | */ | 686 | */ |
693 | struct GNUNET_MESH_TransmitHandle * | 687 | struct GNUNET_MESH_TransmitHandle * |
694 | GNUNET_MESH_notify_transmit_ready (struct | 688 | GNUNET_MESH_notify_transmit_ready (struct GNUNET_MESH_Tunnel *tunnel, int cork, |
695 | GNUNET_MESH_Tunnel | ||
696 | *tunnel, | ||
697 | int cork, | ||
698 | uint32_t priority, | 689 | uint32_t priority, |
699 | struct | 690 | struct GNUNET_TIME_Relative maxdelay, |
700 | GNUNET_TIME_Relative | ||
701 | maxdelay, | ||
702 | const struct GNUNET_PeerIdentity *target | 691 | const struct GNUNET_PeerIdentity *target |
703 | __attribute__ ((unused)), | 692 | __attribute__ ((unused)), size_t notify_size, |
704 | size_t notify_size, | 693 | GNUNET_CONNECTION_TransmitReadyNotify notify, |
705 | GNUNET_CONNECTION_TransmitReadyNotify | 694 | void *notify_cls) |
706 | notify, void *notify_cls) | ||
707 | { | 695 | { |
708 | if (NULL != tunnel->notify_handle) | 696 | if (NULL != tunnel->notify_handle) |
709 | { | 697 | { |
@@ -718,7 +706,8 @@ GNUNET_MESH_notify_transmit_ready (struct | |||
718 | cls->notify = notify; | 706 | cls->notify = notify; |
719 | cls->tunnel = tunnel; | 707 | cls->tunnel = tunnel; |
720 | 708 | ||
721 | tunnel->notify_handle = (struct GNUNET_MESH_TransmitHandle *) | 709 | tunnel->notify_handle = |
710 | (struct GNUNET_MESH_TransmitHandle *) | ||
722 | GNUNET_CORE_notify_transmit_ready (tunnel->handle->core, cork, priority, | 711 | GNUNET_CORE_notify_transmit_ready (tunnel->handle->core, cork, priority, |
723 | maxdelay, &tunnel->peer, | 712 | maxdelay, &tunnel->peer, |
724 | notify_size + | 713 | notify_size + |
@@ -806,11 +795,8 @@ build_hello_message (struct GNUNET_MESH_Handle *handle, | |||
806 | 795 | ||
807 | 796 | ||
808 | struct GNUNET_MESH_Handle * | 797 | struct GNUNET_MESH_Handle * |
809 | GNUNET_MESH_connect (const struct | 798 | GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls, |
810 | GNUNET_CONFIGURATION_Handle | 799 | GNUNET_MESH_TunnelEndHandler cleaner, |
811 | *cfg, void *cls, | ||
812 | GNUNET_MESH_TunnelEndHandler | ||
813 | cleaner, | ||
814 | const struct GNUNET_MESH_MessageHandler *handlers, | 800 | const struct GNUNET_MESH_MessageHandler *handlers, |
815 | const GNUNET_MESH_ApplicationType *stypes) | 801 | const GNUNET_MESH_ApplicationType *stypes) |
816 | { | 802 | { |
@@ -845,15 +831,10 @@ GNUNET_MESH_connect (const struct | |||
845 | {NULL, 0, 0} | 831 | {NULL, 0, 0} |
846 | }; | 832 | }; |
847 | 833 | ||
848 | ret->core = GNUNET_CORE_connect (cfg, | 834 | ret->core = |
849 | 42, | 835 | GNUNET_CORE_connect (cfg, 42, ret, &core_startup, &core_connect, |
850 | ret, | 836 | &core_disconnect, NULL, NULL, GNUNET_NO, NULL, |
851 | &core_startup, | 837 | GNUNET_NO, core_handlers); |
852 | &core_connect, | ||
853 | &core_disconnect, | ||
854 | NULL, | ||
855 | NULL, | ||
856 | GNUNET_NO, NULL, GNUNET_NO, core_handlers); | ||
857 | return ret; | 838 | return ret; |
858 | } | 839 | } |
859 | 840 | ||
diff --git a/src/mesh/mesh_api_new.c b/src/mesh/mesh_api_new.c index 83ac2a818..f765aca1c 100644 --- a/src/mesh/mesh_api_new.c +++ b/src/mesh/mesh_api_new.c | |||
@@ -239,18 +239,20 @@ send_connect_packet (void *cls, size_t size, void *buf) | |||
239 | 239 | ||
240 | for (napps = 0, apps = NULL; napps < h->n_applications; napps++) | 240 | for (napps = 0, apps = NULL; napps < h->n_applications; napps++) |
241 | { | 241 | { |
242 | apps = GNUNET_realloc (apps, | 242 | apps = |
243 | sizeof (GNUNET_MESH_ApplicationType) * (napps + 1)); | 243 | GNUNET_realloc (apps, |
244 | sizeof (GNUNET_MESH_ApplicationType) * (napps + 1)); | ||
244 | apps[napps] = h->applications[napps]; | 245 | apps[napps] = h->applications[napps]; |
245 | } | 246 | } |
246 | 247 | ||
247 | msg->header.size = htons (sizeof (struct GNUNET_MESH_ClientConnect) + | 248 | msg->header.size = |
248 | sizeof (uint16_t) * ntypes + | 249 | htons (sizeof (struct GNUNET_MESH_ClientConnect) + |
249 | sizeof (GNUNET_MESH_ApplicationType) * napps); | 250 | sizeof (uint16_t) * ntypes + |
251 | sizeof (GNUNET_MESH_ApplicationType) * napps); | ||
250 | 252 | ||
251 | memcpy (&msg[1], types, sizeof (uint16_t) * ntypes); | 253 | memcpy (&msg[1], types, sizeof (uint16_t) * ntypes); |
252 | memcpy (&msg[1] + sizeof (uint16_t) * ntypes, | 254 | memcpy (&msg[1] + sizeof (uint16_t) * ntypes, apps, |
253 | apps, sizeof (GNUNET_MESH_ApplicationType) * napps); | 255 | sizeof (GNUNET_MESH_ApplicationType) * napps); |
254 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 256 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
255 | "Sent %lu bytes long message %d types and %d apps\n", | 257 | "Sent %lu bytes long message %d types and %d apps\n", |
256 | ntohs (msg->header.size), ntypes, napps); | 258 | ntohs (msg->header.size), ntypes, napps); |
@@ -303,8 +305,8 @@ send_tunnel_create_packet (void *cls, size_t size, void *buf) | |||
303 | msg->header.size = htons (sizeof (struct GNUNET_MESH_TunnelMessage)); | 305 | msg->header.size = htons (sizeof (struct GNUNET_MESH_TunnelMessage)); |
304 | msg->tunnel_id = htonl (t->tid); | 306 | msg->tunnel_id = htonl (t->tid); |
305 | 307 | ||
306 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 308 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sent %lu bytes long message\n", |
307 | "Sent %lu bytes long message\n", ntohs (msg->header.size)); | 309 | ntohs (msg->header.size)); |
308 | 310 | ||
309 | return ntohs (msg->header.size); | 311 | return ntohs (msg->header.size); |
310 | } | 312 | } |
@@ -502,8 +504,8 @@ msg_received (void *cls, const struct GNUNET_MessageHeader *msg) | |||
502 | } | 504 | } |
503 | 505 | ||
504 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "received a message from mesh\n"); | 506 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "received a message from mesh\n"); |
505 | GNUNET_CLIENT_receive (h->client, | 507 | GNUNET_CLIENT_receive (h->client, &msg_received, h, |
506 | &msg_received, h, GNUNET_TIME_UNIT_FOREVER_REL); | 508 | GNUNET_TIME_UNIT_FOREVER_REL); |
507 | return; | 509 | return; |
508 | } | 510 | } |
509 | 511 | ||
@@ -527,8 +529,7 @@ msg_received (void *cls, const struct GNUNET_MessageHeader *msg) | |||
527 | * NULL on error (in this case, init is never called) | 529 | * NULL on error (in this case, init is never called) |
528 | */ | 530 | */ |
529 | struct GNUNET_MESH_Handle * | 531 | struct GNUNET_MESH_Handle * |
530 | GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | 532 | GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, void *cls, |
531 | void *cls, | ||
532 | GNUNET_MESH_TunnelEndHandler cleaner, | 533 | GNUNET_MESH_TunnelEndHandler cleaner, |
533 | const struct GNUNET_MESH_MessageHandler *handlers, | 534 | const struct GNUNET_MESH_MessageHandler *handlers, |
534 | const GNUNET_MESH_ApplicationType *stypes) | 535 | const GNUNET_MESH_ApplicationType *stypes) |
@@ -540,8 +541,8 @@ GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
540 | 541 | ||
541 | h->cleaner = cleaner; | 542 | h->cleaner = cleaner; |
542 | h->client = GNUNET_CLIENT_connect ("mesh", cfg); | 543 | h->client = GNUNET_CLIENT_connect ("mesh", cfg); |
543 | GNUNET_CLIENT_receive (h->client, | 544 | GNUNET_CLIENT_receive (h->client, &msg_received, h, |
544 | &msg_received, h, GNUNET_TIME_UNIT_FOREVER_REL); | 545 | GNUNET_TIME_UNIT_FOREVER_REL); |
545 | if (h->client == NULL) | 546 | if (h->client == NULL) |
546 | { | 547 | { |
547 | GNUNET_free (h); | 548 | GNUNET_free (h); |
@@ -560,12 +561,11 @@ GNUNET_MESH_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | |||
560 | size += h->n_handlers * sizeof (uint16_t); | 561 | size += h->n_handlers * sizeof (uint16_t); |
561 | size += h->n_applications * sizeof (GNUNET_MESH_ApplicationType); | 562 | size += h->n_applications * sizeof (GNUNET_MESH_ApplicationType); |
562 | 563 | ||
563 | h->th = GNUNET_CLIENT_notify_transmit_ready (h->client, | 564 | h->th = |
564 | size, | 565 | GNUNET_CLIENT_notify_transmit_ready (h->client, size, |
565 | GNUNET_TIME_UNIT_FOREVER_REL, | 566 | GNUNET_TIME_UNIT_FOREVER_REL, |
566 | GNUNET_YES, | 567 | GNUNET_YES, &send_connect_packet, |
567 | &send_connect_packet, | 568 | (void *) h); |
568 | (void *) h); | ||
569 | 569 | ||
570 | return h; | 570 | return h; |
571 | } | 571 | } |
@@ -602,8 +602,7 @@ GNUNET_MESH_disconnect (struct GNUNET_MESH_Handle *handle) | |||
602 | */ | 602 | */ |
603 | struct GNUNET_MESH_Tunnel * | 603 | struct GNUNET_MESH_Tunnel * |
604 | GNUNET_MESH_tunnel_create (struct GNUNET_MESH_Handle *h, | 604 | GNUNET_MESH_tunnel_create (struct GNUNET_MESH_Handle *h, |
605 | GNUNET_MESH_TunnelConnectHandler | 605 | GNUNET_MESH_TunnelConnectHandler connect_handler, |
606 | connect_handler, | ||
607 | GNUNET_MESH_TunnelDisconnectHandler | 606 | GNUNET_MESH_TunnelDisconnectHandler |
608 | disconnect_handler, void *handler_cls) | 607 | disconnect_handler, void *handler_cls) |
609 | { | 608 | { |
@@ -619,13 +618,14 @@ GNUNET_MESH_tunnel_create (struct GNUNET_MESH_Handle *h, | |||
619 | tunnel->tid = h->next_tid++; | 618 | tunnel->tid = h->next_tid++; |
620 | h->next_tid |= GNUNET_MESH_LOCAL_TUNNEL_ID_MARK; // keep in range | 619 | h->next_tid |= GNUNET_MESH_LOCAL_TUNNEL_ID_MARK; // keep in range |
621 | 620 | ||
622 | h->th = GNUNET_CLIENT_notify_transmit_ready (h->client, | 621 | h->th = |
623 | sizeof (struct | 622 | GNUNET_CLIENT_notify_transmit_ready (h->client, |
624 | GNUNET_MESH_TunnelMessage), | 623 | sizeof (struct |
625 | GNUNET_TIME_UNIT_FOREVER_REL, | 624 | GNUNET_MESH_TunnelMessage), |
626 | GNUNET_YES, | 625 | GNUNET_TIME_UNIT_FOREVER_REL, |
627 | &send_tunnel_create_packet, | 626 | GNUNET_YES, |
628 | (void *) tunnel); | 627 | &send_tunnel_create_packet, |
628 | (void *) tunnel); | ||
629 | 629 | ||
630 | return tunnel; | 630 | return tunnel; |
631 | } | 631 | } |
@@ -714,14 +714,13 @@ GNUNET_MESH_peer_request_connect_by_type (struct GNUNET_MESH_Tunnel *tunnel, | |||
714 | * memory); if NULL is returned, "notify" will NOT be called. | 714 | * memory); if NULL is returned, "notify" will NOT be called. |
715 | */ | 715 | */ |
716 | struct GNUNET_MESH_TransmitHandle * | 716 | struct GNUNET_MESH_TransmitHandle * |
717 | GNUNET_MESH_notify_transmit_ready (struct GNUNET_MESH_Tunnel *tunnel, | 717 | GNUNET_MESH_notify_transmit_ready (struct GNUNET_MESH_Tunnel *tunnel, int cork, |
718 | int cork, | ||
719 | uint32_t priority, | 718 | uint32_t priority, |
720 | struct GNUNET_TIME_Relative maxdelay, | 719 | struct GNUNET_TIME_Relative maxdelay, |
721 | const struct GNUNET_PeerIdentity *target, | 720 | const struct GNUNET_PeerIdentity *target, |
722 | size_t notify_size, | 721 | size_t notify_size, |
723 | GNUNET_CONNECTION_TransmitReadyNotify | 722 | GNUNET_CONNECTION_TransmitReadyNotify notify, |
724 | notify, void *notify_cls) | 723 | void *notify_cls) |
725 | { | 724 | { |
726 | struct GNUNET_MESH_TransmitHandle *handle; | 725 | struct GNUNET_MESH_TransmitHandle *handle; |
727 | 726 | ||
diff --git a/src/mesh/test_mesh_api.c b/src/mesh/test_mesh_api.c index 9828ee8d9..c5f0e9f0f 100644 --- a/src/mesh/test_mesh_api.c +++ b/src/mesh/test_mesh_api.c | |||
@@ -51,9 +51,7 @@ GNUNET_SCHEDULER_TaskIdentifier test_task; | |||
51 | * GNUNET_SYSERR to close it (signal serious error) | 51 | * GNUNET_SYSERR to close it (signal serious error) |
52 | */ | 52 | */ |
53 | static int | 53 | static int |
54 | callback (void *cls, | 54 | callback (void *cls, struct GNUNET_MESH_Tunnel *tunnel, void **tunnel_ctx, |
55 | struct GNUNET_MESH_Tunnel *tunnel, | ||
56 | void **tunnel_ctx, | ||
57 | const struct GNUNET_PeerIdentity *sender, | 55 | const struct GNUNET_PeerIdentity *sender, |
58 | const struct GNUNET_MessageHeader *message, | 56 | const struct GNUNET_MessageHeader *message, |
59 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) | 57 | const struct GNUNET_TRANSPORT_ATS_Information *atsi) |
@@ -125,16 +123,16 @@ test (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
125 | 123 | ||
126 | 124 | ||
127 | static void | 125 | static void |
128 | run (void *cls, | 126 | run (void *cls, char *const *args, const char *cfgfile, |
129 | char *const *args, | 127 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
130 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
131 | { | 128 | { |
132 | arm_pid = GNUNET_OS_start_process (NULL, NULL, | 129 | arm_pid = |
133 | "gnunet-service-arm", "gnunet-service-arm", | 130 | GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", |
131 | "gnunet-service-arm", | ||
134 | #if VERBOSE_ARM | 132 | #if VERBOSE_ARM |
135 | "-L", "DEBUG", | 133 | "-L", "DEBUG", |
136 | #endif | 134 | #endif |
137 | "-c", "test_mesh.conf", NULL); | 135 | "-c", "test_mesh.conf", NULL); |
138 | 136 | ||
139 | abort_task = | 137 | abort_task = |
140 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply | 138 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply |
@@ -170,14 +168,14 @@ main (int argc, char *argv[]) | |||
170 | "WARNING", | 168 | "WARNING", |
171 | #endif | 169 | #endif |
172 | NULL); | 170 | NULL); |
173 | ret = GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, | 171 | ret = |
174 | argv2, "test-mesh-api", "nohelp", | 172 | GNUNET_PROGRAM_run ((sizeof (argv2) / sizeof (char *)) - 1, argv2, |
175 | options, &run, NULL); | 173 | "test-mesh-api", "nohelp", options, &run, NULL); |
176 | 174 | ||
177 | if (GNUNET_OK != ret) | 175 | if (GNUNET_OK != ret) |
178 | { | 176 | { |
179 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 177 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "run failed with error code %d\n", |
180 | "run failed with error code %d\n", ret); | 178 | ret); |
181 | return 1; | 179 | return 1; |
182 | } | 180 | } |
183 | if (GNUNET_SYSERR == result) | 181 | if (GNUNET_SYSERR == result) |
diff --git a/src/mesh/test_mesh_small.c b/src/mesh/test_mesh_small.c index d0d394177..fe0ca631d 100644 --- a/src/mesh/test_mesh_small.c +++ b/src/mesh/test_mesh_small.c | |||
@@ -213,8 +213,8 @@ connect_mesh_service (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
213 | } | 213 | } |
214 | 214 | ||
215 | 215 | ||
216 | static void | 216 | static void churn_peers (void *cls, |
217 | churn_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 217 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
218 | 218 | ||
219 | 219 | ||
220 | /** | 220 | /** |
@@ -235,9 +235,9 @@ stats_finished_callback (void *cls, int success) | |||
235 | { | 235 | { |
236 | /* Stats lookup successful, write out data */ | 236 | /* Stats lookup successful, write out data */ |
237 | buf = NULL; | 237 | buf = NULL; |
238 | buf_len = GNUNET_asprintf (&buf, | 238 | buf_len = |
239 | "TOTAL_MESH_BYTES: %u\n", | 239 | GNUNET_asprintf (&buf, "TOTAL_MESH_BYTES: %u\n", |
240 | stats_context->total_mesh_bytes); | 240 | stats_context->total_mesh_bytes); |
241 | if (buf_len > 0) | 241 | if (buf_len > 0) |
242 | { | 242 | { |
243 | GNUNET_DISK_file_write (data_file, buf, buf_len); | 243 | GNUNET_DISK_file_write (data_file, buf, buf_len); |
@@ -263,10 +263,9 @@ stats_finished_callback (void *cls, int success) | |||
263 | * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration | 263 | * @return GNUNET_OK to continue, GNUNET_SYSERR to abort iteration |
264 | */ | 264 | */ |
265 | static int | 265 | static int |
266 | statistics_iterator (void *cls, | 266 | statistics_iterator (void *cls, const struct GNUNET_PeerIdentity *peer, |
267 | const struct GNUNET_PeerIdentity *peer, | 267 | const char *subsystem, const char *name, uint64_t value, |
268 | const char *subsystem, | 268 | int is_persistent) |
269 | const char *name, uint64_t value, int is_persistent) | ||
270 | { | 269 | { |
271 | struct StatsContext *stats_context = cls; | 270 | struct StatsContext *stats_context = cls; |
272 | 271 | ||
@@ -300,10 +299,9 @@ disconnect_mesh_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
300 | // } | 299 | // } |
301 | 300 | ||
302 | GNUNET_asprintf (&buf, "round%llu", current_round); | 301 | GNUNET_asprintf (&buf, "round%llu", current_round); |
303 | if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (testing_cfg, | 302 | if (GNUNET_OK == |
304 | "test_mesh_small", | 303 | GNUNET_CONFIGURATION_get_value_number (testing_cfg, "test_mesh_small", |
305 | buf, | 304 | buf, &peers_next_round)) |
306 | &peers_next_round)) | ||
307 | { | 305 | { |
308 | current_round++; | 306 | current_round++; |
309 | GNUNET_assert (churn_task == GNUNET_SCHEDULER_NO_TASK); | 307 | GNUNET_assert (churn_task == GNUNET_SCHEDULER_NO_TASK); |
@@ -314,8 +312,7 @@ disconnect_mesh_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
314 | stats_context = GNUNET_malloc (sizeof (struct StatsContext)); | 312 | stats_context = GNUNET_malloc (sizeof (struct StatsContext)); |
315 | GNUNET_SCHEDULER_cancel (shutdown_handle); | 313 | GNUNET_SCHEDULER_cancel (shutdown_handle); |
316 | shutdown_handle = GNUNET_SCHEDULER_NO_TASK; | 314 | shutdown_handle = GNUNET_SCHEDULER_NO_TASK; |
317 | GNUNET_TESTING_get_statistics (pg, | 315 | GNUNET_TESTING_get_statistics (pg, &stats_finished_callback, |
318 | &stats_finished_callback, | ||
319 | &statistics_iterator, stats_context); | 316 | &statistics_iterator, stats_context); |
320 | } | 317 | } |
321 | GNUNET_free (buf); | 318 | GNUNET_free (buf); |
@@ -331,8 +328,8 @@ disconnect_mesh_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
331 | static void | 328 | static void |
332 | topology_output_callback (void *cls, const char *emsg) | 329 | topology_output_callback (void *cls, const char *emsg) |
333 | { | 330 | { |
334 | disconnect_task = GNUNET_SCHEDULER_add_delayed (wait_time, | 331 | disconnect_task = |
335 | &disconnect_mesh_peers, NULL); | 332 | GNUNET_SCHEDULER_add_delayed (wait_time, &disconnect_mesh_peers, NULL); |
336 | GNUNET_SCHEDULER_add_now (&connect_mesh_service, NULL); | 333 | GNUNET_SCHEDULER_add_now (&connect_mesh_service, NULL); |
337 | } | 334 | } |
338 | 335 | ||
@@ -354,19 +351,18 @@ churn_callback (void *cls, const char *emsg) | |||
354 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 351 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
355 | "Round %llu, churn finished successfully.\n", current_round); | 352 | "Round %llu, churn finished successfully.\n", current_round); |
356 | GNUNET_assert (disconnect_task == GNUNET_SCHEDULER_NO_TASK); | 353 | GNUNET_assert (disconnect_task == GNUNET_SCHEDULER_NO_TASK); |
357 | GNUNET_asprintf (&temp_output_file, | 354 | GNUNET_asprintf (&temp_output_file, "%s_%llu.dot", topology_file, |
358 | "%s_%llu.dot", topology_file, current_round); | 355 | current_round); |
359 | GNUNET_TESTING_peergroup_topology_to_file (pg, | 356 | GNUNET_TESTING_peergroup_topology_to_file (pg, temp_output_file, |
360 | temp_output_file, | ||
361 | &topology_output_callback, NULL); | 357 | &topology_output_callback, NULL); |
362 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 358 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Writing topology to file %s\n", |
363 | "Writing topology to file %s\n", temp_output_file); | 359 | temp_output_file); |
364 | GNUNET_free (temp_output_file); | 360 | GNUNET_free (temp_output_file); |
365 | } | 361 | } |
366 | else | 362 | else |
367 | { | 363 | { |
368 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 364 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Round %llu, churn FAILED!!\n", |
369 | "Round %llu, churn FAILED!!\n", current_round); | 365 | current_round); |
370 | GNUNET_SCHEDULER_cancel (shutdown_handle); | 366 | GNUNET_SCHEDULER_cancel (shutdown_handle); |
371 | shutdown_handle = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | 367 | shutdown_handle = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); |
372 | } | 368 | } |
@@ -383,9 +379,8 @@ churn_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
383 | /* Nothing to do... */ | 379 | /* Nothing to do... */ |
384 | GNUNET_SCHEDULER_add_now (&connect_mesh_service, NULL); | 380 | GNUNET_SCHEDULER_add_now (&connect_mesh_service, NULL); |
385 | GNUNET_assert (disconnect_task == GNUNET_SCHEDULER_NO_TASK); | 381 | GNUNET_assert (disconnect_task == GNUNET_SCHEDULER_NO_TASK); |
386 | disconnect_task = GNUNET_SCHEDULER_add_delayed (wait_time, | 382 | disconnect_task = |
387 | &disconnect_mesh_peers, | 383 | GNUNET_SCHEDULER_add_delayed (wait_time, &disconnect_mesh_peers, NULL); |
388 | NULL); | ||
389 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Round %lu, doing nothing!\n", | 384 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Round %lu, doing nothing!\n", |
390 | current_round); | 385 | current_round); |
391 | } | 386 | } |
@@ -401,18 +396,18 @@ churn_peers (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
401 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 396 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
402 | "Round %llu, turning off %llu peers, turning on %llu peers!\n", | 397 | "Round %llu, turning off %llu peers, turning on %llu peers!\n", |
403 | current_round, | 398 | current_round, |
404 | (peers_running > peers_next_round) | 399 | (peers_running > |
405 | ? peers_running - peers_next_round | 400 | peers_next_round) ? peers_running - peers_next_round : 0, |
406 | : 0, | 401 | (peers_next_round > |
407 | (peers_next_round > peers_running) | 402 | peers_running) ? peers_next_round - peers_running : 0); |
408 | ? peers_next_round - peers_running : 0); | ||
409 | GNUNET_TESTING_daemons_churn (pg, "nse", | 403 | GNUNET_TESTING_daemons_churn (pg, "nse", |
410 | (peers_running > peers_next_round) | 404 | (peers_running > |
411 | ? peers_running - peers_next_round | 405 | peers_next_round) ? peers_running - |
412 | : 0, | 406 | peers_next_round : 0, |
413 | (peers_next_round > peers_running) | 407 | (peers_next_round > |
414 | ? peers_next_round - peers_running | 408 | peers_running) ? peers_next_round - |
415 | : 0, wait_time, &churn_callback, NULL); | 409 | peers_running : 0, wait_time, &churn_callback, |
410 | NULL); | ||
416 | } | 411 | } |
417 | } | 412 | } |
418 | 413 | ||
@@ -435,8 +430,8 @@ my_cb (void *cls, const char *emsg) | |||
435 | #if VERBOSE | 430 | #if VERBOSE |
436 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer Group started successfully!\n"); | 431 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer Group started successfully!\n"); |
437 | #endif | 432 | #endif |
438 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 433 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Have %u connections\n", |
439 | "Have %u connections\n", total_connections); | 434 | total_connections); |
440 | if (data_file != NULL) | 435 | if (data_file != NULL) |
441 | { | 436 | { |
442 | buf = NULL; | 437 | buf = NULL; |
@@ -469,10 +464,8 @@ my_cb (void *cls, const char *emsg) | |||
469 | * @param emsg error message (NULL on success) | 464 | * @param emsg error message (NULL on success) |
470 | */ | 465 | */ |
471 | static void | 466 | static void |
472 | connect_cb (void *cls, | 467 | connect_cb (void *cls, const struct GNUNET_PeerIdentity *first, |
473 | const struct GNUNET_PeerIdentity *first, | 468 | const struct GNUNET_PeerIdentity *second, uint32_t distance, |
474 | const struct GNUNET_PeerIdentity *second, | ||
475 | uint32_t distance, | ||
476 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, | 469 | const struct GNUNET_CONFIGURATION_Handle *first_cfg, |
477 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, | 470 | const struct GNUNET_CONFIGURATION_Handle *second_cfg, |
478 | struct GNUNET_TESTING_Daemon *first_daemon, | 471 | struct GNUNET_TESTING_Daemon *first_daemon, |
@@ -484,9 +477,8 @@ connect_cb (void *cls, | |||
484 | 477 | ||
485 | 478 | ||
486 | static void | 479 | static void |
487 | run (void *cls, | 480 | run (void *cls, char *const *args, const char *cfgfile, |
488 | char *const *args, | 481 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
489 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
490 | { | 482 | { |
491 | char *temp_str; | 483 | char *temp_str; |
492 | unsigned long long temp_wait; | 484 | unsigned long long temp_wait; |
@@ -496,82 +488,80 @@ run (void *cls, | |||
496 | testing_cfg = (struct GNUNET_CONFIGURATION_Handle *) cfg; // GNUNET_CONFIGURATION_create(); | 488 | testing_cfg = (struct GNUNET_CONFIGURATION_Handle *) cfg; // GNUNET_CONFIGURATION_create(); |
497 | #if VERBOSE | 489 | #if VERBOSE |
498 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons.\n"); | 490 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting daemons.\n"); |
499 | GNUNET_CONFIGURATION_set_value_string (testing_cfg, | 491 | GNUNET_CONFIGURATION_set_value_string (testing_cfg, "testing", |
500 | "testing", "use_progressbars", "YES"); | 492 | "use_progressbars", "YES"); |
501 | #endif | 493 | #endif |
502 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg, | 494 | if (GNUNET_OK != |
503 | "testing", | 495 | GNUNET_CONFIGURATION_get_value_number (testing_cfg, "testing", |
504 | "num_peers", | 496 | "num_peers", &num_peers)) |
505 | &num_peers)) | ||
506 | { | 497 | { |
507 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 498 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
508 | "Option TESTING:NUM_PEERS is required!\n"); | 499 | "Option TESTING:NUM_PEERS is required!\n"); |
509 | return; | 500 | return; |
510 | } | 501 | } |
511 | 502 | ||
512 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_number (testing_cfg, | 503 | if (GNUNET_OK != |
513 | "test_mesh_small", | 504 | GNUNET_CONFIGURATION_get_value_number (testing_cfg, "test_mesh_small", |
514 | "wait_time", | 505 | "wait_time", &temp_wait)) |
515 | &temp_wait)) | ||
516 | { | 506 | { |
517 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 507 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
518 | "Option nsetest_mesh_small:wait_time is required!\n"); | 508 | "Option nsetest_mesh_small:wait_time is required!\n"); |
519 | return; | 509 | return; |
520 | } | 510 | } |
521 | 511 | ||
522 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (testing_cfg, | 512 | if (GNUNET_OK != |
523 | "testing", | 513 | GNUNET_CONFIGURATION_get_value_string (testing_cfg, "testing", |
524 | "topology_output_file", | 514 | "topology_output_file", |
525 | &topology_file)) | 515 | &topology_file)) |
526 | { | 516 | { |
527 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 517 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
528 | "Option test_mesh_small:topology_output_file is required!\n"); | 518 | "Option test_mesh_small:topology_output_file is required!\n"); |
529 | return; | 519 | return; |
530 | } | 520 | } |
531 | 521 | ||
532 | if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (testing_cfg, | 522 | if (GNUNET_OK != |
533 | "test_mesh_small", | 523 | GNUNET_CONFIGURATION_get_value_string (testing_cfg, "test_mesh_small", |
534 | "data_output_file", | 524 | "data_output_file", |
535 | &data_filename)) | 525 | &data_filename)) |
536 | { | 526 | { |
537 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 527 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
538 | "Option test_mesh_small:data_output_file is required!\n"); | 528 | "Option test_mesh_small:data_output_file is required!\n"); |
539 | return; | 529 | return; |
540 | } | 530 | } |
541 | 531 | ||
542 | data_file = GNUNET_DISK_file_open (data_filename, | 532 | data_file = |
543 | GNUNET_DISK_OPEN_READWRITE | 533 | GNUNET_DISK_file_open (data_filename, |
544 | | GNUNET_DISK_OPEN_CREATE, | 534 | GNUNET_DISK_OPEN_READWRITE | |
545 | GNUNET_DISK_PERM_USER_READ | | 535 | GNUNET_DISK_OPEN_CREATE, |
546 | GNUNET_DISK_PERM_USER_WRITE); | 536 | GNUNET_DISK_PERM_USER_READ | |
537 | GNUNET_DISK_PERM_USER_WRITE); | ||
547 | if (data_file == NULL) | 538 | if (data_file == NULL) |
548 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 539 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to open %s for output!\n", |
549 | "Failed to open %s for output!\n", data_filename); | 540 | data_filename); |
550 | GNUNET_free (data_filename); | 541 | GNUNET_free (data_filename); |
551 | 542 | ||
552 | wait_time = | 543 | wait_time = |
553 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_wait); | 544 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, temp_wait); |
554 | 545 | ||
555 | if (GNUNET_YES == GNUNET_CONFIGURATION_get_value_string (cfg, | 546 | if (GNUNET_YES == |
556 | "test_mesh_small", | 547 | GNUNET_CONFIGURATION_get_value_string (cfg, "test_mesh_small", |
557 | "output_file", | 548 | "output_file", &temp_str)) |
558 | &temp_str)) | ||
559 | { | 549 | { |
560 | output_file = GNUNET_DISK_file_open (temp_str, GNUNET_DISK_OPEN_READWRITE | 550 | output_file = |
561 | | GNUNET_DISK_OPEN_CREATE, | 551 | GNUNET_DISK_file_open (temp_str, |
562 | GNUNET_DISK_PERM_USER_READ | | 552 | GNUNET_DISK_OPEN_READWRITE | |
563 | GNUNET_DISK_PERM_USER_WRITE); | 553 | GNUNET_DISK_OPEN_CREATE, |
554 | GNUNET_DISK_PERM_USER_READ | | ||
555 | GNUNET_DISK_PERM_USER_WRITE); | ||
564 | if (output_file == NULL) | 556 | if (output_file == NULL) |
565 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 557 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Failed to open %s for output!\n", |
566 | "Failed to open %s for output!\n", temp_str); | 558 | temp_str); |
567 | } | 559 | } |
568 | GNUNET_free_non_null (temp_str); | 560 | GNUNET_free_non_null (temp_str); |
569 | 561 | ||
570 | hosts = GNUNET_TESTING_hosts_load (testing_cfg); | 562 | hosts = GNUNET_TESTING_hosts_load (testing_cfg); |
571 | 563 | ||
572 | pg = GNUNET_TESTING_peergroup_start (testing_cfg, | 564 | pg = GNUNET_TESTING_peergroup_start (testing_cfg, num_peers, TIMEOUT, |
573 | num_peers, | ||
574 | TIMEOUT, | ||
575 | &connect_cb, &my_cb, NULL, hosts); | 565 | &connect_cb, &my_cb, NULL, hosts); |
576 | GNUNET_assert (pg != NULL); | 566 | GNUNET_assert (pg != NULL); |
577 | shutdown_handle = | 567 | shutdown_handle = |
@@ -602,10 +592,9 @@ main (int argc, char *argv[]) | |||
602 | "WARNING", | 592 | "WARNING", |
603 | #endif | 593 | #endif |
604 | NULL); | 594 | NULL); |
605 | GNUNET_PROGRAM_run (argc, | 595 | GNUNET_PROGRAM_run (argc, argv, "test_mesh_small", |
606 | argv, "test_mesh_small", | 596 | gettext_noop ("Test mesh in a small network."), options, |
607 | gettext_noop ("Test mesh in a small network."), | 597 | &run, NULL); |
608 | options, &run, NULL); | ||
609 | #if REMOVE_DIR | 598 | #if REMOVE_DIR |
610 | GNUNET_DISK_directory_remove ("/tmp/test_mesh_small"); | 599 | GNUNET_DISK_directory_remove ("/tmp/test_mesh_small"); |
611 | #endif | 600 | #endif |