aboutsummaryrefslogtreecommitdiff
path: root/src/dht/gnunet-service-xdht_neighbours.c
diff options
context:
space:
mode:
authorSupriti Singh <supritisingh08@gmail.com>2014-06-27 15:01:19 +0000
committerSupriti Singh <supritisingh08@gmail.com>2014-06-27 15:01:19 +0000
commitbab8e79cae5794f331cd06f0366b081228e364eb (patch)
treeaecf0336347f2ce336ae4a41452f85293d7fce8e /src/dht/gnunet-service-xdht_neighbours.c
parent1918912e0de49f876e09dfc0fa3535c909dc5a44 (diff)
downloadgnunet-bab8e79cae5794f331cd06f0366b081228e364eb.tar.gz
gnunet-bab8e79cae5794f331cd06f0366b081228e364eb.zip
xvine: bug fixes
Diffstat (limited to 'src/dht/gnunet-service-xdht_neighbours.c')
-rw-r--r--src/dht/gnunet-service-xdht_neighbours.c78
1 files changed, 40 insertions, 38 deletions
diff --git a/src/dht/gnunet-service-xdht_neighbours.c b/src/dht/gnunet-service-xdht_neighbours.c
index 9dc4f0f74..d667c829b 100644
--- a/src/dht/gnunet-service-xdht_neighbours.c
+++ b/src/dht/gnunet-service-xdht_neighbours.c
@@ -1081,7 +1081,7 @@ GDS_NEIGHBOURS_send_trail_setup (struct GNUNET_PeerIdentity source_peer,
1081 peer_list = (struct GNUNET_PeerIdentity *) &tsm[1]; 1081 peer_list = (struct GNUNET_PeerIdentity *) &tsm[1];
1082 memcpy (peer_list, trail_peer_list, trail_length * sizeof(struct GNUNET_PeerIdentity)); 1082 memcpy (peer_list, trail_peer_list, trail_length * sizeof(struct GNUNET_PeerIdentity));
1083 } 1083 }
1084 1084
1085 GNUNET_CONTAINER_DLL_insert_tail (target_friend->head, target_friend->tail, pending); 1085 GNUNET_CONTAINER_DLL_insert_tail (target_friend->head, target_friend->tail, pending);
1086 target_friend->pending_count++; 1086 target_friend->pending_count++;
1087 process_friend_queue (target_friend); 1087 process_friend_queue (target_friend);
@@ -2138,7 +2138,7 @@ GDS_NEIGHBOURS_send_put (const struct GNUNET_HashCode *key,
2138 put_path_length = 0; 2138 put_path_length = 0;
2139 msize = data_size + sizeof (struct PeerPutMessage); 2139 msize = data_size + sizeof (struct PeerPutMessage);
2140 } 2140 }
2141 2141
2142 if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) 2142 if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
2143 { 2143 {
2144 GNUNET_break (0); 2144 GNUNET_break (0);
@@ -2357,7 +2357,7 @@ GDS_NEIGHBOURS_send_get_result (const struct GNUNET_HashCode *key,
2357 msize = (put_path_length + get_path_length )* sizeof (struct GNUNET_PeerIdentity) + 2357 msize = (put_path_length + get_path_length )* sizeof (struct GNUNET_PeerIdentity) +
2358 data_size + 2358 data_size +
2359 sizeof (struct PeerGetResultMessage); 2359 sizeof (struct PeerGetResultMessage);
2360 2360
2361 if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) 2361 if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
2362 { 2362 {
2363 GNUNET_break (0); 2363 GNUNET_break (0);
@@ -2614,7 +2614,7 @@ select_and_replace_trail (struct FingerInfo *existing_finger,
2614 2614
2615 /* Send trail teardown message across the replaced trail. */ 2615 /* Send trail teardown message across the replaced trail. */
2616 struct Trail *replace_trail = &existing_finger->trail_list[largest_trail_index]; 2616 struct Trail *replace_trail = &existing_finger->trail_list[largest_trail_index];
2617 GDS_ROUTING_remove_trail (replace_trail->trail_id); 2617 GNUNET_assert (GNUNET_YES == GDS_ROUTING_remove_trail (replace_trail->trail_id));
2618 GDS_NEIGHBOURS_send_trail_teardown (replace_trail->trail_id, 2618 GDS_NEIGHBOURS_send_trail_teardown (replace_trail->trail_id,
2619 GDS_ROUTING_SRC_TO_DEST, 2619 GDS_ROUTING_SRC_TO_DEST,
2620 replace_trail->trail_head->peer); 2620 replace_trail->trail_head->peer);
@@ -2776,16 +2776,17 @@ send_trail_teardown (struct FingerInfo *finger,
2776 GNUNET_CONTAINER_multipeermap_get (friend_peermap, 2776 GNUNET_CONTAINER_multipeermap_get (friend_peermap,
2777 &trail->trail_head->peer))); 2777 &trail->trail_head->peer)));
2778 else 2778 else
2779 {
2779 GNUNET_assert (NULL != (friend = 2780 GNUNET_assert (NULL != (friend =
2780 GNUNET_CONTAINER_multipeermap_get (friend_peermap, 2781 GNUNET_CONTAINER_multipeermap_get (friend_peermap,
2781 &finger->finger_identity))); 2782 &finger->finger_identity)));
2782 2783 }
2783 GNUNET_assert (0 == GNUNET_CRYPTO_cmp_peer_identity (next_hop, &friend->id)); 2784 GNUNET_assert (0 == GNUNET_CRYPTO_cmp_peer_identity (next_hop, &friend->id));
2784 GDS_ROUTING_remove_trail (trail->trail_id); 2785 GNUNET_assert (GNUNET_YES == GDS_ROUTING_remove_trail (trail->trail_id));
2785 friend->trails_count--; 2786 friend->trails_count--;
2786 GDS_NEIGHBOURS_send_trail_teardown (trail->trail_id, 2787 GDS_NEIGHBOURS_send_trail_teardown (trail->trail_id,
2787 GDS_ROUTING_SRC_TO_DEST, 2788 GDS_ROUTING_SRC_TO_DEST,
2788 trail->trail_head->peer); 2789 friend->id);
2789} 2790}
2790 2791
2791 2792
@@ -3029,6 +3030,9 @@ scan_and_compress_trail (struct GNUNET_PeerIdentity finger_identity,
3029 (target_friend = 3030 (target_friend =
3030 GNUNET_CONTAINER_multipeermap_get (friend_peermap, 3031 GNUNET_CONTAINER_multipeermap_get (friend_peermap,
3031 &trail[0]))); 3032 &trail[0])));
3033 GNUNET_assert (NULL !=
3034 (GNUNET_CONTAINER_multipeermap_get (friend_peermap,
3035 &trail[i])));
3032 GDS_ROUTING_update_trail_next_hop (trail_id, trail[i]); 3036 GDS_ROUTING_update_trail_next_hop (trail_id, trail[i]);
3033 GDS_NEIGHBOURS_send_trail_compression (my_identity, 3037 GDS_NEIGHBOURS_send_trail_compression (my_identity,
3034 trail_id, trail[i], 3038 trail_id, trail[i],
@@ -3796,6 +3800,9 @@ get_local_best_known_next_hop (uint64_t final_dest_finger_value,
3796 /* Are we just a part of a trail towards a finger (current_destination)? */ 3800 /* Are we just a part of a trail towards a finger (current_destination)? */
3797 if (0 != (GNUNET_CRYPTO_cmp_peer_identity (&my_identity, current_dest))) 3801 if (0 != (GNUNET_CRYPTO_cmp_peer_identity (&my_identity, current_dest)))
3798 { 3802 {
3803 struct GNUNET_PeerIdentity print_peer;
3804 memcpy(&print_peer, current_dest, sizeof (struct GNUNET_PeerIdentity));
3805
3799 struct GNUNET_PeerIdentity *closest_peer; 3806 struct GNUNET_PeerIdentity *closest_peer;
3800 3807
3801 /* Select best successor among one found locally and current_destination 3808 /* Select best successor among one found locally and current_destination
@@ -3812,7 +3819,7 @@ get_local_best_known_next_hop (uint64_t final_dest_finger_value,
3812 { 3819 {
3813 struct GNUNET_PeerIdentity *next_hop; 3820 struct GNUNET_PeerIdentity *next_hop;
3814 next_hop = GDS_ROUTING_get_next_hop (intermediate_trail_id, 3821 next_hop = GDS_ROUTING_get_next_hop (intermediate_trail_id,
3815 GDS_ROUTING_SRC_TO_DEST); 3822 GDS_ROUTING_SRC_TO_DEST);
3816 /* FIXME: Here we found next_hop NULL from routing table, but we still 3823 /* FIXME: Here we found next_hop NULL from routing table, but we still
3817 * have a next_hop from find_successor should we not break and choose that 3824 * have a next_hop from find_successor should we not break and choose that
3818 * next_hop. */ 3825 * next_hop. */
@@ -4804,13 +4811,7 @@ handle_dht_p2p_notify_new_successor(void *cls,
4804 /* I am the new_successor to source_peer. */ 4811 /* I am the new_successor to source_peer. */
4805 if ( 0 == GNUNET_CRYPTO_cmp_peer_identity (&my_identity, &new_successor)) 4812 if ( 0 == GNUNET_CRYPTO_cmp_peer_identity (&my_identity, &new_successor))
4806 { 4813 {
4807 /* Add an entry in routing table only if new predecessor is not a friend. */ 4814 GDS_ROUTING_add (trail_id, *peer, my_identity);
4808 if (NULL == GNUNET_CONTAINER_multipeermap_get(friend_peermap, &source))
4809 {
4810 /* FIXME: check that you always add trail entry even if your finger is
4811 friend. */
4812 GDS_ROUTING_add (trail_id, *peer, my_identity);
4813 }
4814 compare_and_update_predecessor (source, trail, trail_length); 4815 compare_and_update_predecessor (source, trail, trail_length);
4815 return GNUNET_OK; 4816 return GNUNET_OK;
4816 } 4817 }
@@ -4826,8 +4827,7 @@ handle_dht_p2p_notify_new_successor(void *cls,
4826 next_hop = new_successor; 4827 next_hop = new_successor;
4827 else 4828 else
4828 next_hop = trail[my_index + 1]; 4829 next_hop = trail[my_index + 1];
4829 /* FIXME: check that you always add trail entry even if your finger is 4830
4830 friend. */
4831 /* Add an entry in routing table for trail from source to its new successor. */ 4831 /* Add an entry in routing table for trail from source to its new successor. */
4832 GNUNET_assert (GNUNET_OK == GDS_ROUTING_add (trail_id, *peer, next_hop)); 4832 GNUNET_assert (GNUNET_OK == GDS_ROUTING_add (trail_id, *peer, next_hop));
4833 GNUNET_assert (NULL != 4833 GNUNET_assert (NULL !=
@@ -4968,15 +4968,9 @@ handle_dht_p2p_trail_setup_rejection (void *cls,
4968 { 4968 {
4969 /* Add an entry in routing table only 4969 /* Add an entry in routing table only
4970 * 1. If I am not the original source which sent the request for trail setup 4970 * 1. If I am not the original source which sent the request for trail setup
4971 * 2. If trail length > 0. 4971 FIXME: check that you always add trail entry even if your finger is
4972 * NOTE: In case trail length > 0 and source is my friend, then also I add
4973 * an entry in routing table,as we will send a trail compression message
4974 * later.
4975 */
4976 /* FIXME: check that you always add trail entry even if your finger is
4977 friend. */ 4972 friend. */
4978 if ((0 != GNUNET_CRYPTO_cmp_peer_identity (&source, &my_identity)) || 4973 if (0 != GNUNET_CRYPTO_cmp_peer_identity (&source, &my_identity))
4979 (trail_length > 0))
4980 GNUNET_assert (GNUNET_YES == GDS_ROUTING_add (trail_id, *peer, my_identity)); 4974 GNUNET_assert (GNUNET_YES == GDS_ROUTING_add (trail_id, *peer, my_identity));
4981 4975
4982 if (0 == trail_length) 4976 if (0 == trail_length)
@@ -5054,9 +5048,11 @@ handle_dht_p2p_trail_compression (void *cls, const struct GNUNET_PeerIdentity *p
5054 if (0 == (GNUNET_CRYPTO_cmp_peer_identity (&(trail_compression->new_first_friend), 5048 if (0 == (GNUNET_CRYPTO_cmp_peer_identity (&(trail_compression->new_first_friend),
5055 &my_identity))) 5049 &my_identity)))
5056 { 5050 {
5051 GNUNET_assert (NULL != GNUNET_CONTAINER_multipeermap_get (friend_peermap, &trail_compression->source_peer));
5057 /* Update your prev hop to source of this message. */ 5052 /* Update your prev hop to source of this message. */
5058 GDS_ROUTING_update_trail_prev_hop (trail_id, 5053 GNUNET_assert (GNUNET_SYSERR !=
5059 trail_compression->source_peer); 5054 (GDS_ROUTING_update_trail_prev_hop (trail_id,
5055 trail_compression->source_peer)));
5060 return GNUNET_OK; 5056 return GNUNET_OK;
5061 } 5057 }
5062 //GDS_ROUTING_test_print(); 5058 //GDS_ROUTING_test_print();
@@ -5094,9 +5090,9 @@ handle_dht_p2p_trail_teardown (void *cls, const struct GNUNET_PeerIdentity *peer
5094 const struct PeerTrailTearDownMessage *trail_teardown; 5090 const struct PeerTrailTearDownMessage *trail_teardown;
5095 enum GDS_ROUTING_trail_direction trail_direction; 5091 enum GDS_ROUTING_trail_direction trail_direction;
5096 struct GNUNET_HashCode trail_id; 5092 struct GNUNET_HashCode trail_id;
5097 //struct GNUNET_PeerIdentity *prev_hop;
5098 struct GNUNET_PeerIdentity *next_hop; 5093 struct GNUNET_PeerIdentity *next_hop;
5099 size_t msize; 5094 size_t msize;
5095
5100 msize = ntohs (message->size); 5096 msize = ntohs (message->size);
5101 5097
5102 /* Here we pass only the trail id. */ 5098 /* Here we pass only the trail id. */
@@ -5122,23 +5118,29 @@ handle_dht_p2p_trail_teardown (void *cls, const struct GNUNET_PeerIdentity *peer
5122 return GNUNET_SYSERR; 5118 return GNUNET_SYSERR;
5123 } 5119 }
5124#endif 5120#endif
5125 5121
5126 next_hop = GDS_ROUTING_get_next_hop (trail_id, trail_direction); 5122 next_hop = GDS_ROUTING_get_next_hop (trail_id, trail_direction);
5123
5127 if (NULL == next_hop) 5124 if (NULL == next_hop)
5128 { 5125 {
5129 GNUNET_break (0); 5126 GNUNET_break (0);
5130 return GNUNET_SYSERR; 5127 return GNUNET_SYSERR;
5131 } 5128 }
5132 5129
5133 GNUNET_assert (GNUNET_YES == GDS_ROUTING_remove_trail (trail_id)); 5130 GNUNET_assert (GNUNET_YES == GDS_ROUTING_remove_trail (trail_id));
5134 5131
5135 /* If next_hop is my_identity, it means I am the final destination. */ 5132 /* I am the next hop, which means I am the final destination. */
5136 if (0 == GNUNET_CRYPTO_cmp_peer_identity (next_hop, &my_identity)) 5133 if (0 == GNUNET_CRYPTO_cmp_peer_identity (next_hop, &my_identity))
5134 {
5137 return GNUNET_OK; 5135 return GNUNET_OK;
5136 }
5137 else
5138 {
5139 /* If not final destination, then send a trail teardown message to next hop.*/
5140 GNUNET_assert (NULL != GNUNET_CONTAINER_multipeermap_get (friend_peermap, next_hop));
5141 GDS_NEIGHBOURS_send_trail_teardown (trail_id, trail_direction, *next_hop);
5142 }
5138 5143
5139 /* If not final destination, then send a trail teardown message to next hop.*/
5140 GDS_NEIGHBOURS_send_trail_teardown (trail_id, trail_direction, *next_hop);
5141 //GNUNET_free_non_null (next_hop);
5142 return GNUNET_OK; 5144 return GNUNET_OK;
5143} 5145}
5144 5146
@@ -5202,7 +5204,7 @@ handle_dht_p2p_add_trail (void *cls, const struct GNUNET_PeerIdentity *peer,
5202 5204
5203 /* Get my location in the trail. */ 5205 /* Get my location in the trail. */
5204 my_index = search_my_index (trail, trail_length); 5206 my_index = search_my_index (trail, trail_length);
5205 if (GNUNET_SYSERR == my_index) 5207 if (-1 == my_index)
5206 { 5208 {
5207 GNUNET_break_op (0); 5209 GNUNET_break_op (0);
5208 return GNUNET_SYSERR; 5210 return GNUNET_SYSERR;
@@ -5279,7 +5281,7 @@ remove_matching_trails (const struct GNUNET_PeerIdentity *disconnected_friend,
5279 GNUNET_assert (0 == (GNUNET_CRYPTO_cmp_peer_identity (disconnected_friend, 5281 GNUNET_assert (0 == (GNUNET_CRYPTO_cmp_peer_identity (disconnected_friend,
5280 next_hop))); 5282 next_hop)));
5281 matching_trails_count++; 5283 matching_trails_count++;
5282 GDS_ROUTING_remove_trail (trail->trail_id); 5284 GNUNET_assert (GNUNET_YES == GDS_ROUTING_remove_trail (trail->trail_id));
5283 5285
5284 free_trail (trail); 5286 free_trail (trail);
5285 trail->is_present = GNUNET_NO; 5287 trail->is_present = GNUNET_NO;
@@ -5345,7 +5347,7 @@ remove_matching_fingers (const struct GNUNET_PeerIdentity *disconnected_peer)
5345 GNUNET_assert (0 == 5347 GNUNET_assert (0 ==
5346 (GNUNET_CRYPTO_cmp_peer_identity (next_hop, 5348 (GNUNET_CRYPTO_cmp_peer_identity (next_hop,
5347 &remove_finger->finger_identity))); 5349 &remove_finger->finger_identity)));
5348 GDS_ROUTING_remove_trail (trail_id); 5350 GNUNET_assert (GNUNET_YES == GDS_ROUTING_remove_trail (trail_id));
5349 remove_friend = GNUNET_CONTAINER_multipeermap_get (friend_peermap, 5351 remove_friend = GNUNET_CONTAINER_multipeermap_get (friend_peermap,
5350 disconnected_peer); 5352 disconnected_peer);
5351 remove_friend->trails_count--; 5353 remove_friend->trails_count--;
@@ -5400,7 +5402,7 @@ handle_core_disconnect (void *cls,
5400 /* Remove any trail from routing table of which peer is a part of. This function 5402 /* Remove any trail from routing table of which peer is a part of. This function
5401 * internally sends a trail teardown message in the direction of which 5403 * internally sends a trail teardown message in the direction of which
5402 * disconnected peer is not part of. */ 5404 * disconnected peer is not part of. */
5403 GDS_ROUTING_remove_trail_by_peer (peer); 5405 GNUNET_assert (GNUNET_SYSERR != GDS_ROUTING_remove_trail_by_peer (peer));
5404 5406
5405 GNUNET_assert (0 == remove_friend->trails_count); 5407 GNUNET_assert (0 == remove_friend->trails_count);
5406 5408