aboutsummaryrefslogtreecommitdiff
path: root/src/ats/plugin_ats2_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ats/plugin_ats2_common.c')
-rw-r--r--src/ats/plugin_ats2_common.c99
1 files changed, 0 insertions, 99 deletions
diff --git a/src/ats/plugin_ats2_common.c b/src/ats/plugin_ats2_common.c
deleted file mode 100644
index da20a342c..000000000
--- a/src/ats/plugin_ats2_common.c
+++ /dev/null
@@ -1,99 +0,0 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2011-2015, 2018 GNUnet e.V.
4
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 SPDX-License-Identifier: AGPL3.0-or-later
19 */
20/**
21 * @file ats/plugin_ats2_common.c
22 * @brief ATS solver helper functions to be inlined
23 * @author Matthias Wachs
24 * @author Christian Grothoff
25 */
26
27/**
28 * Default bandwidth assigned to a network: 64 KB/s
29 */
30#define DEFAULT_BANDWIDTH 65536
31
32
33/**
34 * Parse @a cfg for @a quota as specified for @a direction of
35 * network type @a nts.
36 *
37 * @param cfg configuration to parse
38 * @param nts network type string to get quota for
39 * @param direction direction to get quota for ("IN" or "OUT")
40 * @param quota[out] set to quota, #DEFAULT_BANDWIDTH if @a cfg does not say anything useful
41 */
42static void
43get_quota (const struct GNUNET_CONFIGURATION_Handle *cfg,
44 const char *nts,
45 const char *direction,
46 unsigned long long *quota)
47{
48 char *quota_str;
49 char *quota_s;
50 int res;
51
52 GNUNET_asprintf (&quota_s,
53 "%s_QUOTA_%s",
54 nts,
55 direction);
56 if (GNUNET_OK !=
57 GNUNET_CONFIGURATION_get_value_string (cfg,
58 "ATS",
59 quota_s,
60 &quota_str))
61 {
62 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
63 "ATS",
64 quota_s);
65 GNUNET_free (quota_s);
66 return;
67 }
68 GNUNET_free (quota_s);
69 res = GNUNET_NO;
70 if (0 == strcmp (quota_str,
71 "unlimited"))
72 {
73 *quota = ULONG_MAX;
74 res = GNUNET_YES;
75 }
76 if ((GNUNET_NO == res) &&
77 (GNUNET_OK ==
78 GNUNET_STRINGS_fancy_size_to_bytes (quota_str,
79 quota)))
80 res = GNUNET_YES;
81 if ((GNUNET_NO == res) &&
82 (1 ==
83 sscanf (quota_str,
84 "%llu",
85 quota)))
86 res = GNUNET_YES;
87 if (GNUNET_NO == res)
88 {
89 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
90 _ (
91 "Could not load %s quota for network `%s': `%s', assigning default bandwidth %llu\n"),
92 direction,
93 nts,
94 quota_str,
95 (unsigned long long) DEFAULT_BANDWIDTH);
96 *quota = DEFAULT_BANDWIDTH;
97 }
98 GNUNET_free (quota_str);
99}