GNUnet  0.10.x
Macros | Functions
plugin_ats2_common.c File Reference

ATS solver helper functions to be inlined. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define DEFAULT_BANDWIDTH   65536
 Default bandwidth assigned to a network: 64 KB/s. More...
 

Functions

static void get_quota (const struct GNUNET_CONFIGURATION_Handle *cfg, const char *nts, const char *direction, unsigned long long *quota)
 Parse cfg for quota as specified for direction of network type nts. More...
 

Detailed Description

ATS solver helper functions to be inlined.

Author
Matthias Wachs
Christian Grothoff

Definition in file plugin_ats2_common.c.

Macro Definition Documentation

◆ DEFAULT_BANDWIDTH

#define DEFAULT_BANDWIDTH   65536

Default bandwidth assigned to a network: 64 KB/s.

Definition at line 30 of file plugin_ats2_common.c.

Referenced by get_quota().

Function Documentation

◆ get_quota()

static void get_quota ( const struct GNUNET_CONFIGURATION_Handle cfg,
const char *  nts,
const char *  direction,
unsigned long long *  quota 
)
static

Parse cfg for quota as specified for direction of network type nts.

Parameters
cfgconfiguration to parse
ntsnetwork type string to get quota for
directiondirection to get quota for ("IN" or "OUT")
quota[out]set to quota, DEFAULT_BANDWIDTH if cfg does not say anything useful

Definition at line 43 of file plugin_ats2_common.c.

References _, DEFAULT_BANDWIDTH, GNUNET_asprintf(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_log_config_missing(), GNUNET_NO, GNUNET_OK, GNUNET_STRINGS_fancy_size_to_bytes(), GNUNET_YES, and res.

Referenced by libgnunet_plugin_ats2_simple_init().

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 !=
58  "ATS",
59  quota_s,
60  &quota_str))
61  {
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 ==
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  {
90  _("Could not load %s quota for network `%s': `%s', assigning default bandwidth %llu\n"),
91  direction,
92  nts,
93  quota_str,
94  (unsigned long long)DEFAULT_BANDWIDTH);
96  }
97  GNUNET_free(quota_str);
98 }
int GNUNET_STRINGS_fancy_size_to_bytes(const char *fancy_size, unsigned long long *size)
Convert a given fancy human-readable size to bytes.
Definition: strings.c:318
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
void GNUNET_log_config_missing(enum GNUNET_ErrorType kind, const char *section, const char *option)
Log error message about missing configuration option.
static int res
int GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
static unsigned long long quota
How much space are we allowed to use?
#define DEFAULT_BANDWIDTH
Default bandwidth assigned to a network: 64 KB/s.
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function: