diff options
author | Supriti Singh <supritisingh08@gmail.com> | 2014-04-23 16:35:03 +0000 |
---|---|---|
committer | Supriti Singh <supritisingh08@gmail.com> | 2014-04-23 16:35:03 +0000 |
commit | 56fb00e3dd64217b9b7d6c6e19c5467ed0c7b842 (patch) | |
tree | aa5b5b1a598ae5c7a12c3eec6491cad3e53df417 /src/dht | |
parent | 1dc43e7ecd7286670cb5646ce4b1f0663c0fd122 (diff) | |
download | gnunet-56fb00e3dd64217b9b7d6c6e19c5467ed0c7b842.tar.gz gnunet-56fb00e3dd64217b9b7d6c6e19c5467ed0c7b842.zip |
Removing compile warnings
Adding a new message type, tear down.
Diffstat (limited to 'src/dht')
-rw-r--r-- | src/dht/gnunet-service-xdht_clients.c | 21 | ||||
-rw-r--r-- | src/dht/gnunet-service-xdht_neighbours.c | 122 | ||||
-rw-r--r-- | src/dht/gnunet-service-xdht_neighbours.h | 10 |
3 files changed, 116 insertions, 37 deletions
diff --git a/src/dht/gnunet-service-xdht_clients.c b/src/dht/gnunet-service-xdht_clients.c index 83c8983bf..453fe38ab 100644 --- a/src/dht/gnunet-service-xdht_clients.c +++ b/src/dht/gnunet-service-xdht_clients.c | |||
@@ -850,12 +850,10 @@ transmit_request (struct ClientQueryRecord *cqr) | |||
850 | * stored should be const or else you may overwrite it and you lose your | 850 | * stored should be const or else you may overwrite it and you lose your |
851 | * identity value. */ | 851 | * identity value. */ |
852 | 852 | ||
853 | const struct GNUNET_PeerIdentity *my_identity; | 853 | struct GNUNET_PeerIdentity my_identity; |
854 | struct GNUNET_PeerIdentity copy_my_identity; | ||
855 | my_identity = GDS_NEIGHBOURS_get_my_id (); | 854 | my_identity = GDS_NEIGHBOURS_get_my_id (); |
856 | memcpy (©_my_identity, my_identity, sizeof(struct GNUNET_PeerIdentity)); | ||
857 | GDS_NEIGHBOURS_send_get (&cqr->key, cqr->type, cqr->msg_options, | 855 | GDS_NEIGHBOURS_send_get (&cqr->key, cqr->type, cqr->msg_options, |
858 | cqr->replication, ©_my_identity, ©_my_identity, NULL, | 856 | cqr->replication, my_identity, my_identity, NULL, |
859 | 0, 0, NULL); | 857 | 0, 0, NULL); |
860 | 858 | ||
861 | /* exponential back-off for retries. | 859 | /* exponential back-off for retries. |
@@ -957,24 +955,22 @@ handle_dht_local_put (void *cls, struct GNUNET_SERVER_Client *client, | |||
957 | * address and then pass this address. address at which your identity is | 955 | * address and then pass this address. address at which your identity is |
958 | * stored should be const or else you may overwrite it and you lose your | 956 | * stored should be const or else you may overwrite it and you lose your |
959 | * identity value. */ | 957 | * identity value. */ |
960 | const struct GNUNET_PeerIdentity *my_identity; | 958 | struct GNUNET_PeerIdentity my_identity; |
961 | struct GNUNET_PeerIdentity copy_my_identity; | ||
962 | my_identity = GDS_NEIGHBOURS_get_my_id(); | 959 | my_identity = GDS_NEIGHBOURS_get_my_id(); |
963 | memcpy (©_my_identity, my_identity, sizeof(struct GNUNET_PeerIdentity)); | ||
964 | GDS_NEIGHBOURS_send_put (&put_msg->key, &put_msg[1], | 960 | GDS_NEIGHBOURS_send_put (&put_msg->key, &put_msg[1], |
965 | size - sizeof (struct GNUNET_DHT_ClientPutMessage), | 961 | size - sizeof (struct GNUNET_DHT_ClientPutMessage), |
966 | ntohl (put_msg->type), ntohl (put_msg->options), | 962 | ntohl (put_msg->type), ntohl (put_msg->options), |
967 | ntohl (put_msg->desired_replication_level), | 963 | ntohl (put_msg->desired_replication_level), |
968 | GNUNET_TIME_absolute_ntoh (put_msg->expiration), | 964 | GNUNET_TIME_absolute_ntoh (put_msg->expiration), |
969 | ©_my_identity, ©_my_identity, NULL, 0, 0, NULL); | 965 | my_identity, my_identity, NULL, 0, 0, NULL); |
970 | 966 | ||
971 | 967 | ||
972 | GDS_CLIENTS_process_put (ntohl (put_msg->options), | 968 | GDS_CLIENTS_process_put (ntohl (put_msg->options), |
973 | ntohl (put_msg->type), | 969 | ntohl (put_msg->type), |
974 | 0, | 970 | 0, |
975 | ntohl (put_msg->desired_replication_level), | 971 | ntohl (put_msg->desired_replication_level), |
976 | 1, | 972 | 1, |
977 | GDS_NEIGHBOURS_get_my_id(), | 973 | &my_identity, |
978 | GNUNET_TIME_absolute_ntoh (put_msg->expiration), | 974 | GNUNET_TIME_absolute_ntoh (put_msg->expiration), |
979 | &put_msg->key, | 975 | &put_msg->key, |
980 | &put_msg[1], | 976 | &put_msg[1], |
@@ -1048,12 +1044,15 @@ handle_dht_local_get (void *cls, struct GNUNET_SERVER_Client *client, | |||
1048 | // FIXME use cqr->key, set multihashmap create to GNUNET_YES | 1044 | // FIXME use cqr->key, set multihashmap create to GNUNET_YES |
1049 | GNUNET_CONTAINER_multihashmap_put (forward_map, &get->key, cqr, | 1045 | GNUNET_CONTAINER_multihashmap_put (forward_map, &get->key, cqr, |
1050 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 1046 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
1047 | |||
1048 | struct GNUNET_PeerIdentity my_identity; | ||
1049 | my_identity = GDS_NEIGHBOURS_get_my_id(); | ||
1051 | GDS_CLIENTS_process_get (ntohl (get->options), | 1050 | GDS_CLIENTS_process_get (ntohl (get->options), |
1052 | ntohl (get->type), | 1051 | ntohl (get->type), |
1053 | 0, | 1052 | 0, |
1054 | ntohl (get->desired_replication_level), | 1053 | ntohl (get->desired_replication_level), |
1055 | 1, | 1054 | 1, |
1056 | GDS_NEIGHBOURS_get_my_id(), | 1055 | &my_identity, |
1057 | &get->key); | 1056 | &get->key); |
1058 | /* start remote requests */ | 1057 | /* start remote requests */ |
1059 | if (GNUNET_SCHEDULER_NO_TASK != retry_task) | 1058 | if (GNUNET_SCHEDULER_NO_TASK != retry_task) |
diff --git a/src/dht/gnunet-service-xdht_neighbours.c b/src/dht/gnunet-service-xdht_neighbours.c index bb2346bad..e12afccf8 100644 --- a/src/dht/gnunet-service-xdht_neighbours.c +++ b/src/dht/gnunet-service-xdht_neighbours.c | |||
@@ -72,6 +72,8 @@ | |||
72 | 72 | ||
73 | /** | 73 | /** |
74 | * Maximum number of trails allowed to go through a friend. | 74 | * Maximum number of trails allowed to go through a friend. |
75 | * FIXME: Random value at the moment, need to be adjusted to maintain a balance | ||
76 | * between performance and Sybil tolerance. | ||
75 | */ | 77 | */ |
76 | #define LINK_THRESHOLD 64 | 78 | #define LINK_THRESHOLD 64 |
77 | 79 | ||
@@ -132,7 +134,6 @@ struct PeerPutMessage | |||
132 | * The key to store the value under. | 134 | * The key to store the value under. |
133 | */ | 135 | */ |
134 | struct GNUNET_HashCode key GNUNET_PACKED; | 136 | struct GNUNET_HashCode key GNUNET_PACKED; |
135 | |||
136 | 137 | ||
137 | /* put path (if tracked) */ | 138 | /* put path (if tracked) */ |
138 | 139 | ||
@@ -1340,17 +1341,19 @@ send_find_finger_trail_message (void *cls, | |||
1340 | { | 1341 | { |
1341 | finger_identity = compute_finger_identity(); | 1342 | finger_identity = compute_finger_identity(); |
1342 | } | 1343 | } |
1344 | |||
1343 | finger_map_index = current_finger_index; | 1345 | finger_map_index = current_finger_index; |
1344 | 1346 | ||
1345 | /* FIXME: verify if its correct to set current_destination and current_source | 1347 | /* FIXME: verify if its correct to set current_destination and current_source |
1346 | as my identity. */ | 1348 | as my identity. Check what should be the best value to set for current_dest |
1349 | * and current_source. */ | ||
1347 | GDS_NEIGHBOURS_send_trail_setup (&my_identity, finger_identity, &(target_friend->id), | 1350 | GDS_NEIGHBOURS_send_trail_setup (&my_identity, finger_identity, &(target_friend->id), |
1348 | &(target_friend->id), target_friend, 0, NULL, finger_map_index); | 1351 | &(target_friend->id), target_friend, 0, NULL, finger_map_index); |
1349 | } | 1352 | } |
1350 | 1353 | ||
1351 | 1354 | ||
1352 | /** | 1355 | /** |
1353 | * | 1356 | * Invert the trail list. |
1354 | * @param destination_peer | 1357 | * @param destination_peer |
1355 | * @param existing_trail | 1358 | * @param existing_trail |
1356 | * @param trail_length | 1359 | * @param trail_length |
@@ -1447,7 +1450,38 @@ scan_trail (struct GNUNET_PeerIdentity *finger_trail) | |||
1447 | } | 1450 | } |
1448 | #endif | 1451 | #endif |
1449 | 1452 | ||
1453 | /* @param cls closure | ||
1454 | * @param key current public key | ||
1455 | * @param value value in the hash map | ||
1456 | * @return #GNUNET_YES if we should continue to | ||
1457 | * iterate, | ||
1458 | * #GNUNET_NO if not. | ||
1459 | */ | ||
1460 | static int | ||
1461 | get_existing_finger (void *cls, | ||
1462 | const struct GNUNET_PeerIdentity *key, | ||
1463 | void *value) | ||
1464 | { | ||
1465 | struct FingerInfo *existing_finger = value; | ||
1466 | uint32_t finger_map_index = (uint32_t) cls; | ||
1467 | |||
1468 | if (existing_finger->finger_map_index == finger_map_index) | ||
1469 | { | ||
1470 | /* SUPU: How do I communicate this finger to the calling function. */ | ||
1471 | } | ||
1472 | return GNUNET_NO; | ||
1473 | } | ||
1474 | |||
1450 | /** | 1475 | /** |
1476 | * TODO: | ||
1477 | * If you remove an entry from finger table, and if the finger is not your friend | ||
1478 | * and the trail length > 1 for the finger that you removed, then you should send | ||
1479 | * a trail_teardown message along the trail. so that the peers which have an | ||
1480 | * entry in their routing table for this trail can remove it from their routing | ||
1481 | * table. | ||
1482 | * 2. how to handle the case in which same finger identity is stored for different | ||
1483 | * finger map index. because this will just increase the size of finger map and | ||
1484 | * also size of the array we use in find_successor. | ||
1451 | * Add an entry in finger table. Before adding, check if there is already an | 1485 | * Add an entry in finger table. Before adding, check if there is already an |
1452 | * entry in finger peermap for the same index, if yes then choose the closest one. | 1486 | * entry in finger peermap for the same index, if yes then choose the closest one. |
1453 | * In case both the existing identity and new identity are same, keep both the trail | 1487 | * In case both the existing identity and new identity are same, keep both the trail |
@@ -1487,7 +1521,9 @@ void finger_table_add (const struct GNUNET_PeerIdentity *finger_identity, | |||
1487 | if yes then check the trail. if I use gnuent_container_multipeermap_iterate, | 1521 | if yes then check the trail. if I use gnuent_container_multipeermap_iterate, |
1488 | i should stop after I found the finger map index, and just return the | 1522 | i should stop after I found the finger map index, and just return the |
1489 | struct finger info. then I should call another function which takes care of | 1523 | struct finger info. then I should call another function which takes care of |
1490 | finding the closest peer*/ | 1524 | finding the closest peer */ |
1525 | GNUNET_CONTAINER_multipeermap_iterate (finger_peermap, &get_existing_finger, | ||
1526 | (void *)finger_map_index); | ||
1491 | 1527 | ||
1492 | add_new_entry: | 1528 | add_new_entry: |
1493 | memcpy (&(new_finger_entry.finger_identity), finger_identity, sizeof (struct GNUNET_PeerIdentity)); | 1529 | memcpy (&(new_finger_entry.finger_identity), finger_identity, sizeof (struct GNUNET_PeerIdentity)); |
@@ -1896,8 +1932,8 @@ GDS_NEIGHBOURS_send_put (const struct GNUNET_HashCode *key, | |||
1896 | enum GNUNET_DHT_RouteOption options, | 1932 | enum GNUNET_DHT_RouteOption options, |
1897 | uint32_t desired_replication_level, | 1933 | uint32_t desired_replication_level, |
1898 | struct GNUNET_TIME_Absolute expiration_time, | 1934 | struct GNUNET_TIME_Absolute expiration_time, |
1899 | struct GNUNET_PeerIdentity *current_destination, | 1935 | struct GNUNET_PeerIdentity current_destination, |
1900 | struct GNUNET_PeerIdentity *current_source, | 1936 | struct GNUNET_PeerIdentity current_source, |
1901 | struct GNUNET_PeerIdentity *target_peer, | 1937 | struct GNUNET_PeerIdentity *target_peer, |
1902 | uint32_t hop_count, | 1938 | uint32_t hop_count, |
1903 | uint32_t put_path_length, | 1939 | uint32_t put_path_length, |
@@ -1932,7 +1968,16 @@ GDS_NEIGHBOURS_send_put (const struct GNUNET_HashCode *key, | |||
1932 | struct GNUNET_PeerIdentity *next_hop; | 1968 | struct GNUNET_PeerIdentity *next_hop; |
1933 | 1969 | ||
1934 | memcpy (&key_value, key, sizeof (uint64_t)); | 1970 | memcpy (&key_value, key, sizeof (uint64_t)); |
1935 | next_hop = find_successor (key_value, current_destination, current_source); | 1971 | struct GNUNET_PeerIdentity curr_dest; |
1972 | struct GNUNET_PeerIdentity curr_src; | ||
1973 | memcpy (&curr_dest, ¤t_destination, sizeof (struct GNUNET_PeerIdentity)); | ||
1974 | memcpy (&curr_src, ¤t_source, sizeof (struct GNUNET_PeerIdentity)); | ||
1975 | next_hop = find_successor (key_value, &curr_dest, &curr_src); | ||
1976 | /* FIXME: I am copying back current_destination and current_source. but I am not | ||
1977 | sure, if its correct. I am doing so just to remove the code from client file.*/ | ||
1978 | memcpy (¤t_destination, &curr_dest, sizeof (struct GNUNET_PeerIdentity)); | ||
1979 | memcpy (¤t_source, &curr_src, sizeof (struct GNUNET_PeerIdentity)); | ||
1980 | |||
1936 | if (NULL == next_hop) /* I am the destination do datacache_put */ | 1981 | if (NULL == next_hop) /* I am the destination do datacache_put */ |
1937 | { | 1982 | { |
1938 | GDS_DATACACHE_handle_put (expiration_time, key, put_path_length, put_path, | 1983 | GDS_DATACACHE_handle_put (expiration_time, key, put_path_length, put_path, |
@@ -1956,8 +2001,8 @@ GDS_NEIGHBOURS_send_put (const struct GNUNET_HashCode *key, | |||
1956 | ppm->put_path_length = htonl (put_path_length); | 2001 | ppm->put_path_length = htonl (put_path_length); |
1957 | ppm->expiration_time = GNUNET_TIME_absolute_hton (expiration_time); | 2002 | ppm->expiration_time = GNUNET_TIME_absolute_hton (expiration_time); |
1958 | ppm->key = *key; | 2003 | ppm->key = *key; |
1959 | ppm->current_destination = *current_destination; | 2004 | ppm->current_destination = current_destination; |
1960 | ppm->current_source = *current_source; | 2005 | ppm->current_source = current_source; |
1961 | 2006 | ||
1962 | pp = (struct GNUNET_PeerIdentity *) &ppm[1]; | 2007 | pp = (struct GNUNET_PeerIdentity *) &ppm[1]; |
1963 | if (put_path_length != 0) | 2008 | if (put_path_length != 0) |
@@ -1994,8 +2039,8 @@ GDS_NEIGHBOURS_send_get (const struct GNUNET_HashCode *key, | |||
1994 | enum GNUNET_BLOCK_Type block_type, | 2039 | enum GNUNET_BLOCK_Type block_type, |
1995 | enum GNUNET_DHT_RouteOption options, | 2040 | enum GNUNET_DHT_RouteOption options, |
1996 | uint32_t desired_replication_level, | 2041 | uint32_t desired_replication_level, |
1997 | struct GNUNET_PeerIdentity *current_destination, | 2042 | struct GNUNET_PeerIdentity current_destination, |
1998 | struct GNUNET_PeerIdentity *current_source, | 2043 | struct GNUNET_PeerIdentity current_source, |
1999 | struct GNUNET_PeerIdentity *target_peer, | 2044 | struct GNUNET_PeerIdentity *target_peer, |
2000 | uint32_t hop_count, | 2045 | uint32_t hop_count, |
2001 | uint32_t get_path_length, | 2046 | uint32_t get_path_length, |
@@ -2021,13 +2066,21 @@ GDS_NEIGHBOURS_send_get (const struct GNUNET_HashCode *key, | |||
2021 | /* This is the first call from client file, we need to search for next_hop*/ | 2066 | /* This is the first call from client file, we need to search for next_hop*/ |
2022 | struct GNUNET_PeerIdentity *next_hop; | 2067 | struct GNUNET_PeerIdentity *next_hop; |
2023 | uint64_t key_value; | 2068 | uint64_t key_value; |
2024 | 2069 | struct GNUNET_PeerIdentity curr_dest; | |
2070 | struct GNUNET_PeerIdentity curr_src; | ||
2071 | memcpy (&curr_dest, ¤t_destination, sizeof (struct GNUNET_PeerIdentity)); | ||
2072 | memcpy (&curr_src, ¤t_source, sizeof (struct GNUNET_PeerIdentity)); | ||
2025 | memcpy (&key_value, key, sizeof (struct GNUNET_PeerIdentity)); | 2073 | memcpy (&key_value, key, sizeof (struct GNUNET_PeerIdentity)); |
2026 | next_hop = find_successor (key_value, current_destination, current_source); | 2074 | next_hop = find_successor (key_value, &curr_dest, &curr_src); |
2075 | /* FIXME: Again I am copying back value of current_destination, current_source, | ||
2076 | Think of a better solution. */ | ||
2077 | memcpy (¤t_destination, &curr_dest, sizeof (struct GNUNET_PeerIdentity)); | ||
2078 | memcpy (¤t_source, &curr_src, sizeof (struct GNUNET_PeerIdentity)); | ||
2027 | if (NULL == next_hop) /* I am the destination do datacache_put */ | 2079 | if (NULL == next_hop) /* I am the destination do datacache_put */ |
2028 | { | 2080 | { |
2029 | GDS_DATACACHE_handle_get (key,block_type, NULL, 0, | 2081 | GDS_DATACACHE_handle_get (key,block_type, NULL, 0, |
2030 | NULL, 0, 1, &my_identity, NULL,&my_identity); | 2082 | NULL, 0, 1, &my_identity, NULL,&my_identity); |
2083 | return; | ||
2031 | } | 2084 | } |
2032 | else | 2085 | else |
2033 | { | 2086 | { |
@@ -2043,8 +2096,8 @@ GDS_NEIGHBOURS_send_get (const struct GNUNET_HashCode *key, | |||
2043 | pgm->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_GET); | 2096 | pgm->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_P2P_GET); |
2044 | pgm->get_path_length = htonl (get_path_length); | 2097 | pgm->get_path_length = htonl (get_path_length); |
2045 | pgm->key = *key; | 2098 | pgm->key = *key; |
2046 | pgm->current_destination = *current_destination; | 2099 | pgm->current_destination = current_destination; |
2047 | pgm->current_source = *current_source; | 2100 | pgm->current_source = current_source; |
2048 | pgm->hop_count = htonl (hop_count + 1); | 2101 | pgm->hop_count = htonl (hop_count + 1); |
2049 | 2102 | ||
2050 | gp = (struct GNUNET_PeerIdentity *) &pgm[1]; | 2103 | gp = (struct GNUNET_PeerIdentity *) &pgm[1]; |
@@ -2330,7 +2383,7 @@ handle_dht_p2p_put (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
2330 | ntohl (put->block_type),ntohl (put->options), | 2383 | ntohl (put->block_type),ntohl (put->options), |
2331 | ntohl (put->desired_replication_level), | 2384 | ntohl (put->desired_replication_level), |
2332 | GNUNET_TIME_absolute_ntoh (put->expiration_time), | 2385 | GNUNET_TIME_absolute_ntoh (put->expiration_time), |
2333 | ¤t_destination, ¤t_source, next_hop, | 2386 | current_destination, current_source, next_hop, |
2334 | ntohl (put->hop_count), putlen, pp); | 2387 | ntohl (put->hop_count), putlen, pp); |
2335 | 2388 | ||
2336 | return GNUNET_YES; | 2389 | return GNUNET_YES; |
@@ -2422,8 +2475,8 @@ handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
2422 | else | 2475 | else |
2423 | { | 2476 | { |
2424 | GDS_NEIGHBOURS_send_get (&(get->key), get->block_type, get->options, | 2477 | GDS_NEIGHBOURS_send_get (&(get->key), get->block_type, get->options, |
2425 | get->desired_replication_level,¤t_destination, | 2478 | get->desired_replication_level,current_destination, |
2426 | ¤t_source, next_hop, 0, | 2479 | current_source, next_hop, 0, |
2427 | get_length, gp); | 2480 | get_length, gp); |
2428 | } | 2481 | } |
2429 | return GNUNET_SYSERR; | 2482 | return GNUNET_SYSERR; |
@@ -2484,8 +2537,11 @@ handle_dht_p2p_get_result (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
2484 | payload_size = msize - (sizeof (struct PeerGetResultMessage) + | 2537 | payload_size = msize - (sizeof (struct PeerGetResultMessage) + |
2485 | getlen * sizeof (struct GNUNET_PeerIdentity)); | 2538 | getlen * sizeof (struct GNUNET_PeerIdentity)); |
2486 | /* FIXME: Check if its correct or not. */ | 2539 | /* FIXME: Check if its correct or not. */ |
2540 | |||
2487 | if (putlen > 0) | 2541 | if (putlen > 0) |
2488 | put_path = &get_path[1]; | 2542 | put_path = &get_path[1]; |
2543 | else | ||
2544 | put_path = NULL; | ||
2489 | 2545 | ||
2490 | if (0 == (GNUNET_CRYPTO_cmp_peer_identity (&my_identity, &(get_path[0])))) | 2546 | if (0 == (GNUNET_CRYPTO_cmp_peer_identity (&my_identity, &(get_path[0])))) |
2491 | { | 2547 | { |
@@ -2571,7 +2627,8 @@ handle_dht_p2p_trail_setup(void *cls, const struct GNUNET_PeerIdentity *peer, | |||
2571 | if (0 != (GNUNET_CRYPTO_cmp_peer_identity (¤t_destination, &my_identity))) | 2627 | if (0 != (GNUNET_CRYPTO_cmp_peer_identity (¤t_destination, &my_identity))) |
2572 | { | 2628 | { |
2573 | next_hop = GDS_ROUTING_search (¤t_source, ¤t_destination, peer); | 2629 | next_hop = GDS_ROUTING_search (¤t_source, ¤t_destination, peer); |
2574 | /* OPTIMIZATION: do find_successor also and get a better path if possible. */ | 2630 | /* ADDNOW: OPTIMIZATION: do find_successor also and get a better path if possible. */ |
2631 | |||
2575 | if (next_hop == NULL) | 2632 | if (next_hop == NULL) |
2576 | { | 2633 | { |
2577 | /* FIXME next_hop to NULL, 1. statistics update, drop the message. | 2634 | /* FIXME next_hop to NULL, 1. statistics update, drop the message. |
@@ -3131,6 +3188,24 @@ int handle_dht_p2p_trail_rejection(void *cls, const struct GNUNET_PeerIdentity * | |||
3131 | return GNUNET_SYSERR; | 3188 | return GNUNET_SYSERR; |
3132 | } | 3189 | } |
3133 | 3190 | ||
3191 | /** | ||
3192 | * Core handle for p2p trail tear down messages. | ||
3193 | * @param cls closure | ||
3194 | * @param message message | ||
3195 | * @param peer peer identity this notification is about | ||
3196 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | ||
3197 | */ | ||
3198 | static | ||
3199 | int handle_dht_p2p_trail_treadown (void *cls, const struct GNUNET_PeerIdentity *peer, | ||
3200 | const struct GNUNET_MessageHeader *message) | ||
3201 | { | ||
3202 | /* Call is made to this function when the source peer removes an existing | ||
3203 | finger entry and it need to inform the peers which are part of the trail to remove | ||
3204 | the trail from their routing table. So, this peer should first | ||
3205 | get the next hop and then delete the entry. */ | ||
3206 | return GNUNET_YES; | ||
3207 | } | ||
3208 | |||
3134 | 3209 | ||
3135 | /** | 3210 | /** |
3136 | * FIXME: free_finger(remove_finger); Call this function at finger_table_add, | 3211 | * FIXME: free_finger(remove_finger); Call this function at finger_table_add, |
@@ -3313,6 +3388,7 @@ GDS_NEIGHBOURS_init (void) | |||
3313 | {&handle_dht_p2p_verify_successor_result, GNUNET_MESSAGE_TYPE_DHT_P2P_VERIFY_SUCCESSOR_RESULT, 0}, | 3388 | {&handle_dht_p2p_verify_successor_result, GNUNET_MESSAGE_TYPE_DHT_P2P_VERIFY_SUCCESSOR_RESULT, 0}, |
3314 | {&handle_dht_p2p_notify_new_successor, GNUNET_MESSAGE_TYPE_DHT_P2P_NOTIFY_NEW_SUCCESSOR, 0}, | 3389 | {&handle_dht_p2p_notify_new_successor, GNUNET_MESSAGE_TYPE_DHT_P2P_NOTIFY_NEW_SUCCESSOR, 0}, |
3315 | {&handle_dht_p2p_trail_rejection, GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_REJECTION, 0}, | 3390 | {&handle_dht_p2p_trail_rejection, GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_REJECTION, 0}, |
3391 | {&handle_dht_p2p_trail_treadown, GNUNET_MESSAGE_TYPE_DHT_P2P_TRAIL_TEARDOWN, 0}, | ||
3316 | {NULL, 0, 0} | 3392 | {NULL, 0, 0} |
3317 | }; | 3393 | }; |
3318 | 3394 | ||
@@ -3376,14 +3452,18 @@ GDS_NEIGHBOURS_done (void) | |||
3376 | 3452 | ||
3377 | 3453 | ||
3378 | /** | 3454 | /** |
3455 | * FIXME: Here I want to send only the value not the address. Initially | ||
3456 | * I wanted to make it const struct * so that no other function can change it. | ||
3457 | * then in client file, i make a copy and send that copy. now I have made this | ||
3458 | * as only struct. | ||
3379 | * Get my identity | 3459 | * Get my identity |
3380 | * | 3460 | * |
3381 | * @return my identity | 3461 | * @return my identity |
3382 | */ | 3462 | */ |
3383 | const struct GNUNET_PeerIdentity * | 3463 | struct GNUNET_PeerIdentity |
3384 | GDS_NEIGHBOURS_get_my_id (void) | 3464 | GDS_NEIGHBOURS_get_my_id (void) |
3385 | { | 3465 | { |
3386 | return &my_identity; | 3466 | return my_identity; |
3387 | } | 3467 | } |
3388 | 3468 | ||
3389 | 3469 | ||
diff --git a/src/dht/gnunet-service-xdht_neighbours.h b/src/dht/gnunet-service-xdht_neighbours.h index f4cfe4ae8..38f3cfe92 100644 --- a/src/dht/gnunet-service-xdht_neighbours.h +++ b/src/dht/gnunet-service-xdht_neighbours.h | |||
@@ -57,8 +57,8 @@ GDS_NEIGHBOURS_send_put (const struct GNUNET_HashCode *key, | |||
57 | enum GNUNET_DHT_RouteOption options, | 57 | enum GNUNET_DHT_RouteOption options, |
58 | uint32_t desired_replication_level, | 58 | uint32_t desired_replication_level, |
59 | struct GNUNET_TIME_Absolute expiration_time, | 59 | struct GNUNET_TIME_Absolute expiration_time, |
60 | struct GNUNET_PeerIdentity *current_destination, | 60 | struct GNUNET_PeerIdentity current_destination, |
61 | struct GNUNET_PeerIdentity *current_source, | 61 | struct GNUNET_PeerIdentity current_source, |
62 | struct GNUNET_PeerIdentity *target_peer, | 62 | struct GNUNET_PeerIdentity *target_peer, |
63 | uint32_t hop_count, | 63 | uint32_t hop_count, |
64 | uint32_t put_path_length, | 64 | uint32_t put_path_length, |
@@ -88,8 +88,8 @@ GDS_NEIGHBOURS_send_get (const struct GNUNET_HashCode *key, | |||
88 | enum GNUNET_BLOCK_Type block_type, | 88 | enum GNUNET_BLOCK_Type block_type, |
89 | enum GNUNET_DHT_RouteOption options, | 89 | enum GNUNET_DHT_RouteOption options, |
90 | uint32_t desired_replication_level, | 90 | uint32_t desired_replication_level, |
91 | struct GNUNET_PeerIdentity *current_destination, | 91 | struct GNUNET_PeerIdentity current_destination, |
92 | struct GNUNET_PeerIdentity *current_source, | 92 | struct GNUNET_PeerIdentity current_source, |
93 | struct GNUNET_PeerIdentity *target_peer, | 93 | struct GNUNET_PeerIdentity *target_peer, |
94 | uint32_t hop_count, | 94 | uint32_t hop_count, |
95 | uint32_t get_path_length, | 95 | uint32_t get_path_length, |
@@ -149,7 +149,7 @@ GDS_NEIGHBOURS_done (void); | |||
149 | * | 149 | * |
150 | * @return my identity | 150 | * @return my identity |
151 | */ | 151 | */ |
152 | const struct GNUNET_PeerIdentity * | 152 | struct GNUNET_PeerIdentity |
153 | GDS_NEIGHBOURS_get_my_id (void); | 153 | GDS_NEIGHBOURS_get_my_id (void); |
154 | 154 | ||
155 | 155 | ||