aboutsummaryrefslogtreecommitdiff
path: root/src/testbed/testbed_api_topology.c
diff options
context:
space:
mode:
authorSree Harsha Totakura <totakura@in.tum.de>2012-12-17 13:11:54 +0000
committerSree Harsha Totakura <totakura@in.tum.de>2012-12-17 13:11:54 +0000
commit6e00d60dcda92185169e7758817914f3c41c58da (patch)
tree3d524fa95e5b94d3329fcf9dc57811e6a68d6d52 /src/testbed/testbed_api_topology.c
parenta6357180c8a0880dbc6b2effbc726d54b15205d1 (diff)
downloadgnunet-6e00d60dcda92185169e7758817914f3c41c58da.tar.gz
gnunet-6e00d60dcda92185169e7758817914f3c41c58da.zip
- warn if connecting a peer to itself
- peer indices in overlay topology file start with index 0
Diffstat (limited to 'src/testbed/testbed_api_topology.c')
-rw-r--r--src/testbed/testbed_api_topology.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/testbed/testbed_api_topology.c b/src/testbed/testbed_api_topology.c
index fd37d6572..0b949d3aa 100644
--- a/src/testbed/testbed_api_topology.c
+++ b/src/testbed/testbed_api_topology.c
@@ -266,11 +266,11 @@ oprelease_overlay_configure_topology (void *cls)
266 266
267 267
268/** 268/**
269 * Populates the OverlayLink structure 269 * Populates the OverlayLink structure.
270 * 270 *
271 * @param link the OverlayLink 271 * @param link the OverlayLink
272 * @param A the peer A 272 * @param A the peer A. Should be different from B
273 * @param B the peer B 273 * @param B the peer B. Should be different from A
274 * @param tc the TopologyContext 274 * @param tc the TopologyContext
275 * @return 275 * @return
276 */ 276 */
@@ -280,6 +280,8 @@ make_link (struct OverlayLink *link,
280 uint32_t B, 280 uint32_t B,
281 struct TopologyContext *tc) 281 struct TopologyContext *tc)
282{ 282{
283 GNUNET_assert (A != B);
284 LOG (GNUNET_ERROR_TYPE_DEBUG, "Connecting peer %u to %u\n", B, A);
283 link->A = A; 285 link->A = A;
284 link->B = B; 286 link->B = B;
285 link->op = NULL; 287 link->op = NULL;
@@ -633,7 +635,7 @@ gen_topo_from_file (struct TopologyContext *tc, const char *filename)
633 if (tc->num_peers <= peer_id) 635 if (tc->num_peers <= peer_id)
634 { 636 {
635 LOG (GNUNET_ERROR_TYPE_ERROR, 637 LOG (GNUNET_ERROR_TYPE_ERROR,
636 _("Topology file need more peers than the given ones\n"), 638 _("Topology file needs more peers than given ones\n"),
637 filename); 639 filename);
638 goto _exit; 640 goto _exit;
639 } 641 }
@@ -658,17 +660,23 @@ gen_topo_from_file (struct TopologyContext *tc, const char *filename)
658 if (tc->num_peers <= other_peer_id) 660 if (tc->num_peers <= other_peer_id)
659 { 661 {
660 LOG (GNUNET_ERROR_TYPE_ERROR, 662 LOG (GNUNET_ERROR_TYPE_ERROR,
661 _("Topology file need more peers than the given ones\n"), 663 _("Topology file needs more peers than given ones\n"),
662 filename); 664 filename);
663 goto _exit; 665 goto _exit;
664 } 666 }
665 tc->link_array_size++; 667 if (peer_id != other_peer_id)
666 tc->link_array = GNUNET_realloc (tc->link_array, 668 {
667 sizeof (struct OverlayLink) * 669 tc->link_array_size++;
668 tc->link_array_size); 670 tc->link_array = GNUNET_realloc (tc->link_array,
669 offset += end - &data[offset]; 671 sizeof (struct OverlayLink) *
670 make_link (&tc->link_array[tc->link_array_size - 1], peer_id, 672 tc->link_array_size);
671 other_peer_id, tc); 673 offset += end - &data[offset];
674 make_link (&tc->link_array[tc->link_array_size - 1], peer_id,
675 other_peer_id, tc);
676 }
677 else
678 LOG (GNUNET_ERROR_TYPE_WARNING,
679 _("Ignoring to connect peer %u to peer %u\n"), peer_id, other_peer_id);
672 while (('\n' != data[offset]) && ('|' != data[offset]) 680 while (('\n' != data[offset]) && ('|' != data[offset])
673 && (offset < fs)) 681 && (offset < fs))
674 offset++; 682 offset++;
@@ -689,7 +697,7 @@ gen_topo_from_file (struct TopologyContext *tc, const char *filename)
689 if (GNUNET_OK != status) 697 if (GNUNET_OK != status)
690 { 698 {
691 LOG (GNUNET_ERROR_TYPE_WARNING, 699 LOG (GNUNET_ERROR_TYPE_WARNING,
692 "Removing and link data read from the file\n"); 700 "Removing link data read from the file\n");
693 tc->link_array_size = 0; 701 tc->link_array_size = 0;
694 GNUNET_free_non_null (tc->link_array); 702 GNUNET_free_non_null (tc->link_array);
695 tc->link_array = NULL; 703 tc->link_array = NULL;