service to advertise capabilities described as regex and to lookup capabilities by regex More...
Go to the source code of this file.
Data Structures | |
struct | ClientEntry |
Information about one of our clients. More... | |
Functions | |
static void | cleanup_task (void *cls) |
Task run during shutdown. More... | |
static void | reannounce (void *cls) |
Periodic task to refresh our announcement of the regex. More... | |
static int | check_announce (void *cls, const struct AnnounceMessage *am) |
Check ANNOUNCE message. More... | |
static void | handle_announce (void *cls, const struct AnnounceMessage *am) |
Handle ANNOUNCE message. More... | |
static void | handle_search_result (void *cls, const struct GNUNET_PeerIdentity *id, const struct GNUNET_DHT_PathElement *get_path, unsigned int get_path_length, const struct GNUNET_DHT_PathElement *put_path, unsigned int put_path_length) |
Handle result, pass it back to the client. More... | |
static int | check_search (void *cls, const struct RegexSearchMessage *sm) |
Check SEARCH message. More... | |
static void | handle_search (void *cls, const struct RegexSearchMessage *sm) |
Handle SEARCH message. More... | |
static void | run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SERVICE_Handle *service) |
Process regex requests. More... | |
static void * | client_connect_cb (void *cls, struct GNUNET_SERVICE_Client *c, struct GNUNET_MQ_Handle *mq) |
Callback called when a client connects to the service. More... | |
static void | client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *c, void *internal_cls) |
Callback called when a client disconnected from the service. More... | |
GNUNET_SERVICE_MAIN (GNUNET_OS_project_data_gnunet(), "regex", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_var_size(announce, GNUNET_MESSAGE_TYPE_REGEX_ANNOUNCE, struct AnnounceMessage, NULL), GNUNET_MQ_hd_var_size(search, GNUNET_MESSAGE_TYPE_REGEX_SEARCH, struct RegexSearchMessage, NULL), GNUNET_MQ_handler_end()) | |
Define "main" method using service macro. More... | |
Variables | |
static struct GNUNET_DHT_Handle * | dht |
Connection to the DHT. More... | |
static struct GNUNET_STATISTICS_Handle * | stats |
Handle for doing statistics. More... | |
static struct GNUNET_CRYPTO_EddsaPrivateKey * | my_private_key |
Private key for this peer. More... | |
service to advertise capabilities described as regex and to lookup capabilities by regex
Definition in file gnunet-service-regex.c.
|
static |
Task run during shutdown.
cls | unused |
Definition at line 92 of file gnunet-service-regex.c.
References dht, GNUNET_DHT_disconnect(), GNUNET_free, GNUNET_NO, GNUNET_STATISTICS_destroy(), my_private_key, and stats.
Referenced by run().
|
static |
Periodic task to refresh our announcement of the regex.
cls | the struct ClientEntry * of the client that triggered the announcement |
Definition at line 111 of file gnunet-service-regex.c.
References ClientEntry::ah, ClientEntry::frequency, GNUNET_SCHEDULER_add_delayed(), reannounce(), ClientEntry::refresh_task, and REGEX_INTERNAL_reannounce().
Referenced by handle_announce(), and reannounce().
|
static |
Check ANNOUNCE message.
cls | identification of the client |
am | the actual message |
Definition at line 130 of file gnunet-service-regex.c.
References ClientEntry::ah, GNUNET_break, GNUNET_MQ_check_zero_termination, GNUNET_OK, and GNUNET_SYSERR.
|
static |
Handle ANNOUNCE message.
cls | identification of the client |
am | the actual message |
Definition at line 153 of file gnunet-service-regex.c.
References ClientEntry::ah, ClientEntry::client, AnnounceMessage::compression, dht, ClientEntry::frequency, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_cancel(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_relative_ntoh(), my_private_key, reannounce(), AnnounceMessage::refresh_delay, ClientEntry::refresh_task, REGEX_INTERNAL_announce(), and stats.
|
static |
Handle result, pass it back to the client.
cls | the struct ClientEntry of the client searching |
id | Peer providing a regex that matches the string. |
get_path | Path of the get request. |
get_path_length | Length of get_path. |
put_path | Path of the put request. |
put_path_length | Length of the put_path. |
Definition at line 197 of file gnunet-service-regex.c.
References env, GNUNET_break, GNUNET_MAX_MESSAGE_SIZE, GNUNET_MESSAGE_TYPE_REGEX_RESULT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), id, ClientEntry::mq, result, and size.
Referenced by handle_search().
|
static |
Check SEARCH message.
cls | identification of the client |
sm | the actual message |
Definition at line 244 of file gnunet-service-regex.c.
References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, RegexSearchMessage::header, ClientEntry::sh, GNUNET_MessageHeader::size, and size.
|
static |
Handle SEARCH message.
cls | identification of the client |
sm | the actual message |
Definition at line 275 of file gnunet-service-regex.c.
References ClientEntry::client, dht, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), handle_search_result(), REGEX_INTERNAL_search(), ClientEntry::sh, and stats.
|
static |
Process regex requests.
cls | closure |
cfg | configuration to use |
service | the initialized service |
Definition at line 308 of file gnunet-service-regex.c.
References cfg, cleanup_task(), dht, GNUNET_CRYPTO_eddsa_key_create_from_configuration(), GNUNET_DHT_connect(), GNUNET_free, GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_STATISTICS_create(), my_private_key, and stats.
|
static |
Callback called when a client connects to the service.
cls | closure for the service |
c | the new client that connected to the service |
mq | the message queue used to send messages to the client |
Definition at line 341 of file gnunet-service-regex.c.
References ClientEntry::client, GNUNET_new, mq, and ClientEntry::mq.
|
static |
Callback called when a client disconnected from the service.
cls | closure for the service |
c | the client that disconnected |
internal_cls | should be equal to c |
Definition at line 362 of file gnunet-service-regex.c.
References ClientEntry::ah, GNUNET_free, GNUNET_SCHEDULER_cancel(), ClientEntry::refresh_task, REGEX_INTERNAL_announce_cancel(), REGEX_INTERNAL_search_cancel(), and ClientEntry::sh.
GNUNET_SERVICE_MAIN | ( | GNUNET_OS_project_data_gnunet() | , |
"regex" | , | ||
GNUNET_SERVICE_OPTION_NONE | , | ||
& | run, | ||
& | client_connect_cb, | ||
& | client_disconnect_cb, | ||
NULL | , | ||
GNUNET_MQ_hd_var_size(announce, GNUNET_MESSAGE_TYPE_REGEX_ANNOUNCE, struct AnnounceMessage, NULL) | , | ||
GNUNET_MQ_hd_var_size(search, GNUNET_MESSAGE_TYPE_REGEX_SEARCH, struct RegexSearchMessage, NULL) | , | ||
GNUNET_MQ_handler_end() | |||
) |
Define "main" method using service macro.
|
static |
Connection to the DHT.
Definition at line 73 of file gnunet-service-regex.c.
Referenced by cleanup_task(), handle_announce(), handle_search(), and run().
|
static |
Handle for doing statistics.
Definition at line 78 of file gnunet-service-regex.c.
Referenced by cleanup_task(), handle_announce(), handle_search(), and run().
|
static |
Private key for this peer.
Definition at line 83 of file gnunet-service-regex.c.
Referenced by cleanup_task(), handle_announce(), and run().