gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r12973 - in gnunet: . contrib src/block src/fs src/include


From: gnunet
Subject: [GNUnet-SVN] r12973 - in gnunet: . contrib src/block src/fs src/include src/util
Date: Mon, 13 Sep 2010 05:18:26 +0200

Author: grothoff
Date: 2010-09-13 05:18:26 +0200 (Mon, 13 Sep 2010)
New Revision: 12973

Added:
   gnunet/src/include/block_fs.h
Modified:
   gnunet/TODO
   gnunet/contrib/defaults.conf
   gnunet/src/block/block.c
   gnunet/src/block/plugin_block_fs.c
   gnunet/src/block/test_block.c
   gnunet/src/fs/
   gnunet/src/fs/fs.h
   gnunet/src/fs/gnunet-service-fs.c
   gnunet/src/include/Makefile.am
   gnunet/src/include/gnunet_block_lib.h
   gnunet/src/util/test_time.c
Log:
new block lib

Modified: gnunet/TODO
===================================================================
--- gnunet/TODO 2010-09-12 13:08:54 UTC (rev 12972)
+++ gnunet/TODO 2010-09-13 03:18:26 UTC (rev 12973)
@@ -1,14 +1,11 @@
 0.9.0pre2:
-* BLOCK:
-  - implement FS plugin
-  - design new block-lib API
+ FS:
   - move FS serivce to new block API
-* FS:
   - integrate with DHT
   - measure latencies (core, datastore) => trust economy
   - refuse content migration message (or solicit?)
   - FS performance benchmarking
-* DHT:
+* DHT: [Nate]
   - use new block lib
 * CORE:
   - derived key generation [Nils]
@@ -101,6 +98,8 @@
   - good to have for DHT evaluation!
 * DHT: [Nate]
   - performance tests
+* BLOCK:
+  - more testing (KBlock, SBlock, NBlock)
 
 0.9.1:
 * TRANSPORT: [MW]

Modified: gnunet/contrib/defaults.conf
===================================================================
--- gnunet/contrib/defaults.conf        2010-09-12 13:08:54 UTC (rev 12972)
+++ gnunet/contrib/defaults.conf        2010-09-13 03:18:26 UTC (rev 12973)
@@ -261,3 +261,6 @@
 # REJECT_FROM =
 # REJECT_FROM6 =
 # PREFIX =
+
+[block]
+PLUGINS = fs

Modified: gnunet/src/block/block.c
===================================================================
--- gnunet/src/block/block.c    2010-09-12 13:08:54 UTC (rev 12972)
+++ gnunet/src/block/block.c    2010-09-13 03:18:26 UTC (rev 12973)
@@ -29,207 +29,8 @@
 #include "gnunet_block_lib.h"
 #include "plugin_block.h"
 
-/**
- * Check if the given KBlock is well-formed.
- *
- * @param kb the kblock data (or at least "dsize" bytes claiming to be one)
- * @param dsize size of "kb" in bytes; check for < sizeof(struct KBlock)!
- * @param query where to store the query that this block answers
- * @return GNUNET_OK if this is actually a well-formed KBlock
- */
-static int
-check_kblock (const struct KBlock *kb,
-             size_t dsize,
-             GNUNET_HashCode *query)
-{
-  if (dsize < sizeof (struct KBlock))
-    {
-      GNUNET_break_op (0);
-      return GNUNET_SYSERR;
-    }
-  if (dsize - sizeof (struct KBlock) !=
-      ntohl (kb->purpose.size) 
-      - sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) 
-      - sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) ) 
-    {
-      GNUNET_break_op (0);
-      return GNUNET_SYSERR;
-    }
-  if (GNUNET_OK !=
-      GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_FS_KBLOCK,
-                               &kb->purpose,
-                               &kb->signature,
-                               &kb->keyspace)) 
-    {
-      GNUNET_break_op (0);
-      return GNUNET_SYSERR;
-    }
-  if (query != NULL)
-    GNUNET_CRYPTO_hash (&kb->keyspace,
-                       sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
-                       query);
-  return GNUNET_OK;
-}
 
-
 /**
- * Check if the given NBlock is well-formed.
- *
- * @param nb the nblock data (or at least "dsize" bytes claiming to be one)
- * @param dsize size of "nb" in bytes; check for < sizeof(struct NBlock)!
- * @param query where to store the query that this block answers
- * @return GNUNET_OK if this is actually a well-formed NBlock
- */
-static int
-check_nblock (const struct NBlock *nb,
-             size_t dsize,
-             GNUNET_HashCode *query)
-{
-  if (dsize < sizeof (struct NBlock))
-    {
-      GNUNET_break_op (0);
-      return GNUNET_SYSERR;
-    }
-  if (dsize - sizeof (struct NBlock) !=
-      ntohl (nb->ns_purpose.size) 
-      - sizeof (struct GNUNET_CRYPTO_RsaSignaturePurpose) 
-      - sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded) ) 
-    {
-      GNUNET_break_op (0);
-      return GNUNET_SYSERR;
-    }
-  if (dsize !=
-      ntohl (nb->ksk_purpose.size) + sizeof (struct 
GNUNET_CRYPTO_RsaSignature))
-    {
-      GNUNET_break_op (0);
-      return GNUNET_SYSERR;
-    }
-  if (GNUNET_OK !=
-      GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK_KSIG,
-                               &nb->ksk_purpose,
-                               &nb->ksk_signature,
-                               &nb->keyspace)) 
-    {
-      GNUNET_break_op (0);
-      return GNUNET_SYSERR;
-    }
-  if (GNUNET_OK !=
-      GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_FS_NBLOCK,
-                               &nb->ns_purpose,
-                               &nb->ns_signature,
-                               &nb->subspace)) 
-    {
-      GNUNET_break_op (0);
-      return GNUNET_SYSERR;
-    }
-  if (query != NULL)
-    GNUNET_CRYPTO_hash (&nb->keyspace,
-                       sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
-                       query);
-  return GNUNET_OK;
-}
-
-
-/**
- * Check if the given SBlock is well-formed.
- *
- * @param sb the sblock data (or at least "dsize" bytes claiming to be one)
- * @param dsize size of "kb" in bytes; check for < sizeof(struct SBlock)!
- * @param query where to store the query that this block answers
- * @return GNUNET_OK if this is actually a well-formed SBlock
- */
-static int
-check_sblock (const struct SBlock *sb,
-             size_t dsize,
-             GNUNET_HashCode *query)
-{
-  if (dsize < sizeof (struct SBlock))
-    {
-      GNUNET_break_op (0);
-      return GNUNET_SYSERR;
-    }
-  if (dsize !=
-      ntohl (sb->purpose.size) + sizeof (struct GNUNET_CRYPTO_RsaSignature))
-    {
-      GNUNET_break_op (0);
-      return GNUNET_SYSERR;
-    }
-  if (GNUNET_OK !=
-      GNUNET_CRYPTO_rsa_verify (GNUNET_SIGNATURE_PURPOSE_FS_SBLOCK,
-                               &sb->purpose,
-                               &sb->signature,
-                               &sb->subspace)) 
-    {
-      GNUNET_break_op (0);
-      return GNUNET_SYSERR;
-    }
-  if (query != NULL)
-    *query = sb->identifier;
-  return GNUNET_OK;
-}
-
-
-/**
- * Check if the given block is well-formed (and of the given type).
- *
- * @param type type of the block
- * @param block the block data (or at least "size" bytes claiming to be one)
- * @param size size of "kb" in bytes; check that it is large enough
- * @param query where to store the query that this block answers
- * @return GNUNET_OK if this is actually a well-formed block,
- *         GNUNET_NO if we could not determine the query,
- *         GNUNET_SYSERR if the block is malformed
- */
-int
-GNUNET_BLOCK_check_block (enum GNUNET_BLOCK_Type type,
-                         const void *block,
-                         size_t size,
-                         GNUNET_HashCode *query)
-{
-  /* first, validate! */
-  switch (type)
-    {
-    case GNUNET_BLOCK_TYPE_DBLOCK:
-    case GNUNET_BLOCK_TYPE_IBLOCK:
-      GNUNET_CRYPTO_hash (block, size, query);
-      break;
-    case GNUNET_BLOCK_TYPE_KBLOCK:
-      if (GNUNET_OK !=
-         check_kblock (block,
-                       size,
-                       query))
-       return GNUNET_SYSERR;
-      break;
-    case GNUNET_BLOCK_TYPE_SBLOCK:
-      if (GNUNET_OK !=
-         check_sblock (block,
-                       size,
-                       query))
-       return GNUNET_SYSERR;
-      break;
-    case GNUNET_BLOCK_TYPE_NBLOCK:
-      if (GNUNET_OK !=
-         check_nblock (block,
-                       size,
-                       query))
-       return GNUNET_SYSERR;
-      return GNUNET_OK;
-    case GNUNET_BLOCK_TYPE_ONDEMAND:
-      if (size != sizeof (struct OnDemandBlock))
-       return GNUNET_SYSERR;
-      memset (query, 0, sizeof (GNUNET_HashCode));      
-      return GNUNET_NO;
-    default:
-      /* unknown block type */
-      GNUNET_break_op (0);
-      return GNUNET_SYSERR;
-    }
-  return GNUNET_OK;
-}
-
-/* ***************** NEW API ******************* */
-
-/**
  * Handle for a plugin.
  */
 struct Plugin
@@ -272,12 +73,47 @@
 GNUNET_BLOCK_context_create (const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   struct GNUNET_BLOCK_Context *ctx;
+  struct GNUNET_BLOCK_PluginFunctions *api;
+  struct Plugin *plugin;
   unsigned int num_plugins;
+  char *plugs;
+  char *pos;
+  char *libname;
 
   ctx = GNUNET_malloc (sizeof (struct GNUNET_BLOCK_Context));
   ctx->cfg = cfg;
   num_plugins = 0;
-  /* FIXME: actually load plugins... */
+  if (GNUNET_OK ==
+      GNUNET_CONFIGURATION_get_value_string (cfg,
+                                             "block", "PLUGINS", &plugs))
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                  _("Loading block plugins `%s'\n"), plugs);
+      pos = strtok (plugs, " ");
+      while (pos != NULL)
+        {
+         GNUNET_asprintf (&libname, "libgnunet_plugin_block_%s", pos);
+         api = GNUNET_PLUGIN_load (libname, NULL);
+         if (api == NULL)
+           {
+             GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                         _("Failed to load block plugin `%s'\n"),
+                         pos);
+             GNUNET_free (libname);
+           }
+         else
+           {
+             plugin = GNUNET_malloc (sizeof (struct Plugin));
+             plugin->api = api;
+             plugin->library_name = libname;
+             GNUNET_array_append (ctx->plugins,
+                                  num_plugins,
+                                  plugin);
+           }
+          pos = strtok (NULL, " ");
+        }
+      GNUNET_free (plugs);
+    }
   GNUNET_array_append (ctx->plugins,
                       num_plugins,
                       NULL);

Modified: gnunet/src/block/plugin_block_fs.c
===================================================================
--- gnunet/src/block/plugin_block_fs.c  2010-09-12 13:08:54 UTC (rev 12972)
+++ gnunet/src/block/plugin_block_fs.c  2010-09-13 03:18:26 UTC (rev 12973)
@@ -26,6 +26,7 @@
 
 #include "platform.h"
 #include "plugin_block.h"
+#include "block_fs.h"
 #include "gnunet_signatures.h"
 
 #define DEBUG_FS_BLOCK GNUNET_NO
@@ -97,6 +98,8 @@
          GNUNET_break_op (0);
          return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
        }
+      if (reply_block == NULL)
+       return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
       return GNUNET_BLOCK_EVALUATION_OK_LAST;
     case GNUNET_BLOCK_TYPE_KBLOCK:
     case GNUNET_BLOCK_TYPE_NBLOCK:
@@ -310,7 +313,7 @@
  * Entry point for the plugin.
  */
 void *
-gnunet_plugin_block_fs_init (void *cls)
+libgnunet_plugin_block_fs_init (void *cls)
 {
   static enum GNUNET_BLOCK_Type types[] = 
     {
@@ -335,7 +338,7 @@
  * Exit point from the plugin.
  */
 void *
-gnunet_plugin_block_fs_done (void *cls)
+libgnunet_plugin_block_fs_done (void *cls)
 {
   struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
 

Modified: gnunet/src/block/test_block.c
===================================================================
--- gnunet/src/block/test_block.c       2010-09-12 13:08:54 UTC (rev 12972)
+++ gnunet/src/block/test_block.c       2010-09-13 03:18:26 UTC (rev 12973)
@@ -29,8 +29,67 @@
 
 #define VERBOSE GNUNET_NO
 
+static int
+test_fs (struct GNUNET_BLOCK_Context *ctx)
+{
+  GNUNET_HashCode key;
+  char block[4];
+
+  memset (block, 1, sizeof (block));
+  if (GNUNET_OK !=
+      GNUNET_BLOCK_get_key (ctx,
+                           GNUNET_BLOCK_TYPE_DBLOCK,
+                           block,
+                           sizeof (block),
+                           &key))
+    return 1;
+  if (GNUNET_BLOCK_EVALUATION_OK_LAST !=
+      GNUNET_BLOCK_evaluate (ctx,
+                            GNUNET_BLOCK_TYPE_DBLOCK,
+                            &key,
+                            NULL, 0,
+                            NULL, 0,
+                            block, sizeof (block)))
+    return 2;
+  if (GNUNET_BLOCK_EVALUATION_REQUEST_VALID !=
+      GNUNET_BLOCK_evaluate (ctx,
+                            GNUNET_BLOCK_TYPE_DBLOCK,
+                            &key,
+                            NULL, 0,
+                            NULL, 0,
+                            NULL, 0))
+    return 4;
+  GNUNET_log_skip (1, GNUNET_NO);
+  if (GNUNET_BLOCK_EVALUATION_REQUEST_INVALID  !=
+      GNUNET_BLOCK_evaluate (ctx,
+                            GNUNET_BLOCK_TYPE_DBLOCK,
+                            &key,
+                            NULL, 0,
+                            "bogus", 5,
+                            NULL, 0))
+    return 8;
+  GNUNET_log_skip (0, GNUNET_YES);
+  return 0;
+}
+
 int
 main (int argc, char *argv[])
 {
-  return 0;                     /* testcase passed */
+  int ret;
+  struct GNUNET_BLOCK_Context *ctx;
+  struct GNUNET_CONFIGURATION_Handle *cfg;
+
+  GNUNET_log_setup ("test-block", "WARNING", NULL);
+  cfg = GNUNET_CONFIGURATION_create ();
+  GNUNET_CONFIGURATION_set_value_string (cfg,
+                                        "block",
+                                        "PLUGINS",
+                                        "fs");
+  ctx = GNUNET_BLOCK_context_create (cfg);
+  ret = test_fs (ctx);
+  GNUNET_BLOCK_context_destroy (ctx);
+  GNUNET_CONFIGURATION_destroy (cfg);
+  if (ret != 0)
+    fprintf (stderr, "Tests failed: %d\n", ret);
+  return ret;
 }


Property changes on: gnunet/src/fs
___________________________________________________________________
Modified: svn:ignore
   - test_gnunet_service_fs_migration
test_fs_download_indexed
test_fs_unindex_persistence
test_fs_search_persistence
test_fs_publish_persistence
test_fs_download_persistence
test_gnunet_fs_rec.py
test_gnunet_fs_psd.py
test_gnunet_fs_ns.py
test_gnunet_fs_idx.py
test_gnunet_service_fs_p2p
test_fs_test_lib
gnunet-service-fs.gcda
test_fs_unindex.gcno
test_fs_unindex.gcda
test_fs_start_stop.gcno
test_fs_start_stop.gcda
test_fs_search.gcno
test_fs_search.gcda
test_fs_publish.gcno
test_fs_publish.gcda
test_fs_namespace.gcno
test_fs_list_indexed.gcno
test_fs_list_indexed.gcda
test_fs_file_information.gcno
test_fs_file_information.gcda
test_fs_download.gcno
test_fs_download.gcda
test_fs_publish
test_fs_list_indexed
test_fs_file_information
test_fs_unindex
test_fs_namespace
test_fs_start_stop
test_fs_search
test_fs_download
test_fs_uri.gcno
test_fs_uri.gcda
test_fs_getopt.gcno
test_fs_directory.gcno
test_fs_directory.gcda
test_fs_collection.gcno
gnunet-unindex.gcno
gnunet-service-fs.gcno
gnunet-search.gcno
gnunet-publish.gcno
gnunet-pseudonym.gcno
gnunet-download.gcno
gnunet-directory.gcno
fs_uri.gcno
fs_uri.gcda
fs_unindex.gcno
fs_unindex.gcda
fs_tree.gcno
fs_tree.gcda
fs_search.gcno
fs_search.gcda
fs_publish.gcno
fs_publish.gcda
fs_namespace.gcno
fs_namespace.gcda
fs_list_indexed.gcno
fs_list_indexed.gcda
fs_getopt.gcno
fs_getopt.gcda
fs_file_information.gcno
fs_file_information.gcda
fs_download.gcno
fs_download.gcda
fs_directory.gcno
fs_directory.gcda
fs_collection.gcno
fs_collection.gcda
fs.gcno
fs.gcda
test_fs_uri
test_fs_getopt
test_fs_directory
test_fs_collection
gnunet-service-fs
gnunet-pseudonym
gnunet-directory
gnunet-unindex
gnunet-search
gnunet-download
gnunet-publish
Makefile.in
Makefile
.deps

   + test_fs_namespace_list_updateable
test_gnunet_service_fs_migration
test_fs_download_indexed
test_fs_unindex_persistence
test_fs_search_persistence
test_fs_publish_persistence
test_fs_download_persistence
test_gnunet_fs_rec.py
test_gnunet_fs_psd.py
test_gnunet_fs_ns.py
test_gnunet_fs_idx.py
test_gnunet_service_fs_p2p
test_fs_test_lib
gnunet-service-fs.gcda
test_fs_unindex.gcno
test_fs_unindex.gcda
test_fs_start_stop.gcno
test_fs_start_stop.gcda
test_fs_search.gcno
test_fs_search.gcda
test_fs_publish.gcno
test_fs_publish.gcda
test_fs_namespace.gcno
test_fs_list_indexed.gcno
test_fs_list_indexed.gcda
test_fs_file_information.gcno
test_fs_file_information.gcda
test_fs_download.gcno
test_fs_download.gcda
test_fs_publish
test_fs_list_indexed
test_fs_file_information
test_fs_unindex
test_fs_namespace
test_fs_start_stop
test_fs_search
test_fs_download
test_fs_uri.gcno
test_fs_uri.gcda
test_fs_getopt.gcno
test_fs_directory.gcno
test_fs_directory.gcda
test_fs_collection.gcno
gnunet-unindex.gcno
gnunet-service-fs.gcno
gnunet-search.gcno
gnunet-publish.gcno
gnunet-pseudonym.gcno
gnunet-download.gcno
gnunet-directory.gcno
fs_uri.gcno
fs_uri.gcda
fs_unindex.gcno
fs_unindex.gcda
fs_tree.gcno
fs_tree.gcda
fs_search.gcno
fs_search.gcda
fs_publish.gcno
fs_publish.gcda
fs_namespace.gcno
fs_namespace.gcda
fs_list_indexed.gcno
fs_list_indexed.gcda
fs_getopt.gcno
fs_getopt.gcda
fs_file_information.gcno
fs_file_information.gcda
fs_download.gcno
fs_download.gcda
fs_directory.gcno
fs_directory.gcda
fs_collection.gcno
fs_collection.gcda
fs.gcno
fs.gcda
test_fs_uri
test_fs_getopt
test_fs_directory
test_fs_collection
gnunet-service-fs
gnunet-pseudonym
gnunet-directory
gnunet-unindex
gnunet-search
gnunet-download
gnunet-publish
Makefile.in
Makefile
.deps


Modified: gnunet/src/fs/fs.h
===================================================================
--- gnunet/src/fs/fs.h  2010-09-12 13:08:54 UTC (rev 12972)
+++ gnunet/src/fs/fs.h  2010-09-13 03:18:26 UTC (rev 12973)
@@ -31,6 +31,7 @@
 #include "gnunet_datastore_service.h"
 #include "gnunet_fs_service.h"
 #include "gnunet_block_lib.h"
+#include "block_fs.h"
 
 /**
  * Maximum size of the datastore queue for P2P operations.

Modified: gnunet/src/fs/gnunet-service-fs.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs.c   2010-09-12 13:08:54 UTC (rev 12972)
+++ gnunet/src/fs/gnunet-service-fs.c   2010-09-13 03:18:26 UTC (rev 12973)
@@ -616,8 +616,17 @@
  */
 static struct GNUNET_DATASTORE_Handle *dsh;
 
+/**
+ * Our block context.
+ */
+static struct GNUNET_BLOCK_Context *block_ctx;
 
 /**
+ * Our block configuration.
+ */
+static struct GNUNET_CONFIGURATION_Handle *block_cfg;
+
+/**
  * Our scheduler.
  */
 static struct GNUNET_SCHEDULER_Handle *sched;
@@ -1569,12 +1578,19 @@
       GNUNET_STATISTICS_destroy (stats, GNUNET_NO);
       stats = NULL;
     }
-  GNUNET_DATASTORE_disconnect (dsh,
-                              GNUNET_NO);
+  if (dsh != NULL)
+    {
+      GNUNET_DATASTORE_disconnect (dsh,
+                                  GNUNET_NO);
+      dsh = NULL;
+    }
   while (mig_head != NULL)
     delete_migration_block (mig_head);
   GNUNET_assert (0 == mig_size);
-  dsh = NULL;
+  GNUNET_BLOCK_context_destroy (block_ctx);
+  block_ctx = NULL;
+  GNUNET_CONFIGURATION_destroy (block_cfg);
+  block_cfg = NULL;
   sched = NULL;
   cfg = NULL;  
   GNUNET_free_non_null (trustDirectory);
@@ -2783,17 +2799,18 @@
   type = ntohl (put->type);
   expiration = GNUNET_TIME_absolute_ntoh (put->expiration);
 
+  if (type == GNUNET_BLOCK_TYPE_ONDEMAND)
+    return GNUNET_SYSERR;
   if (GNUNET_OK !=
-      GNUNET_BLOCK_check_block (type,
-                               &put[1],
-                               dsize,
-                               &query))
+      GNUNET_BLOCK_get_key (block_ctx,
+                           type,
+                           &put[1],
+                           dsize,
+                           &query))
     {
       GNUNET_break_op (0);
       return GNUNET_SYSERR;
     }
-  if (type == GNUNET_BLOCK_TYPE_ONDEMAND)
-    return GNUNET_SYSERR;
   if (GNUNET_BLOCK_TYPE_SBLOCK == type)
     { 
       sb = (const struct SBlock*) &put[1];
@@ -3051,10 +3068,12 @@
                          sizeof (struct 
GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded),
                          &prq.namespace);
     }
-  if (GNUNET_OK != GNUNET_BLOCK_check_block (type,
-                                            data,
-                                            size,
-                                            &query))
+  if (GNUNET_OK != 
+      GNUNET_BLOCK_get_key (block_ctx,
+                           type,
+                           data,
+                           size,
+                           &query))
     {
       GNUNET_break (0);
       GNUNET_DATASTORE_remove (dsh,
@@ -3786,12 +3805,23 @@
       GNUNET_SCHEDULER_shutdown (sched);
       return;
     }
+  block_cfg = GNUNET_CONFIGURATION_create ();
+  GNUNET_CONFIGURATION_set_value_string (block_cfg,
+                                        "block",
+                                        "PLUGINS",
+                                        "fs");
+  block_ctx = GNUNET_BLOCK_context_create (block_cfg);
+  GNUNET_assert (NULL != block_ctx);
   if ( (GNUNET_OK != GNUNET_FS_indexing_init (sched, cfg, dsh)) ||
        (GNUNET_OK != main_init (sched, server, cfg)) )
     {    
       GNUNET_SCHEDULER_shutdown (sched);
       GNUNET_DATASTORE_disconnect (dsh, GNUNET_NO);
       dsh = NULL;
+      GNUNET_BLOCK_context_destroy (block_ctx);
+      block_ctx = NULL;
+      GNUNET_CONFIGURATION_destroy (block_cfg);
+      block_cfg = NULL;
       return;   
     }
 }

Modified: gnunet/src/include/Makefile.am
===================================================================
--- gnunet/src/include/Makefile.am      2010-09-12 13:08:54 UTC (rev 12972)
+++ gnunet/src/include/Makefile.am      2010-09-13 03:18:26 UTC (rev 12973)
@@ -3,7 +3,8 @@
 gnunetincludedir = $(includedir)/gnunet
 
 nodist_gnunetinclude_HEADERS = \
-  gnunet_directories.h
+  gnunet_directories.h \
+  block_fs.h
 
 if MINGW
   WINPROC = winproc.h

Added: gnunet/src/include/block_fs.h
===================================================================
--- gnunet/src/include/block_fs.h                               (rev 0)
+++ gnunet/src/include/block_fs.h       2010-09-13 03:18:26 UTC (rev 12973)
@@ -0,0 +1,165 @@
+/*
+     This file is part of GNUnet.
+     (C) 2010 Christian Grothoff (and other contributing authors)
+
+     GNUnet is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 3, or (at your
+     option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file include/block_fs.h
+ * @brief fs block formats (shared between fs and block)
+ * @author Christian Grothoff
+ */
+#ifndef BLOCK_FS_H
+#define BLOCK_FS_H
+
+#include "gnunet_util_lib.h"
+
+/**
+ * @brief keyword block (advertising data under a keyword)
+ */
+struct KBlock
+{
+
+  /**
+   * GNUNET_RSA_Signature using RSA-key generated from search keyword.
+   */
+  struct GNUNET_CRYPTO_RsaSignature signature;
+
+  /**
+   * What is being signed and why?
+   */
+  struct GNUNET_CRYPTO_RsaSignaturePurpose purpose;
+
+  /**
+   * Key generated (!) from the H(keyword) as the seed!
+   */
+  struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded keyspace;
+
+  /* 0-terminated URI here */
+
+  /* variable-size Meta-Data follows here */
+
+};
+
+
+/**
+ * @brief namespace content block (advertising data under an identifier in a 
namespace)
+ */
+struct SBlock
+{
+
+  /**
+   * GNUNET_RSA_Signature using RSA-key of the namespace
+   */
+  struct GNUNET_CRYPTO_RsaSignature signature;
+
+  /**
+   * What is being signed and why?
+   */
+  struct GNUNET_CRYPTO_RsaSignaturePurpose purpose;
+
+  /**
+   * Hash of the hash of the human-readable identifier used for
+   * this entry (the hash of the human-readable identifier is
+   * used as the key for decryption; the xor of this identifier
+   * and the hash of the "keyspace" is the datastore-query hash).
+   */
+  GNUNET_HashCode identifier;
+
+  /**
+   * Public key of the namespace.
+   */
+  struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded subspace;
+
+  /* 0-terminated update-identifier here */
+
+  /* 0-terminated URI here (except for NBlocks) */
+
+  /* variable-size Meta-Data follows here */
+
+};
+
+
+/**
+ * @brief namespace advertisement block (advertising root of a namespace)
+ */
+struct NBlock
+{
+
+  /**
+   * GNUNET_RSA_Signature using RSA-key generated from search keyword.
+   */
+  struct GNUNET_CRYPTO_RsaSignature ksk_signature;
+
+  /**
+   * What is being signed and why?
+   */
+  struct GNUNET_CRYPTO_RsaSignaturePurpose ksk_purpose;
+
+  /**
+   * Key generated (!) from the H(keyword) as the seed!
+   */
+  struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded keyspace;
+
+  /**
+   * GNUNET_RSA_Signature using RSA-key of the namespace
+   */
+  struct GNUNET_CRYPTO_RsaSignature ns_signature;
+
+  /**
+   * What is being signed and why?
+   */
+  struct GNUNET_CRYPTO_RsaSignaturePurpose ns_purpose;
+
+  /**
+   * Public key of the namespace.
+   */
+  struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded subspace;
+
+  /* from here on, data is encrypted with H(keyword) */
+
+  /* 0-terminated root identifier here */
+
+  /* variable-size Meta-Data follows here */
+
+};
+
+
+/**
+ * @brief index block (indexing a DBlock that 
+ *        can be obtained directly from reading
+ *        the plaintext file)
+ */
+struct OnDemandBlock
+{
+  /**
+   * Hash code of the entire content of the
+   * file that was indexed (used to uniquely
+   * identify the plaintext file).
+   */
+  GNUNET_HashCode file_id;
+
+  /**
+   * At which offset should we be able to find
+   * this on-demand encoded block? (in NBO)
+   */
+  uint64_t offset GNUNET_PACKED;
+
+};
+
+
+#endif

Modified: gnunet/src/include/gnunet_block_lib.h
===================================================================
--- gnunet/src/include/gnunet_block_lib.h       2010-09-12 13:08:54 UTC (rev 
12972)
+++ gnunet/src/include/gnunet_block_lib.h       2010-09-13 03:18:26 UTC (rev 
12973)
@@ -83,165 +83,9 @@
   };
 
 
-/* **************** FIXME: move these to block_fs.h or so ***************** */
 
-/**
- * @brief keyword block (advertising data under a keyword)
- */
-struct KBlock
-{
 
-  /**
-   * GNUNET_RSA_Signature using RSA-key generated from search keyword.
-   */
-  struct GNUNET_CRYPTO_RsaSignature signature;
-
-  /**
-   * What is being signed and why?
-   */
-  struct GNUNET_CRYPTO_RsaSignaturePurpose purpose;
-
-  /**
-   * Key generated (!) from the H(keyword) as the seed!
-   */
-  struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded keyspace;
-
-  /* 0-terminated URI here */
-
-  /* variable-size Meta-Data follows here */
-
-};
-
-
 /**
- * @brief namespace content block (advertising data under an identifier in a 
namespace)
- */
-struct SBlock
-{
-
-  /**
-   * GNUNET_RSA_Signature using RSA-key of the namespace
-   */
-  struct GNUNET_CRYPTO_RsaSignature signature;
-
-  /**
-   * What is being signed and why?
-   */
-  struct GNUNET_CRYPTO_RsaSignaturePurpose purpose;
-
-  /**
-   * Hash of the hash of the human-readable identifier used for
-   * this entry (the hash of the human-readable identifier is
-   * used as the key for decryption; the xor of this identifier
-   * and the hash of the "keyspace" is the datastore-query hash).
-   */
-  GNUNET_HashCode identifier;
-
-  /**
-   * Public key of the namespace.
-   */
-  struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded subspace;
-
-  /* 0-terminated update-identifier here */
-
-  /* 0-terminated URI here (except for NBlocks) */
-
-  /* variable-size Meta-Data follows here */
-
-};
-
-
-/**
- * @brief namespace advertisement block (advertising root of a namespace)
- */
-struct NBlock
-{
-
-  /**
-   * GNUNET_RSA_Signature using RSA-key generated from search keyword.
-   */
-  struct GNUNET_CRYPTO_RsaSignature ksk_signature;
-
-  /**
-   * What is being signed and why?
-   */
-  struct GNUNET_CRYPTO_RsaSignaturePurpose ksk_purpose;
-
-  /**
-   * Key generated (!) from the H(keyword) as the seed!
-   */
-  struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded keyspace;
-
-  /**
-   * GNUNET_RSA_Signature using RSA-key of the namespace
-   */
-  struct GNUNET_CRYPTO_RsaSignature ns_signature;
-
-  /**
-   * What is being signed and why?
-   */
-  struct GNUNET_CRYPTO_RsaSignaturePurpose ns_purpose;
-
-  /**
-   * Public key of the namespace.
-   */
-  struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded subspace;
-
-  /* from here on, data is encrypted with H(keyword) */
-
-  /* 0-terminated root identifier here */
-
-  /* variable-size Meta-Data follows here */
-
-};
-
-
-/**
- * @brief index block (indexing a DBlock that 
- *        can be obtained directly from reading
- *        the plaintext file)
- */
-struct OnDemandBlock
-{
-  /**
-   * Hash code of the entire content of the
-   * file that was indexed (used to uniquely
-   * identify the plaintext file).
-   */
-  GNUNET_HashCode file_id;
-
-  /**
-   * At which offset should we be able to find
-   * this on-demand encoded block? (in NBO)
-   */
-  uint64_t offset GNUNET_PACKED;
-
-};
-
-
-/* **************** OLD API ***************** */
-
-/**
- * Check if the given block is well-formed (and of the given type).
- *
- * @param type type of the block
- * @param block the block data (or at least "size" bytes claiming to be one)
- * @param size size of "kb" in bytes; check that it is large enough
- * @param query where to store the query that this block answers
- * @return GNUNET_OK if this is actually a well-formed KBlock
- *         GNUNET_NO if we could not determine the query,
- *         GNUNET_SYSERR if the block is malformed
- */
-int
-GNUNET_BLOCK_check_block (enum GNUNET_BLOCK_Type type,
-                         const void *block,
-                         size_t size,
-                         GNUNET_HashCode *query);
-
-
-/* **************** NEW API ***************** */
-
-/**
  * Possible ways for how a block may relate to a query.
  */
 enum GNUNET_BLOCK_EvaluationResult

Modified: gnunet/src/util/test_time.c
===================================================================
--- gnunet/src/util/test_time.c 2010-09-12 13:08:54 UTC (rev 12972)
+++ gnunet/src/util/test_time.c 2010-09-13 03:18:26 UTC (rev 12973)
@@ -64,8 +64,10 @@
   GNUNET_assert (GNUNET_TIME_relative_get_zero ().value == 
GNUNET_TIME_relative_multiply (rel,0).value);
 
   /* test infinity-check for relative to absolute */
+  GNUNET_log_skip (1, GNUNET_NO);
   last = GNUNET_TIME_relative_to_absolute (rel);
   GNUNET_assert (last.value == GNUNET_TIME_UNIT_FOREVER_ABS.value);
+  GNUNET_log_skip (0, GNUNET_YES);
 
   /*check relative to absolute*/
   rel.value = 0;
@@ -179,13 +181,15 @@
   forever = GNUNET_TIME_absolute_get_forever ();
   forever.value = forever.value - 1024;
   GNUNET_assert(GNUNET_TIME_absolute_get_zero ().value == 
-               GNUNET_TIME_calculate_eta (forever,50000,100000).value);
-  /*check zero*/
+               GNUNET_TIME_calculate_eta (forever, 50000, 100000).value);
+  /* check zero */
+  GNUNET_log_skip (1, GNUNET_NO);
   GNUNET_assert(GNUNET_TIME_UNIT_ZERO.value ==
-               (GNUNET_TIME_calculate_eta (last,60000,50000)).value);
+               (GNUNET_TIME_calculate_eta (last, 60000, 50000)).value);
+  GNUNET_log_skip (0, GNUNET_YES);
   /*check forever*/
   GNUNET_assert(GNUNET_TIME_UNIT_FOREVER_REL.value ==
-               (GNUNET_TIME_calculate_eta (last,0,50000)).value);
+               (GNUNET_TIME_calculate_eta (last, 0, 50000)).value);
 
   /*check relative subtract*/
   now = GNUNET_TIME_absolute_get ();




reply via email to

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