GNUnet  0.10.x
regex_internal_dht.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet
3  Copyright (C) 2012, 2015 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19 */
26 #include "platform.h"
27 #include "regex_internal_lib.h"
28 #include "regex_block_lib.h"
29 #include "gnunet_dht_service.h"
31 #include "gnunet_constants.h"
32 #include "gnunet_signatures.h"
33 
34 
35 #define LOG(kind,...) GNUNET_log_from (kind,"regex-dht",__VA_ARGS__)
36 
40 #define DHT_REPLICATION 5
41 
45 #define DHT_TTL GNUNET_TIME_UNIT_HOURS
46 
50 #define DHT_OPT GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE
51 
52 
57 {
62 
66  const char *regex;
67 
72 
77 
82 };
83 
84 
95 static void
96 regex_iterator (void *cls,
97  const struct GNUNET_HashCode *key,
98  const char *proof,
99  int accepting,
100  unsigned int num_edges,
101  const struct REGEX_BLOCK_Edge *edges)
102 {
103  struct REGEX_INTERNAL_Announcement *h = cls;
104  struct RegexBlock *block;
105  size_t size;
106  unsigned int i;
107 
109  "DHT PUT for state %s with proof `%s' and %u edges:\n",
110  GNUNET_h2s (key),
111  proof,
112  num_edges);
113  for (i = 0; i < num_edges; i++)
114  {
116  "Edge %u `%s' towards %s\n",
117  i,
118  edges[i].label,
119  GNUNET_h2s (&edges[i].destination));
120  }
121  if (GNUNET_YES == accepting)
122  {
123  struct RegexAcceptBlock ab;
124 
126  "State %s is accepting, putting own id\n",
127  GNUNET_h2s (key));
128  size = sizeof (struct RegexAcceptBlock);
129  ab.purpose.size = ntohl (sizeof (struct GNUNET_CRYPTO_EccSignaturePurpose) +
130  sizeof (struct GNUNET_TIME_AbsoluteNBO) +
131  sizeof (struct GNUNET_HashCode));
134  ab.key = *key;
136  &ab.peer.public_key);
139  &ab.purpose,
140  &ab.signature));
141 
142  GNUNET_STATISTICS_update (h->stats, "# regex accepting blocks stored",
143  1, GNUNET_NO);
144  GNUNET_STATISTICS_update (h->stats, "# regex accepting block bytes stored",
145  sizeof (struct RegexAcceptBlock), GNUNET_NO);
146  (void)
147  GNUNET_DHT_put (h->dht, key,
151  size,
152  &ab,
154  NULL, NULL);
155  }
156  block = REGEX_BLOCK_create (proof,
157  num_edges,
158  edges,
159  accepting,
160  &size);
161  if (NULL == block)
162  return;
163  (void) GNUNET_DHT_put (h->dht,
164  key,
166  DHT_OPT,
168  size,
169  block,
171  NULL,
172  NULL);
174  "# regex blocks stored",
175  1,
176  GNUNET_NO);
178  "# regex block bytes stored",
179  size,
180  GNUNET_NO);
181  GNUNET_free (block);
182 }
183 
184 
199  const struct GNUNET_CRYPTO_EddsaPrivateKey *priv,
200  const char *regex,
201  uint16_t compression,
203 {
205 
206  GNUNET_assert (NULL != dht);
208  h->regex = regex;
209  h->dht = dht;
210  h->stats = stats;
211  h->priv = priv;
212  h->dfa = REGEX_INTERNAL_construct_dfa (regex, strlen (regex), compression);
214  return h;
215 }
216 
217 
224 void
226 {
227  GNUNET_assert (NULL != h->dfa); /* make sure to call announce first */
229  "REGEX_INTERNAL_reannounce: %s\n",
230  h->regex);
233  h);
234 }
235 
236 
243 void
245 {
247  GNUNET_free (h);
248 }
249 
250 
251 /******************************************************************************/
252 
253 
259 {
264  size_t position;
265 
270 
275  unsigned int longest_match;
276 
280  struct GNUNET_HashCode hash;
281 };
282 
283 
287 struct Result
288 {
292  size_t size;
293 
297  const void *data;
298 };
299 
300 
306 {
311 
316 
320  char *description;
321 
326 
332 
337 
341  unsigned int n_contexts;
342 
347 
352 };
353 
354 
362 static void
363 regex_next_edge (const struct RegexBlock *block,
364  size_t size,
365  struct RegexSearchContext *ctx);
366 
367 
383 static void
385  const struct GNUNET_HashCode *key,
386  const struct GNUNET_PeerIdentity *get_path,
387  unsigned int get_path_length,
388  const struct GNUNET_PeerIdentity *put_path,
389  unsigned int put_path_length,
390  enum GNUNET_BLOCK_Type type,
391  size_t size, const void *data)
392 {
393  const struct RegexAcceptBlock *block = data;
394  struct RegexSearchContext *ctx = cls;
395  struct REGEX_INTERNAL_Search *info = ctx->info;
396 
398  "Regex result accept for %s (key %s)\n",
399  info->description, GNUNET_h2s(key));
400 
402  "# regex accepting blocks found",
403  1, GNUNET_NO);
405  "# regex accepting block bytes found",
406  size, GNUNET_NO);
407  info->callback (info->callback_cls,
408  &block->peer,
409  get_path, get_path_length,
410  put_path, put_path_length);
411 }
412 
413 
421 static void
423  struct RegexSearchContext *ctx)
424 {
425  struct GNUNET_DHT_GetHandle *get_h;
426 
428  "Accept state found, now searching for paths to %s\n",
429  GNUNET_h2s (key),
430  (unsigned int) ctx->position);
431  get_h = GNUNET_DHT_get_start (ctx->info->dht, /* handle */
433  key, /* key to search */
434  DHT_REPLICATION, /* replication level */
436  NULL, /* xquery */ // FIXME BLOOMFILTER
437  0, /* xquery bits */ // FIXME BLOOMFILTER SIZE
441  key,
442  get_h,
444 }
445 
446 
464 static void
466  const struct GNUNET_HashCode *key,
467  const struct GNUNET_PeerIdentity *get_path,
468  unsigned int get_path_length,
469  const struct GNUNET_PeerIdentity *put_path,
470  unsigned int put_path_length,
471  enum GNUNET_BLOCK_Type type,
472  size_t size, const void *data)
473 {
474  const struct RegexBlock *block = data;
475  struct RegexSearchContext *ctx = cls;
476  struct REGEX_INTERNAL_Search *info = ctx->info;
477  size_t len;
478  struct Result *copy;
479 
481  "DHT GET result for %s (%s)\n",
482  GNUNET_h2s (key), ctx->info->description);
483  copy = GNUNET_malloc (sizeof (struct Result) + size);
484  copy->size = size;
485  copy->data = &copy[1];
486  GNUNET_memcpy (&copy[1], block, size);
489  key, copy,
491  len = strlen (info->description);
492  if (len == ctx->position) // String processed
493  {
494  if (GNUNET_YES == GNUNET_BLOCK_is_accepting (block, size))
495  {
496  regex_find_path (key, ctx);
497  }
498  else
499  {
500  LOG (GNUNET_ERROR_TYPE_INFO, "block not accepting!\n");
501  /* FIXME REGEX this block not successful, wait for more? start timeout? */
502  }
503  return;
504  }
505  regex_next_edge (block, size, ctx);
506 }
507 
508 
517 static int
519  const struct GNUNET_HashCode * key,
520  void *value)
521 {
522  struct Result *result = value;
523  const struct RegexBlock *block = result->data;
524  struct RegexSearchContext *ctx = cls;
525 
526  if ( (GNUNET_YES ==
527  GNUNET_BLOCK_is_accepting (block, result->size)) &&
528  (ctx->position == strlen (ctx->info->description)) )
529  {
531  "Found accepting known block\n");
532  regex_find_path (key, ctx);
533  return GNUNET_YES; // We found an accept state!
534  }
536  "* %u, %u, [%u]\n",
537  ctx->position,
538  strlen (ctx->info->description),
539  GNUNET_BLOCK_is_accepting (block, result->size));
540  regex_next_edge (block, result->size, ctx);
541 
542  GNUNET_STATISTICS_update (ctx->info->stats, "# regex cadet blocks iterated",
543  1, GNUNET_NO);
544 
545  return GNUNET_YES;
546 }
547 
548 
558 static int
560  const char *token,
561  size_t len,
562  const struct GNUNET_HashCode *key)
563 {
564  struct RegexSearchContext *ctx = cls;
565  struct REGEX_INTERNAL_Search *info = ctx->info;
566  const char *current;
567  size_t current_len;
568 
569  GNUNET_STATISTICS_update (info->stats, "# regex edges iterated",
570  1, GNUNET_NO);
571  current = &info->description[ctx->position];
572  current_len = strlen (info->description) - ctx->position;
573  if (len > current_len)
574  {
575  LOG (GNUNET_ERROR_TYPE_DEBUG, "Token too long, END\n");
576  return GNUNET_YES;
577  }
578  if (0 != strncmp (current, token, len))
579  {
580  LOG (GNUNET_ERROR_TYPE_DEBUG, "Token doesn't match, END\n");
581  return GNUNET_YES;
582  }
583 
584  if (len > ctx->longest_match)
585  {
586  LOG (GNUNET_ERROR_TYPE_DEBUG, "Token is longer, KEEP\n");
587  ctx->longest_match = len;
588  ctx->hash = *key;
589  }
590  else
591  {
592  LOG (GNUNET_ERROR_TYPE_DEBUG, "Token is not longer, IGNORE\n");
593  }
594 
595  LOG (GNUNET_ERROR_TYPE_DEBUG, "* End of regex edge iterator\n");
596  return GNUNET_YES;
597 }
598 
599 
607 static void
608 regex_next_edge (const struct RegexBlock *block,
609  size_t size,
610  struct RegexSearchContext *ctx)
611 {
612  struct RegexSearchContext *new_ctx;
613  struct REGEX_INTERNAL_Search *info = ctx->info;
614  struct GNUNET_DHT_GetHandle *get_h;
615  struct GNUNET_HashCode *hash;
616  const char *rest;
617  int result;
618 
619  LOG (GNUNET_ERROR_TYPE_DEBUG, "Next edge\n");
620  /* Find the longest match for the current string position,
621  * among tokens in the given block */
622  ctx->longest_match = 0;
623  result = REGEX_BLOCK_iterate (block, size,
624  &regex_edge_iterator, ctx);
625  GNUNET_break (GNUNET_OK == result);
626 
627  /* Did anything match? */
628  if (0 == ctx->longest_match)
629  {
631  "no match in block\n");
632  return;
633  }
634 
635  hash = &ctx->hash;
636  new_ctx = GNUNET_new (struct RegexSearchContext);
637  new_ctx->info = info;
638  new_ctx->position = ctx->position + ctx->longest_match;
639  GNUNET_array_append (info->contexts, info->n_contexts, new_ctx);
640 
641  /* Check whether we already have a DHT GET running for it */
642  if (GNUNET_YES ==
644  {
646  "GET for %s running, END\n",
647  GNUNET_h2s (hash));
649  hash,
651  new_ctx);
652  return; /* We are already looking for it */
653  }
654 
655  GNUNET_STATISTICS_update (info->stats, "# regex nodes traversed",
656  1, GNUNET_NO);
657 
659  "Following edges at %s for offset %u in `%s'\n",
660  GNUNET_h2s (hash),
661  (unsigned int) ctx->position,
662  info->description);
663  rest = &new_ctx->info->description[new_ctx->position];
664  get_h =
665  GNUNET_DHT_get_start (info->dht, /* handle */
666  GNUNET_BLOCK_TYPE_REGEX, /* type */
667  hash, /* key to search */
668  DHT_REPLICATION, /* replication level */
669  DHT_OPT,
670  rest, /* xquery */
671  strlen (rest) + 1, /* xquery bits */
672  &dht_get_string_handler, new_ctx);
673  if (GNUNET_OK !=
675  hash,
676  get_h,
678  {
679  GNUNET_break (0);
680  return;
681  }
682 }
683 
684 
698 struct REGEX_INTERNAL_Search *
700  const char *string,
702  void *callback_cls,
704 {
705  struct REGEX_INTERNAL_Search *h;
706  struct GNUNET_DHT_GetHandle *get_h;
707  struct RegexSearchContext *ctx;
708  struct GNUNET_HashCode key;
709  size_t size;
710  size_t len;
711 
712  /* Initialize handle */
713  GNUNET_assert (NULL != dht);
714  GNUNET_assert (NULL != callback);
715  h = GNUNET_new (struct REGEX_INTERNAL_Search);
716  h->dht = dht;
717  h->description = GNUNET_strdup (string);
718  h->callback = callback;
719  h->callback_cls = callback_cls;
720  h->stats = stats;
723 
724  /* Initialize context */
725  len = strlen (string);
726  size = REGEX_INTERNAL_get_first_key (string, len, &key);
728  "Initial key for `%s' is %s (based on `%.*s')\n",
729  string,
730  GNUNET_h2s (&key),
731  size,
732  string);
733  ctx = GNUNET_new (struct RegexSearchContext);
734  ctx->position = size;
735  ctx->info = h;
737  h->n_contexts,
738  ctx);
739  /* Start search in DHT */
740  get_h = GNUNET_DHT_get_start (h->dht, /* handle */
741  GNUNET_BLOCK_TYPE_REGEX, /* type */
742  &key, /* key to search */
743  DHT_REPLICATION, /* replication level */
744  DHT_OPT,
745  &h->description[size], /* xquery */
746  // FIXME add BLOOMFILTER to exclude filtered peers
747  len + 1 - size, /* xquery bits */
748  // FIXME add BLOOMFILTER SIZE
749  &dht_get_string_handler, ctx);
750  GNUNET_break (
751  GNUNET_OK ==
753  &key,
754  get_h,
756  );
757 
758  return h;
759 }
760 
761 
772 static int
774  const struct GNUNET_HashCode * key,
775  void *value)
776 {
777  struct GNUNET_DHT_GetHandle *h = value;
778 
780  return GNUNET_YES;
781 }
782 
783 
794 static int
795 regex_free_result (void *cls,
796  const struct GNUNET_HashCode * key,
797  void *value)
798 {
799  GNUNET_free (value);
800  return GNUNET_YES;
801 }
802 
803 
809 void
811 {
812  unsigned int i;
813 
816  &regex_cancel_dht_get, NULL);
818  &regex_free_result, NULL);
821  if (0 < h->n_contexts)
822  {
823  for (i = 0; i < h->n_contexts; i++)
824  GNUNET_free (h->contexts[i]);
825  GNUNET_free (h->contexts);
826  }
827  GNUNET_free (h);
828 }
829 
830 
831 /* end of regex_internal_dht.c */
#define GNUNET_CONSTANTS_DHT_MAX_EXPIRATION
How long do we cache records at most in the DHT?
GNUNET_NETWORK_STRUCT_END int GNUNET_BLOCK_is_accepting(const struct RegexBlock *block, size_t size)
Test if this block is marked as being an accept state.
Block to store a cadet regex accepting state.
#define DHT_REPLICATION
DHT replication level to use.
const void * data
The raw result data.
We should keep track of the route that the message took in the P2P network.
size_t position
Part of the description already consumed by this particular search branch.
size_t REGEX_INTERNAL_get_first_key(const char *input_string, size_t string_len, struct GNUNET_HashCode *key)
Get the first key for the given input_string.
static void dht_get_string_accept_handler(void *cls, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, const struct GNUNET_PeerIdentity *get_path, unsigned int get_path_length, const struct GNUNET_PeerIdentity *put_path, unsigned int put_path_length, enum GNUNET_BLOCK_Type type, size_t size, const void *data)
Function to process DHT string to regex matching.
struct GNUNET_HashCode key
The key of the state.
Definition: block_regex.h:66
uint16_t num_edges
Number of edges parting from this state.
uint32_t purpose
What does this signature vouch for? This must contain a GNUNET_SIGNATURE_PURPOSE_XXX constant (from g...
GNUNET_BLOCK_Type
Blocks in the datastore and the datacache must have a unique type.
struct GNUNET_TIME_Absolute GNUNET_TIME_relative_to_absolute(struct GNUNET_TIME_Relative rel)
Convert relative time to an absolute time in the future.
Definition: time.c:245
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
int REGEX_BLOCK_iterate(const struct RegexBlock *block, size_t size, REGEX_INTERNAL_EgdeIterator iterator, void *iter_cls)
Iterate over all edges of a block of a regex state.
struct GNUNET_CRYPTO_EddsaSignature signature
The signature.
Definition: block_regex.h:76
Block to announce a regex state.
int GNUNET_CRYPTO_eddsa_sign(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const struct GNUNET_CRYPTO_EccSignaturePurpose *purpose, struct GNUNET_CRYPTO_EddsaSignature *sig)
EdDSA sign a given block.
Definition: crypto_ecc.c:989
Struct to keep state of running searches that have consumed a part of the inital string.
int GNUNET_CONTAINER_multihashmap_iterate(struct GNUNET_CONTAINER_MultiHashMap *map, GNUNET_CONTAINER_HashMapIterator it, void *it_cls)
Iterate over all entries in the map.
#define GNUNET_NO
Definition: gnunet_common.h:81
void REGEX_INTERNAL_announce_cancel(struct REGEX_INTERNAL_Announcement *h)
Clear all cached data used by a regex announce.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
const char * GNUNET_h2s(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Automaton representation.
static int regex_free_result(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator over hash map entries to free CadetRegexBlocks stored during the search for connect_by_strin...
int GNUNET_CONTAINER_multihashmap_contains(const struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key)
Check if the map contains any value under the given key (including values that are NULL)...
Block to announce a peer accepting a state.
Definition: block_regex.h:49
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
Handle for the service.
static void regex_iterator(void *cls, const struct GNUNET_HashCode *key, const char *proof, int accepting, unsigned int num_edges, const struct REGEX_BLOCK_Edge *edges)
Regex callback iterator to store own service description in the DHT.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
Time for absolute time used by GNUnet, in microseconds and in network byte order. ...
#define DHT_OPT
DHT options to set.
Internal representation of the hash map.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Edge representation.
static struct GNUNET_DNSSTUB_Context * ctx
Context for DNS resolution.
static struct GNUNET_ARM_Handle * h
Connection with ARM.
Definition: gnunet-arm.c:94
Connection to the DHT service.
Definition: dht_api.c:205
struct GNUNET_PeerIdentity peer
Public key of the peer signing.
Definition: block_regex.h:71
header of what an ECC signature signs this must be followed by "size - 8" bytes of the actual signed ...
struct GNUNET_HashCode hash
Destination hash of the longest match.
static void dht_get_string_handler(void *cls, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, const struct GNUNET_PeerIdentity *get_path, unsigned int get_path_length, const struct GNUNET_PeerIdentity *put_path, unsigned int put_path_length, enum GNUNET_BLOCK_Type type, size_t size, const void *data)
Function to process DHT string to regex matching.
#define DHT_TTL
DHT record lifetime to use.
#define GNUNET_memcpy(dst, src, n)
, &#39; bother checking if a value already exists (faster than GNUNET_CONTAINER_MULTIHASHMAPOPTION_...
static char * value
Value of the record to add/remove.
library to parse regular expressions into dfa
static uint64_t proof
Definition: gnunet-scrypt.c:41
void GNUNET_CONTAINER_multihashmap_destroy(struct GNUNET_CONTAINER_MultiHashMap *map)
Destroy a hash map.
static int regex_cancel_dht_get(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator over hash map entries to cancel DHT GET requests after a successful connect_by_string.
struct REGEX_INTERNAL_Search * info
Information about the search.
static int result
Global testing status.
Handle to store cached data about a regex announce.
void REGEX_INTERNAL_search_cancel(struct REGEX_INTERNAL_Search *h)
Cancel an ongoing regex search in the DHT and free all resources.
uint32_t size
How many bytes does this signature sign? (including this purpose header); in network byte order (!)...
struct GNUNET_CRYPTO_EccSignaturePurpose purpose
Accept blocks must be signed.
Definition: block_regex.h:56
A 512-bit hashcode.
void GNUNET_DHT_get_stop(struct GNUNET_DHT_GetHandle *get_handle)
Stop async DHT-get.
Definition: dht_api.c:1160
Type of values in dht_get_results.
struct RegexBlock * REGEX_BLOCK_create(const char *proof, unsigned int num_edges, const struct REGEX_BLOCK_Edge *edges, int accepting, size_t *rsize)
Construct a regex block to be stored in the DHT.
struct GNUNET_CONTAINER_MultiHashMap * dht_get_results
Results from running DHT GETs, values are of type &#39;struct Result&#39;.
void(* REGEX_INTERNAL_Found)(void *cls, const struct GNUNET_PeerIdentity *id, const struct GNUNET_PeerIdentity *get_path, unsigned int get_path_length, const struct GNUNET_PeerIdentity *put_path, unsigned int put_path_length)
Search callback function.
struct GNUNET_HashCode key
The key used in the DHT.
struct GNUNET_DHT_PutHandle * GNUNET_DHT_put(struct GNUNET_DHT_Handle *handle, const struct GNUNET_HashCode *key, uint32_t desired_replication_level, enum GNUNET_DHT_RouteOption options, enum GNUNET_BLOCK_Type type, size_t size, const void *data, struct GNUNET_TIME_Absolute exp, GNUNET_SCHEDULER_TaskCallback cont, void *cont_cls)
Perform a PUT operation storing data in the DHT.
Definition: dht_api.c:971
static unsigned int size
Size of the "table".
Definition: peer.c:67
struct REGEX_INTERNAL_Search * REGEX_INTERNAL_search(struct GNUNET_DHT_Handle *dht, const char *string, REGEX_INTERNAL_Found callback, void *callback_cls, struct GNUNET_STATISTICS_Handle *stats)
Search for a peer offering a regex matching certain string in the DHT.
struct REGEX_INTERNAL_Announcement * REGEX_INTERNAL_announce(struct GNUNET_DHT_Handle *dht, const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, const char *regex, uint16_t compression, struct GNUNET_STATISTICS_Handle *stats)
Announce a regular expression: put all states of the automaton in the DHT.
struct GNUNET_DHT_Handle * dht
DHT handle to use, must be initialized externally.
unsigned int n_contexts
Number of contexts (branches/steps in search).
void REGEX_INTERNAL_automaton_destroy(struct REGEX_INTERNAL_Automaton *a)
Free the memory allocated by constructing the REGEX_INTERNAL_Automaton data structure.
static int regex_edge_iterator(void *cls, const char *token, size_t len, const struct GNUNET_HashCode *key)
Iterator over edges in a regex block retrieved from the DHT.
int GNUNET_CONTAINER_multihashmap_put(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
Handle to a GET request.
Definition: dht_api.c:80
struct GNUNET_STATISTICS_Handle * stats
Optional statistics handle to report usage.
void GNUNET_CRYPTO_eddsa_key_get_public(const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, struct GNUNET_CRYPTO_EddsaPublicKey *pub)
Extract the public key for the given private key.
Definition: crypto_ecc.c:272
Struct to keep information of searches of services described by a regex using a user-provided string ...
void REGEX_INTERNAL_reannounce(struct REGEX_INTERNAL_Announcement *h)
Announce again a regular expression previously announced.
Allow multiple values with the same key.
Private ECC key encoded for transmission.
#define GNUNET_array_append(arr, size, element)
Append an element to a list (growing the list by one).
The identity of the host (wraps the signing key of the peer).
struct GNUNET_DHT_GetHandle * GNUNET_DHT_get_start(struct GNUNET_DHT_Handle *handle, enum GNUNET_BLOCK_Type type, const struct GNUNET_HashCode *key, uint32_t desired_replication_level, enum GNUNET_DHT_RouteOption options, const void *xquery, size_t xquery_size, GNUNET_DHT_GetIterator iter, void *iter_cls)
Perform an asynchronous GET operation on the DHT identified.
Definition: dht_api.c:1072
#define GNUNET_SIGNATURE_PURPOSE_REGEX_ACCEPT
Accept state in regex DFA.
struct REGEX_INTERNAL_Automaton * REGEX_INTERNAL_construct_dfa(const char *regex, const size_t len, unsigned int max_path_len)
Construct DFA for the given &#39;regex&#39; of length &#39;len&#39;.
int GNUNET_CONTAINER_multihashmap_get_multiple(struct GNUNET_CONTAINER_MultiHashMap *map, const struct GNUNET_HashCode *key, GNUNET_CONTAINER_HashMapIterator it, void *it_cls)
Iterate over all entries in the map that match a particular key.
common function to manipulate blocks stored by regex in the DHT
char * description
User provided description of the searched service.
REGEX_INTERNAL_Found callback
struct GNUNET_CONTAINER_MultiHashMap * GNUNET_CONTAINER_multihashmap_create(unsigned int len, int do_not_copy_keys)
Create a multi hash map.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
const char * regex
Regular expression.
Time for absolute times used by GNUnet, in microseconds.
#define GNUNET_YES
Definition: gnunet_common.h:80
struct GNUNET_STATISTICS_Handle * stats
Optional statistics handle to report usage.
static void regex_next_edge(const struct RegexBlock *block, size_t size, struct RegexSearchContext *ctx)
Jump to the next edge, with the longest matching token.
#define LOG(kind,...)
struct GNUNET_DHT_Handle * dht
DHT handle to use, must be initialized externally.
void REGEX_INTERNAL_iterate_reachable_edges(struct REGEX_INTERNAL_Automaton *a, REGEX_INTERNAL_KeyIterator iterator, void *iterator_cls)
Iterate over all edges of automaton &#39;a&#39; that are reachable from a state with a proof of at least GNUN...
const struct GNUNET_CRYPTO_EddsaPrivateKey * priv
Our private key.
Block to store a cadet regex state.
uint32_t data
The data value.
struct GNUNET_CONTAINER_MultiHashMap * dht_get_handles
Running DHT GETs.
struct GNUNET_TIME_AbsoluteNBO GNUNET_TIME_absolute_hton(struct GNUNET_TIME_Absolute a)
Convert absolute time to network byte order.
Definition: time.c:654
struct REGEX_INTERNAL_Automaton * dfa
Automaton representation of the regex (expensive to build).
#define GNUNET_malloc(size)
Wrapper around malloc.
unsigned int longest_match
We just want to look for one edge, the longer the better.
struct RegexSearchContext ** contexts
Contexts, for each running DHT GET.
#define GNUNET_free(ptr)
Wrapper around free.
static int regex_result_iterator(void *cls, const struct GNUNET_HashCode *key, void *value)
Iterator over found existing cadet regex blocks that match an ongoing search.
struct GNUNET_CRYPTO_EddsaPublicKey public_key
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
size_t size
Number of bytes in data.
struct GNUNET_TIME_AbsoluteNBO expiration_time
When does the signature expire?
Definition: block_regex.h:61
static void regex_find_path(const struct GNUNET_HashCode *key, struct RegexSearchContext *ctx)
Find a path to a peer that offers a regex service compatible with a given string. ...