GNUnet 0.21.1
RegEx service

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

Collaboration diagram for RegEx service:

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 57 of file gnunet_regex_service.h.

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_lengthLength of get_path.
put_pathPath of the put request.
put_path_lengthLength of the put_path.

Definition at line 109 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 139 of file regex_api_announce.c.

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

References _, announce_reconnect(), cfg, 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().

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.

Definition at line 173 of file regex_api_announce.c.

174{
176 GNUNET_free (a->regex);
177 GNUNET_free (a);
178}
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:683

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

Referenced by cleanup().

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.

Definition at line 189 of file regex_api_search.c.

193{
194 struct GNUNET_REGEX_Search *s;
195 size_t slen = strlen (string) + 1;
196
197 if (slen + sizeof(struct RegexSearchMessage) >= GNUNET_MAX_MESSAGE_SIZE)
198 {
200 _ ("Search string `%s' is too long!\n"),
201 string);
202 GNUNET_break (0);
203 return NULL;
204 }
206 "Starting regex search for %s\n",
207 string);
208 s = GNUNET_new (struct GNUNET_REGEX_Search);
209 s->cfg = cfg;
210 s->string = GNUNET_strdup (string);
211 s->callback = callback;
214 if (NULL == s->mq)
215 {
216 GNUNET_free (s->string);
217 GNUNET_free (s);
218 return NULL;
219 }
220 return s;
221}
@ GNUNET_ERROR_TYPE_DEBUG
static void search_reconnect(struct GNUNET_REGEX_Search *s)
(Re)connect to the REGEX service for the given search s.
#define LOG(kind,...)
Handle to store data about a regex search.
GNUNET_REGEX_Found callback
Function to call with results.
void * callback_cls
Closure for callback.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
char * string
Search string to transmit to the service.
struct GNUNET_MQ_Handle * mq
Connection to the regex service.
Message to initiate regex search.
Definition: regex_ipc.h:64

References _, GNUNET_REGEX_Search::callback, GNUNET_REGEX_Search::callback_cls, cfg, 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().

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.

Definition at line 225 of file regex_api_search.c.

226{
228 GNUNET_free (s->string);
229 GNUNET_free (s);
230}

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

Referenced by free_channel_state(), and handle_regex_result().

Here is the call graph for this function:
Here is the caller graph for this function: