gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r13150 - in gnunet: . src/dht


From: gnunet
Subject: [GNUnet-SVN] r13150 - in gnunet: . src/dht
Date: Mon, 4 Oct 2010 22:22:32 +0200

Author: grothoff
Date: 2010-10-04 22:22:32 +0200 (Mon, 04 Oct 2010)
New Revision: 13150

Modified:
   gnunet/TODO
   gnunet/src/dht/dht.h
   gnunet/src/dht/dht_api.c
   gnunet/src/dht/gnunet-service-dht.c
Log:
client-side path tracking support

Modified: gnunet/TODO
===================================================================
--- gnunet/TODO 2010-10-04 18:20:48 UTC (rev 13149)
+++ gnunet/TODO 2010-10-04 20:22:32 UTC (rev 13150)
@@ -5,8 +5,8 @@
   - integrate with DHT (need DHT API to fit block API better first; also, get 
rid of the continuation!)
 * DHT: [Nate]
   - use new block lib in service
-  - provide block-lib compatible API in gnunet_dht_service.h
-  - eliminate continuations in DHT API (not needed, we have auto-retransmit!)
+  - track paths content travels (PUT, reply-to-get) in messages,
+    pass to client (client API & protocol already support this!)
 * CORE:
   - authentication of ciphertexts [Nils]
   - Jun 27 11:51:54 core-7670 ERROR Assertion failed at 
gnunet-service-core.c:3616.

Modified: gnunet/src/dht/dht.h
===================================================================
--- gnunet/src/dht/dht.h        2010-10-04 18:20:48 UTC (rev 13149)
+++ gnunet/src/dht/dht.h        2010-10-04 20:22:32 UTC (rev 13150)
@@ -212,11 +212,20 @@
   struct GNUNET_MessageHeader header;
 
   /**
-   * For alignment, always zero.
+   * Number of peers recorded in the "PUT" path.
+   * (original path message took during "PUT").  These
+   * peer identities follow this message.
    */
-  uint32_t reserved GNUNET_PACKED;
+  uint16_t put_path_length GNUNET_PACKED;
 
   /**
+   * Number of peers recorded in the "GET" path
+   * (inverse of the path the GET message took).  These
+   * peer identities follow this message.
+   */
+  uint16_t get_path_length GNUNET_PACKED;
+
+  /**
    * Unique ID identifying this request (necessary for
    * client to compare to sent requests)
    */
@@ -227,6 +236,10 @@
    */
   GNUNET_HashCode key;
 
+  /* PUT path */
+
+  /* GET path */
+
   /* GNUNET_MessageHeader *enc actual DHT message, copied to end of this dealy 
do */
 };
 
@@ -242,6 +255,11 @@
   struct GNUNET_MessageHeader header;
 
   /**
+   * Always zero.
+   */
+  uint32_t reserved GNUNET_PACKED;
+
+  /**
    * Message options
    */
   uint32_t options GNUNET_PACKED;
@@ -252,14 +270,14 @@
   uint32_t hop_count GNUNET_PACKED;
 
   /**
-   * Network size estimate
+   * Replication level for this message
    */
-  uint32_t network_size GNUNET_PACKED;
+  uint32_t desired_replication_level GNUNET_PACKED;
 
   /**
-   * Replication level for this message
+   * Network size estimate
    */
-  uint32_t desired_replication_level GNUNET_PACKED;
+  uint32_t network_size GNUNET_PACKED;
 
   /**
    * Unique ID identifying this request
@@ -298,6 +316,20 @@
   struct GNUNET_MessageHeader header;
 
   /**
+   * Number of peers recorded in the "PUT" path.
+   * (original path message took during "PUT").  These
+   * peer identities follow this message.
+   */
+  uint16_t put_path_length GNUNET_PACKED;
+
+  /**
+   * Number of peers recorded in the "GET" path
+   * (inverse of the path the GET message took).  These
+   * peer identities follow this message.
+   */
+  uint16_t get_path_length GNUNET_PACKED;
+
+  /**
    * Message options
    */
   uint32_t options GNUNET_PACKED;
@@ -329,6 +361,11 @@
   uint32_t network_size GNUNET_PACKED;
 #endif
 
+
+  /* PUT path */
+
+  /* GET path */
+
   /* GNUNET_MessageHeader *enc actual DHT message, copied to end of this dealy 
do */
 };
 

Modified: gnunet/src/dht/dht_api.c
===================================================================
--- gnunet/src/dht/dht_api.c    2010-10-04 18:20:48 UTC (rev 13149)
+++ gnunet/src/dht/dht_api.c    2010-10-04 20:22:32 UTC (rev 13150)
@@ -398,8 +398,12 @@
   const struct GNUNET_MessageHeader *enc_msg;
   size_t enc_size;
   uint64_t uid;
-  const struct GNUNET_PeerIdentity *const*get_path;
-  const struct GNUNET_PeerIdentity *const*put_path;
+  const struct GNUNET_PeerIdentity **get_path;
+  const struct GNUNET_PeerIdentity **put_path;
+  const struct GNUNET_PeerIdentity *pos;
+  uint16_t gpl;
+  uint16_t ppl;
+  unsigned int i;
 
   uid = GNUNET_ntohll (dht_msg->unique_id);
   if (uid != rh->uid)
@@ -414,21 +418,56 @@
       GNUNET_break (0);
       return GNUNET_NO;
     }
-  enc_msg = (const struct GNUNET_MessageHeader *) &dht_msg[1];
+  pos = (const struct GNUNET_PeerIdentity *) &dht_msg[1];
+  ppl = ntohs (dht_msg->put_path_length);
+  gpl = ntohs (dht_msg->get_path_length);
+  if ( (ppl + gpl) * sizeof (struct GNUNET_PeerIdentity) > enc_size)
+    {
+      GNUNET_break (0);
+      return GNUNET_NO;
+    }
+  if (ppl > 0)
+    {
+      put_path = GNUNET_malloc ((ppl+1) * sizeof (struct 
GNUNET_PeerIdentity*));
+      for (i=0;i<ppl;i++)
+       {
+         put_path[i] = pos;
+         pos++;
+       }
+      put_path[ppl] = NULL;
+    }
+  else
+    put_path = NULL;
+  if (gpl > 0)
+    {
+      get_path = GNUNET_malloc ((gpl+1) * sizeof (struct 
GNUNET_PeerIdentity*));
+      for (i=0;i<gpl;i++)
+       {
+         get_path[i] = pos;
+         pos++;
+       }
+      get_path[gpl] = NULL;
+    }
+  else
+    get_path = NULL;
+  enc_size -= (ppl + gpl) * sizeof (struct GNUNET_PeerIdentity);
+  enc_msg = (const struct GNUNET_MessageHeader *) pos;
   if (enc_size != ntohs (enc_msg->size))
     {
       GNUNET_break (0);
+      GNUNET_free_non_null (get_path);
+      GNUNET_free_non_null (put_path);
       return GNUNET_NO;
     }
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Processing reply.\n");
-  get_path = NULL; // FIXME: parse path info!
-  put_path = NULL; // FIXME: parse path info!
   rh->iter (rh->iter_cls, 
            &rh->key,
            get_path,
            put_path,
            enc_msg);
+  GNUNET_free_non_null (get_path);
+  GNUNET_free_non_null (put_path);
   return GNUNET_YES;
 }
 

Modified: gnunet/src/dht/gnunet-service-dht.c
===================================================================
--- gnunet/src/dht/gnunet-service-dht.c 2010-10-04 18:20:48 UTC (rev 13149)
+++ gnunet/src/dht/gnunet-service-dht.c 2010-10-04 20:22:32 UTC (rev 13150)
@@ -1024,10 +1024,11 @@
  * @param peer the peer to forward the message to
  * @param msg_ctx the context of the message (hop count, bloom, etc.)
  */
-static void forward_result_message (void *cls,
-                                    const struct GNUNET_MessageHeader *msg,
-                                    struct PeerInfo *peer,
-                                    struct DHT_MessageContext *msg_ctx)
+static void 
+forward_result_message (void *cls,
+                       const struct GNUNET_MessageHeader *msg,
+                       struct PeerInfo *peer,
+                       struct DHT_MessageContext *msg_ctx)
 {
   struct GNUNET_DHT_P2PRouteResultMessage *result_message;
   struct P2PPendingMessage *pending;
@@ -1045,6 +1046,8 @@
   result_message = (struct GNUNET_DHT_P2PRouteResultMessage *)pending->msg;
   result_message->header.size = htons(msize);
   result_message->header.type = 
htons(GNUNET_MESSAGE_TYPE_DHT_P2P_ROUTE_RESULT);
+  result_message->put_path_length = htons(0); /* FIXME: implement */
+  result_message->get_path_length = htons(0); /* FIXME: implement */
   result_message->options = htonl(msg_ctx->msg_options);
   result_message->hop_count = htonl(msg_ctx->hop_count + 1);
   GNUNET_assert(GNUNET_OK == 
GNUNET_CONTAINER_bloomfilter_get_raw_data(msg_ctx->bloom, 
result_message->bloomfilter, DHT_BLOOM_SIZE));
@@ -1882,7 +1885,8 @@
   reply = (struct GNUNET_DHT_RouteResultMessage *)&pending_message[1];
   reply->header.type = htons (GNUNET_MESSAGE_TYPE_DHT_LOCAL_ROUTE_RESULT);
   reply->header.size = htons (tsize);
-  reply->reserved = 0;
+  reply->put_path_length = htons(0); /* FIXME: implement */
+  reply->get_path_length = htons(0); /* FIXME: implement */
   reply->unique_id = GNUNET_htonll (uid);
   reply->key = *key;
   memcpy (&reply[1], message, msize);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]