GNUnet  0.11.x
Data Structures | Macros | Typedefs | Enumerations | Functions
ATS service

Bandwidth allocation. More...

Data Structures

struct  GNUNET_ATS_Properties
 ATS performance characteristics for an address. More...
 
struct  GNUNET_ATS_PropertiesNBO
 ATS performance characteristics for an address in network byte order (for IPC). More...
 

Macros

#define GNUNET_ATS_DefaultBandwidth   65536
 Default bandwidth assigned to a network : 64 KB/s. More...
 
#define GNUNET_ATS_VALUE_UNDEFINED   UINT32_MAX
 Undefined value for an enum GNUNET_ATS_Property More...
 
#define GNUNET_ATS_VALUE_UNDEFINED_STR   "undefined"
 String representation for GNUNET_ATS_VALUE_UNDEFINED. More...
 
#define GNUNET_ATS_MaxBandwidth   UINT32_MAX
 Maximum bandwidth assigned to a network : 4095 MB/s. More...
 
#define GNUNET_ATS_MaxBandwidthString   "unlimited"
 Textual equivalent for GNUNET_ATS_MaxBandwidth. More...
 
#define GNUNET_ATS_PreferenceType
 ATS preference types as array initializer. More...
 
#define GNUNET_ATS_PreferenceTypeString   { "BANDWIDTH", "LATENCY", "END" }
 ATS preference types as string array initializer. More...
 

Typedefs

typedef void(* GNUNET_ATS_AddressSuggestionCallback) (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
 Signature of a function called by ATS with the current bandwidth and address preferences as determined by ATS. More...
 
typedef void(* GNUNET_ATS_AddressInformationCallback) (void *cls, const struct GNUNET_HELLO_Address *address, int address_active, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, const struct GNUNET_ATS_Properties *prop)
 Signature of a function that is called with QoS information about an address. More...
 
typedef void(* GNUNET_ATS_ReservationCallback) (void *cls, const struct GNUNET_PeerIdentity *peer, int32_t amount, struct GNUNET_TIME_Relative res_delay)
 Function called with reservation result. More...
 
typedef void(* GNUNET_ATS_AllocationCallback) (void *cls, struct GNUNET_ATS_Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
 Signature of a function called by ATS with the current bandwidth allocation to be used as determined by ATS. More...
 
typedef void(* GNUNET_ATS_SuggestionCallback) (void *cls, const struct GNUNET_PeerIdentity *pid, const char *address)
 Signature of a function called by ATS suggesting transport to try connecting with a particular address. More...
 

Enumerations

enum  GNUNET_ATS_PreferenceKind { GNUNET_ATS_PREFERENCE_BANDWIDTH = 0, GNUNET_ATS_PREFERENCE_LATENCY = 1, GNUNET_ATS_PREFERENCE_END = 2 }
 Enum defining all known preference categories. More...
 

Functions

struct GNUNET_ATS_ApplicationHandle * GNUNET_ATS_application_init (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Initialize the ATS application client handle. More...
 
void GNUNET_ATS_application_done (struct GNUNET_ATS_ApplicationHandle *ch)
 Shutdown ATS application client. More...
 
struct GNUNET_ATS_ApplicationSuggestHandle * GNUNET_ATS_application_suggest (struct GNUNET_ATS_ApplicationHandle *ch, const struct GNUNET_PeerIdentity *peer, enum GNUNET_MQ_PreferenceKind pk, struct GNUNET_BANDWIDTH_Value32NBO bw)
 An application would like to communicate with a peer. More...
 
void GNUNET_ATS_application_suggest_cancel (struct GNUNET_ATS_ApplicationSuggestHandle *sh)
 We no longer care about communicating with a peer. More...
 
void GNUNET_ATS_properties_hton (struct GNUNET_ATS_PropertiesNBO *nbo, const struct GNUNET_ATS_Properties *hbo)
 Convert ATS properties from host to network byte order. More...
 
void GNUNET_ATS_properties_ntoh (struct GNUNET_ATS_Properties *hbo, const struct GNUNET_ATS_PropertiesNBO *nbo)
 Convert ATS properties from network to host byte order. More...
 
struct GNUNET_ATS_ConnectivityHandleGNUNET_ATS_connectivity_init (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Initialize the ATS connectivity suggestion client handle. More...
 
void GNUNET_ATS_connectivity_done (struct GNUNET_ATS_ConnectivityHandle *ch)
 Shutdown ATS connectivity suggestion client. More...
 
struct GNUNET_ATS_ConnectivitySuggestHandleGNUNET_ATS_connectivity_suggest (struct GNUNET_ATS_ConnectivityHandle *ch, const struct GNUNET_PeerIdentity *peer, uint32_t strength)
 We would like to establish a new connection with a peer. More...
 
void GNUNET_ATS_connectivity_suggest_cancel (struct GNUNET_ATS_ConnectivitySuggestHandle *sh)
 We no longer care about being connected to a peer. More...
 
struct GNUNET_ATS_SchedulingHandleGNUNET_ATS_scheduling_init (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_ATS_AddressSuggestionCallback suggest_cb, void *suggest_cb_cls)
 Initialize the ATS scheduling subsystem. More...
 
void GNUNET_ATS_scheduling_done (struct GNUNET_ATS_SchedulingHandle *sh)
 Client is done with ATS scheduling, release resources. More...
 
struct GNUNET_ATS_AddressRecordGNUNET_ATS_address_add (struct GNUNET_ATS_SchedulingHandle *sh, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, const struct GNUNET_ATS_Properties *prop)
 We have a new address ATS should know. More...
 
void GNUNET_ATS_address_add_session (struct GNUNET_ATS_AddressRecord *ar, struct GNUNET_ATS_Session *session)
 An address was used to initiate a session. More...
 
int GNUNET_ATS_address_del_session (struct GNUNET_ATS_AddressRecord *ar, struct GNUNET_ATS_Session *session)
 A session was destroyed, disassociate it from the given address record. More...
 
void GNUNET_ATS_address_update (struct GNUNET_ATS_AddressRecord *ar, const struct GNUNET_ATS_Properties *prop)
 We have updated performance statistics for a given address. More...
 
void GNUNET_ATS_address_destroy (struct GNUNET_ATS_AddressRecord *ar)
 An address got destroyed, stop using it as a valid address. More...
 
struct GNUNET_ATS_PerformanceHandleGNUNET_ATS_performance_init (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_ATS_AddressInformationCallback addr_info_cb, void *addr_info_cb_cls)
 Get handle to access performance API of the ATS subsystem. More...
 
struct GNUNET_ATS_AddressListHandleGNUNET_ATS_performance_list_addresses (struct GNUNET_ATS_PerformanceHandle *ph, const struct GNUNET_PeerIdentity *peer, int all, GNUNET_ATS_AddressInformationCallback infocb, void *infocb_cls)
 Get information about addresses known to the ATS subsystem. More...
 
void GNUNET_ATS_performance_list_addresses_cancel (struct GNUNET_ATS_AddressListHandle *alh)
 Cancel a pending address listing operation. More...
 
void GNUNET_ATS_performance_done (struct GNUNET_ATS_PerformanceHandle *ph)
 Client is done using the ATS performance subsystem, release resources. More...
 
struct GNUNET_ATS_ReservationContextGNUNET_ATS_reserve_bandwidth (struct GNUNET_ATS_PerformanceHandle *ph, const struct GNUNET_PeerIdentity *peer, int32_t amount, GNUNET_ATS_ReservationCallback rcb, void *rcb_cls)
 Reserve inbound bandwidth from the given peer. More...
 
void GNUNET_ATS_reserve_bandwidth_cancel (struct GNUNET_ATS_ReservationContext *rc)
 Cancel request for reserving bandwidth. More...
 
const char * GNUNET_ATS_print_preference_type (enum GNUNET_ATS_PreferenceKind type)
 Convert a GNUNET_ATS_PreferenceType to a string. More...
 
void GNUNET_ATS_performance_change_preference (struct GNUNET_ATS_PerformanceHandle *ph, const struct GNUNET_PeerIdentity *peer,...)
 Change preferences for the given peer. More...
 
void GNUNET_ATS_performance_give_feedback (struct GNUNET_ATS_PerformanceHandle *ph, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_TIME_Relative scope,...)
 Application feedback on how good preference requirements are fulfilled for the preferences included in the given time scope [now - scope . More...
 
struct GNUNET_ATS_TransportHandle * GNUNET_ATS_transport_init (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_ATS_AllocationCallback alloc_cb, void *alloc_cb_cls, GNUNET_ATS_SuggestionCallback suggest_cb, void *suggest_cb_cls)
 Initialize the ATS transport subsystem. More...
 
void GNUNET_ATS_transport_done (struct GNUNET_ATS_TransportHandle *ath)
 Client is done with ATS transport, release resources. More...
 
struct GNUNET_ATS_SessionRecord * GNUNET_ATS_session_add (struct GNUNET_ATS_TransportHandle *ath, const struct GNUNET_PeerIdentity *pid, const char *address, struct GNUNET_ATS_Session *session, const struct GNUNET_ATS_Properties *prop)
 We have a new session ATS should know. More...
 
void GNUNET_ATS_session_update (struct GNUNET_ATS_SessionRecord *ar, const struct GNUNET_ATS_Properties *prop)
 We have updated performance statistics for a given session. More...
 
void GNUNET_ATS_session_del (struct GNUNET_ATS_SessionRecord *ar)
 A session was destroyed, ATS should now schedule and allocate under the assumption that this ar is no longer in use. More...
 

Detailed Description

Bandwidth allocation.

Bandwidth allocation for transport service.

Automatic Transport Selection and outbound bandwidth determination.

See also
Documentation

Macro Definition Documentation

◆ GNUNET_ATS_DefaultBandwidth

#define GNUNET_ATS_DefaultBandwidth   65536

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

Definition at line 45 of file gnunet_ats_service.h.

Referenced by GNUNET_ATS_solvers_load_quotas(), load_quota(), and parse_quota().

◆ GNUNET_ATS_VALUE_UNDEFINED

#define GNUNET_ATS_VALUE_UNDEFINED   UINT32_MAX

Undefined value for an enum GNUNET_ATS_Property

Definition at line 50 of file gnunet_ats_service.h.

◆ GNUNET_ATS_VALUE_UNDEFINED_STR

#define GNUNET_ATS_VALUE_UNDEFINED_STR   "undefined"

String representation for GNUNET_ATS_VALUE_UNDEFINED.

Definition at line 55 of file gnunet_ats_service.h.

◆ GNUNET_ATS_MaxBandwidth

#define GNUNET_ATS_MaxBandwidth   UINT32_MAX

Maximum bandwidth assigned to a network : 4095 MB/s.

Definition at line 60 of file gnunet_ats_service.h.

Referenced by GNUNET_ATS_solvers_load_quotas(), and parse_quota().

◆ GNUNET_ATS_MaxBandwidthString

#define GNUNET_ATS_MaxBandwidthString   "unlimited"

Textual equivalent for GNUNET_ATS_MaxBandwidth.

Definition at line 65 of file gnunet_ats_service.h.

Referenced by parse_quota().

◆ GNUNET_ATS_PreferenceType

#define GNUNET_ATS_PreferenceType
Value:
GNUNET_ATS_PREFERENCE_LATENCY, \
GNUNET_ATS_PREFERENCE_END }
Change the peer's bandwidth value (value per byte of bandwidth in the goal function) to the given amo...

ATS preference types as array initializer.

Definition at line 533 of file gnunet_ats_service.h.

◆ GNUNET_ATS_PreferenceTypeString

#define GNUNET_ATS_PreferenceTypeString   { "BANDWIDTH", "LATENCY", "END" }

ATS preference types as string array initializer.

Definition at line 540 of file gnunet_ats_service.h.

Referenced by GNUNET_ATS_print_preference_type(), and parse_preference_string().

Typedef Documentation

◆ GNUNET_ATS_AddressSuggestionCallback

typedef void(* GNUNET_ATS_AddressSuggestionCallback) (void *cls, const struct GNUNET_PeerIdentity *peer, const struct GNUNET_HELLO_Address *address, struct GNUNET_ATS_Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)

Signature of a function called by ATS with the current bandwidth and address preferences as determined by ATS.

If our connection to ATS dies and thus all suggestions become invalid, this function is called ONCE with all arguments (except cls) being NULL/0.

Parameters
clsclosure
peerfor which we suggest an address, NULL if ATS connection died
addresssuggested address (including peer identity of the peer), may be NULL to signal disconnect from peer
sessionsession to use, NULL to establish a new outgoing session
bandwidth_outassigned outbound bandwidth for the connection, 0 to signal disconnect
bandwidth_inassigned inbound bandwidth for the connection, 0 to signal disconnect

Definition at line 265 of file gnunet_ats_service.h.

◆ GNUNET_ATS_AddressInformationCallback

typedef void(* GNUNET_ATS_AddressInformationCallback) (void *cls, const struct GNUNET_HELLO_Address *address, int address_active, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, const struct GNUNET_ATS_Properties *prop)

Signature of a function that is called with QoS information about an address.

Parameters
clsclosure
addressthe address, NULL if ATS service was disconnected or when the iteration is completed in the case of GNUNET_ATS_performance_list_addresses()
address_activeGNUNET_YES if this address is actively used to maintain a connection to a peer; GNUNET_NO if the address is not actively used; GNUNET_SYSERR if this address is no longer available for ATS
bandwidth_outassigned outbound bandwidth for the connection
bandwidth_inassigned inbound bandwidth for the connection
propperformance data for the address

Definition at line 403 of file gnunet_ats_service.h.

◆ GNUNET_ATS_ReservationCallback

typedef void(* GNUNET_ATS_ReservationCallback) (void *cls, const struct GNUNET_PeerIdentity *peer, int32_t amount, struct GNUNET_TIME_Relative res_delay)

Function called with reservation result.

Parameters
clsclosure
peeridentifies the peer
amountset to the amount that was actually reserved or unreserved; either the full requested amount or zero (no partial reservations)
res_delayif the reservation could not be satisfied (amount was 0), how long should the client wait until re-trying?

Definition at line 487 of file gnunet_ats_service.h.

◆ GNUNET_ATS_AllocationCallback

typedef void(* GNUNET_ATS_AllocationCallback) (void *cls, struct GNUNET_ATS_Session *session, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)

Signature of a function called by ATS with the current bandwidth allocation to be used as determined by ATS.

Parameters
clsclosure
sessionsession this is about
bandwidth_outassigned outbound bandwidth for the connection, 0 to signal disconnect
bandwidth_inassigned inbound bandwidth for the connection, 0 to signal disconnect

Definition at line 136 of file gnunet_ats_transport_service.h.

◆ GNUNET_ATS_SuggestionCallback

typedef void(* GNUNET_ATS_SuggestionCallback) (void *cls, const struct GNUNET_PeerIdentity *pid, const char *address)

Signature of a function called by ATS suggesting transport to try connecting with a particular address.

Parameters
clsclosure
pidtarget peer
addressthe address to try

Definition at line 153 of file gnunet_ats_transport_service.h.

Enumeration Type Documentation

◆ GNUNET_ATS_PreferenceKind

Enum defining all known preference categories.

Enumerator
GNUNET_ATS_PREFERENCE_BANDWIDTH 

Change the peer's bandwidth value (value per byte of bandwidth in the goal function) to the given amount.

The argument is followed by a double value giving the desired value (can be negative). Preference changes are forgotten if peers disconnect.

GNUNET_ATS_PREFERENCE_LATENCY 

Change the peer's latency value to the given amount.

The argument is followed by a double value giving the desired value (can be negative). The absolute score in the goal function is the inverse of the latency in microseconds (minimum: 1 microsecond) multiplied by the latency preferences.

GNUNET_ATS_PREFERENCE_END 

End of preference list.

Definition at line 545 of file gnunet_ats_service.h.

546 {
554 
563 
568 };
End of preference list.
Change the peer's latency value to the given amount.
Change the peer's bandwidth value (value per byte of bandwidth in the goal function) to the given amo...

Function Documentation

◆ GNUNET_ATS_application_init()

struct GNUNET_ATS_ApplicationHandle* GNUNET_ATS_application_init ( const struct GNUNET_CONFIGURATION_Handle cfg)

Initialize the ATS application client handle.

Parameters
cfgconfiguration to use
Returns
ats application handle, NULL on error

◆ GNUNET_ATS_application_done()

void GNUNET_ATS_application_done ( struct GNUNET_ATS_ApplicationHandle *  ch)

Shutdown ATS application client.

Parameters
chhandle to destroy

◆ GNUNET_ATS_application_suggest()

struct GNUNET_ATS_ApplicationSuggestHandle* GNUNET_ATS_application_suggest ( struct GNUNET_ATS_ApplicationHandle *  ch,
const struct GNUNET_PeerIdentity peer,
enum GNUNET_MQ_PreferenceKind  pk,
struct GNUNET_BANDWIDTH_Value32NBO  bw 
)

An application would like to communicate with a peer.

ATS should allocate bandwith using a suitable address for requiremetns pk to transport.

Parameters
chhandle
peeridentity of the peer we need an address for
pkwhat kind of application will the application require (can be GNUNET_MQ_PREFERENCE_NONE, we will still try to connect)
bwdesired bandwith, can be zero (we will still try to connect)
Returns
suggestion handle, NULL if request is already pending

◆ GNUNET_ATS_application_suggest_cancel()

void GNUNET_ATS_application_suggest_cancel ( struct GNUNET_ATS_ApplicationSuggestHandle *  sh)

We no longer care about communicating with a peer.

Parameters
shhandle

◆ GNUNET_ATS_properties_hton()

void GNUNET_ATS_properties_hton ( struct GNUNET_ATS_PropertiesNBO nbo,
const struct GNUNET_ATS_Properties hbo 
)

Convert ATS properties from host to network byte order.

Parameters
nbo[OUT]value written
hbovalue read

Definition at line 36 of file ats_api_scanner.c.

References GNUNET_ATS_PropertiesNBO::delay, GNUNET_ATS_Properties::delay, GNUNET_ATS_Properties::distance, GNUNET_ATS_PropertiesNBO::distance, GNUNET_TIME_relative_hton(), GNUNET_ATS_Properties::scope, GNUNET_ATS_PropertiesNBO::scope, GNUNET_ATS_Properties::utilization_in, GNUNET_ATS_PropertiesNBO::utilization_in, GNUNET_ATS_Properties::utilization_out, and GNUNET_ATS_PropertiesNBO::utilization_out.

Referenced by GNUNET_ATS_address_add(), GNUNET_ATS_address_update(), GNUNET_TRANSPORT_manipulation_set(), notify_client(), and transmit_req_addr().

38 {
39  nbo->utilization_out = htonl (hbo->utilization_out);
40  nbo->utilization_in = htonl (hbo->utilization_in);
41  nbo->scope = htonl ((uint32_t) hbo->scope);
42  nbo->distance = htonl (hbo->distance);
44 }
uint32_t utilization_in
Actual traffic on this connection from the other peer to this peer.
uint32_t utilization_in
Actual traffic on this connection from the other peer to this peer.
uint32_t scope
Which network scope does the respective address belong to? This property does not change...
struct GNUNET_TIME_RelativeNBO delay
Delay.
struct GNUNET_TIME_Relative delay
Delay.
uint32_t utilization_out
Actual traffic on this connection from this peer to the other peer.
struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton(struct GNUNET_TIME_Relative a)
Convert relative time to network byte order.
Definition: time.c:625
enum GNUNET_NetworkType scope
Which network scope does the respective address belong to? This property does not change...
uint32_t distance
Distance on network layer (required for distance-vector routing) in hops.
unsigned int distance
Distance on network layer (required for distance-vector routing) in hops.
uint32_t utilization_out
Actual traffic on this connection from this peer to the other peer.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ATS_properties_ntoh()

void GNUNET_ATS_properties_ntoh ( struct GNUNET_ATS_Properties hbo,
const struct GNUNET_ATS_PropertiesNBO nbo 
)

Convert ATS properties from network to host byte order.

Parameters
hbo[OUT]value written
nbovalue read

Definition at line 54 of file ats_api_scanner.c.

References GNUNET_ATS_PropertiesNBO::delay, GNUNET_ATS_Properties::delay, GNUNET_ATS_Properties::distance, GNUNET_ATS_PropertiesNBO::distance, GNUNET_TIME_relative_ntoh(), GNUNET_ATS_Properties::scope, GNUNET_ATS_PropertiesNBO::scope, GNUNET_ATS_Properties::utilization_in, GNUNET_ATS_PropertiesNBO::utilization_in, GNUNET_ATS_Properties::utilization_out, and GNUNET_ATS_PropertiesNBO::utilization_out.

Referenced by GAS_handle_address_add(), GAS_handle_address_update(), GST_manipulation_set_metric(), handle_address_list(), and handle_peer_information().

56 {
57  hbo->utilization_out = ntohl (nbo->utilization_out);
58  hbo->utilization_in = ntohl (nbo->utilization_in);
59  hbo->scope = ntohl ((uint32_t) nbo->scope);
60  hbo->distance = ntohl (nbo->distance);
62 }
uint32_t utilization_in
Actual traffic on this connection from the other peer to this peer.
uint32_t utilization_in
Actual traffic on this connection from the other peer to this peer.
uint32_t scope
Which network scope does the respective address belong to? This property does not change...
struct GNUNET_TIME_RelativeNBO delay
Delay.
struct GNUNET_TIME_Relative delay
Delay.
struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh(struct GNUNET_TIME_RelativeNBO a)
Convert relative time from network byte order.
Definition: time.c:641
uint32_t utilization_out
Actual traffic on this connection from this peer to the other peer.
enum GNUNET_NetworkType scope
Which network scope does the respective address belong to? This property does not change...
uint32_t distance
Distance on network layer (required for distance-vector routing) in hops.
unsigned int distance
Distance on network layer (required for distance-vector routing) in hops.
uint32_t utilization_out
Actual traffic on this connection from this peer to the other peer.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ATS_connectivity_init()

struct GNUNET_ATS_ConnectivityHandle* GNUNET_ATS_connectivity_init ( const struct GNUNET_CONFIGURATION_Handle cfg)

Initialize the ATS connectivity suggestion client handle.

Parameters
cfgconfiguration to use
Returns
ats connectivity handle, NULL on error

Definition at line 227 of file ats_api_connectivity.c.

References cfg, GNUNET_ATS_ConnectivityHandle::cfg, GNUNET_ATS_ConnectivitySuggestHandle::ch, GNUNET_CONTAINER_multipeermap_create(), GNUNET_new, GNUNET_YES, reconnect(), and GNUNET_ATS_ConnectivityHandle::sug_requests.

Referenced by GDS_NEIGHBOURS_init(), GNUNET_TRANSPORT_TESTING_restart_peer(), GNUNET_TRANSPORT_TESTING_start_peer(), opstart_get_handle_ats_connectivity(), and run().

228 {
230 
232  ch->cfg = cfg;
234  GNUNET_YES);
235  reconnect (ch);
236  return ch;
237 }
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static void reconnect(struct GNUNET_ATS_ConnectivityHandle *ch)
Re-establish the connection to the ATS service.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
struct GNUNET_CONTAINER_MultiPeerMap * sug_requests
Map with the identities of all the peers for which we would like to have address suggestions.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
#define GNUNET_YES
Definition: gnunet_common.h:77
Handle to the ATS subsystem for connectivity management.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ATS_connectivity_done()

void GNUNET_ATS_connectivity_done ( struct GNUNET_ATS_ConnectivityHandle ch)

Shutdown ATS connectivity suggestion client.

Parameters
chhandle to destroy

Shutdown ATS connectivity suggestion client.

Parameters
chhandle to release

Definition at line 267 of file ats_api_connectivity.c.

References free_sug_handle(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), GNUNET_ATS_ConnectivityHandle::mq, GNUNET_ATS_ConnectivityHandle::sug_requests, and GNUNET_ATS_ConnectivityHandle::task.

Referenced by cleaning_task(), end(), GDS_NEIGHBOURS_done(), GNUNET_TRANSPORT_TESTING_restart_peer(), GNUNET_TRANSPORT_TESTING_stop_peer(), oprelease_get_handle_ats_connectivity(), run(), shutdown_rest(), and shutdown_task().

268 {
269  if (NULL != ch->mq)
270  {
271  GNUNET_MQ_destroy (ch->mq);
272  ch->mq = NULL;
273  }
274  if (NULL != ch->task)
275  {
277  ch->task = NULL;
278  }
281  NULL);
283  GNUNET_free (ch);
284 }
struct GNUNET_MQ_Handle * mq
Message queue for sending requests to the ATS service.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
struct GNUNET_SCHEDULER_Task * task
Task to trigger reconnect.
struct GNUNET_CONTAINER_MultiPeerMap * sug_requests
Map with the identities of all the peers for which we would like to have address suggestions.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
static int free_sug_handle(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Function called to free all struct GNUNET_ATS_ConnectivitySuggestHandles in the map.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ATS_connectivity_suggest()

struct GNUNET_ATS_ConnectivitySuggestHandle* GNUNET_ATS_connectivity_suggest ( struct GNUNET_ATS_ConnectivityHandle ch,
const struct GNUNET_PeerIdentity peer,
uint32_t  strength 
)

We would like to establish a new connection with a peer.

ATS should suggest a good address to begin with.

Parameters
chhandle
peeridentity of the peer we need an address for
strengthhow urgent is the need for such a suggestion
Returns
suggestion handle, NULL if request is already pending

We would like to establish a new connection with a peer.

ATS will respond with a call to the continuation immediately containing an address or no address if none is available. ATS can suggest more addresses until we call GNUNET_ATS_connectivity_suggest_cancel().

Parameters
chhandle
peeridentity of the peer we need an address for
strengthhow urgent is the need for such a suggestion
Returns
suggest handle, NULL if a request is already pending

Definition at line 299 of file ats_api_connectivity.c.

References GNUNET_ATS_ConnectivitySuggestHandle::ch, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_CONTAINER_multipeermap_put(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_new, GNUNET_OK, GNUNET_ATS_ConnectivitySuggestHandle::id, LOG, GNUNET_ATS_ConnectivityHandle::mq, peer, GNUNET_ATS_ConnectivitySuggestHandle::strength, GNUNET_ATS_ConnectivityHandle::sug_requests, and transmit_suggestion().

Referenced by attempt_connect(), consider_peer_activate(), GNUNET_TRANSPORT_TESTING_connect_peers(), notify_disconnect(), occ_cache_get_handle_ats_occ_cb(), occ_cache_get_handle_ats_rocc_cb(), run(), setup_neighbour(), and try_connect().

302 {
304 
306  s->ch = ch;
307  s->id = *peer;
308  s->strength = strength;
309  if (GNUNET_OK !=
311  &s->id,
312  s,
314  {
316  "Not requesting ATS to suggest address for `%s', request already pending\n",
317  GNUNET_i2s (peer));
318  GNUNET_free (s);
319  return NULL;
320  }
322  "Requesting ATS to suggest address for `%s'\n",
323  GNUNET_i2s (peer));
324  if (NULL == ch->mq)
325  return s;
326  (void) transmit_suggestion (ch,
327  &s->id,
328  s);
329  return s;
330 }
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
struct GNUNET_MQ_Handle * mq
Message queue for sending requests to the ATS service.
#define LOG(kind,...)
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_new(type)
Allocate a struct or union of the given type.
uint32_t strength
How urgent is the request.
Handle for ATS address suggestion requests.
struct GNUNET_CONTAINER_MultiPeerMap * sug_requests
Map with the identities of all the peers for which we would like to have address suggestions.
static int transmit_suggestion(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
Transmit request for an address suggestion.
There must only be one value per key; storing a value should fail if a value under the same key alrea...
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
int GNUNET_CONTAINER_multipeermap_put(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
struct GNUNET_ATS_ConnectivityHandle * ch
Connecitivity handle this suggestion handle belongs to.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_PeerIdentity id
ID of the peer for which address suggestion was requested.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ATS_connectivity_suggest_cancel()

void GNUNET_ATS_connectivity_suggest_cancel ( struct GNUNET_ATS_ConnectivitySuggestHandle sh)

We no longer care about being connected to a peer.

Parameters
shhandle
shhandle to stop

Definition at line 339 of file ats_api_connectivity.c.

References GNUNET_ATS_ConnectivitySuggestHandle::ch, GNUNET_assert, GNUNET_CONTAINER_multipeermap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS_CANCEL, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_OK, GNUNET_ATS_ConnectivitySuggestHandle::id, LOG, m, GNUNET_ATS_ConnectivityHandle::mq, RequestAddressMessage::peer, RequestAddressMessage::strength, and GNUNET_ATS_ConnectivityHandle::sug_requests.

Referenced by attempt_connect(), cleanup_occ_lp2c(), cleanup_rocc(), consider_peer_activate(), destroy_peer(), end(), free_connect_info(), free_neighbour(), free_peer(), GNUNET_TRANSPORT_TESTING_connect_peers_cancel(), notify_connect(), shutdown_task(), and try_connect().

341 {
342  struct GNUNET_ATS_ConnectivityHandle *ch = sh->ch;
343  struct GNUNET_MQ_Envelope *ev;
344  struct RequestAddressMessage *m;
345 
347  "Telling ATS we no longer care for an address for `%s'\n",
348  GNUNET_i2s (&sh->id));
351  &sh->id,
352  sh));
353  if (NULL == ch->mq)
354  {
355  GNUNET_free (sh);
356  return;
357  }
358  ev = GNUNET_MQ_msg (m,
360  m->strength = htonl (0);
361  m->peer = sh->id;
362  GNUNET_MQ_send (ch->mq, ev);
363  GNUNET_free (sh);
364 }
Connectivity client to ATS service: we would like to have address suggestions for this peer...
Definition: ats.h:87
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
struct GNUNET_MQ_Handle * mq
Message queue for sending requests to the ATS service.
#define LOG(kind,...)
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
int GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
uint32_t strength
How "strong" is our need for an address for this peer?
Definition: ats.h:99
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
#define GNUNET_MESSAGE_TYPE_ATS_REQUEST_ADDRESS_CANCEL
Type of the 'struct RequestAddressMessage' sent by clients to ATS to request an address to help conne...
struct GNUNET_CONTAINER_MultiPeerMap * sug_requests
Map with the identities of all the peers for which we would like to have address suggestions.
struct GNUNET_ATS_ConnectivityHandle * ch
Connecitivity handle this suggestion handle belongs to.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
Handle to the ATS subsystem for connectivity management.
struct GNUNET_PeerIdentity peer
Peer to get address suggestions for.
Definition: ats.h:104
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_PeerIdentity id
ID of the peer for which address suggestion was requested.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ATS_scheduling_init()

struct GNUNET_ATS_SchedulingHandle* GNUNET_ATS_scheduling_init ( const struct GNUNET_CONFIGURATION_Handle cfg,
GNUNET_ATS_AddressSuggestionCallback  suggest_cb,
void *  suggest_cb_cls 
)

Initialize the ATS scheduling subsystem.

Parameters
cfgconfiguration to use
suggest_cbnotification to call whenever the suggestation changed
suggest_cb_clsclosure for suggest_cb
Returns
ats context

Initialize the ATS scheduling subsystem.

Parameters
cfgconfiguration to use
suggest_cbnotification to call whenever the suggestation changed
suggest_cb_clsclosure for suggest_cb
Returns
ats context

Definition at line 569 of file ats_api_scheduling.c.

References cfg, GNUNET_ATS_SchedulingHandle::cfg, GNUNET_array_grow, GNUNET_new, reconnect(), GNUNET_ATS_SchedulingHandle::session_array, GNUNET_ATS_SchedulingHandle::session_array_size, GNUNET_ATS_AddressRecord::sh, GNUNET_ATS_SchedulingHandle::suggest_cb, and GNUNET_ATS_SchedulingHandle::suggest_cb_cls.

Referenced by run().

572 {
574 
576  sh->cfg = cfg;
577  sh->suggest_cb = suggest_cb;
580  sh->session_array_size,
581  4);
582  reconnect (sh);
583  return sh;
584 }
struct GNUNET_ATS_AddressRecord ** session_array
Array of session objects (we need to translate them to numbers and back for the protocol; the offset ...
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
Handle to the ATS subsystem for bandwidth/transport scheduling information.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
GNUNET_ATS_AddressSuggestionCallback suggest_cb
Callback to invoke on suggestions.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
void * suggest_cb_cls
Closure for suggest_cb.
static struct SolverHandle * sh
unsigned int session_array_size
Size of the session_array.
static void reconnect(struct GNUNET_ATS_SchedulingHandle *sh)
Re-establish the connection to the ATS service.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ATS_scheduling_done()

void GNUNET_ATS_scheduling_done ( struct GNUNET_ATS_SchedulingHandle sh)

Client is done with ATS scheduling, release resources.

Parameters
shhandle to release

Definition at line 593 of file ats_api_scheduling.c.

References GNUNET_ATS_AddressRecord::address, GNUNET_array_grow, GNUNET_free, GNUNET_HELLO_address_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), GNUNET_ATS_SchedulingHandle::mq, GNUNET_ATS_SchedulingHandle::session_array, GNUNET_ATS_SchedulingHandle::session_array_size, and GNUNET_ATS_SchedulingHandle::task.

Referenced by shutdown_task().

594 {
595  struct GNUNET_ATS_AddressRecord *ar;
596  unsigned int i;
597 
598  if (NULL != sh->mq)
599  {
600  GNUNET_MQ_destroy (sh->mq);
601  sh->mq = NULL;
602  }
603  if (NULL != sh->task)
604  {
606  sh->task = NULL;
607  }
608  for (i = 0; i < sh->session_array_size; i++)
609  {
610  if (NULL != (ar = sh->session_array[i]))
611  {
613  GNUNET_free (ar);
614  sh->session_array[i] = NULL;
615  }
616  }
618  sh->session_array_size,
619  0);
620  GNUNET_free (sh);
621 }
struct GNUNET_SCHEDULER_Task * task
Task to trigger reconnect.
struct GNUNET_ATS_AddressRecord ** session_array
Array of session objects (we need to translate them to numbers and back for the protocol; the offset ...
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
unsigned int session_array_size
Size of the session_array.
Information we track per address, incoming or outgoing.
struct GNUNET_MQ_Handle * mq
Message queue for sending requests to the ATS service.
struct GNUNET_HELLO_Address * address
Address data.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#define GNUNET_HELLO_address_free(addr)
Free an address.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ATS_address_add()

struct GNUNET_ATS_AddressRecord* GNUNET_ATS_address_add ( struct GNUNET_ATS_SchedulingHandle sh,
const struct GNUNET_HELLO_Address address,
struct GNUNET_ATS_Session session,
const struct GNUNET_ATS_Properties prop 
)

We have a new address ATS should know.

Addresses have to be added with this function before they can be: updated, set in use and destroyed

Parameters
shhandle
addressthe address
sessionsession handle (if available, i.e. for incoming connections)
propperformance data for the address
Returns
handle to the address representation inside ATS, NULL on error (i.e. ATS knows this exact address already, or address is invalid)

Addresses have to be added with this function before they can be: updated, set in use and destroyed.

Parameters
shhandle
addressthe address
sessionsession handle, can be NULL
propperformance data for the address
Returns
handle to the address representation inside ATS, NULL on error (i.e. ATS knows this exact address already)

Definition at line 637 of file ats_api_scheduling.c.

References GNUNET_ATS_AddressRecord::address, GNUNET_HELLO_Address::address_length, find_empty_session_slot(), find_session_id(), GNUNET_ATS_properties_hton(), GNUNET_break, GNUNET_HELLO_address_copy(), GNUNET_MAX_MESSAGE_SIZE, GNUNET_new, GNUNET_NT_UNSPECIFIED, NOT_FOUND, GNUNET_ATS_AddressRecord::properties, GNUNET_ATS_Properties::scope, send_add_address_message(), GNUNET_ATS_AddressRecord::session, GNUNET_ATS_SchedulingHandle::session_array, GNUNET_ATS_AddressRecord::sh, GNUNET_ATS_AddressRecord::slot, and GNUNET_HELLO_Address::transport_name.

Referenced by GST_ats_add_address(), GST_ats_add_inbound_address(), and unblock_address().

641 {
642  struct GNUNET_ATS_AddressRecord *ar;
643  size_t namelen;
644  size_t msize;
645  uint32_t s;
646 
647  if (NULL == address)
648  {
649  /* we need a valid address */
650  GNUNET_break (0);
651  return NULL;
652  }
654  namelen = strlen (address->transport_name) + 1;
655  msize = address->address_length + namelen;
656  if ((msize + sizeof(struct AddressUpdateMessage) >=
658  (address->address_length >= GNUNET_MAX_MESSAGE_SIZE) ||
659  (namelen >= GNUNET_MAX_MESSAGE_SIZE))
660  {
661  /* address too large for us, this should not happen */
662  GNUNET_break (0);
663  return NULL;
664  }
665 
666  if (NOT_FOUND !=
667  find_session_id (sh,
668  session,
669  address))
670  {
671  /* Already existing, nothing todo, but this should not happen */
672  GNUNET_break (0);
673  return NULL;
674  }
675  s = find_empty_session_slot (sh);
676  ar = GNUNET_new (struct GNUNET_ATS_AddressRecord);
677  ar->sh = sh;
678  ar->slot = s;
679  ar->session = session;
680  ar->address = GNUNET_HELLO_address_copy (address);
682  prop);
683  sh->session_array[s] = ar;
684  send_add_address_message (sh, ar);
685  return ar;
686 }
size_t address_length
Number of bytes in address.
static void send_add_address_message(struct GNUNET_ATS_SchedulingHandle *sh, const struct GNUNET_ATS_AddressRecord *ar)
Generate and transmit the struct AddressAddMessage for the given address record.
struct GNUNET_ATS_AddressRecord ** session_array
Array of session objects (we need to translate them to numbers and back for the protocol; the offset ...
void GNUNET_ATS_properties_hton(struct GNUNET_ATS_PropertiesNBO *nbo, const struct GNUNET_ATS_Properties *hbo)
Convert ATS properties from host to network byte order.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Message used to notify ATS that the performance characteristics for an address have changed...
Definition: ats.h:161
struct GNUNET_ATS_Session * session
Session handle.
static uint32_t find_empty_session_slot(struct GNUNET_ATS_SchedulingHandle *sh)
Get an available session ID.
#define NOT_FOUND
Session ID we use if there is no session / slot.
static struct SolverHandle * sh
const char * transport_name
Name of the transport plugin enabling the communication using this address.
Information we track per address, incoming or outgoing.
struct GNUNET_ATS_PropertiesNBO properties
Performance data about the address.
struct GNUNET_ATS_SchedulingHandle * sh
Scheduling handle this address record belongs to.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
enum GNUNET_NetworkType scope
Which network scope does the respective address belong to? This property does not change...
struct GNUNET_HELLO_Address * address
Address data.
struct GNUNET_HELLO_Address * GNUNET_HELLO_address_copy(const struct GNUNET_HELLO_Address *address)
Copy an address struct.
Definition: address.c:109
static uint32_t find_session_id(struct GNUNET_ATS_SchedulingHandle *sh, struct GNUNET_ATS_Session *session, const struct GNUNET_HELLO_Address *address)
Get the ID for the given session object.
uint32_t slot
Which slot (index) in the session array does this record correspond to? FIXME: a linear search on thi...
Category of last resort.
Definition: gnunet_nt_lib.h:40
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ATS_address_add_session()

void GNUNET_ATS_address_add_session ( struct GNUNET_ATS_AddressRecord ar,
struct GNUNET_ATS_Session session 
)

An address was used to initiate a session.

Parameters
araddress record to update information for
sessionsession handle

Definition at line 696 of file ats_api_scheduling.c.

References GNUNET_break, and GNUNET_ATS_AddressRecord::session.

Referenced by GST_ats_new_session().

698 {
699  GNUNET_break (NULL == ar->session);
700  ar->session = session;
701 }
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_ATS_Session * session
Session handle.
Here is the caller graph for this function:

◆ GNUNET_ATS_address_del_session()

int GNUNET_ATS_address_del_session ( struct GNUNET_ATS_AddressRecord ar,
struct GNUNET_ATS_Session session 
)

A session was destroyed, disassociate it from the given address record.

If this was an incoming addess, destroys the address as well.

Parameters
araddress record to update information for
sessionsession handle
Returns
GNUNET_YES if the ar was destroyed because it was an incoming address, GNUNET_NO if the was kept because we can use it still to establish a new session

A session was destroyed, disassociate it from the given address record.

If this was an incoming addess, destroy the address as well.

Parameters
araddress record to update information for
sessionsession handle
Returns
GNUNET_YES if the ar was destroyed because it was an incoming address, GNUNET_NO if the was kept because we can use it still to establish a new session

Definition at line 717 of file ats_api_scheduling.c.

References GNUNET_ATS_AddressRecord::address, GNUNET_assert, GNUNET_ATS_address_destroy(), GNUNET_HELLO_address_check_option(), GNUNET_HELLO_ADDRESS_INFO_INBOUND, GNUNET_NO, GNUNET_YES, and GNUNET_ATS_AddressRecord::session.

Referenced by GST_ats_block_address(), and GST_ats_del_session().

719 {
720  GNUNET_assert (session == ar->session);
721  ar->session = NULL;
724  {
726  return GNUNET_YES;
727  }
728  return GNUNET_NO;
729 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_NO
Definition: gnunet_common.h:78
struct GNUNET_ATS_Session * session
Session handle.
int GNUNET_HELLO_address_check_option(const struct GNUNET_HELLO_Address *address, enum GNUNET_HELLO_AddressInfo option)
Check if an address has a local option set.
Definition: address.c:39
This is an inbound address and cannot be used to initiate an outbound connection to another peer...
struct GNUNET_HELLO_Address * address
Address data.
void GNUNET_ATS_address_destroy(struct GNUNET_ATS_AddressRecord *ar)
An address got destroyed, stop using it as a valid address.
#define GNUNET_YES
Definition: gnunet_common.h:77
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ATS_address_update()

void GNUNET_ATS_address_update ( struct GNUNET_ATS_AddressRecord ar,
const struct GNUNET_ATS_Properties prop 
)

We have updated performance statistics for a given address.

Note that this function can be called for addresses that are currently in use as well as addresses that are valid but not actively in use. Furthermore, the peer may not even be connected to us right now (session value of NULL used to signal disconnect, or somehow we otherwise got updated on ats information). Based on the information provided, ATS may update bandwidth assignments and suggest to switch addresses.

Parameters
araddress record to update information for
propperformance data for the address

Note that this function can be called for addresses that are currently in use as well as addresses that are valid but not actively in use. Furthermore, the peer may not even be connected to us right now (in which case the call may be ignored or the information may be stored for later use). Update bandwidth assignments.

Parameters
araddress record to update information for
propperformance data for the address

Definition at line 744 of file ats_api_scheduling.c.

References GNUNET_ATS_AddressRecord::address, GNUNET_ATS_properties_hton(), GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_NT_UNSPECIFIED, LOG, m, GNUNET_ATS_SchedulingHandle::mq, AddressUpdateMessage::peer, GNUNET_HELLO_Address::peer, GNUNET_ATS_AddressRecord::properties, AddressUpdateMessage::properties, GNUNET_ATS_Properties::scope, GNUNET_ATS_AddressRecord::session, AddressUpdateMessage::session_id, GNUNET_ATS_AddressRecord::sh, GNUNET_ATS_AddressRecord::slot, and GNUNET_HELLO_Address::transport_name.

Referenced by GST_ats_update_delay(), GST_ats_update_distance(), and GST_ats_update_utilization().

746 {
747  struct GNUNET_ATS_SchedulingHandle *sh = ar->sh;
748  struct GNUNET_MQ_Envelope *ev;
749  struct AddressUpdateMessage *m;
750 
752  "Updating address for peer `%s', plugin `%s', session %p slot %u\n",
753  GNUNET_i2s (&ar->address->peer),
754  ar->address->transport_name,
755  ar->session,
756  ar->slot);
759  prop);
760  if (NULL == sh->mq)
761  return; /* disconnected, skip for now */
763  m->session_id = htonl (ar->slot);
764  m->peer = ar->address->peer;
765  m->properties = ar->properties;
766  GNUNET_MQ_send (sh->mq,
767  ev);
768 }
struct GNUNET_PeerIdentity peer
Which peer is this about? (Technically redundant, as the session_id should be sufficient, but enables ATS service to find the session faster).
Definition: ats.h:178
Handle to the ATS subsystem for bandwidth/transport scheduling information.
void GNUNET_ATS_properties_hton(struct GNUNET_ATS_PropertiesNBO *nbo, const struct GNUNET_ATS_Properties *hbo)
Convert ATS properties from host to network byte order.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define LOG(kind,...)
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Message used to notify ATS that the performance characteristics for an address have changed...
Definition: ats.h:161
struct GNUNET_ATS_Session * session
Session handle.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
static struct SolverHandle * sh
const char * transport_name
Name of the transport plugin enabling the communication using this address.
struct GNUNET_ATS_PropertiesNBO properties
Performance data about the address.
struct GNUNET_PeerIdentity peer
For which peer is this an address?
struct GNUNET_ATS_SchedulingHandle * sh
Scheduling handle this address record belongs to.
enum GNUNET_NetworkType scope
Which network scope does the respective address belong to? This property does not change...
struct GNUNET_MQ_Handle * mq
Message queue for sending requests to the ATS service.
struct GNUNET_HELLO_Address * address
Address data.
struct GNUNET_ATS_PropertiesNBO properties
Performance properties of the address.
Definition: ats.h:183
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
uint32_t slot
Which slot (index) in the session array does this record correspond to? FIXME: a linear search on thi...
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
uint32_t session_id
Internal number this client uses to refer to this address.
Definition: ats.h:171
#define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE
Type of the &#39;struct AddressUpdateMessage&#39; sent by clients to ATS to inform ATS about performance chan...
Category of last resort.
Definition: gnunet_nt_lib.h:40
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ATS_address_destroy()

void GNUNET_ATS_address_destroy ( struct GNUNET_ATS_AddressRecord ar)

An address got destroyed, stop using it as a valid address.

Parameters
araddress record to destroy, it's validation has expired and ATS may no longer use it
araddress to destroy

Definition at line 777 of file ats_api_scheduling.c.

References GNUNET_ATS_AddressRecord::address, GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_YES, GNUNET_ATS_AddressRecord::in_destroy, LOG, m, GNUNET_ATS_SchedulingHandle::mq, AddressDestroyedMessage::peer, GNUNET_HELLO_Address::peer, GNUNET_ATS_AddressRecord::session, AddressDestroyedMessage::session_id, GNUNET_ATS_AddressRecord::sh, GNUNET_ATS_AddressRecord::slot, and GNUNET_HELLO_Address::transport_name.

Referenced by destroy_ai(), GNUNET_ATS_address_del_session(), GST_ats_block_address(), and GST_ats_del_session().

778 {
779  struct GNUNET_ATS_SchedulingHandle *sh = ar->sh;
780  struct GNUNET_MQ_Envelope *ev;
781  struct AddressDestroyedMessage *m;
782 
784  "Deleting address for peer `%s', plugin `%s', slot %u session %p\n",
785  GNUNET_i2s (&ar->address->peer),
786  ar->address->transport_name,
787  ar->slot,
788  ar->session);
789  GNUNET_break (NULL == ar->session);
790  ar->session = NULL;
791  ar->in_destroy = GNUNET_YES;
792  if (NULL == sh->mq)
793  return;
795  m->session_id = htonl (ar->slot);
796  m->peer = ar->address->peer;
797  GNUNET_MQ_send (sh->mq, ev);
798 }
#define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED
Type of the &#39;struct AddressDestroyedMessage&#39; sent by clients to ATS to inform ATS about an address be...
Handle to the ATS subsystem for bandwidth/transport scheduling information.
struct GNUNET_PeerIdentity peer
Which peer is this about? (Technically redundant, as the session_id should be sufficient, but enables ATS service to find the session faster).
Definition: ats.h:209
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
uint32_t session_id
Internal number this client uses to refer to this address.
Definition: ats.h:202
#define LOG(kind,...)
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
struct GNUNET_ATS_Session * session
Session handle.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
static struct SolverHandle * sh
const char * transport_name
Name of the transport plugin enabling the communication using this address.
struct GNUNET_PeerIdentity peer
For which peer is this an address?
struct GNUNET_ATS_SchedulingHandle * sh
Scheduling handle this address record belongs to.
struct GNUNET_MQ_Handle * mq
Message queue for sending requests to the ATS service.
struct GNUNET_HELLO_Address * address
Address data.
#define GNUNET_YES
Definition: gnunet_common.h:77
int in_destroy
We&#39;re about to destroy this address record, just ATS does not know this yet.
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
Message sent by ATS client to ATS service when an address was destroyed and must thus henceforth no l...
Definition: ats.h:192
uint32_t slot
Which slot (index) in the session array does this record correspond to? FIXME: a linear search on thi...
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ATS_performance_init()

struct GNUNET_ATS_PerformanceHandle* GNUNET_ATS_performance_init ( const struct GNUNET_CONFIGURATION_Handle cfg,
GNUNET_ATS_AddressInformationCallback  addr_info_cb,
void *  addr_info_cb_cls 
)

Get handle to access performance API of the ATS subsystem.

Parameters
cfgconfiguration to use
addr_info_cbcallback called when performance characteristics for an address change
addr_info_cb_clsclosure for addr_info_cb
Returns
ats performance context

Definition at line 613 of file ats_api_performance.c.

References GNUNET_ATS_PerformanceHandle::addr_info_cb, addr_info_cb(), GNUNET_ATS_PerformanceHandle::addr_info_cb_cls, cfg, GNUNET_ATS_PerformanceHandle::cfg, GNUNET_free, GNUNET_new, GNUNET_ATS_PerformanceHandle::mq, ph, and reconnect().

Referenced by ats_perf_connect_adapter(), and run().

616 {
618 
620  ph->cfg = cfg;
623  reconnect (ph);
624  if (NULL == ph->mq)
625  {
626  GNUNET_free (ph);
627  return NULL;
628  }
629  return ph;
630 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static struct GNUNET_ATS_PerformanceHandle * ph
ATS performance handle used.
Definition: gnunet-ats.c:116
struct GNUNET_MQ_Handle * mq
Connection to ATS service.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
static void addr_info_cb(void *cls, const struct GNUNET_HELLO_Address *address, int address_active, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in, const struct GNUNET_ATS_Properties *prop)
Signature of a function that is called with QoS information about an address.
GNUNET_ATS_AddressInformationCallback addr_info_cb
Callback to invoke when an address has performance changes.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
ATS Handle to obtain and/or modify performance information.
static void reconnect(struct GNUNET_ATS_PerformanceHandle *ph)
Re-establish the connection to the ATS service.
void * addr_info_cb_cls
Closure for addr_info_cb.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ATS_performance_list_addresses()

struct GNUNET_ATS_AddressListHandle* GNUNET_ATS_performance_list_addresses ( struct GNUNET_ATS_PerformanceHandle ph,
const struct GNUNET_PeerIdentity peer,
int  all,
GNUNET_ATS_AddressInformationCallback  infocb,
void *  infocb_cls 
)

Get information about addresses known to the ATS subsystem.

Parameters
phthe performance handle to use
peerpeer idm can be NULL for all peers
allGNUNET_YES to get information about all addresses or GNUNET_NO to get only address currently used
infocbcallback to call with the addresses, will callback with address == NULL when done
infocb_clsclosure for infocb
Returns
handle to abort the operation
Parameters
phthe performance handle to use
peerpeer idm can be NULL for all peers
allGNUNET_YES to get information about all addresses or GNUNET_NO to get only address currently used
infocbcallback to call with the addresses, will callback with address == NULL when done
infocb_clsclosure for infocb
Returns
ats performance context

Definition at line 746 of file ats_api_performance.c.

References GNUNET_ATS_PerformanceHandle::addresslist_head, GNUNET_ATS_PerformanceHandle::addresslist_tail, alh, AddressListRequestMessage::all, GNUNET_ATS_AddressListHandle::all_addresses, GNUNET_ATS_AddressListHandle::all_peers, GNUNET_ATS_AddressListHandle::cb, GNUNET_ATS_AddressListHandle::cb_cls, env, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new, GNUNET_NO, GNUNET_YES, GNUNET_ATS_AddressListHandle::id, GNUNET_ATS_PerformanceHandle::id, AddressListRequestMessage::id, m, GNUNET_ATS_PerformanceHandle::mq, GNUNET_ATS_ReservationContext::peer, GNUNET_ATS_AddressListHandle::peer, AddressListRequestMessage::peer, GNUNET_ATS_AddressListHandle::ph, and ph.

Referenced by run().

752 {
754  struct GNUNET_MQ_Envelope *env;
756 
757  if (NULL == ph->mq)
758  return NULL;
759  if (NULL == infocb)
760  {
761  GNUNET_break (0);
762  return NULL;
763  }
765  alh->id = ph->id++;
766  alh->cb = infocb;
767  alh->cb_cls = infocb_cls;
768  alh->ph = ph;
769  alh->all_addresses = all;
770  if (NULL == peer)
771  {
772  alh->all_peers = GNUNET_YES;
773  }
774  else
775  {
776  alh->all_peers = GNUNET_NO;
777  alh->peer = *peer;
778  }
780  ph->addresslist_tail,
781  alh);
782  env = GNUNET_MQ_msg (m,
784  m->all = htonl (all);
785  m->id = htonl (alh->id);
786  if (NULL != peer)
787  m->peer = *peer;
788  GNUNET_MQ_send (ph->mq,
789  env);
790  return alh;
791 }
struct GNUNET_ATS_AddressListHandle * addresslist_tail
Tail of linked list of pending address list requests.
uint32_t id
Request multiplexing.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
int all_addresses
Return all or used address only.
struct GNUNET_ATS_AddressListHandle * addresslist_head
Head of linked list of pending address list requests.
static struct GNUNET_ATS_PerformanceHandle * ph
ATS performance handle used.
Definition: gnunet-ats.c:116
int all_peers
Return all or specific peer only.
struct GNUNET_MQ_Handle * mq
Connection to ATS service.
uint32_t id
ID used to match replies to this request.
Definition: ats.h:351
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_NO
Definition: gnunet_common.h:78
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Linked list of pending reservations.
GNUNET_ATS_AddressInformationCallback cb
Callback.
#define GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST
Type of the &#39;struct AddressListRequestMessage&#39; sent by client to ATS to request information about add...
static struct GNUNET_ATS_AddressListHandle * alh
ATS address list handle used.
Definition: gnunet-ats.c:131
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
void * cb_cls
Callback closure for cb.
struct GNUNET_ATS_PerformanceHandle * ph
Performance handle.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
Client to service: please give us an overview of the addresses.
Definition: ats.h:341
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
uint32_t id
Request multiplexing.
int32_t all
GNUNET_YES to get information about all addresses, GNUNET_NO to only return addresses that are in use...
Definition: ats.h:362
#define GNUNET_YES
Definition: gnunet_common.h:77
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
struct GNUNET_PeerIdentity peer
Which peer do we care about? All zeros for all.
Definition: ats.h:356
struct GNUNET_PeerIdentity peer
Target peer.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ATS_performance_list_addresses_cancel()

void GNUNET_ATS_performance_list_addresses_cancel ( struct GNUNET_ATS_AddressListHandle alh)

Cancel a pending address listing operation.

Parameters
alhthe struct GNUNET_ATS_AddressListHandle handle to cancel
alhthe handle of the request to cancel

Definition at line 800 of file ats_api_performance.c.

References GNUNET_ATS_PerformanceHandle::addresslist_head, GNUNET_ATS_PerformanceHandle::addresslist_tail, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_ATS_AddressListHandle::ph, and ph.

Referenced by end().

802 {
803  struct GNUNET_ATS_PerformanceHandle *ph = alh->ph;
804 
806  ph->addresslist_tail,
807  alh);
808  GNUNET_free (alh);
809 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_ATS_AddressListHandle * addresslist_tail
Tail of linked list of pending address list requests.
struct GNUNET_ATS_AddressListHandle * addresslist_head
Head of linked list of pending address list requests.
static struct GNUNET_ATS_PerformanceHandle * ph
ATS performance handle used.
Definition: gnunet-ats.c:116
struct GNUNET_ATS_PerformanceHandle * ph
Performance handle.
ATS Handle to obtain and/or modify performance information.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ GNUNET_ATS_performance_done()

void GNUNET_ATS_performance_done ( struct GNUNET_ATS_PerformanceHandle ph)

Client is done using the ATS performance subsystem, release resources.

Parameters
phhandle

Definition at line 639 of file ats_api_performance.c.

References GNUNET_ATS_PerformanceHandle::addresslist_head, GNUNET_ATS_PerformanceHandle::addresslist_tail, alh, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), GNUNET_ATS_PerformanceHandle::mq, GNUNET_ATS_ReservationContext::rcb, GNUNET_ATS_PerformanceHandle::reservation_head, GNUNET_ATS_PerformanceHandle::reservation_tail, and GNUNET_ATS_PerformanceHandle::task.

Referenced by ats_perf_disconnect_adapter(), do_shutdown(), end(), and shutdown_task().

640 {
643 
644  while (NULL != (alh = ph->addresslist_head))
645  {
647  ph->addresslist_tail,
648  alh);
649  GNUNET_free (alh);
650  }
651  while (NULL != (rc = ph->reservation_head))
652  {
654  ph->reservation_tail,
655  rc);
656  GNUNET_break (NULL == rc->rcb);
657  GNUNET_free (rc);
658  }
659  if (NULL != ph->task)
660  {
662  ph->task = NULL;
663  }
664  if (NULL != ph->mq)
665  {
666  GNUNET_MQ_destroy (ph->mq);
667  ph->mq = NULL;
668  }
669  GNUNET_free (ph);
670 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_ATS_AddressListHandle * addresslist_tail
Tail of linked list of pending address list requests.
struct GNUNET_ATS_ReservationContext * reservation_tail
Tail of linked list of pending reservation requests.
struct GNUNET_ATS_AddressListHandle * addresslist_head
Head of linked list of pending address list requests.
GNUNET_ATS_ReservationCallback rcb
Function to call on result.
struct GNUNET_ATS_ReservationContext * reservation_head
Head of linked list of pending reservation requests.
struct GNUNET_MQ_Handle * mq
Connection to ATS service.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Linked list of pending reservations.
static struct GNUNET_ATS_AddressListHandle * alh
ATS address list handle used.
Definition: gnunet-ats.c:131
struct GNUNET_SCHEDULER_Task * task
Task to trigger reconnect.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:824
#define GNUNET_free(ptr)
Wrapper around free.
Linked list of pending reservations.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:966
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ATS_reserve_bandwidth()

struct GNUNET_ATS_ReservationContext* GNUNET_ATS_reserve_bandwidth ( struct GNUNET_ATS_PerformanceHandle ph,
const struct GNUNET_PeerIdentity peer,
int32_t  amount,
GNUNET_ATS_ReservationCallback  rcb,
void *  rcb_cls 
)

Reserve inbound bandwidth from the given peer.

ATS will look at the current amount of traffic we receive from the peer and ensure that the peer could add 'amount' of data to its stream.

Parameters
phperformance handle
peeridentifies the peer
amountreserve N bytes for receiving, negative amounts can be used to undo a (recent) reservation;
rcbfunction to call with the resulting reservation information
rcb_clsclosure for rcb
Returns
NULL on error
Deprecated:
will be replaced soon

ATS will look at the current amount of traffic we receive from the peer and ensure that the peer could add amount of data to its stream.

Parameters
phperformance handle
peeridentifies the peer
amountreserve N bytes for receiving, negative amounts can be used to undo a (recent) reservation;
rcbfunction to call with the resulting reservation information
rcb_clsclosure for rcb
Returns
NULL on error
Deprecated:
will be replaced soon

Definition at line 688 of file ats_api_performance.c.

References ReservationRequestMessage::amount, env, GNUNET_CONTAINER_DLL_insert_tail, GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_new, GNUNET_YES, m, GNUNET_ATS_PerformanceHandle::mq, GNUNET_ATS_ReservationContext::peer, ReservationRequestMessage::peer, GNUNET_ATS_ReservationContext::rcb, GNUNET_ATS_ReservationContext::rcb_cls, GNUNET_ATS_PerformanceHandle::reservation_head, GNUNET_ATS_PerformanceHandle::reservation_tail, GNUNET_ATS_ReservationContext::size, and GNUNET_ATS_ReservationContext::undo.

Referenced by GSF_peer_connect_handler(), handle_reservation_result(), retry_reservation(), and schedule_transmission().

693 {
695  struct GNUNET_MQ_Envelope *env;
697 
698  if (NULL == ph->mq)
699  return NULL;
701  rc->size = amount;
702  rc->peer = *peer;
703  rc->rcb = rcb;
704  rc->rcb_cls = rcb_cls;
705  if ((NULL != rcb) &&
706  (amount > 0))
707  rc->undo = GNUNET_YES;
709  ph->reservation_tail,
710  rc);
711  env = GNUNET_MQ_msg (m,
713  m->amount = htonl (amount);
714  m->peer = *peer;
715  GNUNET_MQ_send (ph->mq,
716  env);
717  return rc;
718 }
struct GNUNET_ATS_ReservationContext * reservation_tail
Tail of linked list of pending reservation requests.
struct GNUNET_ATS_ReservationContext * reservation_head
Head of linked list of pending reservation requests.
GNUNET_ATS_ReservationCallback rcb
Function to call on result.
struct GNUNET_MQ_Handle * mq
Connection to ATS service.
void * rcb_cls
Closure for rcb.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_new(type)
Allocate a struct or union of the given type.
int undo
Do we need to undo this reservation if it succeeded? Set to GNUNET_YES if a reservation is cancelled...
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
struct GNUNET_PeerIdentity peer
Target peer.
#define GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST
Type of the &#39;struct ReservationRequestMessage&#39; sent by clients to ATS to ask for inbound bandwidth re...
int32_t size
Desired reservation.
#define GNUNET_YES
Definition: gnunet_common.h:77
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
struct GNUNET_PeerIdentity peer
Definition: ats.h:384
Linked list of pending reservations.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ATS_reserve_bandwidth_cancel()

void GNUNET_ATS_reserve_bandwidth_cancel ( struct GNUNET_ATS_ReservationContext rc)

Cancel request for reserving bandwidth.

Parameters
rccontext returned by the original GNUNET_ATS_reserve_bandwidth call
rccontext returned by the original GNUNET_ATS_reserve_bandwidth() call

Definition at line 727 of file ats_api_performance.c.

References GNUNET_ATS_ReservationContext::rcb.

Referenced by GSF_peer_disconnect_handler().

728 {
729  rc->rcb = NULL;
730 }
GNUNET_ATS_ReservationCallback rcb
Function to call on result.
Here is the caller graph for this function:

◆ GNUNET_ATS_print_preference_type()

const char* GNUNET_ATS_print_preference_type ( enum GNUNET_ATS_PreferenceKind  type)

Convert a GNUNET_ATS_PreferenceType to a string.

Parameters
typethe preference type
Returns
a string or NULL if invalid

Convert a GNUNET_ATS_PreferenceType to a string.

Parameters
typethe preference type
Returns
a string or NULL if invalid

Definition at line 819 of file ats_api_performance.c.

References GNUNET_ATS_PREFERENCE_END, GNUNET_ATS_PreferenceTypeString, and type.

Referenced by GNUNET_ATS_solver_generate_preferences_start(), GNUNET_ATS_solver_generate_preferences_stop(), GNUNET_ATS_solver_logging_eval(), GNUNET_ATS_solver_logging_now(), load_op_start_set_preference(), load_op_stop_set_preference(), recalculate_relative_preferences(), set_feedback_task(), set_pref_task(), update_preference(), update_rel_sum(), and update_relative_values_for_peer().

820 {
821  const char *prefs[] = GNUNET_ATS_PreferenceTypeString;
822 
824  return prefs[type];
825  return NULL;
826 }
End of preference list.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
#define GNUNET_ATS_PreferenceTypeString
ATS preference types as string array initializer.
Here is the caller graph for this function:

◆ GNUNET_ATS_performance_change_preference()

void GNUNET_ATS_performance_change_preference ( struct GNUNET_ATS_PerformanceHandle ph,
const struct GNUNET_PeerIdentity peer,
  ... 
)

Change preferences for the given peer.

Preference changes are forgotten if peers disconnect.

Parameters
phperformance handle
peeridentifies the peer
...GNUNET_ATS_PREFERENCE_END-terminated specification of the desired changes

Definition at line 838 of file ats_api_performance.c.

References env, GNUNET_assert, GNUNET_ATS_PREFERENCE_BANDWIDTH, GNUNET_ATS_PREFERENCE_END, GNUNET_ATS_PREFERENCE_LATENCY, GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_VA_ARG_ENUM, m, GNUNET_ATS_PerformanceHandle::mq, ChangePreferenceMessage::num_preferences, GNUNET_ATS_ReservationContext::peer, ChangePreferenceMessage::peer, pi, PreferenceInformation::preference_kind, and PreferenceInformation::preference_value.

Referenced by run(), schedule_transmission(), and set_pref_task().

843 {
844  struct GNUNET_MQ_Envelope *env;
845  struct ChangePreferenceMessage *m;
846  uint32_t count;
847  struct PreferenceInformation *pi;
848  va_list ap;
849  enum GNUNET_ATS_PreferenceKind kind;
850 
851  if (NULL == ph->mq)
852  return;
853  count = 0;
854  va_start (ap, peer);
855  while (GNUNET_ATS_PREFERENCE_END !=
857  {
858  switch (kind)
859  {
861  count++;
862  (void) va_arg (ap, double);
863  break;
864 
866  count++;
867  (void) va_arg (ap, double);
868  break;
869 
870  default:
871  GNUNET_assert (0);
872  }
873  }
874  va_end (ap);
875  env = GNUNET_MQ_msg_extra (m,
876  count * sizeof(struct PreferenceInformation),
878  m->num_preferences = htonl (count);
879  m->peer = *peer;
880  pi = (struct PreferenceInformation *) &m[1];
881  count = 0;
882  va_start (ap, peer);
883  while (GNUNET_ATS_PREFERENCE_END != (kind =
884  GNUNET_VA_ARG_ENUM (ap,
886  {
887  pi[count].preference_kind = htonl (kind);
888  switch (kind)
889  {
891  pi[count].preference_value = (float) va_arg (ap, double);
892 
893  count++;
894  break;
895 
897  pi[count].preference_value = (float) va_arg (ap, double);
898 
899  count++;
900  break;
901 
902  default:
903  GNUNET_assert (0);
904  }
905  }
906  va_end (ap);
907  GNUNET_MQ_send (ph->mq,
908  env);
909 }
struct GNUNET_PeerIdentity peer
Which peer is the preference being expressed for?
Definition: ats.h:453
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_MQ_Handle * mq
Connection to ATS service.
uint32_t preference_kind
An enum GNUNET_ATS_PreferenceKind in NBO.
Definition: ats.h:424
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
End of preference list.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
uint32_t num_preferences
How many struct PreferenceInformation entries follow this struct?
Definition: ats.h:448
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
Change the peer&#39;s latency value to the given amount.
#define GNUNET_VA_ARG_ENUM(va, X)
wrap va_arg for enums
Change the peer&#39;s bandwidth value (value per byte of bandwidth in the goal function) to the given amo...
Variable-size entry in a struct ChangePreferenceMessage or struct FeedbackPreferenceMessage.
Definition: ats.h:419
Client to ATS: I have a performance preference for a peer.
Definition: ats.h:437
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
GNUNET_ATS_PreferenceKind
Enum defining all known preference categories.
float preference_value
Degree of preference (or appreciation) for this preference_kind being expressed.
Definition: ats.h:430
#define GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE
Type of the &#39;struct ChangePreferenceMessage&#39; sent by clients to ATS to ask for allocation preference ...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ATS_performance_give_feedback()

void GNUNET_ATS_performance_give_feedback ( struct GNUNET_ATS_PerformanceHandle ph,
const struct GNUNET_PeerIdentity peer,
const struct GNUNET_TIME_Relative  scope,
  ... 
)

Application feedback on how good preference requirements are fulfilled for the preferences included in the given time scope [now - scope .

. now]

An application notifies ATS if (and only if) it has feedback information for specific properties. This values are valid until the feedback scores are updated by the application.

If the application has no feedback for this preference kind the application will not explicitly call for this property and will not include it in this function call.

Parameters
phperformance handle
scopethe time interval this valid for: [now - scope .. now]
peeridentifies the peer
...GNUNET_ATS_PREFERENCE_END-terminated specification of the desired changes

Application feedback on how good preference requirements are fulfilled for the preferences included in the given time scope [now - scope .

Parameters
phperformance handle
scopethe time interval this valid for: [now - scope .. now]
peeridentifies the peer
...GNUNET_ATS_PREFERENCE_END-terminated specification of the desired changes

Definition at line 922 of file ats_api_performance.c.

References env, GNUNET_assert, GNUNET_ATS_PREFERENCE_BANDWIDTH, GNUNET_ATS_PREFERENCE_END, GNUNET_ATS_PREFERENCE_LATENCY, GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), GNUNET_TIME_relative_hton(), GNUNET_VA_ARG_ENUM, m, GNUNET_ATS_PerformanceHandle::mq, FeedbackPreferenceMessage::num_feedback, GNUNET_ATS_ReservationContext::peer, FeedbackPreferenceMessage::peer, pi, PreferenceInformation::preference_kind, PreferenceInformation::preference_value, and FeedbackPreferenceMessage::scope.

926 {
927  struct GNUNET_MQ_Envelope *env;
929  uint32_t count;
930  struct PreferenceInformation *pi;
931  va_list ap;
932  enum GNUNET_ATS_PreferenceKind kind;
933 
934  if (NULL == ph->mq)
935  return;
936  count = 0;
937  va_start (ap, scope);
938  while (GNUNET_ATS_PREFERENCE_END !=
940  {
941  switch (kind)
942  {
944  count++;
945  (void) va_arg (ap, double);
946  break;
947 
949  count++;
950  (void) va_arg (ap, double);
951  break;
952 
953  default:
954  GNUNET_assert (0);
955  }
956  }
957  va_end (ap);
958  env = GNUNET_MQ_msg_extra (m,
959  count * sizeof(struct PreferenceInformation),
961  m->scope = GNUNET_TIME_relative_hton (scope);
962  m->num_feedback = htonl (count);
963  m->peer = *peer;
964  pi = (struct PreferenceInformation *) &m[1];
965  count = 0;
966  va_start (ap, scope);
967  while (GNUNET_ATS_PREFERENCE_END != (kind =
968  GNUNET_VA_ARG_ENUM (ap,
970  {
971  pi[count].preference_kind = htonl (kind);
972  switch (kind)
973  {
975  pi[count].preference_value = (float) va_arg (ap, double);
976 
977  count++;
978  break;
979 
981  pi[count].preference_value = (float) va_arg (ap, double);
982 
983  count++;
984  break;
985 
986  default:
987  GNUNET_assert (0);
988  }
989  }
990  va_end (ap);
991  GNUNET_MQ_send (ph->mq,
992  env);
993 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_MQ_Handle * mq
Connection to ATS service.
uint32_t preference_kind
An enum GNUNET_ATS_PreferenceKind in NBO.
Definition: ats.h:424
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
uint32_t num_feedback
Number of feedback values included.
Definition: ats.h:473
End of preference list.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
struct GNUNET_PeerIdentity peer
Peer this feedback is for.
Definition: ats.h:483
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton(struct GNUNET_TIME_Relative a)
Convert relative time to network byte order.
Definition: time.c:625
#define GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK
Type of the &#39;struct ChangePreferenceMessage&#39; sent by clients to ATS to ask for allocation preference ...
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
Change the peer&#39;s latency value to the given amount.
Message containing application feedback for a peer.
Definition: ats.h:463
struct GNUNET_TIME_RelativeNBO scope
Relative time describing for which time interval this feedback is.
Definition: ats.h:478
#define GNUNET_VA_ARG_ENUM(va, X)
wrap va_arg for enums
Change the peer&#39;s bandwidth value (value per byte of bandwidth in the goal function) to the given amo...
Variable-size entry in a struct ChangePreferenceMessage or struct FeedbackPreferenceMessage.
Definition: ats.h:419
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
GNUNET_ATS_PreferenceKind
Enum defining all known preference categories.
float preference_value
Degree of preference (or appreciation) for this preference_kind being expressed.
Definition: ats.h:430
Here is the call graph for this function:

◆ GNUNET_ATS_transport_init()

struct GNUNET_ATS_TransportHandle* GNUNET_ATS_transport_init ( const struct GNUNET_CONFIGURATION_Handle cfg,
GNUNET_ATS_AllocationCallback  alloc_cb,
void *  alloc_cb_cls,
GNUNET_ATS_SuggestionCallback  suggest_cb,
void *  suggest_cb_cls 
)

Initialize the ATS transport subsystem.

Parameters
cfgconfiguration to use
alloc_cbnotification to call whenever the allocation changed
alloc_cb_clsclosure for alloc_cb
suggest_cbnotification to call whenever the suggestation is made
suggest_cb_clsclosure for suggest_cb
Returns
ats context

◆ GNUNET_ATS_transport_done()

void GNUNET_ATS_transport_done ( struct GNUNET_ATS_TransportHandle *  ath)

Client is done with ATS transport, release resources.

Parameters
athhandle to release

◆ GNUNET_ATS_session_add()

struct GNUNET_ATS_SessionRecord* GNUNET_ATS_session_add ( struct GNUNET_ATS_TransportHandle *  ath,
const struct GNUNET_PeerIdentity pid,
const char *  address,
struct GNUNET_ATS_Session session,
const struct GNUNET_ATS_Properties prop 
)

We have a new session ATS should know.

Sessiones have to be added with this function before they can be: updated, set in use and destroyed

Parameters
athhandle
pidpeer we connected to
addressthe address (human readable version),
sessiontransport-internal handle for the session/queue, NULL if the session is inbound-only
propperformance data for the session
Returns
handle to the session representation inside ATS, NULL on error (i.e. ATS knows this exact session already, or session is invalid)

◆ GNUNET_ATS_session_update()

void GNUNET_ATS_session_update ( struct GNUNET_ATS_SessionRecord *  ar,
const struct GNUNET_ATS_Properties prop 
)

We have updated performance statistics for a given session.

Based on the information provided, ATS may update bandwidth assignments.

Parameters
arsession record to update information for
propperformance data for the session

◆ GNUNET_ATS_session_del()

void GNUNET_ATS_session_del ( struct GNUNET_ATS_SessionRecord *  ar)

A session was destroyed, ATS should now schedule and allocate under the assumption that this ar is no longer in use.

Parameters
arsession record to drop