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.

◆ 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.

◆ GNUNET_ATS_MaxBandwidthString

#define GNUNET_ATS_MaxBandwidthString   "unlimited"

Textual equivalent for GNUNET_ATS_MaxBandwidth.

Definition at line 65 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 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.

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 264 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 402 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 486 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 545 of file gnunet_ats_service.h.

546 {
554 
563 
568 };
@ 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

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:444
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

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:454

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
@ GNUNET_YES
Definition: gnunet_common.h:97
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).
#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 GDS_NEIGHBOURS_init(), GNUNET_TRANSPORT_TESTING_restart_peer(), GNUNET_TRANSPORT_TESTING_start_peer(), 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:837
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:972
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(), GDS_NEIGHBOURS_done(), 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,...)
@ GNUNET_OK
Definition: gnunet_common.h:95
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...
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_TRANSPORT_TESTING_connect_peers(), ip_drop(), ip_hold(), notify_disconnect(), occ_cache_get_handle_ats_occ_cb(), occ_cache_get_handle_ats_rocc_cb(), run(), setup_neighbour(), and try_connect().

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.

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 }
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
static struct SolverHandle * sh
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_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:355
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#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_connect_info(), free_neighbour(), free_peer(), GNUNET_TRANSPORT_TESTING_connect_peers_cancel(), ip_drop(), ip_hold(), notify_connect(), shutdown_task(), and try_connect().

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.

572 {
574 
576  sh->cfg = cfg;
577  sh->suggest_cb = suggest_cb;
578  sh->suggest_cb_cls = suggest_cb_cls;
579  GNUNET_array_grow (sh->session_array,
580  sh->session_array_size,
581  4);
582  reconnect (sh);
583  return sh;
584 }
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 593 of file ats_api_scheduling.c.

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  {
605  GNUNET_SCHEDULER_cancel (sh->task);
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  }
617  GNUNET_array_grow (sh->session_array,
618  sh->session_array_size,
619  0);
620  GNUNET_free (sh);
621 }
#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 637 of file ats_api_scheduling.c.

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 !=
668  session,
669  address))
670  {
671  /* Already existing, nothing todo, but this should not happen */
672  GNUNET_break (0);
673  return NULL;
674  }
676  ar = GNUNET_new (struct GNUNET_ATS_AddressRecord);
677  ar->sh = sh;
678  ar->slot = s;
679  ar->session = session;
682  prop);
683  sh->session_array[s] = ar;
685  return ar;
686 }
#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:109
#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:40
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 696 of file ats_api_scheduling.c.

698 {
699  GNUNET_break (NULL == ar->session);
700  ar->session = session;
701 }

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

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

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

Definition at line 717 of file ats_api_scheduling.c.

719 {
720  GNUNET_assert (session == ar->session);
721  ar->session = NULL;
724  {
726  return GNUNET_YES;
727  }
728  return GNUNET_NO;
729 }
@ GNUNET_NO
Definition: gnunet_common.h:94
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.

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

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 }
#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, 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.

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 '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
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.

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  {
773  }
774  else
775  {
777  alh->peer = *peer;
778  }
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_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
alhthe handle of the request to cancel

Definition at line 800 of file ats_api_performance.c.

802 {
804 
807  alh);
808  GNUNET_free (alh);
809 }
#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

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.

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;
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 }
#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
rccontext returned by the original GNUNET_ATS_reserve_bandwidth() call

Definition at line 727 of file ats_api_performance.c.

728 {
729  rc->rcb = NULL;
730 }

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

820 {
821  const char *prefs[] = GNUNET_ATS_PreferenceTypeString;
822 
824  return prefs[type];
825  return NULL;
826 }
#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

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.

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);
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 }
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
#define GNUNET_VA_ARG_ENUM(va, X)
wrap va_arg for enums
GNUNET_ATS_PreferenceKind
Enum defining all known preference categories.
#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
#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 922 of file ats_api_performance.c.

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);
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_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