From 1b130a115ce60a5d567f721e5e1b2d56f8336e29 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Tue, 6 Nov 2012 15:42:11 +0000 Subject: [PATCH] - change peer preferences via cmd line --- src/ats-tool/gnunet-ats.c | 78 +++++++++++++++++++++++++++++++++++---- 1 file changed, 71 insertions(+), 7 deletions(-) diff --git a/src/ats-tool/gnunet-ats.c b/src/ats-tool/gnunet-ats.c index fdb09df41..af6d8381e 100644 --- a/src/ats-tool/gnunet-ats.c +++ b/src/ats-tool/gnunet-ats.c @@ -38,6 +38,14 @@ static int results; static int resolve_addresses_numeric; static int monitor; +/** + * For which peer should we change preference values? + */ +static char *pid_str; + +static char *type_str; +static unsigned int value; + static struct GNUNET_ATS_PerformanceHandle *ph; static struct GNUNET_CONFIGURATION_Handle *cfg; @@ -135,7 +143,10 @@ void end (void *cls, void testservice_ats (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) { + struct GNUNET_PeerIdentity pid; struct GNUNET_CONFIGURATION_Handle *cfg = cls; + unsigned int c; + unsigned int type; if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) { @@ -144,14 +155,56 @@ void testservice_ats (void *cls, } results = 0; - ph = GNUNET_ATS_performance_init (cfg, ats_perf_cb, NULL); - if (NULL == ph) - fprintf (stderr, _("Cannot connect to ATS service, exiting...\n")); - - if (GNUNET_NO == monitor) - end_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end, NULL); + if (NULL != pid_str) + { + if (GNUNET_OK != GNUNET_CRYPTO_hash_from_string (pid_str, &pid.hashPubKey)) + { + FPRINTF (stderr, _("Failed to parse peer identity `%s'\n"), pid_str); + return; + } + if (NULL == type_str) + { + FPRINTF (stderr, _("Type required\n")); + return; + } + + for (c = 0; c