diff options
Diffstat (limited to 'src/dht/gnunet-service-xdht_neighbours.c')
-rw-r--r-- | src/dht/gnunet-service-xdht_neighbours.c | 106 |
1 files changed, 40 insertions, 66 deletions
diff --git a/src/dht/gnunet-service-xdht_neighbours.c b/src/dht/gnunet-service-xdht_neighbours.c index 0b66c38d5..6f080a4d0 100644 --- a/src/dht/gnunet-service-xdht_neighbours.c +++ b/src/dht/gnunet-service-xdht_neighbours.c | |||
@@ -3565,9 +3565,12 @@ handle_dht_p2p_put (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3565 | { | 3565 | { |
3566 | struct PeerPutMessage *put; | 3566 | struct PeerPutMessage *put; |
3567 | struct GNUNET_PeerIdentity *put_path; | 3567 | struct GNUNET_PeerIdentity *put_path; |
3568 | struct GNUNET_PeerIdentity current_best_known_dest; | ||
3568 | struct GNUNET_PeerIdentity best_known_dest; | 3569 | struct GNUNET_PeerIdentity best_known_dest; |
3570 | struct GNUNET_HashCode received_intermediate_trail_id; | ||
3569 | struct GNUNET_HashCode intermediate_trail_id; | 3571 | struct GNUNET_HashCode intermediate_trail_id; |
3570 | struct GNUNET_PeerIdentity *next_hop; | 3572 | struct GNUNET_PeerIdentity *next_hop; |
3573 | struct GNUNET_PeerIdentity *next_routing_hop; | ||
3571 | enum GNUNET_DHT_RouteOption options; | 3574 | enum GNUNET_DHT_RouteOption options; |
3572 | struct GNUNET_HashCode test_key; | 3575 | struct GNUNET_HashCode test_key; |
3573 | void *payload; | 3576 | void *payload; |
@@ -3609,11 +3612,11 @@ handle_dht_p2p_put (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3609 | ("# Bytes received from other peers"), (int64_t) msize, | 3612 | ("# Bytes received from other peers"), (int64_t) msize, |
3610 | GNUNET_NO); | 3613 | GNUNET_NO); |
3611 | 3614 | ||
3612 | best_known_dest = put->best_known_destination; | 3615 | current_best_known_dest = put->best_known_destination; |
3613 | put_path = (struct GNUNET_PeerIdentity *) &put[1]; | 3616 | put_path = (struct GNUNET_PeerIdentity *) &put[1]; |
3614 | payload = &put_path[putlen]; | 3617 | payload = &put_path[putlen]; |
3615 | options = ntohl (put->options); | 3618 | options = ntohl (put->options); |
3616 | intermediate_trail_id = put->intermediate_trail_id; | 3619 | received_intermediate_trail_id = put->intermediate_trail_id; |
3617 | hop_count = ntohl(put->hop_count); | 3620 | hop_count = ntohl(put->hop_count); |
3618 | payload_size = msize - (sizeof (struct PeerPutMessage) + | 3621 | payload_size = msize - (sizeof (struct PeerPutMessage) + |
3619 | putlen * sizeof (struct GNUNET_PeerIdentity)); | 3622 | putlen * sizeof (struct GNUNET_PeerIdentity)); |
@@ -3690,47 +3693,26 @@ handle_dht_p2p_put (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3690 | putlen = 0; | 3693 | putlen = 0; |
3691 | 3694 | ||
3692 | memcpy (&key_value, &(put->key), sizeof (uint64_t)); | 3695 | memcpy (&key_value, &(put->key), sizeof (uint64_t)); |
3693 | if (0 != (GNUNET_CRYPTO_cmp_peer_identity (&best_known_dest, &my_identity))) | 3696 | struct Closest_Peer successor; |
3697 | key_value = GNUNET_ntohll (key_value); | ||
3698 | successor = find_local_best_known_next_hop (key_value, | ||
3699 | GDS_FINGER_TYPE_NON_PREDECESSOR); | ||
3700 | next_hop = GNUNET_new (struct GNUNET_PeerIdentity); | ||
3701 | *next_hop = successor.next_hop; | ||
3702 | intermediate_trail_id = successor.trail_id; | ||
3703 | best_known_dest = successor.best_known_destination; | ||
3704 | |||
3705 | if (0 != (GNUNET_CRYPTO_cmp_peer_identity (¤t_best_known_dest, &my_identity))) | ||
3694 | { | 3706 | { |
3695 | next_hop = GDS_ROUTING_get_next_hop (intermediate_trail_id, | 3707 | next_routing_hop = GDS_ROUTING_get_next_hop (intermediate_trail_id, |
3696 | GDS_ROUTING_SRC_TO_DEST); | 3708 | GDS_ROUTING_SRC_TO_DEST); |
3697 | if (NULL == next_hop) | 3709 | if (NULL != next_routing_hop) |
3698 | { | ||
3699 | DEBUG(" NO ENTRY FOUND IN %s ROUTING TABLE for trail id %s, line", | ||
3700 | GNUNET_i2s(&my_identity), GNUNET_h2s(&intermediate_trail_id), __LINE__); | ||
3701 | GNUNET_STATISTICS_update (GDS_stats, | ||
3702 | gettext_noop ("# Next hop to forward the packet not found " | ||
3703 | "trail setup request, packet dropped."), | ||
3704 | 1, GNUNET_NO); | ||
3705 | |||
3706 | GNUNET_break_op (0); | ||
3707 | //Fixme: even after circle is compelte, it fails | ||
3708 | //FIXME: Adding put here,only to ensure that process does not hang. but | ||
3709 | // should not be here. fix the logic. | ||
3710 | GDS_DATACACHE_handle_put (GNUNET_TIME_absolute_ntoh (put->expiration_time), | ||
3711 | &(put->key),putlen, pp, ntohl (put->block_type), | ||
3712 | payload_size, payload); | ||
3713 | return GNUNET_OK; | ||
3714 | } | ||
3715 | else | ||
3716 | { | 3710 | { |
3717 | GNUNET_assert (0 != GNUNET_CRYPTO_cmp_peer_identity (&my_identity, | 3711 | next_hop = next_routing_hop; |
3718 | next_hop)); | 3712 | intermediate_trail_id = received_intermediate_trail_id; |
3713 | best_known_dest = current_best_known_dest; | ||
3719 | } | 3714 | } |
3720 | } | 3715 | } |
3721 | else | ||
3722 | { | ||
3723 | struct Closest_Peer successor; | ||
3724 | key_value = GNUNET_ntohll (key_value); | ||
3725 | successor = find_local_best_known_next_hop (key_value, | ||
3726 | GDS_FINGER_TYPE_NON_PREDECESSOR); | ||
3727 | next_hop = GNUNET_new (struct GNUNET_PeerIdentity); | ||
3728 | *next_hop = successor.next_hop; | ||
3729 | intermediate_trail_id = successor.trail_id; | ||
3730 | best_known_dest = successor.best_known_destination; | ||
3731 | } | ||
3732 | |||
3733 | |||
3734 | 3716 | ||
3735 | GDS_CLIENTS_process_put (options, | 3717 | GDS_CLIENTS_process_put (options, |
3736 | ntohl (put->block_type), | 3718 | ntohl (put->block_type), |
@@ -3781,8 +3763,12 @@ handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3781 | const struct PeerGetMessage *get; | 3763 | const struct PeerGetMessage *get; |
3782 | const struct GNUNET_PeerIdentity *get_path; | 3764 | const struct GNUNET_PeerIdentity *get_path; |
3783 | struct GNUNET_PeerIdentity best_known_dest; | 3765 | struct GNUNET_PeerIdentity best_known_dest; |
3766 | struct GNUNET_PeerIdentity current_best_known_dest; | ||
3784 | struct GNUNET_HashCode intermediate_trail_id; | 3767 | struct GNUNET_HashCode intermediate_trail_id; |
3768 | struct GNUNET_HashCode received_intermediate_trail_id; | ||
3769 | struct Closest_Peer successor; | ||
3785 | struct GNUNET_PeerIdentity *next_hop; | 3770 | struct GNUNET_PeerIdentity *next_hop; |
3771 | struct GNUNET_PeerIdentity *next_routing_hop; | ||
3786 | uint32_t get_length; | 3772 | uint32_t get_length; |
3787 | uint64_t key_value; | 3773 | uint64_t key_value; |
3788 | uint32_t hop_count; | 3774 | uint32_t hop_count; |
@@ -3805,8 +3791,8 @@ handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3805 | 3791 | ||
3806 | get = (const struct PeerGetMessage *)message; | 3792 | get = (const struct PeerGetMessage *)message; |
3807 | get_length = ntohl (get->get_path_length); | 3793 | get_length = ntohl (get->get_path_length); |
3808 | best_known_dest = get->best_known_destination; | 3794 | current_best_known_dest = get->best_known_destination; |
3809 | intermediate_trail_id = get->intermediate_trail_id; | 3795 | received_intermediate_trail_id = get->intermediate_trail_id; |
3810 | get_path = (const struct GNUNET_PeerIdentity *)&get[1]; | 3796 | get_path = (const struct GNUNET_PeerIdentity *)&get[1]; |
3811 | hop_count = get->hop_count; | 3797 | hop_count = get->hop_count; |
3812 | hop_count++; | 3798 | hop_count++; |
@@ -3849,38 +3835,26 @@ handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3849 | get->desired_replication_level, get->get_path_length, | 3835 | get->desired_replication_level, get->get_path_length, |
3850 | gp, &get->key); | 3836 | gp, &get->key); |
3851 | 3837 | ||
3838 | |||
3839 | successor = find_local_best_known_next_hop (key_value, | ||
3840 | GDS_FINGER_TYPE_NON_PREDECESSOR); | ||
3841 | next_hop = GNUNET_new (struct GNUNET_PeerIdentity); | ||
3842 | *next_hop = successor.next_hop; | ||
3843 | best_known_dest = successor.best_known_destination; | ||
3844 | intermediate_trail_id = successor.trail_id; | ||
3852 | /* I am not the final destination. I am part of trail to reach final dest. */ | 3845 | /* I am not the final destination. I am part of trail to reach final dest. */ |
3853 | if (0 != (GNUNET_CRYPTO_cmp_peer_identity (&best_known_dest, &my_identity))) | 3846 | if (0 != (GNUNET_CRYPTO_cmp_peer_identity (¤t_best_known_dest, &my_identity))) |
3854 | { | 3847 | { |
3855 | next_hop = GDS_ROUTING_get_next_hop (intermediate_trail_id, | 3848 | next_routing_hop = GDS_ROUTING_get_next_hop (received_intermediate_trail_id, |
3856 | GDS_ROUTING_SRC_TO_DEST); | 3849 | GDS_ROUTING_SRC_TO_DEST); |
3857 | if (NULL == next_hop) | 3850 | if (NULL != next_routing_hop) |
3858 | { | 3851 | { |
3859 | DEBUG(" NO ENTRY FOUND IN %s ROUTING TABLE for trail id %s, line", | 3852 | next_hop = next_routing_hop; |
3860 | GNUNET_i2s(&my_identity), GNUNET_h2s(&intermediate_trail_id), __LINE__); | 3853 | best_known_dest = current_best_known_dest; |
3861 | GNUNET_STATISTICS_update (GDS_stats, | 3854 | intermediate_trail_id = received_intermediate_trail_id; |
3862 | gettext_noop ("# Next hop to forward the packet not found " | ||
3863 | "GET request, packet dropped."), | ||
3864 | 1, GNUNET_NO); | ||
3865 | GNUNET_break (0); | ||
3866 | /* We are not able to proceed further*/ | ||
3867 | GDS_DATACACHE_handle_get (&(get->key),(get->block_type), NULL, 0, NULL, 0, | ||
3868 | get_length, gp, &gp[get_length - 2], | ||
3869 | &my_identity); | ||
3870 | return GNUNET_OK; | ||
3871 | } | 3855 | } |
3872 | } | 3856 | } |
3873 | else | 3857 | |
3874 | { | ||
3875 | struct Closest_Peer successor; | ||
3876 | |||
3877 | successor = find_local_best_known_next_hop (key_value, | ||
3878 | GDS_FINGER_TYPE_NON_PREDECESSOR); | ||
3879 | next_hop = GNUNET_new (struct GNUNET_PeerIdentity); | ||
3880 | *next_hop = successor.next_hop; | ||
3881 | best_known_dest = successor.best_known_destination; | ||
3882 | intermediate_trail_id = successor.trail_id; | ||
3883 | } | ||
3884 | 3858 | ||
3885 | /* I am the final destination. */ | 3859 | /* I am the final destination. */ |
3886 | if (0 == GNUNET_CRYPTO_cmp_peer_identity(&my_identity, &best_known_dest)) | 3860 | if (0 == GNUNET_CRYPTO_cmp_peer_identity(&my_identity, &best_known_dest)) |