aboutsummaryrefslogtreecommitdiff
path: root/src/dht/gnunet-service-xdht_neighbours.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dht/gnunet-service-xdht_neighbours.c')
-rw-r--r--src/dht/gnunet-service-xdht_neighbours.c171
1 files changed, 0 insertions, 171 deletions
diff --git a/src/dht/gnunet-service-xdht_neighbours.c b/src/dht/gnunet-service-xdht_neighbours.c
index 6f3137f8a..314f6d13d 100644
--- a/src/dht/gnunet-service-xdht_neighbours.c
+++ b/src/dht/gnunet-service-xdht_neighbours.c
@@ -939,12 +939,6 @@ static struct GNUNET_TIME_Relative notify_successor_retry_time;
939unsigned int track_topology; 939unsigned int track_topology;
940 940
941/** 941/**
942 * Should I be a malicious peer and drop the PUT/GET packets?
943 * if 0 then NOT malicious.
944 */
945unsigned int act_malicious;
946
947/**
948 * Count of fingers found. Ideally we should have O(logn) fingers for a 942 * Count of fingers found. Ideally we should have O(logn) fingers for a
949 * stable network. 943 * stable network.
950 */ 944 */
@@ -1068,19 +1062,6 @@ process_friend_queue (struct FriendInfo *peer)
1068} 1062}
1069 1063
1070 1064
1071#if ENABLE_MALICIOUS
1072/**
1073 * Set the ENABLE_MALICIOUS value to malicious.
1074 * @param malicious
1075 */
1076int
1077GDS_NEIGHBOURS_act_malicious (unsigned int malicious)
1078{
1079 act_malicious = malicious;
1080 return GNUNET_OK;
1081}
1082#endif
1083
1084/** 1065/**
1085 * Construct a trail setup message and forward it to target_friend 1066 * Construct a trail setup message and forward it to target_friend
1086 * @param source_peer Peer which wants to setup the trail 1067 * @param source_peer Peer which wants to setup the trail
@@ -2291,38 +2272,6 @@ GDS_NEIGHBOURS_handle_put (const struct GNUNET_HashCode *key,
2291 } 2272 }
2292 /* In case we are sending the request to a finger, then send across all of its 2273 /* In case we are sending the request to a finger, then send across all of its
2293 trail.*/ 2274 trail.*/
2294#if ENABLE_MALICIOUS
2295 if (0 != GNUNET_CRYPTO_cmp_peer_identity (&successor.best_known_destination,
2296 &successor.next_hop))
2297 {
2298 struct FingerInfo *next_hop_finger;
2299 unsigned int i;
2300
2301 next_hop_finger = &finger_table[successor.finger_table_index];
2302 for (i = 0; i < next_hop_finger->trails_count; i++)
2303 {
2304 if (GNUNET_YES == next_hop_finger->trail_list[i].is_present)
2305 {
2306 if(0 == next_hop_finger->trail_list[i].trail_length)
2307 {
2308 GDS_NEIGHBOURS_send_put (key, block_type, options, desired_replication_level,
2309 best_known_dest, intermediate_trail_id, &next_hop,
2310 0, 1, &my_identity, expiration_time,
2311 data, data_size);
2312 return;
2313 }
2314 next_hop = next_hop_finger->trail_list[i].trail_head->peer;
2315 GDS_NEIGHBOURS_send_put (key, block_type, options, desired_replication_level,
2316 best_known_dest,
2317 next_hop_finger->trail_list[i].trail_id,
2318 &next_hop, 0, 1, &my_identity,
2319 expiration_time,
2320 data, data_size);
2321 }
2322 }
2323 return;
2324 }
2325#endif
2326 GDS_NEIGHBOURS_send_put (key, block_type, options, desired_replication_level, 2275 GDS_NEIGHBOURS_send_put (key, block_type, options, desired_replication_level,
2327 best_known_dest, intermediate_trail_id, &next_hop, 2276 best_known_dest, intermediate_trail_id, &next_hop,
2328 0, 1, &my_identity, expiration_time, 2277 0, 1, &my_identity, expiration_time,
@@ -2436,38 +2385,6 @@ GDS_NEIGHBOURS_handle_get(const struct GNUNET_HashCode *key,
2436 return; 2385 return;
2437 } 2386 }
2438 2387
2439#if ENABLE_MALICIOUS
2440 struct GNUNET_PeerIdentity next_hop;
2441 if (0 != GNUNET_CRYPTO_cmp_peer_identity (&successor.best_known_destination,
2442 &successor.next_hop))
2443 {
2444 struct FingerInfo *next_hop_finger;
2445 unsigned int i;
2446
2447 next_hop_finger = &finger_table[successor.finger_table_index];
2448 for (i = 0; i < next_hop_finger->trails_count; i++)
2449 {
2450 if (GNUNET_YES == next_hop_finger->trail_list[i].is_present)
2451 {
2452 if(0 == next_hop_finger->trail_list[i].trail_length)
2453 {
2454 GDS_NEIGHBOURS_send_get (key, block_type, options,
2455 desired_replication_level,
2456 best_known_dest,intermediate_trail_id,
2457 &successor.next_hop,
2458 0, 1, &my_identity);
2459 return;
2460 }
2461 next_hop = next_hop_finger->trail_list[i].trail_head->peer;
2462 GDS_NEIGHBOURS_send_get (key, block_type, options, desired_replication_level,
2463 best_known_dest,
2464 next_hop_finger->trail_list[i].trail_id,
2465 &next_hop, 0, 1, &my_identity);
2466 }
2467 }
2468 return;
2469 }
2470#endif
2471 GDS_NEIGHBOURS_send_get (key, block_type, options, desired_replication_level, 2388 GDS_NEIGHBOURS_send_get (key, block_type, options, desired_replication_level,
2472 best_known_dest,intermediate_trail_id, &successor.next_hop, 2389 best_known_dest,intermediate_trail_id, &successor.next_hop,
2473 0, 1, &my_identity); 2390 0, 1, &my_identity);
@@ -3686,13 +3603,6 @@ handle_dht_p2p_put (void *cls, const struct GNUNET_PeerIdentity *peer,
3686 GNUNET_break_op (0); 3603 GNUNET_break_op (0);
3687 return GNUNET_OK; 3604 return GNUNET_OK;
3688 } 3605 }
3689#if ENABLE_MALICIOUS
3690 if(1 == act_malicious)
3691 {
3692 DEBUG("\n I AM MALICIOUS PUT_REQUEST_DROPPED for key = %ss",GNUNET_h2s(&put->key));
3693 return GNUNET_OK;
3694 }
3695#endif
3696 GNUNET_STATISTICS_update (GDS_stats, 3606 GNUNET_STATISTICS_update (GDS_stats,
3697 gettext_noop 3607 gettext_noop
3698 ("# Bytes received from other peers"), (int64_t) msize, 3608 ("# Bytes received from other peers"), (int64_t) msize,
@@ -3818,45 +3728,6 @@ handle_dht_p2p_put (void *cls, const struct GNUNET_PeerIdentity *peer,
3818 &(put->key),putlen, pp, ntohl (put->block_type), 3728 &(put->key),putlen, pp, ntohl (put->block_type),
3819 payload_size, payload); 3729 payload_size, payload);
3820 } 3730 }
3821 else
3822 {
3823#if ENABLE_MALICIOUS
3824 if (0 != GNUNET_CRYPTO_cmp_peer_identity (&successor.best_known_destination,
3825 &successor.next_hop))
3826 {
3827 struct FingerInfo *next_hop_finger;
3828 unsigned int i;
3829
3830 next_hop_finger = &finger_table[successor.finger_table_index];
3831 for (i = 0; i < next_hop_finger->trails_count; i++)
3832 {
3833 if (GNUNET_YES == next_hop_finger->trail_list[i].is_present)
3834 {
3835 if(0 == next_hop_finger->trail_list[i].trail_length)
3836 {
3837 GDS_NEIGHBOURS_send_put (&put->key,
3838 ntohl (put->block_type),ntohl (put->options),
3839 ntohl (put->desired_replication_level),
3840 best_known_dest, intermediate_trail_id, &next_hop,
3841 hop_count, putlen, pp,
3842 GNUNET_TIME_absolute_ntoh (put->expiration_time),
3843 payload, payload_size);
3844 return GNUNET_OK;
3845 }
3846 next_hop = next_hop_finger->trail_list[i].trail_head->peer;
3847 GDS_NEIGHBOURS_send_put (&put->key,
3848 ntohl (put->block_type),ntohl (put->options),
3849 ntohl (put->desired_replication_level),
3850 best_known_dest,
3851 next_hop_finger->trail_list[i].trail_id,
3852 &next_hop, hop_count, putlen, pp,
3853 GNUNET_TIME_absolute_ntoh (put->expiration_time),
3854 payload, payload_size);
3855 }
3856 }
3857 return GNUNET_OK;
3858 }
3859#endif
3860 GDS_NEIGHBOURS_send_put (&put->key, 3731 GDS_NEIGHBOURS_send_put (&put->key,
3861 ntohl (put->block_type),ntohl (put->options), 3732 ntohl (put->block_type),ntohl (put->options),
3862 ntohl (put->desired_replication_level), 3733 ntohl (put->desired_replication_level),
@@ -3917,13 +3788,6 @@ handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer,
3917 return GNUNET_YES; 3788 return GNUNET_YES;
3918 } 3789 }
3919 3790
3920#if ENABLE_MALICIOUS
3921 if(1 == act_malicious)
3922 {
3923 DEBUG("I am malicious,GET_REQUEST_DROPPED for key = %s. \n",GNUNET_h2s(&get->key));
3924 return GNUNET_OK;
3925 }
3926#endif
3927 current_best_known_dest = get->best_known_destination; 3791 current_best_known_dest = get->best_known_destination;
3928 received_intermediate_trail_id = get->intermediate_trail_id; 3792 received_intermediate_trail_id = get->intermediate_trail_id;
3929 get_path = (const struct GNUNET_PeerIdentity *)&get[1]; 3793 get_path = (const struct GNUNET_PeerIdentity *)&get[1];
@@ -3997,37 +3861,6 @@ handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer,
3997 else 3861 else
3998 { 3862 {
3999 3863
4000#if ENABLE_MALICIOUS
4001 if (0 != GNUNET_CRYPTO_cmp_peer_identity (&successor.best_known_destination,
4002 &successor.next_hop))
4003 {
4004 struct FingerInfo *next_hop_finger;
4005 unsigned int i;
4006
4007 next_hop_finger = &finger_table[successor.finger_table_index];
4008 for (i = 0; i < next_hop_finger->trails_count; i++)
4009 {
4010 if(0 == next_hop_finger->trail_list[i].trail_length)
4011 {
4012 GDS_NEIGHBOURS_send_get (&(get->key), get->block_type, get->options,
4013 get->desired_replication_level, best_known_dest,
4014 intermediate_trail_id, &next_hop, hop_count,
4015 get_length, gp);
4016 return GNUNET_OK;
4017 }
4018 if (GNUNET_YES == next_hop_finger->trail_list[i].is_present)
4019 {
4020 next_hop = next_hop_finger->trail_list[i].trail_head->peer;
4021 GDS_NEIGHBOURS_send_get (&(get->key), get->block_type, get->options,
4022 get->desired_replication_level, best_known_dest,
4023 next_hop_finger->trail_list[i].trail_id,
4024 &next_hop, hop_count,
4025 get_length, gp);
4026 }
4027 }
4028 return GNUNET_OK;
4029 }
4030#endif
4031 GDS_NEIGHBOURS_send_get (&(get->key), get->block_type, get->options, 3864 GDS_NEIGHBOURS_send_get (&(get->key), get->block_type, get->options,
4032 get->desired_replication_level, best_known_dest, 3865 get->desired_replication_level, best_known_dest,
4033 intermediate_trail_id, &next_hop, hop_count, 3866 intermediate_trail_id, &next_hop, hop_count,
@@ -6168,10 +6001,6 @@ GDS_NEIGHBOURS_init (void)
6168 {NULL, 0, 0} 6001 {NULL, 0, 0}
6169 }; 6002 };
6170 6003
6171#if ENABLE_MALICIOUS
6172 act_malicious = 0;
6173#endif
6174
6175 core_api = 6004 core_api =
6176 GNUNET_CORE_connect (GDS_cfg, NULL, &core_init, &handle_core_connect, 6005 GNUNET_CORE_connect (GDS_cfg, NULL, &core_init, &handle_core_connect,
6177 &handle_core_disconnect, NULL, GNUNET_NO, NULL, 6006 &handle_core_disconnect, NULL, GNUNET_NO, NULL,