add method to record and print DHT routes to DHT command-line tools
authorChristian Grothoff <christian@grothoff.org>
Tue, 31 Jan 2017 13:44:41 +0000 (14:44 +0100)
committerChristian Grothoff <christian@grothoff.org>
Tue, 31 Jan 2017 13:44:41 +0000 (14:44 +0100)
src/dht/gnunet-dht-get.c
src/dht/gnunet-dht-put.c

index 8a1b836f67798fb1acaa51493fdb77cf38531ffc..ce479dc3e240c74f19ab7a82f65aa3952bab832a 100644 (file)
@@ -148,13 +148,36 @@ get_result_iterator (void *cls, struct GNUNET_TIME_Absolute exp,
                      const struct GNUNET_PeerIdentity *get_path,
                      unsigned int get_path_length,
                      const struct GNUNET_PeerIdentity *put_path,
-                     unsigned int put_path_length, enum GNUNET_BLOCK_Type type,
-                     size_t size, const void *data)
+                     unsigned int put_path_length,
+                     enum GNUNET_BLOCK_Type type,
+                     size_t size,
+                     const void *data)
 {
   FPRINTF (stdout,
           _("Result %d, type %d:\n%.*s\n"),
-          result_count, type,
-           (unsigned int) size, (char *) data);
+          result_count,
+           type,
+           (unsigned int) size,
+           (char *) data);
+  if (verbose)
+  {
+    FPRINTF (stdout,
+             "  GET path: ");
+    for (unsigned int i=0;i<get_path_length;i++)
+      FPRINTF (stdout,
+               "%s%s",
+               (0 == i) ? "" : "-",
+               GNUNET_i2s (&get_path[i]));
+    FPRINTF (stdout,
+             "\n  PUT path: ");
+    for (unsigned int i=0;i<put_path_length;i++)
+      FPRINTF (stdout,
+               "%s%s",
+               (0 == i) ? "" : "-",
+               GNUNET_i2s (&put_path[i]));
+    FPRINTF (stdout,
+             "\n");
+  }
   result_count++;
 }
 
index 1f3df1d351856fa173254024772bef88f754cc9a..9b17da01f6cd7db737e6271e5ef068076b04bac5 100644 (file)
@@ -57,10 +57,15 @@ static unsigned int replication = 5;
 static int verbose;
 
 /**
- * Use DHT demultixplex_everywhere
+ * Use #GNUNET_DHT_DEMULTIPLEX_EVERYWHERE.
  */
 static int demultixplex_everywhere;
 
+/**
+ * Use #GNUNET_DHT_RO_RECORD_ROUTE.
+ */
+static int record_route;
+
 /**
  * Handle to the DHT
  */
@@ -144,6 +149,7 @@ run (void *cls,
      const struct GNUNET_CONFIGURATION_Handle *c)
 {
   struct GNUNET_TIME_Absolute expiration;
+  enum GNUNET_DHT_RouteOption ro;
 
   cfg = c;
   if ((NULL == query_key) || (NULL == data))
@@ -171,10 +177,15 @@ run (void *cls,
   if (verbose)
     FPRINTF (stderr, _("Issuing put request for `%s' with data `%s'!\n"),
              query_key, data);
+  ro = GNUNET_DHT_RO_NONE;
+  if (demultixplex_everywhere)
+    ro |= GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE;
+  if (record_route)
+    ro |= GNUNET_DHT_RO_RECORD_ROUTE;
   GNUNET_DHT_put (dht_handle,
                   &key,
                   replication,
-                  (demultixplex_everywhere) ? GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE : GNUNET_DHT_RO_NONE,
+                  ro,
                   query_type,
                   strlen (data),
                   data,
@@ -203,6 +214,9 @@ static struct GNUNET_GETOPT_CommandLineOption options[] = {
   {'r', "replication", "LEVEL",
    gettext_noop ("how many replicas to create"),
    1, &GNUNET_GETOPT_set_uint, &replication},
+  {'R', "record", NULL,
+   gettext_noop ("use DHT's record route option"),
+   0, &GNUNET_GETOPT_set_one, &record_route},
   {'t', "type", "TYPE",
    gettext_noop ("the type to insert data as"),
    1, &GNUNET_GETOPT_set_uint, &query_type},