aboutsummaryrefslogtreecommitdiff
path: root/src/dht
diff options
context:
space:
mode:
Diffstat (limited to 'src/dht')
-rw-r--r--src/dht/gnunet-service-xdht_clients.c9
-rw-r--r--src/dht/gnunet-service-xdht_datacache.c7
-rw-r--r--src/dht/gnunet-service-xdht_neighbours.c115
-rw-r--r--src/dht/gnunet-service-xdht_neighbours.h6
4 files changed, 68 insertions, 69 deletions
diff --git a/src/dht/gnunet-service-xdht_clients.c b/src/dht/gnunet-service-xdht_clients.c
index b9cfd6dda..96c3bb7d3 100644
--- a/src/dht/gnunet-service-xdht_clients.c
+++ b/src/dht/gnunet-service-xdht_clients.c
@@ -491,10 +491,11 @@ forward_reply (void *cls, const struct GNUNET_HashCode * key, void *value)
491 int do_free; 491 int do_free;
492 struct GNUNET_HashCode ch; 492 struct GNUNET_HashCode ch;
493 unsigned int i; 493 unsigned int i;
494 494
495 LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG, 495 LOG_TRAFFIC (GNUNET_ERROR_TYPE_DEBUG,
496 "R5N CLIENT-RESULT %s\n", 496 "XVINE CLIENT-RESULT %s\n",
497 GNUNET_h2s_full (key)); 497 GNUNET_h2s_full (key));
498#if 0
498 if ((record->type != GNUNET_BLOCK_TYPE_ANY) && (record->type != frc->type)) 499 if ((record->type != GNUNET_BLOCK_TYPE_ANY) && (record->type != frc->type))
499 { 500 {
500 LOG (GNUNET_ERROR_TYPE_DEBUG, 501 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -506,6 +507,7 @@ forward_reply (void *cls, const struct GNUNET_HashCode * key, void *value)
506 1, GNUNET_NO); 507 1, GNUNET_NO);
507 return GNUNET_YES; /* type mismatch */ 508 return GNUNET_YES; /* type mismatch */
508 } 509 }
510#endif
509 GNUNET_CRYPTO_hash (frc->data, frc->data_size, &ch); 511 GNUNET_CRYPTO_hash (frc->data, frc->data_size, &ch);
510 for (i = 0; i < record->seen_replies_count; i++) 512 for (i = 0; i < record->seen_replies_count; i++)
511 if (0 == memcmp (&record->seen_replies[i], &ch, sizeof (struct GNUNET_HashCode))) 513 if (0 == memcmp (&record->seen_replies[i], &ch, sizeof (struct GNUNET_HashCode)))
@@ -666,7 +668,6 @@ GDS_CLIENTS_handle_reply (struct GNUNET_TIME_Absolute expiration,
666 frc.type = type; 668 frc.type = type;
667 GNUNET_CONTAINER_multihashmap_get_multiple (forward_map, key, &forward_reply, 669 GNUNET_CONTAINER_multihashmap_get_multiple (forward_map, key, &forward_reply,
668 &frc); 670 &frc);
669
670 if (GNUNET_NO == frc.do_copy) 671 if (GNUNET_NO == frc.do_copy)
671 { 672 {
672 /* did not match any of the requests, free! */ 673 /* did not match any of the requests, free! */
@@ -850,6 +851,7 @@ transmit_request (struct ClientQueryRecord *cqr)
850 GNUNET_h2s (&cqr->key), 851 GNUNET_h2s (&cqr->key),
851 cqr->replication, 852 cqr->replication,
852 cqr->seen_replies_count); 853 cqr->seen_replies_count);
854
853 GDS_NEIGHBOURS_send_get (&cqr->key, cqr->type, cqr->msg_options, 855 GDS_NEIGHBOURS_send_get (&cqr->key, cqr->type, cqr->msg_options,
854 cqr->replication, NULL, NULL , NULL, 856 cqr->replication, NULL, NULL , NULL,
855 0, 0, NULL); 857 0, 0, NULL);
@@ -1034,6 +1036,7 @@ handle_dht_local_get (void *cls, struct GNUNET_SERVER_Client *client,
1034 cqr->replication = ntohl (get->desired_replication_level); 1036 cqr->replication = ntohl (get->desired_replication_level);
1035 cqr->msg_options = ntohl (get->options); 1037 cqr->msg_options = ntohl (get->options);
1036 cqr->type = ntohl (get->type); 1038 cqr->type = ntohl (get->type);
1039
1037 // FIXME use cqr->key, set multihashmap create to GNUNET_YES 1040 // FIXME use cqr->key, set multihashmap create to GNUNET_YES
1038 GNUNET_CONTAINER_multihashmap_put (forward_map, &get->key, cqr, 1041 GNUNET_CONTAINER_multihashmap_put (forward_map, &get->key, cqr,
1039 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); 1042 GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE);
diff --git a/src/dht/gnunet-service-xdht_datacache.c b/src/dht/gnunet-service-xdht_datacache.c
index ab1dedeab..5ed510f03 100644
--- a/src/dht/gnunet-service-xdht_datacache.c
+++ b/src/dht/gnunet-service-xdht_datacache.c
@@ -204,6 +204,7 @@ datacache_get_iterator (void *cls,
204 "Found reply for query %s in datacache, evaluation result is %d\n", 204 "Found reply for query %s in datacache, evaluation result is %d\n",
205 GNUNET_h2s (key), (int) eval); 205 GNUNET_h2s (key), (int) eval);
206 ctx->eval = eval; 206 ctx->eval = eval;
207
207 switch (eval) 208 switch (eval)
208 { 209 {
209 case GNUNET_BLOCK_EVALUATION_OK_MORE: 210 case GNUNET_BLOCK_EVALUATION_OK_MORE:
@@ -225,6 +226,7 @@ datacache_get_iterator (void *cls,
225 i++; 226 i++;
226 iterator = iterator->next; 227 iterator = iterator->next;
227 } 228 }
229
228 GDS_NEIGHBOURS_send_get_result (key,type, &(ctx->next_hop),&(ctx->source_peer), 230 GDS_NEIGHBOURS_send_get_result (key,type, &(ctx->next_hop),&(ctx->source_peer),
229 put_path_length, put_path, ctx->get_path_length, 231 put_path_length, put_path, ctx->get_path_length,
230 get_path, exp, data, size ); 232 get_path, exp, data, size );
@@ -313,6 +315,7 @@ GDS_DATACACHE_handle_get (const struct GNUNET_HashCode * key,
313 memcpy (&(ctx.next_hop), next_hop, sizeof (struct GNUNET_PeerIdentity)); 315 memcpy (&(ctx.next_hop), next_hop, sizeof (struct GNUNET_PeerIdentity));
314 } 316 }
315 unsigned int i = 0; 317 unsigned int i = 0;
318
316 ctx.head = NULL; 319 ctx.head = NULL;
317 ctx.tail = NULL; 320 ctx.tail = NULL;
318 if (get_path != NULL) 321 if (get_path != NULL)
@@ -324,11 +327,11 @@ GDS_DATACACHE_handle_get (const struct GNUNET_HashCode * key,
324 element->next = NULL; 327 element->next = NULL;
325 element->prev = NULL; 328 element->prev = NULL;
326 element->peer = get_path[i]; 329 element->peer = get_path[i];
327 GNUNET_CONTAINER_DLL_insert (ctx.head, ctx.tail, element); 330 GNUNET_CONTAINER_DLL_insert_tail (ctx.head, ctx.tail, element);
328 i++; 331 i++;
329 } 332 }
330 } 333 }
331 334
332 r = GNUNET_DATACACHE_get (datacache, key, type, &datacache_get_iterator, 335 r = GNUNET_DATACACHE_get (datacache, key, type, &datacache_get_iterator,
333 &ctx); 336 &ctx);
334 LOG (GNUNET_ERROR_TYPE_DEBUG, 337 LOG (GNUNET_ERROR_TYPE_DEBUG,
diff --git a/src/dht/gnunet-service-xdht_neighbours.c b/src/dht/gnunet-service-xdht_neighbours.c
index 5268b2466..1dba50e23 100644
--- a/src/dht/gnunet-service-xdht_neighbours.c
+++ b/src/dht/gnunet-service-xdht_neighbours.c
@@ -258,7 +258,7 @@ struct PeerGetMessage
258 struct GNUNET_HashCode key; 258 struct GNUNET_HashCode key;
259 259
260 /* Get path. */ 260 /* Get path. */
261 261 /* struct GNUNET_PeerIdentity[]*/
262}; 262};
263 263
264/** 264/**
@@ -911,7 +911,7 @@ core_transmit_notify (void *cls, size_t size, void *buf)
911 struct P2PPendingMessage *pending; 911 struct P2PPendingMessage *pending;
912 size_t off; 912 size_t off;
913 size_t msize; 913 size_t msize;
914 914
915 peer->th = NULL; 915 peer->th = NULL;
916 while ((NULL != (pending = peer->head)) && 916 while ((NULL != (pending = peer->head)) &&
917 (0 == GNUNET_TIME_absolute_get_remaining (pending->timeout).rel_value_us)) 917 (0 == GNUNET_TIME_absolute_get_remaining (pending->timeout).rel_value_us))
@@ -961,7 +961,6 @@ core_transmit_notify (void *cls, size_t size, void *buf)
961 &core_transmit_notify, peer); 961 &core_transmit_notify, peer);
962 GNUNET_break (NULL != peer->th); 962 GNUNET_break (NULL != peer->th);
963 } 963 }
964
965 return off; 964 return off;
966} 965}
967 966
@@ -985,7 +984,7 @@ process_friend_queue (struct FriendInfo *peer)
985 gettext_noop 984 gettext_noop
986 ("# Bytes of bandwidth requested from core"), 985 ("# Bytes of bandwidth requested from core"),
987 ntohs (pending->msg->size), GNUNET_NO); 986 ntohs (pending->msg->size), GNUNET_NO);
988 987
989 peer->th = 988 peer->th =
990 GNUNET_CORE_notify_transmit_ready (core_api, GNUNET_NO, 989 GNUNET_CORE_notify_transmit_ready (core_api, GNUNET_NO,
991 pending->importance, 990 pending->importance,
@@ -2102,7 +2101,9 @@ GDS_NEIGHBOURS_send_put (const struct GNUNET_HashCode *key,
2102 uint64_t key_value; 2101 uint64_t key_value;
2103 struct GNUNET_PeerIdentity *next_hop; 2102 struct GNUNET_PeerIdentity *next_hop;
2104 2103
2105 memcpy (&key_value, key, sizeof (uint64_t)); 2104 memcpy (&key_value, key, sizeof (uint64_t));
2105 key_value = GNUNET_ntohll (key_value);
2106
2106 next_hop = find_successor (key_value, &local_best_known_dest, 2107 next_hop = find_successor (key_value, &local_best_known_dest,
2107 intermediate_trail_id, GDS_FINGER_TYPE_NON_PREDECESSOR); 2108 intermediate_trail_id, GDS_FINGER_TYPE_NON_PREDECESSOR);
2108 if (0 == GNUNET_CRYPTO_cmp_peer_identity (&local_best_known_dest, &my_identity)) 2109 if (0 == GNUNET_CRYPTO_cmp_peer_identity (&local_best_known_dest, &my_identity))
@@ -2146,6 +2147,7 @@ GDS_NEIGHBOURS_send_put (const struct GNUNET_HashCode *key,
2146 sizeof (struct GNUNET_PeerIdentity) * put_path_length); 2147 sizeof (struct GNUNET_PeerIdentity) * put_path_length);
2147 } 2148 }
2148 memcpy (&pp[put_path_length], data, data_size); 2149 memcpy (&pp[put_path_length], data, data_size);
2150
2149 GNUNET_CONTAINER_DLL_insert_tail (target_friend->head, target_friend->tail, pending); 2151 GNUNET_CONTAINER_DLL_insert_tail (target_friend->head, target_friend->tail, pending);
2150 target_friend->pending_count++; 2152 target_friend->pending_count++;
2151 process_friend_queue (target_friend); 2153 process_friend_queue (target_friend);
@@ -2191,25 +2193,21 @@ GDS_NEIGHBOURS_send_get (const struct GNUNET_HashCode *key,
2191 msize = sizeof (struct PeerGetMessage) + 2193 msize = sizeof (struct PeerGetMessage) +
2192 (get_path_length * sizeof (struct GNUNET_PeerIdentity)); 2194 (get_path_length * sizeof (struct GNUNET_PeerIdentity));
2193 2195
2194 if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) 2196 /* In this case we don't make get_path_length = 0, as we need get path to
2195 { 2197 * return the message back to querying client. */
2196 get_path_length = 0;
2197 msize = sizeof (struct PeerPutMessage);
2198 }
2199
2200 if (msize > GNUNET_SERVER_MAX_MESSAGE_SIZE) 2198 if (msize > GNUNET_SERVER_MAX_MESSAGE_SIZE)
2201 { 2199 {
2202 GNUNET_break (0); 2200 GNUNET_break (0);
2203 return; 2201 return;
2204 } 2202 }
2205
2206 /* This is the first time we got request from our own client file. */ 2203 /* This is the first time we got request from our own client file. */
2207 if (NULL == target_peer) 2204 if (NULL == target_peer)
2208 { 2205 {
2209 struct GNUNET_PeerIdentity *next_hop; 2206 struct GNUNET_PeerIdentity *next_hop;
2210 uint64_t key_value; 2207 uint64_t key_value;
2211 2208
2212 memcpy (&key_value, key, sizeof (uint64_t)); //FIXME: endianess of key? 2209 memcpy (&key_value, key, sizeof (uint64_t));
2210 key_value = GNUNET_ntohll (key_value);
2213 2211
2214 /* Find the next destination to forward the packet. */ 2212 /* Find the next destination to forward the packet. */
2215 next_hop = find_successor (key_value, &local_best_known_dest, 2213 next_hop = find_successor (key_value, &local_best_known_dest,
@@ -2237,6 +2235,7 @@ GDS_NEIGHBOURS_send_get (const struct GNUNET_HashCode *key,
2237 } 2235 }
2238 2236
2239 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize); 2237 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
2238 pending->timeout = GNUNET_TIME_relative_to_absolute (GET_TIMEOUT);
2240 pending->importance = 0; /* FIXME */ 2239 pending->importance = 0; /* FIXME */
2241 pgm = (struct PeerGetMessage *) &pending[1]; 2240 pgm = (struct PeerGetMessage *) &pending[1];
2242 pending->msg = &pgm->header; 2241 pending->msg = &pgm->header;
@@ -2244,18 +2243,20 @@ GDS_NEIGHBOURS_send_get (const struct GNUNET_HashCode *key,
2244 pgm->header.type = htons (GNUNET_MESSAGE_TYPE_XDHT_P2P_GET); 2243 pgm->header.type = htons (GNUNET_MESSAGE_TYPE_XDHT_P2P_GET);
2245 pgm->get_path_length = htonl (get_path_length); 2244 pgm->get_path_length = htonl (get_path_length);
2246 pgm->best_known_destination = local_best_known_dest; 2245 pgm->best_known_destination = local_best_known_dest;
2246 pgm->key = *key;
2247 2247
2248 if (NULL == intermediate_trail_id) 2248 if (NULL == intermediate_trail_id)
2249 memset (&pgm->intermediate_trail_id, 0, sizeof (pgm->intermediate_trail_id)); 2249 memset ((void *)&pgm->intermediate_trail_id, 0, sizeof (pgm->intermediate_trail_id));
2250 else 2250 else
2251 pgm->intermediate_trail_id = *intermediate_trail_id; 2251 pgm->intermediate_trail_id = *intermediate_trail_id;
2252 pgm->hop_count = htonl (hop_count + 1); 2252 pgm->hop_count = htonl (hop_count + 1);
2253 gp = (struct GNUNET_PeerIdentity *) &pgm[1];
2253 2254
2254 if (get_path_length != 0) 2255 if (get_path_length != 0)
2255 { 2256 {
2256 gp = (struct GNUNET_PeerIdentity *) &pgm[1];
2257 memcpy (gp, get_path, get_path_length * sizeof (struct GNUNET_PeerIdentity)); 2257 memcpy (gp, get_path, get_path_length * sizeof (struct GNUNET_PeerIdentity));
2258 } 2258 }
2259
2259 GNUNET_CONTAINER_DLL_insert_tail (target_friend->head, target_friend->tail, pending); 2260 GNUNET_CONTAINER_DLL_insert_tail (target_friend->head, target_friend->tail, pending);
2260 target_friend->pending_count++; 2261 target_friend->pending_count++;
2261 process_friend_queue (target_friend); 2262 process_friend_queue (target_friend);
@@ -2279,25 +2280,25 @@ GDS_NEIGHBOURS_send_get (const struct GNUNET_HashCode *key,
2279void 2280void
2280GDS_NEIGHBOURS_send_get_result (const struct GNUNET_HashCode *key, 2281GDS_NEIGHBOURS_send_get_result (const struct GNUNET_HashCode *key,
2281 enum GNUNET_BLOCK_Type type, 2282 enum GNUNET_BLOCK_Type type,
2282 struct GNUNET_PeerIdentity *target_peer, 2283 const struct GNUNET_PeerIdentity *target_peer,
2283 struct GNUNET_PeerIdentity *source_peer, 2284 const struct GNUNET_PeerIdentity *source_peer,
2284 unsigned int put_path_length, 2285 unsigned int put_path_length,
2285 const struct GNUNET_PeerIdentity *put_path, 2286 const struct GNUNET_PeerIdentity *put_path,
2286 unsigned int get_path_length, 2287 unsigned int get_path_length,
2287 struct GNUNET_PeerIdentity *get_path, 2288 const struct GNUNET_PeerIdentity *get_path,
2288 struct GNUNET_TIME_Absolute expiration, 2289 struct GNUNET_TIME_Absolute expiration,
2289 const void *data, size_t data_size) 2290 const void *data, size_t data_size)
2290{ 2291{
2291 struct PeerGetResultMessage *get_result; 2292 struct PeerGetResultMessage *get_result;
2292 struct GNUNET_PeerIdentity *get_result_path; 2293 struct GNUNET_PeerIdentity *paths;
2293 struct GNUNET_PeerIdentity *pp;
2294 struct P2PPendingMessage *pending; 2294 struct P2PPendingMessage *pending;
2295 struct FriendInfo *target_friend; 2295 struct FriendInfo *target_friend;
2296 int current_path_index; 2296 int current_path_index;
2297 size_t msize; 2297 size_t msize;
2298 2298
2299 msize = get_path_length * sizeof (struct GNUNET_PeerIdentity) + data_size + 2299 msize = (put_path_length + get_path_length )* sizeof (struct GNUNET_PeerIdentity) +
2300 sizeof (struct PeerPutMessage); 2300 data_size +
2301 sizeof (struct PeerGetResultMessage);
2301 2302
2302 if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) 2303 if (msize >= GNUNET_SERVER_MAX_MESSAGE_SIZE)
2303 { 2304 {
@@ -2305,7 +2306,7 @@ GDS_NEIGHBOURS_send_get_result (const struct GNUNET_HashCode *key,
2305 return; 2306 return;
2306 } 2307 }
2307 2308
2308 current_path_index = -1; 2309 current_path_index = 0;
2309 if(get_path_length > 0) 2310 if(get_path_length > 0)
2310 { 2311 {
2311 current_path_index = search_my_index(get_path, get_path_length); 2312 current_path_index = search_my_index(get_path, get_path_length);
@@ -2324,31 +2325,26 @@ GDS_NEIGHBOURS_send_get_result (const struct GNUNET_HashCode *key,
2324 } 2325 }
2325 2326
2326 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize); 2327 pending = GNUNET_malloc (sizeof (struct P2PPendingMessage) + msize);
2328 pending->timeout = GNUNET_TIME_relative_to_absolute (GET_TIMEOUT);
2327 pending->importance = 0; 2329 pending->importance = 0;
2328 get_result = (struct PeerGetResultMessage *)&pending[1]; 2330 get_result = (struct PeerGetResultMessage *)&pending[1];
2329 pending->msg = &get_result->header; 2331 pending->msg = &get_result->header;
2330 get_result->header.size = htons (msize); 2332 get_result->header.size = htons (msize);
2331 get_result->header.type = htons (GNUNET_MESSAGE_TYPE_XDHT_P2P_GET_RESULT); 2333 get_result->header.type = htons (GNUNET_MESSAGE_TYPE_XDHT_P2P_GET_RESULT);
2332 get_result->key = *key; 2334 get_result->key = *key;
2333 /* FIXME: check if you are passing the correct querying_peer as described in 2335 get_result->querying_peer = *source_peer;
2334 the get_result documentation. */
2335 memcpy (&(get_result->querying_peer), source_peer, sizeof (struct GNUNET_PeerIdentity));
2336 get_result->expiration_time = expiration; 2336 get_result->expiration_time = expiration;
2337 get_result_path = (struct GNUNET_PeerIdentity *)&get_result[1]; 2337 get_result->get_path_length = htonl (get_path_length);
2338 if (get_path_length != 0) 2338 get_result->put_path_length = htonl (put_path_length);
2339 memcpy (get_result_path, get_path, 2339 paths = (struct GNUNET_PeerIdentity *)&get_result[1];
2340 sizeof (struct GNUNET_PeerIdentity) * get_path_length); 2340 memcpy (paths, put_path,
2341 memcpy (&get_result_path[get_path_length], data, data_size); 2341 put_path_length * sizeof (struct GNUNET_PeerIdentity));
2342 2342 memcpy (&paths[put_path_length], get_path,
2343 /* FIXME: Is this correct? */ 2343 get_path_length * sizeof (struct GNUNET_PeerIdentity));
2344 if (put_path_length != 0) 2344 memcpy (&paths[put_path_length + get_path_length], data, data_size);
2345 {
2346 pp = (struct GNUNET_PeerIdentity *)&get_result_path[1];
2347 memcpy (pp, put_path,sizeof (struct GNUNET_PeerIdentity) * put_path_length);
2348 }
2349 2345
2350 target_friend = GNUNET_CONTAINER_multipeermap_get (friend_peermap, 2346 target_friend = GNUNET_CONTAINER_multipeermap_get (friend_peermap,
2351 &get_result_path[current_path_index - 1]); 2347 &get_path[current_path_index - 1]);
2352 GNUNET_CONTAINER_DLL_insert_tail (target_friend->head, target_friend->tail, pending); 2348 GNUNET_CONTAINER_DLL_insert_tail (target_friend->head, target_friend->tail, pending);
2353 target_friend->pending_count++; 2349 target_friend->pending_count++;
2354 process_friend_queue (target_friend); 2350 process_friend_queue (target_friend);
@@ -3529,7 +3525,7 @@ handle_dht_p2p_put (void *cls, const struct GNUNET_PeerIdentity *peer,
3529 payload, 3525 payload,
3530 payload_size); 3526 payload_size);
3531 3527
3532 if (0 == GNUNET_CRYPTO_cmp_peer_identity(&my_identity, &best_known_dest)) /* I am the final destination */ 3528 if (0 == GNUNET_CRYPTO_cmp_peer_identity (&my_identity, &best_known_dest)) /* I am the final destination */
3533 { 3529 {
3534 GDS_DATACACHE_handle_put (GNUNET_TIME_absolute_ntoh (put->expiration_time), 3530 GDS_DATACACHE_handle_put (GNUNET_TIME_absolute_ntoh (put->expiration_time),
3535 &(put->key),putlen, pp, ntohl (put->block_type), 3531 &(put->key),putlen, pp, ntohl (put->block_type),
@@ -3602,10 +3598,11 @@ handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer,
3602 struct GNUNET_PeerIdentity gp[get_length + 1]; 3598 struct GNUNET_PeerIdentity gp[get_length + 1];
3603 if (get_length > 0) 3599 if (get_length > 0)
3604 memcpy (gp, get_path, get_length * sizeof (struct GNUNET_PeerIdentity)); 3600 memcpy (gp, get_path, get_length * sizeof (struct GNUNET_PeerIdentity));
3605 gp[get_length + 1] = *peer; 3601 gp[get_length] = *peer;
3606 get_length = get_length + 1; 3602 get_length = get_length + 1;
3607 3603
3608 memcpy (&key_value, &(get->key), sizeof (uint64_t)); 3604 memcpy (&key_value, &(get->key), sizeof (uint64_t));
3605 key_value = GNUNET_ntohll (key_value);
3609 3606
3610 /* I am not the final destination. I am part of trail to reach final dest. */ 3607 /* I am not the final destination. I am part of trail to reach final dest. */
3611 if (0 != (GNUNET_CRYPTO_cmp_peer_identity (&best_known_dest, &my_identity))) 3608 if (0 != (GNUNET_CRYPTO_cmp_peer_identity (&best_known_dest, &my_identity)))
@@ -3628,7 +3625,9 @@ handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer,
3628 1, GNUNET_NO); 3625 1, GNUNET_NO);
3629 return GNUNET_SYSERR; 3626 return GNUNET_SYSERR;
3630 } 3627 }
3631 3628 GDS_CLIENTS_process_get (get->options, get->block_type,get->hop_count,
3629 get->desired_replication_level, get->get_path_length,
3630 gp, &get->key);
3632 /* I am the final destination. */ 3631 /* I am the final destination. */
3633 if (0 == GNUNET_CRYPTO_cmp_peer_identity(&my_identity, &best_known_dest)) 3632 if (0 == GNUNET_CRYPTO_cmp_peer_identity(&my_identity, &best_known_dest))
3634 { 3633 {
@@ -3636,7 +3635,7 @@ handle_dht_p2p_get (void *cls, const struct GNUNET_PeerIdentity *peer,
3636 struct GNUNET_PeerIdentity next_hop; 3635 struct GNUNET_PeerIdentity next_hop;
3637 3636
3638 memcpy (final_get_path, gp, get_length * sizeof (struct GNUNET_PeerIdentity)); 3637 memcpy (final_get_path, gp, get_length * sizeof (struct GNUNET_PeerIdentity));
3639 memcpy (&final_get_path[get_length+1], &my_identity, sizeof (struct GNUNET_PeerIdentity)); 3638 memcpy (&final_get_path[get_length], &my_identity, sizeof (struct GNUNET_PeerIdentity));
3640 get_length = get_length + 1; 3639 get_length = get_length + 1;
3641 3640
3642 /* Get the next hop to pass the get result message. */ 3641 /* Get the next hop to pass the get result message. */
@@ -3669,10 +3668,10 @@ static int
3669handle_dht_p2p_get_result (void *cls, const struct GNUNET_PeerIdentity *peer, 3668handle_dht_p2p_get_result (void *cls, const struct GNUNET_PeerIdentity *peer,
3670 const struct GNUNET_MessageHeader *message) 3669 const struct GNUNET_MessageHeader *message)
3671{ 3670{
3672 struct PeerGetResultMessage *get_result; 3671 const struct PeerGetResultMessage *get_result;
3673 struct GNUNET_PeerIdentity *get_path; 3672 const struct GNUNET_PeerIdentity *get_path;
3674 struct GNUNET_PeerIdentity *put_path; 3673 const struct GNUNET_PeerIdentity *put_path;
3675 void *payload; 3674 const void *payload;
3676 size_t payload_size; 3675 size_t payload_size;
3677 size_t msize; 3676 size_t msize;
3678 unsigned int getlen; 3677 unsigned int getlen;
@@ -3685,8 +3684,8 @@ handle_dht_p2p_get_result (void *cls, const struct GNUNET_PeerIdentity *peer,
3685 GNUNET_break_op (0); 3684 GNUNET_break_op (0);
3686 return GNUNET_YES; 3685 return GNUNET_YES;
3687 } 3686 }
3688 3687
3689 get_result = (struct PeerGetResultMessage *)message; 3688 get_result = (const struct PeerGetResultMessage *)message;
3690 getlen = ntohl (get_result->get_path_length); 3689 getlen = ntohl (get_result->get_path_length);
3691 putlen = ntohl (get_result->put_path_length); 3690 putlen = ntohl (get_result->put_path_length);
3692 3691
@@ -3703,14 +3702,12 @@ handle_dht_p2p_get_result (void *cls, const struct GNUNET_PeerIdentity *peer,
3703 return GNUNET_YES; 3702 return GNUNET_YES;
3704 } 3703 }
3705 3704
3706 get_path = (struct GNUNET_PeerIdentity *) &get_result[1]; 3705 put_path = (const struct GNUNET_PeerIdentity *) &get_result[1];
3707 payload = &get_path[getlen]; 3706 get_path = &put_path[putlen];
3707 payload = (const void *) &get_path[getlen];
3708 payload_size = msize - (sizeof (struct PeerGetResultMessage) + 3708 payload_size = msize - (sizeof (struct PeerGetResultMessage) +
3709 getlen * sizeof (struct GNUNET_PeerIdentity)); 3709 (getlen + putlen) * sizeof (struct GNUNET_PeerIdentity));
3710 3710
3711
3712 put_path = &get_path[1];
3713
3714 if (0 == (GNUNET_CRYPTO_cmp_peer_identity (&my_identity, &(get_path[0])))) 3711 if (0 == (GNUNET_CRYPTO_cmp_peer_identity (&my_identity, &(get_path[0]))))
3715 { 3712 {
3716 GDS_CLIENTS_handle_reply (get_result->expiration_time, &(get_result->key), 3713 GDS_CLIENTS_handle_reply (get_result->expiration_time, &(get_result->key),
@@ -3721,7 +3718,7 @@ handle_dht_p2p_get_result (void *cls, const struct GNUNET_PeerIdentity *peer,
3721 else 3718 else
3722 { 3719 {
3723 current_path_index = search_my_index (get_path, getlen); 3720 current_path_index = search_my_index (get_path, getlen);
3724 if (GNUNET_SYSERR == current_path_index ) 3721 if (-1 == current_path_index )
3725 { 3722 {
3726 GNUNET_break (0); 3723 GNUNET_break (0);
3727 return GNUNET_SYSERR; 3724 return GNUNET_SYSERR;
@@ -5411,10 +5408,6 @@ core_init (void *cls,
5411 my_identity = *identity; 5408 my_identity = *identity;
5412 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 5409 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
5413 "my_indentity = %s\n",GNUNET_i2s(&my_identity)); 5410 "my_indentity = %s\n",GNUNET_i2s(&my_identity));
5414#if 0
5415 FPRINTF (stderr,_("\nSUPU %s, %s, %d, my_identity = %s"),
5416 __FILE__, __func__,__LINE__, GNUNET_i2s (&my_identity));
5417#endif
5418} 5411}
5419 5412
5420 5413
diff --git a/src/dht/gnunet-service-xdht_neighbours.h b/src/dht/gnunet-service-xdht_neighbours.h
index a72f92984..fbb8cf5f8 100644
--- a/src/dht/gnunet-service-xdht_neighbours.h
+++ b/src/dht/gnunet-service-xdht_neighbours.h
@@ -109,12 +109,12 @@ GDS_NEIGHBOURS_send_get (const struct GNUNET_HashCode *key,
109void 109void
110GDS_NEIGHBOURS_send_get_result (const struct GNUNET_HashCode *key, 110GDS_NEIGHBOURS_send_get_result (const struct GNUNET_HashCode *key,
111 enum GNUNET_BLOCK_Type type, 111 enum GNUNET_BLOCK_Type type,
112 struct GNUNET_PeerIdentity *target_peer, 112 const struct GNUNET_PeerIdentity *target_peer,
113 struct GNUNET_PeerIdentity *source_peer, 113 const struct GNUNET_PeerIdentity *source_peer,
114 unsigned int put_path_length, 114 unsigned int put_path_length,
115 const struct GNUNET_PeerIdentity *put_path, 115 const struct GNUNET_PeerIdentity *put_path,
116 unsigned int get_path_length, 116 unsigned int get_path_length,
117 struct GNUNET_PeerIdentity *get_path, 117 const struct GNUNET_PeerIdentity *get_path,
118 struct GNUNET_TIME_Absolute expiration, 118 struct GNUNET_TIME_Absolute expiration,
119 const void *data, size_t data_size); 119 const void *data, size_t data_size);
120 120