GNUnet  0.11.x
Functions
gnunet-service-ats_plugins.h File Reference

ats service plugin management More...

#include "gnunet-service-ats_addresses.h"
Include dependency graph for gnunet-service-ats_plugins.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int GAS_plugin_init (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Initialize address subsystem. More...
 
void GAS_plugin_done (void)
 Shutdown address subsystem. More...
 
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...
 
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 (void)
 Stop instant solving, there are many state updates happening in bulk right now. More...
 
void GAS_plugin_solver_unlock (void)
 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...
 

Detailed Description

ats service plugin management

Author
Matthias Wachs
Christian Grothoff

Definition in file gnunet-service-ats_plugins.h.

Function Documentation

◆ GAS_plugin_init()

int GAS_plugin_init ( const struct GNUNET_CONFIGURATION_Handle cfg)

Initialize address subsystem.

The addresses subsystem manages the addresses known and current performance information. It has a solver component responsible for the resource allocation. It tells the solver about changes and receives updates when the solver changes the ressource allocation.

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

Initialize address subsystem.

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

Definition at line 436 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().

437 {
438  char *mode_str;
439 
440  /* Figure out configured solution method */
441  if (GNUNET_SYSERR ==
443  "ats",
444  "MODE",
445  &mode_str))
446  {
448  "No resource assignment method configured, using proportional approach\n");
449  mode_str = GNUNET_strdup ("proportional");
450  }
451  env.cls = NULL;
456  env.cfg = cfg;
457  env.stats = GSA_stats;
460  load_quotas (cfg,
461  env.out_quota,
462  env.in_quota,
465  "libgnunet_plugin_ats_%s",
466  mode_str);
468  "Initializing solver `%s'\n",
469  mode_str);
470  GNUNET_free (mode_str);
471  if (NULL == (sf = GNUNET_PLUGIN_load (plugin, &env)))
472  {
474  _ ("Failed to initialize solver `%s'!\n"),
475  plugin);
476  return GNUNET_SYSERR;
477  }
478  return GNUNET_OK;
479 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
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.
struct GNUNET_STATISTICS_Handle * stats
Statistics handle to be used by the solver.
#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.
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
struct GNUNET_CONTAINER_MultiPeerMap * GSA_addresses
A multihashmap to store all addresses.
void * cls
Closure to pass to all callbacks in this struct.
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 * GNUNET_PLUGIN_load(const char *library_name, void *arg)
Setup plugin (runs the "init" callback and returns whatever "init" returned).
Definition: plugin.c:207
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 486 of file gnunet-service-ats_plugins.c.

References GNUNET_free, GNUNET_PLUGIN_unload(), and plugin.

Referenced by cleanup_task().

487 {
489  sf);
490  sf = NULL;
492  plugin = NULL;
493 }
void * GNUNET_PLUGIN_unload(const char *library_name, void *arg)
Unload plugin (runs the "done" callback and returns whatever "done" returned).
Definition: plugin.c:256
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_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 }
void * cls
Closure to pass to all solver functions in this struct.
GAS_solver_address_change_preference s_pref
Change relative preference for quality in solver.
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
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:

◆ 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
addr_netnetwork scope the address is in
new_addressthe new address

Definition at line 503 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().

504 {
505  sf->s_add (sf->cls,
506  new_address,
507  new_address->properties.scope); /* FIXME: remove 3rd arg here! */
508 }
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 518 of file gnunet-service-ats_plugins.c.

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

Referenced by free_address().

519 {
520  sf->s_del (sf->cls,
521  address);
522 }
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 536 of file gnunet-service-ats_plugins.c.

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

Referenced by handle_feedback().

541 {
542  sf->s_feedback (sf->cls,
543  application,
544  peer,
545  scope,
546  kind,
547  score_abs);
548 }
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 556 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().

557 {
558  sf->s_bulk_start (sf->cls);
559 }
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 566 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().

567 {
568  sf->s_bulk_stop (sf->cls);
569 }
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 579 of file gnunet-service-ats_plugins.c.

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

Referenced by GAS_handle_request_address().

580 {
581  sf->s_get (sf->cls,
582  pid);
583 }
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 593 of file gnunet-service-ats_plugins.c.

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

Referenced by free_matching_requests().

594 {
595  sf->s_get_stop (sf->cls,
596  pid);
597 }
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: