[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r25473 - gnunet/src/ats-tool
From: |
gnunet |
Subject: |
[GNUnet-SVN] r25473 - gnunet/src/ats-tool |
Date: |
Fri, 14 Dec 2012 10:28:38 +0100 |
Author: wachs
Date: 2012-12-14 10:28:38 +0100 (Fri, 14 Dec 2012)
New Revision: 25473
Modified:
gnunet/src/ats-tool/gnunet-ats.c
Log:
new switch -q to print configured quotas
Modified: gnunet/src/ats-tool/gnunet-ats.c
===================================================================
--- gnunet/src/ats-tool/gnunet-ats.c 2012-12-13 20:21:45 UTC (rev 25472)
+++ gnunet/src/ats-tool/gnunet-ats.c 2012-12-14 09:28:38 UTC (rev 25473)
@@ -30,6 +30,8 @@
#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 5)
+#define BIG_M_STRING "unlimited"
+
/**
* Final status code.
*/
@@ -68,6 +70,11 @@
static int op_set_pref;
/**
+ * Print quotas configured
+ */
+static int op_print_quotas;
+
+/**
* Monitor addresses used
*/
static int op_monitor;
@@ -261,7 +268,68 @@
}
}
+static unsigned int
+print_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg)
+{
+ char *network_str[GNUNET_ATS_NetworkTypeCount] =
GNUNET_ATS_NetworkTypeString;
+ char * entry_in = NULL;
+ char * entry_out = NULL;
+ char * quota_out_str;
+ char * quota_in_str;
+ unsigned long long int quota_out;
+ unsigned long long int quota_in;
+ int c;
+ for (c = 0; (c < GNUNET_ATS_NetworkTypeCount); c++)
+ {
+
+ GNUNET_asprintf (&entry_out, "%s_QUOTA_OUT", network_str[c]);
+ GNUNET_asprintf (&entry_in, "%s_QUOTA_IN", network_str[c]);
+
+ /* quota out */
+ if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats",
entry_out, "a_out_str))
+ {
+ if (0 == strcmp(quota_out_str, BIG_M_STRING) ||
+ (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_out_str,
"a_out)))
+ quota_out = UINT32_MAX;
+
+ GNUNET_free (quota_out_str);
+ GNUNET_asprintf ("a_out_str, "%llu", quota_out);
+ }
+ else
+ {
+ fprintf (stderr, "Outbound quota for network `%11s' not configured!\n",
+ network_str[c]);
+ GNUNET_asprintf ("a_out_str, "-");
+ }
+ GNUNET_free (entry_out);
+
+ /* quota in */
+ if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string(cfg, "ats",
entry_in, "a_in_str))
+ {
+ if (0 == strcmp(quota_in_str, BIG_M_STRING) ||
+ (GNUNET_SYSERR == GNUNET_STRINGS_fancy_size_to_bytes (quota_in_str,
"a_in)))
+ quota_in = UINT32_MAX;
+ GNUNET_free (quota_in_str);
+ GNUNET_asprintf ("a_in_str, "%llu", quota_in);
+ }
+ else
+ {
+ fprintf (stderr, "Inbound quota for network `%11s' not configured!\n",
+ network_str[c]);
+ GNUNET_asprintf ("a_in_str, "-");
+ }
+ GNUNET_free (entry_in);
+
+ fprintf (stderr, _("Quota for network `%11s' (in/out): %10s / %10s\n"),
network_str[c], quota_in_str, quota_out_str );
+ GNUNET_free (quota_out_str);
+ GNUNET_free (quota_in_str);
+ }
+ return GNUNET_ATS_NetworkTypeCount;
+}
+
+
+
void testservice_ats (void *cls,
const struct GNUNET_SCHEDULER_TaskContext *tc)
{
@@ -290,14 +358,17 @@
c = op_list_all + op_list_used + op_monitor + op_set_pref;
if ((1 < c))
{
- FPRINTF (stderr, _("Please select one operation : %s or %s or %s or
%s\n"),
- "--used", "--all", "--monitor", "--preference");
+ FPRINTF (stderr, _("Please select one operation : %s or %s or %s or %s
or %s\n"),
+ "--used", "--all", "--monitor", "--preference", "--quotas");
return;
}
if ((0 == c))
op_list_used = GNUNET_YES; /* set default */
-
-
+ if (op_print_quotas)
+ {
+ ret = print_quotas (cfg);
+ return;
+ }
if (op_list_all)
{
ph = GNUNET_ATS_performance_init (cfg, NULL, NULL);
@@ -428,6 +499,9 @@
{'p', "preference", NULL,
gettext_noop ("set preference for the given peer"),
0, &GNUNET_GETOPT_set_one, &op_set_pref},
+ {'q', "quotas", NULL,
+ gettext_noop ("print all configured quotas"),
+ 0, &GNUNET_GETOPT_set_one, &op_print_quotas},
{'i', "id", "TYPE",
gettext_noop ("peer id"),
1, &GNUNET_GETOPT_set_string, &pid_str},
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r25473 - gnunet/src/ats-tool,
gnunet <=