aboutsummaryrefslogtreecommitdiff
path: root/src/dht/dht_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dht/dht_api.c')
-rw-r--r--src/dht/dht_api.c49
1 files changed, 44 insertions, 5 deletions
diff --git a/src/dht/dht_api.c b/src/dht/dht_api.c
index 0dd40a735..62078b5cf 100644
--- a/src/dht/dht_api.c
+++ b/src/dht/dht_api.c
@@ -398,8 +398,12 @@ process_reply (void *cls,
398 const struct GNUNET_MessageHeader *enc_msg; 398 const struct GNUNET_MessageHeader *enc_msg;
399 size_t enc_size; 399 size_t enc_size;
400 uint64_t uid; 400 uint64_t uid;
401 const struct GNUNET_PeerIdentity *const*get_path; 401 const struct GNUNET_PeerIdentity **get_path;
402 const struct GNUNET_PeerIdentity *const*put_path; 402 const struct GNUNET_PeerIdentity **put_path;
403 const struct GNUNET_PeerIdentity *pos;
404 uint16_t gpl;
405 uint16_t ppl;
406 unsigned int i;
403 407
404 uid = GNUNET_ntohll (dht_msg->unique_id); 408 uid = GNUNET_ntohll (dht_msg->unique_id);
405 if (uid != rh->uid) 409 if (uid != rh->uid)
@@ -414,21 +418,56 @@ process_reply (void *cls,
414 GNUNET_break (0); 418 GNUNET_break (0);
415 return GNUNET_NO; 419 return GNUNET_NO;
416 } 420 }
417 enc_msg = (const struct GNUNET_MessageHeader *) &dht_msg[1]; 421 pos = (const struct GNUNET_PeerIdentity *) &dht_msg[1];
422 ppl = ntohs (dht_msg->put_path_length);
423 gpl = ntohs (dht_msg->get_path_length);
424 if ( (ppl + gpl) * sizeof (struct GNUNET_PeerIdentity) > enc_size)
425 {
426 GNUNET_break (0);
427 return GNUNET_NO;
428 }
429 if (ppl > 0)
430 {
431 put_path = GNUNET_malloc ((ppl+1) * sizeof (struct GNUNET_PeerIdentity*));
432 for (i=0;i<ppl;i++)
433 {
434 put_path[i] = pos;
435 pos++;
436 }
437 put_path[ppl] = NULL;
438 }
439 else
440 put_path = NULL;
441 if (gpl > 0)
442 {
443 get_path = GNUNET_malloc ((gpl+1) * sizeof (struct GNUNET_PeerIdentity*));
444 for (i=0;i<gpl;i++)
445 {
446 get_path[i] = pos;
447 pos++;
448 }
449 get_path[gpl] = NULL;
450 }
451 else
452 get_path = NULL;
453 enc_size -= (ppl + gpl) * sizeof (struct GNUNET_PeerIdentity);
454 enc_msg = (const struct GNUNET_MessageHeader *) pos;
418 if (enc_size != ntohs (enc_msg->size)) 455 if (enc_size != ntohs (enc_msg->size))
419 { 456 {
420 GNUNET_break (0); 457 GNUNET_break (0);
458 GNUNET_free_non_null (get_path);
459 GNUNET_free_non_null (put_path);
421 return GNUNET_NO; 460 return GNUNET_NO;
422 } 461 }
423 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 462 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
424 "Processing reply.\n"); 463 "Processing reply.\n");
425 get_path = NULL; // FIXME: parse path info!
426 put_path = NULL; // FIXME: parse path info!
427 rh->iter (rh->iter_cls, 464 rh->iter (rh->iter_cls,
428 &rh->key, 465 &rh->key,
429 get_path, 466 get_path,
430 put_path, 467 put_path,
431 enc_msg); 468 enc_msg);
469 GNUNET_free_non_null (get_path);
470 GNUNET_free_non_null (put_path);
432 return GNUNET_YES; 471 return GNUNET_YES;
433} 472}
434 473