/*
This file is part of GNUnet.
- (C) 2011 Christian Grothoff (and other contributing authors)
+ Copyright (C) 2011-2014 GNUnet e.V.
GNUnet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
You should have received a copy of the GNU General Public License
along with GNUnet; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
*/
/**
#include "gnunet_util_lib.h"
#include "gnunet_ats_service.h"
#include "gnunet-service-ats.h"
-#include "gnunet_statistics_service.h"
#include "ats.h"
/**
* prevent the client from being thrashed. If the client requires immediately
* it can reset this block using GAS_addresses_handle_backoff_reset.
*
- * 1.7.7 Marking address in use
- *
- * The client can notify addresses that it successfully uses an address and
- * wants this address to be kept by calling GSA_address_in_use. Adresses will
- * mark the address as used an notify the solver about the use.
- *
- * 1.7.8 Address lifecycle
+ * 1.7.7 Address lifecycle
*
* * (add address)
- * * (updated address) || (address in use)
+ * * (updated address)
* * (delete address)
*
* 1.8 Bandwidth assignment
* The bandwidth assigned to a peer can be influenced by setting a preference
* for a peer. The prefernce will be given to to the solver with s_pref which
* has to take care of the preference value
-
*/
+
/*
* How long will address suggestions blocked after a suggestion
*/
/**
* Averaging queue
*/
- uint32_t atsi_abs[GAS_normalization_queue_length];
+ uint64_t atsi_abs[GAS_normalization_queue_length];
/**
* Averaged ATSI values from queue
*/
- uint32_t avg;
+ uint64_t avg;
/**
* Normalized values from queue to a range of values [1.0...2.0]
double norm;
};
+
/**
* Address with additional information
*/
struct ATS_Address
{
/**
- * Next element in DLL
+ * Peer ID this address is for.
*/
- struct ATS_Address *next;
+ struct GNUNET_PeerIdentity peer;
/**
- * Previous element in DLL
+ * Address (in plugin-specific binary format).
*/
- struct ATS_Address *prev;
+ const void *addr;
/**
- * Peer ID
+ * Plugin name
*/
- struct GNUNET_PeerIdentity peer;
+ char *plugin;
/**
- * Session ID, 0 if no session is given
+ * Solver-specific information for this address
*/
- uint32_t session_id;
+ void *solver_information;
/**
- * Address
+ * ATS performance information for this address
*/
- const void *addr;
+ struct GNUNET_ATS_Properties properties;
/**
- * Address length
+ * Time when address had last activity (update, in uses)
*/
- size_t addr_len;
+ struct GNUNET_TIME_Absolute t_last_activity;
/**
- * Plugin name
+ * Time when address was added
*/
- char *plugin;
+ struct GNUNET_TIME_Absolute t_added;
/**
- * Solver specific information for this address
+ * Address length, number of bytes in @e addr.
*/
- void *solver_information;
+ size_t addr_len;
/**
- * ATS performance information for this address
+ * Session ID, can never be 0.
*/
- struct GNUNET_ATS_Information *atsi;
+ uint32_t session_id;
/**
- * ATS performance information for this address
+ * Field to store local flags.
+ */
+ enum GNUNET_HELLO_AddressInfo local_address_info;
+
+ /**
+ * ATS performance information for this address, size of the @e atsi array.
*/
uint32_t atsi_count;
/**
- * Inbound bandwidth assigned by solver in NBO
+ * Inbound bandwidth assigned by solver
*/
- struct GNUNET_BANDWIDTH_Value32NBO assigned_bw_in;
+ uint32_t assigned_bw_in;
/**
- * Outbound bandwidth assigned by solver in NBO
+ * Outbound bandwidth assigned by solver
*/
- struct GNUNET_BANDWIDTH_Value32NBO assigned_bw_out;
+ uint32_t assigned_bw_out;
/**
- * Blocking interval
+ * Inbound bandwidth assigned by solver in NBO
*/
- struct GNUNET_TIME_Relative block_interval;
+ uint32_t last_notified_bw_in;
/**
- * Time when address can be suggested again
+ * Outbound bandwidth assigned by solver in NBO
*/
- struct GNUNET_TIME_Absolute blocked_until;
+ uint32_t last_notified_bw_out;
/**
* Is this the active address for this peer?
int active;
/**
- * Is this the address for this peer in use?
+ * Normalized delay information for this address.
*/
- int used;
+ struct GAS_NormalizationInfo norm_delay;
/**
- * Normalized ATS performance information for this address
- * Each entry can be accessed using the GNUNET_ATS_QualityProperties avg_queue_index
+ * Normalized distance information for this address.
*/
- struct GAS_NormalizationInfo atsin[GNUNET_ATS_QualityPropertiesCount];
-};
+ struct GAS_NormalizationInfo norm_distance;
+ /**
+ * Normalized utilization inbound for this address.
+ */
+ struct GAS_NormalizationInfo norm_utilization_in;
+ /**
+ * Normalized utilization outbound for this address.
+ */
+ struct GAS_NormalizationInfo norm_utilization_out;
+
+};
-/**
- * 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.
- *
- * @param cfg configuration to use
- * @param stats the statistics handle to use
- * @return an address handle
- */
-struct GAS_Addresses_Handle *
-GAS_addresses_init (const struct GNUNET_CONFIGURATION_Handle *cfg,
- const struct GNUNET_STATISTICS_Handle *stats);
/**
- * Shutdown address subsystem.
- *
- * @param handle the address handle to shutdown
+ * A multipeermap mapping peer identities to `struct ATS_Address`.
*/
-void
-GAS_addresses_done (struct GAS_Addresses_Handle *handle);
+extern struct GNUNET_CONTAINER_MultiPeerMap *GSA_addresses;
+
/**
- * Add a new address for a peer.
- *
- * @param handle the address handle to use
- * @param peer peer
- * @param plugin_name transport plugin name
- * @param plugin_addr plugin address
- * @param plugin_addr_len length of the plugin address
- * @param session_id session id, can be 0
- * @param atsi performance information for this address
- * @param atsi_count number of performance information contained
+ * Initialize address subsystem. The addresses subsystem manages the addresses
+ * known and current performance information.
*/
void
-GAS_addresses_add (struct GAS_Addresses_Handle *handle,
- const struct GNUNET_PeerIdentity *peer, const char *plugin_name,
- const void *plugin_addr, size_t plugin_addr_len, uint32_t session_id,
- const struct GNUNET_ATS_Information *atsi, uint32_t atsi_count);
+GAS_addresses_init (void);
-/**
- * Notification about active use of an address.
- * in_use == GNUNET_YES:
- * This address is used to maintain an active connection with a peer.
- * in_use == GNUNET_NO:
- * This address is no longer used to maintain an active connection with a peer.
- *
- * Note: can only be called with in_use == GNUNET_NO if called with GNUNET_YES
- * before
- *
- * @param handle the address handle to use
- * @param peer peer
- * @param plugin_name transport plugin name
- * @param plugin_addr plugin address
- * @param plugin_addr_len length of the plugin address
- * @param session_id session id, can be 0
- * @param in_use GNUNET_YES if GNUNET_NO
- * @return GNUNET_SYSERR on failure (address unknown ...)
- */
-int
-GAS_addresses_in_use (struct GAS_Addresses_Handle *handle,
- const struct GNUNET_PeerIdentity *peer, const char *plugin_name,
- const void *plugin_addr, size_t plugin_addr_len, uint32_t session_id,
- int in_use);
/**
- * Update an address with a session or performance information for a peer.
- *
- * If an address was added without a session it will be updated with the
- * session
- *
- * @param handle the address handle to use
- * @param peer peer
- * @param plugin_name transport plugin name
- * @param plugin_addr plugin address
- * @param plugin_addr_len length of the plugin address
- * @param session_id session id, can be 0
- * @param atsi performance information for this address
- * @param atsi_count number of performance information contained
+ * Shutdown address subsystem.
*/
void
-GAS_addresses_update (struct GAS_Addresses_Handle *handle,
- const struct GNUNET_PeerIdentity *peer, const char *plugin_name,
- const void *plugin_addr, size_t plugin_addr_len, uint32_t session_id,
- const struct GNUNET_ATS_Information *atsi, uint32_t atsi_count);
+GAS_addresses_done (void);
+
/**
- * Remove an address or just a session for a peer.
+ * Add a new address for a peer.
*
- * @param handle the address handle to use
* @param peer peer
* @param plugin_name transport plugin name
* @param plugin_addr plugin address
- * @param plugin_addr_len length of the plugin address
- * @param session_id session id, can be 0
+ * @param plugin_addr_len length of the @a plugin_addr
+ * @param local_address_info the local address for the address
+ * @param session_id session id, can never be 0.
+ * @param prop performance information for this address
*/
void
-GAS_addresses_destroy (struct GAS_Addresses_Handle *handle,
- const struct GNUNET_PeerIdentity *peer, const char *plugin_name,
- const void *plugin_addr, size_t plugin_addr_len, uint32_t session_id);
+GAS_addresses_add (const struct GNUNET_PeerIdentity *peer,
+ const char *plugin_name,
+ const void *plugin_addr,
+ size_t plugin_addr_len,
+ uint32_t local_address_info,
+ uint32_t session_id,
+ const struct GNUNET_ATS_Properties *prop);
-/**
- * Remove all addresses
- *
- * @param handle the address handle to use
- */
-void
-GAS_addresses_destroy_all (struct GAS_Addresses_Handle *handle);
/**
- * Request address suggestions for a peer
+ * Update an address with new performance information for a peer.
*
- * @param handle the address handle
- * @param peer the peer id
+ * @param peer peer
+ * @param session_id session id, can never be 0
+ * @param prop performance information for this address
*/
void
-GAS_addresses_request_address (struct GAS_Addresses_Handle *handle,
- const struct GNUNET_PeerIdentity *peer);
+GAS_addresses_update (const struct GNUNET_PeerIdentity *peer,
+ uint32_t session_id,
+ const struct GNUNET_ATS_Properties *prop);
-/**
- * Cancel address suggestions for a peer
- *
- * @param handle the address handle
- * @param peer the peer id
- */
-void
-GAS_addresses_request_address_cancel (struct GAS_Addresses_Handle *handle,
- const struct GNUNET_PeerIdentity *peer);
/**
- * Reset suggestion backoff for a peer
+ * Remove an address for a peer.
*
- * Suggesting addresses is blocked for ATS_BLOCKING_DELTA. Blocking can be
- * reset using this function
- *
- * @param handle the address handle
- * @param peer the peer id
+ * @param peer peer
+ * @param session_id session id, can never be 0
*/
void
-GAS_addresses_handle_backoff_reset (struct GAS_Addresses_Handle *handle,
- const struct GNUNET_PeerIdentity *peer);
+GAS_addresses_destroy (const struct GNUNET_PeerIdentity *peer,
+ uint32_t session_id);
-/**
- * Change the preference for a peer
- *
- * @param handle the address handle
- * @param client the client sending this request
- * @param peer the peer id
- * @param kind the preference kind to change
- * @param score_abs the new preference score
- */
-void
-GAS_addresses_change_preference (struct GAS_Addresses_Handle *handle,
- void *client, const struct GNUNET_PeerIdentity *peer,
- enum GNUNET_ATS_PreferenceKind kind, float score_abs);
/**
- * Application feedback on how good preference requirements are fulfilled
- * for a specific preference in the given time scope [now - scope .. now]
- *
- * An application notifies ATS if (and only if) it has feedback information
- * for a specific property. This value is valid until the feedback score is
- * updated by the application.
- *
- * If the application has no feedback for this preference kind the application
- * will not explicitly call.
- *
- * @param handle the address handle
- * @param application the application sending this request
- * @param peer the peer id
- * @param scope the time interval this valid for: [now - scope .. now]
- * @param kind the preference kind this feedback is intended for
- * @param score_abs the new preference score
+ * Remove all addresses.
*/
void
-GAS_addresses_preference_feedback (struct GAS_Addresses_Handle *handle,
- void *application, const struct GNUNET_PeerIdentity *peer,
- const struct GNUNET_TIME_Relative scope,
- enum GNUNET_ATS_PreferenceKind kind, float score_abs);
-
-/**
- * Iterator for GAS_addresses_iterate_peers
- *
- * @param p_it_cls closure
- * @param id the peer id
- */
-typedef void
-(*GNUNET_ATS_Peer_Iterator) (void *p_it_cls,
- const struct GNUNET_PeerIdentity *id);
+GAS_addresses_destroy_all (void);
-/**
- * Return all peers currently known to ATS
- *
- * @param handle the address handle to use
- * @param p_it the iterator to call for every peer
- * @param p_it_cls the closure for the iterator
- */
-void
-GAS_addresses_iterate_peers (struct GAS_Addresses_Handle *handle,
- GNUNET_ATS_Peer_Iterator p_it, void *p_it_cls);
/**
- * Iterator for GAS_addresses_get_peer_info
+ * Iterator for #GAS_addresses_get_peer_info()
*
- * @param p_it_cls closure closure
+ * @param cls closure
* @param id the peer id
* @param plugin_name plugin name
* @param plugin_addr address
- * @param plugin_addr_len address length
+ * @param plugin_addr_len length of @a plugin_addr
* @param address_active is address actively used
* @param atsi ats performance information
- * @param atsi_count number of ats performance elements
+ * @param local_address_info flags for the address
* @param bandwidth_out current outbound bandwidth assigned to address
* @param bandwidth_in current inbound bandwidth assigned to address
*/
typedef void
-(*GNUNET_ATS_PeerInfo_Iterator) (void *p_it_cls,
- const struct GNUNET_PeerIdentity *id, const char *plugin_name,
- const void *plugin_addr, size_t plugin_addr_len, const int address_active,
- const struct GNUNET_ATS_Information *atsi, uint32_t atsi_count,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out,
- struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in);
+(*GNUNET_ATS_PeerInfo_Iterator) (void *cls,
+ const struct GNUNET_PeerIdentity *id,
+ const char *plugin_name,
+ const void *plugin_addr,
+ size_t plugin_addr_len,
+ const int address_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);
+
/**
* Return information all peers currently known to ATS
*
- * @param handle the address handle to use
* @param peer the respective peer
* @param pi_it the iterator to call for every peer
- * @param pi_it_cls the closure for the iterator
+ * @param pi_it_cls the closure for @a pi_it
+ */
+void
+GAS_addresses_get_peer_info (const struct GNUNET_PeerIdentity *peer,
+ GNUNET_ATS_PeerInfo_Iterator pi_it,
+ void *pi_it_cls);
+
+
+/**
+ * Handle 'address list request' messages from clients.
+ *
+ * @param client client that sent the request
+ * @param alrm the request message
*/
void
-GAS_addresses_get_peer_info (struct GAS_Addresses_Handle *handle,
- const struct GNUNET_PeerIdentity *peer, GNUNET_ATS_PeerInfo_Iterator pi_it,
- void *pi_it_cls);
+GAS_handle_request_address_list (struct GNUNET_SERVICE_Client *client,
+ const struct AddressListRequestMessage *alrm);
+
#endif