GNUnet  0.10.x
Functions
gnunet-service-ats_scheduling.h File Reference

ats service, interaction with 'scheduling' API More...

#include "gnunet_util_lib.h"
Include dependency graph for gnunet-service-ats_scheduling.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int GAS_scheduling_add_client (struct GNUNET_SERVICE_Client *client)
 Register a new scheduling client. More...
 
void GAS_scheduling_remove_client (struct GNUNET_SERVICE_Client *client)
 Unregister a client (which may have been a scheduling client, but this is not assured). More...
 
void GAS_scheduling_transmit_address_suggestion (const struct GNUNET_PeerIdentity *peer, uint32_t session_id, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out, struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in)
 Transmit the given address suggestion and bandwidth update to all scheduling clients. More...
 
void GAS_handle_address_add (const struct AddressAddMessage *m)
 Handle 'address add' messages from clients. More...
 
void GAS_handle_address_update (const struct AddressUpdateMessage *m)
 Handle 'address update' messages from clients. More...
 
void GAS_handle_address_destroyed (const struct AddressDestroyedMessage *m)
 Handle 'address destroyed' messages from clients. More...
 

Detailed Description

ats service, interaction with 'scheduling' API

Author
Matthias Wachs
Christian Grothoff

Definition in file gnunet-service-ats_scheduling.h.

Function Documentation

◆ GAS_scheduling_add_client()

int GAS_scheduling_add_client ( struct GNUNET_SERVICE_Client client)

Register a new scheduling client.

Parameters
clienthandle of the new client
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 45 of file gnunet-service-ats_scheduling.c.

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_OK, and GNUNET_SYSERR.

Referenced by handle_ats_start().

46 {
47  if (NULL != my_client)
48  {
50  "This ATS already has a scheduling client, refusing new scheduling client for now.\n");
51  return GNUNET_SYSERR;
52  }
53  my_client = client;
54  return GNUNET_OK;
55 }
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
static struct GNUNET_SERVICE_Client * my_client
Actual handle to the client.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
#define GNUNET_log(kind,...)
Here is the caller graph for this function:

◆ GAS_scheduling_remove_client()

void GAS_scheduling_remove_client ( struct GNUNET_SERVICE_Client client)

Unregister a client (which may have been a scheduling client, but this is not assured).

Parameters
clienthandle of the (now dead) client

Definition at line 65 of file gnunet-service-ats_scheduling.c.

References GAS_addresses_destroy_all().

Referenced by client_disconnect_cb().

66 {
67  if (my_client != client)
68  return;
70  my_client = NULL;
71 }
void GAS_addresses_destroy_all()
Remove all addresses.
static struct GNUNET_SERVICE_Client * my_client
Actual handle to the client.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GAS_scheduling_transmit_address_suggestion()

void GAS_scheduling_transmit_address_suggestion ( const struct GNUNET_PeerIdentity peer,
uint32_t  session_id,
struct GNUNET_BANDWIDTH_Value32NBO  bandwidth_out,
struct GNUNET_BANDWIDTH_Value32NBO  bandwidth_in 
)

Transmit the given address suggestion and bandwidth update to all scheduling clients.

Parameters
peerpeer for which this is an address suggestion
session_idsession ID to use
bandwidth_outassigned outbound bandwidth
bandwidth_inassigned inbound bandwidth
peerpeer for which this is an address suggestion
session_idsession ID to use for the given client
bandwidth_outassigned outbound bandwidth
bandwidth_inassigned inbound bandwidth

Definition at line 84 of file gnunet-service-ats_scheduling.c.

References AddressSuggestionMessage::bandwidth_in, AddressSuggestionMessage::bandwidth_out, env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_NO, GNUNET_SERVICE_client_get_mq(), GNUNET_STATISTICS_update(), GSA_stats, msg, peer, AddressSuggestionMessage::peer, AddressSuggestionMessage::session_id, and GNUNET_BANDWIDTH_Value32NBO::value__.

Referenced by bandwidth_changed_cb().

88 {
89  struct GNUNET_MQ_Envelope *env;
91 
92  if (NULL == my_client)
93  return;
95  "# address suggestions made",
96  1,
97  GNUNET_NO);
98  env = GNUNET_MQ_msg (msg,
100  msg->peer = *peer;
101  msg->session_id = htonl (session_id);
103  msg->bandwidth_in = bandwidth_in;
105  "ATS sends quota for peer `%s': (in/out) %u/%u\n",
106  GNUNET_i2s (peer),
107  (unsigned int) ntohl (bandwidth_in.value__),
108  (unsigned int) ntohl (bandwidth_out.value__));
110  env);
111 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2734
#define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION
Type of the 'struct AddressSuggestionMessage' sent by ATS to clients to suggest switching to a differ...
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
static struct GNUNET_HashCode session_id
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in
How much bandwidth we are allowed for receiving.
Definition: ats.h:276
#define GNUNET_NO
Definition: gnunet_common.h:81
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out
How much bandwidth we are allowed for sending.
Definition: ats.h:271
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
struct GNUNET_STATISTICS_Handle * GSA_stats
Handle for statistics.
uint32_t session_id
Internal number this client uses to refer to the address this suggestion is about.
Definition: ats.h:259
uint32_t value__
The actual value (bytes per second).
static struct GNUNET_SERVICE_Client * my_client
Actual handle to the client.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
ATS Service suggests to the transport service to use the address identified by the given session_id f...
Definition: ats.h:248
#define GNUNET_log(kind,...)
struct GNUNET_PeerIdentity peer
Which peer is this about? (Technically redundant, as the session_id should be sufficient, but may enable client to find the session faster and/or check consistency).
Definition: ats.h:266
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:353
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:

◆ GAS_handle_address_add()

void GAS_handle_address_add ( const struct AddressAddMessage m)

Handle 'address add' messages from clients.

Parameters
clientclient that sent the request
mthe request message
mthe request message

Definition at line 120 of file gnunet-service-ats_scheduling.c.

References address, AddressAddMessage::address_length, AddressAddMessage::address_local_info, GAS_addresses_add(), GNUNET_ATS_properties_ntoh(), GNUNET_break, GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_NO, GNUNET_NT_UNSPECIFIED, GNUNET_STATISTICS_update(), GSA_stats, AddressAddMessage::peer, plugin_name, AddressAddMessage::plugin_name_length, AddressAddMessage::properties, GNUNET_ATS_Properties::scope, and AddressAddMessage::session_id.

Referenced by handle_address_add().

121 {
122  const char *address;
123  const char *plugin_name;
124  uint16_t address_length;
125  uint16_t plugin_name_length;
126  struct GNUNET_ATS_Properties prop;
127 
129  "Received `%s' message\n",
130  "ADDRESS_ADD");
131  address_length = ntohs (m->address_length);
132  plugin_name_length = ntohs (m->plugin_name_length);
133  address = (const char *) &m[1];
134  if (plugin_name_length != 0)
135  plugin_name = &address[address_length];
136  else
137  plugin_name = "";
139  "# addresses created",
140  1,
141  GNUNET_NO);
143  &m->properties);
144  GNUNET_break (GNUNET_NT_UNSPECIFIED != prop.scope);
145  GAS_addresses_add (&m->peer,
146  plugin_name,
147  address,
148  address_length,
149  ntohl (m->address_local_info),
150  ntohl (m->session_id),
151  &prop);
152 }
uint16_t address_length
Number of bytes in the address that follows this struct.
Definition: ats.h:122
struct GNUNET_PeerIdentity peer
Identity of the peer that this address is for.
Definition: ats.h:132
struct GNUNET_ATS_PropertiesNBO properties
Performance properties of the address.
Definition: ats.h:149
#define GNUNET_NO
Definition: gnunet_common.h:81
void GAS_addresses_add(const struct GNUNET_PeerIdentity *peer, const char *plugin_name, const void *plugin_addr, size_t plugin_addr_len, uint32_t local_address_info, uint32_t session_id, const struct GNUNET_ATS_Properties *prop)
Add a new address for a peer.
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
struct GNUNET_STATISTICS_Handle * GSA_stats
Handle for statistics.
ATS performance characteristics for an address.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static char * plugin_name
Solver plugin name as string.
uint16_t plugin_name_length
Number of bytes in the plugin name that follows this struct.
Definition: ats.h:127
uint32_t address_local_info
Local-only information of the address, see enum GNUNET_HELLO_AddressInfo.
Definition: ats.h:144
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.
#define GNUNET_log(kind,...)
uint32_t session_id
Internal number this client will henceforth use to refer to this address.
Definition: ats.h:138
static char * address
GNS address for this phone.
Category of last resort.
Definition: gnunet_nt_lib.h:40
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GAS_handle_address_update()

void GAS_handle_address_update ( const struct AddressUpdateMessage m)

Handle 'address update' messages from clients.

Parameters
mthe request message

Definition at line 161 of file gnunet-service-ats_scheduling.c.

References GAS_addresses_update(), GNUNET_ATS_properties_ntoh(), GNUNET_NO, GNUNET_STATISTICS_update(), GSA_stats, AddressUpdateMessage::peer, AddressUpdateMessage::properties, and AddressUpdateMessage::session_id.

Referenced by handle_address_update().

162 {
163  struct GNUNET_ATS_Properties prop;
164 
166  "# address updates received",
167  1,
168  GNUNET_NO);
170  &m->properties);
172  ntohl (m->session_id),
173  &prop);
174 }
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:180
#define GNUNET_NO
Definition: gnunet_common.h:81
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
struct GNUNET_STATISTICS_Handle * GSA_stats
Handle for statistics.
ATS performance characteristics for an address.
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.
struct GNUNET_ATS_PropertiesNBO properties
Performance properties of the address.
Definition: ats.h:185
void GAS_addresses_update(const struct GNUNET_PeerIdentity *peer, uint32_t session_id, const struct GNUNET_ATS_Properties *prop)
Update an address with new performance information for a peer.
uint32_t session_id
Internal number this client uses to refer to this address.
Definition: ats.h:173
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GAS_handle_address_destroyed()

void GAS_handle_address_destroyed ( const struct AddressDestroyedMessage m)

Handle 'address destroyed' messages from clients.

Parameters
mthe request message

Definition at line 183 of file gnunet-service-ats_scheduling.c.

References env, GAS_addresses_destroy(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_MESSAGE_TYPE_ATS_SESSION_RELEASE, GNUNET_MQ_msg, GNUNET_MQ_send(), GNUNET_NO, GNUNET_SERVICE_client_get_mq(), GNUNET_STATISTICS_update(), GSA_stats, AddressDestroyedMessage::peer, GNUNET_ATS_SessionReleaseMessage::peer, AddressDestroyedMessage::session_id, and GNUNET_ATS_SessionReleaseMessage::session_id.

Referenced by handle_address_destroyed().

184 {
185  struct GNUNET_MQ_Envelope *env;
187 
189  "Received `%s' message\n",
190  "ADDRESS_DESTROYED");
192  "# addresses destroyed",
193  1,
194  GNUNET_NO);
196  ntohl (m->session_id));
197  env = GNUNET_MQ_msg (srm,
199  srm->session_id = m->session_id;
200  srm->peer = m->peer;
202  env);
203 }
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2734
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:212
uint32_t session_id
Number the client used to identify the session.
Definition: ats.h:231
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_NO
Definition: gnunet_common.h:81
uint32_t session_id
Internal number this client uses to refer to this address.
Definition: ats.h:205
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
struct GNUNET_STATISTICS_Handle * GSA_stats
Handle for statistics.
struct GNUNET_PeerIdentity peer
Which peer is this about? (Technically redundant, as the session_id should be sufficient, but may enable client to find the session faster).
Definition: ats.h:238
#define GNUNET_MESSAGE_TYPE_ATS_SESSION_RELEASE
Type of the 'struct SessionReleaseMessage' sent by ATS to client to confirm that a session ID was des...
static struct GNUNET_SERVICE_Client * my_client
Actual handle to the client.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
void GAS_addresses_destroy(const struct GNUNET_PeerIdentity *peer, uint32_t session_id)
Remove an address for a peer.
#define GNUNET_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:353
Message sent by ATS service to client to confirm that it is done using the given session ID...
Definition: ats.h:221
Here is the call graph for this function:
Here is the caller graph for this function: