aboutsummaryrefslogtreecommitdiff
path: root/src/regex/plugin_block_regex.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/regex/plugin_block_regex.c')
-rw-r--r--src/regex/plugin_block_regex.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/regex/plugin_block_regex.c b/src/regex/plugin_block_regex.c
index 6636f3cdb..287ecf905 100644
--- a/src/regex/plugin_block_regex.c
+++ b/src/regex/plugin_block_regex.c
@@ -28,11 +28,17 @@
28#include "gnunet_block_group_lib.h" 28#include "gnunet_block_group_lib.h"
29#include "block_regex.h" 29#include "block_regex.h"
30#include "regex_block_lib.h" 30#include "regex_block_lib.h"
31#include "gnunet_constants.h"
32#include "gnunet_signatures.h" 31#include "gnunet_signatures.h"
33 32
34 33
35/** 34/**
35 * Number of bits we set per entry in the bloomfilter.
36 * Do not change!
37 */
38#define BLOOMFILTER_K 16
39
40
41/**
36 * How big is the BF we use for REGEX blocks? 42 * How big is the BF we use for REGEX blocks?
37 */ 43 */
38#define REGEX_BF_SIZE 8 44#define REGEX_BF_SIZE 8
@@ -58,9 +64,26 @@ block_plugin_regex_create_group (void *cls,
58 size_t raw_data_size, 64 size_t raw_data_size,
59 va_list va) 65 va_list va)
60{ 66{
67 unsigned int bf_size;
68 const char *guard;
69
70 guard = va_arg (va, const char *);
71 if (0 == strcmp (guard,
72 "seen-set-size"))
73 bf_size = GNUNET_BLOCK_GROUP_compute_bloomfilter_size (va_arg (va, unsigned int),
74 BLOOMFILTER_K);
75 else if (0 == strcmp (guard,
76 "filter-size"))
77 bf_size = va_arg (va, unsigned int);
78 else
79 {
80 GNUNET_break (0);
81 bf_size = REGEX_BF_SIZE;
82 }
83 GNUNET_break (NULL == va_arg (va, const char *));
61 return GNUNET_BLOCK_GROUP_bf_create (cls, 84 return GNUNET_BLOCK_GROUP_bf_create (cls,
62 REGEX_BF_SIZE, 85 bf_size,
63 GNUNET_CONSTANTS_BLOOMFILTER_K, 86 BLOOMFILTER_K,
64 type, 87 type,
65 nonce, 88 nonce,
66 raw_data, 89 raw_data,
@@ -246,6 +269,7 @@ evaluate_block_regex_accept (void *cls,
246 * be done with the #GNUNET_BLOCK_get_key() function. 269 * be done with the #GNUNET_BLOCK_get_key() function.
247 * 270 *
248 * @param cls closure 271 * @param cls closure
272 * @param ctx block context
249 * @param type block type 273 * @param type block type
250 * @param bg group to evaluate against 274 * @param bg group to evaluate against
251 * @param eo control flags 275 * @param eo control flags
@@ -258,6 +282,7 @@ evaluate_block_regex_accept (void *cls,
258 */ 282 */
259static enum GNUNET_BLOCK_EvaluationResult 283static enum GNUNET_BLOCK_EvaluationResult
260block_plugin_regex_evaluate (void *cls, 284block_plugin_regex_evaluate (void *cls,
285 struct GNUNET_BLOCK_Context *ctx,
261 enum GNUNET_BLOCK_Type type, 286 enum GNUNET_BLOCK_Type type,
262 struct GNUNET_BLOCK_Group *bg, 287 struct GNUNET_BLOCK_Group *bg,
263 enum GNUNET_BLOCK_EvaluationOptions eo, 288 enum GNUNET_BLOCK_EvaluationOptions eo,
@@ -370,7 +395,7 @@ libgnunet_plugin_block_regex_init (void *cls)
370void * 395void *
371libgnunet_plugin_block_regex_done (void *cls) 396libgnunet_plugin_block_regex_done (void *cls)
372{ 397{
373 struct GNUNET_TRANSPORT_PluginFunctions *api = cls; 398 struct GNUNET_BLOCK_PluginFunctions *api = cls;
374 399
375 GNUNET_free (api); 400 GNUNET_free (api);
376 return NULL; 401 return NULL;