gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet] branch master updated: add validation for inner co


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated: add validation for inner consensus element
Date: Sun, 26 Feb 2017 23:40:13 +0100

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new 82242cae3 add validation for inner consensus element
82242cae3 is described below

commit 82242cae3bb6313ee10df20570e4c14627828033
Author: Florian Dold <address@hidden>
AuthorDate: Sun Feb 26 23:39:29 2017 +0100

    add validation for inner consensus element
    
    The nested block validation requires the block context, and thus the
    evaluate callback not also receives the block context.
---
 src/block/block.c                      |  1 +
 src/block/plugin_block_template.c      |  2 ++
 src/block/plugin_block_test.c          |  2 ++
 src/consensus/plugin_block_consensus.c | 21 ++++++++++++++++++---
 src/dht/plugin_block_dht.c             |  2 ++
 src/dns/plugin_block_dns.c             |  2 ++
 src/fs/plugin_block_fs.c               |  2 ++
 src/gns/plugin_block_gns.c             |  2 ++
 src/include/gnunet_block_plugin.h      |  2 ++
 src/regex/plugin_block_regex.c         |  2 ++
 src/set/Makefile.am                    | 16 ++++++++++++++++
 11 files changed, 51 insertions(+), 3 deletions(-)

diff --git a/src/block/block.c b/src/block/block.c
index 23caacd38..d6e61acf6 100644
--- a/src/block/block.c
+++ b/src/block/block.c
@@ -351,6 +351,7 @@ GNUNET_BLOCK_evaluate (struct GNUNET_BLOCK_Context *ctx,
   if (NULL == plugin)
     return GNUNET_BLOCK_EVALUATION_TYPE_NOT_SUPPORTED;
   return plugin->evaluate (plugin->cls,
+                           ctx,
                            type,
                            group,
                            eo,
diff --git a/src/block/plugin_block_template.c 
b/src/block/plugin_block_template.c
index b714b6858..2edca17ec 100644
--- a/src/block/plugin_block_template.c
+++ b/src/block/plugin_block_template.c
@@ -95,6 +95,7 @@ block_plugin_template_create_group (void *cls,
  * request evaluation, simply pass "NULL" for the reply_block.
  *
  * @param cls closure
+ * @param ctx context
  * @param type block type
  * @param group block group to use
  * @param eo control flags
@@ -107,6 +108,7 @@ block_plugin_template_create_group (void *cls,
  */
 static enum GNUNET_BLOCK_EvaluationResult
 block_plugin_template_evaluate (void *cls,
+                                struct GNUNET_BLOCK_Context *ctx,
                                 enum GNUNET_BLOCK_Type type,
                                 struct GNUNET_BLOCK_Group *group,
                                 enum GNUNET_BLOCK_EvaluationOptions eo,
diff --git a/src/block/plugin_block_test.c b/src/block/plugin_block_test.c
index b9f71cacb..e359acd7f 100644
--- a/src/block/plugin_block_test.c
+++ b/src/block/plugin_block_test.c
@@ -93,6 +93,7 @@ block_plugin_test_create_group (void *cls,
  * request evaluation, simply pass "NULL" for the reply_block.
  *
  * @param cls closure
+ * @param ctx block context
  * @param type block type
  * @param group group to check against
  * @param eo control flags
@@ -105,6 +106,7 @@ block_plugin_test_create_group (void *cls,
  */
 static enum GNUNET_BLOCK_EvaluationResult
 block_plugin_test_evaluate (void *cls,
+                            struct GNUNET_BLOCK_Context *ctx,
                             enum GNUNET_BLOCK_Type type,
                             struct GNUNET_BLOCK_Group *group,
                             enum GNUNET_BLOCK_EvaluationOptions eo,
diff --git a/src/consensus/plugin_block_consensus.c 
b/src/consensus/plugin_block_consensus.c
index 39e348b18..3ad335760 100644
--- a/src/consensus/plugin_block_consensus.c
+++ b/src/consensus/plugin_block_consensus.c
@@ -35,6 +35,7 @@
  * request evaluation, simply pass "NULL" for the reply_block.
  *
  * @param cls closure
+ * @param ctx context
  * @param type block type
  * @param group block group to use
  * @param eo control flags
@@ -47,6 +48,7 @@
  */
 static enum GNUNET_BLOCK_EvaluationResult
 block_plugin_consensus_evaluate (void *cls,
+                                 struct GNUNET_BLOCK_Context *ctx,
                                  enum GNUNET_BLOCK_Type type,
                                  struct GNUNET_BLOCK_Group *group,
                                  enum GNUNET_BLOCK_EvaluationOptions eo,
@@ -57,10 +59,23 @@ block_plugin_consensus_evaluate (void *cls,
                                  size_t reply_block_size)
 {
   if (reply_block_size < sizeof (struct ConsensusElement))
-  {
     return GNUNET_BLOCK_EVALUATION_RESULT_INVALID;
-  }
-  return GNUNET_BLOCK_EVALUATION_OK_MORE;
+
+  const struct ConsensusElement *ce = reply_block;
+
+  if ( (GNUNET_YES == ce->is_contested_marker) ||
+       (0 == ce->payload_type ) )
+    return GNUNET_BLOCK_EVALUATION_OK_MORE;
+
+  return GNUNET_BLOCK_evaluate (ctx,
+                                type,
+                                group,
+                                eo,
+                                query,
+                                xquery,
+                                xquery_size,
+                                &ce[1],
+                                reply_block_size - sizeof (struct 
ConsensusElement));
 }
 
 
diff --git a/src/dht/plugin_block_dht.c b/src/dht/plugin_block_dht.c
index 74498746c..96349ae9d 100644
--- a/src/dht/plugin_block_dht.c
+++ b/src/dht/plugin_block_dht.c
@@ -92,6 +92,7 @@ block_plugin_dht_create_group (void *cls,
  * request evaluation, simply pass "NULL" for the @a reply_block.
  *
  * @param cls closure
+ * @param ctx context
  * @param type block type
  * @param group block group to check against
  * @param eo control flags
@@ -104,6 +105,7 @@ block_plugin_dht_create_group (void *cls,
  */
 static enum GNUNET_BLOCK_EvaluationResult
 block_plugin_dht_evaluate (void *cls,
+                           struct GNUNET_BLOCK_Context *ctx,
                            enum GNUNET_BLOCK_Type type,
                            struct GNUNET_BLOCK_Group *group,
                            enum GNUNET_BLOCK_EvaluationOptions eo,
diff --git a/src/dns/plugin_block_dns.c b/src/dns/plugin_block_dns.c
index fe416e450..ca6ea84c4 100644
--- a/src/dns/plugin_block_dns.c
+++ b/src/dns/plugin_block_dns.c
@@ -93,6 +93,7 @@ block_plugin_dns_create_group (void *cls,
  * request evaluation, simply pass "NULL" for the reply_block.
  *
  * @param cls closure
+ * @param ctx block context
  * @param type block type
  * @param bg group to evaluate against
  * @param eo control flags
@@ -105,6 +106,7 @@ block_plugin_dns_create_group (void *cls,
  */
 static enum GNUNET_BLOCK_EvaluationResult
 block_plugin_dns_evaluate (void *cls,
+                           struct GNUNET_BLOCK_Context *ctx,
                            enum GNUNET_BLOCK_Type type,
                            struct GNUNET_BLOCK_Group *bg,
                            enum GNUNET_BLOCK_EvaluationOptions eo,
diff --git a/src/fs/plugin_block_fs.c b/src/fs/plugin_block_fs.c
index b6749b418..c5e63c9e2 100644
--- a/src/fs/plugin_block_fs.c
+++ b/src/fs/plugin_block_fs.c
@@ -109,6 +109,7 @@ block_plugin_fs_create_group (void *cls,
  * be done with the #GNUNET_BLOCK_get_key() function.
  *
  * @param cls closure
+ * @param ctx block context
  * @param type block type
  * @param bg group to use for evaluation
  * @param eo control flags
@@ -121,6 +122,7 @@ block_plugin_fs_create_group (void *cls,
  */
 static enum GNUNET_BLOCK_EvaluationResult
 block_plugin_fs_evaluate (void *cls,
+                          struct GNUNET_BLOCK_Context *ctx,
                           enum GNUNET_BLOCK_Type type,
                           struct GNUNET_BLOCK_Group *bg,
                           enum GNUNET_BLOCK_EvaluationOptions eo,
diff --git a/src/gns/plugin_block_gns.c b/src/gns/plugin_block_gns.c
index 2ef48f094..558ded6f4 100644
--- a/src/gns/plugin_block_gns.c
+++ b/src/gns/plugin_block_gns.c
@@ -98,6 +98,7 @@ block_plugin_gns_create_group (void *cls,
  * be done with the "get_key" function.
  *
  * @param cls closure
+ * @param ctx block context
  * @param type block type
  * @param bg block group to use for evaluation
  * @param eo control flags
@@ -110,6 +111,7 @@ block_plugin_gns_create_group (void *cls,
  */
 static enum GNUNET_BLOCK_EvaluationResult
 block_plugin_gns_evaluate (void *cls,
+                           struct GNUNET_BLOCK_Context *ctx,
                            enum GNUNET_BLOCK_Type type,
                            struct GNUNET_BLOCK_Group *bg,
                            enum GNUNET_BLOCK_EvaluationOptions eo,
diff --git a/src/include/gnunet_block_plugin.h 
b/src/include/gnunet_block_plugin.h
index 171b6cfc0..3eb031573 100644
--- a/src/include/gnunet_block_plugin.h
+++ b/src/include/gnunet_block_plugin.h
@@ -171,6 +171,7 @@ typedef struct GNUNET_BLOCK_Group *
  * be done with the "get_key" function.
  *
  * @param cls closure
+ * @param ctx block context
  * @param type block type
  * @param group which block group to use for evaluation
  * @param eo evaluation options to control evaluation
@@ -183,6 +184,7 @@ typedef struct GNUNET_BLOCK_Group *
  */
 typedef enum GNUNET_BLOCK_EvaluationResult
 (*GNUNET_BLOCK_EvaluationFunction) (void *cls,
+                                    struct GNUNET_BLOCK_Context *ctx,
                                    enum GNUNET_BLOCK_Type type,
                                     struct GNUNET_BLOCK_Group *group,
                                     enum GNUNET_BLOCK_EvaluationOptions eo,
diff --git a/src/regex/plugin_block_regex.c b/src/regex/plugin_block_regex.c
index a345dfedb..0b3ef703e 100644
--- a/src/regex/plugin_block_regex.c
+++ b/src/regex/plugin_block_regex.c
@@ -269,6 +269,7 @@ evaluate_block_regex_accept (void *cls,
  * be done with the #GNUNET_BLOCK_get_key() function.
  *
  * @param cls closure
+ * @param ctx block context
  * @param type block type
  * @param bg group to evaluate against
  * @param eo control flags
@@ -281,6 +282,7 @@ evaluate_block_regex_accept (void *cls,
  */
 static enum GNUNET_BLOCK_EvaluationResult
 block_plugin_regex_evaluate (void *cls,
+                             struct GNUNET_BLOCK_Context *ctx,
                              enum GNUNET_BLOCK_Type type,
                              struct GNUNET_BLOCK_Group *bg,
                              enum GNUNET_BLOCK_EvaluationOptions eo,
diff --git a/src/set/Makefile.am b/src/set/Makefile.am
index 10f7ddc5d..cfe95bc1a 100644
--- a/src/set/Makefile.am
+++ b/src/set/Makefile.am
@@ -5,6 +5,8 @@ pkgcfgdir= $(pkgdatadir)/config.d/
 
 libexecdir= $(pkglibdir)/libexec/
 
+plugindir = $(libdir)/gnunet
+
 pkgcfg_DATA = \
   set.conf
 
@@ -112,5 +114,19 @@ test_set_union_copy_LDADD = \
   $(top_builddir)/src/testing/libgnunettesting.la \
   libgnunetset.la
 
+plugin_LTLIBRARIES = \
+  libgnunet_plugin_block_set_test.la
+
+libgnunet_plugin_block_set_test_la_SOURCES = \
+  plugin_block_set_test.c
+libgnunet_plugin_block_set_test_la_LIBADD = \
+  $(top_builddir)/src/block/libgnunetblock.la \
+  $(top_builddir)/src/block/libgnunetblockgroup.la \
+  $(top_builddir)/src/util/libgnunetutil.la \
+  $(LTLIBINTL)
+libgnunet_plugin_block_set_test_la_LDFLAGS = \
+ $(GN_PLUGIN_LDFLAGS)
+
+
 EXTRA_DIST = \
   test_set.conf

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

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