133 "Daemon for %s shutting down\n",
162 "First time, creating regex: %s\n",
198 if ((NULL == regex) || (0 == strlen (regex)))
205 "Daemon for %s starting\n",
254 long long unsigned int peer_id;
262 "MAX_PATH_COMPRESSION",
268 "%s service is lacking key configuration settings (%s). Exiting.\n"),
269 "regexprofiler",
"max_path_compression");
309 "REANNOUNCE_PERIOD_MAX",
313 "reannounce_period_max not given. Using 10 minutes.\n");
325 "Could not acquire dht handle. Exiting.\n");
338 "Policy file %s contains no policies. Exiting.\n",
351 "%s(%s)(0|1|2|3|4|5|6|7|8|9|a|b|c|d|e|f)*",
372main (
int argc,
char *
const *argv)
380 argc, argv,
"regexprofiler",
383 "Daemon to announce regular expressions for the peer using cadet."),
388#if defined(__linux__) && defined(__GLIBC__)
392GNUNET_REGEX_memory_init (
void);
398GNUNET_REGEX_memory_init (
void)
400 mallopt (M_TRIM_THRESHOLD, 4 * 1024);
401 mallopt (M_TOP_PAD, 1 * 1024);
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
struct GNUNET_GETOPT_CommandLineOption options[]
#define gettext_noop(String)
static char * peer_id
Option –peer.
static char * rx_with_pfx
Regex with prefix.
static void reannounce_regex(void *cls)
Announce a previously announced regex re-using cached data.
static int global_ret
Return value from 'main'.
static struct GNUNET_TIME_Relative reannounce_period_max
What's the maximum reannounce period.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg_)
Main function that will be run by the scheduler.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we use.
static struct REGEX_INTERNAL_Announcement * announce_handle
Peer's regex announce handle.
static void shutdown_task(void *cls)
Task run during shutdown.
static void announce_regex(const char *regex)
Announce the given regular expression using regex and the path compression length read from config.
static struct GNUNET_DHT_Handle * dht_handle
Peer's dht handle.
static struct GNUNET_STATISTICS_Handle * stats_handle
Handle to the statistics service.
static char * policy_filename
Name of the file containing policies that this peer should announce.
static unsigned int rounds
How many put rounds should we do.
static int scan(void *cls, const char *filename)
Scan through the policy_dir looking for the n-th filename.
int main(int argc, char *const *argv)
The main function of the regexprofiler service.
static struct GNUNET_CRYPTO_EddsaPrivateKey * my_private_key
Private key for this peer.
static struct GNUNET_SCHEDULER_Task * reannounce_task
Periodically reannounce regex.
static char * regex_prefix
Prefix to add before every regex we're announcing.
static unsigned long long max_path_compression
Maximal path compression length for regex announcing.
static char * policy_dir
Folder where policy files are stored.
struct GNUNET_PQ_ResultSpec __attribute__
API to create, modify and access statistics.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_number(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, unsigned long long *number)
Get a configuration value that should be a number.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
struct GNUNET_CRYPTO_EddsaPrivateKey * GNUNET_CRYPTO_eddsa_key_create_from_configuration(const struct GNUNET_CONFIGURATION_Handle *cfg)
Create a new private key by reading our peer's key from the file specified in the configuration.
@ GNUNET_CRYPTO_QUALITY_WEAK
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
struct GNUNET_DHT_Handle * GNUNET_DHT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int ht_len)
Initialize the connection with the DHT service.
void GNUNET_DHT_disconnect(struct GNUNET_DHT_Handle *handle)
Shutdown connection with the DHT service.
int GNUNET_DISK_directory_scan(const char *dir_name, GNUNET_FileNameCallback callback, void *callback_cls)
Scan a directory for files.
#define GNUNET_log(kind,...)
#define GNUNET_UNUSED
gcc-ism to document unused arguments
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_DEBUG
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_free(ptr)
Wrapper around free.
#define GNUNET_free_nz(ptr)
Wrapper around free.
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(const struct GNUNET_OS_ProjectData *pd, int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
#define GNUNET_TIME_UNIT_MINUTES
One minute.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_multiply(struct GNUNET_TIME_Relative rel, unsigned long long factor)
Multiply relative time by a given factor.
#define GNUNET_TIME_UNIT_MICROSECONDS
One microsecond, our basic time unit.
void REGEX_INTERNAL_announce_cancel(struct REGEX_INTERNAL_Announcement *h)
Clear all cached data used by a regex announce.
void REGEX_INTERNAL_reannounce(struct REGEX_INTERNAL_Announcement *h)
Announce again a regular expression previously announced.
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.
library to parse regular expressions into dfa
void REGEX_TEST_free_from_file(char **regexes)
Free all memory reserved for a set of regexes created by read_from_file.
char * REGEX_TEST_combine(char *const regexes[], unsigned int alphabet_size)
Combine an array of regexes into a single prefix-shared regex.
char ** REGEX_TEST_read_from_file(const char *filename)
Read a set of regexes from a file, one per line and return them in an array suitable for REGEX_TEST_c...
Private ECC key encoded for transmission.
Connection to the DHT service.
Definition of a command line option.
Entry in list of pending tasks.
Time for relative time used by GNUnet, in microseconds.
uint64_t rel_value_us
The actual value.
Handle to store cached data about a regex announce.