aboutsummaryrefslogtreecommitdiff
path: root/src/regex
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-02-28 21:12:03 +0000
committerChristian Grothoff <christian@grothoff.org>2015-02-28 21:12:03 +0000
commit3a2737d76679c68331fad0be0b89d8efdcde5079 (patch)
tree5bd4ef163438954cdcb75558e6368a297629b56d /src/regex
parent9c46ed792caae948fd99cca44deaf5a265af7614 (diff)
downloadgnunet-3a2737d76679c68331fad0be0b89d8efdcde5079.tar.gz
gnunet-3a2737d76679c68331fad0be0b89d8efdcde5079.zip
-extend block API to allow specifying flags, use this to allow reducing checks for replies from local DB
Diffstat (limited to 'src/regex')
-rw-r--r--src/regex/plugin_block_regex.c67
1 files changed, 45 insertions, 22 deletions
diff --git a/src/regex/plugin_block_regex.c b/src/regex/plugin_block_regex.c
index 874f6b4cc..2d6a5b693 100644
--- a/src/regex/plugin_block_regex.c
+++ b/src/regex/plugin_block_regex.c
@@ -34,29 +34,34 @@
34 34
35/** 35/**
36 * Function called to validate a reply or a request of type 36 * Function called to validate a reply or a request of type
37 * GNUNET_BLOCK_TYPE_REGEX. 37 * #GNUNET_BLOCK_TYPE_REGEX.
38 * For request evaluation, pass "NULL" for the reply_block. 38 * For request evaluation, pass "NULL" for the reply_block.
39 * Note that it is assumed that the reply has already been 39 * Note that it is assumed that the reply has already been
40 * matched to the key (and signatures checked) as it would 40 * matched to the key (and signatures checked) as it would
41 * be done with the "get_key" function. 41 * be done with the #GNUNET_BLOCK_get_key() function.
42 * 42 *
43 * @param cls closure 43 * @param cls closure
44 * @param type block type 44 * @param type block type
45 * @param eo control flags
45 * @param query original query (hash) 46 * @param query original query (hash)
46 * @param bf pointer to bloom filter associated with query; possibly updated (!) 47 * @param bf pointer to bloom filter associated with query; possibly updated (!)
47 * @param bf_mutator mutation value for bf 48 * @param bf_mutator mutation value for bf
48 * @param xquery extrended query data (can be NULL, depending on type) 49 * @param xquery extrended query data (can be NULL, depending on type)
49 * @param xquery_size number of bytes in xquery 50 * @param xquery_size number of bytes in @a xquery
50 * @param reply_block response to validate 51 * @param reply_block response to validate
51 * @param reply_block_size number of bytes in reply block 52 * @param reply_block_size number of bytes in @a reply_block
52 * @return characterization of result 53 * @return characterization of result
53 */ 54 */
54static enum GNUNET_BLOCK_EvaluationResult 55static enum GNUNET_BLOCK_EvaluationResult
55evaluate_block_regex (void *cls, enum GNUNET_BLOCK_Type type, 56evaluate_block_regex (void *cls,
57 enum GNUNET_BLOCK_Type type,
58 enum GNUNET_BLOCK_EvaluationOptions eo,
56 const struct GNUNET_HashCode *query, 59 const struct GNUNET_HashCode *query,
57 struct GNUNET_CONTAINER_BloomFilter **bf, 60 struct GNUNET_CONTAINER_BloomFilter **bf,
58 int32_t bf_mutator, const void *xquery, 61 int32_t bf_mutator,
59 size_t xquery_size, const void *reply_block, 62 const void *xquery,
63 size_t xquery_size,
64 const void *reply_block,
60 size_t reply_block_size) 65 size_t reply_block_size)
61{ 66{
62 if (NULL == reply_block) 67 if (NULL == reply_block)
@@ -131,25 +136,28 @@ evaluate_block_regex (void *cls, enum GNUNET_BLOCK_Type type,
131 136
132/** 137/**
133 * Function called to validate a reply or a request of type 138 * Function called to validate a reply or a request of type
134 * GNUNET_BLOCK_TYPE_REGEX_ACCEPT. 139 * #GNUNET_BLOCK_TYPE_REGEX_ACCEPT.
135 * For request evaluation, pass "NULL" for the reply_block. 140 * For request evaluation, pass "NULL" for the reply_block.
136 * Note that it is assumed that the reply has already been 141 * Note that it is assumed that the reply has already been
137 * matched to the key (and signatures checked) as it would 142 * matched to the key (and signatures checked) as it would
138 * be done with the "get_key" function. 143 * be done with the #GNUNET_BLOCK_get_key() function.
139 * 144 *
140 * @param cls closure 145 * @param cls closure
141 * @param type block type 146 * @param type block type
147 * @param eo control flags
142 * @param query original query (hash) 148 * @param query original query (hash)
143 * @param bf pointer to bloom filter associated with query; possibly updated (!) 149 * @param bf pointer to bloom filter associated with query; possibly updated (!)
144 * @param bf_mutator mutation value for bf 150 * @param bf_mutator mutation value for bf
145 * @param xquery extrended query data (can be NULL, depending on type) 151 * @param xquery extrended query data (can be NULL, depending on type)
146 * @param xquery_size number of bytes in xquery 152 * @param xquery_size number of bytes in @a xquery
147 * @param reply_block response to validate 153 * @param reply_block response to validate
148 * @param reply_block_size number of bytes in reply block 154 * @param reply_block_size number of bytes in @a reply_block
149 * @return characterization of result 155 * @return characterization of result
150 */ 156 */
151static enum GNUNET_BLOCK_EvaluationResult 157static enum GNUNET_BLOCK_EvaluationResult
152evaluate_block_regex_accept (void *cls, enum GNUNET_BLOCK_Type type, 158evaluate_block_regex_accept (void *cls,
159 enum GNUNET_BLOCK_Type type,
160 enum GNUNET_BLOCK_EvaluationOptions eo,
153 const struct GNUNET_HashCode * query, 161 const struct GNUNET_HashCode * query,
154 struct GNUNET_CONTAINER_BloomFilter **bf, 162 struct GNUNET_CONTAINER_BloomFilter **bf,
155 int32_t bf_mutator, const void *xquery, 163 int32_t bf_mutator, const void *xquery,
@@ -221,10 +229,11 @@ evaluate_block_regex_accept (void *cls, enum GNUNET_BLOCK_Type type,
221 * request evaluation, simply pass "NULL" for the reply_block. 229 * request evaluation, simply pass "NULL" for the reply_block.
222 * Note that it is assumed that the reply has already been 230 * Note that it is assumed that the reply has already been
223 * matched to the key (and signatures checked) as it would 231 * matched to the key (and signatures checked) as it would
224 * be done with the "get_key" function. 232 * be done with the #GNUNET_BLOCK_get_key() function.
225 * 233 *
226 * @param cls closure 234 * @param cls closure
227 * @param type block type 235 * @param type block type
236 * @param eo control flags
228 * @param query original query (hash) 237 * @param query original query (hash)
229 * @param bf pointer to bloom filter associated with query; possibly updated (!) 238 * @param bf pointer to bloom filter associated with query; possibly updated (!)
230 * @param bf_mutator mutation value for bf 239 * @param bf_mutator mutation value for bf
@@ -235,11 +244,15 @@ evaluate_block_regex_accept (void *cls, enum GNUNET_BLOCK_Type type,
235 * @return characterization of result 244 * @return characterization of result
236 */ 245 */
237static enum GNUNET_BLOCK_EvaluationResult 246static enum GNUNET_BLOCK_EvaluationResult
238block_plugin_regex_evaluate (void *cls, enum GNUNET_BLOCK_Type type, 247block_plugin_regex_evaluate (void *cls,
239 const struct GNUNET_HashCode * query, 248 enum GNUNET_BLOCK_Type type,
249 enum GNUNET_BLOCK_EvaluationOptions eo,
250 const struct GNUNET_HashCode *query,
240 struct GNUNET_CONTAINER_BloomFilter **bf, 251 struct GNUNET_CONTAINER_BloomFilter **bf,
241 int32_t bf_mutator, const void *xquery, 252 int32_t bf_mutator,
242 size_t xquery_size, const void *reply_block, 253 const void *xquery,
254 size_t xquery_size,
255 const void *reply_block,
243 size_t reply_block_size) 256 size_t reply_block_size)
244{ 257{
245 enum GNUNET_BLOCK_EvaluationResult result; 258 enum GNUNET_BLOCK_EvaluationResult result;
@@ -247,12 +260,20 @@ block_plugin_regex_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
247 switch (type) 260 switch (type)
248 { 261 {
249 case GNUNET_BLOCK_TYPE_REGEX: 262 case GNUNET_BLOCK_TYPE_REGEX:
250 result = evaluate_block_regex (cls, type, query, bf, bf_mutator, 263 result = evaluate_block_regex (cls,
264 type,
265 eo,
266 query,
267 bf, bf_mutator,
251 xquery, xquery_size, 268 xquery, xquery_size,
252 reply_block, reply_block_size); 269 reply_block, reply_block_size);
253 break; 270 break;
254 case GNUNET_BLOCK_TYPE_REGEX_ACCEPT: 271 case GNUNET_BLOCK_TYPE_REGEX_ACCEPT:
255 result = evaluate_block_regex_accept (cls, type, query, bf, bf_mutator, 272 result = evaluate_block_regex_accept (cls,
273 type,
274 eo,
275 query,
276 bf, bf_mutator,
256 xquery, xquery_size, 277 xquery, xquery_size,
257 reply_block, reply_block_size); 278 reply_block, reply_block_size);
258 break; 279 break;
@@ -276,9 +297,11 @@ block_plugin_regex_evaluate (void *cls, enum GNUNET_BLOCK_Type type,
276 * (or if extracting a key from a block of this type does not work) 297 * (or if extracting a key from a block of this type does not work)
277 */ 298 */
278static int 299static int
279block_plugin_regex_get_key (void *cls, enum GNUNET_BLOCK_Type type, 300block_plugin_regex_get_key (void *cls,
280 const void *block, size_t block_size, 301 enum GNUNET_BLOCK_Type type,
281 struct GNUNET_HashCode * key) 302 const void *block,
303 size_t block_size,
304 struct GNUNET_HashCode *key)
282{ 305{
283 switch (type) 306 switch (type)
284 { 307 {