diff options
author | Supriti Singh <supritisingh08@gmail.com> | 2014-08-17 11:01:09 +0000 |
---|---|---|
committer | Supriti Singh <supritisingh08@gmail.com> | 2014-08-17 11:01:09 +0000 |
commit | 0f74ff197e6d5108c19545a1b407ab965d582137 (patch) | |
tree | 1ab5c8f93227b58e84d8d71f49cac9a5e574d5cc | |
parent | c4f67446e0b6ec727f3aa4dffc8e7a4f1eaac4c3 (diff) | |
download | gnunet-0f74ff197e6d5108c19545a1b407ab965d582137.tar.gz gnunet-0f74ff197e6d5108c19545a1b407ab965d582137.zip |
Added correct routing table entry in trail setup
-rw-r--r-- | src/dht/gnunet-service-xdht_neighbours.c | 39 | ||||
-rw-r--r-- | src/dht/gnunet-service-xdht_routing.c | 1 |
2 files changed, 15 insertions, 25 deletions
diff --git a/src/dht/gnunet-service-xdht_neighbours.c b/src/dht/gnunet-service-xdht_neighbours.c index c5136a504..a780bb8be 100644 --- a/src/dht/gnunet-service-xdht_neighbours.c +++ b/src/dht/gnunet-service-xdht_neighbours.c | |||
@@ -1133,7 +1133,7 @@ GDS_NEIGHBOURS_send_trail_setup_result (struct GNUNET_PeerIdentity querying_peer | |||
1133 | 1133 | ||
1134 | pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize); | 1134 | pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize); |
1135 | pending->importance = 0; | 1135 | pending->importance = 0; |
1136 | pending->timeout = GNUNET_TIME_relative_to_absolute (GET_TIMEOUT); | 1136 | pending->timeout = GNUNET_TIME_relative_to_absolute (GET_TIMEOUT); //TODO: Change it |
1137 | tsrm = (struct PeerTrailSetupResultMessage *) &pending[1]; | 1137 | tsrm = (struct PeerTrailSetupResultMessage *) &pending[1]; |
1138 | pending->msg = &tsrm->header; | 1138 | pending->msg = &tsrm->header; |
1139 | tsrm->header.size = htons (msize); | 1139 | tsrm->header.size = htons (msize); |
@@ -1145,9 +1145,8 @@ GDS_NEIGHBOURS_send_trail_setup_result (struct GNUNET_PeerIdentity querying_peer | |||
1145 | tsrm->ulitmate_destination_finger_value = | 1145 | tsrm->ulitmate_destination_finger_value = |
1146 | GNUNET_htonll (ultimate_destination_finger_value); | 1146 | GNUNET_htonll (ultimate_destination_finger_value); |
1147 | peer_list = (struct GNUNET_PeerIdentity *) &tsrm[1]; | 1147 | peer_list = (struct GNUNET_PeerIdentity *) &tsrm[1]; |
1148 | |||
1149 | memcpy (peer_list, trail_peer_list, trail_length * sizeof (struct GNUNET_PeerIdentity)); | 1148 | memcpy (peer_list, trail_peer_list, trail_length * sizeof (struct GNUNET_PeerIdentity)); |
1150 | 1149 | ||
1151 | /* Send the message to chosen friend. */ | 1150 | /* Send the message to chosen friend. */ |
1152 | GNUNET_CONTAINER_DLL_insert_tail (target_friend->head, target_friend->tail, pending); | 1151 | GNUNET_CONTAINER_DLL_insert_tail (target_friend->head, target_friend->tail, pending); |
1153 | target_friend->pending_count++; | 1152 | target_friend->pending_count++; |
@@ -4133,7 +4132,6 @@ handle_dht_p2p_trail_setup (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
4133 | trail_length = (msize - sizeof (struct PeerTrailSetupMessage))/ | 4132 | trail_length = (msize - sizeof (struct PeerTrailSetupMessage))/ |
4134 | sizeof (struct GNUNET_PeerIdentity); | 4133 | sizeof (struct GNUNET_PeerIdentity); |
4135 | 4134 | ||
4136 | |||
4137 | GNUNET_STATISTICS_update (GDS_stats, | 4135 | GNUNET_STATISTICS_update (GDS_stats, |
4138 | gettext_noop | 4136 | gettext_noop |
4139 | ("# Bytes received from other peers"), msize, | 4137 | ("# Bytes received from other peers"), msize, |
@@ -4206,7 +4204,6 @@ handle_dht_p2p_trail_setup (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
4206 | return GNUNET_OK; | 4204 | return GNUNET_OK; |
4207 | } | 4205 | } |
4208 | 4206 | ||
4209 | GDS_ROUTING_add (trail_id, *peer, my_identity); | ||
4210 | if (trail_length > 0) | 4207 | if (trail_length > 0) |
4211 | target_friend = | 4208 | target_friend = |
4212 | GNUNET_CONTAINER_multipeermap_get (friend_peermap, | 4209 | GNUNET_CONTAINER_multipeermap_get (friend_peermap, |
@@ -4220,13 +4217,15 @@ handle_dht_p2p_trail_setup (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
4220 | GNUNET_break_op (0); | 4217 | GNUNET_break_op (0); |
4221 | return GNUNET_SYSERR; | 4218 | return GNUNET_SYSERR; |
4222 | } | 4219 | } |
4223 | 4220 | ||
4221 | GDS_ROUTING_add (trail_id, target_friend->id, my_identity); | ||
4224 | GDS_NEIGHBOURS_send_trail_setup_result (source, | 4222 | GDS_NEIGHBOURS_send_trail_setup_result (source, |
4225 | my_identity, | 4223 | my_identity, |
4226 | target_friend, trail_length, | 4224 | target_friend, trail_length, |
4227 | trail_peer_list, | 4225 | trail_peer_list, |
4228 | is_predecessor, | 4226 | is_predecessor, |
4229 | final_dest_finger_val,trail_id); | 4227 | final_dest_finger_val,trail_id); |
4228 | |||
4230 | } | 4229 | } |
4231 | else /* I'm not the final destination. */ | 4230 | else /* I'm not the final destination. */ |
4232 | { | 4231 | { |
@@ -4243,13 +4242,14 @@ handle_dht_p2p_trail_setup (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
4243 | memcpy (peer_list, trail_peer_list, | 4242 | memcpy (peer_list, trail_peer_list, |
4244 | trail_length * sizeof (struct GNUNET_PeerIdentity)); | 4243 | trail_length * sizeof (struct GNUNET_PeerIdentity)); |
4245 | peer_list[trail_length] = my_identity; | 4244 | peer_list[trail_length] = my_identity; |
4246 | 4245 | ||
4247 | GDS_NEIGHBOURS_send_trail_setup (source, | 4246 | GDS_NEIGHBOURS_send_trail_setup (source, |
4248 | final_dest_finger_val, | 4247 | final_dest_finger_val, |
4249 | next_peer.best_known_destination, | 4248 | next_peer.best_known_destination, |
4250 | target_friend, trail_length + 1, peer_list, | 4249 | target_friend, trail_length + 1, peer_list, |
4251 | is_predecessor, trail_id, | 4250 | is_predecessor, trail_id, |
4252 | next_peer.trail_id); | 4251 | next_peer.trail_id); |
4252 | GNUNET_free_non_null (peer_list); | ||
4253 | } | 4253 | } |
4254 | else | 4254 | else |
4255 | GDS_NEIGHBOURS_send_trail_setup (source, | 4255 | GDS_NEIGHBOURS_send_trail_setup (source, |
@@ -4295,15 +4295,15 @@ handle_dht_p2p_trail_setup_result(void *cls, const struct GNUNET_PeerIdentity *p | |||
4295 | } | 4295 | } |
4296 | 4296 | ||
4297 | trail_result = (const struct PeerTrailSetupResultMessage *) message; | 4297 | trail_result = (const struct PeerTrailSetupResultMessage *) message; |
4298 | trail_length = (msize - sizeof (struct PeerTrailSetupResultMessage))/ | ||
4299 | sizeof (struct GNUNET_PeerIdentity); | ||
4300 | if ((msize - sizeof (struct PeerTrailSetupResultMessage)) % | 4298 | if ((msize - sizeof (struct PeerTrailSetupResultMessage)) % |
4301 | sizeof (struct GNUNET_PeerIdentity) != 0) | 4299 | sizeof (struct GNUNET_PeerIdentity) != 0) |
4302 | { | 4300 | { |
4303 | GNUNET_break_op (0); | 4301 | GNUNET_break_op (0); |
4304 | return GNUNET_OK; | 4302 | return GNUNET_OK; |
4305 | } | 4303 | } |
4306 | 4304 | trail_length = (msize - sizeof (struct PeerTrailSetupResultMessage))/ | |
4305 | sizeof (struct GNUNET_PeerIdentity); | ||
4306 | |||
4307 | GNUNET_STATISTICS_update (GDS_stats, | 4307 | GNUNET_STATISTICS_update (GDS_stats, |
4308 | gettext_noop | 4308 | gettext_noop |
4309 | ("# Bytes received from other peers"), msize, | 4309 | ("# Bytes received from other peers"), msize, |
@@ -4332,13 +4332,6 @@ handle_dht_p2p_trail_setup_result(void *cls, const struct GNUNET_PeerIdentity *p | |||
4332 | peer)); | 4332 | peer)); |
4333 | } | 4333 | } |
4334 | 4334 | ||
4335 | /* If I am my own finger identity, error. */ | ||
4336 | if (0 == GNUNET_CRYPTO_cmp_peer_identity (&my_identity, &finger_identity)) | ||
4337 | { | ||
4338 | GNUNET_break_op (0); | ||
4339 | return GNUNET_SYSERR; | ||
4340 | } | ||
4341 | |||
4342 | GDS_ROUTING_add (trail_id, my_identity, *peer); | 4335 | GDS_ROUTING_add (trail_id, my_identity, *peer); |
4343 | finger_table_add (finger_identity, trail_peer_list, trail_length, | 4336 | finger_table_add (finger_identity, trail_peer_list, trail_length, |
4344 | is_predecessor, ulitmate_destination_finger_value, trail_id); | 4337 | is_predecessor, ulitmate_destination_finger_value, trail_id); |
@@ -4353,7 +4346,7 @@ handle_dht_p2p_trail_setup_result(void *cls, const struct GNUNET_PeerIdentity *p | |||
4353 | GNUNET_break_op(0); | 4346 | GNUNET_break_op(0); |
4354 | return GNUNET_SYSERR; | 4347 | return GNUNET_SYSERR; |
4355 | } | 4348 | } |
4356 | 4349 | //TODO; return -2. | |
4357 | if ((trail_length + 1) == my_index) | 4350 | if ((trail_length + 1) == my_index) |
4358 | { | 4351 | { |
4359 | DEBUG ("Found twice in trail.\n"); | 4352 | DEBUG ("Found twice in trail.\n"); |
@@ -4361,6 +4354,7 @@ handle_dht_p2p_trail_setup_result(void *cls, const struct GNUNET_PeerIdentity *p | |||
4361 | return GNUNET_SYSERR; | 4354 | return GNUNET_SYSERR; |
4362 | } | 4355 | } |
4363 | 4356 | ||
4357 | //TODO; Refactor code here and above to check if sender peer is correct | ||
4364 | if (my_index == 0) | 4358 | if (my_index == 0) |
4365 | { | 4359 | { |
4366 | if(trail_length > 1) | 4360 | if(trail_length > 1) |
@@ -4392,12 +4386,7 @@ handle_dht_p2p_trail_setup_result(void *cls, const struct GNUNET_PeerIdentity *p | |||
4392 | GNUNET_break_op (0); | 4386 | GNUNET_break_op (0); |
4393 | return GNUNET_SYSERR; | 4387 | return GNUNET_SYSERR; |
4394 | } | 4388 | } |
4395 | if (0 == (GNUNET_CRYPTO_cmp_peer_identity (&(trail_result->querying_peer), | 4389 | |
4396 | &(trail_result->finger_identity)))) | ||
4397 | { | ||
4398 | GNUNET_break_op (0); | ||
4399 | return GNUNET_SYSERR; | ||
4400 | } | ||
4401 | GDS_ROUTING_add (trail_id, next_hop, *peer); | 4390 | GDS_ROUTING_add (trail_id, next_hop, *peer); |
4402 | GDS_NEIGHBOURS_send_trail_setup_result (querying_peer, finger_identity, | 4391 | GDS_NEIGHBOURS_send_trail_setup_result (querying_peer, finger_identity, |
4403 | target_friend, trail_length, trail_peer_list, | 4392 | target_friend, trail_length, trail_peer_list, |
@@ -5799,7 +5788,7 @@ remove_matching_fingers (const struct GNUNET_PeerIdentity *disconnected_peer) | |||
5799 | struct GNUNET_PeerIdentity *next_hop; | 5788 | struct GNUNET_PeerIdentity *next_hop; |
5800 | struct GNUNET_HashCode trail_id; | 5789 | struct GNUNET_HashCode trail_id; |
5801 | /* FIXME: Just for check, remove it afterwards. Here finger is a friend. | 5790 | /* FIXME: Just for check, remove it afterwards. Here finger is a friend. |
5802 | hence trail length should be 0.*/ | 5791 | hence trail length should be 0*/ |
5803 | GNUNET_assert (0 == remove_finger->trail_list[0].trail_length); | 5792 | GNUNET_assert (0 == remove_finger->trail_list[0].trail_length); |
5804 | GNUNET_assert (GNUNET_YES == (remove_finger->trail_list[0].is_present)); | 5793 | GNUNET_assert (GNUNET_YES == (remove_finger->trail_list[0].is_present)); |
5805 | trail_id = remove_finger->trail_list[0].trail_id; | 5794 | trail_id = remove_finger->trail_list[0].trail_id; |
diff --git a/src/dht/gnunet-service-xdht_routing.c b/src/dht/gnunet-service-xdht_routing.c index 841234bf5..5e1516e4c 100644 --- a/src/dht/gnunet-service-xdht_routing.c +++ b/src/dht/gnunet-service-xdht_routing.c | |||
@@ -177,6 +177,7 @@ GDS_ROUTING_remove_trail (const struct GNUNET_HashCode remove_trail_id) | |||
177 | GNUNET_free (remove_entry); | 177 | GNUNET_free (remove_entry); |
178 | return GNUNET_YES; | 178 | return GNUNET_YES; |
179 | } | 179 | } |
180 | |||
180 | return GNUNET_NO; | 181 | return GNUNET_NO; |
181 | } | 182 | } |
182 | 183 | ||