GNUnet  0.18.1
ATS service

Bandwidth allocation. More...

Collaboration diagram for ATS service:

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 an enum 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 48 of file gnunet_ats_service.h.

◆ GNUNET_ATS_VALUE_UNDEFINED

#define GNUNET_ATS_VALUE_UNDEFINED   UINT32_MAX

Undefined value for an enum GNUNET_ATS_Property

Definition at line 53 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 58 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 63 of file gnunet_ats_service.h.

◆ GNUNET_ATS_MaxBandwidthString

#define GNUNET_ATS_MaxBandwidthString   "unlimited"

Textual equivalent for GNUNET_ATS_MaxBandwidth.

Definition at line 68 of file gnunet_ats_service.h.

◆ GNUNET_ATS_PreferenceType

#define GNUNET_ATS_PreferenceType
Value:
GNUNET_ATS_PREFERENCE_LATENCY, \
GNUNET_ATS_PREFERENCE_END }
@ GNUNET_ATS_PREFERENCE_BANDWIDTH
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 536 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 543 of file gnunet_ats_service.h.

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 267 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 405 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 489 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 135 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 152 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 548 of file gnunet_ats_service.h.

549 {
557 
566 
571 };
@ GNUNET_ATS_PREFERENCE_LATENCY
Change the peer's latency value to the given amount.
@ GNUNET_ATS_PREFERENCE_END
End of preference list.

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 bandwidth 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 bandwidth, 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
nbo[OUT]value written
hbovalue read

Definition at line 36 of file ats_api_scanner.c.

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 }
struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton(struct GNUNET_TIME_Relative a)
Convert relative time to network byte order.
Definition: time.c:617
uint32_t utilization_out
Actual traffic on this connection from this peer to the other peer.
uint32_t utilization_in
Actual traffic on this connection from the other peer to this peer.
struct GNUNET_TIME_RelativeNBO delay
Delay.
uint32_t distance
Distance on network layer (required for distance-vector routing) in hops.
uint32_t scope
Which network scope does the respective address belong to? This property does not change.
uint32_t utilization_in
Actual traffic on this connection from the other peer to this peer.
unsigned int distance
Distance on network layer (required for distance-vector routing) in hops.
struct GNUNET_TIME_Relative delay
Delay.
enum GNUNET_NetworkType scope
Which network scope does the respective address belong to? This property does not change.
uint32_t utilization_out
Actual traffic on this connection from this peer to the other peer.

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().

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
hbo[OUT]value written
nbovalue read

Definition at line 54 of file ats_api_scanner.c.

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 }
struct GNUNET_TIME_Relative GNUNET_TIME_relative_ntoh(struct GNUNET_TIME_RelativeNBO a)
Convert relative time from network byte order.
Definition: time.c:627

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().

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.

228 {
230 
232  ch->cfg = cfg;
233  ch->sug_requests = GNUNET_CONTAINER_multipeermap_create (32,
234  GNUNET_YES);
235  reconnect (ch);
236  return ch;
237 }
static void reconnect(struct GNUNET_ATS_ConnectivityHandle *ch)
Re-establish the connection to the ATS service.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
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).
@ GNUNET_YES
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Handle to the ATS subsystem for connectivity management.

References cfg, ch, GNUNET_CONTAINER_multipeermap_create(), GNUNET_new, GNUNET_YES, and reconnect().

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

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.

268 {
269  if (NULL != ch->mq)
270  {
272  ch->mq = NULL;
273  }
274  if (NULL != ch->task)
275  {
276  GNUNET_SCHEDULER_cancel (ch->task);
277  ch->task = NULL;
278  }
281  NULL);
283  GNUNET_free (ch);
284 }
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_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
#define GNUNET_free(ptr)
Wrapper around free.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:686
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:943
struct GNUNET_MQ_Handle * mq
Message Queue for the channel (which we are implementing).
Definition: cadet.h:143

References ch, free_sug_handle(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), and GNUNET_CADET_Channel::mq.

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

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.

302 {
304 
306  s->ch = ch;
307  s->id = *peer;
308  s->strength = strength;
309  if (GNUNET_OK !=
310  GNUNET_CONTAINER_multipeermap_put (ch->sug_requests,
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 int transmit_suggestion(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
Transmit request for an address suggestion.
#define LOG(kind,...)
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.
@ GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY
There must only be one value per key; storing a value should fail if a value under the same key alrea...
@ GNUNET_OK
Definition: gnunet_common.h:99
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
@ GNUNET_ERROR_TYPE_DEBUG
Handle for ATS address suggestion requests.
struct GNUNET_PeerIdentity id
ID of the peer for which address suggestion was requested.
struct GNUNET_ATS_ConnectivityHandle * ch
Connecitivity handle this suggestion handle belongs to.
uint32_t strength
How urgent is the request.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.

References GNUNET_ATS_ConnectivitySuggestHandle::ch, 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_CADET_Channel::mq, peer, GNUNET_ATS_ConnectivitySuggestHandle::strength, and transmit_suggestion().

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

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 to stop

Definition at line 334 of file ats_api_connectivity.c.

336 {
337  struct GNUNET_ATS_ConnectivityHandle *ch = sh->ch;
338  struct GNUNET_MQ_Envelope *ev;
339  struct RequestAddressMessage *m;
340 
342  "Telling ATS we no longer care for an address for `%s'\n",
343  GNUNET_i2s (&sh->id));
346  &sh->id,
347  sh));
348  if (NULL == ch->mq)
349  {
350  GNUNET_free (sh);
351  return;
352  }
353  ev = GNUNET_MQ_msg (m,
355  m->strength = htonl (0);
356  m->peer = sh->id;
357  GNUNET_MQ_send (ch->mq, ev);
358  GNUNET_free (sh);
359 }
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
static struct SolverHandle * sh
enum GNUNET_GenericReturnValue 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_assert(cond)
Use this for fatal errors that cannot be handled.
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:303
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:71
#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...
Connectivity client to ATS service: we would like to have address suggestions for this peer.
Definition: ats.h:88

Referenced by attempt_connect(), cleanup_occ_lp2c(), cleanup_rocc(), consider_peer_activate(), core_disconnect_cb(), destroy_peer(), end(), free_neighbour(), free_peer(), gnunet_drop(), gnunet_hold(), GNUNET_TRANSPORT_TESTING_connect_peers_cancel(), notify_connect(), and shutdown_task().

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

Definition at line 561 of file ats_api_scheduling.c.

564 {
566 
568  sh->cfg = cfg;
569  sh->suggest_cb = suggest_cb;
570  sh->suggest_cb_cls = suggest_cb_cls;
571  GNUNET_array_grow (sh->session_array,
572  sh->session_array_size,
573  4);
574  reconnect (sh);
575  return sh;
576 }
static void reconnect(struct GNUNET_ATS_SchedulingHandle *sh)
Re-establish the connection to the ATS service.
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
Handle to the ATS subsystem for bandwidth/transport scheduling information.
void * suggest_cb_cls
Closure for suggest_cb.
GNUNET_ATS_AddressSuggestionCallback suggest_cb
Callback to invoke on suggestions.

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

Referenced by run().

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 585 of file ats_api_scheduling.c.

586 {
587  struct GNUNET_ATS_AddressRecord *ar;
588  unsigned int i;
589 
590  if (NULL != sh->mq)
591  {
592  GNUNET_MQ_destroy (sh->mq);
593  sh->mq = NULL;
594  }
595  if (NULL != sh->task)
596  {
597  GNUNET_SCHEDULER_cancel (sh->task);
598  sh->task = NULL;
599  }
600  for (i = 0; i < sh->session_array_size; i++)
601  {
602  if (NULL != (ar = sh->session_array[i]))
603  {
605  GNUNET_free (ar);
606  sh->session_array[i] = NULL;
607  }
608  }
609  GNUNET_array_grow (sh->session_array,
610  sh->session_array_size,
611  0);
612  GNUNET_free (sh);
613 }
#define GNUNET_HELLO_address_free(addr)
Free an address.
Information we track per address, incoming or outgoing.
struct GNUNET_HELLO_Address * address
Address data.

References GNUNET_ATS_AddressRecord::address, GNUNET_array_grow, GNUNET_free, GNUNET_HELLO_address_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), and sh.

Referenced by shutdown_task().

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, e.g 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 629 of file ats_api_scheduling.c.

633 {
634  struct GNUNET_ATS_AddressRecord *ar;
635  size_t namelen;
636  size_t msize;
637  uint32_t s;
638 
639  if (NULL == address)
640  {
641  /* we need a valid address */
642  GNUNET_break (0);
643  return NULL;
644  }
646  namelen = strlen (address->transport_name) + 1;
647  msize = address->address_length + namelen;
648  if ((msize + sizeof(struct AddressUpdateMessage) >=
650  (address->address_length >= GNUNET_MAX_MESSAGE_SIZE) ||
651  (namelen >= GNUNET_MAX_MESSAGE_SIZE))
652  {
653  /* address too large for us, this should not happen */
654  GNUNET_break (0);
655  return NULL;
656  }
657 
658  if (NOT_FOUND !=
660  session,
661  address))
662  {
663  /* Already existing, nothing todo, but this should not happen */
664  GNUNET_break (0);
665  return NULL;
666  }
668  ar = GNUNET_new (struct GNUNET_ATS_AddressRecord);
669  ar->sh = sh;
670  ar->slot = s;
671  ar->session = session;
674  prop);
675  sh->session_array[s] = ar;
677  return ar;
678 }
#define NOT_FOUND
Session ID we use if there is no session / slot.
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.
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.
static uint32_t find_empty_session_slot(struct GNUNET_ATS_SchedulingHandle *sh)
Get an available session ID.
static char * address
GNS address for this phone.
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message,...
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.
struct GNUNET_HELLO_Address * GNUNET_HELLO_address_copy(const struct GNUNET_HELLO_Address *address)
Copy an address struct.
Definition: address.c:99
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_NT_UNSPECIFIED
Category of last resort.
Definition: gnunet_nt_lib.h:43
Message used to notify ATS that the performance characteristics for an address have changed.
Definition: ats.h:162
struct GNUNET_ATS_Session * session
Session handle.
uint32_t slot
Which slot (index) in the session array does this record correspond to? FIXME: a linear search on thi...
struct GNUNET_ATS_SchedulingHandle * sh
Scheduling handle this address record belongs to.
struct GNUNET_ATS_PropertiesNBO properties
Performance data about the address.

References GNUNET_ATS_AddressRecord::address, address, 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_AddressRecord::sh, sh, and GNUNET_ATS_AddressRecord::slot.

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

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 688 of file ats_api_scheduling.c.

690 {
691  GNUNET_break (NULL == ar->session);
692  ar->session = session;
693 }

References GNUNET_break, and GNUNET_ATS_AddressRecord::session.

Referenced by GST_ats_new_session().

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 address, 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 ar was kept because we can use it still to establish a new session

Definition at line 697 of file ats_api_scheduling.c.

699 {
700  GNUNET_assert (session == ar->session);
701  ar->session = NULL;
704  {
706  return GNUNET_YES;
707  }
708  return GNUNET_NO;
709 }
void GNUNET_ATS_address_destroy(struct GNUNET_ATS_AddressRecord *ar)
An address got destroyed, stop using it as a valid address.
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
@ GNUNET_HELLO_ADDRESS_INFO_INBOUND
This is an inbound address and cannot be used to initiate an outbound connection to another peer.
@ GNUNET_NO
Definition: gnunet_common.h:98

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().

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 724 of file ats_api_scheduling.c.

726 {
727  struct GNUNET_ATS_SchedulingHandle *sh = ar->sh;
728  struct GNUNET_MQ_Envelope *ev;
729  struct AddressUpdateMessage *m;
730 
732  "Updating address for peer `%s', plugin `%s', session %p slot %u\n",
733  GNUNET_i2s (&ar->address->peer),
734  ar->address->transport_name,
735  ar->session,
736  ar->slot);
739  prop);
740  if (NULL == sh->mq)
741  return; /* disconnected, skip for now */
743  m->session_id = htonl (ar->slot);
744  m->peer = ar->address->peer;
745  m->properties = ar->properties;
746  GNUNET_MQ_send (sh->mq,
747  ev);
748 }
#define LOG(kind,...)
#define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_UPDATE
Type of the 'struct AddressUpdateMessage' sent by clients to ATS to inform ATS about performance chan...
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?

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_HELLO_Address::peer, GNUNET_ATS_AddressRecord::properties, GNUNET_ATS_Properties::scope, GNUNET_ATS_AddressRecord::session, GNUNET_ATS_AddressRecord::sh, 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().

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, its validation has expired and ATS may no longer use it
araddress to destroy

Definition at line 757 of file ats_api_scheduling.c.

758 {
759  struct GNUNET_ATS_SchedulingHandle *sh = ar->sh;
760  struct GNUNET_MQ_Envelope *ev;
761  struct AddressDestroyedMessage *m;
762 
764  "Deleting address for peer `%s', plugin `%s', slot %u session %p\n",
765  GNUNET_i2s (&ar->address->peer),
766  ar->address->transport_name,
767  ar->slot,
768  ar->session);
769  GNUNET_break (NULL == ar->session);
770  ar->session = NULL;
771  ar->in_destroy = GNUNET_YES;
772  if (NULL == sh->mq)
773  return;
775  m->session_id = htonl (ar->slot);
776  m->peer = ar->address->peer;
777  GNUNET_MQ_send (sh->mq, ev);
778 }
#define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_DESTROYED
Type of the 'struct AddressDestroyedMessage' sent by clients to ATS to inform ATS about an address be...
Message sent by ATS client to ATS service when an address was destroyed and must thus henceforth no l...
Definition: ats.h:193
int in_destroy
We're about to destroy this address record, just ATS does not know this yet.

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_HELLO_Address::peer, GNUNET_ATS_AddressRecord::session, GNUNET_ATS_AddressRecord::sh, 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().

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.

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 void reconnect(struct GNUNET_ATS_PerformanceHandle *ph)
Re-establish the connection to the ATS service.
static struct GNUNET_ATS_PerformanceHandle * ph
ATS performance handle used.
Definition: gnunet-ats.c:116
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.
ATS Handle to obtain and/or modify performance information.
struct GNUNET_MQ_Handle * mq
Connection to ATS service.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
void * addr_info_cb_cls
Closure for addr_info_cb.
GNUNET_ATS_AddressInformationCallback addr_info_cb
Callback to invoke when an address has performance changes.

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 run().

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

Definition at line 715 of file ats_api_performance.c.

721 {
723  struct GNUNET_MQ_Envelope *env;
725 
726  if (NULL == ph->mq)
727  return NULL;
728  if (NULL == infocb)
729  {
730  GNUNET_break (0);
731  return NULL;
732  }
734  alh->id = ph->id++;
735  alh->cb = infocb;
736  alh->cb_cls = infocb_cls;
737  alh->ph = ph;
738  alh->all_addresses = all;
739  if (NULL == peer)
740  {
742  }
743  else
744  {
746  alh->peer = *peer;
747  }
750  alh);
751  env = GNUNET_MQ_msg (m,
753  m->all = htonl (all);
754  m->id = htonl (alh->id);
755  if (NULL != peer)
756  m->peer = *peer;
757  GNUNET_MQ_send (ph->mq,
758  env);
759  return alh;
760 }
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
static struct GNUNET_ATS_AddressListHandle * alh
ATS address list handle used.
Definition: gnunet-ats.c:131
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
#define GNUNET_MESSAGE_TYPE_ATS_ADDRESSLIST_REQUEST
Type of the 'struct AddressListRequestMessage' sent by client to ATS to request information about add...
Client to service: please give us an overview of the addresses.
Definition: ats.h:342
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
Linked list of pending reservations.
GNUNET_ATS_AddressInformationCallback cb
Callback.
void * cb_cls
Callback closure for cb.
uint32_t id
Request multiplexing.
struct GNUNET_PeerIdentity peer
Target peer.
struct GNUNET_ATS_PerformanceHandle * ph
Performance handle.
int all_peers
Return all or specific peer only.
int all_addresses
Return all or used address only.
uint32_t id
Request multiplexing.
struct GNUNET_ATS_AddressListHandle * addresslist_head
Head of linked list of pending address list requests.
struct GNUNET_ATS_AddressListHandle * addresslist_tail
Tail of linked list of pending address list requests.

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, m, GNUNET_ATS_PerformanceHandle::mq, GNUNET_ATS_AddressListHandle::peer, peer, ph, and GNUNET_ATS_AddressListHandle::ph.

Referenced by run().

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

Definition at line 764 of file ats_api_performance.c.

766 {
768 
771  alh);
772  GNUNET_free (alh);
773 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.

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

Referenced by end().

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.

640 {
643 
644  while (NULL != (alh = ph->addresslist_head))
645  {
648  alh);
649  GNUNET_free (alh);
650  }
651  while (NULL != (rc = ph->reservation_head))
652  {
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  {
667  ph->mq = NULL;
668  }
669  GNUNET_free (ph);
670 }
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.
struct GNUNET_SCHEDULER_Task * task
Task to trigger reconnect.
Linked list of pending reservations.
GNUNET_ATS_ReservationCallback rcb
Function to call on result.

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, ph, GNUNET_ATS_ReservationContext::rcb, GNUNET_ATS_PerformanceHandle::reservation_head, GNUNET_ATS_PerformanceHandle::reservation_tail, and GNUNET_ATS_PerformanceHandle::task.

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

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

Definition at line 674 of file ats_api_performance.c.

679 {
681  struct GNUNET_MQ_Envelope *env;
683 
684  if (NULL == ph->mq)
685  return NULL;
687  rc->size = amount;
688  rc->peer = *peer;
689  rc->rcb = rcb;
690  rc->rcb_cls = rcb_cls;
691  if ((NULL != rcb) &&
692  (amount > 0))
693  rc->undo = GNUNET_YES;
696  rc);
697  env = GNUNET_MQ_msg (m,
699  m->amount = htonl (amount);
700  m->peer = *peer;
701  GNUNET_MQ_send (ph->mq,
702  env);
703  return rc;
704 }
#define GNUNET_CONTAINER_DLL_insert_tail(head, tail, element)
Insert an element at the tail of a DLL.
#define GNUNET_MESSAGE_TYPE_ATS_RESERVATION_REQUEST
Type of the 'struct ReservationRequestMessage' sent by clients to ATS to ask for inbound bandwidth re...
struct GNUNET_PeerIdentity peer
Target peer.
int undo
Do we need to undo this reservation if it succeeded? Set to GNUNET_YES if a reservation is cancelled.
void * rcb_cls
Closure for rcb.
int32_t size
Desired reservation.

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, peer, ph, 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().

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

Definition at line 708 of file ats_api_performance.c.

709 {
710  rc->rcb = NULL;
711 }

References GNUNET_ATS_ReservationContext::rcb.

Referenced by GSF_peer_disconnect_handler().

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 an enum GNUNET_ATS_PreferenceType to a string.

Parameters
typethe preference type
Returns
a string or NULL if invalid

Definition at line 777 of file ats_api_performance.c.

778 {
779  const char *prefs[] = GNUNET_ATS_PreferenceTypeString;
780 
782  return prefs[type];
783  return NULL;
784 }
#define GNUNET_ATS_PreferenceTypeString
ATS preference types as string array initializer.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model

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().

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 788 of file ats_api_performance.c.

793 {
794  struct GNUNET_MQ_Envelope *env;
795  struct ChangePreferenceMessage *m;
796  uint32_t count;
797  struct PreferenceInformation *pi;
798  va_list ap;
799  enum GNUNET_ATS_PreferenceKind kind;
800 
801  if (NULL == ph->mq)
802  return;
803  count = 0;
804  va_start (ap, peer);
805  while (GNUNET_ATS_PREFERENCE_END !=
807  {
808  switch (kind)
809  {
811  count++;
812  (void) va_arg (ap, double);
813  break;
814 
816  count++;
817  (void) va_arg (ap, double);
818  break;
819 
820  default:
821  GNUNET_assert (0);
822  }
823  }
824  va_end (ap);
826  count * sizeof(struct PreferenceInformation),
828  m->num_preferences = htonl (count);
829  m->peer = *peer;
830  pi = (struct PreferenceInformation *) &m[1];
831  count = 0;
832  va_start (ap, peer);
833  while (GNUNET_ATS_PREFERENCE_END != (kind =
834  GNUNET_VA_ARG_ENUM (ap,
836  {
837  pi[count].preference_kind = htonl (kind);
838  switch (kind)
839  {
841  pi[count].preference_value = (float) va_arg (ap, double);
842 
843  count++;
844  break;
845 
847  pi[count].preference_value = (float) va_arg (ap, double);
848 
849  count++;
850  break;
851 
852  default:
853  GNUNET_assert (0);
854  }
855  }
856  va_end (ap);
857  GNUNET_MQ_send (ph->mq,
858  env);
859 }
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
GNUNET_ATS_PreferenceKind
Enum defining all known preference categories.
#define GNUNET_VA_ARG_ENUM(va, X)
wrap va_arg for enums
#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:56
#define GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE
Type of the 'struct ChangePreferenceMessage' sent by clients to ATS to ask for allocation preference ...
Client to ATS: I have a performance preference for a peer.
Definition: ats.h:438
Variable-size entry in a struct ChangePreferenceMessage or struct FeedbackPreferenceMessage.
Definition: ats.h:420

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, peer, ph, and pi.

Referenced by run(), and schedule_transmission().

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 872 of file ats_api_performance.c.

876 {
877  struct GNUNET_MQ_Envelope *env;
879  uint32_t count;
880  struct PreferenceInformation *pi;
881  va_list ap;
882  enum GNUNET_ATS_PreferenceKind kind;
883 
884  if (NULL == ph->mq)
885  return;
886  count = 0;
887  va_start (ap, scope);
888  while (GNUNET_ATS_PREFERENCE_END !=
890  {
891  switch (kind)
892  {
894  count++;
895  (void) va_arg (ap, double);
896  break;
897 
899  count++;
900  (void) va_arg (ap, double);
901  break;
902 
903  default:
904  GNUNET_assert (0);
905  }
906  }
907  va_end (ap);
909  count * sizeof(struct PreferenceInformation),
911  m->scope = GNUNET_TIME_relative_hton (scope);
912  m->num_feedback = htonl (count);
913  m->peer = *peer;
914  pi = (struct PreferenceInformation *) &m[1];
915  count = 0;
916  va_start (ap, scope);
917  while (GNUNET_ATS_PREFERENCE_END != (kind =
918  GNUNET_VA_ARG_ENUM (ap,
920  {
921  pi[count].preference_kind = htonl (kind);
922  switch (kind)
923  {
925  pi[count].preference_value = (float) va_arg (ap, double);
926 
927  count++;
928  break;
929 
931  pi[count].preference_value = (float) va_arg (ap, double);
932 
933  count++;
934  break;
935 
936  default:
937  GNUNET_assert (0);
938  }
939  }
940  va_end (ap);
941  GNUNET_MQ_send (ph->mq,
942  env);
943 }
#define GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK
Type of the 'struct ChangePreferenceMessage' sent by clients to ATS to ask for allocation preference ...
static enum GNUNET_NetworkType scope
Which network scope do we belong to?
Message containing application feedback for a peer.
Definition: ats.h:464

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, peer, ph, pi, and scope.

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