GNUnet  0.10.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   { GNUNET_ATS_PREFERENCE_BANDWIDTH, GNUNET_ATS_PREFERENCE_LATENCY, GNUNET_ATS_PREFERENCE_END }
 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_ApplicationHandleGNUNET_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_ApplicationSuggestHandleGNUNET_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_TransportHandleGNUNET_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_SessionRecordGNUNET_ATS_session_add (struct GNUNET_ATS_TransportHandle *ath, const struct GNUNET_PeerIdentity *pid, const char *address, struct GNUNET_ATS_Session *session, const struct GNUNET_ATS_Properties *prop)
 We have a new session ATS should know. More...
 
void GNUNET_ATS_session_update (struct GNUNET_ATS_SessionRecord *ar, const struct GNUNET_ATS_Properties *prop)
 We have updated performance statistics for a given session. More...
 
void GNUNET_ATS_session_del (struct GNUNET_ATS_SessionRecord *ar)
 A session was destroyed, ATS should now schedule and allocate under the assumption that this ar is no longer in use. More...
 

Detailed Description

Bandwidth allocation.

Bandwidth allocation for transport service.

Automatic Transport Selection and outbound bandwidth determination.

See also
Documentation

Macro Definition Documentation

◆ GNUNET_ATS_DefaultBandwidth

#define GNUNET_ATS_DefaultBandwidth   65536

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

Definition at line 45 of file gnunet_ats_service.h.

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

◆ GNUNET_ATS_VALUE_UNDEFINED

#define GNUNET_ATS_VALUE_UNDEFINED   UINT32_MAX

Undefined value for an enum GNUNET_ATS_Property

Definition at line 50 of file gnunet_ats_service.h.

◆ GNUNET_ATS_VALUE_UNDEFINED_STR

#define GNUNET_ATS_VALUE_UNDEFINED_STR   "undefined"

String representation for GNUNET_ATS_VALUE_UNDEFINED.

Definition at line 55 of file gnunet_ats_service.h.

◆ GNUNET_ATS_MaxBandwidth

#define GNUNET_ATS_MaxBandwidth   UINT32_MAX

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

Definition at line 60 of file gnunet_ats_service.h.

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

◆ GNUNET_ATS_MaxBandwidthString

#define GNUNET_ATS_MaxBandwidthString   "unlimited"

Textual equivalent for GNUNET_ATS_MaxBandwidth.

Definition at line 65 of file gnunet_ats_service.h.

Referenced by parse_quota().

◆ GNUNET_ATS_PreferenceType

ATS preference types as array initializer.

Definition at line 524 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 529 of file gnunet_ats_service.h.

Referenced by GNUNET_ATS_print_preference_type(), and parse_preference_string().

Typedef Documentation

◆ GNUNET_ATS_AddressSuggestionCallback

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

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

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

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

Definition at line 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 400 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 478 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 150 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 534 of file gnunet_ats_service.h.

534  {
542 
551 
556 };
End of preference list.
Change the peer's latency value to the given amount.
Change the peer's bandwidth value (value per byte of bandwidth in the goal function) to the given amo...

Function Documentation

◆ GNUNET_ATS_application_init()

struct GNUNET_ATS_ApplicationHandle* GNUNET_ATS_application_init ( const struct GNUNET_CONFIGURATION_Handle cfg)

Initialize the ATS application client handle.

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

Initialize the ATS application client handle.

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

Definition at line 224 of file ats_api2_application.c.

References GNUNET_ATS_ApplicationHandle::cfg, cfg, GNUNET_ATS_ApplicationSuggestHandle::ch, GNUNET_CONTAINER_multipeermap_create(), GNUNET_new, GNUNET_YES, reconnect(), and GNUNET_ATS_ApplicationHandle::sug_requests.

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

◆ GNUNET_ATS_application_done()

void GNUNET_ATS_application_done ( struct GNUNET_ATS_ApplicationHandle ch)

Shutdown ATS application client.

Parameters
chhandle to destroy

Shutdown ATS application client.

Parameters
chhandle to release

Definition at line 264 of file ats_api2_application.c.

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

265 {
266  if (NULL != ch->mq)
267  {
268  GNUNET_MQ_destroy(ch->mq);
269  ch->mq = NULL;
270  }
271  if (NULL != ch->task)
272  {
274  ch->task = NULL;
275  }
278  NULL);
280  GNUNET_free(ch);
281 }
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
struct GNUNET_SCHEDULER_Task * task
Task to trigger reconnect.
static int free_sug_handle(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Function called to free all struct GNUNET_ATS_ApplicationSuggestHandles in the 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.
struct GNUNET_CONTAINER_MultiPeerMap * sug_requests
Map with the identities of all the peers for which we would like to have address suggestions.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:821
struct GNUNET_MQ_Handle * mq
Message queue for sending requests to the ATS service.
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956
Here is the call graph for this function:

◆ GNUNET_ATS_application_suggest()

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

An application would like to communicate with a peer.

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

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

An application would like to communicate 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_application_suggest_cancel().

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

Definition at line 298 of file ats_api2_application.c.

References GNUNET_ATS_ApplicationSuggestHandle::bw, GNUNET_ATS_ApplicationSuggestHandle::ch, GNUNET_assert, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multipeermap_put(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_new, GNUNET_OK, GNUNET_ATS_ApplicationSuggestHandle::id, LOG, GNUNET_ATS_ApplicationHandle::mq, peer, GNUNET_ATS_ApplicationSuggestHandle::pk, GNUNET_ATS_ApplicationHandle::sug_requests, and transmit_suggestion().

302 {
304 
306  s->ch = ch;
307  s->id = *peer;
308  s->pk = pk;
309  s->bw = bw;
311  &s->id,
312  s,
315  "Requesting ATS to suggest address for `%s'\n",
316  GNUNET_i2s(peer));
317  if (NULL == ch->mq)
318  return s;
321  &s->id,
322  s));
323  return s;
324 }
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
static struct GNUNET_CRYPTO_EddsaPrivateKey * pk
Private key of this peer.
struct GNUNET_BIO_WriteHandle * bw
hanlde to the file to write the load statistics to
struct GNUNET_ATS_ApplicationHandle * ch
Connecitivity handle this suggestion handle belongs to.
static int transmit_suggestion(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
Transmit request for an address suggestion.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define LOG(kind,...)
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_PeerIdentity id
ID of the peer for which address suggestion was requested.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
enum GNUNET_MQ_PreferenceKind pk
What preference is being expressed?
Allow multiple values with the same key.
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.
Handle for ATS address suggestion requests.
struct GNUNET_CONTAINER_MultiPeerMap * sug_requests
Map with the identities of all the peers for which we would like to have address suggestions.
struct GNUNET_MQ_Handle * mq
Message queue for sending requests to the ATS service.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
struct GNUNET_BANDWIDTH_Value32NBO bw
How much bandwidth does the client expect?
Here is the call graph for this function:

◆ 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

We no longer care about communicating with a peer.

Parameters
shhandle to stop

Definition at line 333 of file ats_api2_application.c.

References GNUNET_ATS_ApplicationSuggestHandle::bw, ExpressPreferenceMessage::bw, GNUNET_ATS_ApplicationSuggestHandle::ch, GNUNET_assert, GNUNET_CONTAINER_multipeermap_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_MESSAGE_TYPE_ATS_SUGGEST_CANCEL, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_OK, GNUNET_ATS_ApplicationSuggestHandle::id, LOG, m, GNUNET_ATS_ApplicationHandle::mq, ExpressPreferenceMessage::peer, GNUNET_ATS_ApplicationSuggestHandle::pk, ExpressPreferenceMessage::pk, and GNUNET_ATS_ApplicationHandle::sug_requests.

334 {
335  struct GNUNET_ATS_ApplicationHandle *ch = sh->ch;
336  struct GNUNET_MQ_Envelope *ev;
337  struct ExpressPreferenceMessage *m;
338 
340  "Telling ATS we no longer care for an address for `%s'\n",
341  GNUNET_i2s(&sh->id));
344  &sh->id,
345  sh));
346  if (NULL == ch->mq)
347  {
348  GNUNET_free(sh);
349  return;
350  }
351  ev = GNUNET_MQ_msg(m,
353  m->pk = htonl((uint32_t)sh->pk);
354  m->bw = sh->bw;
355  m->peer = sh->id;
356  GNUNET_MQ_send(ch->mq,
357  ev);
358  GNUNET_free(sh);
359 }
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
struct GNUNET_ATS_ApplicationHandle * ch
Connecitivity handle this suggestion handle belongs to.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
int GNUNET_CONTAINER_multipeermap_remove(struct GNUNET_CONTAINER_MultiPeerMap *map, const struct GNUNET_PeerIdentity *key, const void *value)
Remove the given key-value pair from the map.
#define LOG(kind,...)
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
uint32_t pk
What type of performance preference does the client have? A enum GNUNET_MQ_PreferenceKind in NBO...
Definition: ats2.h:121
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:99
Handle to the ATS subsystem for application management.
struct GNUNET_PeerIdentity id
ID of the peer for which address suggestion was requested.
#define GNUNET_MESSAGE_TYPE_ATS_SUGGEST_CANCEL
Type of the 'struct ExpressPreferenceMessage' send by clients to ATS to abandon bandwidth preference...
enum GNUNET_MQ_PreferenceKind pk
What preference is being expressed?
struct GNUNET_CONTAINER_MultiPeerMap * sug_requests
Map with the identities of all the peers for which we would like to have address suggestions.
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:351
struct GNUNET_MQ_Handle * mq
Message queue for sending requests to the ATS service.
struct GNUNET_BANDWIDTH_Value32NBO bw
How much bandwidth in bytes/second does the application expect?
Definition: ats2.h:131
Application client to ATS service: we would like to have address suggestions for this peer...
Definition: ats2.h:109
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_PeerIdentity peer
Peer to get address suggestions for.
Definition: ats2.h:126
struct GNUNET_BANDWIDTH_Value32NBO bw
How much bandwidth does the client expect?
Here is the call graph for this function:

◆ GNUNET_ATS_properties_hton()

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

Convert ATS properties from host to network byte order.

Parameters
nbo[OUT]value written
hbovalue read

Definition at line 36 of file ats_api_scanner.c.

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

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

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

◆ GNUNET_ATS_properties_ntoh()

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

Convert ATS properties from network to host byte order.

Parameters
hbo[OUT]value written
nbovalue read

Definition at line 54 of file ats_api_scanner.c.

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

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

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

◆ GNUNET_ATS_connectivity_init()

struct GNUNET_ATS_ConnectivityHandle* GNUNET_ATS_connectivity_init ( const struct GNUNET_CONFIGURATION_Handle cfg)

Initialize the ATS connectivity suggestion client handle.

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

Definition at line 224 of file ats_api_connectivity.c.

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

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

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

◆ GNUNET_ATS_connectivity_done()

void GNUNET_ATS_connectivity_done ( struct GNUNET_ATS_ConnectivityHandle ch)

Shutdown ATS connectivity suggestion client.

Parameters
chhandle to destroy

Shutdown ATS connectivity suggestion client.

Parameters
chhandle to release

Definition at line 264 of file ats_api_connectivity.c.

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

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

265 {
266  if (NULL != ch->mq)
267  {
268  GNUNET_MQ_destroy(ch->mq);
269  ch->mq = NULL;
270  }
271  if (NULL != ch->task)
272  {
274  ch->task = NULL;
275  }
278  NULL);
280  GNUNET_free(ch);
281 }
struct GNUNET_MQ_Handle * mq
Message queue for sending requests to the ATS service.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
struct GNUNET_SCHEDULER_Task * task
Task to trigger reconnect.
struct GNUNET_CONTAINER_MultiPeerMap * sug_requests
Map with the identities of all the peers for which we would like to have address suggestions.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
static int free_sug_handle(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Function called to free all struct GNUNET_ATS_ConnectivitySuggestHandles in the map.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:821
#define GNUNET_free(ptr)
Wrapper around free.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956
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 296 of file ats_api_connectivity.c.

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

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

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

◆ GNUNET_ATS_connectivity_suggest_cancel()

void GNUNET_ATS_connectivity_suggest_cancel ( struct GNUNET_ATS_ConnectivitySuggestHandle sh)

We no longer care about being connected to a peer.

Parameters
shhandle
shhandle to stop

Definition at line 336 of file ats_api_connectivity.c.

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

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

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

◆ GNUNET_ATS_scheduling_init()

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

Initialize the ATS scheduling subsystem.

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

Initialize the ATS scheduling subsystem.

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

Definition at line 566 of file ats_api_scheduling.c.

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

Referenced by run().

569 {
571 
573  sh->cfg = cfg;
574  sh->suggest_cb = suggest_cb;
577  sh->session_array_size,
578  4);
579  reconnect(sh);
580  return sh;
581 }
struct GNUNET_ATS_AddressRecord ** session_array
Array of session objects (we need to translate them to numbers and back for the protocol; the offset ...
Handle to the ATS subsystem for bandwidth/transport scheduling information.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
GNUNET_ATS_AddressSuggestionCallback suggest_cb
Callback to invoke on suggestions.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
#define GNUNET_array_grow(arr, size, tsize)
Grow a well-typed (!) array.
void * suggest_cb_cls
Closure for suggest_cb.
static struct SolverHandle * sh
unsigned int session_array_size
Size of the session_array.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
static void suggest_cb(void *cls, const struct GNUNET_PeerIdentity *pid, const char *address)
Function called by the solver to prompt the transport to try out a new address.
static void reconnect(struct GNUNET_ATS_SchedulingHandle *sh)
Re-establish the connection to the ATS service.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ATS_scheduling_done()

void GNUNET_ATS_scheduling_done ( struct GNUNET_ATS_SchedulingHandle sh)

Client is done with ATS scheduling, release resources.

Parameters
shhandle to release

Definition at line 590 of file ats_api_scheduling.c.

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

Referenced by shutdown_task().

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

◆ GNUNET_ATS_address_add()

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

We have a new address ATS should know.

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

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

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

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

Definition at line 634 of file ats_api_scheduling.c.

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

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

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

References GNUNET_break, and GNUNET_ATS_AddressRecord::session.

Referenced by GST_ats_new_session().

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

◆ GNUNET_ATS_address_del_session()

int GNUNET_ATS_address_del_session ( struct GNUNET_ATS_AddressRecord ar,
struct GNUNET_ATS_Session session 
)

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

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

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

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

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

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

Definition at line 713 of file ats_api_scheduling.c.

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

Referenced by GST_ats_block_address(), and GST_ats_del_session().

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

◆ GNUNET_ATS_address_update()

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

We have updated performance statistics for a given address.

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

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

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

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

Definition at line 740 of file ats_api_scheduling.c.

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

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

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

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

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

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

◆ GNUNET_ATS_performance_init()

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

Get handle to access performance API of the ATS subsystem.

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

Definition at line 608 of file ats_api_performance.c.

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

Referenced by ats_perf_connect_adapter(), and run().

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

◆ GNUNET_ATS_performance_list_addresses()

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

Get information about addresses known to the ATS subsystem.

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

Definition at line 741 of file ats_api_performance.c.

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

Referenced by run().

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

◆ GNUNET_ATS_performance_list_addresses_cancel()

void GNUNET_ATS_performance_list_addresses_cancel ( struct GNUNET_ATS_AddressListHandle alh)

Cancel a pending address listing operation.

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

Definition at line 794 of file ats_api_performance.c.

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

Referenced by end().

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

◆ GNUNET_ATS_performance_done()

void GNUNET_ATS_performance_done ( struct GNUNET_ATS_PerformanceHandle ph)

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

Parameters
phhandle

Definition at line 634 of file ats_api_performance.c.

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

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

635 {
638 
639  while (NULL != (alh = ph->addresslist_head))
640  {
642  ph->addresslist_tail,
643  alh);
644  GNUNET_free(alh);
645  }
646  while (NULL != (rc = ph->reservation_head))
647  {
649  ph->reservation_tail,
650  rc);
651  GNUNET_break(NULL == rc->rcb);
652  GNUNET_free(rc);
653  }
654  if (NULL != ph->task)
655  {
657  ph->task = NULL;
658  }
659  if (NULL != ph->mq)
660  {
661  GNUNET_MQ_destroy(ph->mq);
662  ph->mq = NULL;
663  }
664  GNUNET_free(ph);
665 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct GNUNET_ATS_AddressListHandle * addresslist_tail
Tail of linked list of pending address list requests.
struct GNUNET_ATS_ReservationContext * reservation_tail
Tail of linked list of pending reservation requests.
struct GNUNET_ATS_AddressListHandle * addresslist_head
Head of linked list of pending address list requests.
GNUNET_ATS_ReservationCallback rcb
Function to call on result.
struct GNUNET_ATS_ReservationContext * reservation_head
Head of linked list of pending reservation requests.
struct GNUNET_MQ_Handle * mq
Connection to ATS service.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Linked list of pending reservations.
static struct GNUNET_ATS_AddressListHandle * alh
ATS address list handle used.
Definition: gnunet-ats.c:131
struct GNUNET_SCHEDULER_Task * task
Task to trigger reconnect.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:821
#define GNUNET_free(ptr)
Wrapper around free.
Linked list of pending reservations.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956
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 683 of file ats_api_performance.c.

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

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

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

◆ GNUNET_ATS_reserve_bandwidth_cancel()

void GNUNET_ATS_reserve_bandwidth_cancel ( struct GNUNET_ATS_ReservationContext rc)

Cancel request for reserving bandwidth.

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

Definition at line 722 of file ats_api_performance.c.

References GNUNET_ATS_ReservationContext::rcb.

Referenced by GSF_peer_disconnect_handler().

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

◆ GNUNET_ATS_print_preference_type()

const char* GNUNET_ATS_print_preference_type ( enum GNUNET_ATS_PreferenceKind  type)

Convert a GNUNET_ATS_PreferenceType to a string.

Parameters
typethe preference type
Returns
a string or NULL if invalid

Convert a GNUNET_ATS_PreferenceType to a string.

Parameters
typethe preference type
Returns
a string or NULL if invalid

Definition at line 812 of file ats_api_performance.c.

References GNUNET_ATS_PREFERENCE_END, GNUNET_ATS_PreferenceTypeString, and type.

Referenced by GAS_ril_address_change_preference(), GAS_ril_address_preference_feedback(), 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().

813 {
814  const char *prefs[] = GNUNET_ATS_PreferenceTypeString;
815 
817  return prefs[type];
818  return NULL;
819 }
End of preference list.
enum GNUNET_TESTBED_UnderlayLinkModelType type
the type of this model
#define GNUNET_ATS_PreferenceTypeString
ATS preference types as string array initializer.
Here is the caller graph for this function:

◆ GNUNET_ATS_performance_change_preference()

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

Change preferences for the given peer.

Preference changes are forgotten if peers disconnect.

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

Definition at line 831 of file ats_api_performance.c.

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

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

834 {
835  struct GNUNET_MQ_Envelope *env;
836  struct ChangePreferenceMessage *m;
837  uint32_t count;
838  struct PreferenceInformation *pi;
839  va_list ap;
840  enum GNUNET_ATS_PreferenceKind kind;
841 
842  if (NULL == ph->mq)
843  return;
844  count = 0;
845  va_start(ap, peer);
846  while (GNUNET_ATS_PREFERENCE_END !=
848  {
849  switch (kind)
850  {
852  count++;
853  (void)va_arg(ap, double);
854  break;
855 
857  count++;
858  (void)va_arg(ap, double);
859  break;
860 
861  default:
862  GNUNET_assert(0);
863  }
864  }
865  va_end(ap);
866  env = GNUNET_MQ_msg_extra(m,
867  count * sizeof(struct PreferenceInformation),
869  m->num_preferences = htonl(count);
870  m->peer = *peer;
871  pi = (struct PreferenceInformation *)&m[1];
872  count = 0;
873  va_start(ap, peer);
874  while (GNUNET_ATS_PREFERENCE_END != (kind =
876  {
877  pi[count].preference_kind = htonl(kind);
878  switch (kind)
879  {
881  pi[count].preference_value = (float)va_arg(ap, double);
882 
883  count++;
884  break;
885 
887  pi[count].preference_value = (float)va_arg(ap, double);
888 
889  count++;
890  break;
891 
892  default:
893  GNUNET_assert(0);
894  }
895  }
896  va_end(ap);
897  GNUNET_MQ_send(ph->mq,
898  env);
899 }
struct GNUNET_PeerIdentity peer
Which peer is the preference being expressed for?
Definition: ats.h:440
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_MQ_Handle * mq
Connection to ATS service.
uint32_t preference_kind
An enum GNUNET_ATS_PreferenceKind in NBO.
Definition: ats.h:412
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
End of preference list.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:99
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
uint32_t num_preferences
How many struct PreferenceInformation entries follow this struct?
Definition: ats.h:435
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
Change the peer&#39;s latency value to the given amount.
#define GNUNET_VA_ARG_ENUM(va, X)
wrap va_arg for enums
Change the peer&#39;s bandwidth value (value per byte of bandwidth in the goal function) to the given amo...
Variable-size entry in a struct ChangePreferenceMessage or struct FeedbackPreferenceMessage.
Definition: ats.h:408
Client to ATS: I have a performance preference for a peer.
Definition: ats.h:425
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:351
GNUNET_ATS_PreferenceKind
Enum defining all known preference categories.
float preference_value
Degree of preference (or appreciation) for this preference_kind being expressed.
Definition: ats.h:418
#define GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_CHANGE
Type of the &#39;struct ChangePreferenceMessage&#39; sent by clients to ATS to ask for allocation preference ...
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_ATS_performance_give_feedback()

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

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

. now]

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

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

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

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

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

Definition at line 912 of file ats_api_performance.c.

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

916 {
917  struct GNUNET_MQ_Envelope *env;
919  uint32_t count;
920  struct PreferenceInformation *pi;
921  va_list ap;
922  enum GNUNET_ATS_PreferenceKind kind;
923 
924  if (NULL == ph->mq)
925  return;
926  count = 0;
927  va_start(ap, scope);
928  while (GNUNET_ATS_PREFERENCE_END !=
930  {
931  switch (kind)
932  {
934  count++;
935  (void)va_arg(ap, double);
936  break;
937 
939  count++;
940  (void)va_arg(ap, double);
941  break;
942 
943  default:
944  GNUNET_assert(0);
945  }
946  }
947  va_end(ap);
948  env = GNUNET_MQ_msg_extra(m,
949  count * sizeof(struct PreferenceInformation),
951  m->scope = GNUNET_TIME_relative_hton(scope);
952  m->num_feedback = htonl(count);
953  m->peer = *peer;
954  pi = (struct PreferenceInformation *)&m[1];
955  count = 0;
956  va_start(ap, scope);
957  while (GNUNET_ATS_PREFERENCE_END != (kind =
959  {
960  pi[count].preference_kind = htonl(kind);
961  switch (kind)
962  {
964  pi[count].preference_value = (float)va_arg(ap, double);
965 
966  count++;
967  break;
968 
970  pi[count].preference_value = (float)va_arg(ap, double);
971 
972  count++;
973  break;
974 
975  default:
976  GNUNET_assert(0);
977  }
978  }
979  va_end(ap);
980  GNUNET_MQ_send(ph->mq,
981  env);
982 }
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_MQ_Handle * mq
Connection to ATS service.
uint32_t preference_kind
An enum GNUNET_ATS_PreferenceKind in NBO.
Definition: ats.h:412
static struct GNUNET_PEERINFO_Handle * pi
Handle to peerinfo service.
uint32_t num_feedback
Number of feedback values included.
Definition: ats.h:459
End of preference list.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:99
#define GNUNET_MQ_msg_extra(mvar, esize, type)
Allocate an envelope, with extra space allocated after the space needed by the message struct...
Definition: gnunet_mq_lib.h:52
struct GNUNET_PeerIdentity peer
Peer this feedback is for.
Definition: ats.h:469
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_TIME_RelativeNBO GNUNET_TIME_relative_hton(struct GNUNET_TIME_Relative a)
Convert relative time to network byte order.
Definition: time.c:623
#define GNUNET_MESSAGE_TYPE_ATS_PREFERENCE_FEEDBACK
Type of the &#39;struct ChangePreferenceMessage&#39; sent by clients to ATS to ask for allocation preference ...
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
Change the peer&#39;s latency value to the given amount.
Message containing application feedback for a peer.
Definition: ats.h:450
struct GNUNET_TIME_RelativeNBO scope
Relative time describing for which time interval this feedback is.
Definition: ats.h:464
#define GNUNET_VA_ARG_ENUM(va, X)
wrap va_arg for enums
Change the peer&#39;s bandwidth value (value per byte of bandwidth in the goal function) to the given amo...
Variable-size entry in a struct ChangePreferenceMessage or struct FeedbackPreferenceMessage.
Definition: ats.h:408
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:351
GNUNET_ATS_PreferenceKind
Enum defining all known preference categories.
float preference_value
Degree of preference (or appreciation) for this preference_kind being expressed.
Definition: ats.h:418
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

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

Definition at line 482 of file ats_api2_transport.c.

References GNUNET_ATS_TransportHandle::alloc_cb, GNUNET_ATS_TransportHandle::alloc_cb_cls, GNUNET_ATS_SessionRecord::ath, GNUNET_ATS_TransportHandle::cfg, cfg, GNUNET_CONTAINER_multipeermap_create(), GNUNET_new, GNUNET_YES, reconnect(), GNUNET_ATS_TransportHandle::records, GNUNET_ATS_TransportHandle::suggest_cb, suggest_cb(), and GNUNET_ATS_TransportHandle::suggest_cb_cls.

487 {
488  struct GNUNET_ATS_TransportHandle *ath;
489 
491  ath->cfg = cfg;
492  ath->suggest_cb = suggest_cb;
494  ath->alloc_cb = alloc_cb;
495  ath->alloc_cb_cls = alloc_cb_cls;
497  GNUNET_YES);
498  reconnect(ath);
499  return ath;
500 }
void * alloc_cb_cls
Closure for alloc_cb.
static void reconnect(struct GNUNET_ATS_TransportHandle *ath)
Re-establish the connection to the ATS service.
GNUNET_ATS_AllocationCallback alloc_cb
Callback to invoke on allocations.
struct GNUNET_CONTAINER_MultiPeerMap * records
Hash map mapping PIDs to session records.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_CONTAINER_MultiPeerMap * GNUNET_CONTAINER_multipeermap_create(unsigned int len, int do_not_copy_keys)
Create a multi peer map (hash map for public keys of peers).
void * suggest_cb_cls
Closure for suggest_cb.
GNUNET_ATS_SuggestionCallback suggest_cb
Callback to invoke on suggestions.
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
static void suggest_cb(void *cls, const struct GNUNET_PeerIdentity *pid, const char *address)
Function called by the solver to prompt the transport to try out a new address.
#define GNUNET_YES
Definition: gnunet_common.h:77
Handle to the ATS subsystem for bandwidth/transport transport information.
Here is the call graph for this function:

◆ 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

Definition at line 531 of file ats_api2_transport.c.

References free_record(), GNUNET_CONTAINER_multipeermap_destroy(), GNUNET_CONTAINER_multipeermap_iterate(), GNUNET_free, GNUNET_MQ_destroy(), GNUNET_SCHEDULER_cancel(), GNUNET_ATS_TransportHandle::mq, GNUNET_ATS_TransportHandle::records, and GNUNET_ATS_TransportHandle::task.

532 {
533  if (NULL != ath->mq)
534  {
535  GNUNET_MQ_destroy(ath->mq);
536  ath->mq = NULL;
537  }
538  if (NULL != ath->task)
539  {
541  ath->task = NULL;
542  }
544  &free_record,
545  NULL);
547  GNUNET_free(ath);
548 }
struct GNUNET_CONTAINER_MultiPeerMap * records
Hash map mapping PIDs to session records.
void GNUNET_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
struct GNUNET_SCHEDULER_Task * task
Task to trigger reconnect.
static int free_record(void *cls, const struct GNUNET_PeerIdentity *pid, void *value)
Release memory associated with the session record.
int GNUNET_CONTAINER_multipeermap_iterate(struct GNUNET_CONTAINER_MultiPeerMap *map, GNUNET_CONTAINER_PeerMapIterator it, void *it_cls)
Iterate over all entries in the map.
void GNUNET_MQ_destroy(struct GNUNET_MQ_Handle *mq)
Destroy the message queue.
Definition: mq.c:821
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_MQ_Handle * mq
Message queue for sending requests to the ATS service.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:956
Here is the call graph for this function:

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

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)

Definition at line 566 of file ats_api2_transport.c.

References GNUNET_ATS_SessionRecord::address, GNUNET_ATS_SessionRecord::ath, find_session(), GNUNET_break, GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE, GNUNET_CONTAINER_multipeermap_put(), GNUNET_CRYPTO_QUALITY_WEAK, GNUNET_CRYPTO_random_u32(), GNUNET_malloc, GNUNET_MAX_MESSAGE_SIZE, GNUNET_ATS_SessionRecord::pid, GNUNET_ATS_SessionRecord::properties, GNUNET_ATS_TransportHandle::records, send_add_session_message(), GNUNET_ATS_SessionRecord::session, and GNUNET_ATS_SessionRecord::slot.

571 {
572  struct GNUNET_ATS_SessionRecord *ar;
573  uint32_t s;
574  size_t alen;
575 
576  if (NULL == address)
577  {
578  /* we need a valid address */
579  GNUNET_break(0);
580  return NULL;
581  }
582  alen = strlen(address) + 1;
583  if ((alen + sizeof(struct SessionAddMessage) >= GNUNET_MAX_MESSAGE_SIZE) ||
584  (alen >= GNUNET_MAX_MESSAGE_SIZE))
585  {
586  /* address too large for us, this should not happen */
587  GNUNET_break(0);
588  return NULL;
589  }
590 
591  /* Spin 's' until we find an unused session ID for this pid */
593  UINT32_MAX);
594  NULL != find_session(ath,
595  s,
596  pid);
597  s++)
598  ;
599 
600  alen = strlen(address) + 1;
601  ar = GNUNET_malloc(sizeof(struct GNUNET_ATS_SessionRecord) + alen);
602  ar->ath = ath;
603  ar->slot = s;
604  ar->session = session;
605  ar->address = (const char *)&ar[1];
606  ar->pid = *pid;
607  ar->properties = *prop;
608  memcpy(&ar[1],
609  address,
610  alen);
612  &ar->pid,
613  ar,
616  return ar;
617 }
struct GNUNET_PeerIdentity pid
Identity of the peer reached at address.
uint32_t GNUNET_CRYPTO_random_u32(enum GNUNET_CRYPTO_Quality mode, uint32_t i)
Produce a random value.
struct GNUNET_CONTAINER_MultiPeerMap * records
Hash map mapping PIDs to session records.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
Transport client to ATS service: here is another session you can use.
Definition: ats2.h:138
Information we track per session, incoming or outgoing.
uint32_t slot
Unique ID to identify this session at this pid in IPC messages.
static struct GNUNET_ATS_SessionRecord * find_session(struct GNUNET_ATS_TransportHandle *ath, uint32_t session_id, const struct GNUNET_PeerIdentity *pid)
Find session record for peer pid and session session_id.
struct GNUNET_ATS_TransportHandle * ath
Transport handle this session record belongs to.
struct GNUNET_ATS_Session * session
Session handle, NULL if inbound-only (also implies we cannot actually control inbound traffic via tra...
#define GNUNET_MAX_MESSAGE_SIZE
Largest supported message (to be precise, one byte more than the largest possible message...
Allow multiple values with the same key.
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.
const char * address
Address data.
struct GNUNET_ATS_Properties properties
Performance data about the session.
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
static char * address
GNS address for this phone.
static void send_add_session_message(const struct GNUNET_ATS_SessionRecord *ar)
Generate and transmit the struct SessionAddMessage for the given session record.
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
#define GNUNET_malloc(size)
Wrapper around malloc.
Here is the call graph for this function:

◆ 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

Note that this function can be called for sessiones that are currently in use as well as sessiones 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
arsession record to update information for
propperformance data for the session

Definition at line 632 of file ats_api2_transport.c.

References GNUNET_ATS_SessionRecord::address, GNUNET_ATS_SessionRecord::ath, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_MESSAGE_TYPE_ATS_SESSION_UPDATE, GNUNET_MQ_msg, GNUNET_MQ_send(), LOG, m, GNUNET_ATS_TransportHandle::mq, SessionUpdateMessage::peer, GNUNET_ATS_SessionRecord::pid, GNUNET_ATS_SessionRecord::properties, SessionUpdateMessage::properties, properties_hton(), SessionUpdateMessage::session_id, and GNUNET_ATS_SessionRecord::slot.

634 {
635  struct GNUNET_ATS_TransportHandle *ath = ar->ath;
636  struct GNUNET_MQ_Envelope *ev;
637  struct SessionUpdateMessage *m;
638 
640  "Updating address `%s' for peer `%s'\n",
641  ar->address,
642  GNUNET_i2s(&ar->pid));
643  ar->properties = *prop;
644  if (NULL == ath->mq)
645  return; /* disconnected, skip for now */
646  ev = GNUNET_MQ_msg(m,
648  m->session_id = htonl(ar->slot);
649  m->peer = ar->pid;
651  &ar->properties);
652  GNUNET_MQ_send(ath->mq,
653  ev);
654 }
struct GNUNET_PeerIdentity pid
Identity of the peer reached at address.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
static void properties_hton(struct PropertiesNBO *nbo, const struct GNUNET_ATS_Properties *hbo)
Convert ATS properties from host to network byte order.
uint32_t session_id
Internal number this client uses to refer to this session.
Definition: ats2.h:180
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:99
uint32_t slot
Unique ID to identify this session at this pid in IPC messages.
Message used to notify ATS that the performance characteristics for an session have changed...
Definition: ats2.h:171
struct GNUNET_ATS_TransportHandle * ath
Transport handle this session record belongs to.
struct GNUNET_PeerIdentity peer
Which peer is this about? (Technically redundant, as the session_id should be sufficient, but enables ATS service to find the session faster).
Definition: ats2.h:187
struct PropertiesNBO properties
Performance properties of the session.
Definition: ats2.h:192
#define GNUNET_MESSAGE_TYPE_ATS_SESSION_UPDATE
Type of the &#39;struct SessionUpdateMessage&#39; send by transport clients to ATS to inform ATS about proper...
const char * address
Address data.
struct GNUNET_ATS_Properties properties
Performance data about the session.
#define LOG(kind,...)
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:351
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Handle to the ATS subsystem for bandwidth/transport transport information.
struct GNUNET_MQ_Handle * mq
Message queue for sending requests to the ATS service.
Here is the call graph for this function:

◆ 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

Definition at line 665 of file ats_api2_transport.c.

References GNUNET_ATS_SessionRecord::address, GNUNET_ATS_SessionRecord::ath, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_MESSAGE_TYPE_ATS_SESSION_DEL, GNUNET_MQ_msg, GNUNET_MQ_send(), LOG, m, GNUNET_ATS_TransportHandle::mq, SessionDelMessage::peer, GNUNET_ATS_SessionRecord::pid, SessionDelMessage::session_id, and GNUNET_ATS_SessionRecord::slot.

666 {
667  struct GNUNET_ATS_TransportHandle *ath = ar->ath;
668  struct GNUNET_MQ_Envelope *ev;
669  struct SessionDelMessage *m;
670 
672  "Deleting address `%s' for peer `%s'\n",
673  ar->address,
674  GNUNET_i2s(&ar->pid));
675  if (NULL == ath->mq)
676  return;
677  ev = GNUNET_MQ_msg(m,
679  m->session_id = htonl(ar->slot);
680  m->peer = ar->pid;
681  GNUNET_MQ_send(ath->mq,
682  ev);
683 }
Message sent by ATS client to ATS service when an session was destroyed and must thus henceforth no l...
Definition: ats2.h:201
struct GNUNET_PeerIdentity pid
Identity of the peer reached at address.
struct GNUNET_PeerIdentity peer
Which peer is this about? (Technically redundant, as the session_id should be sufficient, but enables ATS service to find the session faster).
Definition: ats2.h:217
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:99
uint32_t slot
Unique ID to identify this session at this pid in IPC messages.
struct GNUNET_ATS_TransportHandle * ath
Transport handle this session record belongs to.
uint32_t session_id
Internal number this client uses to refer to this session.
Definition: ats2.h:210
const char * address
Address data.
#define GNUNET_MESSAGE_TYPE_ATS_SESSION_DEL
Type of the &#39;struct SessionDelMessage&#39; send by transport clients to ATS to tell ATS that a session is...
#define LOG(kind,...)
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:351
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
Handle to the ATS subsystem for bandwidth/transport transport information.
struct GNUNET_MQ_Handle * mq
Message queue for sending requests to the ATS service.
Here is the call graph for this function: