diff options
author | Supriti Singh <supritisingh08@gmail.com> | 2014-08-10 13:47:29 +0000 |
---|---|---|
committer | Supriti Singh <supritisingh08@gmail.com> | 2014-08-10 13:47:29 +0000 |
commit | 953138deb1873ae40f0a9b2f698342111c583afb (patch) | |
tree | a6d0af008673c3abda8d8383264f855f92f8baa4 /src/dht/gnunet-service-xdht_neighbours.c | |
parent | 130bcc21ae7a0dfda053b4a636b551e64226a41d (diff) | |
download | gnunet-953138deb1873ae40f0a9b2f698342111c583afb.tar.gz gnunet-953138deb1873ae40f0a9b2f698342111c583afb.zip |
Checking if circle is formed.
Diffstat (limited to 'src/dht/gnunet-service-xdht_neighbours.c')
-rw-r--r-- | src/dht/gnunet-service-xdht_neighbours.c | 55 |
1 files changed, 31 insertions, 24 deletions
diff --git a/src/dht/gnunet-service-xdht_neighbours.c b/src/dht/gnunet-service-xdht_neighbours.c index dfd210795..c5a89208f 100644 --- a/src/dht/gnunet-service-xdht_neighbours.c +++ b/src/dht/gnunet-service-xdht_neighbours.c | |||
@@ -2117,8 +2117,10 @@ GDS_NEIGHBOURS_send_put (const struct GNUNET_HashCode *key, | |||
2117 | msize = data_size + sizeof (struct PeerPutMessage); | 2117 | msize = data_size + sizeof (struct PeerPutMessage); |
2118 | } | 2118 | } |
2119 | 2119 | ||
2120 | /* Should it be GNUNET_SERVER_MAX_MESSAGE_SIZE? */ | ||
2120 | if (msize >= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE) | 2121 | if (msize >= GNUNET_CONSTANTS_MAX_ENCRYPTED_MESSAGE_SIZE) |
2121 | { | 2122 | { |
2123 | DEBUG("msize = %lu\n",msize); | ||
2122 | GNUNET_break (0); | 2124 | GNUNET_break (0); |
2123 | return; | 2125 | return; |
2124 | } | 2126 | } |
@@ -2141,6 +2143,7 @@ GDS_NEIGHBOURS_send_put (const struct GNUNET_HashCode *key, | |||
2141 | if (0 == GNUNET_CRYPTO_cmp_peer_identity (&best_known_dest, &my_identity)) | 2143 | if (0 == GNUNET_CRYPTO_cmp_peer_identity (&best_known_dest, &my_identity)) |
2142 | { | 2144 | { |
2143 | /* I am the destination. */ | 2145 | /* I am the destination. */ |
2146 | DEBUG("PUT destination is me = %s,key =%s\n",GNUNET_i2s(&my_identity),GNUNET_h2s(key)); | ||
2144 | GDS_DATACACHE_handle_put (expiration_time, key, 0, NULL, | 2147 | GDS_DATACACHE_handle_put (expiration_time, key, 0, NULL, |
2145 | block_type,data_size,data); | 2148 | block_type,data_size,data); |
2146 | return; | 2149 | return; |
@@ -2233,7 +2236,9 @@ GDS_NEIGHBOURS_send_get (const struct GNUNET_HashCode *key, | |||
2233 | GNUNET_break (0); | 2236 | GNUNET_break (0); |
2234 | return; | 2237 | return; |
2235 | } | 2238 | } |
2236 | 2239 | ||
2240 | DEBUG("GET FOR DATA_SIZE = %lu\n",msize); | ||
2241 | |||
2237 | /* This is the first time we got request from our own client file. */ | 2242 | /* This is the first time we got request from our own client file. */ |
2238 | if (NULL == target_peer) | 2243 | if (NULL == target_peer) |
2239 | { | 2244 | { |
@@ -2251,6 +2256,7 @@ GDS_NEIGHBOURS_send_get (const struct GNUNET_HashCode *key, | |||
2251 | if (0 == GNUNET_CRYPTO_cmp_peer_identity (&my_identity, | 2256 | if (0 == GNUNET_CRYPTO_cmp_peer_identity (&my_identity, |
2252 | &best_known_dest)) | 2257 | &best_known_dest)) |
2253 | { | 2258 | { |
2259 | DEBUG("GET destination is me = %s,KEY = %s\n",GNUNET_i2s(&my_identity),GNUNET_h2s(key)); | ||
2254 | GDS_DATACACHE_handle_get (key,block_type, NULL, 0, | 2260 | GDS_DATACACHE_handle_get (key,block_type, NULL, 0, |
2255 | NULL, 0, 1, &my_identity, NULL,&my_identity); | 2261 | NULL, 0, 1, &my_identity, NULL,&my_identity); |
2256 | 2262 | ||
@@ -2346,7 +2352,7 @@ GDS_NEIGHBOURS_send_get_result (const struct GNUNET_HashCode *key, | |||
2346 | GNUNET_break(0); | 2352 | GNUNET_break(0); |
2347 | return; | 2353 | return; |
2348 | } | 2354 | } |
2349 | 2355 | DEBUG("GET RESULT FOR DATA_SIZE = %lu\n",msize); | |
2350 | current_path_index = 0; | 2356 | current_path_index = 0; |
2351 | if(get_path_length > 0) | 2357 | if(get_path_length > 0) |
2352 | { | 2358 | { |
@@ -3107,23 +3113,6 @@ send_verify_successor_message (void *cls, | |||
3107 | /* Trail stored at this index. */ | 3113 | /* Trail stored at this index. */ |
3108 | GNUNET_assert (GNUNET_YES == trail->is_present); | 3114 | GNUNET_assert (GNUNET_YES == trail->is_present); |
3109 | 3115 | ||
3110 | /* Code for testing ONLY: Store the successor for path tracking */ | ||
3111 | if (track_topology && (NULL != GDS_stats)) | ||
3112 | { | ||
3113 | char *my_id_str; | ||
3114 | char *succ_id_str; | ||
3115 | char *key; | ||
3116 | |||
3117 | my_id_str = GNUNET_strdup (GNUNET_i2s (&my_identity)); | ||
3118 | succ_id_str = GNUNET_strdup (GNUNET_i2s | ||
3119 | (&successor->finger_identity)); | ||
3120 | GNUNET_asprintf (&key, "XDHT:%s:%s", my_id_str, succ_id_str); | ||
3121 | GNUNET_free (my_id_str); | ||
3122 | GNUNET_free (succ_id_str); | ||
3123 | GNUNET_STATISTICS_update (GDS_stats, key, 1, 0); | ||
3124 | GNUNET_free (key); | ||
3125 | } | ||
3126 | |||
3127 | trail_id = trail->trail_id; | 3116 | trail_id = trail->trail_id; |
3128 | trail_length = trail->trail_length; | 3117 | trail_length = trail->trail_length; |
3129 | 3118 | ||
@@ -3524,7 +3513,7 @@ handle_dht_p2p_put (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3524 | GNUNET_break_op (0); | 3513 | GNUNET_break_op (0); |
3525 | return GNUNET_OK; | 3514 | return GNUNET_OK; |
3526 | } | 3515 | } |
3527 | 3516 | DEBUG("GET FOR DATA_SIZE = %lu\n",msize); | |
3528 | GNUNET_STATISTICS_update (GDS_stats, | 3517 | GNUNET_STATISTICS_update (GDS_stats, |
3529 | gettext_noop | 3518 | gettext_noop |
3530 | ("# Bytes received from other peers"), (int64_t) msize, | 3519 | ("# Bytes received from other peers"), (int64_t) msize, |
@@ -3636,6 +3625,7 @@ handle_dht_p2p_put (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3636 | /* I am the final destination */ | 3625 | /* I am the final destination */ |
3637 | if (0 == GNUNET_CRYPTO_cmp_peer_identity (&my_identity, &best_known_dest)) | 3626 | if (0 == GNUNET_CRYPTO_cmp_peer_identity (&my_identity, &best_known_dest)) |
3638 | { | 3627 | { |
3628 | DEBUG("PUT destination is me = %s,KEY = %s\n",GNUNET_i2s(&my_identity),GNUNET_h2s(&(put->key))); | ||
3639 | GDS_DATACACHE_handle_put (GNUNET_TIME_absolute_ntoh (put->expiration_time), | 3629 | GDS_DATACACHE_handle_put (GNUNET_TIME_absolute_ntoh (put->expiration_time), |
3640 | &(put->key),putlen, pp, ntohl (put->block_type), | 3630 | &(put->key),putlen, pp, ntohl (put->block_type), |
3641 | payload_size, payload); | 3631 | payload_size, payload); |
@@ -3698,7 +3688,7 @@ handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3698 | GNUNET_break_op (0); | 3688 | GNUNET_break_op (0); |
3699 | return GNUNET_YES; | 3689 | return GNUNET_YES; |
3700 | } | 3690 | } |
3701 | 3691 | DEBUG("PUT FOR DATA_SIZE = %lu\n",msize); | |
3702 | GNUNET_STATISTICS_update (GDS_stats, | 3692 | GNUNET_STATISTICS_update (GDS_stats, |
3703 | gettext_noop | 3693 | gettext_noop |
3704 | ("# Bytes received from other peers"), msize, | 3694 | ("# Bytes received from other peers"), msize, |
@@ -3745,6 +3735,7 @@ handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3745 | /* I am the final destination. */ | 3735 | /* I am the final destination. */ |
3746 | if (0 == GNUNET_CRYPTO_cmp_peer_identity(&my_identity, &best_known_dest)) | 3736 | if (0 == GNUNET_CRYPTO_cmp_peer_identity(&my_identity, &best_known_dest)) |
3747 | { | 3737 | { |
3738 | DEBUG("GET destination is me = %s,KEY = %s\n",GNUNET_i2s(&my_identity),GNUNET_h2s(&(get->key))); | ||
3748 | struct GNUNET_PeerIdentity final_get_path[get_length+1]; | 3739 | struct GNUNET_PeerIdentity final_get_path[get_length+1]; |
3749 | 3740 | ||
3750 | memcpy (final_get_path, gp, get_length * sizeof (struct GNUNET_PeerIdentity)); | 3741 | memcpy (final_get_path, gp, get_length * sizeof (struct GNUNET_PeerIdentity)); |
@@ -3811,7 +3802,7 @@ handle_dht_p2p_get_result (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
3811 | GNUNET_break_op (0); | 3802 | GNUNET_break_op (0); |
3812 | return GNUNET_YES; | 3803 | return GNUNET_YES; |
3813 | } | 3804 | } |
3814 | 3805 | DEBUG("GET_RESULT FOR DATA_SIZE = %lu\n",msize); | |
3815 | GNUNET_STATISTICS_update (GDS_stats, | 3806 | GNUNET_STATISTICS_update (GDS_stats, |
3816 | gettext_noop | 3807 | gettext_noop |
3817 | ("# Bytes received from other peers"), msize, | 3808 | ("# Bytes received from other peers"), msize, |
@@ -4956,8 +4947,24 @@ compare_and_update_successor (struct GNUNET_PeerIdentity curr_succ, | |||
4956 | 4947 | ||
4957 | /* If the current_successor in the finger table is closest, then do nothing. */ | 4948 | /* If the current_successor in the finger table is closest, then do nothing. */ |
4958 | if (closest_peer == ¤t_successor->finger_identity) | 4949 | if (closest_peer == ¤t_successor->finger_identity) |
4950 | { | ||
4951 | /* Code for testing ONLY: Store the successor for path tracking */ | ||
4952 | track_topology = 1; | ||
4953 | if (track_topology && (NULL != GDS_stats)) | ||
4954 | { | ||
4955 | char *my_id_str; | ||
4956 | uint64_t succ; | ||
4957 | char *key; | ||
4958 | |||
4959 | my_id_str = GNUNET_strdup (GNUNET_i2s_full (&my_identity)); | ||
4960 | memcpy(&succ, ¤t_successor->finger_identity, sizeof(uint64_t)); | ||
4961 | GNUNET_asprintf (&key, "XDHT:%s:", my_id_str); | ||
4962 | GNUNET_free (my_id_str); | ||
4963 | GNUNET_STATISTICS_set (GDS_stats, key, succ, 0); | ||
4964 | GNUNET_free (key); | ||
4965 | } | ||
4959 | return; | 4966 | return; |
4960 | 4967 | } | |
4961 | /* Probable successor is the closest peer.*/ | 4968 | /* Probable successor is the closest peer.*/ |
4962 | if(trail_length > 0) | 4969 | if(trail_length > 0) |
4963 | { | 4970 | { |
@@ -5603,7 +5610,7 @@ remove_matching_trails (const struct GNUNET_PeerIdentity *disconnected_friend, | |||
5603 | matching_trails_count = 0; | 5610 | matching_trails_count = 0; |
5604 | 5611 | ||
5605 | /* Iterate over all the trails of finger. */ | 5612 | /* Iterate over all the trails of finger. */ |
5606 | for (i = 0; i < remove_finger->trails_count; i++) | 5613 | for (i = 0; i < MAXIMUM_TRAILS_PER_FINGER; i++) |
5607 | { | 5614 | { |
5608 | struct Trail *trail; | 5615 | struct Trail *trail; |
5609 | trail = &remove_finger->trail_list[i]; | 5616 | trail = &remove_finger->trail_list[i]; |