2 This file is part of GNUnet.
3 Copyright (C) 2011-2015, 2018 GNUnet e.V.
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.
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.
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/>.
18 SPDX-License-Identifier: AGPL3.0-or-later
21 * @file ats/plugin_ats2_common.c
22 * @brief ATS solver helper functions to be inlined
23 * @author Matthias Wachs
24 * @author Christian Grothoff
28 * Default bandwidth assigned to a network: 64 KB/s
30 #define DEFAULT_BANDWIDTH 65536
34 * Parse @a cfg for @a quota as specified for @a direction of
35 * network type @a nts.
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
43 get_quota (const struct GNUNET_CONFIGURATION_Handle *cfg,
45 const char *direction,
46 unsigned long long *quota)
52 GNUNET_asprintf ("a_s,
57 GNUNET_CONFIGURATION_get_value_string (cfg,
62 GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
65 GNUNET_free (quota_s);
68 GNUNET_free (quota_s);
70 if (0 == strcmp (quota_str,
76 if ( (GNUNET_NO == res) &&
78 GNUNET_STRINGS_fancy_size_to_bytes (quota_str,
81 if ( (GNUNET_NO == res) &&
89 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
90 _("Could not load %s quota for network `%s': `%s', assigning default bandwidth %llu\n"),
94 (unsigned long long) DEFAULT_BANDWIDTH);
95 *quota = DEFAULT_BANDWIDTH;
97 GNUNET_free (quota_str);