aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO4
-rw-r--r--src/dht/dht.h49
-rw-r--r--src/dht/dht_api.c49
-rw-r--r--src/dht/gnunet-service-dht.c14
4 files changed, 98 insertions, 18 deletions
diff --git a/TODO b/TODO
index c1154ca65..be292e2bf 100644
--- a/TODO
+++ b/TODO
@@ -5,8 +5,8 @@
5 - integrate with DHT (need DHT API to fit block API better first; also, get rid of the continuation!) 5 - integrate with DHT (need DHT API to fit block API better first; also, get rid of the continuation!)
6* DHT: [Nate] 6* DHT: [Nate]
7 - use new block lib in service 7 - use new block lib in service
8 - provide block-lib compatible API in gnunet_dht_service.h 8 - track paths content travels (PUT, reply-to-get) in messages,
9 - eliminate continuations in DHT API (not needed, we have auto-retransmit!) 9 pass to client (client API & protocol already support this!)
10* CORE: 10* CORE:
11 - authentication of ciphertexts [Nils] 11 - authentication of ciphertexts [Nils]
12 - Jun 27 11:51:54 core-7670 ERROR Assertion failed at gnunet-service-core.c:3616. 12 - Jun 27 11:51:54 core-7670 ERROR Assertion failed at gnunet-service-core.c:3616.
diff --git a/src/dht/dht.h b/src/dht/dht.h
index 63e95e113..9c2e889a7 100644
--- a/src/dht/dht.h
+++ b/src/dht/dht.h
@@ -212,9 +212,18 @@ struct GNUNET_DHT_RouteResultMessage
212 struct GNUNET_MessageHeader header; 212 struct GNUNET_MessageHeader header;
213 213
214 /** 214 /**
215 * For alignment, always zero. 215 * Number of peers recorded in the "PUT" path.
216 * (original path message took during "PUT"). These
217 * peer identities follow this message.
216 */ 218 */
217 uint32_t reserved GNUNET_PACKED; 219 uint16_t put_path_length GNUNET_PACKED;
220
221 /**
222 * Number of peers recorded in the "GET" path
223 * (inverse of the path the GET message took). These
224 * peer identities follow this message.
225 */
226 uint16_t get_path_length GNUNET_PACKED;
218 227
219 /** 228 /**
220 * Unique ID identifying this request (necessary for 229 * Unique ID identifying this request (necessary for
@@ -227,6 +236,10 @@ struct GNUNET_DHT_RouteResultMessage
227 */ 236 */
228 GNUNET_HashCode key; 237 GNUNET_HashCode key;
229 238
239 /* PUT path */
240
241 /* GET path */
242
230 /* GNUNET_MessageHeader *enc actual DHT message, copied to end of this dealy do */ 243 /* GNUNET_MessageHeader *enc actual DHT message, copied to end of this dealy do */
231}; 244};
232 245
@@ -242,6 +255,11 @@ struct GNUNET_DHT_P2PRouteMessage
242 struct GNUNET_MessageHeader header; 255 struct GNUNET_MessageHeader header;
243 256
244 /** 257 /**
258 * Always zero.
259 */
260 uint32_t reserved GNUNET_PACKED;
261
262 /**
245 * Message options 263 * Message options
246 */ 264 */
247 uint32_t options GNUNET_PACKED; 265 uint32_t options GNUNET_PACKED;
@@ -252,14 +270,14 @@ struct GNUNET_DHT_P2PRouteMessage
252 uint32_t hop_count GNUNET_PACKED; 270 uint32_t hop_count GNUNET_PACKED;
253 271
254 /** 272 /**
255 * Network size estimate 273 * Replication level for this message
256 */ 274 */
257 uint32_t network_size GNUNET_PACKED; 275 uint32_t desired_replication_level GNUNET_PACKED;
258 276
259 /** 277 /**
260 * Replication level for this message 278 * Network size estimate
261 */ 279 */
262 uint32_t desired_replication_level GNUNET_PACKED; 280 uint32_t network_size GNUNET_PACKED;
263 281
264 /** 282 /**
265 * Unique ID identifying this request 283 * Unique ID identifying this request
@@ -298,6 +316,20 @@ struct GNUNET_DHT_P2PRouteResultMessage
298 struct GNUNET_MessageHeader header; 316 struct GNUNET_MessageHeader header;
299 317
300 /** 318 /**
319 * Number of peers recorded in the "PUT" path.
320 * (original path message took during "PUT"). These
321 * peer identities follow this message.
322 */
323 uint16_t put_path_length GNUNET_PACKED;
324
325 /**
326 * Number of peers recorded in the "GET" path
327 * (inverse of the path the GET message took). These
328 * peer identities follow this message.
329 */
330 uint16_t get_path_length GNUNET_PACKED;
331
332 /**
301 * Message options 333 * Message options
302 */ 334 */
303 uint32_t options GNUNET_PACKED; 335 uint32_t options GNUNET_PACKED;
@@ -329,6 +361,11 @@ struct GNUNET_DHT_P2PRouteResultMessage
329 uint32_t network_size GNUNET_PACKED; 361 uint32_t network_size GNUNET_PACKED;
330#endif 362#endif
331 363
364
365 /* PUT path */
366
367 /* GET path */
368
332 /* GNUNET_MessageHeader *enc actual DHT message, copied to end of this dealy do */ 369 /* GNUNET_MessageHeader *enc actual DHT message, copied to end of this dealy do */
333}; 370};
334 371
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
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c
index c03e0b1ac..48661fd88 100644
--- a/src/dht/gnunet-service-dht.c
+++ b/src/dht/gnunet-service-dht.c
@@ -1024,10 +1024,11 @@ try_core_send (void *cls,
1024 * @param peer the peer to forward the message to 1024 * @param peer the peer to forward the message to
1025 * @param msg_ctx the context of the message (hop count, bloom, etc.) 1025 * @param msg_ctx the context of the message (hop count, bloom, etc.)
1026 */ 1026 */
1027static void forward_result_message (void *cls, 1027static void
1028 const struct GNUNET_MessageHeader *msg, 1028forward_result_message (void *cls,
1029 struct PeerInfo *peer, 1029 const struct GNUNET_MessageHeader *msg,
1030 struct DHT_MessageContext *msg_ctx) 1030 struct PeerInfo *peer,
1031 struct DHT_MessageContext *msg_ctx)
1031{ 1032{
1032 struct GNUNET_DHT_P2PRouteResultMessage *result_message; 1033 struct GNUNET_DHT_P2PRouteResultMessage *result_message;
1033 struct P2PPendingMessage *pending; 1034 struct P2PPendingMessage *pending;
@@ -1045,6 +1046,8 @@ static void forward_result_message (void *cls,
1045 result_message = (struct GNUNET_DHT_P2PRouteResultMessage *)pending->msg; 1046 result_message = (struct GNUNET_DHT_P2PRouteResultMessage *)pending->msg;
1046 result_message->header.size = htons(msize); 1047 result_message->header.size = htons(msize);
1047 result_message->header.type = htons(GNUNET_MESSAGE_TYPE_DHT_P2P_ROUTE_RESULT); 1048 result_message->header.type = htons(GNUNET_MESSAGE_TYPE_DHT_P2P_ROUTE_RESULT);
1049 result_message->put_path_length = htons(0); /* FIXME: implement */
1050 result_message->get_path_length = htons(0); /* FIXME: implement */
1048 result_message->options = htonl(msg_ctx->msg_options); 1051 result_message->options = htonl(msg_ctx->msg_options);
1049 result_message->hop_count = htonl(msg_ctx->hop_count + 1); 1052 result_message->hop_count = htonl(msg_ctx->hop_count + 1);
1050 GNUNET_assert(GNUNET_OK == GNUNET_CONTAINER_bloomfilter_get_raw_data(msg_ctx->bloom, result_message->bloomfilter, DHT_BLOOM_SIZE)); 1053 GNUNET_assert(GNUNET_OK == GNUNET_CONTAINER_bloomfilter_get_raw_data(msg_ctx->bloom, result_message->bloomfilter, DHT_BLOOM_SIZE));
@@ -1882,7 +1885,8 @@ send_reply_to_client (struct ClientList *client,
1882 reply = (struct GNUNET_DHT_RouteResultMessage *)&pending_message[1]; 1885 reply = (struct GNUNET_DHT_RouteResultMessage *)&pending_message[1];
1883 reply->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_LOCAL_ROUTE_RESULT); 1886 reply->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_LOCAL_ROUTE_RESULT);
1884 reply->header.size = htons (tsize); 1887 reply->header.size = htons (tsize);
1885 reply->reserved = 0; 1888 reply->put_path_length = htons(0); /* FIXME: implement */
1889 reply->get_path_length = htons(0); /* FIXME: implement */
1886 reply->unique_id = GNUNET_htonll (uid); 1890 reply->unique_id = GNUNET_htonll (uid);
1887 reply->key = *key; 1891 reply->key = *key;
1888 memcpy (&reply[1], message, msize); 1892 memcpy (&reply[1], message, msize);