![]() |
GNUnet
0.11.x
|
service to advertise capabilities described as regex and to lookup capabilities by regex More...
#include "platform.h"
#include "gnunet_util_lib.h"
#include "regex_internal_lib.h"
#include "regex_ipc.h"
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_PeerIdentity *get_path, unsigned int get_path_length, const struct GNUNET_PeerIdentity *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 ("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 GNUNET_DHT_disconnect(), GNUNET_free, GNUNET_NO, and GNUNET_STATISTICS_destroy().
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(), ClientEntry::refresh_task, and REGEX_INTERNAL_reannounce().
Referenced by handle_announce().
|
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, 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(), reannounce(), AnnounceMessage::refresh_delay, ClientEntry::refresh_task, and REGEX_INTERNAL_announce().
|
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 | Lenght 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, ResultMessage::get_path_length, GNUNET_break, GNUNET_MAX_MESSAGE_SIZE, GNUNET_memcpy, GNUNET_MESSAGE_TYPE_REGEX_RESULT, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), ResultMessage::id, id, ClientEntry::mq, ResultMessage::put_path_length, result, and size.
Referenced by handle_search().
|
static |
Check SEARCH message.
cls | identification of the client |
message | the actual message |
Definition at line 246 of file gnunet-service-regex.c.
References GNUNET_break, GNUNET_OK, GNUNET_SYSERR, RegexSearchMessage::header, ClientEntry::sh, size, and GNUNET_MessageHeader::size.
|
static |
Handle SEARCH message.
cls | identification of the client |
message | the actual message |
Definition at line 277 of file gnunet-service-regex.c.
References ClientEntry::client, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), handle_search_result(), REGEX_INTERNAL_search(), and ClientEntry::sh.
|
static |
Process regex requests.
cls | closure |
cfg | configuration to use |
service | the initialized service |
Definition at line 310 of file gnunet-service-regex.c.
References cleanup_task(), GNUNET_CRYPTO_eddsa_key_create_from_configuration(), GNUNET_DHT_connect(), GNUNET_free, GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), and GNUNET_STATISTICS_create().
Referenced by client_disconnect_cb().
|
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 343 of file gnunet-service-regex.c.
References ClientEntry::client, GNUNET_new, and ClientEntry::mq.
Referenced by client_disconnect_cb().
|
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 364 of file gnunet-service-regex.c.
References ClientEntry::ah, client_connect_cb(), GNUNET_free, GNUNET_MESSAGE_TYPE_REGEX_ANNOUNCE, GNUNET_MESSAGE_TYPE_REGEX_SEARCH, GNUNET_MQ_handler_end, GNUNET_MQ_hd_var_size, GNUNET_SCHEDULER_cancel(), GNUNET_SERVICE_MAIN(), GNUNET_SERVICE_OPTION_NONE, ClientEntry::refresh_task, REGEX_INTERNAL_announce_cancel(), REGEX_INTERNAL_search_cancel(), run(), and ClientEntry::sh.
GNUNET_SERVICE_MAIN | ( | "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.
Referenced by client_disconnect_cb().
|
static |
Connection to the DHT.
Definition at line 73 of file gnunet-service-regex.c.
|
static |
Handle for doing statistics.
Definition at line 78 of file gnunet-service-regex.c.
|
static |
Private key for this peer.
Definition at line 83 of file gnunet-service-regex.c.