GNUnet  0.10.x
Functions | Variables
gnunet-service-ats_plugins.c File Reference

ats service plugin management More...

#include "platform.h"
#include "gnunet_ats_plugin.h"
#include "gnunet-service-ats_connectivity.h"
#include "gnunet-service-ats_performance.h"
#include "gnunet-service-ats_preferences.h"
#include "gnunet-service-ats_plugins.h"
#include "gnunet-service-ats_reservations.h"
#include "gnunet-service-ats_scheduling.h"
#include "gnunet-service-ats_normalization.h"
Include dependency graph for gnunet-service-ats_plugins.c:

Go to the source code of this file.

Functions

void GAS_plugin_notify_preference_changed (const struct GNUNET_PeerIdentity *peer, enum GNUNET_ATS_PreferenceKind kind, double pref_rel)
 The preference changed for a peer, update solver. More...
 
void GAS_plugin_notify_property_changed (struct ATS_Address *address)
 The relative value for a property changed. More...
 
static void solver_info_cb (void *cls, enum GAS_Solver_Operation op, enum GAS_Solver_Status status, enum GAS_Solver_Additional_Information add)
 Solver information callback. More...
 
static void bandwidth_changed_cb (void *cls, struct ATS_Address *address)
 Callback for solver to notify about assignment changes. More...
 
static unsigned long long parse_quota (const char *quota_str, const char *direction, enum GNUNET_NetworkType network)
 Convert quota from text to numeric value. More...
 
static unsigned long long load_quota (const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_NetworkType type, const char *direction)
 Load quota value from the configuration cfg for the given network type and direction. More...
 
static unsigned int load_quotas (const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned long long *out_dest, unsigned long long *in_dest, int dest_length)
 Load quotas for networks from configuration. More...
 
int GAS_plugin_init (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Initialize plugins subsystem. More...
 
void GAS_plugin_done ()
 Shutdown address subsystem. More...
 
void GAS_plugin_new_address (struct ATS_Address *new_address)
 Tell the solver that the given address can now be used for talking to the respective peer. More...
 
void GAS_plugin_delete_address (struct ATS_Address *address)
 Tell the solver that the given address is no longer valid can cannot be used any longer. More...
 
void GAS_plugin_notify_feedback (struct GNUNET_SERVICE_Client *application, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TIME_Relative scope, enum GNUNET_ATS_PreferenceKind kind, float score_abs)
 Tell the solver that the given client has expressed its appreciation for the past performance of a given connection. More...
 
void GAS_plugin_solver_lock ()
 Stop instant solving, there are many state updates happening in bulk right now. More...
 
void GAS_plugin_solver_unlock ()
 Resume instant solving, we are done with the bulk state updates. More...
 
void GAS_plugin_request_connect_start (const struct GNUNET_PeerIdentity *pid)
 Notify the plugin that a request to connect to a particular peer was given to us. More...
 
void GAS_plugin_request_connect_stop (const struct GNUNET_PeerIdentity *pid)
 Notify the plugin that a request to connect to a particular peer was dropped. More...
 

Variables

static struct GNUNET_ATS_SolverFunctionssf
 Solver handle. More...
 
static struct GNUNET_ATS_PluginEnvironment env
 Solver environment. More...
 
static char * plugin
 Solver plugin name as string. More...
 

Detailed Description

ats service plugin management

Author
Matthias Wachs
Christian Grothoff

Definition in file gnunet-service-ats_plugins.c.

Function Documentation

◆ GAS_plugin_notify_preference_changed()

void GAS_plugin_notify_preference_changed ( const struct GNUNET_PeerIdentity peer,
enum GNUNET_ATS_PreferenceKind  kind,
double  pref_rel 
)

The preference changed for a peer, update solver.

Parameters
peerthe peer
kindthe ATS kind
pref_relthe new relative preference value

Definition at line 62 of file gnunet-service-ats_plugins.c.

References GNUNET_ATS_SolverFunctions::cls, and GNUNET_ATS_SolverFunctions::s_pref.

Referenced by update_relative_values_for_peer().

65 {
66  sf->s_pref(sf->cls,
67  peer,
68  kind,
69  pref_rel);
70 }
GAS_solver_address_change_preference s_pref
Change relative preference for quality in solver.
void * cls
Closure to pass to all solver functions in this struct.
static struct GNUNET_ATS_SolverFunctions * sf
Solver handle.
Here is the caller graph for this function:

◆ GAS_plugin_notify_property_changed()

void GAS_plugin_notify_property_changed ( struct ATS_Address address)

The relative value for a property changed.

Parameters
addressthe peer for which a property changed

Definition at line 79 of file gnunet-service-ats_plugins.c.

References GNUNET_ATS_SolverFunctions::cls, and GNUNET_ATS_SolverFunctions::s_address_update_property.

Referenced by notify_change().

80 {
82  address);
83 }
GAS_solver_address_property_changed s_address_update_property
Update the properties of an address in the solver.
void * cls
Closure to pass to all solver functions in this struct.
static struct GNUNET_ATS_SolverFunctions * sf
Solver handle.
Here is the caller graph for this function:

◆ solver_info_cb()

static void solver_info_cb ( void *  cls,
enum GAS_Solver_Operation  op,
enum GAS_Solver_Status  status,
enum GAS_Solver_Additional_Information  add 
)
static

Solver information callback.

Parameters
clsthe closure
opthe operation
statusoperation status
addadditional information

Definition at line 95 of file gnunet-service-ats_plugins.c.

References GAS_INFO_FULL, GAS_INFO_NONE, GAS_INFO_PROP_ALL, GAS_INFO_PROP_SINGLE, GAS_INFO_UPDATED, GAS_OP_SOLVE_MLP_LP_START, GAS_OP_SOLVE_MLP_LP_STOP, GAS_OP_SOLVE_MLP_MLP_START, GAS_OP_SOLVE_MLP_MLP_STOP, GAS_OP_SOLVE_SETUP_START, GAS_OP_SOLVE_SETUP_STOP, GAS_OP_SOLVE_START, GAS_OP_SOLVE_STOP, GAS_OP_SOLVE_UPDATE_NOTIFICATION_START, GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP, GAS_STAT_SUCCESS, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, and GNUNET_log.

Referenced by GAS_plugin_init().

99 {
100  const char *add_info;
101 
102  switch (add)
103  {
104  case GAS_INFO_NONE:
105  add_info = "GAS_INFO_NONE";
106  break;
107 
108  case GAS_INFO_FULL:
109  add_info = "GAS_INFO_MLP_FULL";
110  break;
111 
112  case GAS_INFO_UPDATED:
113  add_info = "GAS_INFO_MLP_UPDATED";
114  break;
115 
116  case GAS_INFO_PROP_ALL:
117  add_info = "GAS_INFO_PROP_ALL";
118  break;
119 
121  add_info = "GAS_INFO_PROP_SINGLE";
122  break;
123 
124  default:
125  add_info = "INVALID";
126  break;
127  }
128  switch (op)
129  {
130  case GAS_OP_SOLVE_START:
132  "Solver notifies `%s' with result `%s' `%s'\n",
133  "GAS_OP_SOLVE_START",
134  (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL",
135  add_info);
136  return;
137 
138  case GAS_OP_SOLVE_STOP:
140  "Solver notifies `%s' with result `%s'\n",
141  "GAS_OP_SOLVE_STOP",
142  (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL");
143  return;
144 
147  "Solver notifies `%s' with result `%s'\n",
148  "GAS_OP_SOLVE_SETUP_START",
149  (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL");
150  return;
151 
154  "Solver notifies `%s' with result `%s'\n",
155  "GAS_OP_SOLVE_SETUP_STOP",
156  (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL");
157  return;
158 
161  "Solver notifies `%s' with result `%s'\n",
162  "GAS_OP_SOLVE_LP_START",
163  (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL");
164  return;
165 
168  "Solver notifies `%s' with result `%s'\n",
169  "GAS_OP_SOLVE_LP_STOP",
170  (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL");
171  return;
172 
175  "Solver notifies `%s' with result `%s'\n",
176  "GAS_OP_SOLVE_MLP_START",
177  (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL");
178  return;
179 
182  "Solver notifies `%s' with result `%s'\n",
183  "GAS_OP_SOLVE_MLP_STOP",
184  (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL");
185  return;
186 
189  "Solver notifies `%s' with result `%s'\n",
190  "GAS_OP_SOLVE_UPDATE_NOTIFICATION_START",
191  (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL");
192  return;
193 
196  "Solver notifies `%s' with result `%s'\n",
197  "GAS_OP_SOLVE_UPDATE_NOTIFICATION_STOP",
198  (GAS_STAT_SUCCESS == status) ? "SUCCESS" : "FAIL");
199  return;
200 
201  default:
202  GNUNET_break(0);
203  break;
204  }
205 }
Solving of the LP problem was started MLP solver only.
After the problem was finished, start notifications about changes to addresses.
The proportional solver had to recalculate for a single network.
The setup of the problem as a preparation to solve it was started.
The proportional solver had to recalculate for all networks.
No more specific information.
A full solution process is performed Quite specific to the MLP solver.
Solving of the LP problem is done MLP solver only.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Solving of the MLP problem is done MLP solver only.
A solution iteration has been started.
Solving of the MLP problem was started MLP solver only.
uint16_t status
See PRISM_STATUS_*-constants.
static int add
Desired action is to add a record.
A solution iteration has been finished.
#define GNUNET_log(kind,...)
The setup of the problem as a preparation to solve is finished.
An existing solution was reused Quite specific to the MLP solver.
static struct GNUNET_ARM_Operation * op
Current operation.
Definition: gnunet-arm.c:139
After the problem was finished, notifications about changes to addresses are done.
Here is the caller graph for this function:

◆ bandwidth_changed_cb()

static void bandwidth_changed_cb ( void *  cls,
struct ATS_Address address 
)
static

Callback for solver to notify about assignment changes.

Parameters
clsNULL
addressthe address with changes

Definition at line 215 of file gnunet-service-ats_plugins.c.

References ATS_Address::active, ATS_Address::addr, ATS_Address::addr_len, ATS_Address::assigned_bw_in, ATS_Address::assigned_bw_out, GAS_performance_notify_all_clients(), GAS_reservations_set_bandwidth(), GAS_scheduling_transmit_address_suggestion(), GNUNET_BANDWIDTH_value_init(), GNUNET_BANDWIDTH_ZERO, GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, ATS_Address::last_notified_bw_in, ATS_Address::last_notified_bw_out, ATS_Address::local_address_info, ATS_Address::peer, ATS_Address::plugin, ATS_Address::properties, and ATS_Address::session_id.

Referenced by GAS_plugin_init().

217 {
218  long long diff_out;
219  long long diff_in;
220 
222  "Bandwidth assignment changed for peer %s to %u/%u\n",
223  GNUNET_i2s(&address->peer),
224  (unsigned int)address->assigned_bw_in,
225  (unsigned int)address->assigned_bw_out);
228  /* Notify performance clients about changes to address */
230  address->plugin,
231  address->addr,
232  address->addr_len,
233  address->active,
234  &address->properties,
235  address->local_address_info,
238 
239  if ((0 == address->assigned_bw_in) &&
240  (0 == address->assigned_bw_out))
241  {
243  "Telling transport to disconnect peer `%s'\n",
244  GNUNET_i2s(&address->peer));
245 
246  /* Notify scheduling clients about suggestion */
248  address->session_id,
251  return;
252  }
253 
254  /* Do bandwidth stability check */
255  diff_out = llabs((long long)address->assigned_bw_out -
256  (long long)address->last_notified_bw_out);
257  diff_in = llabs((long long)address->assigned_bw_in -
258  (long long)address->last_notified_bw_in);
259  if ((diff_out < htonl(GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__)) &&
260  (diff_in < htonl(GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__)))
261  {
263  "Bandwidth change too small, not notifying client\n");
264  return;
265  }
266 
268  "Sending bandwidth update for peer `%s': %u/%u\n",
269  GNUNET_i2s(&address->peer),
270  address->assigned_bw_out,
271  address->assigned_bw_out);
272 
273  /* *Notify scheduling clients about suggestion */
275  address->session_id,
278 
279  address->last_notified_bw_out = address->assigned_bw_out;
280  address->last_notified_bw_in = address->assigned_bw_in;
281 }
uint32_t session_id
Session ID, can never be 0.
struct GNUNET_ATS_Properties properties
ATS performance information for this address.
int active
Is this the active address for this peer?
struct GNUNET_PeerIdentity peer
Peer ID this address is for.
const void * addr
Address (in plugin-specific binary format).
uint32_t last_notified_bw_out
Outbound bandwidth assigned by solver in NBO.
#define GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT
Bandwidth (in/out) to assume initially (before either peer has communicated any particular preference...
size_t addr_len
Address length, number of bytes in addr.
char * plugin
Plugin name.
void GAS_reservations_set_bandwidth(const struct GNUNET_PeerIdentity *peer, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
Set the amount of bandwidth the other peer could currently transmit to us (as far as we know) to the ...
void GAS_performance_notify_all_clients(const struct GNUNET_PeerIdentity *peer, const char *plugin_name, const void *plugin_addr, size_t plugin_addr_len, int active, const struct GNUNET_ATS_Properties *prop, enum GNUNET_HELLO_AddressInfo local_address_info, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
Transmit the given performance information to all performance clients.
uint32_t assigned_bw_in
Inbound bandwidth assigned by solver.
void GAS_scheduling_transmit_address_suggestion(const struct GNUNET_PeerIdentity *peer, uint32_t session_id, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
Transmit the given address suggestion and bandwidth update to all scheduling clients.
struct GNUNET_BANDWIDTH_Value32NBO GNUNET_BANDWIDTH_value_init(uint32_t bytes_per_second)
Create a new bandwidth value.
Definition: bandwidth.c:39
#define GNUNET_BANDWIDTH_ZERO
Convenience definition to use for 0-bandwidth.
uint32_t assigned_bw_out
Outbound bandwidth assigned by solver.
#define GNUNET_log(kind,...)
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
enum GNUNET_HELLO_AddressInfo local_address_info
Field to store local flags.
uint32_t last_notified_bw_in
Inbound bandwidth assigned by solver in NBO.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_quota()

static unsigned long long parse_quota ( const char *  quota_str,
const char *  direction,
enum GNUNET_NetworkType  network 
)
static

Convert quota from text to numeric value.

Parameters
quota_strthe value found in the configuration
directiondirection of the quota
networknetwork the quota applies to
Returns
numeric quota value to use

Definition at line 293 of file gnunet-service-ats_plugins.c.

References _, GNUNET_ATS_DefaultBandwidth, GNUNET_ATS_MaxBandwidth, GNUNET_ATS_MaxBandwidthString, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_log, GNUNET_NO, GNUNET_NT_to_string(), GNUNET_OK, GNUNET_STRINGS_fancy_size_to_bytes(), GNUNET_YES, res, and ret.

Referenced by load_quota().

296 {
297  int res;
298  unsigned long long ret;
299 
300  res = GNUNET_NO;
301  if (0 == strcmp(quota_str, GNUNET_ATS_MaxBandwidthString))
302  {
304  res = GNUNET_YES;
305  }
306  if ((GNUNET_NO == res) &&
307  (GNUNET_OK ==
309  &ret)))
310  res = GNUNET_YES;
311  if ((GNUNET_NO == res) &&
312  (1 ==
313  sscanf(quota_str,
314  "%llu",
315  &ret)))
316  res = GNUNET_YES;
317  if (GNUNET_NO == res)
318  {
320  _("Could not load %s quota for network `%s': `%s', assigning default bandwidth %llu\n"),
321  direction,
322  GNUNET_NT_to_string(network),
323  quota_str,
324  (unsigned long long)GNUNET_ATS_DefaultBandwidth);
326  }
327  else
328  {
330  _("%s quota configured for network `%s' is %llu\n"),
331  direction,
332  GNUNET_NT_to_string(network),
333  ret);
334  }
335  return ret;
336 }
#define GNUNET_ATS_MaxBandwidthString
Textual equivalent for GNUNET_ATS_MaxBandwidth.
const char * GNUNET_NT_to_string(enum GNUNET_NetworkType net)
Convert a enum GNUNET_NetworkType to a string.
Definition: nt.c:43
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
static int ret
Final status code.
Definition: gnunet-arm.c:89
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
#define GNUNET_ATS_DefaultBandwidth
Default bandwidth assigned to a network : 64 KB/s.
static int res
#define GNUNET_ATS_MaxBandwidth
Maximum bandwidth assigned to a network : 4095 MB/s.
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_quota()

static unsigned long long load_quota ( const struct GNUNET_CONFIGURATION_Handle cfg,
enum GNUNET_NetworkType  type,
const char *  direction 
)
static

Load quota value from the configuration cfg for the given network type and direction.

Parameters
cfgconfiguration to parse
typenetwork type to parse for
directiontraffic direction to parse for
Returns
quota to apply

Definition at line 349 of file gnunet-service-ats_plugins.c.

References _, GNUNET_asprintf(), GNUNET_ATS_DefaultBandwidth, GNUNET_CONFIGURATION_get_value_string(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_NT_to_string(), GNUNET_OK, parse_quota(), and ret.

Referenced by load_quotas().

352 {
353  char *entry;
354  char *quota_str;
355  unsigned long long ret;
356 
357  GNUNET_asprintf(&entry,
358  "%s_QUOTA_%s",
360  direction);
361  if (GNUNET_OK ==
363  "ats",
364  entry,
365  &quota_str))
366  {
367  ret = parse_quota(quota_str,
368  direction,
369  type);
370  GNUNET_free(quota_str);
371  }
372  else
373  {
375  _("No %s-quota configured for network `%s', assigning default bandwidth %llu\n"),
376  direction,
378  (unsigned long long)GNUNET_ATS_DefaultBandwidth);
380  }
381  GNUNET_free(entry);
382  return ret;
383 }
const char * GNUNET_NT_to_string(enum GNUNET_NetworkType net)
Convert a enum GNUNET_NetworkType to a string.
Definition: nt.c:43
static unsigned long long parse_quota(const char *quota_str, const char *direction, enum GNUNET_NetworkType network)
Convert quota from text to numeric value.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
static int ret
Final status code.
Definition: gnunet-arm.c:89
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
#define GNUNET_ATS_DefaultBandwidth
Default bandwidth assigned to a network : 64 KB/s.
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.
#define GNUNET_log(kind,...)
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_quotas()

static unsigned int load_quotas ( const struct GNUNET_CONFIGURATION_Handle cfg,
unsigned long long *  out_dest,
unsigned long long *  in_dest,
int  dest_length 
)
static

Load quotas for networks from configuration.

Parameters
cfgconfiguration handle
out_destwhere to write outbound quotas
in_destwhere to write inbound quotas
dest_lengthlength of inbound and outbound arrays
Returns
number of networks loaded

Definition at line 396 of file gnunet-service-ats_plugins.c.

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NT_COUNT, GNUNET_NT_to_string(), and load_quota().

Referenced by GAS_plugin_init().

400 {
401  unsigned int c;
402 
403  for (c = 0; (c < GNUNET_NT_COUNT) && (c < dest_length); c++)
404  {
405  in_dest[c] = load_quota(cfg,
406  c,
407  "out");
408  out_dest[c] = load_quota(cfg,
409  c,
410  "in");
412  "Loaded quota for network `%s' (in/out): %llu %llu\n",
414  in_dest[c],
415  out_dest[c]);
416  }
417  return c;
418 }
const char * GNUNET_NT_to_string(enum GNUNET_NetworkType net)
Convert a enum GNUNET_NetworkType to a string.
Definition: nt.c:43
static unsigned long long load_quota(const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_NetworkType type, const char *direction)
Load quota value from the configuration cfg for the given network type and direction.
#define GNUNET_log(kind,...)
#define GNUNET_NT_COUNT
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GAS_plugin_init()

int GAS_plugin_init ( const struct GNUNET_CONFIGURATION_Handle cfg)

Initialize plugins subsystem.

Initialize address subsystem.

Parameters
cfgconfiguration to use
Returns
GNUNET_OK on success, GNUNET_SYSERR on error (failed to load solver plugin)

Definition at line 429 of file gnunet-service-ats_plugins.c.

References _, GNUNET_ATS_PluginEnvironment::addresses, bandwidth_changed_cb(), GNUNET_ATS_PluginEnvironment::bandwidth_changed_cb, cfg, GNUNET_ATS_PluginEnvironment::cfg, GNUNET_ATS_PluginEnvironment::cls, env, GAS_connectivity_has_peer(), GAS_preference_get_by_peer(), GNUNET_ATS_PluginEnvironment::get_connectivity, GNUNET_ATS_PluginEnvironment::get_preferences, GNUNET_asprintf(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_NT_COUNT, GNUNET_OK, GNUNET_PLUGIN_load(), GNUNET_strdup, GNUNET_SYSERR, GSA_addresses, GSA_stats, GNUNET_ATS_PluginEnvironment::in_quota, GNUNET_ATS_PluginEnvironment::info_cb, load_quotas(), GNUNET_ATS_PluginEnvironment::network_count, GNUNET_ATS_PluginEnvironment::out_quota, plugin, solver_info_cb(), and GNUNET_ATS_PluginEnvironment::stats.

Referenced by run().

430 {
431  char *mode_str;
432 
433  /* Figure out configured solution method */
434  if (GNUNET_SYSERR ==
436  "ats",
437  "MODE",
438  &mode_str))
439  {
441  "No resource assignment method configured, using proportional approach\n");
442  mode_str = GNUNET_strdup("proportional");
443  }
444  env.cls = NULL;
449  env.cfg = cfg;
450  env.stats = GSA_stats;
453  load_quotas(cfg,
454  env.out_quota,
455  env.in_quota,
458  "libgnunet_plugin_ats_%s",
459  mode_str);
461  "Initializing solver `%s'\n",
462  mode_str);
463  GNUNET_free(mode_str);
464  if (NULL == (sf = GNUNET_PLUGIN_load(plugin, &env)))
465  {
467  _("Failed to initialize solver `%s'!\n"),
468  plugin);
469  return GNUNET_SYSERR;
470  }
471  return GNUNET_OK;
472 }
struct GNUNET_STATISTICS_Handle * stats
Statistics handle to be used by the solver.
GAS_get_preferences get_preferences
ATS addresses function to obtain preference values.
static unsigned int load_quotas(const struct GNUNET_CONFIGURATION_Handle *cfg, unsigned long long *out_dest, unsigned long long *in_dest, int dest_length)
Load quotas for networks from configuration.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
struct GNUNET_STATISTICS_Handle * GSA_stats
Handle for statistics.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
static void bandwidth_changed_cb(void *cls, struct ATS_Address *address)
Callback for solver to notify about assignment changes.
static void solver_info_cb(void *cls, enum GAS_Solver_Operation op, enum GAS_Solver_Status status, enum GAS_Solver_Additional_Information add)
Solver information callback.
unsigned int GAS_connectivity_has_peer(void *cls, const struct GNUNET_PeerIdentity *peer)
Is the given peer in the list of peers for which we have an address request?
static char * plugin
Solver plugin name as string.
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 struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
struct GNUNET_CONTAINER_MultiPeerMap * GSA_addresses
A multihashmap to store all addresses.
unsigned long long in_quota[6]
Array of configured inbound quotas Order according to networks in network array.
static struct GNUNET_ATS_PluginEnvironment env
Solver environment.
const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration handle to be used by the solver.
#define GNUNET_log(kind,...)
GAS_solver_information_callback info_cb
Callback for solver to call with status information, can be NULL.
unsigned long long out_quota[6]
Array of configured outbound quotas Order according to networks in network array. ...
void * cls
Closure to pass to all callbacks in this struct.
void * GNUNET_PLUGIN_load(const char *library_name, void *arg)
Setup plugin (runs the "init" callback and returns whatever "init" returned).
Definition: plugin.c:206
static struct GNUNET_ATS_SolverFunctions * sf
Solver handle.
struct GNUNET_CONTAINER_MultiPeerMap * addresses
Hashmap containing all addresses available.
GAS_bandwidth_changed_cb bandwidth_changed_cb
ATS addresses callback to be notified about bandwidth assignment changes.
const double * GAS_preference_get_by_peer(void *cls, const struct GNUNET_PeerIdentity *id)
Get the normalized preference values for a specific peer or the default values if.
#define GNUNET_NT_COUNT
unsigned int network_count
Number of networks available, size of the out_quota and in_quota arrays.
#define GNUNET_free(ptr)
Wrapper around free.
GAS_get_connectivity get_connectivity
ATS addresses function to obtain preference values.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GAS_plugin_done()

void GAS_plugin_done ( void  )

Shutdown address subsystem.

Definition at line 479 of file gnunet-service-ats_plugins.c.

References GNUNET_free, GNUNET_PLUGIN_unload(), and plugin.

Referenced by cleanup_task().

480 {
482  sf);
483  sf = NULL;
485  plugin = NULL;
486 }
void * GNUNET_PLUGIN_unload(const char *library_name, void *arg)
Unload plugin (runs the "done" callback and returns whatever "done" returned).
Definition: plugin.c:255
static char * plugin
Solver plugin name as string.
static struct GNUNET_ATS_SolverFunctions * sf
Solver handle.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GAS_plugin_new_address()

void GAS_plugin_new_address ( struct ATS_Address new_address)

Tell the solver that the given address can now be used for talking to the respective peer.

Parameters
new_addressthe new address

Definition at line 496 of file gnunet-service-ats_plugins.c.

References GNUNET_ATS_SolverFunctions::cls, ATS_Address::properties, GNUNET_ATS_SolverFunctions::s_add, and GNUNET_ATS_Properties::scope.

Referenced by GAS_addresses_add().

497 {
498  sf->s_add(sf->cls,
499  new_address,
500  new_address->properties.scope); /* FIXME: remove 3rd arg here! */
501 }
GAS_solver_address_add s_add
Add a new address for a peer to the solver.
struct GNUNET_ATS_Properties properties
ATS performance information for this address.
void * cls
Closure to pass to all solver functions in this struct.
enum GNUNET_NetworkType scope
Which network scope does the respective address belong to? This property does not change...
static struct GNUNET_ATS_SolverFunctions * sf
Solver handle.
Here is the caller graph for this function:

◆ GAS_plugin_delete_address()

void GAS_plugin_delete_address ( struct ATS_Address address)

Tell the solver that the given address is no longer valid can cannot be used any longer.

Parameters
addressaddress that was deleted

Definition at line 511 of file gnunet-service-ats_plugins.c.

References GNUNET_ATS_SolverFunctions::cls, and GNUNET_ATS_SolverFunctions::s_del.

Referenced by free_address().

512 {
513  sf->s_del(sf->cls,
514  address);
515 }
GAS_solver_address_delete s_del
Delete an address in the solver.
void * cls
Closure to pass to all solver functions in this struct.
static struct GNUNET_ATS_SolverFunctions * sf
Solver handle.
Here is the caller graph for this function:

◆ GAS_plugin_notify_feedback()

void GAS_plugin_notify_feedback ( struct GNUNET_SERVICE_Client application,
const struct GNUNET_PeerIdentity peer,
const struct GNUNET_TIME_Relative  scope,
enum GNUNET_ATS_PreferenceKind  kind,
float  score_abs 
)

Tell the solver that the given client has expressed its appreciation for the past performance of a given connection.

Parameters
applicationclient providing the feedback
peerpeer the feedback is about
scopetimeframe the feedback applies to
kindperformance property the feedback relates to
score_absdegree of the appreciation

Definition at line 529 of file gnunet-service-ats_plugins.c.

References GNUNET_ATS_SolverFunctions::cls, and GNUNET_ATS_SolverFunctions::s_feedback.

Referenced by handle_feedback().

534 {
535  sf->s_feedback(sf->cls,
536  application,
537  peer,
538  scope,
539  kind,
540  score_abs);
541 }
GAS_solver_address_feedback_preference s_feedback
Give feedback about the current assignment.
void * cls
Closure to pass to all solver functions in this struct.
static struct GNUNET_ATS_SolverFunctions * sf
Solver handle.
Here is the caller graph for this function:

◆ GAS_plugin_solver_lock()

void GAS_plugin_solver_lock ( void  )

Stop instant solving, there are many state updates happening in bulk right now.

Definition at line 549 of file gnunet-service-ats_plugins.c.

References GNUNET_ATS_SolverFunctions::cls, and GNUNET_ATS_SolverFunctions::s_bulk_start.

Referenced by GAS_addresses_add(), GAS_addresses_destroy_all(), GAS_addresses_done(), GAS_connectivity_done(), GAS_handle_preference_change(), GAS_normalization_update_property(), and preference_aging().

550 {
551  sf->s_bulk_start(sf->cls);
552 }
void * cls
Closure to pass to all solver functions in this struct.
GAS_solver_bulk_start s_bulk_start
Start a bulk operation.
static struct GNUNET_ATS_SolverFunctions * sf
Solver handle.
Here is the caller graph for this function:

◆ GAS_plugin_solver_unlock()

void GAS_plugin_solver_unlock ( void  )

Resume instant solving, we are done with the bulk state updates.

Definition at line 559 of file gnunet-service-ats_plugins.c.

References GNUNET_ATS_SolverFunctions::cls, and GNUNET_ATS_SolverFunctions::s_bulk_stop.

Referenced by GAS_addresses_add(), GAS_addresses_destroy_all(), GAS_addresses_done(), GAS_connectivity_done(), GAS_handle_preference_change(), GAS_normalization_update_property(), and preference_aging().

560 {
561  sf->s_bulk_stop(sf->cls);
562 }
void * cls
Closure to pass to all solver functions in this struct.
static struct GNUNET_ATS_SolverFunctions * sf
Solver handle.
GAS_solver_bulk_stop s_bulk_stop
Bulk operation done.
Here is the caller graph for this function:

◆ GAS_plugin_request_connect_start()

void GAS_plugin_request_connect_start ( const struct GNUNET_PeerIdentity pid)

Notify the plugin that a request to connect to a particular peer was given to us.

Parameters
pididentity of peer we now care about

Definition at line 572 of file gnunet-service-ats_plugins.c.

References GNUNET_ATS_SolverFunctions::cls, and GNUNET_ATS_SolverFunctions::s_get.

Referenced by GAS_handle_request_address().

573 {
574  sf->s_get(sf->cls,
575  pid);
576 }
void * cls
Closure to pass to all solver functions in this struct.
GAS_solver_get_preferred_address s_get
Tell solver to notify ATS if the address to use changes for a specific peer using the bandwidth chang...
static struct GNUNET_ATS_SolverFunctions * sf
Solver handle.
Here is the caller graph for this function:

◆ GAS_plugin_request_connect_stop()

void GAS_plugin_request_connect_stop ( const struct GNUNET_PeerIdentity pid)

Notify the plugin that a request to connect to a particular peer was dropped.

Parameters
pididentity of peer we care now less about

Definition at line 586 of file gnunet-service-ats_plugins.c.

References GNUNET_ATS_SolverFunctions::cls, and GNUNET_ATS_SolverFunctions::s_get_stop.

Referenced by free_matching_requests().

587 {
588  sf->s_get_stop(sf->cls,
589  pid);
590 }
GAS_solver_stop_get_preferred_address s_get_stop
Tell solver stop notifying ATS about changes for this peers.
void * cls
Closure to pass to all solver functions in this struct.
static struct GNUNET_ATS_SolverFunctions * sf
Solver handle.
Here is the caller graph for this function:

Variable Documentation

◆ sf

struct GNUNET_ATS_SolverFunctions* sf
static

◆ env

struct GNUNET_ATS_PluginEnvironment env
static

Solver environment.

Definition at line 46 of file gnunet-service-ats_plugins.c.

Referenced by GAS_plugin_init().

◆ plugin

char* plugin
static

Solver plugin name as string.

Definition at line 51 of file gnunet-service-ats_plugins.c.

Referenced by GAS_plugin_done(), and GAS_plugin_init().