GNUnet  0.10.x
Macros | Typedefs | Functions
RegEx service

Advertise capabilities via RegEx and discover respective peers using matching strings. More...

Macros

#define GNUNET_REGEX_INITIAL_BYTES   24
 Constant for how many bytes the initial string regex should have. More...
 

Typedefs

typedef void(* GNUNET_REGEX_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, invoked for every result that was found. More...
 

Functions

struct GNUNET_REGEX_AnnouncementGNUNET_REGEX_announce (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *regex, struct GNUNET_TIME_Relative refresh_delay, uint16_t compression)
 Announce this peer under the given regular expression. More...
 
void GNUNET_REGEX_announce_cancel (struct GNUNET_REGEX_Announcement *a)
 Stop announcing the regex specified by the given handle. More...
 
struct GNUNET_REGEX_SearchGNUNET_REGEX_search (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *string, GNUNET_REGEX_Found callback, void *callback_cls)
 Search for a peer offering a regex matching certain string in the DHT. More...
 
void GNUNET_REGEX_search_cancel (struct GNUNET_REGEX_Search *s)
 Stop search and free all data used by a GNUNET_REGEX_search call. More...
 

Detailed Description

Advertise capabilities via RegEx and discover respective peers using matching strings.

See also
Documentation

Macro Definition Documentation

◆ GNUNET_REGEX_INITIAL_BYTES

#define GNUNET_REGEX_INITIAL_BYTES   24

Constant for how many bytes the initial string regex should have.

Definition at line 53 of file gnunet_regex_service.h.

Referenced by dfa_compress_paths_helper(), reachability_iterator(), REGEX_INTERNAL_get_first_key(), and REGEX_INTERNAL_iterate_all_edges().

Typedef Documentation

◆ GNUNET_REGEX_Found

typedef void(* GNUNET_REGEX_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, invoked for every result that was found.

Parameters
clsClosure provided in GNUNET_REGEX_search.
idPeer providing a regex that matches the string.
get_pathPath of the get request.
get_path_lengthLenght of get_path.
put_pathPath of the put request.
put_path_lengthLength of the put_path.

Definition at line 106 of file gnunet_regex_service.h.

Function Documentation

◆ GNUNET_REGEX_announce()

struct GNUNET_REGEX_Announcement* GNUNET_REGEX_announce ( const struct GNUNET_CONFIGURATION_Handle cfg,
const char *  regex,
struct GNUNET_TIME_Relative  refresh_delay,
uint16_t  compression 
)

Announce this peer under the given regular expression.

Does not free resources, must call GNUNET_REGEX_announce_cancel for that.

Parameters
cfgconfiguration to use
regexRegular expression to announce.
refresh_delayafter what delay should the announcement be repeated?
compressionHow many characters per edge can we squeeze?
Returns
Handle to reuse o free cached resources. Must be freed by calling GNUNET_REGEX_announce_cancel.

Announce this peer under the given regular expression.

Parameters
cfgconfiguration to use
regexRegular expression to announce.
refresh_delayafter what delay should the announcement be repeated?
compressionHow many characters per edge can we squeeze?
Returns
Handle to reuse o free cached resources. Must be freed by calling GNUNET_REGEX_announce_cancel().

Definition at line 140 of file regex_api_announce.c.

References _, announce_reconnect(), GNUNET_REGEX_Announcement::cfg, GNUNET_REGEX_Announcement::compression, GNUNET_break, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_MAX_MESSAGE_SIZE, GNUNET_new, GNUNET_strdup, GNUNET_REGEX_Announcement::mq, GNUNET_REGEX_Announcement::refresh_delay, and GNUNET_REGEX_Announcement::regex.

Referenced by run().

144 {
145  struct GNUNET_REGEX_Announcement *a;
146  size_t slen;
147 
148  slen = strlen (regex) + 1;
149  if (slen + sizeof (struct AnnounceMessage) >= GNUNET_MAX_MESSAGE_SIZE)
150  {
152  _("Regex `%s' is too long!\n"),
153  regex);
154  GNUNET_break (0);
155  return NULL;
156  }
158  a->cfg = cfg;
161  a->regex = GNUNET_strdup (regex);
162  announce_reconnect (a);
163  if (NULL == a->mq)
164  {
165  GNUNET_free (a->regex);
166  GNUNET_free (a);
167  return NULL;
168  }
169  return a;
170 }
static void announce_reconnect(struct GNUNET_REGEX_Announcement *a)
(Re)connect to the REGEX service with the given announcement a.
Handle to store cached data about a regex announce.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint16_t compression
Number of characters per edge.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
Request for regex service to announce capability.
Definition: regex_ipc.h:34
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
char * regex
Message we're sending to the service.
#define GNUNET_log(kind,...)
struct GNUNET_MQ_Handle * mq
Connection to the regex service.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_TIME_Relative refresh_delay
Frequency of announcements.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_REGEX_announce_cancel()

void GNUNET_REGEX_announce_cancel ( struct GNUNET_REGEX_Announcement a)

Stop announcing the regex specified by the given handle.

Parameters
ahandle returned by a previous GNUNET_REGEX_announce call.
ahandle returned by a previous GNUNET_REGEX_announce() call.

Definition at line 179 of file regex_api_announce.c.

References GNUNET_free, GNUNET_MQ_destroy(), GNUNET_REGEX_Announcement::mq, and GNUNET_REGEX_Announcement::regex.

Referenced by cleanup().

180 {
181  GNUNET_MQ_destroy (a->mq);
182  GNUNET_free (a->regex);
183  GNUNET_free (a);
184 }
char * regex
Message we're sending to the service.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
struct GNUNET_MQ_Handle * mq
Connection to the regex service.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_REGEX_search()

struct GNUNET_REGEX_Search* GNUNET_REGEX_search ( const struct GNUNET_CONFIGURATION_Handle cfg,
const char *  string,
GNUNET_REGEX_Found  callback,
void *  callback_cls 
)

Search for a peer offering a regex matching certain string in the DHT.

The search runs until GNUNET_REGEX_search_cancel is called, even if results are returned.

Parameters
cfgconfiguration to use
stringString to match against the regexes in the DHT.
callbackCallback for found peers.
callback_clsClosure for callback.
Returns
Handle to stop search and free resources. Must be freed by calling GNUNET_REGEX_search_cancel.

The search runs until GNUNET_REGEX_search_cancel() is called, even if results are returned.

Parameters
cfgconfiguration to use
stringString to match against the regexes in the DHT.
callbackCallback for found peers.
callback_clsClosure for callback.
Returns
Handle to stop search and free resources. Must be freed by calling GNUNET_REGEX_search_cancel().

Definition at line 201 of file regex_api_search.c.

References _, GNUNET_REGEX_Search::callback, GNUNET_REGEX_Search::callback_cls, GNUNET_REGEX_Search::cfg, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_MAX_MESSAGE_SIZE, GNUNET_new, GNUNET_strdup, LOG, GNUNET_REGEX_Search::mq, search_reconnect(), and GNUNET_REGEX_Search::string.

Referenced by create_channel_to_destination().

205 {
206  struct GNUNET_REGEX_Search *s;
207  size_t slen = strlen (string) + 1;
208 
209  if (slen + sizeof (struct RegexSearchMessage) >= GNUNET_MAX_MESSAGE_SIZE)
210  {
212  _("Search string `%s' is too long!\n"),
213  string);
214  GNUNET_break (0);
215  return NULL;
216  }
218  "Starting regex search for %s\n",
219  string);
220  s = GNUNET_new (struct GNUNET_REGEX_Search);
221  s->cfg = cfg;
222  s->string = GNUNET_strdup (string);
223  s->callback = callback;
225  search_reconnect (s);
226  if (NULL == s->mq)
227  {
228  GNUNET_free (s->string);
229  GNUNET_free (s);
230  return NULL;
231  }
232  return s;
233 }
char * string
Search string to transmit to the service.
static void search_reconnect(struct GNUNET_REGEX_Search *s)
(Re)connect to the REGEX service for the given search s.
Message to initiate regex search.
Definition: regex_ipc.h:64
#define LOG(kind,...)
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
struct GNUNET_MQ_Handle * mq
Connection to the regex service.
GNUNET_REGEX_Found callback
Function to call with results.
void * callback_cls
Closure for callback.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
#define GNUNET_log(kind,...)
Handle to store data about a regex search.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_REGEX_search_cancel()

void GNUNET_REGEX_search_cancel ( struct GNUNET_REGEX_Search s)

Stop search and free all data used by a GNUNET_REGEX_search call.

Parameters
sHandle returned by a previous GNUNET_REGEX_search call.

Stop search and free all data used by a GNUNET_REGEX_search call.

Parameters
sHandle returned by a previous GNUNET_REGEX_search() call.

Definition at line 242 of file regex_api_search.c.

References GNUNET_free, GNUNET_MQ_destroy(), GNUNET_REGEX_Search::mq, and GNUNET_REGEX_Search::string.

Referenced by free_channel_state(), and handle_regex_result().

243 {
244  GNUNET_MQ_destroy (s->mq);
245  GNUNET_free (s->string);
246  GNUNET_free (s);
247 }
char * string
Search string to transmit to the service.
struct GNUNET_MQ_Handle * mq
Connection to the regex service.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function: