GNUnet  0.10.x
Data Structures | Enumerations | Functions | Variables
gnunet-service-ats-new.c File Reference

ats service More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_statistics_service.h"
#include "gnunet_ats_plugin_new.h"
#include "ats2.h"
Include dependency graph for gnunet-service-ats-new.c:

Go to the source code of this file.

Data Structures

struct  ClientPreference
 Preferences expressed by a client are kept in a DLL per client. More...
 
struct  GNUNET_ATS_Session
 Information about ongoing sessions of the transport client. More...
 
struct  Client
 Information we track per client. More...
 

Enumerations

enum  ClientType {
  CT_NONE = 0, CT_TRANSPORT, CT_APPLICATION, CT_NONE = 0,
  CT_CORE = 1, CT_MONITOR = 2, CT_COMMUNICATOR = 3, CT_APPLICATION = 4,
  CT_NONE = 0, CT_CORE = 1, CT_MONITOR = 2, CT_BLACKLIST = 3,
  CT_CORE_NO_HANDLERS = 4
}
 What type of client is this client? More...
 

Functions

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. More...
 
static void allocate_cb (void *cls, struct GNUNET_ATS_Session *session, const struct GNUNET_PeerIdentity *peer, struct GNUNET_BANDWIDTH_Value32NBO bw_in, struct GNUNET_BANDWIDTH_Value32NBO bw_out)
 Function called by the solver to tell the transpor to allocate bandwidth for the specified session. More...
 
static void prop_ntoh (const struct PropertiesNBO *properties, struct GNUNET_ATS_Properties *prop)
 Convert properties to prop. More...
 
static void handle_suggest (void *cls, const struct ExpressPreferenceMessage *msg)
 We have received a struct ExpressPreferenceMessage from an application client. More...
 
static void handle_suggest_cancel (void *cls, const struct ExpressPreferenceMessage *msg)
 We have received a struct ExpressPreferenceMessage from an application client. More...
 
static void handle_start (void *cls, const struct GNUNET_MessageHeader *hdr)
 Handle 'start' messages from transport clients. More...
 
static int check_session_add (void *cls, const struct SessionAddMessage *message)
 Check 'session_add' message is well-formed and comes from a transport client. More...
 
static void handle_session_add (void *cls, const struct SessionAddMessage *message)
 Handle 'session add' messages from transport clients. More...
 
static void handle_session_update (void *cls, const struct SessionUpdateMessage *msg)
 Handle 'session update' messages from transport clients. More...
 
static void handle_session_del (void *cls, const struct SessionDelMessage *message)
 Handle 'session delete' messages from transport clients. More...
 
static void * client_connect_cb (void *cls, struct GNUNET_SERVICE_Client *client, struct GNUNET_MQ_Handle *mq)
 A client connected to us. More...
 
static int free_session (void *cls, uint32_t key, void *value)
 Function called on each session to release associated state on transport disconnect. More...
 
static void client_disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *client, void *app_ctx)
 A client disconnected from us. More...
 
static void final_cleanup (void *cls)
 Task run at the end during shutdown. More...
 
static void cleanup_task (void *cls)
 Task run during shutdown. More...
 
static void run (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg, struct GNUNET_SERVICE_Handle *service)
 Process template requests. More...
 
 GNUNET_SERVICE_MAIN ("ats", GNUNET_SERVICE_OPTION_NONE, &run, &client_connect_cb, &client_disconnect_cb, NULL, GNUNET_MQ_hd_fixed_size(suggest, GNUNET_MESSAGE_TYPE_ATS_SUGGEST, struct ExpressPreferenceMessage, NULL), GNUNET_MQ_hd_fixed_size(suggest_cancel, GNUNET_MESSAGE_TYPE_ATS_SUGGEST_CANCEL, struct ExpressPreferenceMessage, NULL), GNUNET_MQ_hd_fixed_size(start, GNUNET_MESSAGE_TYPE_ATS_START, struct GNUNET_MessageHeader, NULL), GNUNET_MQ_hd_var_size(session_add, GNUNET_MESSAGE_TYPE_ATS_SESSION_ADD, struct SessionAddMessage, NULL), GNUNET_MQ_hd_var_size(session_add, GNUNET_MESSAGE_TYPE_ATS_SESSION_ADD_INBOUND_ONLY, struct SessionAddMessage, NULL), GNUNET_MQ_hd_fixed_size(session_update, GNUNET_MESSAGE_TYPE_ATS_SESSION_UPDATE, struct SessionUpdateMessage, NULL), GNUNET_MQ_hd_fixed_size(session_del, GNUNET_MESSAGE_TYPE_ATS_SESSION_DEL, struct SessionDelMessage, NULL), GNUNET_MQ_handler_end())
 Define "main" method using service macro. More...
 

Variables

static struct GNUNET_STATISTICS_Handlestats
 Handle for statistics. More...
 
static struct GNUNET_ATS_SolverFunctionsplugin
 Our solver. More...
 
static char * plugin_name
 Solver plugin name as string. More...
 
static struct Clienttransport_client
 The transport client (there can only be one at a time). More...
 

Detailed Description

ats service

Author
Matthias Wachs
Christian Grothoff

Definition in file gnunet-service-ats-new.c.

Enumeration Type Documentation

◆ ClientType

enum ClientType

What type of client is this client?

Enumerator
CT_NONE 

We don't know yet.

CT_TRANSPORT 

Transport service.

CT_APPLICATION 

Application.

CT_NONE 

We do not know yet (client is fresh).

CT_CORE 

Is the CORE service, we need to forward traffic to it.

CT_MONITOR 

It is a monitor, forward monitor data.

CT_COMMUNICATOR 

It is a communicator, use for communication.

CT_APPLICATION 

"Application" telling us where to connect (i.e.

TOPOLOGY, DHT or CADET).

CT_NONE 

We do not know yet (client is fresh).

CT_CORE 

Is the CORE service, we need to forward traffic to it.

CT_MONITOR 

It is a monitor, forward monitor data.

CT_BLACKLIST 

It is a blacklist, query about allowed connections.

CT_CORE_NO_HANDLERS 

CORE client without any handlers.

Definition at line 36 of file gnunet-service-ats-new.c.

36  {
40  CT_NONE = 0,
41 
46 
51 };
We don't know yet.
Transport service.

Function Documentation

◆ suggest_cb()

static void suggest_cb ( void *  cls,
const struct GNUNET_PeerIdentity pid,
const char *  address 
)
static

Function called by the solver to prompt the transport to try out a new address.

Parameters
clsclosure, NULL
pidpeer this is about
addressaddress the transport should try

Definition at line 191 of file gnunet-service-ats-new.c.

References env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), Client::mq, AddressSuggestionMessage::peer, and pid.

Referenced by GNUNET_ATS_scheduling_init(), GNUNET_ATS_transport_init(), and run().

194 {
195  struct GNUNET_MQ_Envelope *env;
196  size_t slen = strlen(address) + 1;
197  struct AddressSuggestionMessage *as;
198 
199  if (NULL == transport_client)
200  {
201  // FIXME: stats!
202  return;
203  }
205  "Suggesting address `%s' of peer `%s'\n",
206  address,
207  GNUNET_i2s(pid));
208  env = GNUNET_MQ_msg_extra(as,
209  slen,
211  as->peer = *pid;
212  memcpy(&as[1],
213  address,
214  slen);
216  env);
217 }
struct GNUNET_MQ_Handle * mq
Message queue to talk to the client.
#define GNUNET_MESSAGE_TYPE_ATS_ADDRESS_SUGGESTION
Type of the 'struct AddressSuggestionMessage' sent by ATS to clients to suggest switching to a differ...
static struct Client * transport_client
The transport client (there can only be one at a time).
#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_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:237
#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:254
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
static struct GNUNET_PeerIdentity pid
Identity of the peer we transmit to / connect to.
static char * address
GNS address for this phone.
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:

◆ allocate_cb()

static void allocate_cb ( void *  cls,
struct GNUNET_ATS_Session session,
const struct GNUNET_PeerIdentity peer,
struct GNUNET_BANDWIDTH_Value32NBO  bw_in,
struct GNUNET_BANDWIDTH_Value32NBO  bw_out 
)
static

Function called by the solver to tell the transpor to allocate bandwidth for the specified session.

Parameters
clsclosure, NULL
sessionsession this is about
peerpeer this is about
bw_insuggested bandwidth for receiving
bw_outsuggested bandwidth for transmission

Definition at line 231 of file gnunet-service-ats-new.c.

References SessionAllocationMessage::bandwidth_in, SessionAllocationMessage::bandwidth_out, GNUNET_ATS_Session::client, env, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_ATS_SESSION_ALLOCATION, GNUNET_MQ_msg, GNUNET_MQ_send(), Client::mq, peer, SessionAllocationMessage::peer, GNUNET_ATS_Session::session_id, SessionAllocationMessage::session_id, transport_client, and GNUNET_BANDWIDTH_Value32NBO::value__.

Referenced by run().

236 {
237  struct GNUNET_MQ_Envelope *env;
238  struct SessionAllocationMessage *sam;
239 
240  (void)cls;
241  if ((NULL == transport_client) ||
242  (session->client != transport_client))
243  {
244  /* transport must have just died and solver is addressing the
245  losses of sessions (possibly of previous transport), ignore! */
246  return;
247  }
249  "Allocating %u/%u bytes for %p of peer `%s'\n",
250  ntohl(bw_in.value__),
251  ntohl(bw_out.value__),
252  session,
253  GNUNET_i2s(peer));
254  env = GNUNET_MQ_msg(sam,
256  sam->session_id = session->session_id;
257  sam->peer = *peer;
258  sam->bandwidth_in = bw_in;
259  sam->bandwidth_out = bw_out;
261  env);
262 }
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: ats2.h:243
uint32_t session_id
Unique ID for the session when talking with the client.
struct GNUNET_MQ_Handle * mq
Message queue to talk to the client.
#define GNUNET_MQ_msg(mvar, type)
Allocate a GNUNET_MQ_Envelope.
Definition: gnunet_mq_lib.h:67
static struct Client * transport_client
The transport client (there can only be one at a time).
#define GNUNET_MESSAGE_TYPE_ATS_SESSION_ALLOCATION
Type of the 'struct SessionAllocationMessage' send by ATS to the transport to tell it about resources...
uint32_t value__
The actual value (bytes per second).
ATS Service allocates resources to an session identified by the given session_id for the given peer w...
Definition: ats2.h:226
struct GNUNET_BANDWIDTH_Value32NBO bandwidth_out
How much bandwidth we are allowed for sending.
Definition: ats2.h:248
uint32_t session_id
Internal number this client uses to refer to the session this suggestion is about.
Definition: ats2.h:236
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
#define GNUNET_log(kind,...)
struct Client * client
The transport client that provided the session.
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_BANDWIDTH_Value32NBO bandwidth_in
How much bandwidth we are allowed for receiving.
Definition: ats2.h:253
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:

◆ prop_ntoh()

static void prop_ntoh ( const struct PropertiesNBO properties,
struct GNUNET_ATS_Properties prop 
)
static

Convert properties to prop.

Parameters
propertiesin NBO
prop[out]in HBO

Definition at line 272 of file gnunet-service-ats-new.c.

References GNUNET_ATS_Properties::cc, PropertiesNBO::cc, PropertiesNBO::delay, GNUNET_ATS_Properties::delay, PropertiesNBO::distance, GNUNET_ATS_Properties::distance, GNUNET_TIME_relative_ntoh(), PropertiesNBO::goodput_in, GNUNET_ATS_Properties::goodput_in, PropertiesNBO::goodput_out, GNUNET_ATS_Properties::goodput_out, PropertiesNBO::mtu, GNUNET_ATS_Properties::mtu, PropertiesNBO::nt, GNUNET_ATS_Properties::nt, PropertiesNBO::utilization_in, GNUNET_ATS_Properties::utilization_in, PropertiesNBO::utilization_out, and GNUNET_ATS_Properties::utilization_out.

Referenced by handle_session_add(), and handle_session_update().

274 {
275  prop->delay = GNUNET_TIME_relative_ntoh(properties->delay);
276  prop->goodput_out = ntohl(properties->goodput_out);
277  prop->goodput_in = ntohl(properties->goodput_in);
278  prop->utilization_out = ntohl(properties->utilization_out);
279  prop->utilization_in = ntohl(properties->utilization_in);
280  prop->distance = ntohl(properties->distance);
281  prop->mtu = ntohl(properties->mtu);
282  prop->nt = (enum GNUNET_NetworkType)ntohl(properties->nt);
283  prop->cc = (enum GNUNET_TRANSPORT_CommunicatorCharacteristics)ntohl(properties->cc);
284 }
GNUNET_TRANSPORT_CommunicatorCharacteristics
What characteristics does this communicator have?
uint32_t cc
What characteristics does this communicator have? A enum GNUNET_TRANSPORT_CommunicatorCharacteristics...
Definition: ats2.h:101
uint32_t utilization_in
Actual traffic on this connection from the other peer to this peer.
Definition: ats2.h:76
uint32_t goodput_out
Confirmed successful payload on this connection from this peer to the other peer. ...
uint32_t utilization_in
Actual traffic on this connection from the other peer to this peer.
enum GNUNET_TRANSPORT_CommunicatorCharacteristics cc
What characteristics does this communicator have?
uint32_t goodput_out
Confirmed successful payload on this connection from this peer to the other peer. ...
Definition: ats2.h:52
GNUNET_NetworkType
Types of networks (with separate quotas) we support.
Definition: gnunet_nt_lib.h:35
uint32_t utilization_out
Actual traffic on this connection from this peer to the other peer.
Definition: ats2.h:68
uint32_t mtu
MTU of the network layer, UINT32_MAX for no MTU (stream).
Definition: ats2.h:89
uint32_t distance
Distance on network layer (required for distance-vector routing) in hops.
Definition: ats2.h:82
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 goodput_in
Confirmed useful payload on this connection to this peer from the other peer.
uint32_t mtu
MTU of the network layer, UINT32_MAX for no MTU (stream).
uint32_t nt
Which network scope does the respective address belong to? A enum GNUNET_NetworkType nt in NBO...
Definition: ats2.h:95
enum GNUNET_NetworkType nt
Which network scope does the respective address belong to?
struct GNUNET_TIME_RelativeNBO delay
Delay.
Definition: ats2.h:44
uint32_t goodput_in
Confirmed useful payload on this connection to this peer from the other peer.
Definition: ats2.h:60
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:

◆ handle_suggest()

static void handle_suggest ( void *  cls,
const struct ExpressPreferenceMessage msg 
)
static

We have received a struct ExpressPreferenceMessage from an application client.

Parameters
clshandle to the client
msgthe start message

Definition at line 294 of file gnunet-service-ats-new.c.

References Client::application, ExpressPreferenceMessage::bw, GNUNET_ATS_Preference::bw, ClientPreference::client, Client::client, GNUNET_ATS_SolverFunctions::cls, CT_APPLICATION, CT_NONE, Client::details, GNUNET_break, GNUNET_CONTAINER_DLL_insert, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_new, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), ExpressPreferenceMessage::peer, GNUNET_ATS_Preference::peer, ClientPreference::ph, ExpressPreferenceMessage::pk, GNUNET_ATS_Preference::pk, ClientPreference::pref, GNUNET_ATS_SolverFunctions::preference_add, Client::type, and GNUNET_BANDWIDTH_Value32NBO::value__.

296 {
297  struct Client *c = cls;
298  struct ClientPreference *cp;
299 
300  if (CT_NONE == c->type)
301  c->type = CT_APPLICATION;
302  if (CT_APPLICATION != c->type)
303  {
304  GNUNET_break(0);
306  return;
307  }
309  "Client suggested we talk to %s with preference %d at rate %u\n",
310  GNUNET_i2s(&msg->peer),
311  (int)ntohl(msg->pk),
312  (int)ntohl(msg->bw.value__));
313  cp = GNUNET_new(struct ClientPreference);
314  cp->client = c;
315  cp->pref.peer = msg->peer;
316  cp->pref.bw = msg->bw;
317  cp->pref.pk = (enum GNUNET_MQ_PreferenceKind)ntohl(msg->pk);
319  &cp->pref);
321  c->details.application.cp_tail,
322  cp);
324 }
Information we track per client.
#define GNUNET_CONTAINER_DLL_insert(head, tail, element)
Insert an element at the head of a DLL.
We don't know yet.
struct GNUNET_SERVICE_Client * client
Service handle of the client.
enum GNUNET_MQ_PreferenceKind pk
What type of performance preference does the client have?
struct Client * client
Which client expressed the preference?
#define GNUNET_new(type)
Allocate a struct or union of the given type.
Preferences expressed by a client are kept in a DLL per client.
struct Client::@0::@1 application
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
uint32_t value__
The actual value (bytes per second).
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_ATS_SolverFunctions * plugin
Our solver.
GNUNET_MQ_PreferenceKind
Enum defining all known preference categories.
struct GNUNET_ATS_PreferenceHandle *(* preference_add)(void *cls, const struct GNUNET_ATS_Preference *pref)
The plugin should begin to respect a new preference.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2315
struct GNUNET_BANDWIDTH_Value32NBO bw
How much bandwidth in bytes/second does the application expect?
void * cls
Closure to pass to all solver functions in this struct.
enum ClientType type
Type of the client, initially CT_NONE.
struct GNUNET_ATS_Preference pref
Details about the preference.
struct GNUNET_ATS_PreferenceHandle * ph
Plugin's representation of the preference.
#define GNUNET_log(kind,...)
union Client::@0 details
Details depending on type.
struct GNUNET_PeerIdentity peer
Peer to get address suggestions for.
struct GNUNET_BANDWIDTH_Value32NBO bw
How much bandwidth in bytes/second does the application expect?
Definition: ats2.h:131
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2234
struct GNUNET_PeerIdentity peer
Peer to get address suggestions for.
Definition: ats2.h:126
Here is the call graph for this function:

◆ handle_suggest_cancel()

static void handle_suggest_cancel ( void *  cls,
const struct ExpressPreferenceMessage msg 
)
static

We have received a struct ExpressPreferenceMessage from an application client.

Parameters
clshandle to the client
msgthe start message

Definition at line 334 of file gnunet-service-ats-new.c.

References Client::application, ExpressPreferenceMessage::bw, GNUNET_ATS_Preference::bw, Client::client, GNUNET_ATS_SolverFunctions::cls, CT_APPLICATION, CT_NONE, Client::details, GNUNET_break, GNUNET_CONTAINER_DLL_remove, GNUNET_free, GNUNET_memcmp, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), ClientPreference::next, ExpressPreferenceMessage::peer, GNUNET_ATS_Preference::peer, ClientPreference::ph, ExpressPreferenceMessage::pk, GNUNET_ATS_Preference::pk, ClientPreference::pref, GNUNET_ATS_SolverFunctions::preference_del, Client::type, and GNUNET_BANDWIDTH_Value32NBO::value__.

336 {
337  struct Client *c = cls;
338  struct ClientPreference *cp;
339 
340  if (CT_NONE == c->type)
341  c->type = CT_APPLICATION;
342  if (CT_APPLICATION != c->type)
343  {
344  GNUNET_break(0);
346  return;
347  }
348  for (cp = c->details.application.cp_head;
349  NULL != cp;
350  cp = cp->next)
351  if ((cp->pref.pk == (enum GNUNET_MQ_PreferenceKind)ntohl(msg->pk)) &&
352  (cp->pref.bw.value__ == msg->bw.value__) &&
353  (0 == GNUNET_memcmp(&cp->pref.peer,
354  &msg->peer)))
355  break;
356  if (NULL == cp)
357  {
358  GNUNET_break(0);
360  return;
361  }
363  cp->ph,
364  &cp->pref);
366  c->details.application.cp_tail,
367  cp);
368  GNUNET_free(cp);
370 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
Information we track per client.
We don't know yet.
struct GNUNET_SERVICE_Client * client
Service handle of the client.
enum GNUNET_MQ_PreferenceKind pk
What type of performance preference does the client have?
Preferences expressed by a client are kept in a DLL per client.
struct Client::@0::@1 application
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
uint32_t value__
The actual value (bytes per second).
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_ATS_SolverFunctions * plugin
Our solver.
GNUNET_MQ_PreferenceKind
Enum defining all known preference categories.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2315
struct GNUNET_BANDWIDTH_Value32NBO bw
How much bandwidth in bytes/second does the application expect?
void * cls
Closure to pass to all solver functions in this struct.
#define GNUNET_memcmp(a, b)
Compare memory in a and b, where both must be of the same pointer type.
enum ClientType type
Type of the client, initially CT_NONE.
struct GNUNET_ATS_Preference pref
Details about the preference.
struct GNUNET_ATS_PreferenceHandle * ph
Plugin's representation of the preference.
void(* preference_del)(void *cls, struct GNUNET_ATS_PreferenceHandle *ph, const struct GNUNET_ATS_Preference *pref)
The plugin should end respecting a preference.
struct ClientPreference * next
DLL pointer.
union Client::@0 details
Details depending on type.
struct GNUNET_PeerIdentity peer
Peer to get address suggestions for.
struct GNUNET_BANDWIDTH_Value32NBO bw
How much bandwidth in bytes/second does the application expect?
Definition: ats2.h:131
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2234
#define GNUNET_free(ptr)
Wrapper around free.
struct GNUNET_PeerIdentity peer
Peer to get address suggestions for.
Definition: ats2.h:126
Here is the call graph for this function:

◆ handle_start()

static void handle_start ( void *  cls,
const struct GNUNET_MessageHeader hdr 
)
static

Handle 'start' messages from transport clients.

Parameters
clsclient that sent the request
messagethe request message

Definition at line 380 of file gnunet-service-ats-new.c.

References Client::client, CT_NONE, CT_TRANSPORT, Client::details, GNUNET_break, GNUNET_CONTAINER_multihashmap32_create(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), Client::transport, and Client::type.

382 {
383  struct Client *c = cls;
384 
385  if (CT_NONE != c->type)
386  {
387  GNUNET_break(0);
389  return;
390  }
391  c->type = CT_TRANSPORT;
392  c->details.transport.sessions
394  if (NULL != transport_client)
395  {
397  transport_client = NULL;
398  }
399  transport_client = c;
401 }
struct Client::@0::@2 transport
Information we track per client.
We don't know yet.
struct GNUNET_SERVICE_Client * client
Service handle of the client.
Transport service.
static struct Client * transport_client
The transport client (there can only be one at a time).
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2315
struct GNUNET_CONTAINER_MultiHashMap32 * GNUNET_CONTAINER_multihashmap32_create(unsigned int len)
Create a 32-bit key multi hash map.
enum ClientType type
Type of the client, initially CT_NONE.
union Client::@0 details
Details depending on type.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2234
Here is the call graph for this function:

◆ check_session_add()

static int check_session_add ( void *  cls,
const struct SessionAddMessage message 
)
static

Check 'session_add' message is well-formed and comes from a transport client.

Parameters
clsclient that sent the request
messagethe request message
Returns
GNUNET_OK if message is well-formed

Definition at line 413 of file gnunet-service-ats-new.c.

References CT_TRANSPORT, GNUNET_break, GNUNET_MQ_check_zero_termination, GNUNET_OK, GNUNET_SYSERR, and Client::type.

415 {
416  struct Client *c = cls;
417 
419  if (CT_TRANSPORT != c->type)
420  {
421  GNUNET_break(0);
422  return GNUNET_SYSERR;
423  }
424  return GNUNET_OK;
425 }
Information we track per client.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
Transport service.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_MQ_check_zero_termination(m)
Insert code for a "check_" function that verifies that a given variable-length message received over ...
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
enum ClientType type
Type of the client, initially CT_NONE.

◆ handle_session_add()

static void handle_session_add ( void *  cls,
const struct SessionAddMessage message 
)
static

Handle 'session add' messages from transport clients.

Parameters
clsclient that sent the request
messagethe request message

Definition at line 435 of file gnunet-service-ats-new.c.

References address, GNUNET_ATS_Session::client, Client::client, GNUNET_ATS_SolverFunctions::cls, GNUNET_ATS_Session::data, Client::details, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_multihashmap32_get(), GNUNET_CONTAINER_multihashmap32_put(), GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY, GNUNET_ERROR_TYPE_DEBUG, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_ATS_SESSION_ADD_INBOUND_ONLY, GNUNET_new, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_YES, SessionAddMessage::header, inbound_only, GNUNET_ATS_SessionData::inbound_only, SessionAddMessage::peer, GNUNET_ATS_SessionData::peer, GNUNET_ATS_SessionData::prop, prop_ntoh(), SessionAddMessage::properties, GNUNET_ATS_SessionData::session, GNUNET_ATS_SolverFunctions::session_add, GNUNET_ATS_Session::session_id, SessionAddMessage::session_id, GNUNET_ATS_Session::sh, Client::transport, and GNUNET_MessageHeader::type.

437 {
438  struct Client *c = cls;
439  const char *address = (const char *)&message[1];
440  struct GNUNET_ATS_Session *session;
442  ntohs(message->header.type));
443 
445  message->session_id);
446  if (NULL != session)
447  {
448  GNUNET_break(0);
450  return;
451  }
452  session = GNUNET_new(struct GNUNET_ATS_Session);
453  session->data.session = session;
454  session->client = c;
455  session->session_id = message->session_id;
456  session->data.peer = message->peer;
457  prop_ntoh(&message->properties,
458  &session->data.prop);
459  session->data.inbound_only = inbound_only;
462  message->session_id,
463  session,
465  session->sh = plugin->session_add(plugin->cls,
466  &session->data,
467  address);
468  GNUNET_assert(NULL != session->sh);
470  "Transport has new session %p to %s\n",
471  session,
472  GNUNET_i2s(&message->peer));
474 }
struct Client::@0::@2 transport
Information we track per client.
struct GNUNET_ATS_Session * session
Handle to the session that has the given properties.
struct GNUNET_SERVICE_Client * client
Service handle of the client.
uint32_t session_id
Internal number this client will henceforth use to refer to this session.
Definition: ats2.h:149
uint32_t session_id
Unique ID for the session when talking with the client.
struct GNUNET_ATS_SessionHandle * sh
Session state in the plugin.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_PeerIdentity peer
Peer the session is with.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
int GNUNET_CONTAINER_multihashmap32_put(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, void *value, enum GNUNET_CONTAINER_MultiHashMapOption opt)
Store a key-value pair in the map.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
#define GNUNET_MESSAGE_TYPE_ATS_SESSION_ADD_INBOUND_ONLY
Type of the 'struct SessionAddMessage' send by transport clients to ATS to inform ATS about a session...
static int inbound_only
Option -i.
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
uint16_t type
The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
struct GNUNET_MessageHeader header
Type is GNUNET_MESSAGE_TYPE_ATS_SESSION_ADD or GNUNET_MESSAGE_TYPE_ATS_SESSION_ADD_INBOUND_ONLY.
Definition: ats2.h:143
Information about ongoing sessions of the transport client.
void * GNUNET_CONTAINER_multihashmap32_get(const struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key)
Given a key find a value in the map matching the key.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2315
struct GNUNET_ATS_SessionHandle *(* session_add)(void *cls, const struct GNUNET_ATS_SessionData *data, const char *address)
Transport established a new session with performance characteristics given in data.
There must only be one value per key; storing a value should fail if a value under the same key alrea...
int inbound_only
Is the session inbound only?
void * cls
Closure to pass to all solver functions in this struct.
struct GNUNET_PeerIdentity peer
Identity of the peer that this session is for.
Definition: ats2.h:154
struct GNUNET_ATS_SessionData data
Session data exposed to the plugin.
#define GNUNET_log(kind,...)
static void prop_ntoh(const struct PropertiesNBO *properties, struct GNUNET_ATS_Properties *prop)
Convert properties to prop.
struct Client * client
The transport client that provided the session.
#define GNUNET_YES
Definition: gnunet_common.h:77
union Client::@0 details
Details depending on type.
static char * address
GNS address for this phone.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2234
struct PropertiesNBO properties
Performance properties of the session.
Definition: ats2.h:159
struct GNUNET_ATS_Properties prop
ATS performance characteristics for a session.
Here is the call graph for this function:

◆ handle_session_update()

static void handle_session_update ( void *  cls,
const struct SessionUpdateMessage msg 
)
static

Handle 'session update' messages from transport clients.

Parameters
clsclient that sent the request
msgthe request message

Definition at line 484 of file gnunet-service-ats-new.c.

References Client::client, GNUNET_ATS_SolverFunctions::cls, CT_TRANSPORT, GNUNET_ATS_Session::data, Client::details, GNUNET_break, GNUNET_CONTAINER_multihashmap32_get(), GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_ATS_SessionData::prop, prop_ntoh(), SessionUpdateMessage::properties, SessionUpdateMessage::session_id, GNUNET_ATS_SolverFunctions::session_update, GNUNET_ATS_Session::sh, Client::transport, and Client::type.

486 {
487  struct Client *c = cls;
488  struct GNUNET_ATS_Session *session;
489 
490  if (CT_TRANSPORT != c->type)
491  {
492  GNUNET_break(0);
494  return;
495  }
497  msg->session_id);
498  if (NULL == session)
499  {
500  GNUNET_break(0);
502  return;
503  }
504  prop_ntoh(&msg->properties,
505  &session->data.prop);
507  session->sh,
508  &session->data);
510 }
struct Client::@0::@2 transport
Information we track per client.
struct GNUNET_SERVICE_Client * client
Service handle of the client.
void(* session_update)(void *cls, struct GNUNET_ATS_SessionHandle *sh, const struct GNUNET_ATS_SessionData *data)
data changed for a given sh, solver should consider the updated performance characteristics.
struct GNUNET_ATS_SessionHandle * sh
Session state in the plugin.
Transport service.
uint32_t session_id
Internal number this client uses to refer to this session.
Definition: ats2.h:180
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
Information about ongoing sessions of the transport client.
void * GNUNET_CONTAINER_multihashmap32_get(const struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key)
Given a key find a value in the map matching the key.
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2315
struct PropertiesNBO properties
Performance properties of the session.
Definition: ats2.h:192
void * cls
Closure to pass to all solver functions in this struct.
enum ClientType type
Type of the client, initially CT_NONE.
struct GNUNET_ATS_SessionData data
Session data exposed to the plugin.
static void prop_ntoh(const struct PropertiesNBO *properties, struct GNUNET_ATS_Properties *prop)
Convert properties to prop.
union Client::@0 details
Details depending on type.
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2234
struct GNUNET_ATS_Properties prop
ATS performance characteristics for a session.
Here is the call graph for this function:

◆ handle_session_del()

static void handle_session_del ( void *  cls,
const struct SessionDelMessage message 
)
static

Handle 'session delete' messages from transport clients.

Parameters
clsclient that sent the request
messagethe request message

Definition at line 520 of file gnunet-service-ats-new.c.

References Client::client, GNUNET_ATS_SolverFunctions::cls, CT_TRANSPORT, GNUNET_ATS_Session::data, Client::details, GNUNET_assert, GNUNET_break, GNUNET_CONTAINER_multihashmap32_get(), GNUNET_CONTAINER_multihashmap32_remove(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, GNUNET_i2s(), GNUNET_log, GNUNET_SERVICE_client_continue(), GNUNET_SERVICE_client_drop(), GNUNET_YES, GNUNET_ATS_SessionData::peer, GNUNET_ATS_SolverFunctions::session_del, GNUNET_ATS_Session::session_id, SessionDelMessage::session_id, GNUNET_ATS_Session::sh, Client::transport, and Client::type.

522 {
523  struct Client *c = cls;
524  struct GNUNET_ATS_Session *session;
525 
526  if (CT_TRANSPORT != c->type)
527  {
528  GNUNET_break(0);
530  return;
531  }
533  message->session_id);
534  if (NULL == session)
535  {
536  GNUNET_break(0);
538  return;
539  }
540  GNUNET_assert(NULL != session->sh);
542  session->sh,
543  &session->data);
544  session->sh = NULL;
547  session->session_id,
548  session));
550  "Transport lost session %p to %s\n",
551  session,
552  GNUNET_i2s(&session->data.peer));
553  GNUNET_free(session);
555 }
struct Client::@0::@2 transport
Information we track per client.
struct GNUNET_SERVICE_Client * client
Service handle of the client.
uint32_t session_id
Unique ID for the session when talking with the client.
struct GNUNET_ATS_SessionHandle * sh
Session state in the plugin.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_PeerIdentity peer
Peer the session is with.
Transport service.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur...
void(* session_del)(void *cls, struct GNUNET_ATS_SessionHandle *sh, const struct GNUNET_ATS_SessionData *data)
A session went away.
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
int GNUNET_CONTAINER_multihashmap32_remove(struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key, const void *value)
Remove the given key-value pair from the map.
Information about ongoing sessions of the transport client.
void * GNUNET_CONTAINER_multihashmap32_get(const struct GNUNET_CONTAINER_MultiHashMap32 *map, uint32_t key)
Given a key find a value in the map matching the key.
uint32_t session_id
Internal number this client uses to refer to this session.
Definition: ats2.h:210
void GNUNET_SERVICE_client_drop(struct GNUNET_SERVICE_Client *c)
Ask the server to disconnect from the given client.
Definition: service.c:2315
void * cls
Closure to pass to all solver functions in this struct.
enum ClientType type
Type of the client, initially CT_NONE.
struct GNUNET_ATS_SessionData data
Session data exposed to the plugin.
#define GNUNET_log(kind,...)
#define GNUNET_YES
Definition: gnunet_common.h:77
union Client::@0 details
Details depending on type.
const char * GNUNET_i2s(const struct GNUNET_PeerIdentity *pid)
Convert a peer identity to a string (for printing debug messages).
void GNUNET_SERVICE_client_continue(struct GNUNET_SERVICE_Client *c)
Continue receiving further messages from the given client.
Definition: service.c:2234
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:

◆ client_connect_cb()

static void* client_connect_cb ( void *  cls,
struct GNUNET_SERVICE_Client client,
struct GNUNET_MQ_Handle mq 
)
static

A client connected to us.

Setup the local client record.

Parameters
clsunused
clienthandle of the client
mqmessage queue to talk to client
Returns
client

Definition at line 568 of file gnunet-service-ats-new.c.

References ClientPreference::client, Client::client, GNUNET_new, mq, and Client::mq.

Referenced by run().

571 {
572  struct Client *c = GNUNET_new(struct Client);
573 
574  c->client = client;
575  c->mq = mq;
576  return c;
577 }
Information we track per client.
struct GNUNET_SERVICE_Client * client
Service handle of the client.
struct GNUNET_MQ_Handle * mq
Message queue to talk to the client.
#define GNUNET_new(type)
Allocate a struct or union of the given type.
struct GNUNET_MQ_Handle * mq
Definition: 003.c:5
Here is the caller graph for this function:

◆ free_session()

static int free_session ( void *  cls,
uint32_t  key,
void *  value 
)
static

Function called on each session to release associated state on transport disconnect.

Parameters
clsthe struct Client
keyunused (session_id)
valuea struct GNUNET_ATS_Session

Definition at line 589 of file gnunet-service-ats-new.c.

References GNUNET_ATS_Session::client, GNUNET_ATS_SolverFunctions::cls, GNUNET_ATS_Session::data, GNUNET_assert, GNUNET_free, GNUNET_OK, GNUNET_ATS_SolverFunctions::session_del, GNUNET_ATS_Session::sh, and value.

Referenced by client_disconnect_cb().

592 {
593  struct Client *c = cls;
594  struct GNUNET_ATS_Session *session = value;
595 
596  (void)key;
597  GNUNET_assert(c == session->client);
598  GNUNET_assert(NULL != session->sh);
600  session->sh,
601  &session->data);
602  session->sh = NULL;
603  GNUNET_free(session);
604  return GNUNET_OK;
605 }
Information we track per client.
struct GNUNET_ATS_SessionHandle * sh
Session state in the plugin.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:75
void(* session_del)(void *cls, struct GNUNET_ATS_SessionHandle *sh, const struct GNUNET_ATS_SessionData *data)
A session went away.
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
static char * value
Value of the record to add/remove.
Information about ongoing sessions of the transport client.
struct GNUNET_HashCode key
The key used in the DHT.
void * cls
Closure to pass to all solver functions in this struct.
struct GNUNET_ATS_SessionData data
Session data exposed to the plugin.
struct Client * client
The transport client that provided the session.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ client_disconnect_cb()

static void client_disconnect_cb ( void *  cls,
struct GNUNET_SERVICE_Client client,
void *  app_ctx 
)
static

A client disconnected from us.

Tear down the local client record.

Parameters
clsunused
clienthandle of the client
app_ctxour struct Client

Definition at line 617 of file gnunet-service-ats-new.c.

References Client::application, Client::client, GNUNET_ATS_SolverFunctions::cls, CT_APPLICATION, CT_NONE, CT_TRANSPORT, Client::details, free_session(), GNUNET_assert, GNUNET_CONTAINER_DLL_remove, GNUNET_CONTAINER_multihashmap32_destroy(), GNUNET_CONTAINER_multihashmap32_iterate(), GNUNET_free, GNUNET_ATS_SolverFunctions::preference_del, Client::transport, and Client::type.

Referenced by run().

620 {
621  struct Client *c = app_ctx;
622 
623  (void)cls;
624  GNUNET_assert(c->client == client);
625  switch (c->type)
626  {
627  case CT_NONE:
628  break;
629 
630  case CT_APPLICATION:
631  for (struct ClientPreference *cp = c->details.application.cp_head;
632  NULL != cp;
633  cp = c->details.application.cp_head)
634  {
636  cp->ph,
637  &cp->pref);
639  c->details.application.cp_tail,
640  cp);
641  GNUNET_free(cp);
642  }
643  break;
644 
645  case CT_TRANSPORT:
646  if (transport_client == c)
647  transport_client = NULL;
649  &free_session,
650  c);
652  break;
653  }
654  GNUNET_free(c);
655 }
#define GNUNET_CONTAINER_DLL_remove(head, tail, element)
Remove an element from a DLL.
struct Client::@0::@2 transport
Information we track per client.
We don't know yet.
struct GNUNET_SERVICE_Client * client
Service handle of the client.
int GNUNET_CONTAINER_multihashmap32_iterate(struct GNUNET_CONTAINER_MultiHashMap32 *map, GNUNET_CONTAINER_MulitHashMapIterator32Callback it, void *it_cls)
Iterate over all entries in the map.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static int free_session(void *cls, uint32_t key, void *value)
Function called on each session to release associated state on transport disconnect.
Preferences expressed by a client are kept in a DLL per client.
Transport service.
static struct Client * transport_client
The transport client (there can only be one at a time).
struct Client::@0::@1 application
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
void GNUNET_CONTAINER_multihashmap32_destroy(struct GNUNET_CONTAINER_MultiHashMap32 *map)
Destroy a 32-bit key hash map.
void * cls
Closure to pass to all solver functions in this struct.
enum ClientType type
Type of the client, initially CT_NONE.
void(* preference_del)(void *cls, struct GNUNET_ATS_PreferenceHandle *ph, const struct GNUNET_ATS_Preference *pref)
The plugin should end respecting a preference.
union Client::@0 details
Details depending on type.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ final_cleanup()

static void final_cleanup ( void *  cls)
static

Task run at the end during shutdown.

Parameters
clsunused

Definition at line 664 of file gnunet-service-ats-new.c.

References GNUNET_free, GNUNET_NO, GNUNET_PLUGIN_unload(), GNUNET_STATISTICS_destroy(), and plugin_name.

Referenced by cleanup_task().

665 {
666  (void)cls;
667  if (NULL != stats)
668  {
670  GNUNET_NO);
671  stats = NULL;
672  }
673  if (NULL != plugin)
674  {
676  plugin);
677  plugin = NULL;
678  }
679  if (NULL != plugin_name)
680  {
682  plugin_name = NULL;
683  }
684 }
static struct GNUNET_STATISTICS_Handle * stats
Handle for statistics.
#define GNUNET_NO
Definition: gnunet_common.h:78
void GNUNET_STATISTICS_destroy(struct GNUNET_STATISTICS_Handle *h, int sync_first)
Destroy a handle (free all state associated with it).
void * GNUNET_PLUGIN_unload(const char *library_name, void *arg)
Unload plugin (runs the "done" callback and returns whatever "done" returned).
Definition: plugin.c:255
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
static char * plugin_name
Solver plugin name as string.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanup_task()

static void cleanup_task ( void *  cls)
static

Task run during shutdown.

Parameters
clsunused

Definition at line 693 of file gnunet-service-ats-new.c.

References final_cleanup(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_log, and GNUNET_SCHEDULER_add_now().

Referenced by run().

694 {
695  (void)cls;
697  "ATS shutdown initiated\n");
699  NULL);
700 }
static void final_cleanup(void *cls)
Task run at the end during shutdown.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible.
Definition: scheduler.c:1264
#define GNUNET_log(kind,...)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

static void run ( void *  cls,
const struct GNUNET_CONFIGURATION_Handle cfg,
struct GNUNET_SERVICE_Handle service 
)
static

Process template requests.

Parameters
clsclosure
cfgconfiguration to use
servicethe initialized service

Definition at line 711 of file gnunet-service-ats-new.c.

References _, GNUNET_ATS_PluginEnvironment::allocate_cb, allocate_cb(), cfg, GNUNET_ATS_PluginEnvironment::cfg, cleanup_task(), client_connect_cb(), client_disconnect_cb(), GNUNET_ATS_PluginEnvironment::cls, GNUNET_asprintf(), GNUNET_CONFIGURATION_get_value_string(), GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_WARNING, GNUNET_free, GNUNET_log, GNUNET_MESSAGE_TYPE_ATS_SESSION_ADD, GNUNET_MESSAGE_TYPE_ATS_SESSION_ADD_INBOUND_ONLY, GNUNET_MESSAGE_TYPE_ATS_SESSION_DEL, GNUNET_MESSAGE_TYPE_ATS_SESSION_UPDATE, GNUNET_MESSAGE_TYPE_ATS_START, GNUNET_MESSAGE_TYPE_ATS_SUGGEST, GNUNET_MESSAGE_TYPE_ATS_SUGGEST_CANCEL, GNUNET_MQ_handler_end, GNUNET_MQ_hd_fixed_size, GNUNET_MQ_hd_var_size, GNUNET_PLUGIN_load(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), GNUNET_SERVICE_MAIN(), GNUNET_SERVICE_OPTION_NONE, GNUNET_STATISTICS_create(), GNUNET_strdup, GNUNET_SYSERR, plugin_name, start, stats, GNUNET_ATS_PluginEnvironment::stats, suggest_cb(), and GNUNET_ATS_PluginEnvironment::suggest_cb.

714 {
715  static struct GNUNET_ATS_PluginEnvironment env;
716  char *solver;
717 
719  cfg);
720  if (GNUNET_SYSERR ==
722  "ats",
723  "SOLVER",
724  &solver))
725  {
727  "No ATS solver configured, using 'simple' approach\n");
728  solver = GNUNET_strdup("simple");
729  }
731  NULL);
732  env.cls = NULL;
733  env.cfg = cfg;
734  env.stats = stats;
735  env.suggest_cb = &suggest_cb;
736  env.allocate_cb = &allocate_cb;
738  "libgnunet_plugin_ats2_%s",
739  solver);
740  GNUNET_free(solver);
741  if (NULL == (plugin = GNUNET_PLUGIN_load(plugin_name,
742  &env)))
743  {
745  _("Failed to initialize solver `%s'!\n"),
746  plugin_name);
748  return;
749  }
750 }
static struct GNUNET_STATISTICS_Handle * stats
Handle for statistics.
static void allocate_cb(void *cls, struct GNUNET_ATS_Session *session, const struct GNUNET_PeerIdentity *peer, struct GNUNET_BANDWIDTH_Value32NBO bw_in, struct GNUNET_BANDWIDTH_Value32NBO bw_out)
Function called by the solver to tell the transpor to allocate bandwidth for the specified session...
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received, or when GNUNET_SCHEDULER_shutdown() is being invoked.
Definition: scheduler.c:1284
struct GNUNET_STATISTICS_Handle * GNUNET_STATISTICS_create(const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg)
Get handle for the statistics service.
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:517
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
static void cleanup_task(void *cls)
Task run during shutdown.
static struct GNUNET_ATS_SolverFunctions * plugin
Our solver.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
static char * plugin_name
Solver plugin name as string.
int GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
struct GNUNET_MQ_Envelope * env
Definition: 005.c:1
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_log(kind,...)
void * GNUNET_PLUGIN_load(const char *library_name, void *arg)
Setup plugin (runs the "init" callback and returns whatever "init" returned).
Definition: plugin.c:206
The ATS plugin will pass a pointer to a struct of this type as to the initialization function of the ...
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:

◆ GNUNET_SERVICE_MAIN()

Define "main" method using service macro.

Referenced by run().

Here is the caller graph for this function:

Variable Documentation

◆ stats

struct GNUNET_STATISTICS_Handle* stats
static

◆ plugin

struct GNUNET_ATS_SolverFunctions* plugin
static

Our solver.

Definition at line 169 of file gnunet-service-ats-new.c.

Referenced by __attribute__(), ack_message_sent(), ack_proc(), add_plugin(), address_notification(), append_port(), broadcast_mst_cb(), client_connect(), client_delete_session(), client_receive_mst_cb(), client_run(), client_send_cb(), connect_notify(), create_macendpoint(), create_session(), delete_entries(), destroy_session_cb(), disconnect_and_free_it(), disconnect_notify(), do_transmit(), enqueue_fragment(), expi_proc(), expire_blocks(), expire_entries(), find_plugin(), fragmented_message_done(), free_macendpoint(), free_value(), get_session_delete_it(), GNUNET_BLOCK_context_destroy(), GNUNET_BLOCK_evaluate(), GNUNET_BLOCK_get_key(), GNUNET_BLOCK_group_create(), GNUNET_GNSRECORD_number_to_typename(), GNUNET_GNSRECORD_string_to_value(), GNUNET_GNSRECORD_typename_to_number(), GNUNET_GNSRECORD_value_to_string(), GNUNET_RECLAIM_ATTRIBUTE_number_to_typename(), GNUNET_RECLAIM_ATTRIBUTE_string_to_value(), GNUNET_RECLAIM_ATTRIBUTE_typename_to_number(), GNUNET_RECLAIM_ATTRIBUTE_value_to_string(), handle_helper_message(), handle_tcp_data(), handle_tcp_nat_probe(), handle_tcp_welcome(), heap_get_keys(), heap_plugin_del(), heap_plugin_estimate_size(), heap_plugin_get(), heap_plugin_get_closest(), heap_plugin_get_expiration(), heap_plugin_get_key(), heap_plugin_get_random(), heap_plugin_get_replication(), heap_plugin_get_zero_anonymity(), heap_plugin_put(), heap_plugin_remove_key(), http_client_plugin_get_network_for_address(), http_client_plugin_get_session(), http_client_plugin_peer_disconnect(), http_client_plugin_send(), http_client_plugin_session_disconnect(), http_client_plugin_setup_monitor(), iface_proc(), iterate_entries(), libgnunet_plugin_datacache_heap_done(), libgnunet_plugin_datacache_heap_init(), libgnunet_plugin_datacache_postgres_done(), libgnunet_plugin_datacache_postgres_init(), libgnunet_plugin_datacache_sqlite_done(), libgnunet_plugin_datacache_sqlite_init(), libgnunet_plugin_datacache_template_done(), libgnunet_plugin_datacache_template_init(), libgnunet_plugin_datastore_heap_done(), libgnunet_plugin_datastore_heap_init(), libgnunet_plugin_datastore_mysql_done(), libgnunet_plugin_datastore_mysql_init(), libgnunet_plugin_datastore_postgres_done(), libgnunet_plugin_datastore_postgres_init(), libgnunet_plugin_datastore_sqlite_done(), libgnunet_plugin_datastore_sqlite_init(), libgnunet_plugin_datastore_template_done(), libgnunet_plugin_datastore_template_init(), libgnunet_plugin_namecache_flat_done(), libgnunet_plugin_namecache_flat_init(), libgnunet_plugin_namecache_postgres_done(), libgnunet_plugin_namecache_postgres_init(), libgnunet_plugin_namecache_sqlite_done(), libgnunet_plugin_namecache_sqlite_init(), libgnunet_plugin_namestore_flat_done(), libgnunet_plugin_namestore_flat_init(), libgnunet_plugin_namestore_postgres_done(), libgnunet_plugin_namestore_postgres_init(), libgnunet_plugin_namestore_sqlite_done(), libgnunet_plugin_namestore_sqlite_init(), libgnunet_plugin_peerstore_flat_done(), libgnunet_plugin_peerstore_flat_init(), libgnunet_plugin_peerstore_sqlite_done(), libgnunet_plugin_peerstore_sqlite_init(), libgnunet_plugin_rest_config_done(), libgnunet_plugin_rest_config_init(), libgnunet_plugin_rest_copying_done(), libgnunet_plugin_rest_copying_init(), libgnunet_plugin_rest_credential_done(), libgnunet_plugin_rest_credential_init(), libgnunet_plugin_rest_gns_done(), libgnunet_plugin_rest_gns_init(), libgnunet_plugin_rest_identity_done(), libgnunet_plugin_rest_identity_init(), libgnunet_plugin_rest_namestore_done(), libgnunet_plugin_rest_namestore_init(), libgnunet_plugin_rest_openid_connect_done(), libgnunet_plugin_rest_openid_connect_init(), libgnunet_plugin_rest_peerinfo_done(), libgnunet_plugin_rest_peerinfo_init(), libgnunet_plugin_rest_reclaim_done(), libgnunet_plugin_rest_reclaim_init(), LIBGNUNET_PLUGIN_TRANSPORT_DONE(), libgnunet_plugin_transport_http_client_done(), libgnunet_plugin_transport_http_client_init(), libgnunet_plugin_transport_http_server_init(), LIBGNUNET_PLUGIN_TRANSPORT_INIT(), libgnunet_plugin_transport_tcp_done(), libgnunet_plugin_transport_tcp_init(), libgnunet_plugin_transport_udp_done(), libgnunet_plugin_transport_unix_done(), libgnunet_plugin_transport_unix_init(), mysql_plugin_drop(), mysql_plugin_estimate_size(), mysql_plugin_get_expiration(), mysql_plugin_get_key(), mysql_plugin_get_keys(), mysql_plugin_get_replication(), mysql_plugin_get_zero_anonymity(), mysql_plugin_put(), mysql_plugin_remove_key(), namecache_cache_block(), namecache_lookup_block(), namecache_postgres_cache_block(), namecache_postgres_lookup_block(), namecache_sqlite_cache_block(), namecache_sqlite_lookup_block(), namestore_flat_iterate_records(), namestore_flat_lookup_records(), namestore_flat_store_records(), namestore_flat_zone_to_name(), namestore_postgres_iterate_records(), namestore_postgres_lookup_records(), namestore_postgres_store_records(), namestore_postgres_zone_to_name(), namestore_sqlite_iterate_records(), namestore_sqlite_lookup_records(), namestore_sqlite_store_records(), namestore_sqlite_zone_to_name(), notify_send_probe(), peerstore_flat_delete_records(), peerstore_flat_expire_records(), peerstore_flat_iterate_records(), peerstore_flat_store_record(), peerstore_sqlite_delete_records(), peerstore_sqlite_expire_records(), peerstore_sqlite_iterate_records(), peerstore_sqlite_store_record(), postgres_plugin_del(), postgres_plugin_drop(), postgres_plugin_estimate_size(), postgres_plugin_get(), postgres_plugin_get_closest(), postgres_plugin_get_expiration(), postgres_plugin_get_key(), postgres_plugin_get_keys(), postgres_plugin_get_random(), postgres_plugin_get_replication(), postgres_plugin_get_zero_anonymity(), postgres_plugin_put(), postgres_plugin_remove_key(), process_data(), process_inbound_tokenized_messages(), process_result(), qc_fragment_sent(), qc_message_sent(), read_process_fragment(), repl_proc(), send_hello_beacon(), send_session_info_iter(), send_with_fragmentation(), server_lookup_connection(), server_wake_up(), session_disconnect_it(), session_timeout(), sqlite_plugin_del(), sqlite_plugin_drop(), sqlite_plugin_estimate_size(), sqlite_plugin_get(), sqlite_plugin_get_closest(), sqlite_plugin_get_expiration(), sqlite_plugin_get_key(), sqlite_plugin_get_keys(), sqlite_plugin_get_random(), sqlite_plugin_get_replication(), sqlite_plugin_get_zero_anonymity(), sqlite_plugin_put(), sqlite_plugin_remove_key(), tcp_nat_port_map_callback(), tcp_plugin_address_pretty_printer(), tcp_plugin_check_address(), tcp_plugin_disconnect(), tcp_plugin_disconnect_session(), tcp_plugin_get_network_for_address(), tcp_plugin_get_session(), tcp_plugin_send(), tcp_plugin_setup_monitor(), tcp_plugin_string_to_address(), try_connection_reversal(), udp_broadcast_receive(), udp_disconnect(), udp_disconnect_session(), udp_ipv4_broadcast_send(), udp_ipv6_broadcast_send(), udp_nat_port_map_callback(), udp_plugin_address_pretty_printer(), udp_plugin_check_address(), udp_plugin_create_session(), udp_plugin_get_network_for_address(), udp_plugin_get_session(), udp_plugin_lookup_session(), udp_plugin_select_v4(), udp_plugin_select_v6(), udp_plugin_send(), udp_plugin_setup_monitor(), udp_plugin_update_session_timeout(), udp_string_to_address(), unix_plugin_check_address(), unix_plugin_get_session(), unix_plugin_peer_disconnect(), unix_plugin_select_read(), unix_plugin_select_write(), unix_plugin_send(), unix_plugin_session_disconnect(), unix_plugin_setup_monitor(), unix_plugin_string_to_address(), unix_plugin_update_session_timeout(), unix_real_send(), unix_transport_server_start(), wlan_data_message_handler(), wlan_plugin_address_suggested(), wlan_plugin_disconnect_peer(), wlan_plugin_disconnect_session(), wlan_plugin_get_session(), wlan_plugin_send(), wlan_plugin_setup_monitor(), and wlan_plugin_string_to_address().

◆ plugin_name

char* plugin_name
static

◆ transport_client

struct Client* transport_client
static

The transport client (there can only be one at a time).

Definition at line 179 of file gnunet-service-ats-new.c.

Referenced by allocate_cb().