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

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 }
static struct GNUNET_SERVICE_Client * my_client
Actual handle to the client.
#define GNUNET_log(kind,...)
@ GNUNET_OK
Definition: gnunet_common.h:95
@ GNUNET_SYSERR
Definition: gnunet_common.h:93
@ GNUNET_ERROR_TYPE_DEBUG

References GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, GNUNET_OK, GNUNET_SYSERR, and my_client.

Referenced by handle_ats_start().

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.

66 {
67  if (my_client != client)
68  return;
70  my_client = NULL;
71 }
void GAS_addresses_destroy_all()
Remove all addresses.

References GAS_addresses_destroy_all(), and my_client.

Referenced by client_disconnect_cb().

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.

91 {
92  struct GNUNET_MQ_Envelope *env;
94 
95  if (NULL == my_client)
96  return;
98  "# address suggestions made",
99  1,
100  GNUNET_NO);
101  env = GNUNET_MQ_msg (msg,
103  msg->peer = *peer;
104  msg->session_id = htonl (session_id);
105  msg->bandwidth_out = bandwidth_out;
106  msg->bandwidth_in = bandwidth_in;
108  "ATS sends quota for peer `%s': (in/out) %u/%u\n",
109  GNUNET_i2s (peer),
110  (unsigned int) ntohl (bandwidth_in.value__),
111  (unsigned int) ntohl (bandwidth_out.value__));
113  env);
114 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
struct GNUNET_STATISTICS_Handle * GSA_stats
Handle for statistics.
static struct GNUNET_HashCode session_id
@ GNUNET_NO
Definition: gnunet_common.h:94
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
void GNUNET_MQ_send(struct GNUNET_MQ_Handle *mq, struct GNUNET_MQ_Envelope *ev)
Send a message with the given message queue.
Definition: mq.c:355
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
#define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION
Type of the 'struct AddressSuggestionMessage' sent by ATS to clients to suggest switching to a differ...
struct GNUNET_MQ_Handle * GNUNET_SERVICE_client_get_mq(struct GNUNET_SERVICE_Client *c)
Obtain the message queue of c.
Definition: service.c:2438
void GNUNET_STATISTICS_update(struct GNUNET_STATISTICS_Handle *handle, const char *name, int64_t delta, int make_persistent)
Set statistic value for the peer.
ATS Service suggests to the transport service to use the address identified by the given session_id f...
Definition: ats.h:244
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_in
How much bandwidth we are allowed for receiving.
Definition: ats.h:271
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out
How much bandwidth we are allowed for sending.
Definition: ats.h:266
uint32_t value__
The actual value (bytes per second).
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.

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, my_client, peer, session_id, and GNUNET_BANDWIDTH_Value32NBO::value__.

Referenced by bandwidth_changed_cb().

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 123 of file gnunet-service-ats_scheduling.c.

124 {
125  const char *address;
126  const char *plugin_name;
127  uint16_t address_length;
128  uint16_t plugin_name_length;
129  struct GNUNET_ATS_Properties prop;
130 
132  "Received `%s' message\n",
133  "ADDRESS_ADD");
134  address_length = ntohs (m->address_length);
135  plugin_name_length = ntohs (m->plugin_name_length);
136  address = (const char *) &m[1];
137  if (plugin_name_length != 0)
138  plugin_name = &address[address_length];
139  else
140  plugin_name = "";
142  "# addresses created",
143  1,
144  GNUNET_NO);
146  &m->properties);
147  GNUNET_break (GNUNET_NT_UNSPECIFIED != prop.scope);
148  GAS_addresses_add (&m->peer,
149  plugin_name,
150  address,
151  address_length,
152  ntohl (m->address_local_info),
153  ntohl (m->session_id),
154  &prop);
155 }
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:104
static char * address
GNS address for this phone.
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.
static char * plugin_name
Name of our plugin.
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_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_NT_UNSPECIFIED
Category of last resort.
Definition: gnunet_nt_lib.h:40
ATS performance characteristics for an address.

References address, 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, m, plugin_name, and GNUNET_ATS_Properties::scope.

Referenced by handle_address_add().

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 164 of file gnunet-service-ats_scheduling.c.

165 {
166  struct GNUNET_ATS_Properties prop;
167 
169  "# address updates received",
170  1,
171  GNUNET_NO);
173  &m->properties);
174  GAS_addresses_update (&m->peer,
175  ntohl (m->session_id),
176  &prop);
177 }
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.

References GAS_addresses_update(), GNUNET_ATS_properties_ntoh(), GNUNET_NO, GNUNET_STATISTICS_update(), GSA_stats, and m.

Referenced by handle_address_update().

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 186 of file gnunet-service-ats_scheduling.c.

187 {
188  struct GNUNET_MQ_Envelope *env;
190 
192  "Received `%s' message\n",
193  "ADDRESS_DESTROYED");
195  "# addresses destroyed",
196  1,
197  GNUNET_NO);
198  GAS_addresses_destroy (&m->peer,
199  ntohl (m->session_id));
200  env = GNUNET_MQ_msg (srm,
202  srm->session_id = m->session_id;
203  srm->peer = m->peer;
205  env);
206 }
void GAS_addresses_destroy(const struct GNUNET_PeerIdentity *peer, uint32_t session_id)
Remove an address for a peer.
#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...
Message sent by ATS service to client to confirm that it is done using the given session ID.
Definition: ats.h:218
struct GNUNET_PeerIdentity peer
Which peer is this about? (Technically redundant, as the session_id should be sufficient,...
Definition: ats.h:234
uint32_t session_id
Number the client used to identify the session.
Definition: ats.h:227

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, m, my_client, GNUNET_ATS_SessionReleaseMessage::peer, and GNUNET_ATS_SessionReleaseMessage::session_id.

Referenced by handle_address_destroyed().

Here is the call graph for this function:
Here is the caller graph for this function: