aboutsummaryrefslogtreecommitdiff
path: root/src/regex/regex_internal_dht.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/regex/regex_internal_dht.c')
-rw-r--r--src/regex/regex_internal_dht.c58
1 files changed, 29 insertions, 29 deletions
diff --git a/src/regex/regex_internal_dht.c b/src/regex/regex_internal_dht.c
index ef0155177..55ca426cb 100644
--- a/src/regex/regex_internal_dht.c
+++ b/src/regex/regex_internal_dht.c
@@ -121,7 +121,7 @@ regex_iterator (void *cls,
121 ab.purpose.purpose = ntohl (GNUNET_SIGNATURE_PURPOSE_REGEX_ACCEPT); 121 ab.purpose.purpose = ntohl (GNUNET_SIGNATURE_PURPOSE_REGEX_ACCEPT);
122 ab.expiration_time = GNUNET_TIME_absolute_hton (GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_DHT_MAX_EXPIRATION)); 122 ab.expiration_time = GNUNET_TIME_absolute_hton (GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_DHT_MAX_EXPIRATION));
123 ab.key = *key; 123 ab.key = *key;
124 GNUNET_CRYPTO_ecc_key_get_public_for_signature (h->priv, 124 GNUNET_CRYPTO_ecc_key_get_public_for_signature (h->priv,
125 &ab.peer.public_key); 125 &ab.peer.public_key);
126 GNUNET_assert (GNUNET_OK == 126 GNUNET_assert (GNUNET_OK ==
127 GNUNET_CRYPTO_ecc_sign (h->priv, 127 GNUNET_CRYPTO_ecc_sign (h->priv,
@@ -151,7 +151,7 @@ regex_iterator (void *cls,
151 GNUNET_DHT_put (h->dht, key, 151 GNUNET_DHT_put (h->dht, key,
152 DHT_REPLICATION, 152 DHT_REPLICATION,
153 DHT_OPT, 153 DHT_OPT,
154 GNUNET_BLOCK_TYPE_REGEX, 154 GNUNET_BLOCK_TYPE_REGEX,
155 size, block, 155 size, block,
156 GNUNET_TIME_relative_to_absolute (DHT_TTL), 156 GNUNET_TIME_relative_to_absolute (DHT_TTL),
157 DHT_TTL, 157 DHT_TTL,
@@ -167,13 +167,13 @@ regex_iterator (void *cls,
167/** 167/**
168 * Announce a regular expression: put all states of the automaton in the DHT. 168 * Announce a regular expression: put all states of the automaton in the DHT.
169 * Does not free resources, must call REGEX_INTERNAL_announce_cancel for that. 169 * Does not free resources, must call REGEX_INTERNAL_announce_cancel for that.
170 * 170 *
171 * @param dht An existing and valid DHT service handle. CANNOT be NULL. 171 * @param dht An existing and valid DHT service handle. CANNOT be NULL.
172 * @param priv our private key, must remain valid until the announcement is cancelled 172 * @param priv our private key, must remain valid until the announcement is cancelled
173 * @param regex Regular expression to announce. 173 * @param regex Regular expression to announce.
174 * @param compression How many characters per edge can we squeeze? 174 * @param compression How many characters per edge can we squeeze?
175 * @param stats Optional statistics handle to report usage. Can be NULL. 175 * @param stats Optional statistics handle to report usage. Can be NULL.
176 * 176 *
177 * @return Handle to reuse o free cached resources. 177 * @return Handle to reuse o free cached resources.
178 * Must be freed by calling REGEX_INTERNAL_announce_cancel. 178 * Must be freed by calling REGEX_INTERNAL_announce_cancel.
179 */ 179 */
@@ -201,14 +201,14 @@ REGEX_INTERNAL_announce (struct GNUNET_DHT_Handle *dht,
201/** 201/**
202 * Announce again a regular expression previously announced. 202 * Announce again a regular expression previously announced.
203 * Does use caching to speed up process. 203 * Does use caching to speed up process.
204 * 204 *
205 * @param h Handle returned by a previous REGEX_INTERNAL_announce call. 205 * @param h Handle returned by a previous REGEX_INTERNAL_announce call.
206 */ 206 */
207void 207void
208REGEX_INTERNAL_reannounce (struct REGEX_INTERNAL_Announcement *h) 208REGEX_INTERNAL_reannounce (struct REGEX_INTERNAL_Announcement *h)
209{ 209{
210 GNUNET_assert (NULL != h->dfa); /* make sure to call announce first */ 210 GNUNET_assert (NULL != h->dfa); /* make sure to call announce first */
211 LOG (GNUNET_ERROR_TYPE_INFO, 211 LOG (GNUNET_ERROR_TYPE_INFO,
212 "REGEX_INTERNAL_reannounce: %s\n", 212 "REGEX_INTERNAL_reannounce: %s\n",
213 h->regex); 213 h->regex);
214 REGEX_INTERNAL_iterate_reachable_edges (h->dfa, &regex_iterator, h); 214 REGEX_INTERNAL_iterate_reachable_edges (h->dfa, &regex_iterator, h);
@@ -218,7 +218,7 @@ REGEX_INTERNAL_reannounce (struct REGEX_INTERNAL_Announcement *h)
218/** 218/**
219 * Clear all cached data used by a regex announce. 219 * Clear all cached data used by a regex announce.
220 * Does not close DHT connection. 220 * Does not close DHT connection.
221 * 221 *
222 * @param h Handle returned by a previous REGEX_INTERNAL_announce call. 222 * @param h Handle returned by a previous REGEX_INTERNAL_announce call.
223 */ 223 */
224void 224void
@@ -264,7 +264,7 @@ struct RegexSearchContext
264 264
265/** 265/**
266 * Type of values in 'dht_get_results'. 266 * Type of values in 'dht_get_results'.
267 */ 267 */
268struct Result 268struct Result
269{ 269{
270 /** 270 /**
@@ -306,7 +306,7 @@ struct REGEX_INTERNAL_Search
306 struct GNUNET_CONTAINER_MultiHashMap *dht_get_handles; 306 struct GNUNET_CONTAINER_MultiHashMap *dht_get_handles;
307 307
308 /** 308 /**
309 * Results from running DHT GETs, values are of type 309 * Results from running DHT GETs, values are of type
310 * 'struct Result'. 310 * 'struct Result'.
311 */ 311 */
312 struct GNUNET_CONTAINER_MultiHashMap *dht_get_results; 312 struct GNUNET_CONTAINER_MultiHashMap *dht_get_results;
@@ -320,7 +320,7 @@ struct REGEX_INTERNAL_Search
320 * Number of contexts (branches/steps in search). 320 * Number of contexts (branches/steps in search).
321 */ 321 */
322 unsigned int n_contexts; 322 unsigned int n_contexts;
323 323
324 /** 324 /**
325 * @param callback Callback for found peers. 325 * @param callback Callback for found peers.
326 */ 326 */
@@ -375,14 +375,14 @@ dht_get_string_accept_handler (void *cls, struct GNUNET_TIME_Absolute exp,
375 struct RegexSearchContext *ctx = cls; 375 struct RegexSearchContext *ctx = cls;
376 struct REGEX_INTERNAL_Search *info = ctx->info; 376 struct REGEX_INTERNAL_Search *info = ctx->info;
377 377
378 LOG (GNUNET_ERROR_TYPE_DEBUG, 378 LOG (GNUNET_ERROR_TYPE_DEBUG,
379 "Regex result accept for %s (key %s)\n", 379 "Regex result accept for %s (key %s)\n",
380 info->description, GNUNET_h2s(key)); 380 info->description, GNUNET_h2s(key));
381 381
382 GNUNET_STATISTICS_update (info->stats, 382 GNUNET_STATISTICS_update (info->stats,
383 "# regex accepting blocks found", 383 "# regex accepting blocks found",
384 1, GNUNET_NO); 384 1, GNUNET_NO);
385 GNUNET_STATISTICS_update (info->stats, 385 GNUNET_STATISTICS_update (info->stats,
386 "# regex accepting block bytes found", 386 "# regex accepting block bytes found",
387 size, GNUNET_NO); 387 size, GNUNET_NO);
388 info->callback (info->callback_cls, 388 info->callback (info->callback_cls,
@@ -395,7 +395,7 @@ dht_get_string_accept_handler (void *cls, struct GNUNET_TIME_Absolute exp,
395/** 395/**
396 * Find a path to a peer that offers a regex servcie compatible 396 * Find a path to a peer that offers a regex servcie compatible
397 * with a given string. 397 * with a given string.
398 * 398 *
399 * @param key The key of the accepting state. 399 * @param key The key of the accepting state.
400 * @param ctx Context containing info about the string, tunnel, etc. 400 * @param ctx Context containing info about the string, tunnel, etc.
401 */ 401 */
@@ -457,7 +457,7 @@ dht_get_string_handler (void *cls, struct GNUNET_TIME_Absolute exp,
457 size_t len; 457 size_t len;
458 struct Result *copy; 458 struct Result *copy;
459 459
460 LOG (GNUNET_ERROR_TYPE_INFO, 460 LOG (GNUNET_ERROR_TYPE_INFO,
461 "DHT GET result for %s (%s)\n", 461 "DHT GET result for %s (%s)\n",
462 GNUNET_h2s (key), ctx->info->description); 462 GNUNET_h2s (key), ctx->info->description);
463 copy = GNUNET_malloc (sizeof (struct Result) + size); 463 copy = GNUNET_malloc (sizeof (struct Result) + size);
@@ -503,18 +503,18 @@ regex_result_iterator (void *cls,
503 const struct RegexBlock *block = result->data; 503 const struct RegexBlock *block = result->data;
504 struct RegexSearchContext *ctx = cls; 504 struct RegexSearchContext *ctx = cls;
505 505
506 if ( (GNUNET_YES == 506 if ( (GNUNET_YES ==
507 GNUNET_BLOCK_is_accepting (block, result->size)) && 507 GNUNET_BLOCK_is_accepting (block, result->size)) &&
508 (ctx->position == strlen (ctx->info->description)) ) 508 (ctx->position == strlen (ctx->info->description)) )
509 { 509 {
510 LOG (GNUNET_ERROR_TYPE_INFO, 510 LOG (GNUNET_ERROR_TYPE_INFO,
511 "Found accepting known block\n"); 511 "Found accepting known block\n");
512 regex_find_path (key, ctx); 512 regex_find_path (key, ctx);
513 return GNUNET_YES; // We found an accept state! 513 return GNUNET_YES; // We found an accept state!
514 } 514 }
515 LOG (GNUNET_ERROR_TYPE_DEBUG, 515 LOG (GNUNET_ERROR_TYPE_DEBUG,
516 "* %u, %u, [%u]\n", 516 "* %u, %u, [%u]\n",
517 ctx->position, 517 ctx->position,
518 strlen (ctx->info->description), 518 strlen (ctx->info->description),
519 GNUNET_BLOCK_is_accepting (block, result->size)); 519 GNUNET_BLOCK_is_accepting (block, result->size));
520 regex_next_edge (block, result->size, ctx); 520 regex_next_edge (block, result->size, ctx);
@@ -554,12 +554,12 @@ regex_edge_iterator (void *cls,
554 if (len > current_len) 554 if (len > current_len)
555 { 555 {
556 LOG (GNUNET_ERROR_TYPE_DEBUG, "Token too long, END\n"); 556 LOG (GNUNET_ERROR_TYPE_DEBUG, "Token too long, END\n");
557 return GNUNET_YES; 557 return GNUNET_YES;
558 } 558 }
559 if (0 != strncmp (current, token, len)) 559 if (0 != strncmp (current, token, len))
560 { 560 {
561 LOG (GNUNET_ERROR_TYPE_DEBUG, "Token doesn't match, END\n"); 561 LOG (GNUNET_ERROR_TYPE_DEBUG, "Token doesn't match, END\n");
562 return GNUNET_YES; 562 return GNUNET_YES;
563 } 563 }
564 564
565 if (len > ctx->longest_match) 565 if (len > ctx->longest_match)
@@ -598,7 +598,7 @@ regex_next_edge (const struct RegexBlock *block,
598 int result; 598 int result;
599 599
600 LOG (GNUNET_ERROR_TYPE_DEBUG, "Next edge\n"); 600 LOG (GNUNET_ERROR_TYPE_DEBUG, "Next edge\n");
601 /* Find the longest match for the current string position, 601 /* Find the longest match for the current string position,
602 * among tokens in the given block */ 602 * among tokens in the given block */
603 ctx->longest_match = 0; 603 ctx->longest_match = 0;
604 result = REGEX_BLOCK_iterate (block, size, 604 result = REGEX_BLOCK_iterate (block, size,
@@ -608,7 +608,7 @@ regex_next_edge (const struct RegexBlock *block,
608 /* Did anything match? */ 608 /* Did anything match? */
609 if (0 == ctx->longest_match) 609 if (0 == ctx->longest_match)
610 { 610 {
611 LOG (GNUNET_ERROR_TYPE_DEBUG, 611 LOG (GNUNET_ERROR_TYPE_DEBUG,
612 "no match in block\n"); 612 "no match in block\n");
613 return; 613 return;
614 } 614 }
@@ -623,7 +623,7 @@ regex_next_edge (const struct RegexBlock *block,
623 if (GNUNET_YES == 623 if (GNUNET_YES ==
624 GNUNET_CONTAINER_multihashmap_contains (info->dht_get_handles, hash)) 624 GNUNET_CONTAINER_multihashmap_contains (info->dht_get_handles, hash))
625 { 625 {
626 LOG (GNUNET_ERROR_TYPE_DEBUG, 626 LOG (GNUNET_ERROR_TYPE_DEBUG,
627 "GET for %s running, END\n", 627 "GET for %s running, END\n",
628 GNUNET_h2s (hash)); 628 GNUNET_h2s (hash));
629 GNUNET_CONTAINER_multihashmap_get_multiple (info->dht_get_results, 629 GNUNET_CONTAINER_multihashmap_get_multiple (info->dht_get_results,
@@ -636,11 +636,11 @@ regex_next_edge (const struct RegexBlock *block,
636 GNUNET_STATISTICS_update (info->stats, "# regex nodes traversed", 636 GNUNET_STATISTICS_update (info->stats, "# regex nodes traversed",
637 1, GNUNET_NO); 637 1, GNUNET_NO);
638 638
639 LOG (GNUNET_ERROR_TYPE_INFO, 639 LOG (GNUNET_ERROR_TYPE_INFO,
640 "looking for %s\n", 640 "looking for %s\n",
641 GNUNET_h2s (hash)); 641 GNUNET_h2s (hash));
642 rest = &new_ctx->info->description[new_ctx->position]; 642 rest = &new_ctx->info->description[new_ctx->position];
643 get_h = 643 get_h =
644 GNUNET_DHT_get_start (info->dht, /* handle */ 644 GNUNET_DHT_get_start (info->dht, /* handle */
645 GNUNET_BLOCK_TYPE_REGEX, /* type */ 645 GNUNET_BLOCK_TYPE_REGEX, /* type */
646 hash, /* key to search */ 646 hash, /* key to search */
@@ -671,7 +671,7 @@ regex_next_edge (const struct RegexBlock *block,
671 * @param callback Callback for found peers. 671 * @param callback Callback for found peers.
672 * @param callback_cls Closure for @c callback. 672 * @param callback_cls Closure for @c callback.
673 * @param stats Optional statistics handle to report usage. Can be NULL. 673 * @param stats Optional statistics handle to report usage. Can be NULL.
674 * 674 *
675 * @return Handle to stop search and free resources. 675 * @return Handle to stop search and free resources.
676 * Must be freed by calling REGEX_INTERNAL_search_cancel. 676 * Must be freed by calling REGEX_INTERNAL_search_cancel.
677 */ 677 */
@@ -712,8 +712,8 @@ REGEX_INTERNAL_search (struct GNUNET_DHT_Handle *dht,
712 ctx->position = size; 712 ctx->position = size;
713 ctx->info = h; 713 ctx->info = h;
714 GNUNET_array_append (h->contexts, h->n_contexts, ctx); 714 GNUNET_array_append (h->contexts, h->n_contexts, ctx);
715 LOG (GNUNET_ERROR_TYPE_DEBUG, 715 LOG (GNUNET_ERROR_TYPE_DEBUG,
716 "consumed %u bits out of %u, now looking for %s\n", 716 "consumed %u bits out of %u, now looking for %s\n",
717 size, len, 717 size, len,
718 GNUNET_h2s (&key)); 718 GNUNET_h2s (&key));
719 719