GNUnet  0.10.x
Functions
service

Bandwidth allocation. More...

Functions

struct GNUNET_TRANSPORT_ApplicationHandleGNUNET_TRANSPORT_application_init (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Initialize the TRANSPORT application client handle. More...
 
void GNUNET_TRANSPORT_application_done (struct GNUNET_TRANSPORT_ApplicationHandle *ch)
 Shutdown TRANSPORT application client. More...
 
struct GNUNET_TRANSPORT_ApplicationSuggestHandleGNUNET_TRANSPORT_application_suggest (struct GNUNET_TRANSPORT_ApplicationHandle *ch, const struct GNUNET_PeerIdentity *peer, enum GNUNET_MQ_PriorityPreferences pk, struct GNUNET_BANDWIDTH_Value32NBO bw)
 An application would like TRANSPORT to connect to a peer. More...
 
void GNUNET_TRANSPORT_application_suggest_cancel (struct GNUNET_TRANSPORT_ApplicationSuggestHandle *sh)
 We no longer care about being connected to a peer. More...
 
void GNUNET_TRANSPORT_application_validate (struct GNUNET_TRANSPORT_ApplicationHandle *ch, const struct GNUNET_PeerIdentity *peer, enum GNUNET_NetworkType nt, const char *addr)
 An application (or a communicator) has received a HELLO (or other address data of another peer) and wants TRANSPORT to validate that the address is correct. More...
 

Detailed Description

Bandwidth allocation.

Function Documentation

◆ GNUNET_TRANSPORT_application_init()

struct GNUNET_TRANSPORT_ApplicationHandle* GNUNET_TRANSPORT_application_init ( const struct GNUNET_CONFIGURATION_Handle cfg)

Initialize the TRANSPORT application client handle.

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

Initialize the TRANSPORT application client handle.

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

Definition at line 217 of file transport_api2_application.c.

References GNUNET_TRANSPORT_ApplicationHandle::cfg, cfg, GNUNET_TRANSPORT_ApplicationSuggestHandle::ch, GNUNET_CONTAINER_multipeermap_create(), GNUNET_new, GNUNET_YES, reconnect(), and GNUNET_TRANSPORT_ApplicationHandle::sug_requests.

Referenced by run().

219 {
221 
223  ch->cfg = cfg;
225  reconnect(ch);
226  return ch;
227 }
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
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_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).
const struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
#define GNUNET_YES
Definition: gnunet_common.h:77
static void reconnect(struct GNUNET_TRANSPORT_ApplicationHandle *ch)
Re-establish the connection to the TRANSPORT service.
Handle to the TRANSPORT subsystem for application management.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_TRANSPORT_application_done()

void GNUNET_TRANSPORT_application_done ( struct GNUNET_TRANSPORT_ApplicationHandle ch)

Shutdown TRANSPORT application client.

Parameters
chhandle to destroy

Shutdown TRANSPORT application client.

Parameters
chhandle to release

Definition at line 255 of file transport_api2_application.c.

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

Referenced by do_shutdown().

257 {
258  if (NULL != ch->mq)
259  {
260  GNUNET_MQ_destroy(ch->mq);
261  ch->mq = NULL;
262  }
263  if (NULL != ch->task)
264  {
266  ch->task = NULL;
267  }
270  NULL);
272  GNUNET_free(ch);
273 }
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_CONTAINER_multipeermap_destroy(struct GNUNET_CONTAINER_MultiPeerMap *map)
Destroy a hash map.
static int free_sug_handle(void *cls, const struct GNUNET_PeerIdentity *key, void *value)
Function called to free all struct GNUNET_TRANSPORT_ApplicationSuggestHandles in the map...
struct GNUNET_MQ_Handle * mq
Message queue for sending requests to the TRANSPORT service.
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_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.
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_TRANSPORT_application_suggest()

struct GNUNET_TRANSPORT_ApplicationSuggestHandle* GNUNET_TRANSPORT_application_suggest ( struct GNUNET_TRANSPORT_ApplicationHandle ch,
const struct GNUNET_PeerIdentity peer,
enum GNUNET_MQ_PriorityPreferences  pk,
struct GNUNET_BANDWIDTH_Value32NBO  bw 
)

An application would like TRANSPORT to connect to a peer.

Parameters
chhandle
peeridentity of the peer we need an address for
pkwhat kind of application will the application require (can be GNUNET_MQ_PRIO_BACKGROUND, 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 287 of file transport_api2_application.c.

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

292 {
294 
296  s->ch = ch;
297  s->id = *peer;
298  s->pk = pk;
299  s->bw = bw;
301  ch->sug_requests,
302  &s->id,
303  s,
306  "Requesting TRANSPORT to suggest address for `%s'\n",
307  GNUNET_i2s(peer));
308  if (NULL == ch->mq)
309  return s;
311  return s;
312 }
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_TRANSPORT_ApplicationHandle * ch
Connecitivity handle this suggestion handle belongs to.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
Handle for TRANSPORT 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.
#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.
#define LOG(kind,...)
enum GNUNET_MQ_PriorityPreferences pk
What preference is being expressed?
static int transmit_suggestion(void *cls, const struct GNUNET_PeerIdentity *peer, void *value)
Transmit request for an address suggestion.
struct GNUNET_MQ_Handle * mq
Message queue for sending requests to the TRANSPORT service.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
struct GNUNET_PeerIdentity id
ID of the peer for which address suggestion was requested.
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.
struct GNUNET_BANDWIDTH_Value32NBO bw
How much bandwidth does the client expect?
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:

◆ GNUNET_TRANSPORT_application_suggest_cancel()

void GNUNET_TRANSPORT_application_suggest_cancel ( struct GNUNET_TRANSPORT_ApplicationSuggestHandle sh)

We no longer care about being connected to a peer.

Parameters
shhandle to stop

Definition at line 321 of file transport_api2_application.c.

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

323 {
325  struct GNUNET_MQ_Envelope *ev;
326  struct ExpressPreferenceMessage *m;
327 
329  "Telling TRANSPORT we no longer care for an address for `%s'\n",
330  GNUNET_i2s(&sh->id));
332  GNUNET_OK ==
334  if (NULL == ch->mq)
335  {
336  GNUNET_free(sh);
337  return;
338  }
340  m->pk = htonl((uint32_t)sh->pk);
341  m->bw = sh->bw;
342  m->peer = sh->id;
343  GNUNET_MQ_send(ch->mq, ev);
344  GNUNET_free(sh);
345 }
static struct GNUNET_CADET_Channel * ch
Channel handle.
Definition: gnunet-cadet.c:117
struct GNUNET_TRANSPORT_ApplicationHandle * ch
Connecitivity handle this suggestion handle belongs to.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
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_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
#define LOG(kind,...)
enum GNUNET_MQ_PriorityPreferences pk
What preference is being expressed?
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
struct GNUNET_MQ_Handle * mq
Message queue for sending requests to the TRANSPORT service.
#define GNUNET_MESSAGE_TYPE_TRANSPORT_SUGGEST_CANCEL
Type of the 'struct ExpressPreferenceMessage' send by clients to TRANSPORT to abandon bandwidth prefe...
struct GNUNET_PeerIdentity id
ID of the peer for which address suggestion was requested.
struct GNUNET_BANDWIDTH_Value32NBO bw
How much bandwidth does the client expect?
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 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
Handle to the TRANSPORT subsystem for application management.
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
Here is the call graph for this function:

◆ GNUNET_TRANSPORT_application_validate()

void GNUNET_TRANSPORT_application_validate ( struct GNUNET_TRANSPORT_ApplicationHandle ch,
const struct GNUNET_PeerIdentity peer,
enum GNUNET_NetworkType  nt,
const char *  addr 
)

An application (or a communicator) has received a HELLO (or other address data of another peer) and wants TRANSPORT to validate that the address is correct.

The result is NOT returned, in fact TRANSPORT may do nothing (i.e. if it has too many active validations or recently tried this one already). If the addr validates, TRANSPORT will persist the address with PEERSTORE.

Parameters
chhandle
peeridentity of the peer we have an address for
ntnetwork type of addr (as claimed by the other peer); used by TRANSPORT to avoid trying addr's that really cannot work due to network type missmatches
addraddress to validate

Definition at line 364 of file transport_api2_application.c.

References GNUNET_ERROR_TYPE_WARNING, GNUNET_i2s(), GNUNET_log, GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_HELLO_VALIDATION, GNUNET_MQ_msg_extra, GNUNET_MQ_send(), m, GNUNET_TRANSPORT_ApplicationHandle::mq, and peer.

Referenced by sock_read().

369 {
370  struct GNUNET_MQ_Envelope *ev;
371  struct RequestHelloValidationMessage *m;
372  size_t alen;
373 
374  if (NULL == ch->mq)
375  {
376  GNUNET_log(
378  "Address validation for %s:%s skipped as transport is not connected\n",
379  GNUNET_i2s(peer),
380  addr);
381  return;
382  }
383  alen = strlen(addr) + 1;
384  ev =
386  alen,
388  m->peer = *peer;
389  m->nt = htonl((uint32_t)nt);
390  memcpy(&m[1], addr, alen);
391  GNUNET_MQ_send(ch->mq, ev);
392 }
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
Definition: gnunet-arm.c:99
#define GNUNET_MESSAGE_TYPE_TRANSPORT_REQUEST_HELLO_VALIDATION
Type of the 'struct RequestHelloValidationMessage' send by clients to TRANSPORT to trigger validation...
#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_Handle * mq
Message queue for sending requests to the TRANSPORT service.
static struct GNUNET_NAT_AUTO_Test * nt
Handle to a NAT test operation.
struct GNUNET_TESTBED_Peer * peer
The peer associated with this model.
#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:351
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: