89 fprintf (stderr,
"%s",
"Cleaning up!\n");
90 if (NULL != monitor_handle)
93 monitor_handle = NULL;
95 if (NULL != dht_handle)
138 uint32_t desired_replication_level,
139 unsigned int path_length,
144 "GET #%u: type %d, key `%s'\n",
170 unsigned int get_path_length,
172 unsigned int put_path_length,
180 ?
"RESPONSE #%u (%s): type %d, key `%s', data `%.*s'\n" 181 :
"RESPONSE #%u (%s): type %d, key `%s'\n",
212 uint32_t desired_replication_level,
213 unsigned int path_length,
222 ?
"PUT %u (%s): type %d, key `%s', data `%.*s'\n" 223 :
"PUT %u (%s): type %d, key `%s'\n",
255 fprintf (stderr,
"%s",
_ (
"Failed to connect to DHT service!\n"));
273 "Monitoring for %s\n",
296 main (
int argc,
char *
const *argv)
315 gettext_noop (
"how long should the monitor command run"),
321 "be verbose (print progress information)"),
334 "gnunet-dht-monitor",
336 "Prints all packets that go through the DHT."),
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_relative_time(char shortName, const char *name, const char *argumentHelp, const char *description, struct GNUNET_TIME_Relative *val)
Allow user to specify a struct GNUNET_TIME_Relative (using human-readable "fancy" time)...
static int verbose
Be verbose.
int main(int argc, char *const *argv)
Entry point for gnunet-dht-monitor.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(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, parse options).
static const struct GNUNET_CONFIGURATION_Handle * cfg
Global handle of the configuration.
Any type of block, used as a wildcard when searching.
struct GNUNET_GETOPT_CommandLineOption options[]
GNUNET_BLOCK_Type
Blocks in the datastore and the datacache must have a unique type.
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, or when GNUNET_SCHEDULER_shutdown() is being invoked.
static void timeout_task(void *cls)
We hit a timeout.
int GNUNET_STRINGS_get_utf8_args(int argc, char *const *argv, int *u8argc, char *const **u8argv)
Returns utf-8 encoded arguments.
static struct GNUNET_SCHEDULER_Task * tt
Task scheduled to handle timeout.
void GNUNET_DHT_monitor_stop(struct GNUNET_DHT_MonitorHandle *mh)
Stop monitoring.
static struct GNUNET_DHT_Handle * dht_handle
Handle to the DHT.
static void put_callback(void *cls, enum GNUNET_DHT_RouteOption options, enum GNUNET_BLOCK_Type type, uint32_t hop_count, uint32_t desired_replication_level, unsigned int path_length, const struct GNUNET_PeerIdentity *path, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, const void *data, size_t size)
Callback called on each PUT request going through the DHT.
static struct GNUNET_TIME_Relative timeout_request
User supplied timeout value (in seconds)
Definition of a command line option.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Connection to the DHT service.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
static char * query_key
The key to be monitored.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
Main function that will be run by the scheduler.
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_DHT_MonitorHandle * GNUNET_DHT_monitor_start(struct GNUNET_DHT_Handle *handle, enum GNUNET_BLOCK_Type type, const struct GNUNET_HashCode *key, GNUNET_DHT_MonitorGetCB get_cb, GNUNET_DHT_MonitorGetRespCB get_resp_cb, GNUNET_DHT_MonitorPutCB put_cb, void *cb_cls)
Start monitoring the local DHT service.
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
static unsigned int result_count
Count of messages received.
GNUNET_DHT_RouteOption
Options for routing.
static void get_resp_callback(void *cls, enum GNUNET_BLOCK_Type type, const struct GNUNET_PeerIdentity *get_path, unsigned int get_path_length, const struct GNUNET_PeerIdentity *put_path, unsigned int put_path_length, struct GNUNET_TIME_Absolute exp, const struct GNUNET_HashCode *key, const void *data, size_t size)
Callback called on each GET reply going through the DHT.
struct GNUNET_HashCode key
The key used in the DHT.
static unsigned int size
Size of the "table".
struct GNUNET_DHT_Handle * GNUNET_DHT_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned int ht_len)
Initialize the connection with the DHT service.
const char * GNUNET_h2s_full(const struct GNUNET_HashCode *hc)
Convert a hash value to a string (for printing debug messages).
void GNUNET_DHT_disconnect(struct GNUNET_DHT_Handle *handle)
Shutdown connection with the DHT service.
static int ret
Global status value.
static struct GNUNET_DHT_MonitorHandle * monitor_handle
Handle for the get request.
The identity of the host (wraps the signing key of the peer).
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
Entry in list of pending tasks.
static void cleanup_task(void *cls)
Stop monitoring request and start shutdown.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
Time for absolute times used by GNUnet, in microseconds.
static unsigned int block_type
The type of the query.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_uint(char shortName, const char *name, const char *argumentHelp, const char *description, unsigned int *val)
Allow user to specify an unsigned int.
const char * GNUNET_STRINGS_absolute_time_to_string(struct GNUNET_TIME_Absolute t)
Like asctime, except for GNUnet time.
uint32_t data
The data value.
#define GNUNET_CRYPTO_hash_from_string(enc, result)
Convert ASCII encoding back to struct GNUNET_HashCode
Handle to a monitoring request.
Time for relative time used by GNUnet, in microseconds.
#define gettext_noop(String)
static void get_callback(void *cls, enum GNUNET_DHT_RouteOption options, enum GNUNET_BLOCK_Type type, uint32_t hop_count, uint32_t desired_replication_level, unsigned int path_length, const struct GNUNET_PeerIdentity *path, const struct GNUNET_HashCode *key)
Callback called on each GET request going through the DHT.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.