aboutsummaryrefslogtreecommitdiff
path: root/src/regex
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-02-20 15:09:00 +0100
committerChristian Grothoff <christian@grothoff.org>2017-02-20 15:09:19 +0100
commita3882b58f1c5976677aa65b0af8a48e8e946b06e (patch)
treebd841d8e78052a05821e194d002ca843693fb2c9 /src/regex
parentf0149c5430f42a8bad422e9c51754af59c7bfa2f (diff)
downloadgnunet-a3882b58f1c5976677aa65b0af8a48e8e946b06e.tar.gz
gnunet-a3882b58f1c5976677aa65b0af8a48e8e946b06e.zip
first half of new BLOCK API to generalize duplicate detection beyond BFs
Diffstat (limited to 'src/regex')
-rw-r--r--src/regex/Makefile.am1
-rw-r--r--src/regex/plugin_block_regex.c37
2 files changed, 37 insertions, 1 deletions
diff --git a/src/regex/Makefile.am b/src/regex/Makefile.am
index 70f612485..80997db40 100644
--- a/src/regex/Makefile.am
+++ b/src/regex/Makefile.am
@@ -80,6 +80,7 @@ libgnunet_plugin_block_regex_la_SOURCES = \
80libgnunet_plugin_block_regex_la_LIBADD = \ 80libgnunet_plugin_block_regex_la_LIBADD = \
81 libgnunetregexblock.la \ 81 libgnunetregexblock.la \
82 $(top_builddir)/src/block/libgnunetblock.la \ 82 $(top_builddir)/src/block/libgnunetblock.la \
83 $(top_builddir)/src/block/libgnunetblockgroup.la \
83 $(top_builddir)/src/util/libgnunetutil.la 84 $(top_builddir)/src/util/libgnunetutil.la
84libgnunet_plugin_block_regex_la_LDFLAGS = \ 85libgnunet_plugin_block_regex_la_LDFLAGS = \
85 $(GN_PLUGIN_LDFLAGS) 86 $(GN_PLUGIN_LDFLAGS)
diff --git a/src/regex/plugin_block_regex.c b/src/regex/plugin_block_regex.c
index 36926c25d..11511a71b 100644
--- a/src/regex/plugin_block_regex.c
+++ b/src/regex/plugin_block_regex.c
@@ -23,9 +23,9 @@
23 * @brief blocks used for regex storage and search 23 * @brief blocks used for regex storage and search
24 * @author Bartlomiej Polot 24 * @author Bartlomiej Polot
25 */ 25 */
26
27#include "platform.h" 26#include "platform.h"
28#include "gnunet_block_plugin.h" 27#include "gnunet_block_plugin.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" 31#include "gnunet_constants.h"
@@ -33,6 +33,40 @@
33 33
34 34
35/** 35/**
36 * How big is the BF we use for REGEX blocks?
37 */
38#define REGEX_BF_SIZE 8
39
40
41/**
42 * Create a new block group.
43 *
44 * @param ctx block context in which the block group is created
45 * @param type type of the block for which we are creating the group
46 * @param nonce random value used to seed the group creation
47 * @param raw_data optional serialized prior state of the group, NULL if unavailable/fresh
48 * @param raw_data_size number of bytes in @a raw_data, 0 if unavailable/fresh
49 * @return block group handle, NULL if block groups are not supported
50 * by this @a type of block (this is not an error)
51 */
52static struct GNUNET_BLOCK_Group *
53block_plugin_regex_create_group (void *cls,
54 enum GNUNET_BLOCK_Type type,
55 uint32_t nonce,
56 const void *raw_data,
57 size_t raw_data_size)
58{
59 return GNUNET_BLOCK_GROUP_bf_create (cls,
60 REGEX_BF_SIZE,
61 GNUNET_CONSTANTS_BLOOMFILTER_K,
62 type,
63 nonce,
64 raw_data,
65 raw_data_size);
66}
67
68
69/**
36 * Function called to validate a reply or a request of type 70 * Function called to validate a reply or a request of type
37 * #GNUNET_BLOCK_TYPE_REGEX. 71 * #GNUNET_BLOCK_TYPE_REGEX.
38 * For request evaluation, pass "NULL" for the reply_block. 72 * For request evaluation, pass "NULL" for the reply_block.
@@ -346,6 +380,7 @@ libgnunet_plugin_block_regex_init (void *cls)
346 api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions); 380 api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions);
347 api->evaluate = &block_plugin_regex_evaluate; 381 api->evaluate = &block_plugin_regex_evaluate;
348 api->get_key = &block_plugin_regex_get_key; 382 api->get_key = &block_plugin_regex_get_key;
383 api->create_group = &block_plugin_regex_create_group;
349 api->types = types; 384 api->types = types;
350 return api; 385 return api;
351} 386}