aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSupriti Singh <supritisingh08@gmail.com>2014-08-20 06:37:41 +0000
committerSupriti Singh <supritisingh08@gmail.com>2014-08-20 06:37:41 +0000
commit72897db4838c7fc21818ebeaa20fc6a5b817bdcb (patch)
tree87a1545432a3cbfeb2e41567320b2de497ca5e60 /src
parent491e6b15d64983d8885067d3ef7bcb354d9555c6 (diff)
downloadgnunet-72897db4838c7fc21818ebeaa20fc6a5b817bdcb.tar.gz
gnunet-72897db4838c7fc21818ebeaa20fc6a5b817bdcb.zip
xvine:fixes
Diffstat (limited to 'src')
-rw-r--r--src/dht/gnunet-service-xdht_neighbours.c100
1 files changed, 61 insertions, 39 deletions
diff --git a/src/dht/gnunet-service-xdht_neighbours.c b/src/dht/gnunet-service-xdht_neighbours.c
index 3257c63ac..f42819aa5 100644
--- a/src/dht/gnunet-service-xdht_neighbours.c
+++ b/src/dht/gnunet-service-xdht_neighbours.c
@@ -3644,7 +3644,27 @@ handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer,
3644 3644
3645 memcpy (&key_value, &(get->key), sizeof (uint64_t)); 3645 memcpy (&key_value, &(get->key), sizeof (uint64_t));
3646 key_value = GNUNET_ntohll (key_value); 3646 key_value = GNUNET_ntohll (key_value);
3647 3647
3648 /* Check if you are already a part of get path. */
3649 unsigned int i;
3650 for (i = 0; i < get_length; i++)
3651 {
3652 if (0 == GNUNET_CRYPTO_cmp_peer_identity (&my_identity, &get_path[i]))
3653 {
3654 get_length = i;
3655 break;
3656 }
3657 }
3658
3659 /* Add yourself in the get path. */
3660 struct GNUNET_PeerIdentity gp[get_length + 1];
3661 memcpy (gp, get_path, get_length * sizeof (struct GNUNET_PeerIdentity));
3662 gp[get_length] = my_identity;
3663 get_length = get_length + 1;
3664 GDS_CLIENTS_process_get (get->options, get->block_type,get->hop_count,
3665 get->desired_replication_level, get->get_path_length,
3666 gp, &get->key);
3667
3648 /* I am not the final destination. I am part of trail to reach final dest. */ 3668 /* I am not the final destination. I am part of trail to reach final dest. */
3649 if (0 != (GNUNET_CRYPTO_cmp_peer_identity (&best_known_dest, &my_identity))) 3669 if (0 != (GNUNET_CRYPTO_cmp_peer_identity (&best_known_dest, &my_identity)))
3650 { 3670 {
@@ -3659,6 +3679,10 @@ handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer,
3659 "GET request, packet dropped."), 3679 "GET request, packet dropped."),
3660 1, GNUNET_NO); 3680 1, GNUNET_NO);
3661 GNUNET_break (0); 3681 GNUNET_break (0);
3682 /* We are not able to proceed further*/
3683 GDS_DATACACHE_handle_get (&(get->key),(get->block_type), NULL, 0, NULL, 0,
3684 get_length, gp, &gp[get_length - 2],
3685 &my_identity);
3662 return GNUNET_OK; 3686 return GNUNET_OK;
3663 } 3687 }
3664 } 3688 }
@@ -3672,27 +3696,7 @@ handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer,
3672 best_known_dest = successor.best_known_destination; 3696 best_known_dest = successor.best_known_destination;
3673 intermediate_trail_id = successor.trail_id; 3697 intermediate_trail_id = successor.trail_id;
3674 } 3698 }
3675 3699
3676 /* Check if you are already a part of get path. */
3677 unsigned int i;
3678 for (i = 0; i < get_length; i++)
3679 {
3680 if (0 == GNUNET_CRYPTO_cmp_peer_identity (&my_identity, &get_path[i]))
3681 {
3682 get_length = i;
3683 break;
3684 }
3685 }
3686
3687 /* Add yourself in the get path. */
3688 struct GNUNET_PeerIdentity gp[get_length + 1];
3689 memcpy (gp, get_path, get_length * sizeof (struct GNUNET_PeerIdentity));
3690 gp[get_length] = my_identity;
3691 get_length = get_length + 1;
3692 GDS_CLIENTS_process_get (get->options, get->block_type,get->hop_count,
3693 get->desired_replication_level, get->get_path_length,
3694 gp, &get->key);
3695
3696 /* I am the final destination. */ 3700 /* I am the final destination. */
3697 if (0 == GNUNET_CRYPTO_cmp_peer_identity(&my_identity, &best_known_dest)) 3701 if (0 == GNUNET_CRYPTO_cmp_peer_identity(&my_identity, &best_known_dest))
3698 { 3702 {
@@ -5095,14 +5099,14 @@ handle_dht_p2p_trail_setup_rejection (void *cls,
5095 } 5099 }
5096 5100
5097 trail_rejection = (const struct PeerTrailRejectionMessage *) message; 5101 trail_rejection = (const struct PeerTrailRejectionMessage *) message;
5098 trail_length = (msize - sizeof (struct PeerTrailRejectionMessage))/
5099 sizeof (struct GNUNET_PeerIdentity);
5100 if ((msize - sizeof (struct PeerTrailRejectionMessage)) % 5102 if ((msize - sizeof (struct PeerTrailRejectionMessage)) %
5101 sizeof (struct GNUNET_PeerIdentity) != 0) 5103 sizeof (struct GNUNET_PeerIdentity) != 0)
5102 { 5104 {
5103 GNUNET_break_op (0); 5105 GNUNET_break_op (0);
5104 return GNUNET_OK; 5106 return GNUNET_OK;
5105 } 5107 }
5108 trail_length = (msize - sizeof (struct PeerTrailRejectionMessage))/
5109 sizeof (struct GNUNET_PeerIdentity);
5106 5110
5107 GNUNET_STATISTICS_update (GDS_stats, 5111 GNUNET_STATISTICS_update (GDS_stats,
5108 gettext_noop 5112 gettext_noop
@@ -5118,9 +5122,13 @@ handle_dht_p2p_trail_setup_rejection (void *cls,
5118 GNUNET_ntohll (trail_rejection->ultimate_destination_finger_value); 5122 GNUNET_ntohll (trail_rejection->ultimate_destination_finger_value);
5119 5123
5120 /* First set the congestion time of the friend that sent you this message. */ 5124 /* First set the congestion time of the friend that sent you this message. */
5121 GNUNET_assert (NULL != 5125 target_friend = GNUNET_CONTAINER_multipeermap_get (friend_peermap, peer);
5122 (target_friend = 5126 if (NULL == target_friend)
5123 GNUNET_CONTAINER_multipeermap_get (friend_peermap, peer))); 5127 {
5128 DEBUG ("\nLINE = %d ,No friend found.",__LINE__);
5129 GNUNET_break(0);
5130 return GNUNET_OK;
5131 }
5124 target_friend->congestion_timestamp = 5132 target_friend->congestion_timestamp =
5125 GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get(), 5133 GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get(),
5126 congestion_timeout); 5134 congestion_timeout);
@@ -5137,10 +5145,15 @@ handle_dht_p2p_trail_setup_rejection (void *cls,
5137 next_peer = source; 5145 next_peer = source;
5138 else 5146 else
5139 next_peer = trail_peer_list[trail_length-1]; 5147 next_peer = trail_peer_list[trail_length-1];
5140 5148
5141 GNUNET_assert (NULL != 5149 target_friend =
5142 (target_friend = 5150 GNUNET_CONTAINER_multipeermap_get (friend_peermap, &next_peer);
5143 GNUNET_CONTAINER_multipeermap_get (friend_peermap, &next_peer))); 5151 if (NULL == target_friend)
5152 {
5153 DEBUG ("\nLINE = %d ,No friend found.",__LINE__);
5154 GNUNET_break(0);
5155 return GNUNET_OK;
5156 }
5144 GDS_NEIGHBOURS_send_trail_rejection (source, 5157 GDS_NEIGHBOURS_send_trail_rejection (source,
5145 ultimate_destination_finger_value, 5158 ultimate_destination_finger_value,
5146 my_identity, is_predecessor, 5159 my_identity, is_predecessor,
@@ -5160,11 +5173,15 @@ handle_dht_p2p_trail_setup_rejection (void *cls,
5160 next_peer = source; 5173 next_peer = source;
5161 else 5174 else
5162 next_peer = trail_peer_list[trail_length-1]; 5175 next_peer = trail_peer_list[trail_length-1];
5163 5176
5164 GNUNET_assert (NULL != 5177 target_friend =
5165 (target_friend = 5178 GNUNET_CONTAINER_multipeermap_get (friend_peermap, &next_peer);
5166 GNUNET_CONTAINER_multipeermap_get (friend_peermap, &next_peer))); 5179 if (NULL == target_friend)
5167 5180 {
5181 DEBUG ("\nLINE = %d ,No friend found.",__LINE__);
5182 GNUNET_break(0);
5183 return GNUNET_OK;
5184 }
5168 GDS_NEIGHBOURS_send_trail_setup_result (source, 5185 GDS_NEIGHBOURS_send_trail_setup_result (source,
5169 my_identity, 5186 my_identity,
5170 target_friend, trail_length, 5187 target_friend, trail_length,
@@ -5180,10 +5197,15 @@ handle_dht_p2p_trail_setup_rejection (void *cls,
5180 memcpy (peer_list, trail_peer_list, trail_length * sizeof (struct GNUNET_PeerIdentity)); 5197 memcpy (peer_list, trail_peer_list, trail_length * sizeof (struct GNUNET_PeerIdentity));
5181 peer_list[trail_length] = my_identity; 5198 peer_list[trail_length] = my_identity;
5182 5199
5183 GNUNET_assert (NULL != 5200 target_friend =
5184 (target_friend =
5185 GNUNET_CONTAINER_multipeermap_get (friend_peermap, 5201 GNUNET_CONTAINER_multipeermap_get (friend_peermap,
5186 &successor.next_hop))); 5202 &successor.next_hop);
5203 if (NULL == target_friend)
5204 {
5205 DEBUG ("\nLINE = %d ,No friend found.",__LINE__);
5206 GNUNET_break(0);
5207 return GNUNET_OK;
5208 }
5187 GDS_NEIGHBOURS_send_trail_setup (source, 5209 GDS_NEIGHBOURS_send_trail_setup (source,
5188 ultimate_destination_finger_value, 5210 ultimate_destination_finger_value,
5189 successor.best_known_destination, 5211 successor.best_known_destination,