gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r22113 - in gnunet/src: include mesh


From: gnunet
Subject: [GNUnet-SVN] r22113 - in gnunet/src: include mesh
Date: Tue, 19 Jun 2012 16:26:38 +0200

Author: bartpolot
Date: 2012-06-19 16:26:38 +0200 (Tue, 19 Jun 2012)
New Revision: 22113

Added:
   gnunet/src/mesh/plugin_block_mesh.c
Modified:
   gnunet/src/include/gnunet_block_lib.h
   gnunet/src/mesh/Makefile.am
   gnunet/src/mesh/gnunet-service-mesh_new.c
Log:
- added dummy mesh block plugin

Modified: gnunet/src/include/gnunet_block_lib.h
===================================================================
--- gnunet/src/include/gnunet_block_lib.h       2012-06-19 13:53:13 UTC (rev 
22112)
+++ gnunet/src/include/gnunet_block_lib.h       2012-06-19 14:26:38 UTC (rev 
22113)
@@ -98,7 +98,12 @@
     /**
      * Block for storing record data
      */
-  GNUNET_BLOCK_TYPE_GNS_NAMERECORD = 11
+  GNUNET_BLOCK_TYPE_GNS_NAMERECORD = 11,
+
+    /**
+     * Block for storing mesh peers
+     */
+  GNUNET_BLOCK_TYPE_MESH_PEER = 20
 };
 
 

Modified: gnunet/src/mesh/Makefile.am
===================================================================
--- gnunet/src/mesh/Makefile.am 2012-06-19 13:53:13 UTC (rev 22112)
+++ gnunet/src/mesh/Makefile.am 2012-06-19 14:26:38 UTC (rev 22113)
@@ -14,6 +14,8 @@
 pkgcfg_DATA = \
   mesh.conf
 
+plugindir = $(libdir)/gnunet
+
 AM_CLFAGS = -g
 
 bin_PROGRAMS = \
@@ -22,12 +24,27 @@
 lib_LTLIBRARIES = \
   libgnunetmesh.la
 
+plugin_LTLIBRARIES = \
+ libgnunet_plugin_block_mesh.la
+
+libgnunet_plugin_block_mesh_la_SOURCES = \
+ plugin_block_mesh.c
+libgnunet_plugin_block_mesh_la_LIBADD = \
+ $(top_builddir)/src/block/libgnunetblock.la \
+ $(top_builddir)/src/util/libgnunetutil.la
+libgnunet_plugin_block_mesh_la_LDFLAGS = \
+ $(GN_PLUGIN_LDFLAGS)
+libgnunet_plugin_block_mesh_la_DEPENDENCIES = \
+ $(top_builddir)/src/block/libgnunetblock.la
+
+
 gnunet_service_mesh_SOURCES = \
  gnunet-service-mesh.c \
  mesh_tunnel_tree.c mesh_tunnel_tree.h
 gnunet_service_mesh_LDADD = \
-  $(top_builddir)/src/core/libgnunetcore.la\
+  $(top_builddir)/src/core/libgnunetcore.la \
   $(top_builddir)/src/dht/libgnunetdht.la \
+  $(top_builddir)/src/block/libgnunetblock.la \
   $(top_builddir)/src/util/libgnunetutil.la
  gnunet_service_mesh_DEPENDENCIES = \
   $(top_builddir)/src/core/libgnunetcore.la\

Modified: gnunet/src/mesh/gnunet-service-mesh_new.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_new.c   2012-06-19 13:53:13 UTC (rev 
22112)
+++ gnunet/src/mesh/gnunet-service-mesh_new.c   2012-06-19 14:26:38 UTC (rev 
22113)
@@ -70,9 +70,11 @@
 
 /* TODO END */
 
-#define MESH_DEBUG_DHT GNUNET_YES
-#define MESH_DEBUG_CONNECTION GNUNET_NO
+#define MESH_BLOOM_SIZE         128
 
+#define MESH_DEBUG_DHT          GNUNET_YES
+#define MESH_DEBUG_CONNECTION   GNUNET_NO
+
 #if MESH_DEBUG_CONNECTION
 #define DEBUG_CONN(...) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
 #else
@@ -382,6 +384,11 @@
   unsigned int nblacklisted;
 
   /**
+   * Bloomfilter (for peer identities) to stop circular routes
+   */
+  char bloomfilter[MESH_BLOOM_SIZE];
+
+  /**
    * Tunnel paths
    */
   struct MeshTunnelTree *tree;
@@ -655,7 +662,8 @@
   /* FIXME: keep return value of 'put' to possibly cancel!? */
   GNUNET_DHT_put (dht_handle, key, 10,
                   GNUNET_DHT_RO_RECORD_ROUTE |
-                  GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, GNUNET_BLOCK_TYPE_TEST,
+                  GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
+                  GNUNET_BLOCK_TYPE_MESH_PEER,
                   sizeof (struct GNUNET_PeerIdentity),
                   (const char *) &my_full_id,
                   GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get (),
@@ -717,7 +725,7 @@
                   &my_full_id.hashPubKey,       /* Key to use */
                   10,          /* Replication level */
                   GNUNET_DHT_RO_RECORD_ROUTE | 
GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,    /* DHT options */
-                  GNUNET_BLOCK_TYPE_TEST,       /* Block type */
+                  GNUNET_BLOCK_TYPE_MESH_PEER,       /* Block type */
                   sizeof (my_full_id),  /* Size of the data */
                   (char *) &my_full_id, /* Data itself */
                   GNUNET_TIME_UNIT_FOREVER_ABS,  /* Data expiration */
@@ -1514,11 +1522,13 @@
                 "  Starting DHT GET for peer %s\n", GNUNET_i2s (&id));
     peer->dhtgetcls = path_info;
     peer->dhtget = GNUNET_DHT_get_start (dht_handle,    /* handle */
-                                         GNUNET_BLOCK_TYPE_TEST,        /* 
type */
-                                         &id.hashPubKey,        /* key to 
search */
+                                         GNUNET_BLOCK_TYPE_MESH_PEER, /* type 
*/
+                                         &id.hashPubKey,     /* key to search 
*/
                                          10,     /* replication level */
-                                         GNUNET_DHT_RO_RECORD_ROUTE | 
GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, NULL,       /* xquery */
-                                         0,     /* xquery bits */
+                                         GNUNET_DHT_RO_RECORD_ROUTE |
+                                         GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
+                                         NULL,       /* xquery */ // FIXME 
BLOOMFILTER
+                                         0,     /* xquery bits */ // FIXME 
BLOOMFILTER SIZE
                                          &dht_get_id_handler, path_info);
   }
   /* Otherwise, there is no path but the DHT get is already started. */
@@ -4449,9 +4459,12 @@
               GNUNET_h2s (&hash));
   t->dht_get_type =
       GNUNET_DHT_get_start (dht_handle, 
-                            GNUNET_BLOCK_TYPE_TEST, &hash, 10,
+                            GNUNET_BLOCK_TYPE_MESH_PEER,
+                            &hash,
+                            10,
                             GNUNET_DHT_RO_RECORD_ROUTE |
-                            GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, NULL, 0,
+                            GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
+                            NULL, 0,
                             &dht_get_type_handler, t);
 
   GNUNET_SERVER_receive_done (client, GNUNET_OK);

Added: gnunet/src/mesh/plugin_block_mesh.c
===================================================================
--- gnunet/src/mesh/plugin_block_mesh.c                         (rev 0)
+++ gnunet/src/mesh/plugin_block_mesh.c 2012-06-19 14:26:38 UTC (rev 22113)
@@ -0,0 +1,125 @@
+/*
+     This file is part of GNUnet
+     (C) 2012 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 mesh/plugin_block_mesh.c
+ * @brief blocks used for mesh peer discovery
+ * @author Bartlomiej Polot
+ */
+
+#include "platform.h"
+#include "gnunet_block_plugin.h"
+
+#define DEBUG_MESH_BLOCK GNUNET_EXTRA_LOGGING
+
+/**
+ * Function called to validate a reply or a request.  For
+ * request evaluation, simply pass "NULL" for the reply_block.
+ * Note that it is assumed that the reply has already been
+ * matched to the key (and signatures checked) as it would
+ * be done with the "get_key" function.
+ *
+ * @param cls closure
+ * @param type block type
+ * @param query original query (hash)
+ * @param bf pointer to bloom filter associated with query; possibly updated 
(!)
+ * @param bf_mutator mutation value for bf
+ * @param xquery extrended query data (can be NULL, depending on type)
+ * @param xquery_size number of bytes in xquery
+ * @param reply_block response to validate
+ * @param reply_block_size number of bytes in reply block
+ * @return characterization of result
+ */
+static enum GNUNET_BLOCK_EvaluationResult
+block_plugin_mesh_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
+                            const struct GNUNET_HashCode * query,
+                            struct GNUNET_CONTAINER_BloomFilter **bf,
+                            int32_t bf_mutator, const void *xquery,
+                            size_t xquery_size, const void *reply_block,
+                            size_t reply_block_size)
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Evaluate called\n");
+  if (GNUNET_BLOCK_TYPE_MESH_PEER == type)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Type MESH PEER\n");
+  }
+  else
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Other type\n");
+  }
+  return GNUNET_BLOCK_EVALUATION_OK_LAST;
+}
+
+
+/**
+ * Function called to obtain the key for a block.
+ *
+ * @param cls closure
+ * @param type block type
+ * @param block block to get the key for
+ * @param block_size number of bytes in block
+ * @param key set to the key (query) for the given block
+ * @return GNUNET_OK on success, GNUNET_SYSERR if type not supported
+ *         (or if extracting a key from a block of this type does not work)
+ */
+static int
+block_plugin_mesh_get_key (void *cls, enum GNUNET_BLOCK_Type type,
+                           const void *block, size_t block_size,
+                           struct GNUNET_HashCode * key)
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Get key called\n");
+  return GNUNET_SYSERR;
+}
+
+
+/**
+ * Entry point for the plugin.
+ */
+void *
+libgnunet_plugin_block_mesh_init (void *cls)
+{
+  static enum GNUNET_BLOCK_Type types[] =
+  {
+    GNUNET_BLOCK_TYPE_MESH_PEER,
+    GNUNET_BLOCK_TYPE_ANY       /* end of list */
+  };
+  struct GNUNET_BLOCK_PluginFunctions *api;
+
+  api = GNUNET_malloc (sizeof (struct GNUNET_BLOCK_PluginFunctions));
+  api->evaluate = &block_plugin_mesh_evaluate;
+  api->get_key = &block_plugin_mesh_get_key;
+  api->types = types;
+  return api;
+}
+
+
+/**
+ * Exit point from the plugin.
+ */
+void *
+libgnunet_plugin_block_mesh_done (void *cls)
+{
+  struct GNUNET_TRANSPORT_PluginFunctions *api = cls;
+
+  GNUNET_free (api);
+  return NULL;
+}
+
+/* end of plugin_block_mesh.c */




reply via email to

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